- improved usage of different bibles and/or books in one service item

This commit is contained in:
Andreas Preikschat 2010-08-15 17:35:20 +02:00
parent 30e867e020
commit 1b1261a1a4

View File

@ -471,6 +471,7 @@ class BibleMediaItem(MediaManagerItem):
items = self.listView.selectedIndexes() items = self.listView.selectedIndexes()
if len(items) == 0: if len(items) == 0:
return False return False
first = True
bible_text = u'' bible_text = u''
old_chapter = u'' old_chapter = u''
raw_footer = [] raw_footer = []
@ -502,7 +503,6 @@ class BibleMediaItem(MediaManagerItem):
# 'dual_permission') # 'dual_permission')
dual_text = self._decodeQtObject(reference, 'dual_text') dual_text = self._decodeQtObject(reference, 'dual_text')
verse_text = self.formatVerse(old_chapter, chapter, verse) verse_text = self.formatVerse(old_chapter, chapter, verse)
old_chapter = chapter
# footer # footer
footer = u'%s (%s %s)' % (book, version, copyright) footer = u'%s (%s %s)' % (book, version, copyright)
if footer not in raw_footer: if footer not in raw_footer:
@ -512,11 +512,11 @@ class BibleMediaItem(MediaManagerItem):
if footer not in raw_footer: if footer not in raw_footer:
raw_footer.append(footer) raw_footer.append(footer)
# If we were previously 'Verse Per Line' we have to add the old # If we were previously 'Verse Per Line' we have to add the old
# bible_text first, because it was not added till now. # bible_text, because it was not added until now.
if bible_text: if bible_text:
raw_slides.append(bible_text) raw_slides.append(bible_text)
bible_text = u'' bible_text = u''
bible_text = u'%s %s \n\n %s %s' % (verse_text, text, bible_text = u'%s %s\n\n%s %s' % (verse_text, text,
verse_text, dual_text) verse_text, dual_text)
raw_slides.append(bible_text) raw_slides.append(bible_text)
bible_text = u'' bible_text = u''
@ -527,34 +527,23 @@ class BibleMediaItem(MediaManagerItem):
bible_text = u'' bible_text = u''
# If we are 'Verse Per Line' then force a new line. # If we are 'Verse Per Line' then force a new line.
elif self.parent.settings_tab.layout_style == 1: elif self.parent.settings_tab.layout_style == 1:
bible_text = u'%s %s %s \n\n' % (bible_text, verse_text, text) bible_text = u'%s %s %s\n\n' % (bible_text, verse_text, text)
# We have to be 'Continuous'. # We have to be 'Continuous'.
elif item.row() < len(items) - 1: else:
#bitem = self.listView.item(item.row() + 1) # We add a line break if the previously verse has a different
bitem = items[item.row() + 1] # book or bible version.
reference = bitem.data(QtCore.Qt.UserRole) if first:
if isinstance(reference, QtCore.QVariant):
reference = reference.toPyObject()
#todo replace 'new' by 'next'
next_bible = self._decodeQtObject(reference, 'bible')
next_dual_bible = self._decodeQtObject(reference, 'dual_bible')
next_verse = self._decodeQtObject(reference, 'verse')
next_chapter = self._decodeQtObject(reference, 'chapter')
next_book = self._decodeQtObject(reference, 'book')
# If the next verse is a dual one, then we append 'bible_text'.
if next_dual_bible:
bible_text = u'%s %s %s' % (bible_text, verse_text, text) bible_text = u'%s %s %s' % (bible_text, verse_text, text)
raw_slides.append(bible_text) elif bible != old_bible or book != old_book:
bible_text = u'' bible_text = u'%s\n\n%s %s' % (bible_text, verse_text,
# We add a line break if the next verse is not part of a series
# of verses, has a different book, bible or so on.
elif bible != next_bible or book != next_book or \
int(verse) + 1 != int(next_verse) or \
int(chapter) != int(next_chapter):
bible_text = u'%s %s %s \n\n' % (bible_text, verse_text,
text) text)
else: else:
bible_text = u'%s %s %s' % (bible_text, verse_text, text) 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 there are no more items we check whether we have to add bible_text.
if bible_text: if bible_text:
raw_slides.append(bible_text) raw_slides.append(bible_text)