forked from openlp/openlp
parent
938f59416d
commit
a7bdb9dfa0
@ -237,11 +237,13 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog, RegistryProperties):
|
|||||||
return False
|
return False
|
||||||
# Validate tags (lp#1199639)
|
# Validate tags (lp#1199639)
|
||||||
misplaced_tags = []
|
misplaced_tags = []
|
||||||
|
verse_tags = []
|
||||||
for i in range(self.verse_list_widget.rowCount()):
|
for i in range(self.verse_list_widget.rowCount()):
|
||||||
item = self.verse_list_widget.item(i, 0)
|
item = self.verse_list_widget.item(i, 0)
|
||||||
tags = self.find_tags.findall(item.text())
|
tags = self.find_tags.findall(item.text())
|
||||||
if not self._validate_tags(tags):
|
|
||||||
field = item.data(QtCore.Qt.UserRole)
|
field = item.data(QtCore.Qt.UserRole)
|
||||||
|
verse_tags.append(field)
|
||||||
|
if not self._validate_tags(tags):
|
||||||
misplaced_tags.append('%s %s' % (VerseType.translated_name(field[0]), field[1:]))
|
misplaced_tags.append('%s %s' % (VerseType.translated_name(field[0]), field[1:]))
|
||||||
if misplaced_tags:
|
if misplaced_tags:
|
||||||
critical_error_message_box(
|
critical_error_message_box(
|
||||||
@ -249,6 +251,17 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog, RegistryProperties):
|
|||||||
'There are misplaced formatting tags in the following verses:\n\n%s\n\n'
|
'There are misplaced formatting tags in the following verses:\n\n%s\n\n'
|
||||||
'Please correct these tags before continuing.' % ', '.join(misplaced_tags)))
|
'Please correct these tags before continuing.' % ', '.join(misplaced_tags)))
|
||||||
return False
|
return False
|
||||||
|
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
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def _validate_tags(self, _tags):
|
def _validate_tags(self, _tags):
|
||||||
|
Loading…
Reference in New Issue
Block a user