Fix up Bible bugs following addition of Tabs and Move code split

bzr-revno: 382
This commit is contained in:
Tim Bentley 2009-03-06 07:18:30 +00:00
parent 980ed505e2
commit 4ad8b74167
3 changed files with 32 additions and 20 deletions

View File

@ -3,7 +3,7 @@
"""
OpenLP - Open Source Lyrics Projection
Copyright (c) 2008 Raoul Snyman
Portions copyright (c) 2008 Martin Thompson, Tim Bentley
Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software

View File

@ -26,6 +26,7 @@ from openlp.core.lib import MediaManagerItem, Receiver
from openlp.core.resources import *
from openlp.plugins.bibles.forms import BibleImportForm
from openlp.plugins.bibles.lib import BiblesTab
class BibleMediaItem(MediaManagerItem):
"""
@ -242,6 +243,7 @@ class BibleMediaItem(MediaManagerItem):
self.ClearAdvancedSearchComboBox.clear()
def loadBibles(self):
log.debug("Loading Bibles")
bibles = self.parent.biblemanager.get_bibles('full')
for bible in bibles: # load bibles into the combo boxes
self.QuickVersionComboBox.addItem(bible)
@ -285,6 +287,7 @@ class BibleMediaItem(MediaManagerItem):
self.adjustComboBox(1, vse, self.AdvancedToVerse)
def onAdvancedSearchButton(self):
log.debug("Advanced Search Button pressed")
bible = str(self.AdvancedVersionComboBox.currentText())
book = str(self.AdvancedBookComboBox.currentText())
chapter_from = int(self.AdvancedFromChapter.currentText())
@ -308,13 +311,13 @@ class BibleMediaItem(MediaManagerItem):
self._adjust_combobox(1, vse, self.AdvancedToVerse)
def onQuickSearchButton(self):
self.log.debug("onQuickSearchButton")
log.debug("Quick Search Button pressed")
bible = str(self.QuickVersionComboBox.currentText())
text = str(self.QuickSearchEdit.displayText())
if self.ClearQuickSearchComboBox.currentIndex() == 0:
self.BibleListView.clear() # clear the results
self.BibleListView.setRowCount(0)
elif self.QuickSearchComboBox.currentIndex() == 1:
if self.QuickSearchComboBox.currentIndex() == 1:
self.search_results = self.parent.biblemanager.get_verse_from_text(bible, text)
else:
self.searchByReference(bible, text)
@ -322,7 +325,9 @@ class BibleMediaItem(MediaManagerItem):
self.displayResults(bible)
def onBiblePreviewClick(self):
log.debug("Bible Preview Button pressed")
items = self.BibleListView.selectedItems()
old_chapter = ''
for item in items:
text = str(item.text())
verse = text[:text.find("(")]
@ -332,31 +337,32 @@ class BibleMediaItem(MediaManagerItem):
chapter = str(self.search_results[0][1])
verse = str(self.search_results[0][2])
text = self.search_results[0][3]
o = self.SettingsOutputStyleComboBox.currentIndex()
v = self.SettingsVerseStyleComboBox.currentIndex()
if o == 1: #Paragraph
text = text + u"\n"
if v == 1: #Paragraph
loc = self._format_verse(chapter, verse, u"(", u")")
elif v == 2: #Paragraph
loc = self._format_verse(chapter, verse, u"{", u"}")
elif v == 3: #Paragraph
loc = self._format_verse(chapter, verse, u"[", u"]")
if self.parent.bibles_tab.paragraph_style: #Paragraph
text = text + u'\n'
if self.parent.bibles_tab.display_style == 1:
loc = self.formatVerse(old_chapter, chapter, verse, u'(', u')')
elif self.parent.bibles_tab.display_style == 2:
loc = self.formatVerse(old_chapter, chapter, verse, u'{', u'}')
elif self.parent.bibles_tab.display_style == 3:
loc = self.formatVerse(old_chapter, chapter, verse, u'[', u']')
else:
loc = self._format_verse(chapter, verse, u"", u"")
loc = self.formatVerse(old_chapter, chapter, verse, u'', u'')
old_chapter = chapter
print book
print loc
print text
def formatVerse(self, chapter, verse, opening, closing):
def formatVerse(self, old_chapter, chapter, verse, opening, closing):
loc = opening
if self.SettingsNewChapterCheck.checkState() == 2:
loc += chapter + u':'
if self.parent.bibles_tab.new_chapter_check:
if old_chapter != chapter:
loc += chapter + u':'
loc += verse
loc += closing
return loc
def reloadBibles(self):
log.debug("Reloading Bibles")
self.parent.biblemanager.reload_bibles()
self.initialiseForm()
@ -405,6 +411,7 @@ class BibleMediaItem(MediaManagerItem):
self.BibleListView.setRowHeight(row_count, 20)
def searchByReference(self, bible, search):
log.debug("searchByReference %s ,%s", bible, search)
book = ''
start_chapter = ''
end_chapter = ''
@ -482,6 +489,6 @@ class BibleMediaItem(MediaManagerItem):
int(start_chapter), int(end_chapter), int(start_verse),
int(end_verse))
else:
reply = QtGui.QMessageBox.information(self.MediaManagerItem,
reply = QtGui.QMessageBox.information(self,
translate(u'BibleMediaItem', u'Information'),
translate(u'BibleMediaItem', message))

View File

@ -118,7 +118,9 @@ class BiblesTab(SettingsTab):
QtCore.QObject.connect(self.VerseRadioButton,
QtCore.SIGNAL("pressed()"), self.onVerseRadioButtonPressed)
QtCore.QObject.connect(self.ParagraphRadioButton,
QtCore.SIGNAL("pressed()"), self.onParagraphRadioButtonPressed)
QtCore.SIGNAL("pressed()"), self.onParagraphRadioButtonPressed)
QtCore.QObject.connect(self.DisplayStyleComboBox,
QtCore.SIGNAL("activated(int)"), self.onDisplayStyleComboBoxChanged)
def retranslateUi(self):
self.VerseDisplayGroupBox.setTitle(translate('SettingsForm', 'Verse Display'))
@ -134,6 +136,9 @@ class BiblesTab(SettingsTab):
self.BibleSearchGroupBox.setTitle(translate('SettingsForm', 'Search'))
self.BibleSearchCheckBox.setText(translate('SettingsForm', 'Search-as-you-type'))
def onDisplayStyleComboBoxChanged(self):
self.display_style = self.DisplayStyleComboBox.currentIndex()
def onVerseRadioButtonPressed(self):
self.paragraph_style = False
@ -170,6 +175,6 @@ class BiblesTab(SettingsTab):
def save(self):
self.config.set_config("paragraph style", str(self.paragraph_style))
self.config.set_config("display new chapter", str(self.new_chapter_check))
self.config.set_config("display brackets", str(self.DisplayStyleComboBox.currentIndex()))
self.config.set_config("display brackets", str(self.display_style))
self.config.set_config("search as type", str(self.bible_search_check))