← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~googol-hush/openlp/bibles into lp:openlp

 

Andreas Preikschat has proposed merging lp:~googol-hush/openlp/bibles into lp:openlp.

Requested reviews:
  Tim Bentley (trb143)
Related bugs:
  #609355 Dual language bible search results and service items don't indicate duality
  https://bugs.launchpad.net/bugs/609355
  #634533 Bible passage in service not complete
  https://bugs.launchpad.net/bugs/634533


Hello!

This brings the following changes:
- bible items cannot be extended any longer
- dual and non-dual verses cannot be mixed (Media Manager/Service Manager)
- changing the "Keep/Clear" Drop-Down-List will delete all results (to prevent edge cases)
- Bible item title in the service manager contains all bible passages (separated by a comma) bug #634533 and bug #609355


-- 
https://code.launchpad.net/~googol-hush/openlp/bibles/+merge/35936
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp/plugins/bibles/forms/importwizardform.py'
--- openlp/plugins/bibles/forms/importwizardform.py	2010-09-18 15:24:39 +0000
+++ openlp/plugins/bibles/forms/importwizardform.py	2010-09-18 21:36:50 +0000
@@ -126,29 +126,29 @@
                 if self.field(u'osis_location').toString() == u'':
                     QtGui.QMessageBox.critical(self,
                         translate('BiblesPlugin.ImportWizardForm',
-                            'Invalid Bible Location'),
+                        'Invalid Bible Location'),
                         translate('BiblesPlugin.ImportWizardForm',
-                            'You need to specify a file to import your '
-                            'Bible from.'))
+                        'You need to specify a file to import your '
+                        'Bible from.'))
                     self.OSISLocationEdit.setFocus()
                     return False
             elif self.field(u'source_format').toInt()[0] == BibleFormat.CSV:
                 if self.field(u'csv_booksfile').toString() == u'':
                     QtGui.QMessageBox.critical(self,
                         translate('BiblesPlugin.ImportWizardForm',
-                            'Invalid Books File'),
+                        'Invalid Books File'),
                         translate('BiblesPlugin.ImportWizardForm',
-                            'You need to specify a file with books of '
-                            'the Bible to use in the import.'))
+                        'You need to specify a file with books of '
+                        'the Bible to use in the import.'))
                     self.BooksLocationEdit.setFocus()
                     return False
                 elif self.field(u'csv_versefile').toString() == u'':
                     QtGui.QMessageBox.critical(self,
                         translate('BiblesPlugin.ImportWizardForm',
-                            'Invalid Verse File'),
+                        'Invalid Verse File'),
                         translate('BiblesPlugin.ImportWizardForm',
-                            'You need to specify a file of Bible '
-                            'verses to import.'))
+                        'You need to specify a file of Bible '
+                        'verses to import.'))
                     self.CsvVerseLocationEdit.setFocus()
                     return False
             elif self.field(u'source_format').toInt()[0] == \
@@ -156,10 +156,10 @@
                 if self.field(u'opensong_file').toString() == u'':
                     QtGui.QMessageBox.critical(self,
                         translate('BiblesPlugin.ImportWizardForm',
-                            'Invalid OpenSong Bible'),
+                        'Invalid OpenSong Bible'),
                         translate('BiblesPlugin.ImportWizardForm',
-                            'You need to specify an OpenSong Bible '
-                            'file to import.'))
+                        'You need to specify an OpenSong Bible '
+                        'file to import.'))
                     self.OpenSongFileEdit.setFocus()
                     return False
             return True
