← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~orangeshirt/openlp/bibles_fixes into lp:openlp

 

Armin Köhler has proposed merging lp:~orangeshirt/openlp/bibles_fixes into lp:openlp.

Requested reviews:
  Raoul Snyman (raoul-snyman)
Related bugs:
  Bug #825205 in OpenLP: "Keep/restore selected book, chapters and verses when changing the bible translation"
  https://bugs.launchpad.net/openlp/+bug/825205

For more details, see:
https://code.launchpad.net/~orangeshirt/openlp/bibles_fixes/+merge/103167

fix bug 825205 - Keep/restore selected book, chapters and verses when changing the bible translation in advanced search
-- 
https://code.launchpad.net/~orangeshirt/openlp/bibles_fixes/+merge/103167
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp/plugins/bibles/lib/mediaitem.py'
--- openlp/plugins/bibles/lib/mediaitem.py	2012-04-12 20:58:11 +0000
+++ openlp/plugins/bibles/lib/mediaitem.py	2012-04-23 20:27:26 +0000
@@ -408,7 +408,7 @@
             self.plugin.appStartup()
         self.updateAutoCompleter()
 
-    def initialiseAdvancedBible(self, bible):
+    def initialiseAdvancedBible(self, bible, last_book_id=None):
         """
         This initialises the given bible, which means that its book names and
         their chapter numbers is added to the combo boxes on the
@@ -417,8 +417,12 @@
 
         ``bible``
             The bible to initialise (unicode).
+        
+        ``last_book_id``
+            The "book reference id" of the book which is choosen at the moment.
+            (int)
         """
-        log.debug(u'initialiseAdvancedBible %s', bible)
+        log.debug(u'initialiseAdvancedBible %s, %s', bible, last_book_id)
         book_data = self.plugin.manager.get_books(bible)
         secondbible = unicode(self.advancedSecondComboBox.currentText())
         if secondbible != u'':
@@ -432,6 +436,7 @@
             book_data = book_data_temp
         self.advancedBookComboBox.clear()
         first = True
+        initialise_chapter_verse = False
         language_selection = self.plugin.manager.get_language_selection(bible)
         booknames = BibleStrings().Booknames
         for book in book_data:
@@ -451,8 +456,19 @@
                 row, QtCore.QVariant(book[u'book_reference_id']))
             if first:
                 first = False
-                self.initialiseChapterVerse(bible, book[u'name'],
-                    book[u'book_reference_id'])
+                first_book = book
+                initialise_chapter_verse = True
+            if last_book_id and last_book_id == int(book[u'book_reference_id']):
+                index = self.advancedBookComboBox.findData(
+                    QtCore.QVariant(book[u'book_reference_id']))
+                if index == -1:
+                    # Not Found.
+                    index = 0
+                self.advancedBookComboBox.setCurrentIndex(index)
+                initialise_chapter_verse = False
+        if initialise_chapter_verse:
+            self.initialiseChapterVerse(bible, first_book[u'name'],
+                first_book[u'book_reference_id'])
 
     def initialiseChapterVerse(self, bible, book, book_ref_id):
         log.debug(u'initialiseChapterVerse %s, %s, %s', bible, book,
@@ -597,11 +613,15 @@
         QtCore.QSettings().setValue(self.settingsSection + u'/advanced bible',
             QtCore.QVariant(self.advancedVersionComboBox.currentText()))
         self.initialiseAdvancedBible(
-            unicode(self.advancedVersionComboBox.currentText()))
+            unicode(self.advancedVersionComboBox.currentText()),
+            self.advancedBookComboBox.itemData(
+                int(self.advancedBookComboBox.currentIndex())))
 
     def onAdvancedSecondComboBox(self):
         self.initialiseAdvancedBible(
-            unicode(self.advancedVersionComboBox.currentText()))
+            unicode(self.advancedVersionComboBox.currentText()),
+            self.advancedBookComboBox.itemData(
+                int(self.advancedBookComboBox.currentIndex())))
 
     def onAdvancedBookComboBox(self):
         item = int(self.advancedBookComboBox.currentIndex())


Follow ups