forked from openlp/openlp
Fix Bible import bugs for duplicate bibles
Fix Bibles refresh errors on nw bible creation Finish Topic / Author and Songbook code for now
This commit is contained in:
parent
11a9d28bed
commit
2c5e701e10
@ -23,19 +23,16 @@ import sys
|
|||||||
import time
|
import time
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from openlp.core.resources import *
|
|
||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
from PyQt4.QtGui import QDialog
|
|
||||||
|
|
||||||
from bibleimportdialog import Ui_BibleImportDialog
|
from bibleimportdialog import Ui_BibleImportDialog
|
||||||
from openlp.core.lib import Receiver
|
from openlp.core.lib import Receiver, translate
|
||||||
|
|
||||||
|
|
||||||
class BibleImportForm(QDialog, Ui_BibleImportDialog):
|
class BibleImportForm(QtGui.QDialog, Ui_BibleImportDialog):
|
||||||
global log
|
global log
|
||||||
log=logging.getLogger("BibleImportForm")
|
log=logging.getLogger("BibleImportForm")
|
||||||
log.info("BibleImportForm loaded")
|
log.info("BibleImportForm loaded")
|
||||||
"""
|
"""
|
||||||
Class documentation goes here.
|
Class documentation goes here.
|
||||||
"""
|
"""
|
||||||
@ -43,7 +40,7 @@ class BibleImportForm(QDialog, Ui_BibleImportDialog):
|
|||||||
"""
|
"""
|
||||||
Constructor
|
Constructor
|
||||||
"""
|
"""
|
||||||
QDialog.__init__(self, parent)
|
QtGui.QDialog.__init__(self, parent)
|
||||||
self.setupUi(self)
|
self.setupUi(self)
|
||||||
self.biblemanager = biblemanager
|
self.biblemanager = biblemanager
|
||||||
self.config = config
|
self.config = config
|
||||||
@ -53,9 +50,9 @@ class BibleImportForm(QDialog, Ui_BibleImportDialog):
|
|||||||
self.AddressEdit.setText(self.config.get_config("proxy_address", ""))
|
self.AddressEdit.setText(self.config.get_config("proxy_address", ""))
|
||||||
self.UsernameEdit.setText(self.config.get_config("proxy_username", ""))
|
self.UsernameEdit.setText(self.config.get_config("proxy_username", ""))
|
||||||
self.PasswordEdit.setText(self.config.get_config("proxy_password",""))
|
self.PasswordEdit.setText(self.config.get_config("proxy_password",""))
|
||||||
|
|
||||||
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, '..', 'resources','crosswalkbooks.csv'))
|
||||||
fbibles=open(filepath, 'r')
|
fbibles=open(filepath, 'r')
|
||||||
self.bible_versions = {}
|
self.bible_versions = {}
|
||||||
self.BibleComboBox.clear()
|
self.BibleComboBox.clear()
|
||||||
@ -64,125 +61,136 @@ class BibleImportForm(QDialog, Ui_BibleImportDialog):
|
|||||||
p = line.split(",")
|
p = line.split(",")
|
||||||
self.bible_versions[p[0]] = p[1].replace('\n', '')
|
self.bible_versions[p[0]] = p[1].replace('\n', '')
|
||||||
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.SIGNAL("activated(int)"), self.onLocationComboBoxSelected)
|
||||||
QtCore.QObject.connect(self.BibleComboBox, QtCore.SIGNAL("activated(int)"), self.onBibleComboBoxSelected)
|
QtCore.QObject.connect(self.BibleComboBox, QtCore.SIGNAL("activated(int)"), self.onBibleComboBoxSelected)
|
||||||
|
|
||||||
#Buttons
|
#Buttons
|
||||||
QtCore.QObject.connect(self.ImportButton, QtCore.SIGNAL("pressed()"), self.onImportButtonClicked)
|
QtCore.QObject.connect(self.ImportButton, QtCore.SIGNAL("pressed()"), self.onImportButtonClicked)
|
||||||
QtCore.QObject.connect(self.CancelButton, QtCore.SIGNAL("pressed()"), self.onCancelButtonClicked)
|
QtCore.QObject.connect(self.CancelButton, QtCore.SIGNAL("pressed()"), self.onCancelButtonClicked)
|
||||||
QtCore.QObject.connect(self.VersesFileButton, QtCore.SIGNAL("pressed()"), self.onVersesFileButtonClicked)
|
QtCore.QObject.connect(self.VersesFileButton, QtCore.SIGNAL("pressed()"), self.onVersesFileButtonClicked)
|
||||||
QtCore.QObject.connect(self.BooksFileButton, QtCore.SIGNAL("pressed()"), self.onBooksFileButtonClicked)
|
QtCore.QObject.connect(self.BooksFileButton, QtCore.SIGNAL("pressed()"), self.onBooksFileButtonClicked)
|
||||||
QtCore.QObject.connect(self.OsisFileButton, QtCore.SIGNAL("pressed()"), self.onOsisFileButtonClicked)
|
QtCore.QObject.connect(self.OsisFileButton, QtCore.SIGNAL("pressed()"), self.onOsisFileButtonClicked)
|
||||||
|
|
||||||
#Lost Focus
|
#Lost Focus
|
||||||
QtCore.QObject.connect(self.OSISLocationEdit, QtCore.SIGNAL("lostFocus()"), self.onOSISLocationEditLostFocus)
|
QtCore.QObject.connect(self.OSISLocationEdit, QtCore.SIGNAL("lostFocus()"), self.onOSISLocationEditLostFocus)
|
||||||
QtCore.QObject.connect(self.BooksLocationEdit, QtCore.SIGNAL("lostFocus()"),self.onBooksLocationEditLostFocus)
|
QtCore.QObject.connect(self.BooksLocationEdit, QtCore.SIGNAL("lostFocus()"),self.onBooksLocationEditLostFocus)
|
||||||
QtCore.QObject.connect(self.VerseLocationEdit, QtCore.SIGNAL("lostFocus()"), self.onVerseLocationEditLostFocus)
|
QtCore.QObject.connect(self.VerseLocationEdit, QtCore.SIGNAL("lostFocus()"), self.onVerseLocationEditLostFocus)
|
||||||
QtCore.QObject.connect(self.AddressEdit, QtCore.SIGNAL("lostFocus()"), self.onProxyAddressEditLostFocus)
|
QtCore.QObject.connect(self.AddressEdit, QtCore.SIGNAL("lostFocus()"), self.onProxyAddressEditLostFocus)
|
||||||
QtCore.QObject.connect(self.UsernameEdit, QtCore.SIGNAL("lostFocus()"), self.onProxyUsernameEditLostFocus)
|
QtCore.QObject.connect(self.UsernameEdit, QtCore.SIGNAL("lostFocus()"), self.onProxyUsernameEditLostFocus)
|
||||||
QtCore.QObject.connect(self.PasswordEdit, QtCore.SIGNAL("lostFocus()"), self.onProxyPasswordEditLostFocus)
|
QtCore.QObject.connect(self.PasswordEdit, QtCore.SIGNAL("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, 'Open file',self.config.get_last_dir(1))
|
||||||
if filename != "":
|
if filename != "":
|
||||||
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, 'Open file',self.config.get_last_dir(2))
|
||||||
if filename != "":
|
if filename != "":
|
||||||
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, 'Open file',self.config.get_last_dir(3))
|
||||||
if filename != "":
|
if filename != "":
|
||||||
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()
|
||||||
|
|
||||||
def onOSISLocationEditLostFocus(self):
|
def onOSISLocationEditLostFocus(self):
|
||||||
if len(self.OSISLocationEdit.displayText() ) > 0:
|
if len(self.OSISLocationEdit.displayText() ) > 0:
|
||||||
self.setOsis()
|
self.setOsis()
|
||||||
else:
|
else:
|
||||||
if self.bible_type == "OSIS": # Was OSIS and is not any more stops lostFocus running mad
|
# Was OSIS and is not any more stops lostFocus running mad
|
||||||
self.bible_type = None
|
if self.bible_type == "OSIS":
|
||||||
|
self.bible_type = None
|
||||||
self.freeAll()
|
self.freeAll()
|
||||||
|
|
||||||
def onBooksLocationEditLostFocus(self):
|
def onBooksLocationEditLostFocus(self):
|
||||||
self.checkOsis()
|
self.checkOsis()
|
||||||
|
|
||||||
def onVerseLocationEditLostFocus(self):
|
def onVerseLocationEditLostFocus(self):
|
||||||
self.checkOsis()
|
self.checkOsis()
|
||||||
|
|
||||||
def onProxyAddressEditLostFocus(self):
|
def onProxyAddressEditLostFocus(self):
|
||||||
self.config.set_config("proxy_address", str(self.AddressEdit.displayText()))
|
self.config.set_config("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("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("proxy_password", str(self.PasswordEdit.displayText()))
|
||||||
|
|
||||||
def onLocationComboBoxSelected(self):
|
def onLocationComboBoxSelected(self):
|
||||||
self.checkHttp()
|
self.checkHttp()
|
||||||
|
|
||||||
def onBibleComboBoxSelected(self):
|
def onBibleComboBoxSelected(self):
|
||||||
self.checkHttp()
|
self.checkHttp()
|
||||||
self.BibleNameEdit.setText(str(self.BibleComboBox.currentText()))
|
self.BibleNameEdit.setText(str(self.BibleComboBox.currentText()))
|
||||||
|
|
||||||
def onCancelButtonClicked(self):
|
def onCancelButtonClicked(self):
|
||||||
# tell import to stop
|
# tell import to stop
|
||||||
Receiver().send_message("openlpstopimport")
|
Receiver().send_message("openlpstopimport")
|
||||||
# tell bibleplugin to reload the bibles
|
# tell bibleplugin to reload the bibles
|
||||||
Receiver().send_message("openlpreloadbibles")
|
Receiver().send_message("openlpreloadbibles")
|
||||||
self.close()
|
self.close()
|
||||||
|
|
||||||
def onImportButtonClicked(self):
|
def onImportButtonClicked(self):
|
||||||
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("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("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("openlpreloadbibles")
|
||||||
|
message = u'Bible import completered'
|
||||||
|
reply = QtGui.QMessageBox.information(self,
|
||||||
|
translate(u'BibleMediaItem', u'Information'),
|
||||||
|
translate(u'BibleMediaItem', message))
|
||||||
|
|
||||||
def setMax(self, max):
|
def setMax(self, max):
|
||||||
log.debug("set Max %s", max)
|
log.debug("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("IncrementBar %s", text)
|
||||||
self.MessageLabel.setText("Import processing " + text)
|
self.MessageLabel.setText("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("Import Bible ")
|
||||||
if self.bible_type == "OSIS":
|
if self.bible_type == "OSIS":
|
||||||
self.biblemanager.register_osis_file_bible(str(self.BibleNameEdit.displayText()), self.OSISLocationEdit.displayText())
|
loaded = self.biblemanager.register_osis_file_bible(str(self.BibleNameEdit.displayText()),
|
||||||
|
self.OSISLocationEdit.displayText())
|
||||||
elif self.bible_type == "CSV":
|
elif self.bible_type == "CSV":
|
||||||
self.biblemanager.register_csv_file_bible(str(self.BibleNameEdit.displayText()), self.BooksLocationEdit.displayText(), self.VerseLocationEdit.displayText())
|
loaded = self.biblemanager.register_csv_file_bible(str(self.BibleNameEdit.displayText()),
|
||||||
|
self.BooksLocationEdit.displayText(), self.VerseLocationEdit.displayText())
|
||||||
else:
|
else:
|
||||||
self.setMax(1) # set a value as it will not be needed
|
self.setMax(1) # set a value as it will not be needed
|
||||||
bible = self.bible_versions[str(self.BibleComboBox.currentText())]
|
bible = self.bible_versions[str(self.BibleComboBox.currentText())]
|
||||||
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()), \
|
||||||
str(bible), \
|
str(bible), \
|
||||||
str(self.AddressEdit.displayText()), \
|
str(self.AddressEdit.displayText()), \
|
||||||
str(self.UsernameEdit .displayText()), \
|
str(self.UsernameEdit .displayText()), \
|
||||||
str(self.PasswordEdit.displayText()))
|
str(self.PasswordEdit.displayText()))
|
||||||
self.biblemanager.save_meta_data(str(self.BibleNameEdit.displayText()), str(self.VersionNameEdit.displayText()), str(self.CopyrightEdit.displayText()), str(self.PermisionEdit.displayText()))
|
if loaded:
|
||||||
|
self.biblemanager.save_meta_data(str(self.BibleNameEdit.displayText()),
|
||||||
|
str(self.VersionNameEdit.displayText()),
|
||||||
|
str(self.CopyrightEdit.displayText()),
|
||||||
|
str(self.PermisionEdit.displayText()))
|
||||||
self.bible_type = None
|
self.bible_type = None
|
||||||
self.freeAll() # free the screen state restrictions
|
self.freeAll() # free the screen state restrictions
|
||||||
self.resetAll() # reset all the screen fields
|
self.resetAll() # reset all the screen fields
|
||||||
@ -191,16 +199,18 @@ class BibleImportForm(QDialog, Ui_BibleImportDialog):
|
|||||||
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:
|
||||||
if self.bible_type == "CSV": # Was CSV and is not any more stops lostFocus running mad
|
# Was CSV and is not any more stops lostFocus running mad
|
||||||
self.bible_type = None
|
if self.bible_type == "CSV":
|
||||||
|
self.bible_type = None
|
||||||
self.freeAll()
|
self.freeAll()
|
||||||
|
|
||||||
def checkHttp(self):
|
def checkHttp(self):
|
||||||
if self.BibleComboBox.currentIndex() != 0 : # First slot is blank so no bible
|
if self.BibleComboBox.currentIndex() != 0 : # First slot is blank so no bible
|
||||||
self.setHttp()
|
self.setHttp()
|
||||||
else:
|
else:
|
||||||
if self.bible_type == "HTTP": # Was HTTP and is not any more stops lostFocus running mad
|
# Was HTTP and is not any more stops lostFocus running mad
|
||||||
self.bible_type = None
|
if self.bible_type == "HTTP":
|
||||||
|
self.bible_type = None
|
||||||
self.freeAll()
|
self.freeAll()
|
||||||
|
|
||||||
def blockCsv(self):
|
def blockCsv(self):
|
||||||
@ -208,48 +218,48 @@ class BibleImportForm(QDialog, Ui_BibleImportDialog):
|
|||||||
self.VerseLocationEdit.setReadOnly(True)
|
self.VerseLocationEdit.setReadOnly(True)
|
||||||
self.BooksFileButton.setEnabled(False)
|
self.BooksFileButton.setEnabled(False)
|
||||||
self.VersesFileButton.setEnabled(False)
|
self.VersesFileButton.setEnabled(False)
|
||||||
|
|
||||||
def setCsv(self):
|
def setCsv(self):
|
||||||
self.bible_type = "CSV"
|
self.bible_type = "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)
|
||||||
self.VersesFileButton.setEnabled(True)
|
self.VersesFileButton.setEnabled(True)
|
||||||
self.blockOsis()
|
self.blockOsis()
|
||||||
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()
|
||||||
self.blockHttp()
|
self.blockHttp()
|
||||||
|
|
||||||
def blockOsis(self):
|
def blockOsis(self):
|
||||||
self.OSISLocationEdit.setReadOnly(True)
|
self.OSISLocationEdit.setReadOnly(True)
|
||||||
self.OsisFileButton.setEnabled(False)
|
self.OsisFileButton.setEnabled(False)
|
||||||
|
|
||||||
def setHttp(self):
|
def setHttp(self):
|
||||||
self.bible_type = "HTTP"
|
self.bible_type = "HTTP"
|
||||||
self.LocationComboBox.setEnabled(True)
|
self.LocationComboBox.setEnabled(True)
|
||||||
self.BibleComboBox.setEnabled(True)
|
self.BibleComboBox.setEnabled(True)
|
||||||
self.blockCsv()
|
self.blockCsv()
|
||||||
self.blockOsis()
|
self.blockOsis()
|
||||||
|
|
||||||
def blockHttp(self):
|
def blockHttp(self):
|
||||||
self.LocationComboBox.setEnabled(False)
|
self.LocationComboBox.setEnabled(False)
|
||||||
self.BibleComboBox.setEnabled(False)
|
self.BibleComboBox.setEnabled(False)
|
||||||
|
|
||||||
def freeAll(self):
|
def freeAll(self):
|
||||||
if self.bible_type == None: # only reset if no bible type set.
|
if self.bible_type == None: # only reset if no bible type set.
|
||||||
self.BooksLocationEdit.setReadOnly(False)
|
self.BooksLocationEdit.setReadOnly(False)
|
||||||
self.VerseLocationEdit.setReadOnly(False)
|
self.VerseLocationEdit.setReadOnly(False)
|
||||||
self.BooksFileButton.setEnabled(True)
|
self.BooksFileButton.setEnabled(True)
|
||||||
self.VersesFileButton.setEnabled(True)
|
self.VersesFileButton.setEnabled(True)
|
||||||
self.OSISLocationEdit.setReadOnly(False)
|
self.OSISLocationEdit.setReadOnly(False)
|
||||||
self.OsisFileButton.setEnabled(True)
|
self.OsisFileButton.setEnabled(True)
|
||||||
self.LocationComboBox.setEnabled(True)
|
self.LocationComboBox.setEnabled(True)
|
||||||
self.BibleComboBox.setEnabled(True)
|
self.BibleComboBox.setEnabled(True)
|
||||||
|
|
||||||
def resetAll(self):
|
def resetAll(self):
|
||||||
self.BooksLocationEdit.setText("")
|
self.BooksLocationEdit.setText("")
|
||||||
|
@ -101,6 +101,7 @@ class BibleDBImpl(BibleCommon):
|
|||||||
return book
|
return book
|
||||||
|
|
||||||
def save_meta(self, key, value):
|
def save_meta(self, key, value):
|
||||||
|
log.debug( "save_meta %s/%s", key, value)
|
||||||
metadata.bind.echo = False
|
metadata.bind.echo = False
|
||||||
session = self.session()
|
session = self.session()
|
||||||
bmeta= BibleMeta()
|
bmeta= BibleMeta()
|
||||||
|
@ -128,7 +128,10 @@ class BibleManager():
|
|||||||
nbible.save_meta("proxyid", proxyid) # store the proxy userid
|
nbible.save_meta("proxyid", proxyid) # store the proxy userid
|
||||||
if proxypass != None and proxypass != "":
|
if proxypass != None and proxypass != "":
|
||||||
nbible.save_meta("proxypass", proxypass) # store the proxy password
|
nbible.save_meta("proxypass", proxypass) # store the proxy password
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
log.debug( "register_http_file_bible %s not created already exists", biblename)
|
||||||
|
return False
|
||||||
|
|
||||||
def register_csv_file_bible(self, biblename, booksfile, versefile):
|
def register_csv_file_bible(self, biblename, booksfile, versefile):
|
||||||
"""
|
"""
|
||||||
@ -143,6 +146,10 @@ class BibleManager():
|
|||||||
self.bible_db_cache[biblename] = nbible # cache the database for use later
|
self.bible_db_cache[biblename] = nbible # cache the database for use later
|
||||||
bcsv = BibleCSVImpl(nbible) # create the loader and pass in the database
|
bcsv = BibleCSVImpl(nbible) # create the loader and pass in the database
|
||||||
bcsv.load_data(booksfile, versefile, self.dialogobject)
|
bcsv.load_data(booksfile, versefile, self.dialogobject)
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
log.debug( "register_csv_file_bible %s not created already exists", biblename)
|
||||||
|
return False
|
||||||
|
|
||||||
def register_osis_file_bible(self, biblename, osisfile):
|
def register_osis_file_bible(self, biblename, osisfile):
|
||||||
"""
|
"""
|
||||||
@ -157,6 +164,10 @@ class BibleManager():
|
|||||||
self.bible_db_cache[biblename] = nbible # cache the database for use later
|
self.bible_db_cache[biblename] = nbible # cache the database for use later
|
||||||
bcsv = BibleOSISImpl(self.biblePath, nbible) # create the loader and pass in the database
|
bcsv = BibleOSISImpl(self.biblePath, nbible) # create the loader and pass in the database
|
||||||
bcsv.load_data(osisfile, self.dialogobject)
|
bcsv.load_data(osisfile, self.dialogobject)
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
log.debug( "register_OSIS_file_bible %s , %s not created already exists", biblename, osisfile)
|
||||||
|
return False
|
||||||
|
|
||||||
def get_bibles(self, mode="full"):
|
def get_bibles(self, mode="full"):
|
||||||
log.debug("get_bibles")
|
log.debug("get_bibles")
|
||||||
|
@ -283,7 +283,7 @@ class BibleMediaItem(MediaManagerItem):
|
|||||||
self.initialiseBible(bible) # use the first bible as the trigger
|
self.initialiseBible(bible) # use the first bible as the trigger
|
||||||
|
|
||||||
def onAdvancedVersionComboBox(self):
|
def onAdvancedVersionComboBox(self):
|
||||||
self.initialiseBible(str(self.AdvancedVersionComboBox.currentText())) # restet the bible info
|
self.initialiseBible(str(self.AdvancedVersionComboBox.currentText())) # reset the bible info
|
||||||
|
|
||||||
def onAdvancedBookComboBox(self):
|
def onAdvancedBookComboBox(self):
|
||||||
self.initialiseBible(str(self.AdvancedVersionComboBox.currentText())) # reset the bible info
|
self.initialiseBible(str(self.AdvancedVersionComboBox.currentText())) # reset the bible info
|
||||||
@ -291,7 +291,7 @@ class BibleMediaItem(MediaManagerItem):
|
|||||||
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)
|
||||||
self.bibleimportform.exec_()
|
self.bibleimportform.exec_()
|
||||||
pass
|
self.reloadBibles()
|
||||||
|
|
||||||
def onAdvancedFromVerse(self):
|
def onAdvancedFromVerse(self):
|
||||||
frm = self.AdvancedFromVerse.currentText()
|
frm = self.AdvancedFromVerse.currentText()
|
||||||
@ -417,22 +417,14 @@ class BibleMediaItem(MediaManagerItem):
|
|||||||
|
|
||||||
def initialiseBible(self, bible):
|
def initialiseBible(self, bible):
|
||||||
log.debug(u"initialiseBible %s", bible)
|
log.debug(u"initialiseBible %s", bible)
|
||||||
current_book = str(self.AdvancedBookComboBox.currentText())
|
books = self.parent.biblemanager.get_bible_books(str(bible))
|
||||||
chapter_count = self.parent.biblemanager.get_book_chapter_count(bible,
|
self.AdvancedBookComboBox.clear()
|
||||||
current_book)[0]
|
first = True
|
||||||
log.debug(u'Book change bible %s book %s ChapterCount %s', bible,
|
for book in books:
|
||||||
current_book, chapter_count)
|
self.AdvancedBookComboBox.addItem(book.name)
|
||||||
if chapter_count == None:
|
if first:
|
||||||
# Only change the search details if the book is missing from the new bible
|
first = False
|
||||||
books = self.parent.biblemanager.get_bible_books(str(
|
self.initialiseChapterVerse(bible, book.name)
|
||||||
self.AdvancedVersionComboBox.currentText()))
|
|
||||||
self.AdvancedBookComboBox.clear()
|
|
||||||
first = True
|
|
||||||
for book in books:
|
|
||||||
self.AdvancedBookComboBox.addItem(book.name)
|
|
||||||
if first:
|
|
||||||
first = False
|
|
||||||
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)
|
||||||
|
@ -55,7 +55,8 @@ class AuthorsForm(QtGui.QDialog, Ui_AuthorsDialog):
|
|||||||
authors = self.songmanager.get_authors()
|
authors = self.songmanager.get_authors()
|
||||||
for author in authors:
|
for author in authors:
|
||||||
self.AuthorListData.addRow(author.id,author.display_name)
|
self.AuthorListData.addRow(author.id,author.display_name)
|
||||||
row_count = self.AuthorListData.rowCount(None)
|
#rowCount is number of rows BUT test should be Zero based
|
||||||
|
row_count = self.AuthorListData.rowCount(None) - 1
|
||||||
if self.currentRow > row_count:
|
if self.currentRow > row_count:
|
||||||
# in case we have delete the last row of the table
|
# in case we have delete the last row of the table
|
||||||
self.currentRow = row_count
|
self.currentRow = row_count
|
||||||
|
@ -55,7 +55,8 @@ class SongBookForm(QtGui.QDialog, Ui_SongBookDialog):
|
|||||||
Books = self.songmanager.get_books()
|
Books = self.songmanager.get_books()
|
||||||
for Book in Books:
|
for Book in Books:
|
||||||
self.BookSongListData.addRow(Book.id,Book.name)
|
self.BookSongListData.addRow(Book.id,Book.name)
|
||||||
row_count = self.BookSongListData.rowCount(None)
|
#rowCount is number of rows BUT test should be Zero based
|
||||||
|
row_count = self.BookSongListData.rowCount(None) - 1
|
||||||
if self.currentRow > row_count:
|
if self.currentRow > row_count:
|
||||||
# in case we have delete the last row of the table
|
# in case we have delete the last row of the table
|
||||||
self.currentRow = row_count
|
self.currentRow = row_count
|
||||||
|
@ -35,7 +35,7 @@ class TopicsForm(QtGui.QDialog, Ui_TopicsDialog):
|
|||||||
self.setupUi(self)
|
self.setupUi(self)
|
||||||
self.songmanager = songmanager
|
self.songmanager = songmanager
|
||||||
self.currentRow = 0
|
self.currentRow = 0
|
||||||
self.songbook = None
|
self.topic = None
|
||||||
|
|
||||||
QtCore.QObject.connect(self.DeleteButton,
|
QtCore.QObject.connect(self.DeleteButton,
|
||||||
QtCore.SIGNAL('pressed()'), self.onDeleteButtonClick)
|
QtCore.SIGNAL('pressed()'), self.onDeleteButtonClick)
|
||||||
@ -52,13 +52,13 @@ class TopicsForm(QtGui.QDialog, Ui_TopicsDialog):
|
|||||||
"""
|
"""
|
||||||
Refresh the screen and rest fields
|
Refresh the screen and rest fields
|
||||||
"""
|
"""
|
||||||
print "topics load form start"
|
|
||||||
self.TopicsListData.resetStore()
|
self.TopicsListData.resetStore()
|
||||||
self.onClearButtonClick() # tidy up screen
|
self.onClearButtonClick() # tidy up screen
|
||||||
Topics = self.songmanager.get_topics()
|
topics = self.songmanager.get_topics()
|
||||||
for Topic in Topics:
|
for topic in topics:
|
||||||
self.TopicsListData.addRow(Topic.id,Topic.name)
|
self.TopicsListData.addRow(topic.id,topic.name)
|
||||||
row_count = self.TopicsListData.rowCount(None)
|
#rowCount is number of rows BUT test should be Zero based
|
||||||
|
row_count = self.TopicsListData.rowCount(None) - 1
|
||||||
if self.currentRow > row_count:
|
if self.currentRow > row_count:
|
||||||
# in case we have delete the last row of the table
|
# in case we have delete the last row of the table
|
||||||
self.currentRow = row_count
|
self.currentRow = row_count
|
||||||
@ -67,14 +67,12 @@ class TopicsForm(QtGui.QDialog, Ui_TopicsDialog):
|
|||||||
self.TopicsListView.selectionModel().setCurrentIndex(row,
|
self.TopicsListView.selectionModel().setCurrentIndex(row,
|
||||||
QtGui.QItemSelectionModel.SelectCurrent)
|
QtGui.QItemSelectionModel.SelectCurrent)
|
||||||
self._validate_form()
|
self._validate_form()
|
||||||
print "topics load form end"
|
|
||||||
|
|
||||||
def onDeleteButtonClick(self):
|
def onDeleteButtonClick(self):
|
||||||
"""
|
"""
|
||||||
Delete the Topic is the Topic is not attached to any songs
|
Delete the Topic is the Topic is not attached to any songs
|
||||||
"""
|
"""
|
||||||
self.songmanager.delete_topic(self.Topic.id)
|
self.songmanager.delete_topic(self.topic.id)
|
||||||
self.onClearButtonClick()
|
|
||||||
self.load_form()
|
self.load_form()
|
||||||
|
|
||||||
def onTopicNameEditLostFocus(self):
|
def onTopicNameEditLostFocus(self):
|
||||||
@ -84,10 +82,10 @@ class TopicsForm(QtGui.QDialog, Ui_TopicsDialog):
|
|||||||
"""
|
"""
|
||||||
Sent New or update details to the database
|
Sent New or update details to the database
|
||||||
"""
|
"""
|
||||||
if self.Topic == None:
|
if self.topic == None:
|
||||||
self.Topic = Topic()
|
self.topic = Topic()
|
||||||
self.Topic.name = unicode(self.TopicNameEdit.displayText())
|
self.topic.name = unicode(self.TopicNameEdit.displayText())
|
||||||
self.songmanager.save_topic(self.Topic)
|
self.songmanager.save_topic(self.topic)
|
||||||
self.onClearButtonClick()
|
self.onClearButtonClick()
|
||||||
self.load_form()
|
self.load_form()
|
||||||
|
|
||||||
@ -99,7 +97,7 @@ class TopicsForm(QtGui.QDialog, Ui_TopicsDialog):
|
|||||||
self.MessageLabel.setText(u'')
|
self.MessageLabel.setText(u'')
|
||||||
self.DeleteButton.setEnabled(False)
|
self.DeleteButton.setEnabled(False)
|
||||||
self.AddUpdateButton.setEnabled(True)
|
self.AddUpdateButton.setEnabled(True)
|
||||||
self.Topic = None
|
self.topic = None
|
||||||
self._validate_form()
|
self._validate_form()
|
||||||
|
|
||||||
def onTopicsListViewItemClicked(self, index):
|
def onTopicsListViewItemClicked(self, index):
|
||||||
@ -109,10 +107,10 @@ class TopicsForm(QtGui.QDialog, Ui_TopicsDialog):
|
|||||||
"""
|
"""
|
||||||
self.currentRow = index.row()
|
self.currentRow = index.row()
|
||||||
id = int(self.TopicsListData.getId(index))
|
id = int(self.TopicsListData.getId(index))
|
||||||
self.Topic = self.songmanager.get_topic(id)
|
self.topic = self.songmanager.get_topic(id)
|
||||||
|
|
||||||
self.TopicNameEdit.setText(self.Topic.name)
|
self.TopicNameEdit.setText(self.topic.name)
|
||||||
if len(self.Topic.songs) > 0:
|
if len(self.topic.songs) > 0:
|
||||||
self.MessageLabel.setText("Topic in use 'Delete' is disabled")
|
self.MessageLabel.setText("Topic in use 'Delete' is disabled")
|
||||||
self.DeleteButton.setEnabled(False)
|
self.DeleteButton.setEnabled(False)
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user