openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #02926
[Merge] lp:~googol-hush/openlp/fixes into lp:openlp
googol has proposed merging lp:~googol-hush/openlp/fixes into lp:openlp.
Requested reviews:
OpenLP Core (openlp-core)
Hello!
This merge is supposed to improve the usage of different bibles versions in one slide. Before r987 the bibles plugin has not done that well, I think.
Let us create one service item with Genesis 1:1-4 and Revelation 22:18-21 ("Layout Style" must be set to "Continuous"). When you send it live or preview it, you'll see, that the bibles plugin separated Genesis 1:1-4 and Revelation 22:18-21. From my point of view this is better than to continue there where you the last verse stopped. However, the criteria for a new line, which separates two verses is that the bible or the book has to be different.
I hope you'll test it and like it. Feel free to comment and give feedback (since this is not *the* solution).
--
https://code.launchpad.net/~googol-hush/openlp/fixes/+merge/33027
Your team OpenLP Core is requested to review the proposed merge of lp:~googol-hush/openlp/fixes into lp:openlp.
=== modified file 'openlp/plugins/bibles/lib/mediaitem.py'
--- openlp/plugins/bibles/lib/mediaitem.py 2010-08-10 16:49:52 +0000
+++ openlp/plugins/bibles/lib/mediaitem.py 2010-08-18 16:14:08 +0000
@@ -465,12 +465,14 @@
def generateSlideData(self, service_item, item=None):
'''
- Generates and formats the slides for the service item.
+ Generates and formats the slides for the service item as well as the
+ service item's title.
'''
log.debug(u'generating slide data')
items = self.listView.selectedIndexes()
if len(items) == 0:
return False
+ first = True
bible_text = u''
old_chapter = u''
raw_footer = []
@@ -501,61 +503,52 @@
#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')')
- elif self.parent.settings_tab.display_style == 2:
- verse_text = self.formatVerse(old_chapter, chapter, verse,
- u'{', u'}')
- elif self.parent.settings_tab.display_style == 3:
- verse_text = self.formatVerse(old_chapter, chapter, verse,
- u'[', u']')
- else:
- verse_text = self.formatVerse(old_chapter, chapter, verse,
- u'', u'')
- old_chapter = chapter
+ verse_text = self.formatVerse(old_chapter, chapter, verse)
+ # footer
footer = u'%s (%s %s)' % (book, version, copyright)
- # If not found add to footer
if footer not in raw_footer:
raw_footer.append(footer)
if dual_bible:
- footer = u'%s (%s %s)' % (book, dual_version,
- dual_copyright)
- # If not found add second version and copyright to footer.
+ footer = u'%s (%s %s)' % (book, dual_version, dual_copyright)
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''
- else:
- # 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 a new slide.
- if self.parent.settings_tab.layout_style == 0:
+ # If we were previously 'Verse Per Line' we have to add the old
+ # bible_text, because it was not added until now.
+ if bible_text:
raw_slides.append(bible_text)
bible_text = u''
- # If we are not 'Verse Per Slide' we have to make sure, that we
- # add more verses.
+ 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)
+ raw_slides.append(bible_text)
+ bible_text = u''
+ # If we are 'Verse Per Line' then force a new line.
+ elif self.parent.settings_tab.layout_style == 1:
+ bible_text = u'%s %s %s\n\n' % (bible_text, verse_text, text)
+ # We have to be 'Continuous'.
+ else:
+ # We add a line break if the previously verse has a different
+ # book or bible version.
+ if first:
+ bible_text = u'%s %s %s' % (bible_text, verse_text, text)
+ elif bible != old_bible or book != old_book:
+ bible_text = u'%s\n\n%s %s' % (bible_text, verse_text,
+ text)
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''
+ bible_text = u'%s %s %s' % (bible_text, verse_text, text)
+ if first:
+ first = False
+ old_chapter = chapter
+ old_book = book
+ old_bible = bible
+ # 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 title
if not service_item.title:
if dual_bible:
@@ -581,14 +574,17 @@
service_item.raw_footer = raw_footer
return True
- def formatVerse(self, old_chapter, chapter, verse, opening, closing):
- verse_text = opening
- if old_chapter != chapter:
- verse_text += chapter + u':'
- elif not self.parent.settings_tab.show_new_chapters:
- verse_text += chapter + u':'
+ 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_text += verse
- verse_text += closing
+ if self.parent.settings_tab.display_style == 1:
+ verse_text = u'(' + verse_text + u')'
+ elif self.parent.settings_tab.display_style == 2:
+ verse_text = u'{' + verse_text + u'}'
+ elif self.parent.settings_tab.display_style == 3:
+ verse_text = u'[' + verse_text + u']'
return verse_text
def reloadBibles(self):
@@ -633,10 +629,10 @@
for i in range(int(range_from), int(range_to) + 1):
combo.addItem(unicode(i))
- def displayResults(self, bible, dual_bible=None):
+ def displayResults(self, bible, dual_bible=u''):
'''
- Displays the search results in the media manager. All data needed for further
- action is saved for/in each row.
+ 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')
@@ -657,34 +653,34 @@
for count, verse in enumerate(self.search_results):
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(
+ '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)
+ '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)
Follow ups