From 8662e76ccf1754c1fe7c16597834e5bf7fca6eb5 Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Mon, 21 Apr 2014 11:18:52 +0200 Subject: [PATCH 1/3] Fix bug 1310523 Fixes: https://launchpad.net/bugs/1310523 --- openlp/plugins/songs/lib/xml.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/songs/lib/xml.py b/openlp/plugins/songs/lib/xml.py index d53bda886..06df206fb 100644 --- a/openlp/plugins/songs/lib/xml.py +++ b/openlp/plugins/songs/lib/xml.py @@ -360,9 +360,9 @@ class OpenLyrics(object): verse_tag = verse[0][u'type'][0].lower() verse_number = verse[0][u'label'] verse_def = verse_tag + verse_number - verse_tags.append(verse_def) # Create the letter from the number of duplicates - verse[0][u'suffix'] = chr(96 + verse_tags.count(verse_def)) + verse[0][u'suffix'] = chr(97 + (verse_tags.count(verse_def) % 26)) + verse_tags.append(verse_def) # If the verse tag is a duplicate use the suffix letter for verse in verse_list: verse_tag = verse[0][u'type'][0].lower() From c4b4df4990e1f87f5ec72c92c774f924dd0f41aa Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Mon, 21 Apr 2014 15:40:30 +0200 Subject: [PATCH 2/3] Check on song edit form for equal verse names --- openlp/plugins/songs/forms/editsongform.py | 24 +++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 781cf691f..793f7af89 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -723,19 +723,33 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): return False cnt_errors = 0 error_list = '' - verse_tag = [] - verse_num = [] + verse_tags = [] + wrong_verse_tags = [] + wrong_verse_nums = [] for i in range(self.verseListWidget.rowCount()): item = self.verseListWidget.item(i, 0) tags = self.find_tags.findall(item.text()) + verse_tags.append(unicode(item.data(QtCore.Qt.UserRole).toString())) if self._validate_tags(tags) == False: field = unicode(item.data(QtCore.Qt.UserRole).toString()) - verse_tag.append(VerseType.translated_name(field[0])) - verse_num.append(field[1:]) + wrong_verse_tags.append(VerseType.translated_name(field[0])) + wrong_verse_nums.append(field[1:]) cnt_errors += 1; + for tag in verse_tags: + if verse_tags.count(tag) > 26: + # lp#1310523: OpenLyrics allows only a-z variants of one verse: + # http://openlyrics.info/dataformat.html#verse-name + print tag + critical_error_message_box( + message=translate('SongsPlugin.EditSongForm', + 'You have %(count)s verses named %(name)s %(number)s. ' + 'You can have at most 26 verses with the same name' % + {'count': verse_tags.count(tag), 'name': VerseType.translated_name(tag[0]), + 'number': tag[1:]})) + return False if cnt_errors > 0: for i in range(cnt_errors): - error_list += '%s %s' % (verse_tag[i], verse_num[i]) + error_list += '%s %s' % (wrong_verse_tags[i], wrong_verse_nums[i]) if i < cnt_errors-1: error_list += ', ' critical_error_message_box( From 20e9c1dd4c1d83aa233a26d965ba6de9632c58e2 Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Mon, 21 Apr 2014 15:41:18 +0200 Subject: [PATCH 3/3] Remove print --- openlp/plugins/songs/forms/editsongform.py | 1 - 1 file changed, 1 deletion(-) diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 793f7af89..8cbfb1c07 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -739,7 +739,6 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): if verse_tags.count(tag) > 26: # lp#1310523: OpenLyrics allows only a-z variants of one verse: # http://openlyrics.info/dataformat.html#verse-name - print tag critical_error_message_box( message=translate('SongsPlugin.EditSongForm', 'You have %(count)s verses named %(name)s %(number)s. '