← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~sam92/openlp/verseorder-import into lp:openlp

 

Samuel Mehrbrodt has proposed merging lp:~sam92/openlp/verseorder-import into lp:openlp.

Requested reviews:
  Tim Bentley (trb143)
  Raoul Snyman (raoul-snyman)

For more details, see:
https://code.launchpad.net/~sam92/openlp/verseorder-import/+merge/215823

Update verse order when verse names change (OpenLyrics Import)
-- 
https://code.launchpad.net/~sam92/openlp/verseorder-import/+merge/215823
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp/plugins/songs/lib/xml.py'
--- openlp/plugins/songs/lib/xml.py	2014-03-21 21:38:08 +0000
+++ openlp/plugins/songs/lib/xml.py	2014-04-15 08:16:32 +0000
@@ -675,6 +675,7 @@
         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 @@
             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):
         """

=== modified file 'tests/functional/openlp_core_lib/test_ui.py'
--- tests/functional/openlp_core_lib/test_ui.py	2014-04-08 21:20:51 +0000
+++ tests/functional/openlp_core_lib/test_ui.py	2014-04-15 08:16:32 +0000
@@ -98,3 +98,18 @@
         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())


Follow ups