Bug fixes for errors in search

Code Cleanups while in the code.
This commit is contained in:
Tim Bentley 2009-06-07 17:33:33 +01:00
parent debd073023
commit 1dcd0623f1
3 changed files with 171 additions and 154 deletions

View File

@ -92,7 +92,7 @@ class MediaManagerItem(QtGui.QWidget):
""" """
if type(icon) is QtGui.QIcon: if type(icon) is QtGui.QIcon:
ButtonIcon = icon ButtonIcon = icon
elif type(icon) is types.StringType: elif type(icon) is types.StringType or type(icon) is types.UnicodeType:
ButtonIcon = QtGui.QIcon() ButtonIcon = QtGui.QIcon()
if icon.startswith(u':/'): if icon.startswith(u':/'):
ButtonIcon.addPixmap(QtGui.QPixmap(icon), QtGui.QIcon.Normal, ButtonIcon.addPixmap(QtGui.QPixmap(icon), QtGui.QIcon.Normal,

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 # vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
""" '''
OpenLP - Open Source Lyrics Projection OpenLP - Open Source Lyrics Projection
Copyright (c) 2008 Raoul Snyman Copyright (c) 2008 Raoul Snyman
Portions copyright (c) 2008 - 2009 Martin Thompson, Tim Bentley Portions copyright (c) 2008 - 2009 Martin Thompson, Tim Bentley
@ -16,7 +16,7 @@ PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place, Suite 330, Boston, MA 02111-1307 USA Place, Suite 330, Boston, MA 02111-1307 USA
""" '''
import sys import sys
import os, os.path import os, os.path
import sys import sys
@ -31,15 +31,15 @@ from openlp.core.lib import Receiver, translate
class BibleImportForm(QtGui.QDialog, Ui_BibleImportDialog): class BibleImportForm(QtGui.QDialog, Ui_BibleImportDialog):
global log global log
log=logging.getLogger("BibleImportForm") log=logging.getLogger(u'BibleImportForm')
log.info("BibleImportForm loaded") log.info(u'BibleImportForm loaded')
""" '''
Class documentation goes here. Class documentation goes here.
""" '''
def __init__(self, config, biblemanager , bibleplugin, parent = None): def __init__(self, config, biblemanager , bibleplugin, parent = None):
""" '''
Constructor Constructor
""" '''
QtGui.QDialog.__init__(self, parent) QtGui.QDialog.__init__(self, parent)
self.setupUi(self) self.setupUi(self)
self.biblemanager = biblemanager self.biblemanager = biblemanager
@ -47,58 +47,72 @@ class BibleImportForm(QtGui.QDialog, Ui_BibleImportDialog):
self.bibleplugin = bibleplugin self.bibleplugin = bibleplugin
self.bible_type = None self.bible_type = None
self.barmax = 0 self.barmax = 0
self.AddressEdit.setText(self.config.get_config("proxy_address", "")) self.AddressEdit.setText(self.config.get_config(u'proxy_address', u''))
self.UsernameEdit.setText(self.config.get_config("proxy_username", "")) self.UsernameEdit.setText(self.config.get_config(u'proxy_username',u''))
self.PasswordEdit.setText(self.config.get_config("proxy_password","")) self.PasswordEdit.setText(self.config.get_config(u'proxy_password',u''))
filepath = os.path.split(os.path.abspath(__file__))[0] filepath = os.path.split(os.path.abspath(__file__))[0]
filepath = os.path.abspath(os.path.join(filepath, '..', 'resources','crosswalkbooks.csv')) filepath = os.path.abspath(os.path.join(filepath, u'..',
u'resources',u'crosswalkbooks.csv'))
fbibles=open(filepath, 'r') fbibles=open(filepath, 'r')
self.bible_versions = {} self.bible_versions = {}
self.BibleComboBox.clear() self.BibleComboBox.clear()
self.BibleComboBox.addItem("") self.BibleComboBox.addItem(u'')
for line in fbibles: for line in fbibles:
p = line.split(",") p = line.split(u',')
self.bible_versions[p[0]] = p[1].replace('\n', '') self.bible_versions[p[0]] = p[1].replace(u'\n', u'')
self.BibleComboBox.addItem(str(p[0])) self.BibleComboBox.addItem(str(p[0]))
#Combo Boxes #Combo Boxes
QtCore.QObject.connect(self.LocationComboBox, QtCore.SIGNAL("activated(int)"), self.onLocationComboBoxSelected) QtCore.QObject.connect(self.LocationComboBox,
QtCore.QObject.connect(self.BibleComboBox, QtCore.SIGNAL("activated(int)"), self.onBibleComboBoxSelected) QtCore.SIGNAL(u'activated(int)'), self.onLocationComboBoxSelected)
QtCore.QObject.connect(self.BibleComboBox,
QtCore.SIGNAL(u'activated(int)'), self.onBibleComboBoxSelected)
#Buttons #Buttons
QtCore.QObject.connect(self.ImportButton, QtCore.SIGNAL("pressed()"), self.onImportButtonClicked) QtCore.QObject.connect(self.ImportButton,
QtCore.QObject.connect(self.CancelButton, QtCore.SIGNAL("pressed()"), self.onCancelButtonClicked) QtCore.SIGNAL(u'pressed()'), self.onImportButtonClicked)
QtCore.QObject.connect(self.VersesFileButton, QtCore.SIGNAL("pressed()"), self.onVersesFileButtonClicked) QtCore.QObject.connect(self.CancelButton,
QtCore.QObject.connect(self.BooksFileButton, QtCore.SIGNAL("pressed()"), self.onBooksFileButtonClicked) QtCore.SIGNAL(u'pressed()'), self.onCancelButtonClicked)
QtCore.QObject.connect(self.OsisFileButton, QtCore.SIGNAL("pressed()"), self.onOsisFileButtonClicked) QtCore.QObject.connect(self.VersesFileButton,
QtCore.SIGNAL(u'pressed()'), self.onVersesFileButtonClicked)
QtCore.QObject.connect(self.BooksFileButton,
QtCore.SIGNAL(u'pressed()'), self.onBooksFileButtonClicked)
QtCore.QObject.connect(self.OsisFileButton,
QtCore.SIGNAL(u'pressed()'), self.onOsisFileButtonClicked)
#Lost Focus #Lost Focus
QtCore.QObject.connect(self.OSISLocationEdit, QtCore.SIGNAL("lostFocus()"), self.onOSISLocationEditLostFocus) QtCore.QObject.connect(self.OSISLocationEdit,
QtCore.QObject.connect(self.BooksLocationEdit, QtCore.SIGNAL("lostFocus()"),self.onBooksLocationEditLostFocus) QtCore.SIGNAL(u'lostFocus()'), self.onOSISLocationEditLostFocus)
QtCore.QObject.connect(self.VerseLocationEdit, QtCore.SIGNAL("lostFocus()"), self.onVerseLocationEditLostFocus) QtCore.QObject.connect(self.BooksLocationEdit,
QtCore.QObject.connect(self.AddressEdit, QtCore.SIGNAL("lostFocus()"), self.onProxyAddressEditLostFocus) QtCore.SIGNAL(u'lostFocus()'),self.onBooksLocationEditLostFocus)
QtCore.QObject.connect(self.UsernameEdit, QtCore.SIGNAL("lostFocus()"), self.onProxyUsernameEditLostFocus) QtCore.QObject.connect(self.VerseLocationEdit,
QtCore.QObject.connect(self.PasswordEdit, QtCore.SIGNAL("lostFocus()"), self.onProxyPasswordEditLostFocus) QtCore.SIGNAL(u'lostFocus()'), self.onVerseLocationEditLostFocus)
QtCore.QObject.connect(self.AddressEdit,
QtCore.SIGNAL(u'lostFocus()'), self.onProxyAddressEditLostFocus)
QtCore.QObject.connect(self.UsernameEdit,
QtCore.SIGNAL(u'lostFocus()'), self.onProxyUsernameEditLostFocus)
QtCore.QObject.connect(self.PasswordEdit,
QtCore.SIGNAL(u'lostFocus()'), self.onProxyPasswordEditLostFocus)
def onVersesFileButtonClicked(self): def onVersesFileButtonClicked(self):
filename = QtGui.QFileDialog.getOpenFileName(self, 'Open file',self.config.get_last_dir(1)) filename = QtGui.QFileDialog.getOpenFileName(self, u'Open file',self.config.get_last_dir(1))
if filename != "": if filename != u'':
self.VerseLocationEdit.setText(filename) self.VerseLocationEdit.setText(filename)
self.config.set_last_dir(filename, 1) self.config.set_last_dir(filename, 1)
self.setCsv() self.setCsv()
def onBooksFileButtonClicked(self): def onBooksFileButtonClicked(self):
filename = QtGui.QFileDialog.getOpenFileName(self, 'Open file',self.config.get_last_dir(2)) filename = QtGui.QFileDialog.getOpenFileName(self, u'Open file',self.config.get_last_dir(2))
if filename != "": if filename != u'':
self.BooksLocationEdit.setText(filename) self.BooksLocationEdit.setText(filename)
self.config.set_last_dir(filename, 2) self.config.set_last_dir(filename, 2)
self.setCsv() self.setCsv()
def onOsisFileButtonClicked(self): def onOsisFileButtonClicked(self):
filename = QtGui.QFileDialog.getOpenFileName(self, 'Open file',self.config.get_last_dir(3)) filename = QtGui.QFileDialog.getOpenFileName(self, u'Open file',self.config.get_last_dir(3))
if filename != "": if filename != u'':
self.OSISLocationEdit.setText(filename) self.OSISLocationEdit.setText(filename)
self.config.set_last_dir(filename, 3) self.config.set_last_dir(filename, 3)
self.setOsis() self.setOsis()
@ -108,7 +122,7 @@ class BibleImportForm(QtGui.QDialog, Ui_BibleImportDialog):
self.setOsis() self.setOsis()
else: else:
# Was OSIS and is not any more stops lostFocus running mad # Was OSIS and is not any more stops lostFocus running mad
if self.bible_type == "OSIS": if self.bible_type == u'OSIS':
self.bible_type = None self.bible_type = None
self.freeAll() self.freeAll()
@ -119,13 +133,13 @@ class BibleImportForm(QtGui.QDialog, Ui_BibleImportDialog):
self.checkOsis() self.checkOsis()
def onProxyAddressEditLostFocus(self): def onProxyAddressEditLostFocus(self):
self.config.set_config("proxy_address", str(self.AddressEdit.displayText())) self.config.set_config(u'proxy_address', str(self.AddressEdit.displayText()))
def onProxyUsernameEditLostFocus(self): def onProxyUsernameEditLostFocus(self):
self.config.set_config("proxy_username", str(self.UsernameEdit.displayText())) self.config.set_config(u'proxy_username', str(self.UsernameEdit.displayText()))
def onProxyPasswordEditLostFocus(self): def onProxyPasswordEditLostFocus(self):
self.config.set_config("proxy_password", str(self.PasswordEdit.displayText())) self.config.set_config(u'proxy_password', str(self.PasswordEdit.displayText()))
def onLocationComboBoxSelected(self): def onLocationComboBoxSelected(self):
self.checkHttp() self.checkHttp()
@ -136,49 +150,51 @@ class BibleImportForm(QtGui.QDialog, Ui_BibleImportDialog):
def onCancelButtonClicked(self): def onCancelButtonClicked(self):
# tell import to stop # tell import to stop
Receiver().send_message("openlpstopimport") self.message = u'Bible import stopped'
Receiver().send_message(u'openlpstopimport')
# tell bibleplugin to reload the bibles # tell bibleplugin to reload the bibles
Receiver().send_message("openlpreloadbibles") Receiver().send_message(u'openlpreloadbibles')
self.close() self.close()
def onImportButtonClicked(self): def onImportButtonClicked(self):
self.message = u'Bible import completed'
if self.biblemanager != None: if self.biblemanager != None:
if not self.bible_type == None and len(self.BibleNameEdit.displayText()) > 0: if not self.bible_type == None and len(self.BibleNameEdit.displayText()) > 0:
self.MessageLabel.setText("Import Started") self.MessageLabel.setText(u'Import Started')
self.ProgressBar.setMinimum(0) self.ProgressBar.setMinimum(0)
self.setMax(65) self.setMax(65)
self.ProgressBar.setValue(0) self.ProgressBar.setValue(0)
self.biblemanager.process_dialog(self) self.biblemanager.process_dialog(self)
self.importBible() self.importBible()
self.MessageLabel.setText("Import Complete") self.MessageLabel.setText(u'Import Complete')
self.ProgressBar.setValue(self.barmax) self.ProgressBar.setValue(self.barmax)
# tell bibleplugin to reload the bibles # tell bibleplugin to reload the bibles
Receiver().send_message("openlpreloadbibles") Receiver().send_message(u'openlpreloadbibles')
message = u'Bible import completered'
reply = QtGui.QMessageBox.information(self, reply = QtGui.QMessageBox.information(self,
translate(u'BibleMediaItem', u'Information'), translate(u'BibleMediaItem', u'Information'),
translate(u'BibleMediaItem', message)) translate(u'BibleMediaItem', self.message))
def setMax(self, max): def setMax(self, max):
log.debug("set Max %s", max) log.debug(u'set Max %s', max)
self.barmax = max self.barmax = max
self.ProgressBar.setMaximum(max) self.ProgressBar.setMaximum(max)
def incrementProgressBar(self, text ): def incrementProgressBar(self, text ):
log.debug("IncrementBar %s", text) log.debug(u'IncrementBar %s', text)
self.MessageLabel.setText("Import processing " + text) self.MessageLabel.setText(u'Import processing ' + text)
self.ProgressBar.setValue(self.ProgressBar.value()+1) self.ProgressBar.setValue(self.ProgressBar.value()+1)
def importBible(self): def importBible(self):
log.debug("Import Bible ") log.debug(u'Import Bible ')
if self.bible_type == "OSIS": if self.bible_type == u'OSIS':
loaded = self.biblemanager.register_osis_file_bible(str(self.BibleNameEdit.displayText()), loaded = self.biblemanager.register_osis_file_bible(str(self.BibleNameEdit.displayText()),
self.OSISLocationEdit.displayText()) self.OSISLocationEdit.displayText())
elif self.bible_type == "CSV": elif self.bible_type == u'CSV':
loaded = self.biblemanager.register_csv_file_bible(str(self.BibleNameEdit.displayText()), loaded = self.biblemanager.register_csv_file_bible(str(self.BibleNameEdit.displayText()),
self.BooksLocationEdit.displayText(), self.VerseLocationEdit.displayText()) self.BooksLocationEdit.displayText(), self.VerseLocationEdit.displayText())
else: else:
self.setMax(1) # set a value as it will not be needed # set a value as it will not be needed
self.setMax(1)
bible = self.bible_versions[str(self.BibleComboBox.currentText())] bible = self.bible_versions[str(self.BibleComboBox.currentText())]
loaded = self.biblemanager.register_http_bible(str(self.BibleComboBox.currentText()), \ loaded = self.biblemanager.register_http_bible(str(self.BibleComboBox.currentText()), \
str(self.LocationComboBox.currentText()), \ str(self.LocationComboBox.currentText()), \
@ -192,15 +208,17 @@ class BibleImportForm(QtGui.QDialog, Ui_BibleImportDialog):
str(self.CopyrightEdit.displayText()), str(self.CopyrightEdit.displayText()),
str(self.PermisionEdit.displayText())) str(self.PermisionEdit.displayText()))
self.bible_type = None self.bible_type = None
self.freeAll() # free the screen state restrictions # free the screen state restrictions
self.resetAll() # reset all the screen fields self.freeAll()
# reset all the screen fields
self.resetAll()
def checkOsis(self): def checkOsis(self):
if len(self.BooksLocationEdit.displayText()) > 0 or len(self.VerseLocationEdit.displayText()) > 0: if len(self.BooksLocationEdit.displayText()) > 0 or len(self.VerseLocationEdit.displayText()) > 0:
self.setCsv() self.setCsv()
else: else:
# Was CSV and is not any more stops lostFocus running mad # Was CSV and is not any more stops lostFocus running mad
if self.bible_type == "CSV": if self.bible_type == u'CSV':
self.bible_type = None self.bible_type = None
self.freeAll() self.freeAll()
@ -209,7 +227,7 @@ class BibleImportForm(QtGui.QDialog, Ui_BibleImportDialog):
self.setHttp() self.setHttp()
else: else:
# Was HTTP and is not any more stops lostFocus running mad # Was HTTP and is not any more stops lostFocus running mad
if self.bible_type == "HTTP": if self.bible_type == u'HTTP':
self.bible_type = None self.bible_type = None
self.freeAll() self.freeAll()
@ -220,7 +238,7 @@ class BibleImportForm(QtGui.QDialog, Ui_BibleImportDialog):
self.VersesFileButton.setEnabled(False) self.VersesFileButton.setEnabled(False)
def setCsv(self): def setCsv(self):
self.bible_type = "CSV" self.bible_type = u'CSV'
self.BooksLocationEdit.setReadOnly(False) self.BooksLocationEdit.setReadOnly(False)
self.VerseLocationEdit.setReadOnly(False) self.VerseLocationEdit.setReadOnly(False)
self.BooksFileButton.setEnabled(True) self.BooksFileButton.setEnabled(True)
@ -229,7 +247,7 @@ class BibleImportForm(QtGui.QDialog, Ui_BibleImportDialog):
self.blockHttp() self.blockHttp()
def setOsis(self): def setOsis(self):
self.bible_type = "OSIS" self.bible_type = 'OSIS'
self.OSISLocationEdit.setReadOnly(False) self.OSISLocationEdit.setReadOnly(False)
self.OsisFileButton.setEnabled(True) self.OsisFileButton.setEnabled(True)
self.blockCsv() self.blockCsv()
@ -240,7 +258,7 @@ class BibleImportForm(QtGui.QDialog, Ui_BibleImportDialog):
self.OsisFileButton.setEnabled(False) self.OsisFileButton.setEnabled(False)
def setHttp(self): def setHttp(self):
self.bible_type = "HTTP" self.bible_type = u'HTTP'
self.LocationComboBox.setEnabled(True) self.LocationComboBox.setEnabled(True)
self.BibleComboBox.setEnabled(True) self.BibleComboBox.setEnabled(True)
self.blockCsv() self.blockCsv()
@ -262,9 +280,9 @@ class BibleImportForm(QtGui.QDialog, Ui_BibleImportDialog):
self.BibleComboBox.setEnabled(True) self.BibleComboBox.setEnabled(True)
def resetAll(self): def resetAll(self):
self.BooksLocationEdit.setText("") self.BooksLocationEdit.setText(u'')
self.VerseLocationEdit.setText("") self.VerseLocationEdit.setText(u'')
self.OSISLocationEdit.setText("") self.OSISLocationEdit.setText(u'')
self.BibleNameEdit.setText("") self.BibleNameEdit.setText(u'')
self.LocationComboBox.setCurrentIndex(0) self.LocationComboBox.setCurrentIndex(0)
self.BibleComboBox.setCurrentIndex(0) self.BibleComboBox.setCurrentIndex(0)

View File

@ -61,7 +61,7 @@ class BibleMediaItem(MediaManagerItem):
MediaManagerItem.__init__(self, parent, icon, title) MediaManagerItem.__init__(self, parent, icon, title)
self.search_results = {} # place to store the search results self.search_results = {} # place to store the search results
QtCore.QObject.connect(Receiver().get_receiver(), QtCore.QObject.connect(Receiver().get_receiver(),
QtCore.SIGNAL("openlpreloadbibles"), self.reloadBibles) QtCore.SIGNAL(u'openlpreloadbibles'), self.reloadBibles)
def setupUi(self): def setupUi(self):
# Add a toolbar # Add a toolbar
@ -69,27 +69,27 @@ class BibleMediaItem(MediaManagerItem):
# Create buttons for the toolbar # Create buttons for the toolbar
## New Bible Button ## ## New Bible Button ##
self.addToolbarButton( self.addToolbarButton(
translate(u'BibleMediaItem','New Bible'), translate(u'BibleMediaItem',u'New Bible'),
translate(u'BibleMediaItem','Register a new Bible'), translate(u'BibleMediaItem',u'Register a new Bible'),
':/themes/theme_import.png', self.onBibleNewClick, 'BibleNewItem') u':/themes/theme_import.png', self.onBibleNewClick, u'BibleNewItem')
## Separator Line ## ## Separator Line ##
self.addToolbarSeparator() self.addToolbarSeparator()
## Preview Bible Button ## ## Preview Bible Button ##
self.addToolbarButton( self.addToolbarButton(
translate(u'BibleMediaItem','Preview Bible'), translate(u'BibleMediaItem',u'Preview Bible'),
translate(u'BibleMediaItem','Preview the selected Bible Verse'), translate(u'BibleMediaItem',u'Preview the selected Bible Verse'),
':/system/system_preview.png', self.onBiblePreviewClick, 'BiblePreviewItem') u':/system/system_preview.png', self.onBiblePreviewClick, u'BiblePreviewItem')
## Live Bible Button ## ## Live Bible Button ##
self.addToolbarButton( self.addToolbarButton(
translate(u'BibleMediaItem','Go Live'), translate(u'BibleMediaItem',u'Go Live'),
translate(u'BibleMediaItem','Send the selected Bible Verse(s) live'), translate(u'BibleMediaItem',u'Send the selected Bible Verse(s) live'),
':/system/system_live.png', self.onBibleLiveClick, 'BibleLiveItem') u':/system/system_live.png', self.onBibleLiveClick, u'BibleLiveItem')
## Add Bible Button ## ## Add Bible Button ##
self.addToolbarButton( self.addToolbarButton(
translate(u'BibleMediaItem','Add Bible Verse(s) To Service'), translate(u'BibleMediaItem',u'Add Bible Verse(s) To Service'),
translate(u'BibleMediaItem','Add the selected Bible(s) to the service'), translate(u'BibleMediaItem',u'Add the selected Bible(s) to the service'),
':/system/system_add.png', u':/system/system_add.png',
self.onBibleAddClick, 'BibleAddItem') self.onBibleAddClick, u'BibleAddItem')
# Create the tab widget # Create the tab widget
self.SearchTabWidget = QtGui.QTabWidget(self) self.SearchTabWidget = QtGui.QTabWidget(self)
@ -98,41 +98,41 @@ class BibleMediaItem(MediaManagerItem):
sizePolicy.setVerticalStretch(0) sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.SearchTabWidget.sizePolicy().hasHeightForWidth()) sizePolicy.setHeightForWidth(self.SearchTabWidget.sizePolicy().hasHeightForWidth())
self.SearchTabWidget.setSizePolicy(sizePolicy) self.SearchTabWidget.setSizePolicy(sizePolicy)
self.SearchTabWidget.setObjectName('SearchTabWidget') self.SearchTabWidget.setObjectName(u'SearchTabWidget')
# Add the Quick Search tab # Add the Quick Search tab
self.QuickTab = QtGui.QWidget() self.QuickTab = QtGui.QWidget()
self.QuickTab.setObjectName('QuickTab') self.QuickTab.setObjectName(u'QuickTab')
self.QuickLayout = QtGui.QGridLayout(self.QuickTab) self.QuickLayout = QtGui.QGridLayout(self.QuickTab)
self.QuickLayout.setMargin(8) self.QuickLayout.setMargin(8)
self.QuickLayout.setSpacing(8) self.QuickLayout.setSpacing(8)
self.QuickLayout.setObjectName('QuickLayout') self.QuickLayout.setObjectName(u'QuickLayout')
self.QuickVersionLabel = QtGui.QLabel(self.QuickTab) self.QuickVersionLabel = QtGui.QLabel(self.QuickTab)
self.QuickVersionLabel.setObjectName('QuickVersionLabel') self.QuickVersionLabel.setObjectName(u'QuickVersionLabel')
self.QuickLayout.addWidget(self.QuickVersionLabel, 0, 0, 1, 1) self.QuickLayout.addWidget(self.QuickVersionLabel, 0, 0, 1, 1)
self.QuickVersionComboBox = QtGui.QComboBox(self.QuickTab) self.QuickVersionComboBox = QtGui.QComboBox(self.QuickTab)
self.QuickVersionComboBox.setObjectName('VersionComboBox') self.QuickVersionComboBox.setObjectName(u'VersionComboBox')
self.QuickLayout.addWidget(self.QuickVersionComboBox, 0, 1, 1, 2) self.QuickLayout.addWidget(self.QuickVersionComboBox, 0, 1, 1, 2)
self.QuickSearchLabel = QtGui.QLabel(self.QuickTab) self.QuickSearchLabel = QtGui.QLabel(self.QuickTab)
self.QuickSearchLabel.setObjectName('QuickSearchLabel') self.QuickSearchLabel.setObjectName(u'QuickSearchLabel')
self.QuickLayout.addWidget(self.QuickSearchLabel, 1, 0, 1, 1) self.QuickLayout.addWidget(self.QuickSearchLabel, 1, 0, 1, 1)
self.QuickSearchComboBox = QtGui.QComboBox(self.QuickTab) self.QuickSearchComboBox = QtGui.QComboBox(self.QuickTab)
self.QuickSearchComboBox.setObjectName('SearchComboBox') self.QuickSearchComboBox.setObjectName(u'SearchComboBox')
self.QuickLayout.addWidget(self.QuickSearchComboBox, 1, 1, 1, 2) self.QuickLayout.addWidget(self.QuickSearchComboBox, 1, 1, 1, 2)
self.QuickSearchLabel = QtGui.QLabel(self.QuickTab) self.QuickSearchLabel = QtGui.QLabel(self.QuickTab)
self.QuickSearchLabel.setObjectName('QuickSearchLabel') self.QuickSearchLabel.setObjectName(u'QuickSearchLabel')
self.QuickLayout.addWidget(self.QuickSearchLabel, 2, 0, 1, 1) self.QuickLayout.addWidget(self.QuickSearchLabel, 2, 0, 1, 1)
self.QuickSearchEdit = QtGui.QLineEdit(self.QuickTab) self.QuickSearchEdit = QtGui.QLineEdit(self.QuickTab)
self.QuickSearchEdit.setObjectName('QuickSearchEdit') self.QuickSearchEdit.setObjectName(u'QuickSearchEdit')
self.QuickLayout.addWidget(self.QuickSearchEdit, 2, 1, 1, 2) self.QuickLayout.addWidget(self.QuickSearchEdit, 2, 1, 1, 2)
self.QuickSearchButton = QtGui.QPushButton(self.QuickTab) self.QuickSearchButton = QtGui.QPushButton(self.QuickTab)
self.QuickSearchButton.setObjectName('QuickSearchButton') self.QuickSearchButton.setObjectName(u'QuickSearchButton')
self.QuickLayout.addWidget(self.QuickSearchButton, 3, 2, 1, 1) self.QuickLayout.addWidget(self.QuickSearchButton, 3, 2, 1, 1)
self.QuickClearLabel = QtGui.QLabel(self.QuickTab) self.QuickClearLabel = QtGui.QLabel(self.QuickTab)
self.QuickClearLabel.setObjectName('QuickSearchLabel') self.QuickClearLabel.setObjectName(u'QuickSearchLabel')
self.QuickLayout.addWidget(self.QuickClearLabel, 3, 0, 1, 1) self.QuickLayout.addWidget(self.QuickClearLabel, 3, 0, 1, 1)
self.ClearQuickSearchComboBox = QtGui.QComboBox(self.QuickTab) self.ClearQuickSearchComboBox = QtGui.QComboBox(self.QuickTab)
self.ClearQuickSearchComboBox.setObjectName('ClearQuickSearchComboBox') self.ClearQuickSearchComboBox.setObjectName(u'ClearQuickSearchComboBox')
self.QuickLayout.addWidget(self.ClearQuickSearchComboBox, 3, 1, 1, 1) self.QuickLayout.addWidget(self.ClearQuickSearchComboBox, 3, 1, 1, 1)
self.SearchTabWidget.addTab(self.QuickTab, 'Quick') self.SearchTabWidget.addTab(self.QuickTab, 'Quick')
QuickSpacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QuickSpacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum,
@ -141,61 +141,61 @@ class BibleMediaItem(MediaManagerItem):
# Add the Advanced Search tab # Add the Advanced Search tab
self.AdvancedTab = QtGui.QWidget() self.AdvancedTab = QtGui.QWidget()
self.AdvancedTab.setObjectName('AdvancedTab') self.AdvancedTab.setObjectName(u'AdvancedTab')
self.AdvancedLayout = QtGui.QGridLayout(self.AdvancedTab) self.AdvancedLayout = QtGui.QGridLayout(self.AdvancedTab)
self.AdvancedLayout.setMargin(8) self.AdvancedLayout.setMargin(8)
self.AdvancedLayout.setSpacing(8) self.AdvancedLayout.setSpacing(8)
self.AdvancedLayout.setObjectName('AdvancedLayout') self.AdvancedLayout.setObjectName(u'AdvancedLayout')
self.AdvancedVersionLabel = QtGui.QLabel(self.AdvancedTab) self.AdvancedVersionLabel = QtGui.QLabel(self.AdvancedTab)
self.AdvancedVersionLabel.setObjectName('AdvancedVersionLabel') self.AdvancedVersionLabel.setObjectName(u'AdvancedVersionLabel')
self.AdvancedLayout.addWidget(self.AdvancedVersionLabel, 0, 0, 1, 1) self.AdvancedLayout.addWidget(self.AdvancedVersionLabel, 0, 0, 1, 1)
self.AdvancedVersionComboBox = QtGui.QComboBox(self.AdvancedTab) self.AdvancedVersionComboBox = QtGui.QComboBox(self.AdvancedTab)
self.AdvancedVersionComboBox.setObjectName('AdvancedVersionComboBox') self.AdvancedVersionComboBox.setObjectName(u'AdvancedVersionComboBox')
self.AdvancedLayout.addWidget(self.AdvancedVersionComboBox, 0, 2, 1, 2) self.AdvancedLayout.addWidget(self.AdvancedVersionComboBox, 0, 2, 1, 2)
self.AdvancedBookLabel = QtGui.QLabel(self.AdvancedTab) self.AdvancedBookLabel = QtGui.QLabel(self.AdvancedTab)
self.AdvancedBookLabel.setObjectName('AdvancedBookLabel') self.AdvancedBookLabel.setObjectName(u'AdvancedBookLabel')
self.AdvancedLayout.addWidget(self.AdvancedBookLabel, 1, 0, 1, 1) self.AdvancedLayout.addWidget(self.AdvancedBookLabel, 1, 0, 1, 1)
self.AdvancedBookComboBox = QtGui.QComboBox(self.AdvancedTab) self.AdvancedBookComboBox = QtGui.QComboBox(self.AdvancedTab)
self.AdvancedBookComboBox.setObjectName('AdvancedBookComboBox') self.AdvancedBookComboBox.setObjectName(u'AdvancedBookComboBox')
self.AdvancedLayout.addWidget(self.AdvancedBookComboBox, 1, 2, 1, 2) self.AdvancedLayout.addWidget(self.AdvancedBookComboBox, 1, 2, 1, 2)
self.AdvancedChapterLabel = QtGui.QLabel(self.AdvancedTab) self.AdvancedChapterLabel = QtGui.QLabel(self.AdvancedTab)
self.AdvancedChapterLabel.setObjectName('AdvancedChapterLabel') self.AdvancedChapterLabel.setObjectName(u'AdvancedChapterLabel')
self.AdvancedLayout.addWidget(self.AdvancedChapterLabel, 2, 2, 1, 1) self.AdvancedLayout.addWidget(self.AdvancedChapterLabel, 2, 2, 1, 1)
self.AdvancedVerseLabel = QtGui.QLabel(self.AdvancedTab) self.AdvancedVerseLabel = QtGui.QLabel(self.AdvancedTab)
self.AdvancedVerseLabel.setObjectName('AdvancedVerseLabel') self.AdvancedVerseLabel.setObjectName(u'AdvancedVerseLabel')
self.AdvancedLayout.addWidget(self.AdvancedVerseLabel, 2, 3, 1, 1) self.AdvancedLayout.addWidget(self.AdvancedVerseLabel, 2, 3, 1, 1)
self.AdvancedFromLabel = QtGui.QLabel(self.AdvancedTab) self.AdvancedFromLabel = QtGui.QLabel(self.AdvancedTab)
self.AdvancedFromLabel.setObjectName('AdvancedFromLabel') self.AdvancedFromLabel.setObjectName(u'AdvancedFromLabel')
self.AdvancedLayout.addWidget(self.AdvancedFromLabel, 3, 0, 1, 1) self.AdvancedLayout.addWidget(self.AdvancedFromLabel, 3, 0, 1, 1)
self.AdvancedToLabel = QtGui.QLabel(self.AdvancedTab) self.AdvancedToLabel = QtGui.QLabel(self.AdvancedTab)
self.AdvancedToLabel.setObjectName('AdvancedToLabel') self.AdvancedToLabel.setObjectName(u'AdvancedToLabel')
self.AdvancedLayout.addWidget(self.AdvancedToLabel, 4, 0, 1, 1) self.AdvancedLayout.addWidget(self.AdvancedToLabel, 4, 0, 1, 1)
self.AdvancedFromChapter = QtGui.QComboBox(self.AdvancedTab) self.AdvancedFromChapter = QtGui.QComboBox(self.AdvancedTab)
self.AdvancedFromChapter.setObjectName('AdvancedFromChapter') self.AdvancedFromChapter.setObjectName(u'AdvancedFromChapter')
self.AdvancedLayout.addWidget(self.AdvancedFromChapter, 3, 2, 1, 1) self.AdvancedLayout.addWidget(self.AdvancedFromChapter, 3, 2, 1, 1)
self.AdvancedFromVerse = QtGui.QComboBox(self.AdvancedTab) self.AdvancedFromVerse = QtGui.QComboBox(self.AdvancedTab)
self.AdvancedFromVerse.setObjectName('AdvancedFromVerse') self.AdvancedFromVerse.setObjectName(u'AdvancedFromVerse')
self.AdvancedLayout.addWidget(self.AdvancedFromVerse, 3, 3, 1, 1) self.AdvancedLayout.addWidget(self.AdvancedFromVerse, 3, 3, 1, 1)
self.AdvancedToChapter = QtGui.QComboBox(self.AdvancedTab) self.AdvancedToChapter = QtGui.QComboBox(self.AdvancedTab)
self.AdvancedToChapter.setObjectName('AdvancedToChapter') self.AdvancedToChapter.setObjectName(u'AdvancedToChapter')
self.AdvancedLayout.addWidget(self.AdvancedToChapter, 4, 2, 1, 1) self.AdvancedLayout.addWidget(self.AdvancedToChapter, 4, 2, 1, 1)
self.AdvancedToVerse = QtGui.QComboBox(self.AdvancedTab) self.AdvancedToVerse = QtGui.QComboBox(self.AdvancedTab)
self.AdvancedToVerse.setObjectName('AdvancedToVerse') self.AdvancedToVerse.setObjectName(u'AdvancedToVerse')
self.AdvancedLayout.addWidget(self.AdvancedToVerse, 4, 3, 1, 1) self.AdvancedLayout.addWidget(self.AdvancedToVerse, 4, 3, 1, 1)
self.AdvancedClearLabel = QtGui.QLabel(self.QuickTab) self.AdvancedClearLabel = QtGui.QLabel(self.QuickTab)
self.AdvancedClearLabel.setObjectName('QuickSearchLabel') self.AdvancedClearLabel.setObjectName(u'QuickSearchLabel')
self.AdvancedLayout.addWidget(self.AdvancedClearLabel, 5, 0, 1, 1) self.AdvancedLayout.addWidget(self.AdvancedClearLabel, 5, 0, 1, 1)
self.ClearAdvancedSearchComboBox = QtGui.QComboBox(self.QuickTab) self.ClearAdvancedSearchComboBox = QtGui.QComboBox(self.QuickTab)
self.ClearAdvancedSearchComboBox.setObjectName('ClearAdvancedSearchComboBox') self.ClearAdvancedSearchComboBox.setObjectName(u'ClearAdvancedSearchComboBox')
self.AdvancedLayout.addWidget(self.ClearAdvancedSearchComboBox, 5, 2, 1, 1) self.AdvancedLayout.addWidget(self.ClearAdvancedSearchComboBox, 5, 2, 1, 1)
self.AdvancedSearchButton = QtGui.QPushButton(self.AdvancedTab) self.AdvancedSearchButton = QtGui.QPushButton(self.AdvancedTab)
self.AdvancedSearchButton.setObjectName('AdvancedSearchButton') self.AdvancedSearchButton.setObjectName(u'AdvancedSearchButton')
self.AdvancedLayout.addWidget(self.AdvancedSearchButton, 5, 3, 1, 1) self.AdvancedLayout.addWidget(self.AdvancedSearchButton, 5, 3, 1, 1)
self.SearchTabWidget.addTab(self.AdvancedTab, 'Advanced') self.SearchTabWidget.addTab(self.AdvancedTab, u'Advanced')
# Add the search tab widget to the page layout # Add the search tab widget to the page layout
self.PageLayout.addWidget(self.SearchTabWidget) self.PageLayout.addWidget(self.SearchTabWidget)
@ -211,31 +211,31 @@ class BibleMediaItem(MediaManagerItem):
# Combo Boxes # Combo Boxes
QtCore.QObject.connect(self.AdvancedVersionComboBox, QtCore.QObject.connect(self.AdvancedVersionComboBox,
QtCore.SIGNAL("activated(int)"), self.onAdvancedVersionComboBox) QtCore.SIGNAL(u'activated(int)'), self.onAdvancedVersionComboBox)
QtCore.QObject.connect(self.AdvancedBookComboBox, QtCore.QObject.connect(self.AdvancedBookComboBox,
QtCore.SIGNAL("activated(int)"), self.onAdvancedBookComboBox) QtCore.SIGNAL(u'activated(int)'), self.onAdvancedBookComboBox)
QtCore.QObject.connect(self.AdvancedFromChapter, QtCore.QObject.connect(self.AdvancedFromChapter,
QtCore.SIGNAL("activated(int)"), self.onAdvancedFromChapter) QtCore.SIGNAL(u'activated(int)'), self.onAdvancedFromChapter)
QtCore.QObject.connect(self.AdvancedFromVerse, QtCore.QObject.connect(self.AdvancedFromVerse,
QtCore.SIGNAL("activated(int)"), self.onAdvancedFromVerse) QtCore.SIGNAL(u'activated(int)'), self.onAdvancedFromVerse)
QtCore.QObject.connect(self.AdvancedToChapter, QtCore.QObject.connect(self.AdvancedToChapter,
QtCore.SIGNAL("activated(int)"), self.onAdvancedToChapter) QtCore.SIGNAL(u'activated(int)'), self.onAdvancedToChapter)
# Buttons # Buttons
QtCore.QObject.connect(self.AdvancedSearchButton, QtCore.QObject.connect(self.AdvancedSearchButton,
QtCore.SIGNAL("pressed()"), self.onAdvancedSearchButton) QtCore.SIGNAL(u'pressed()'), self.onAdvancedSearchButton)
QtCore.QObject.connect(self.QuickSearchButton, QtCore.QObject.connect(self.QuickSearchButton,
QtCore.SIGNAL("pressed()"), self.onQuickSearchButton) QtCore.SIGNAL(u'pressed()'), self.onQuickSearchButton)
# Context Menus # Context Menus
self.BibleListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) self.BibleListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
self.BibleListView.addAction(self.contextMenuAction( self.BibleListView.addAction(self.contextMenuAction(
self.BibleListView, ':/system/system_preview.png', self.BibleListView, u':/system/system_preview.png',
translate(u'BibleMediaItem',u'&Preview Verse'), self.onBiblePreviewClick)) translate(u'BibleMediaItem',u'&Preview Verse'), self.onBiblePreviewClick))
self.BibleListView.addAction(self.contextMenuAction( self.BibleListView.addAction(self.contextMenuAction(
self.BibleListView, ':/system/system_live.png', self.BibleListView, u':/system/system_live.png',
translate(u'BibleMediaItem',u'&Show Live'), self.onBibleLiveClick)) translate(u'BibleMediaItem',u'&Show Live'), self.onBibleLiveClick))
self.BibleListView.addAction(self.contextMenuAction( self.BibleListView.addAction(self.contextMenuAction(
self.BibleListView, ':/system/system_add.png', self.BibleListView, u':/system/system_add.png',
translate(u'BibleMediaItem',u'&Add to Service'), self.onBibleAddClick)) translate(u'BibleMediaItem',u'&Add to Service'), self.onBibleAddClick))
def retranslateUi(self): def retranslateUi(self):
@ -268,25 +268,26 @@ class BibleMediaItem(MediaManagerItem):
log.debug(u'Loading Bibles') log.debug(u'Loading Bibles')
self.QuickVersionComboBox.clear() self.QuickVersionComboBox.clear()
self.AdvancedVersionComboBox.clear() self.AdvancedVersionComboBox.clear()
bibles = self.parent.biblemanager.get_bibles(u'full') bibles = self.parent.biblemanager.get_bibles(u'full')
# load bibles into the combo boxes
for bible in bibles: # load bibles into the combo boxes for bible in bibles:
self.QuickVersionComboBox.addItem(bible) self.QuickVersionComboBox.addItem(bible)
bibles = self.parent.biblemanager.get_bibles(u'partial') # Without HTTP bibles = self.parent.biblemanager.get_bibles(u'partial') # Without HTTP
first = True first = True
for bible in bibles: # load bibles into the combo boxes # load bibles into the combo boxes
for bible in bibles:
self.AdvancedVersionComboBox.addItem(bible) self.AdvancedVersionComboBox.addItem(bible)
if first: if first:
first = False first = False
self.initialiseBible(bible) # use the first bible as the trigger # use the first bible as the trigger
self.initialiseBible(bible)
def onAdvancedVersionComboBox(self): def onAdvancedVersionComboBox(self):
self.initialiseBible(str(self.AdvancedVersionComboBox.currentText())) # reset the bible info self.initialiseBible(str(self.AdvancedVersionComboBox.currentText()))
def onAdvancedBookComboBox(self): def onAdvancedBookComboBox(self):
self.initialiseBible(str(self.AdvancedVersionComboBox.currentText())) # reset the bible info self.initialiseChapterVerse(str(self.AdvancedVersionComboBox.currentText()),
str(self.AdvancedBookComboBox.currentText()))
def onBibleNewClick(self): def onBibleNewClick(self):
self.bibleimportform = BibleImportForm(self.parent.config, self.parent.biblemanager, self) self.bibleimportform = BibleImportForm(self.parent.config, self.parent.biblemanager, self)
@ -324,10 +325,10 @@ class BibleMediaItem(MediaManagerItem):
bible = str(self.AdvancedVersionComboBox.currentText()) bible = str(self.AdvancedVersionComboBox.currentText())
book = str(self.AdvancedBookComboBox.currentText()) book = str(self.AdvancedBookComboBox.currentText())
cf = self.AdvancedFromChapter.currentText() cf = self.AdvancedFromChapter.currentText()
self._adjust_combobox(cf, self.chapters_from, self.AdvancedToChapter) self.adjustComboBox(cf, self.chapters_from, self.AdvancedToChapter)
vse = self.parent.biblemanager.get_book_verse_count(bible, book, int(cf))[0] # get the verse count for new chapter vse = self.parent.biblemanager.get_book_verse_count(bible, book, int(cf))[0] # get the verse count for new chapter
self._adjust_combobox(1, vse, self.AdvancedFromVerse) self.adjustComboBox(1, vse, self.AdvancedFromVerse)
self._adjust_combobox(1, vse, self.AdvancedToVerse) self.adjustComboBox(1, vse, self.AdvancedToVerse)
def onQuickSearchButton(self): def onQuickSearchButton(self):
log.debug(u'Quick Search Button pressed') log.debug(u'Quick Search Button pressed')
@ -344,19 +345,19 @@ class BibleMediaItem(MediaManagerItem):
def onBibleLiveClick(self): def onBibleLiveClick(self):
service_item = ServiceItem(self.parent) service_item = ServiceItem(self.parent)
service_item.addIcon( ":/media/media_verse.png") service_item.addIcon( u':/media/media_verse.png')
self.generateSlideData(service_item) self.generateSlideData(service_item)
self.parent.live_controller.addServiceItem(service_item) self.parent.live_controller.addServiceItem(service_item)
def onBibleAddClick(self): def onBibleAddClick(self):
service_item = ServiceItem(self.parent) service_item = ServiceItem(self.parent)
service_item.addIcon( ":/media/media_verse.png") service_item.addIcon(u':/media/media_verse.png')
self.generateSlideData(service_item) self.generateSlideData(service_item)
self.parent.service_manager.addServiceItem(service_item) self.parent.service_manager.addServiceItem(service_item)
def onBiblePreviewClick(self): def onBiblePreviewClick(self):
service_item = ServiceItem(self.parent) service_item = ServiceItem(self.parent)
service_item.addIcon( ":/media/media_verse.png") service_item.addIcon(u':/media/media_verse.png')
self.generateSlideData(service_item) self.generateSlideData(service_item)
self.parent.preview_controller.addServiceItem(service_item) self.parent.preview_controller.addServiceItem(service_item)
@ -369,8 +370,8 @@ class BibleMediaItem(MediaManagerItem):
bible_text = u'' bible_text = u''
for item in items: for item in items:
text = self.BibleListData.getValue(item) text = self.BibleListData.getValue(item)
verse = text[:text.find(u'(')] verse = text[:text.find(u'(u')]
bible = text[text.find(u'(') + 1:text.find(u')')] bible = text[text.find(u'(u') + 1:text.find(u')')]
self.searchByReference(bible, verse) self.searchByReference(bible, verse)
book = self.search_results[0][0] book = self.search_results[0][0]
chapter = str(self.search_results[0][1]) chapter = str(self.search_results[0][1])
@ -379,7 +380,7 @@ class BibleMediaItem(MediaManagerItem):
if self.parent.bibles_tab.paragraph_style: #Paragraph if self.parent.bibles_tab.paragraph_style: #Paragraph
text = text + u'\n\n' text = text + u'\n\n'
if self.parent.bibles_tab.display_style == 1: if self.parent.bibles_tab.display_style == 1:
loc = self.formatVerse(old_chapter, chapter, verse, u'(', u')') loc = self.formatVerse(old_chapter, chapter, verse, u'(u', u')')
elif self.parent.bibles_tab.display_style == 2: elif self.parent.bibles_tab.display_style == 2:
loc = self.formatVerse(old_chapter, chapter, verse, u'{', u'}') loc = self.formatVerse(old_chapter, chapter, verse, u'{', u'}')
elif self.parent.bibles_tab.display_style == 3: elif self.parent.bibles_tab.display_style == 3:
@ -391,7 +392,6 @@ class BibleMediaItem(MediaManagerItem):
service_item.title = book + u' ' + loc service_item.title = book + u' ' + loc
if len(raw_footer) <= 1: if len(raw_footer) <= 1:
raw_footer.append(book) raw_footer.append(book)
if len(self.parent.bibles_tab.bible_theme) == 0: if len(self.parent.bibles_tab.bible_theme) == 0:
service_item.theme = None service_item.theme = None
else: else:
@ -417,7 +417,7 @@ class BibleMediaItem(MediaManagerItem):
self.loadBibles() self.loadBibles()
def initialiseBible(self, bible): def initialiseBible(self, bible):
log.debug(u"initialiseBible %s", bible) log.debug(u'initialiseBible %s', bible)
books = self.parent.biblemanager.get_bible_books(str(bible)) books = self.parent.biblemanager.get_bible_books(str(bible))
self.AdvancedBookComboBox.clear() self.AdvancedBookComboBox.clear()
first = True first = True
@ -428,7 +428,7 @@ class BibleMediaItem(MediaManagerItem):
self.initialiseChapterVerse(bible, book.name) self.initialiseChapterVerse(bible, book.name)
def initialiseChapterVerse(self, bible, book): def initialiseChapterVerse(self, bible, book):
log.debug(u"initialiseChapterVerse %s , %s", bible, book) log.debug(u'initialiseChapterVerse %s , %s', bible, book)
self.chapters_from = self.parent.biblemanager.get_book_chapter_count(bible, book)[0] self.chapters_from = self.parent.biblemanager.get_book_chapter_count(bible, book)[0]
self.verses = self.parent.biblemanager.get_book_verse_count(bible, book, 1)[0] self.verses = self.parent.biblemanager.get_book_verse_count(bible, book, 1)[0]
self.adjustComboBox(1, self.chapters_from, self.AdvancedFromChapter) self.adjustComboBox(1, self.chapters_from, self.AdvancedFromChapter)
@ -437,24 +437,24 @@ class BibleMediaItem(MediaManagerItem):
self.adjustComboBox(1, self.verses, self.AdvancedToVerse) self.adjustComboBox(1, self.verses, self.AdvancedToVerse)
def adjustComboBox(self, frm, to , combo): def adjustComboBox(self, frm, to , combo):
log.debug(u"adjustComboBox %s , %s , %s", combo, frm, to) log.debug(u'adjustComboBox %s , %s , %s', combo, frm, to)
combo.clear() combo.clear()
for i in range(int(frm), int(to) + 1): for i in range(int(frm), int(to) + 1):
combo.addItem(str(i)) combo.addItem(str(i))
def displayResults(self, bible): def displayResults(self, bible):
for book, chap, vse , txt in self.search_results: for book, chap, vse , txt in self.search_results:
text = str(u" %s %d:%d (%s)"%(book , chap,vse, bible)) text = str(u' %s %d:%d (%s)'%(book , chap,vse, bible))
self.BibleListData.addRow(0,text) self.BibleListData.addRow(0,text)
def searchByReference(self, bible, search): def searchByReference(self, bible, search):
log.debug(u"searchByReference %s ,%s", bible, search) log.debug(u'searchByReference %s ,%s', bible, search)
book = '' book = ''
start_chapter = '' start_chapter = ''
end_chapter = '' end_chapter = ''
start_verse = '' start_verse = ''
end_verse = '' end_verse = ''
search = search.replace(' ', ' ').strip() search = search.replace(u' ', ' ').strip()
original = search original = search
message = None message = None
# Remove book # Remove book
@ -463,18 +463,18 @@ class BibleMediaItem(MediaManagerItem):
book = search[:i] book = search[:i]
search = search[i:] # remove book from string search = search[i:] # remove book from string
break break
search = search.replace('v', ':') # allow V or v for verse instead of : search = search.replace(u'v', ':') # allow V or v for verse instead of :
search = search.replace('V', ':') # allow V or v for verse instead of : search = search.replace(u'V', ':') # allow V or v for verse instead of :
search = search.strip() search = search.strip()
colon = search.find(':') colon = search.find(u':')
if colon == -1: if colon == -1:
# number : found # number : found
i = search.rfind(' ') i = search.rfind(u' ')
if i == -1: if i == -1:
chapter = '' chapter = ''
else: else:
chapter = search[i:len(search)] chapter = search[i:len(search)]
hyphen = chapter.find('-') hyphen = chapter.find(u'-')
if hyphen != -1: if hyphen != -1:
start_chapter= chapter[:hyphen] start_chapter= chapter[:hyphen]
end_chapter= chapter[hyphen + 1:len(chapter)] end_chapter= chapter[hyphen + 1:len(chapter)]
@ -483,9 +483,9 @@ class BibleMediaItem(MediaManagerItem):
else: else:
# more complex # more complex
#print search #print search
sp = search.split('-') #find first sp = search.split(u'-') #find first
#print sp, len(sp) #print sp, len(sp)
sp1 = sp[0].split(':') sp1 = sp[0].split(u':')
#print sp1, len(sp1) #print sp1, len(sp1)
if len(sp1) == 1: if len(sp1) == 1:
start_chapter = sp1[0] start_chapter = sp1[0]
@ -497,7 +497,7 @@ class BibleMediaItem(MediaManagerItem):
end_chapter = start_chapter end_chapter = start_chapter
end_verse = start_verse end_verse = start_verse
else: else:
sp1 = sp[1].split(':') sp1 = sp[1].split(u':')
#print sp1, len(sp1) #print sp1, len(sp1)
if len(sp1) == 1: if len(sp1) == 1:
end_chapter = sp1[0] end_chapter = sp1[0]
@ -516,10 +516,9 @@ class BibleMediaItem(MediaManagerItem):
end_verse = 99 end_verse = 99
if start_chapter == '': if start_chapter == '':
message = u'No chapter found for search' message = u'No chapter found for search'
#print "message = " + str(message) #print 'message = ' + str(message)
#print "search = " + str(original) #print 'search = ' + str(original)
#print "results = " + str(book) + " @ "+ str(start_chapter)+" @ "+ str(end_chapter)+" @ "+ str(start_verse)+ " @ "+ str(end_verse) #print 'results = ' + str(book) + ' @ '+ str(start_chapter)+' @ '+ str(end_chapter)+' @ '+ str(start_verse)+ ' @ '+ str(end_verse)
if message == None: if message == None:
self.search_results = None self.search_results = None
self.search_results = self.parent.biblemanager.get_verse_text(bible, book, self.search_results = self.parent.biblemanager.get_verse_text(bible, book,