openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #18535
[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:
Tim Bentley (trb143)
Related bugs:
Bug #841752 in OpenLP: "song editor: increment verse number automatically"
https://bugs.launchpad.net/openlp/+bug/841752
For more details, see:
https://code.launchpad.net/~erik-lundin/openlp/song-edit/+merge/141543
Fixed bug #841752 'song editor: increment verse number automatically'.
* Automatically set the number of the verse/chorus etc. next to be inserted to the previous number found in the text plus one.
* Don't update the verse type automatically. This is intentional, since I find that I more often need to insert a tag of the same verse type I last inserted, rather than the previous verse type found in the text.
* Let the different verse types only care about found numbers of the same kind (a chorus tag shouldn't care about verses, bridges or any other tags).
* Bonus: get rid of some duplicate code.
* Tested while adding hundreds of songs.
--
https://code.launchpad.net/~erik-lundin/openlp/song-edit/+merge/141543
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp/plugins/songs/forms/editverseform.py'
--- openlp/plugins/songs/forms/editverseform.py 2012-12-29 20:56:56 +0000
+++ openlp/plugins/songs/forms/editverseform.py 2013-01-01 03:31:19 +0000
@@ -93,6 +93,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.
@@ -116,43 +122,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 = 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