@@ -171,29 +171,40 @@
             if license_version == u'':
                 QtGui.QMessageBox.critical(self,
                     translate('BiblesPlugin.ImportWizardForm',
-                        'Empty Version Name'),
+                    'Empty Version Name'),
                     translate('BiblesPlugin.ImportWizardForm',
-                        'You need to specify a version name for your '
-                        'Bible.'))
+                    'You need to specify a version name for your Bible.'))
                 self.VersionNameEdit.setFocus()
                 return False
             elif license_copyright == u'':
                 QtGui.QMessageBox.critical(self,
                     translate('BiblesPlugin.ImportWizardForm',
-                        'Empty Copyright'),
+                    'Empty Copyright'),
                     translate('BiblesPlugin.ImportWizardForm',
+<<<<<<< TREE
                         'You need to set a copyright for your Bible. '
                         'Bibles in the Public Domain need to be marked as '
                         'such.'))
+=======
+                    'You need to set a copyright for your Bible! '
+                    'Bibles in the Public Domain need to be marked as such.'))
+>>>>>>> MERGE-SOURCE
                 self.CopyrightEdit.setFocus()
                 return False
             elif self.manager.exists(license_version):
                 QtGui.QMessageBox.critical(self,
+<<<<<<< TREE
                     translate('BiblesPlugin.ImportWizardForm',
                         'Bible Exists'),
                     translate('BiblesPlugin.ImportWizardForm',
                         'This Bible already exists. Please import '
                         'a different Bible or first delete the existing one.'))
+=======
+                    translate('BiblesPlugin.ImportWizardForm', 'Bible Exists'),
+                    translate('BiblesPlugin.ImportWizardForm',
+                    'This Bible already exists! Please import '
+                    'a different Bible or first delete the existing one.'))
+>>>>>>> MERGE-SOURCE
                 self.VersionNameEdit.setFocus()
                 return False
             return True
@@ -434,18 +445,16 @@
                     unicode(self.field(u'proxy_username').toString()),
                 proxy_password=unicode(self.field(u'proxy_password').toString())
             )
-        success = importer.do_import()
-        if success:
+        if importer.do_import():
             self.manager.save_meta_data(license_version, license_version,
                 license_copyright, license_permission)
             self.manager.reload_bibles()
             self.ImportProgressLabel.setText(
-                translate('BiblesPlugin.ImportWizardForm',
-                    'Finished import.'))
+                translate('BiblesPlugin.ImportWizardForm', 'Finished import.'))
         else:
             self.ImportProgressLabel.setText(
                 translate('BiblesPlugin.ImportWizardForm',
-                    'Your Bible import failed.'))
+                'Your Bible import failed.'))
             delete_database(self.bibleplugin.settingsSection, importer.file)
 
     def postImport(self):

=== modified file 'openlp/plugins/bibles/lib/mediaitem.py'
--- openlp/plugins/bibles/lib/mediaitem.py	2010-09-14 14:21:44 +0000
+++ openlp/plugins/bibles/lib/mediaitem.py	2010-09-18 21:36:50 +0000
@@ -65,12 +65,6 @@
         QtCore.QObject.connect(Receiver.get_receiver(),
             QtCore.SIGNAL(u'bibles_load_list'), self.reloadBibles)
 
-    def _decodeQtObject(self, listobj, key):
-        obj = listobj[QtCore.QString(key)]
-        if isinstance(obj, QtCore.QVariant):
-            obj = obj.toPyObject()
-        return unicode(obj)
-
     def requiredIcons(self):
         MediaManagerItem.requiredIcons(self)
         self.hasImportIcon = True
@@ -245,6 +239,10 @@
             QtCore.SIGNAL(u'activated(int)'), self.onAdvancedFromVerse)
         QtCore.QObject.connect(self.AdvancedToChapter,
             QtCore.SIGNAL(u'activated(int)'), self.onAdvancedToChapter)
+        QtCore.QObject.connect(self.ClearAdvancedSearchComboBox,
+            QtCore.SIGNAL(u'activated(int)'), self.onClearAdvancedSearchComboBox)
+        QtCore.QObject.connect(self.ClearQuickSearchComboBox,
+            QtCore.SIGNAL(u'activated(int)'), self.onClearQuickSearchComboBox)
         # Buttons
         QtCore.QObject.connect(self.AdvancedSearchButton,
             QtCore.SIGNAL(u'pressed()'), self.onAdvancedSearchButton)
