openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #02913
[Merge] lp:~googol-hush/openlp/fixes into lp:openlp
googol has proposed merging lp:~googol-hush/openlp/fixes into lp:openlp.
Requested reviews:
Raoul Snyman (raoul-snyman): approve
Tim Bentley (trb143)
This brings improvements to the usage of (combined) single and dual bible verses. The most important changes are that the search result are now dependent on both bible versions (the search result in the Media Manager saves all necessary data) and a rework of generateSlideData considering that.
The following bugs in the trunk are now fixed:
1) Service Manger item with different dual bible verses (using "Keep" in the Media Manager):
Version 1 and Version 2
Version 3 and Version 4
or
Version 1 and Version 2
Version 3
2) Using "Keep" to combine different search results would not select the new results.
3) Fixed bug #609355 (There has still some work to be done to the titles.)
However, I'll leave the bible name/bible version thing up to Mehts, alright?
--
https://code.launchpad.net/~googol-hush/openlp/fixes/+merge/32225
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp/plugins/bibles/lib/mediaitem.py'
--- openlp/plugins/bibles/lib/mediaitem.py 2010-07-31 02:06:44 +0000
+++ openlp/plugins/bibles/lib/mediaitem.py 2010-08-10 16:52:43 +0000
@@ -59,10 +59,10 @@
self.pluginNameVisible = translate('BiblesPlugin.MediaItem', 'Bible')
self.IconPath = u'songs/song'
self.ListViewWithDnD_class = BibleListView
- self.lastReference = []
MediaManagerItem.__init__(self, parent, icon, title)
- # place to store the search results
+ # place to store the search results for both bibles
self.search_results = {}
+ self.dual_search_results = {}
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'bibles_load_list'), self.reloadBibles)
@@ -344,7 +344,7 @@
self.QuickMessage.setText(text)
self.AdvancedMessage.setText(text)
Receiver.send_message(u'openlp_process_events')
- #minor delay to get the events processed
+ # minor delay to get the events processed
time.sleep(0.1)
def loadBibles(self):
@@ -387,7 +387,7 @@
QtGui.QMessageBox.critical(self,
translate('BiblesPlugin.MediaItem', 'No Book Found'),
translate('BiblesPlugin.MediaItem',
- 'No matching book could be found in this Bible.'))
+ 'No matching book could be found in this Bible.'))
def onAdvancedVersionComboBox(self):
self.initialiseBible(
@@ -423,6 +423,7 @@
def onAdvancedSearchButton(self):
log.debug(u'Advanced Search Button pressed')
bible = unicode(self.AdvancedVersionComboBox.currentText())
+ dual_bible = unicode(self.AdvancedSecondBibleComboBox.currentText())
book = unicode(self.AdvancedBookComboBox.currentText())
chapter_from = int(self.AdvancedFromChapter.currentText())
chapter_to = int(self.AdvancedToChapter.currentText())
@@ -431,11 +432,12 @@
versetext = u'%s %s:%s-%s:%s' % (book, chapter_from, verse_from,
chapter_to, verse_to)
self.search_results = self.parent.manager.get_verses(bible, versetext)
+ if dual_bible:
+ self.dual_search_results = self.parent.manager.get_verses(
+ dual_bible, versetext)
if self.ClearAdvancedSearchComboBox.currentIndex() == 0:
self.listView.clear()
- self.lastReference = []
- self.lastReference.append(versetext)
- self.displayResults(bible)
+ self.displayResults(bible, dual_bible)
def onAdvancedFromChapter(self):
bible = unicode(self.AdvancedVersionComboBox.currentText())
@@ -450,70 +452,55 @@
def onQuickSearchButton(self):
log.debug(u'Quick Search Button pressed')
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.lastReference = []
- self.lastReference.append(text)
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.search_results:
- self.displayResults(bible)
+ self.displayResults(bible, dual_bible)
def generateSlideData(self, service_item, item=None):
+ '''
+ Generates and formats the slides for the service item.
+ '''
log.debug(u'generating slide data')
items = self.listView.selectedIndexes()
if len(items) == 0:
return False
+ bible_text = u''
old_chapter = u''
+ raw_footer = []
raw_slides = []
- raw_footer = []
- bible_text = u''
service_item.add_capability(ItemCapabilities.AllowsPreview)
service_item.add_capability(ItemCapabilities.AllowsLoop)
service_item.add_capability(ItemCapabilities.AllowsAdditions)
- #If we want to use a 2nd translation / version
- bible2 = u''
- if self.SearchTabWidget.currentIndex() == 0:
- bible2 = unicode(self.QuickSecondBibleComboBox.currentText())
- else:
- bible2 = unicode(self.AdvancedSecondBibleComboBox.currentText())
- if bible2:
- bible2_verses = []
- for scripture in self.lastReference:
- bible2_verses.extend(self.parent.manager.get_verses(bible2,
- scripture))
- bible2_version = self.parent.manager.get_meta_data(bible2,
- u'Version')
- bible2_copyright = self.parent.manager.get_meta_data(bible2,
- u'Copyright')
- bible2_permission = self.parent.manager.get_meta_data(bible2,
- u'Permissions')
- if bible2_version:
- bible2_version = bible2_version.value
- else:
- bible2_version = u''
- if bible2_copyright:
- bible2_copyright = bible2_copyright.value
- else:
- bible2_copyright = u''
- if bible2_permission:
- bible2_permission = bible2_permission.value
- else:
- bible2_permission = u''
- # Let's loop through the main lot, and assemble our verses
+ # 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()
- #bible = self._decodeQtObject(reference, 'bible')
book = self._decodeQtObject(reference, 'book')
chapter = self._decodeQtObject(reference, 'chapter')
verse = self._decodeQtObject(reference, 'verse')
- text = self._decodeQtObject(reference, 'text')
+ 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')
if self.parent.settings_tab.display_style == 1:
verse_text = self.formatVerse(old_chapter, chapter, verse,
u'(', u')')
@@ -528,46 +515,68 @@
u'', u'')
old_chapter = chapter
footer = u'%s (%s %s)' % (book, version, copyright)
- #If not found add to footer
+ # If not found add to footer
if footer not in raw_footer:
raw_footer.append(footer)
- if bible2:
- footer = u'%s (%s %s)' % (book, bible2_version,
- bible2_copyright)
- #If not found add second version and copyright to footer
+ if dual_bible:
+ footer = u'%s (%s %s)' % (book, dual_version,
+ dual_copyright)
+ # If not found add second version and copyright to footer.
if footer not in raw_footer:
raw_footer.append(footer)
bible_text = u'%s %s \n\n %s %s' % (verse_text, text,
- verse_text, bible2_verses[item.row()].text)
+ verse_text, dual_text)
raw_slides.append(bible_text)
bible_text = u''
else:
- #Paragraph style force new line per verse
+ # If we are 'Verse Per Line' then force a new line.
if self.parent.settings_tab.layout_style == 1:
text = text + u'\n\n'
bible_text = u'%s %s %s' % (bible_text, verse_text, text)
- #if we are verse per slide then create slide
+ # If we are 'Verse Per Slide' then create a new slide.
if self.parent.settings_tab.layout_style == 0:
raw_slides.append(bible_text)
bible_text = u''
- if not service_item.title:
- service_item.title = u'%s %s' % (book, 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'))
+ # If we are not 'Verse Per Slide' we have to make sure, that we
+ # add more verses.
+ else:
+ if item.row() < len(items) - 1:
+ bitem = items[item.row() + 1]
+ reference = bitem.data(QtCore.Qt.UserRole)
+ if isinstance(reference, QtCore.QVariant):
+ reference = reference.toPyObject()
+ bible_new = self._decodeQtObject(reference, 'bible')
+ dual_bible_new = self._decodeQtObject(reference, 'dual_bible')
+ if dual_bible_new:
+ raw_slides.append(bible_text)
+ bible_text = u''
+ elif bible != bible_new:
+ raw_slides.append(bible_text)
+ bible_text = u''
+ else:
+ raw_slides.append(bible_text)
+ bible_text = u''
+ # 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)
+ 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'))
+ # item theme
if len(self.parent.settings_tab.bible_theme) == 0:
service_item.theme = None
else:
service_item.theme = self.parent.settings_tab.bible_theme
- #if we are verse per slide we have already been added
- if self.parent.settings_tab.layout_style != 0 and not bible2:
- raw_slides.append(bible_text)
for slide in raw_slides:
service_item.add_from_text(slide[:30], slide)
if service_item.raw_footer:
- for foot in raw_footer:
- service_item.raw_footer.append(foot)
+ for footer in raw_footer:
+ service_item.raw_footer.append(footer)
else:
service_item.raw_footer = raw_footer
return True
@@ -599,8 +608,8 @@
row, QtCore.QVariant(book[u'chapters']))
if first:
first = False
- self.initialiseChapterVerse(
- bible, book[u'name'], book[u'chapters'])
+ self.initialiseChapterVerse(bible, book[u'name'],
+ book[u'chapters'])
def initialiseChapterVerse(self, bible, book, chapters):
log.debug(u'initialiseChapterVerse %s, %s', bible, book)
@@ -624,32 +633,69 @@
for i in range(int(range_from), int(range_to) + 1):
combo.addItem(unicode(i))
- def displayResults(self, bible):
+ def displayResults(self, bible, dual_bible=None):
+ '''
+ Displays the search results in the media manager. All data needed for further
+ action is saved for/in each row.
+ '''
version = self.parent.manager.get_meta_data(bible, u'Version')
copyright = self.parent.manager.get_meta_data(bible, u'Copyright')
permission = self.parent.manager.get_meta_data(bible, u'Permissions')
- if not permission:
- permission = u''
- else:
- permission = permission.value
+ if dual_bible:
+ dual_version = self.parent.manager.get_meta_data(dual_bible,
+ u'Version')
+ dual_copyright = self.parent.manager.get_meta_data(dual_bible,
+ u'Copyright')
+ dual_permission = self.parent.manager.get_meta_data(dual_bible,
+ u'Permissions')
+ if dual_permission:
+ dual_permission = dual_permission.value
+ else:
+ dual_permission = u''
+ # We count the number of rows which are maybe already present.
+ start_count = self.listView.count()
for count, verse in enumerate(self.search_results):
- bible_text = u' %s %d:%d (%s)' % \
- (verse.book.name, verse.chapter, verse.verse, bible)
+ if dual_bible:
+ vdict = {
+ 'book':QtCore.QVariant(verse.book.name),
+ 'chapter':QtCore.QVariant(verse.chapter),
+ 'verse':QtCore.QVariant(verse.verse),
+ 'bible':QtCore.QVariant(bible),
+ 'version':QtCore.QVariant(version.value),
+ 'copyright':QtCore.QVariant(copyright.value),
+ #'permission':QtCore.QVariant(permission.value),
+ 'text':QtCore.QVariant(verse.text),
+ 'dual_bible':QtCore.QVariant(dual_bible),
+ 'dual_version':QtCore.QVariant(dual_version.value),
+ 'dual_copyright':QtCore.QVariant(dual_copyright.value),
+ #'dual_permission':QtCore.QVariant(dual_permission),
+ 'dual_text':QtCore.QVariant(
+ self.dual_search_results[count].text)
+ }
+ bible_text = u' %s %d:%d (%s, %s)' % (verse.book.name,
+ verse.chapter, verse.verse, version.value, dual_version.value)
+ else:
+ vdict = {
+ 'book':QtCore.QVariant(verse.book.name),
+ 'chapter':QtCore.QVariant(verse.chapter),
+ 'verse':QtCore.QVariant(verse.verse),
+ 'bible':QtCore.QVariant(bible),
+ 'version':QtCore.QVariant(version.value),
+ 'copyright':QtCore.QVariant(copyright.value),
+ #'permission':QtCore.QVariant(permission.value),
+ 'text':QtCore.QVariant(verse.text),
+ 'dual_bible':QtCore.QVariant(dual_bible)
+ }
+ 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))
- vdict = {
- 'bible': QtCore.QVariant(bible),
- 'version': QtCore.QVariant(version.value),
- 'copyright': QtCore.QVariant(copyright.value),
- 'permission': QtCore.QVariant(permission),
- 'book': QtCore.QVariant(verse.book.name),
- 'chapter': QtCore.QVariant(verse.chapter),
- 'verse': QtCore.QVariant(verse.verse),
- 'text': QtCore.QVariant(verse.text)
- }
bible_verse.setData(QtCore.Qt.UserRole, QtCore.QVariant(vdict))
self.listView.addItem(bible_verse)
- row = self.listView.setCurrentRow(count)
+ row = self.listView.setCurrentRow(count + start_count)
if row:
row.setSelected(True)
+ self.search_results = {}
+ self.dual_search_results = {}
Follow ups