forked from openlp/openlp
Fix bug 1310523 by not allowing more than 26 equal verse names
bzr-revno: 2193 Fixes: https://launchpad.net/bugs/1310523
This commit is contained in:
commit
725be17e7e
@ -723,19 +723,32 @@ 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
|
||||
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(
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user