@@ -438,8 +436,31 @@
                 dual_bible, versetext)
         if self.ClearAdvancedSearchComboBox.currentIndex() == 0:
             self.listView.clear()
+        elif not dual_bible:
+            self.AdvancedSecondBibleComboBox.setEnabled(False)
+        else:
+            self.AdvancedSecondBibleComboBox.setEnabled(True)
+            if self.AdvancedSecondBibleComboBox.findText(u'') != -1:
+                self.AdvancedSecondBibleComboBox.removeItem(0)
         self.displayResults(bible, dual_bible)
 
+    def onClearAdvancedSearchComboBox(self):
+        if self.ClearAdvancedSearchComboBox.currentIndex() == 0:
+            self.AdvancedSecondBibleComboBox.setEnabled(True)
+            if self.AdvancedSecondBibleComboBox.findText(u'') == -1:
+                self.AdvancedSecondBibleComboBox.insertItem(0, u'')
+            self.listView.clear()
+        else:
+            if self.listView.count() != 0:
+                bitem = self.listView.item(0)
+                dual_bible = self._decodeQtObject(bitem, 'dual_bible')
+                if self.AdvancedSecondBibleComboBox.findText(u'') != -1 and \
+                    dual_bible:
+                    self.AdvancedSecondBibleComboBox.removeItem(0)
+                else:
+                    self.AdvancedSecondBibleComboBox.setCurrentIndex(0)
+                    self.AdvancedSecondBibleComboBox.setEnabled(False)
+
     def onAdvancedFromChapter(self):
         bible = unicode(self.AdvancedVersionComboBox.currentText())
         book = unicode(self.AdvancedBookComboBox.currentText())
@@ -455,15 +476,47 @@
         bible = unicode(self.QuickVersionComboBox.currentText())
         dual_bible = unicode(self.QuickSecondBibleComboBox.currentText())
         text = unicode(self.QuickSearchEdit.text())
-        if self.ClearQuickSearchComboBox.currentIndex() == 0:
-            self.listView.clear()
         self.search_results = self.parent.manager.get_verses(bible, text)
         if dual_bible:
             self.dual_search_results = self.parent.manager.get_verses(
                 dual_bible, text)
+        if self.ClearQuickSearchComboBox.currentIndex() == 0:
+            self.listView.clear()
+        elif not dual_bible:
+            self.QuickSecondBibleComboBox.setEnabled(False)
+        else:
+            self.QuickSecondBibleComboBox.setEnabled(True)
+            if self.QuickSecondBibleComboBox.findText(u'') != -1:
+                self.QuickSecondBibleComboBox.removeItem(0)
         if self.search_results:
             self.displayResults(bible, dual_bible)
 
