← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~erik-lundin/openlp/song-edit into lp:openlp

 

Erik Lundin has proposed merging lp:~erik-lundin/openlp/song-edit into lp:openlp.

Requested reviews:
  OpenLP Core (openlp-core)

For more details, see:
https://code.launchpad.net/~erik-lundin/openlp/song-edit/+merge/123458

I propose a change to the way the verse number spinbox in the verse edit form is auto-updated. This occurs when moving the cursor or the verse type is changed, and the verse type and verse number is automatically changed to correspond to the preceding verse header (or chorus etc.). However, most of the time, the verse number you want to insert is the current verse number plus one. I find myself inserting the verse header, writing or pasting the verse contents, clicking the spinbox to increase the verse number by 1, clicking insert, writing or pasting the verse contents, etcetera.

My idea of how it should work is that the verse number spinbox should hold the value of the preceding verse header plus one, and the verse type shouldn't automatically change. This would let you insert the header, write or paste the verse contents, click insert (or press the corresponding keyboard shortcut), write or paste the verse contents, etcetera. I have tried this for adding quite a bunch of songs now, and I find it more efficient and natural.

I'm not sure why so many files have changed in the branch. I merged back the latest changes from trunk to be sure my branch was up to date and no conflicts would occur (I'm used to SVN but not so much to Bazaar). The only file I've altered is 'editverseform.py'.
-- 
https://code.launchpad.net/~erik-lundin/openlp/song-edit/+merge/123458
Your team OpenLP Core is requested to review the proposed merge of lp:~erik-lundin/openlp/song-edit into lp:openlp.
=== modified file 'openlp/plugins/songs/forms/editverseform.py'
--- openlp/plugins/songs/forms/editverseform.py	2012-08-25 19:23:40 +0000
+++ openlp/plugins/songs/forms/editverseform.py	2012-09-09 21:50:26 +0000
@@ -92,6 +92,12 @@
             self.verseNumberBox.value())
 
     def onVerseTypeComboBoxChanged(self):
+        self.updateSuggestedVerseNumber()
+
+    def onCursorPositionChanged(self):
+        self.updateSuggestedVerseNumber()
+
+    def updateSuggestedVerseNumber(self):
         """
         Adjusts the verse number SpinBox in regard to the selected verse type
         and the cursor's position.
@@ -115,43 +121,10 @@
         if match:
             verse_tag = match.group(1)
             try:
-                verse_num = int(match.group(2))
+                verse_num = int(match.group(2)) + 1
             except ValueError:
                 verse_num = 1
-            if VerseType.from_loose_input(verse_tag, False):
-                self.verseNumberBox.setValue(verse_num)
-
-    def onCursorPositionChanged(self):
-        """
-        Determines the previous verse type and number in regard to the cursor's
-        position and adjusts the ComboBox and SpinBox to these values.
-        """
-        position = self.verseTextEdit.textCursor().position()
-        text = unicode(self.verseTextEdit.toPlainText())
-        if not text:
-            return
-        if text.rfind(u'[', 0, position) > text.rfind(u']', 0, position) and \
-            text.find(u']', position) < text.find(u'[', position):
-            return
-        position = text.rfind(u'---[', 0, position)
-        if position == -1:
-            return
-        text = text[position:]
-        position = text.find(u']---')
-        if position == -1:
-            return
-        text = text[:position + 4]
-        match = VERSE_REGEX.match(text)
-        if match:
-            verse_type = match.group(1)
-            verse_type_index = VerseType.from_loose_input(verse_type, None)
-            try:
-                verse_number = int(match.group(2))
-            except ValueError:
-                verse_number = 1
-            if verse_type_index is not None:
-                self.verseTypeComboBox.setCurrentIndex(verse_type_index)
-                self.verseNumberBox.setValue(verse_number)
+            self.verseNumberBox.setValue(verse_num)
 
     def setVerse(self, text, single=False,
         tag=u'%s1' % VerseType.Tags[VerseType.Verse]):


Follow ups