Update verse order when verse names change (OpenLyrics Import)

bzr-revno: 2357
This commit is contained in:
Samuel Mehrbrodt 2014-04-15 22:46:54 +02:00 committed by Raoul Snyman
commit 8c18659adb
2 changed files with 22 additions and 2 deletions

View File

@ -675,6 +675,7 @@ class OpenLyrics(object):
sxml = SongXML()
verses = {}
verse_def_list = []
verse_order = self._text(properties.verseOrder).split(' ') if hasattr(properties, 'verseOrder') else []
try:
lyrics = song_xml.lyrics
except AttributeError:
@ -717,13 +718,17 @@ class OpenLyrics(object):
else:
verses[(verse_tag, verse_number, lang, translit, verse_part)] = text
verse_def_list.append((verse_tag, verse_number, lang, translit, verse_part))
# Update verse order when the verse name has changed
if verse_def != verse_tag + verse_number + verse_part:
for i in range(len(verse_order)):
if verse_order[i] == verse_def:
verse_order[i] = verse_tag + verse_number + verse_part
# We have to use a list to keep the order, as dicts are not sorted.
for verse in verse_def_list:
sxml.add_verse_to_lyrics(verse[0], verse[1], verses[verse], verse[2])
song_obj.lyrics = str(sxml.extract_xml(), 'utf-8')
# Process verse order
if hasattr(properties, 'verseOrder'):
song_obj.verse_order = self._text(properties.verseOrder)
song_obj.verse_order = ' '.join(verse_order)
def _process_songbooks(self, properties, song):
"""

View File

@ -98,3 +98,18 @@ class TestUi(TestCase):
self.assertEqual(combo, label.buddy())
for text in [UiStrings().Top, UiStrings().Middle, UiStrings().Bottom]:
self.assertTrue(combo.findText(text) >= 0)
def test_create_horizontal_adjusting_combo_box(self):
"""
Test creating a horizontal adjusting combo box
"""
# GIVEN: A dialog
dialog = QtGui.QDialog()
# WHEN: We create the combobox
combo = create_horizontal_adjusting_combo_box(dialog, 'combo1')
# THEN: We should get a ComboBox
self.assertIsInstance(combo, QtGui.QComboBox)
self.assertEqual('combo1', combo.objectName())
self.assertEqual(QtGui.QComboBox.AdjustToMinimumContentsLength, combo.sizeAdjustPolicy())