+    def onClearQuickSearchComboBox(self):
+        if self.ClearQuickSearchComboBox.currentIndex() == 0:
+            self.QuickSecondBibleComboBox.setEnabled(True)
+            if self.QuickSecondBibleComboBox.findText(u'') == -1:
+                self.QuickSecondBibleComboBox.insertItem(0, u'')
+            self.listView.clear()
+        else:
+            if self.listView.count() != 0:
+                bitem = self.listView.item(0)
+                dual_bible = self._decodeQtObject(bitem, 'dual_bible')
+                if self.QuickSecondBibleComboBox.findText(u'') != -1 and \
+                    dual_bible:
+                    self.QuickSecondBibleComboBox.removeItem(0)
+                else:
+                    self.QuickSecondBibleComboBox.setCurrentIndex(0)
+                    self.QuickSecondBibleComboBox.setEnabled(False)
+
+    def _decodeQtObject(self, bitem, key):
+        reference = bitem.data(QtCore.Qt.UserRole)
+        if isinstance(reference, QtCore.QVariant):
+            reference = reference.toPyObject()
+        obj = reference[QtCore.QString(key)]
+        if isinstance(obj, QtCore.QVariant):
+            obj = obj.toPyObject()
+        return unicode(obj)
+
     def generateSlideData(self, service_item, item=None):
         """
         Generates and formats the slides for the service item as well as the
@@ -473,67 +526,41 @@
         items = self.listView.selectedIndexes()
         if len(items) == 0:
             return False
-        has_dual_bible = False
         bible_text = u''
         old_chapter = u''
         raw_footer = []
         raw_slides = []
-        for item in items:
-            bitem = self.listView.item(item.row())
-            reference = bitem.data(QtCore.Qt.UserRole)
-            if isinstance(reference, QtCore.QVariant):
-                reference = reference.toPyObject()
-            dual_bible = self._decodeQtObject(reference, 'dual_bible')
-            if dual_bible:
-                has_dual_bible = True
-                break
+        raw_title = []
+        first = True
         # Let's loop through the main lot, and assemble our verses.
         for item in items:
             bitem = self.listView.item(item.row())
-            reference = bitem.data(QtCore.Qt.UserRole)
-            if isinstance(reference, QtCore.QVariant):
-                reference = reference.toPyObject()
-            book = self._decodeQtObject(reference, 'book')
-            chapter = self._decodeQtObject(reference, 'chapter')
-            verse = self._decodeQtObject(reference, 'verse')
-            bible = self._decodeQtObject(reference, 'bible')
-            version = self._decodeQtObject(reference, 'version')
-            copyright = self._decodeQtObject(reference, 'copyright')
-            permission = self._decodeQtObject(reference, 'permission')
-            text = self._decodeQtObject(reference, 'text')
-            dual_bible = self._decodeQtObject(reference, 'dual_bible')
-            if dual_bible:
-                dual_version = self._decodeQtObject(reference,
-                    'dual_version')
-                dual_copyright = self._decodeQtObject(reference,
-                    'dual_copyright')
-                dual_permission = self._decodeQtObject(reference,
-                    'dual_permission')
-                dual_text = self._decodeQtObject(reference, 'dual_text')
+            book = self._decodeQtObject(bitem, 'book')
+            chapter = int(self._decodeQtObject(bitem, 'chapter'))
+            verse = int(self._decodeQtObject(bitem, 'verse'))
+            bible = self._decodeQtObject(bitem, 'bible')
+            version = self._decodeQtObject(bitem, 'version')
+            copyright = self._decodeQtObject(bitem, 'copyright')
+            permission = self._decodeQtObject(bitem, 'permission')
+            text = self._decodeQtObject(bitem, 'text')
+            dual_bible = self._decodeQtObject(bitem, 'dual_bible')
+            dual_version = self._decodeQtObject(bitem, 'dual_version')
+            dual_copyright = self._decodeQtObject(bitem, 'dual_copyright')
+            dual_permission = self._decodeQtObject(bitem, 'dual_permission')
+            dual_text = self._decodeQtObject(bitem, 'dual_text')
             verse_text = self.formatVerse(old_chapter, chapter, verse)
             footer = u'%s (%s %s %s)' % (book, version, copyright, permission)
             if footer not in raw_footer:
                 raw_footer.append(footer)
-            if has_dual_bible:
-                if dual_bible:
-                    footer = u'%s (%s %s %s)' % (book, dual_version,
-                        dual_copyright, dual_permission)
-                    if footer not in raw_footer:
-                        raw_footer.append(footer)
-                    # If there is an old bible_text we have to add it.
-                    if bible_text:
-                        raw_slides.append(bible_text)
-                        bible_text = u''
-                    bible_text = u'%s %s\n\n%s %s' % (verse_text, text,
-                        verse_text, dual_text)
-                    raw_slides.append(bible_text)
-                    bible_text = u''
-                elif self.parent.settings_tab.layout_style == 0:
-                    bible_text = u'%s %s' % (verse_text, text)
-                    raw_slides.append(bible_text)
-                    bible_text = u''
-                else:
-                    bible_text = u'%s %s %s\n' % (bible_text, verse_text, text)
+            if dual_bible:
+                footer = u'%s (%s %s %s)' % (book, dual_version, dual_copyright,
+                    dual_permission)
+                if footer not in raw_footer:
+                    raw_footer.append(footer)
+                bible_text = u'%s %s\n\n%s %s' % (verse_text, text, verse_text,
+                    dual_text)
+                raw_slides.append(bible_text)
+                bible_text = u''
             # If we are 'Verse Per Slide' then create a new slide.
             elif self.parent.settings_tab.layout_style == 0:
                 bible_text = u'%s %s' % (verse_text, text)
@@ -545,29 +572,33 @@
             # We have to be 'Continuous'.
             else:
                 bible_text = u'%s %s %s\n' % (bible_text, verse_text, text)
+            if first:
+                start_item = item
+                first = False
+            elif self.checkTitle(item, old_item):
+                raw_title.append(self.formatTitle(start_item, old_item))
+                start_item = item
+            old_item = item
             old_chapter = chapter
+        raw_title.append(self.formatTitle(start_item, item))
         # If there are no more items we check whether we have to add bible_text.
         if bible_text:
             raw_slides.append(bible_text)
             bible_text = u''
         # Service Item: Capabilities
-        if self.parent.settings_tab.layout_style == 2 and not has_dual_bible:
+        if self.parent.settings_tab.layout_style == 2 and not dual_bible:
             # split the line but do not replace line breaks in renderer
             service_item.add_capability(ItemCapabilities.NoLineBreaks)
         service_item.add_capability(ItemCapabilities.AllowsPreview)
         service_item.add_capability(ItemCapabilities.AllowsLoop)
-        service_item.add_capability(ItemCapabilities.AllowsAdditions)
         # Service Item: Title
-        if not service_item.title:
-            if dual_bible:
-                service_item.title = u'%s (%s, %s) %s' % (book, version,
-                    dual_version, verse_text)
+        first = True
+        for title in raw_title:
+            if first:
+                first = False
+                service_item.title = title
             else:
-                service_item.title = u'%s (%s) %s' % (book, version, verse_text)
-        elif service_item.title.find(
-            translate('BiblesPlugin.MediaItem', 'etc')) == -1:
-            service_item.title = u'%s, %s' % (service_item.title,
-                translate('BiblesPlugin.MediaItem', 'etc'))
+                service_item.title += u', ' + title
         # Service Item: Theme
         if len(self.parent.settings_tab.bible_theme) == 0:
             service_item.theme = None
@@ -582,12 +613,80 @@
             service_item.raw_footer = raw_footer
         return True
 
+    def formatTitle(self, start_item, old_item):
+        """
+        This methode is called, when we have to change the title, because
+        we are at the end of a verse range. E. g. if we want to add
+        Genesis 1:1-6 as well as Daniel 2:14.
+        """
+        old_bitem = self.listView.item(old_item.row())
+        old_chapter = int(self._decodeQtObject(old_bitem, 'chapter'))
+        old_verse = int(self._decodeQtObject(old_bitem, 'verse'))
+        start_bitem = self.listView.item(start_item.row())
+        start_book = self._decodeQtObject(start_bitem, 'book')
+        start_chapter = int(self._decodeQtObject(start_bitem, 'chapter'))
+        start_verse = int(self._decodeQtObject(start_bitem, 'verse'))
+        start_bible = self._decodeQtObject(start_bitem, 'bible')
+        start_dual_bible = self._decodeQtObject(start_bitem, 'dual_bible')
+        if start_dual_bible:
+            if start_verse == old_verse and start_chapter == old_chapter:
+                title = u'%s %s:%s (%s, %s)' % (start_book, start_chapter,
+                    start_verse, start_bible, start_dual_bible)
+            elif start_chapter == old_chapter:
+                title = u'%s %s:%s-%s (%s, %s)' % (start_book, start_chapter,
+                    start_verse, old_verse, start_bible, start_dual_bible)
+            else:
+                title = u'%s %s:%s-%s:%s (%s, %s)' % (start_book, start_chapter,
+                    start_verse, old_chapter, old_verse, start_bible,
+                    start_dual_bible)
+        else:
+            if start_verse == old_verse and start_chapter == old_chapter:
+                title = u'%s %s:%s (%s)' % (start_book, start_chapter,
+                    start_verse, start_bible)
+            elif start_chapter == old_chapter:
+                title = u'%s %s:%s-%s (%s)' % (start_book, start_chapter,
+                    start_verse, old_verse, start_bible)
+            else:
+                title = u'%s %s:%s-%s:%s (%s)' % (start_book, start_chapter,
+                    start_verse, old_chapter, old_verse, start_bible)
+        return title
+
+    def checkTitle(self, item, old_item):
+        """
+        This methode checks if we are at the end of an verse range. If that is
+        the case, we return True, else False. E. g. if we added Genesis 1:1-6,
+        but the next verse is Daniel 2:14.
+        """
+        bitem = self.listView.item(item.row())
+        book = self._decodeQtObject(bitem, 'book')
+        chapter = int(self._decodeQtObject(bitem, 'chapter'))
+        verse = int(self._decodeQtObject(bitem, 'verse'))
+        bible = self._decodeQtObject(bitem, 'bible')
+        dual_bible = self._decodeQtObject(bitem, 'dual_bible')
+        old_bitem = self.listView.item(old_item.row())
+        old_book = self._decodeQtObject(old_bitem, 'book')
+        old_chapter = int(self._decodeQtObject(old_bitem, 'chapter'))
+        old_verse = int(self._decodeQtObject(old_bitem, 'verse'))
+        old_bible = self._decodeQtObject(old_bitem, 'bible')
+        old_dual_bible = self._decodeQtObject(old_bitem, 'dual_bible')
+        if old_bible != bible or old_dual_bible != dual_bible or \
+            old_book != book:
+            return True
+        elif old_verse + 1 != verse and old_chapter == chapter:
+            return True
+        elif old_chapter + 1 == chapter and (verse != 1 or
+            old_verse != self.parent.manager.get_verse_count(
+            old_bible, old_book, old_chapter)):
+            return True
+        else:
+            return False
+
     def formatVerse(self, old_chapter, chapter, verse):
         if not self.parent.settings_tab.show_new_chapters or \
             old_chapter != chapter:
-            verse_text = chapter + u':' + verse
+            verse_text = u'%s:%s' % (chapter, verse)
         else:
-            verse_text = verse
+            verse_text = u'%s' % verse
         if self.parent.settings_tab.display_style == 1:
             verse_text = u'{su}(' + verse_text + u'){/su}'
         elif self.parent.settings_tab.display_style == 2:
@@ -690,14 +789,15 @@
                     'copyright': QtCore.QVariant(copyright.value),
                     'permission': QtCore.QVariant(permission.value),
                     'text': QtCore.QVariant(verse.text),
-                    'dual_bible': QtCore.QVariant(dual_bible)
+                    'dual_bible': QtCore.QVariant(u''),
+                    'dual_version': QtCore.QVariant(u''),
+                    'dual_copyright': QtCore.QVariant(u''),
+                    'dual_permission': QtCore.QVariant(u''),
+                    'dual_text': QtCore.QVariant(u'')
                 }
                 bible_text = u' %s %d:%d (%s)' % (verse.book.name,
                     verse.chapter, verse.verse, version.value)
-            # set the row title
             bible_verse = QtGui.QListWidgetItem(bible_text)
-            #bible_verse.setData(QtCore.Qt.UserRole,
-            #    QtCore.QVariant(bible_text))
             bible_verse.setData(QtCore.Qt.UserRole, QtCore.QVariant(vdict))
             self.listView.addItem(bible_verse)
             row = self.listView.setCurrentRow(count + start_count)


Follow ups