openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #04495
[Merge] lp:~googol-hush/openlp/trivial into lp:openlp
Andreas Preikschat has proposed merging lp:~googol-hush/openlp/trivial into lp:openlp.
Requested reviews:
Tim Bentley (trb143)
Hello!
- changed importer messages (Bug #668789)
- disabled text search for web bibles (does not matter if the web bible is the dual or normal bible)
- available web bibles in the bible importer are now sorted
- imported bible in the Media Manager are now sorted
- speed imporvements (unfortunately this takes the ability to keep unselected item unselected when doing an other search)
- "second" instead of "dual"
- docs, comments
--
https://code.launchpad.net/~googol-hush/openlp/trivial/+merge/41089
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp/core/ui/themestab.py'
--- openlp/core/ui/themestab.py 2010-09-14 18:18:47 +0000
+++ openlp/core/ui/themestab.py 2010-11-17 19:24:20 +0000
@@ -183,9 +183,14 @@
def updateThemeList(self, theme_list):
"""
- Called from ThemeManager when the Themes have changed
+ Called from ThemeManager when the Themes have changed.
+
+ ``theme_list``
+ The list of available themes::
+
+ [u'Bible Theme', u'Song Theme']
"""
- #reload as may have been triggered by the ThemeManager
+ # Reload as may have been triggered by the ThemeManager.
self.global_theme = unicode(QtCore.QSettings().value(
self.settingsSection + u'/global theme',
QtCore.QVariant(u'')).toString())
=== modified file 'openlp/plugins/bibles/forms/bibleimportform.py'
--- openlp/plugins/bibles/forms/bibleimportform.py 2010-10-16 19:38:23 +0000
+++ openlp/plugins/bibles/forms/bibleimportform.py 2010-11-17 19:24:20 +0000
@@ -133,7 +133,7 @@
self.OSISLocationEdit.setFocus()
return False
elif self.field(u'source_format').toInt()[0] == BibleFormat.CSV:
- if self.field(u'csv_booksfile').toString() == u'':
+ if not self.field(u'csv_booksfile').toString():
QtGui.QMessageBox.critical(self,
translate('BiblesPlugin.ImportWizardForm',
'Invalid Books File'),
@@ -142,7 +142,7 @@
'the Bible to use in the import.'))
self.BooksLocationEdit.setFocus()
return False
- elif self.field(u'csv_versefile').toString() == u'':
+ elif not self.field(u'csv_versefile').toString():
QtGui.QMessageBox.critical(self,
translate('BiblesPlugin.ImportWizardForm',
'Invalid Verse File'),
@@ -153,7 +153,7 @@
return False
elif self.field(u'source_format').toInt()[0] == \
BibleFormat.OpenSong:
- if self.field(u'opensong_file').toString() == u'':
+ if not self.field(u'opensong_file').toString():
QtGui.QMessageBox.critical(self,
translate('BiblesPlugin.ImportWizardForm',
'Invalid OpenSong Bible'),
@@ -168,7 +168,7 @@
license_version = unicode(self.field(u'license_version').toString())
license_copyright = \
unicode(self.field(u'license_copyright').toString())
- if license_version == u'':
+ if not license_version:
QtGui.QMessageBox.critical(self,
translate('BiblesPlugin.ImportWizardForm',
'Empty Version Name'),
@@ -176,7 +176,7 @@
'You need to specify a version name for your Bible.'))
self.VersionNameEdit.setFocus()
return False
- elif license_copyright == u'':
+ elif not license_copyright:
QtGui.QMessageBox.critical(self,
translate('BiblesPlugin.ImportWizardForm',
'Empty Copyright'),
@@ -207,9 +207,11 @@
The index of the combo box.
"""
self.BibleComboBox.clear()
- for bible in self.web_bible_list[index].keys():
- self.BibleComboBox.addItem(unicode(
- translate('BiblesPlugin.ImportWizardForm', bible)))
+ bibles = [unicode(translate('BiblesPlugin.ImportWizardForm', bible)) for
+ bible in self.web_bible_list[index].keys()]
+ bibles.sort()
+ for bible in bibles:
+ self.BibleComboBox.addItem(bible)
def onOsisFileButtonClicked(self):
"""
@@ -317,7 +319,7 @@
"""
Load the list of Crosswalk and BibleGateway bibles.
"""
- #Load and store Crosswalk Bibles
+ # Load and store Crosswalk Bibles.
filepath = AppLocation.get_directory(AppLocation.PluginsDir)
filepath = os.path.join(filepath, u'bibles', u'resources')
books_file = None
@@ -341,7 +343,7 @@
finally:
if books_file:
books_file.close()
- #Load and store BibleGateway Bibles
+ # Load and store BibleGateway Bibles.
books_file = None
try:
self.web_bible_list[WebDownload.BibleGateway] = {}
@@ -379,12 +381,18 @@
Receiver.send_message(u'openlp_process_events')
def preImport(self):
+ bible_type = self.field(u'source_format').toInt()[0]
self.finishButton.setVisible(False)
self.ImportProgressBar.setMinimum(0)
self.ImportProgressBar.setMaximum(1188)
self.ImportProgressBar.setValue(0)
- self.ImportProgressLabel.setText(
- translate('BiblesPlugin.ImportWizardForm', 'Starting import...'))
+ if bible_type == BibleFormat.WebDownload:
+ self.ImportProgressLabel.setText(translate(
+ 'BiblesPlugin.ImportWizardForm',
+ 'Starting Registering bible...'))
+ else:
+ self.ImportProgressLabel.setText(translate(
+ 'BiblesPlugin.ImportWizardForm', 'Starting import...'))
Receiver.send_message(u'openlp_process_events')
def performImport(self):
@@ -395,26 +403,26 @@
unicode(self.field(u'license_permissions').toString())
importer = None
if bible_type == BibleFormat.OSIS:
- # Import an OSIS bible
+ # Import an OSIS bible.
importer = self.manager.import_bible(BibleFormat.OSIS,
name=license_version,
filename=unicode(self.field(u'osis_location').toString())
)
elif bible_type == BibleFormat.CSV:
- # Import a CSV bible
+ # Import a CSV bible.
importer = self.manager.import_bible(BibleFormat.CSV,
name=license_version,
booksfile=unicode(self.field(u'csv_booksfile').toString()),
versefile=unicode(self.field(u'csv_versefile').toString())
)
elif bible_type == BibleFormat.OpenSong:
- # Import an OpenSong bible
+ # Import an OpenSong bible.
importer = self.manager.import_bible(BibleFormat.OpenSong,
name=license_version,
filename=unicode(self.field(u'opensong_file').toString())
)
elif bible_type == BibleFormat.WebDownload:
- # Import a bible from the web
+ # Import a bible from the web.
self.ImportProgressBar.setMaximum(1)
download_location = self.field(u'web_location').toInt()[0]
bible_version = unicode(self.BibleComboBox.currentText())
@@ -438,8 +446,14 @@
self.manager.save_meta_data(license_version, license_version,
license_copyright, license_permissions)
self.manager.reload_bibles()
- self.ImportProgressLabel.setText(
- translate('BiblesPlugin.ImportWizardForm', 'Finished import.'))
+ if bible_type == BibleFormat.WebDownload:
+ self.ImportProgressLabel.setText(
+ translate('BiblesPlugin.ImportWizardForm', 'Registered '
+ 'bible. Please note, that verses will be downloaded on\n'
+ 'demand and thus an internet connection is required.'))
+ else:
+ self.ImportProgressLabel.setText(translate(
+ 'BiblesPlugin.ImportWizardForm', 'Finished import.'))
else:
self.ImportProgressLabel.setText(
translate('BiblesPlugin.ImportWizardForm',
=== modified file 'openlp/plugins/bibles/lib/biblestab.py'
--- openlp/plugins/bibles/lib/biblestab.py 2010-09-16 21:10:36 +0000
+++ openlp/plugins/bibles/lib/biblestab.py 2010-11-17 19:24:20 +0000
@@ -110,9 +110,9 @@
self.BibleThemeComboBox.setObjectName(u'BibleThemeComboBox')
self.BibleThemeComboBox.addItem(QtCore.QString())
self.BibleThemeLayout.addWidget(self.BibleThemeComboBox)
- self.BibleDualCheckBox = QtGui.QCheckBox(self.VerseDisplayGroupBox)
- self.BibleDualCheckBox.setObjectName(u'BibleDualCheckBox')
- self.VerseDisplayLayout.addWidget(self.BibleDualCheckBox, 3, 0, 1, 1)
+ self.BibleSecondCheckBox = QtGui.QCheckBox(self.VerseDisplayGroupBox)
+ self.BibleSecondCheckBox.setObjectName(u'BibleSecondCheckBox')
+ self.VerseDisplayLayout.addWidget(self.BibleSecondCheckBox, 3, 0, 1, 1)
self.VerseDisplayLayout.addWidget(self.BibleThemeWidget, 4, 0, 1, 1)
self.ChangeNoteLabel = QtGui.QLabel(self.VerseDisplayGroupBox)
self.ChangeNoteLabel.setObjectName(u'ChangeNoteLabel')
@@ -143,8 +143,8 @@
self.LayoutStyleComboBox, QtCore.SIGNAL(u'activated(int)'),
self.onLayoutStyleComboBoxChanged)
QtCore.QObject.connect(
- self.BibleDualCheckBox, QtCore.SIGNAL(u'stateChanged(int)'),
- self.onBibleDualCheckBox)
+ self.BibleSecondCheckBox, QtCore.SIGNAL(u'stateChanged(int)'),
+ self.onBibleSecondCheckBox)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'theme_update_list'), self.updateThemeList)
@@ -176,8 +176,8 @@
translate('BiblesPlugin.BiblesTab', '[ And ]'))
self.ChangeNoteLabel.setText(translate('BiblesPlugin.BiblesTab',
'Note:\nChanges do not affect verses already in the service.'))
- self.BibleDualCheckBox.setText(
- translate('BiblesPlugin.BiblesTab', 'Display dual Bible verses'))
+ self.BibleSecondCheckBox.setText(
+ translate('BiblesPlugin.BiblesTab', 'Display second Bible verses'))
def onBibleThemeComboBoxChanged(self):
self.bible_theme = self.BibleThemeComboBox.currentText()
@@ -190,15 +190,15 @@
def onNewChaptersCheckBoxChanged(self, check_state):
self.show_new_chapters = False
- # we have a set value convert to True/False
+ # We have a set value convert to True/False.
if check_state == QtCore.Qt.Checked:
self.show_new_chapters = True
- def onBibleDualCheckBox(self, check_state):
- self.dual_bibles = False
- # we have a set value convert to True/False
+ def onBibleSecondCheckBox(self, check_state):
+ self.second_bibles = False
+ # We have a set value convert to True/False.
if check_state == QtCore.Qt.Checked:
- self.dual_bibles = True
+ self.second_bibles = True
def load(self):
settings = QtCore.QSettings()
@@ -211,12 +211,12 @@
u'verse layout style', QtCore.QVariant(0)).toInt()[0]
self.bible_theme = unicode(
settings.value(u'bible theme', QtCore.QVariant(u'')).toString())
- self.dual_bibles = settings.value(
- u'dual bibles', QtCore.QVariant(True)).toBool()
+ self.second_bibles = settings.value(
+ u'second bibles', QtCore.QVariant(True)).toBool()
self.NewChaptersCheckBox.setChecked(self.show_new_chapters)
self.DisplayStyleComboBox.setCurrentIndex(self.display_style)
self.LayoutStyleComboBox.setCurrentIndex(self.layout_style)
- self.BibleDualCheckBox.setChecked(self.dual_bibles)
+ self.BibleSecondCheckBox.setChecked(self.second_bibles)
settings.endGroup()
def save(self):
@@ -228,13 +228,18 @@
QtCore.QVariant(self.display_style))
settings.setValue(u'verse layout style',
QtCore.QVariant(self.layout_style))
- settings.setValue(u'dual bibles', QtCore.QVariant(self.dual_bibles))
+ settings.setValue(u'second bibles', QtCore.QVariant(self.second_bibles))
settings.setValue(u'bible theme', QtCore.QVariant(self.bible_theme))
settings.endGroup()
def updateThemeList(self, theme_list):
"""
- Called from ThemeManager when the Themes have changed
+ Called from ThemeManager when the Themes have changed.
+
+ ``theme_list``
+ The list of available themes::
+
+ [u'Bible Theme', u'Song Theme']
"""
self.BibleThemeComboBox.clear()
self.BibleThemeComboBox.addItem(u'')
@@ -243,7 +248,7 @@
index = self.BibleThemeComboBox.findText(
unicode(self.bible_theme), QtCore.Qt.MatchExactly)
if index == -1:
- # Not Found
+ # Not Found.
index = 0
self.bible_theme = u''
self.BibleThemeComboBox.setCurrentIndex(index)
=== modified file 'openlp/plugins/bibles/lib/db.py'
--- openlp/plugins/bibles/lib/db.py 2010-10-09 19:36:05 +0000
+++ openlp/plugins/bibles/lib/db.py 2010-11-17 19:24:20 +0000
@@ -44,24 +44,28 @@
"""
pass
+
class Testament(BaseModel):
"""
Bible Testaments
"""
pass
+
class Book(BaseModel):
"""
Song model
"""
pass
+
class Verse(BaseModel):
"""
Topic model
"""
pass
+
def init_schema(url):
"""
Setup a bible database connection and initialise the database schema.
@@ -240,7 +244,7 @@
and the value is the verse text.
"""
log.debug(u'create_chapter %s,%s', book_id, chapter)
- # text list has book and chapter as first two elements of the array
+ # Text list has book and chapter as first two elements of the array.
for verse_number, verse_text in textlist.iteritems():
verse = Verse.populate(
book_id = book_id,
=== modified file 'openlp/plugins/bibles/lib/http.py'
--- openlp/plugins/bibles/lib/http.py 2010-10-27 17:42:10 +0000
+++ openlp/plugins/bibles/lib/http.py 2010-11-17 19:24:20 +0000
@@ -364,12 +364,11 @@
if self.proxy_server:
self.create_meta(u'proxy server', self.proxy_server)
if self.proxy_username:
- # store the proxy userid
+ # Store the proxy userid.
self.create_meta(u'proxy username', self.proxy_username)
if self.proxy_password:
- # store the proxy password
+ # Store the proxy password.
self.create_meta(u'proxy password', self.proxy_password)
- self.wizard.incrementProgressBar('Registered.')
return True
def get_verses(self, reference_list):
@@ -417,7 +416,7 @@
## to request ac and get Acts back.
bookname = search_results.book
Receiver.send_message(u'openlp_process_events')
- # check to see if book/chapter exists
+ # Check to see if book/chapter exists.
db_book = self.get_book(bookname)
self.create_chapter(db_book.id, search_results.chapter,
search_results.verselist)
=== modified file 'openlp/plugins/bibles/lib/manager.py'
--- openlp/plugins/bibles/lib/manager.py 2010-10-27 17:42:10 +0000
+++ openlp/plugins/bibles/lib/manager.py 2010-11-17 19:24:20 +0000
@@ -257,17 +257,34 @@
'Book Chapter:Verse-Chapter:Verse'))
return None
- def verse_search(self, bible, text):
+ def verse_search(self, bible, second_bible, text):
"""
Does a verse search for the given bible and text.
``bible``
The bible to seach in (unicode).
+ ``second_bible``
+ The second bible (unicode). We do not search in this bible.
+
``text``
The text to search for (unicode).
"""
- log.debug(u'BibleManager.verse_search("%s", "%s")', bible, text)
+ log.debug(u'BibleManager.verse_search("%s", "%s")', bible, text)
+ # Check if the bible or second_bible is a web bible.
+ webbible = self.db_cache[bible].get_object(BibleMeta,
+ u'download source')
+ second_webbible = u''
+ if second_bible:
+ second_webbible = self.db_cache[second_bible].get_object(BibleMeta,
+ u'download source')
+ if webbible or second_webbible:
+ QtGui.QMessageBox.information(self.parent.mediaItem,
+ translate('BiblesPlugin.BibleManager',
+ 'Web Bible cannot be used'),
+ translate('BiblesPlugin.BibleManager', 'Text Search is not '
+ 'available with Web Bibles.'))
+ return None
if text:
return self.db_cache[bible].verse_search(text)
else:
@@ -317,4 +334,3 @@
"""
for bible in self.db_cache:
self.db_cache[bible].finalise()
-
=== modified file 'openlp/plugins/bibles/lib/mediaitem.py'
--- openlp/plugins/bibles/lib/mediaitem.py 2010-10-21 15:31:22 +0000
+++ openlp/plugins/bibles/lib/mediaitem.py 2010-11-17 19:24:20 +0000
@@ -47,21 +47,22 @@
self.parent().onListViewResize(event.size().width(),
event.size().width())
+
class BibleMediaItem(MediaManagerItem):
"""
This is the custom media manager item for Bibles.
"""
log.info(u'Bible Media Item loaded')
- def __init__(self, parent, icon, title):
+ def __init__(self, parent, plugin, icon):
self.PluginNameShort = u'Bible'
self.pluginNameVisible = translate('BiblesPlugin.MediaItem', 'Bible')
self.IconPath = u'songs/song'
self.ListViewWithDnD_class = BibleListView
- MediaManagerItem.__init__(self, parent, icon, title)
- # place to store the search results for both bibles
+ MediaManagerItem.__init__(self, parent, plugin, icon)
+ # Place to store the search results for both bibles.
self.search_results = {}
- self.dual_search_results = {}
+ self.second_search_results = {}
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'bibles_load_list'), self.reloadBibles)
@@ -83,7 +84,7 @@
self.SearchTabWidget.sizePolicy().hasHeightForWidth())
self.SearchTabWidget.setSizePolicy(sizePolicy)
self.SearchTabWidget.setObjectName(u'SearchTabWidget')
- # Add the Quick Search tab
+ # Add the Quick Search tab.
self.QuickTab = QtGui.QWidget()
self.QuickTab.setObjectName(u'QuickTab')
self.QuickLayout = QtGui.QGridLayout(self.QuickTab)
@@ -144,7 +145,7 @@
QuickSpacerItem = QtGui.QSpacerItem(20, 35, QtGui.QSizePolicy.Minimum,
QtGui.QSizePolicy.Expanding)
self.QuickLayout.addItem(QuickSpacerItem, 6, 2, 1, 1)
- # Add the Advanced Search tab
+ # Add the Advanced Search tab.
self.AdvancedTab = QtGui.QWidget()
self.AdvancedTab.setObjectName(u'AdvancedTab')
self.AdvancedLayout = QtGui.QGridLayout(self.AdvancedTab)
@@ -226,7 +227,7 @@
self.AdvancedLayout.addWidget(self.AdvancedMessage, 8, 0, 1, 3)
self.SearchTabWidget.addTab(self.AdvancedTab,
translate('BiblesPlugin.MediaItem', 'Advanced'))
- # Add the search tab widget to the page layout
+ # Add the search tab widget to the page layout.
self.pageLayout.addWidget(self.SearchTabWidget)
# Combo Boxes
QtCore.QObject.connect(self.AdvancedVersionComboBox,
@@ -270,7 +271,7 @@
def configUpdated(self):
log.debug(u'configUpdated')
- if QtCore.QSettings().value(self.settingsSection + u'/dual bibles',
+ if QtCore.QSettings().value(self.settingsSection + u'/second bibles',
QtCore.QVariant(True)).toBool():
self.AdvancedSecondBibleLabel.setVisible(True)
self.AdvancedSecondBibleComboBox.setVisible(True)
@@ -287,7 +288,7 @@
self.QuickVersionLabel.setText(
translate('BiblesPlugin.MediaItem', 'Version:'))
self.QuickSecondVersionLabel.setText(
- translate('BiblesPlugin.MediaItem', 'Dual:'))
+ translate('BiblesPlugin.MediaItem', 'Second:'))
self.QuickSearchLabel.setText(
translate('BiblesPlugin.MediaItem', 'Search type:'))
self.QuickSearchLabel.setText(
@@ -299,7 +300,7 @@
self.AdvancedVersionLabel.setText(
translate('BiblesPlugin.MediaItem', 'Version:'))
self.AdvancedSecondBibleLabel.setText(
- translate('BiblesPlugin.MediaItem', 'Dual:'))
+ translate('BiblesPlugin.MediaItem', 'Second:'))
self.AdvancedBookLabel.setText(
translate('BiblesPlugin.MediaItem', 'Book:'))
self.AdvancedChapterLabel.setText(
@@ -338,7 +339,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 onListViewResize(self, width, height):
@@ -363,8 +364,9 @@
if not hasattr(self, u'import_wizard'):
self.import_wizard = BibleImportForm(self, self.parent.manager,
self.parent)
- self.import_wizard.exec_()
- self.reloadBibles()
+ # If the import was not canceled then reload.
+ if self.import_wizard.exec_() == 1:
+ self.reloadBibles()
def loadBibles(self):
log.debug(u'Loading Bibles')
@@ -374,8 +376,10 @@
self.AdvancedSecondBibleComboBox.clear()
self.QuickSecondBibleComboBox.addItem(u'')
self.AdvancedSecondBibleComboBox.addItem(u'')
+ # Get all bibles and sort the list.
bibles = self.parent.manager.get_bibles().keys()
- # load bibles into the combo boxes
+ bibles.sort()
+ # Load the bibles into the combo boxes.
first = True
for bible in bibles:
if bible:
@@ -482,6 +486,17 @@
def adjustComboBox(self, range_from, range_to, combo, restore=False):
"""
+ Adjusts the given como box to the given values.
+
+ ``range_from``
+ The first number of the range (int).
+
+ ``range_to``
+ The last number of the range (int).
+
+ ``combo``
+ The combo box itself (QComboBox).
+
``restore``
If True, then the combo's currentText will be restored after
adjusting (if possible).
@@ -490,16 +505,19 @@
if restore:
old_text = unicode(combo.currentText())
combo.clear()
- for i in range(int(range_from), int(range_to) + 1):
+ for i in range(range_from, range_to + 1):
combo.addItem(unicode(i))
if restore and combo.findText(old_text) != -1:
combo.setCurrentIndex(combo.findText(old_text))
def onAdvancedSearchButton(self):
+ """
+ Does an advanced search and saves the search results.
+ """
log.debug(u'Advanced Search Button pressed')
self.AdvancedSearchButton.setEnabled(False)
bible = unicode(self.AdvancedVersionComboBox.currentText())
- dual_bible = unicode(self.AdvancedSecondBibleComboBox.currentText())
+ second_bible = unicode(self.AdvancedSecondBibleComboBox.currentText())
book = unicode(self.AdvancedBookComboBox.currentText())
chapter_from = int(self.AdvancedFromChapter.currentText())
chapter_to = int(self.AdvancedToChapter.currentText())
@@ -508,74 +526,81 @@
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 second_bible:
+ self.second_search_results = self.parent.manager.get_verses(
+ second_bible, versetext)
if self.ClearAdvancedSearchComboBox.currentIndex() == 0:
self.listView.clear()
if self.listView.count() != 0:
+ # Check if the first item is a second bible item or not.
bitem = self.listView.item(0)
- item_dual_bible = self._decodeQtObject(bitem, 'dual_bible')
- if item_dual_bible and dual_bible or not item_dual_bible and \
- not dual_bible:
- self.displayResults(bible, dual_bible)
+ item_second_bible = self._decodeQtObject(bitem, 'second_bible')
+ if item_second_bible and second_bible or not item_second_bible and \
+ not second_bible:
+ self.displayResults(bible, second_bible)
elif QtGui.QMessageBox.critical(self,
translate('BiblePlugin.MediaItem', 'Error'),
translate('BiblePlugin.MediaItem', 'You cannot combine single '
- 'and dual bible verses. Do you want to delete your search '
+ 'and second bible verses. Do you want to delete your search '
'results and start a new search?'),
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.No |
QtGui.QMessageBox.Yes)) == QtGui.QMessageBox.Yes:
self.listView.clear()
- self.displayResults(bible, dual_bible)
+ self.displayResults(bible, second_bible)
else:
- self.displayResults(bible, dual_bible)
+ self.displayResults(bible, second_bible)
self.AdvancedSearchButton.setEnabled(True)
def onQuickSearchButton(self):
+ """
+ Does a quick search and saves the search results. Quick search can
+ either be "Verse Search" or "Text Search".
+ """
log.debug(u'Quick Search Button pressed')
self.QuickSearchButton.setEnabled(False)
bible = unicode(self.QuickVersionComboBox.currentText())
- dual_bible = unicode(self.QuickSecondBibleComboBox.currentText())
+ second_bible = unicode(self.QuickSecondBibleComboBox.currentText())
text = unicode(self.QuickSearchEdit.text())
if self.QuickSearchComboBox.currentIndex() == 0:
# We are doing a 'Verse Search'.
self.search_results = self.parent.manager.get_verses(bible, text)
- if dual_bible and self.search_results:
- self.dual_search_results = self.parent.manager.get_verses(
- dual_bible, text)
+ if second_bible and self.search_results:
+ self.second_search_results = self.parent.manager.get_verses(
+ second_bible, text)
else:
- # We are doing a ' Text Search'.
+ # We are doing a 'Text Search'.
bibles = self.parent.manager.get_bibles()
- self.search_results = self.parent.manager.verse_search(bible, text)
- if dual_bible and self.search_results:
+ self.search_results = self.parent.manager.verse_search(bible,
+ second_bible, text)
+ if second_bible and self.search_results:
text = []
for verse in self.search_results:
text.append((verse.book.name, verse.chapter, verse.verse,
verse.verse))
- self.dual_search_results = bibles[dual_bible].get_verses(text)
+ self.second_search_results = \
+ bibles[second_bible].get_verses(text)
if self.ClearQuickSearchComboBox.currentIndex() == 0:
self.listView.clear()
if self.listView.count() != 0 and self.search_results:
bitem = self.listView.item(0)
- item_dual_bible = self._decodeQtObject(bitem, 'dual_bible')
- if item_dual_bible and dual_bible or not item_dual_bible and \
- not dual_bible:
- self.displayResults(bible, dual_bible)
+ item_second_bible = self._decodeQtObject(bitem, 'second_bible')
+ if item_second_bible and second_bible or not item_second_bible and \
+ not second_bible:
+ self.displayResults(bible, second_bible)
elif QtGui.QMessageBox.critical(self,
translate('BiblePlugin.MediaItem', 'Error'),
translate('BiblePlugin.MediaItem', 'You cannot combine single '
- 'and dual bible verses. Do you want to delete your search '
+ 'and second bible verses. Do you want to delete your search '
'results and start a new search?'),
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.No |
QtGui.QMessageBox.Yes)) == QtGui.QMessageBox.Yes:
self.listView.clear()
- self.displayResults(bible, dual_bible)
+ self.displayResults(bible, second_bible)
elif self.search_results:
- self.displayResults(bible, dual_bible)
+ self.displayResults(bible, second_bible)
self.QuickSearchButton.setEnabled(True)
- def displayResults(self, bible, dual_bible=u''):
+ def displayResults(self, bible, second_bible=u''):
"""
Displays the search results in the media manager. All data needed for
further action is saved for/in each row.
@@ -583,19 +608,17 @@
version = self.parent.manager.get_meta_data(bible, u'Version')
copyright = self.parent.manager.get_meta_data(bible, u'Copyright')
permissions = self.parent.manager.get_meta_data(bible, u'Permissions')
- if dual_bible:
- dual_version = self.parent.manager.get_meta_data(dual_bible,
+ if second_bible:
+ second_version = self.parent.manager.get_meta_data(second_bible,
u'Version')
- dual_copyright = self.parent.manager.get_meta_data(dual_bible,
+ second_copyright = self.parent.manager.get_meta_data(second_bible,
u'Copyright')
- dual_permissions = self.parent.manager.get_meta_data(dual_bible,
+ second_permissions = self.parent.manager.get_meta_data(second_bible,
u'Permissions')
- if not dual_permissions:
- dual_permissions = u''
- # We count the number of rows which are maybe already present.
- start_count = self.listView.count()
+ if not second_permissions:
+ second_permissions = u''
for count, verse in enumerate(self.search_results):
- if dual_bible:
+ if second_bible:
vdict = {
'book': QtCore.QVariant(verse.book.name),
'chapter': QtCore.QVariant(verse.chapter),
@@ -605,16 +628,17 @@
'copyright': QtCore.QVariant(copyright.value),
'permissions': QtCore.QVariant(permissions.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_permissions': QtCore.QVariant(dual_permissions.value),
- 'dual_text': QtCore.QVariant(
- self.dual_search_results[count].text)
+ 'second_bible': QtCore.QVariant(second_bible),
+ 'second_version': QtCore.QVariant(second_version.value),
+ 'second_copyright': QtCore.QVariant(second_copyright.value),
+ 'second_permissions': QtCore.QVariant(
+ second_permissions.value),
+ 'second_text': QtCore.QVariant(
+ self.second_search_results[count].text)
}
bible_text = u' %s %d:%d (%s, %s)' % (verse.book.name,
verse.chapter, verse.verse, version.value,
- dual_version.value)
+ second_version.value)
else:
vdict = {
'book': QtCore.QVariant(verse.book.name),
@@ -625,22 +649,20 @@
'copyright': QtCore.QVariant(copyright.value),
'permissions': QtCore.QVariant(permissions.value),
'text': QtCore.QVariant(verse.text),
- 'dual_bible': QtCore.QVariant(u''),
- 'dual_version': QtCore.QVariant(u''),
- 'dual_copyright': QtCore.QVariant(u''),
- 'dual_permissions': QtCore.QVariant(u''),
- 'dual_text': QtCore.QVariant(u'')
+ 'second_bible': QtCore.QVariant(u''),
+ 'second_version': QtCore.QVariant(u''),
+ 'second_copyright': QtCore.QVariant(u''),
+ 'second_permissions': QtCore.QVariant(u''),
+ 'second_text': QtCore.QVariant(u'')
}
- bible_text = u' %s %d:%d (%s)' % (verse.book.name,
+ bible_text = u'%s %d:%d (%s)' % (verse.book.name,
verse.chapter, verse.verse, version.value)
bible_verse = QtGui.QListWidgetItem(bible_text)
bible_verse.setData(QtCore.Qt.UserRole, QtCore.QVariant(vdict))
self.listView.addItem(bible_verse)
- row = self.listView.setCurrentRow(count + start_count)
- if row:
- row.setSelected(True)
+ self.listView.selectAll()
self.search_results = {}
- self.dual_search_results = {}
+ self.second_search_results = {}
def _decodeQtObject(self, bitem, key):
reference = bitem.data(QtCore.Qt.UserRole)
@@ -661,7 +683,7 @@
if len(items) == 0:
return False
bible_text = u''
- old_chapter = u''
+ old_chapter = -1
raw_footer = []
raw_slides = []
raw_title = []
@@ -676,22 +698,22 @@
copyright = self._decodeQtObject(bitem, 'copyright')
permissions = self._decodeQtObject(bitem, 'permissions')
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_permissions = self._decodeQtObject(bitem, 'dual_permissions')
- dual_text = self._decodeQtObject(bitem, 'dual_text')
+ second_bible = self._decodeQtObject(bitem, 'second_bible')
+ second_version = self._decodeQtObject(bitem, 'second_version')
+ second_copyright = self._decodeQtObject(bitem, 'second_copyright')
+ second_permissions = self._decodeQtObject(bitem, 'second_permissions')
+ second_text = self._decodeQtObject(bitem, 'second_text')
verse_text = self.formatVerse(old_chapter, chapter, verse)
footer = u'%s (%s %s %s)' % (book, version, copyright, permissions)
if footer not in raw_footer:
raw_footer.append(footer)
- if dual_bible:
- footer = u'%s (%s %s %s)' % (book, dual_version, dual_copyright,
- dual_permissions)
+ if second_bible:
+ footer = u'%s (%s %s %s)' % (book, second_version,
+ second_copyright, second_permissions)
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)
+ second_text)
raw_slides.append(bible_text)
bible_text = u''
# If we are 'Verse Per Slide' then create a new slide.
@@ -719,7 +741,7 @@
raw_slides.append(bible_text)
bible_text = u''
# Service Item: Capabilities
- if self.parent.settings_tab.layout_style == 2 and not dual_bible:
+ if self.parent.settings_tab.layout_style == 2 and not second_bible:
# Split the line but do not replace line breaks in renderer.
service_item.add_capability(ItemCapabilities.NoLineBreaks)
service_item.add_capability(ItemCapabilities.AllowsPreview)
@@ -749,6 +771,12 @@
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.
+
+ ``start_item``
+ The first item of a range.
+
+ ``old_item``
+ The last item of a range.
"""
old_bitem = self.listView.item(old_item.row())
old_chapter = int(self._decodeQtObject(old_bitem, 'chapter'))
@@ -758,18 +786,18 @@
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:
+ start_second_bible = self._decodeQtObject(start_bitem, 'second_bible')
+ if start_second_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)
+ start_verse, start_bible, start_second_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)
+ start_verse, old_verse, start_bible, start_second_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)
+ start_second_bible)
else:
if start_verse == old_verse and start_chapter == old_chapter:
title = u'%s %s:%s (%s)' % (start_book, start_chapter,
@@ -785,34 +813,62 @@
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.
+ the case, we return True, otherwise False. E. g. if we added
+ Genesis 1:1-6, but the next verse is Daniel 2:14, we return True.
+
+ ``item``
+ The item we are dealing with at the moment.
+
+ ``old_item``
+ The item we were previously dealing with.
"""
+ # Get all the necessary meta data.
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')
+ second_bible = self._decodeQtObject(bitem, 'second_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_second_bible = self._decodeQtObject(old_bitem, 'second_bible')
+ if old_bible != bible or old_second_bible != second_bible or \
old_book != book:
+ # The bible, second bible or book has changed.
return True
elif old_verse + 1 != verse and old_chapter == chapter:
+ # We are still in the same chapter, but a verse has been skipped.
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)):
+ # We are in the following chapter, but the last verse was not the
+ # last verse of the chapter or the current verse is not the
+ # first one of the chapter.
return True
else:
return False
def formatVerse(self, old_chapter, chapter, verse):
+ """
+ Formats and returns the text, each verse starts with, for the given
+ chapter and verse. The text is either surrounded by round, square,
+ curly brackets or no brackets at all. For example::
+
+ u'{su}1:1{/su}'
+
+ ``old_chapter``
+ The previous verse's chapter number (int).
+
+ ``chapter``
+ The chapter number (int).
+
+ ``verse``
+ The verse number (int).
+ """
if not self.parent.settings_tab.show_new_chapters or \
old_chapter != chapter:
verse_text = u'%s:%s' % (chapter, verse)
=== modified file 'openlp/plugins/songs/forms/songmaintenanceform.py'
--- openlp/plugins/songs/forms/songmaintenanceform.py 2010-11-03 18:18:44 +0000
+++ openlp/plugins/songs/forms/songmaintenanceform.py 2010-11-17 19:24:20 +0000
@@ -405,7 +405,7 @@
def mergeAuthors(self, old_author):
"""
Merges two authors into one author.
-
+
``old_author``
The author which will be deleted afterwards.
"""
@@ -427,7 +427,7 @@
def mergeTopics(self, old_topic):
"""
Merges two topics into one topic.
-
+
``old_topic``
The topic which will be deleted afterwards.
"""
@@ -447,7 +447,7 @@
def mergeBooks(self, old_book):
"""
Merges two books into one book.
-
+
``old_book``
The book which will be deleted afterwards.
"""
Follow ups