forked from openlp/openlp
Clean up code and simplify.
bzr-revno: 327
This commit is contained in:
parent
336cdd9ae0
commit
1f28305ac3
@ -300,8 +300,7 @@ class BiblePlugin(Plugin, PluginUtils):
|
|||||||
|
|
||||||
def onBibleNewClick(self):
|
def onBibleNewClick(self):
|
||||||
self.bibleimportform = BibleImportForm(self.config, self.biblemanager, self)
|
self.bibleimportform = BibleImportForm(self.config, self.biblemanager, self)
|
||||||
self.bibleimportform.setModal(True)
|
self.bibleimportform.exec_()
|
||||||
self.bibleimportform.show()
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def onBiblePreviewClick(self):
|
def onBiblePreviewClick(self):
|
||||||
@ -311,7 +310,6 @@ class BiblePlugin(Plugin, PluginUtils):
|
|||||||
verse = text[:text.find("(")]
|
verse = text[:text.find("(")]
|
||||||
bible = text[text.find("(")+1:text.find(")")]
|
bible = text[text.find("(")+1:text.find(")")]
|
||||||
self._search_using_bible_reference(bible, verse)
|
self._search_using_bible_reference(bible, verse)
|
||||||
print self.search_results
|
|
||||||
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])
|
||||||
verse = str(self.search_results[0][2])
|
verse = str(self.search_results[0][2])
|
||||||
@ -321,13 +319,14 @@ class BiblePlugin(Plugin, PluginUtils):
|
|||||||
if o == 1: #Paragraph
|
if o == 1: #Paragraph
|
||||||
text = text + "\n"
|
text = text + "\n"
|
||||||
if v == 1: #Paragraph
|
if v == 1: #Paragraph
|
||||||
loc = "("+book + " "+chapter+ ":"+verse+")"
|
loc = "("+chapter+ ":"+verse+")"
|
||||||
elif v == 2: #Paragraph
|
elif v == 2: #Paragraph
|
||||||
loc = "{"+book + " "+chapter+ ":"+verse+"}"
|
loc = "{"+chapter+ ":"+verse+"}"
|
||||||
elif v == 3: #Paragraph
|
elif v == 3: #Paragraph
|
||||||
loc = "["+book + " "+chapter+ ":"+verse+"]"
|
loc = "["+chapter+ ":"+verse+"]"
|
||||||
else:
|
else:
|
||||||
loc = book + " "+chapter+ ":"+verse
|
loc = chapter+ ":"+verse
|
||||||
|
print book
|
||||||
print loc
|
print loc
|
||||||
print text
|
print text
|
||||||
|
|
||||||
@ -410,10 +409,10 @@ class BiblePlugin(Plugin, PluginUtils):
|
|||||||
|
|
||||||
def _initialise_chapter_verse(self, bible, book):
|
def _initialise_chapter_verse(self, bible, book):
|
||||||
log.debug("_initialise_chapter_verse %s , %s", bible, book)
|
log.debug("_initialise_chapter_verse %s , %s", bible, book)
|
||||||
self.chaptersfrom = self.biblemanager.get_book_chapter_count(bible, book)[0]
|
self.chapters_from = self.biblemanager.get_book_chapter_count(bible, book)[0]
|
||||||
self.verses = self.biblemanager.get_book_verse_count(bible, book, 1)[0]
|
self.verses = self.biblemanager.get_book_verse_count(bible, book, 1)[0]
|
||||||
self._adjust_combobox(1, self.chaptersfrom, self.AdvancedFromChapter)
|
self._adjust_combobox(1, self.chapters_from, self.AdvancedFromChapter)
|
||||||
self._adjust_combobox(1, self.chaptersfrom, self.AdvancedToChapter)
|
self._adjust_combobox(1, self.chapters_from, self.AdvancedToChapter)
|
||||||
self._adjust_combobox(1, self.verses, self.AdvancedFromVerse)
|
self._adjust_combobox(1, self.verses, self.AdvancedFromVerse)
|
||||||
self._adjust_combobox(1, self.verses, self.AdvancedToVerse)
|
self._adjust_combobox(1, self.verses, self.AdvancedToVerse)
|
||||||
|
|
||||||
@ -421,7 +420,7 @@ class BiblePlugin(Plugin, PluginUtils):
|
|||||||
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.chaptersfrom, self.AdvancedToChapter)
|
self._adjust_combobox(cf, self.chapters_from, self.AdvancedToChapter)
|
||||||
vse = self.biblemanager.get_book_verse_count(bible, book, int(cf))[0] # get the verse count for new chapter
|
vse = self.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._adjust_combobox(1, vse, self.AdvancedFromVerse)
|
||||||
self._adjust_combobox(1, vse, self.AdvancedToVerse)
|
self._adjust_combobox(1, vse, self.AdvancedToVerse)
|
||||||
@ -476,13 +475,13 @@ class BiblePlugin(Plugin, PluginUtils):
|
|||||||
|
|
||||||
def _display_results(self, bible):
|
def _display_results(self, bible):
|
||||||
for book, chap, vse , txt in self.search_results:
|
for book, chap, vse , txt in self.search_results:
|
||||||
c = self.BibleListView.rowCount()
|
row_count = self.BibleListView.rowCount()
|
||||||
self.BibleListView.setRowCount(c+1)
|
self.BibleListView.setRowCount(row_count+1)
|
||||||
table_data = QtGui.QTableWidgetItem(str(bible))
|
table_data = QtGui.QTableWidgetItem(str(bible))
|
||||||
self.BibleListView.setItem(c , 0, table_data)
|
self.BibleListView.setItem(row_count , 0, table_data)
|
||||||
table_data = QtGui.QTableWidgetItem(str(book + " " +str(chap) + ":"+ str(vse)) + " ("+str(bible)+")")
|
table_data = QtGui.QTableWidgetItem(str(book + " " +str(chap) + ":"+ str(vse)) + " ("+str(bible)+")")
|
||||||
self.BibleListView.setItem(c , 1, table_data)
|
self.BibleListView.setItem(row_count , 1, table_data)
|
||||||
self.BibleListView.setRowHeight(c, 20)
|
self.BibleListView.setRowHeight(row_count, 20)
|
||||||
|
|
||||||
|
|
||||||
def _initialise_bible_quick(self, bible): # not sure if needed yet!
|
def _initialise_bible_quick(self, bible): # not sure if needed yet!
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
# Form implementation generated from reading ui file 'bibleimportdialog.ui'
|
# Form implementation generated from reading ui file 'bibleimportdialog.ui'
|
||||||
#
|
#
|
||||||
# Created: Thu Feb 19 16:01:11 2009
|
# Created: Fri Feb 20 05:45:22 2009
|
||||||
# by: PyQt4 UI code generator 4.4.4
|
# by: PyQt4 UI code generator 4.4.4
|
||||||
#
|
#
|
||||||
# WARNING! All changes made in this file will be lost!
|
# WARNING! All changes made in this file will be lost!
|
||||||
@ -77,7 +77,7 @@ class Ui_BibleImportDialog(object):
|
|||||||
self.BibleNameLabel.setObjectName("BibleNameLabel")
|
self.BibleNameLabel.setObjectName("BibleNameLabel")
|
||||||
self.ImportToolBox.addItem(self.FileImportPage, "")
|
self.ImportToolBox.addItem(self.FileImportPage, "")
|
||||||
self.WebBiblePage = QtGui.QWidget()
|
self.WebBiblePage = QtGui.QWidget()
|
||||||
self.WebBiblePage.setGeometry(QtCore.QRect(0, 0, 192, 228))
|
self.WebBiblePage.setGeometry(QtCore.QRect(0, 0, 447, 337))
|
||||||
self.WebBiblePage.setObjectName("WebBiblePage")
|
self.WebBiblePage.setObjectName("WebBiblePage")
|
||||||
self.WebBibleLayout = QtGui.QVBoxLayout(self.WebBiblePage)
|
self.WebBibleLayout = QtGui.QVBoxLayout(self.WebBiblePage)
|
||||||
self.WebBibleLayout.setSpacing(8)
|
self.WebBibleLayout.setSpacing(8)
|
||||||
@ -185,7 +185,8 @@ class Ui_BibleImportDialog(object):
|
|||||||
self.horizontalLayout.addWidget(self.CancelButton)
|
self.horizontalLayout.addWidget(self.CancelButton)
|
||||||
|
|
||||||
self.retranslateUi(BibleImportDialog)
|
self.retranslateUi(BibleImportDialog)
|
||||||
self.ImportToolBox.setCurrentIndex(0)
|
self.ImportToolBox.setCurrentIndex(1)
|
||||||
|
|
||||||
QtCore.QMetaObject.connectSlotsByName(BibleImportDialog)
|
QtCore.QMetaObject.connectSlotsByName(BibleImportDialog)
|
||||||
BibleImportDialog.setTabOrder(self.BibleNameEdit, self.OSISLocationEdit)
|
BibleImportDialog.setTabOrder(self.BibleNameEdit, self.OSISLocationEdit)
|
||||||
BibleImportDialog.setTabOrder(self.OSISLocationEdit, self.OsisFileButton)
|
BibleImportDialog.setTabOrder(self.OSISLocationEdit, self.OsisFileButton)
|
||||||
|
@ -35,7 +35,7 @@ class BibleImportForm(QDialog, Ui_BibleImportDialog, PluginUtils):
|
|||||||
self.biblemanager = biblemanager
|
self.biblemanager = biblemanager
|
||||||
self.config = config
|
self.config = config
|
||||||
self.bibleplugin = bibleplugin
|
self.bibleplugin = bibleplugin
|
||||||
self.bibletype = None
|
self.bible_type = None
|
||||||
self.barmax = 0
|
self.barmax = 0
|
||||||
self.AddressEdit.setText(self.config.get_config("addressedit", ""))
|
self.AddressEdit.setText(self.config.get_config("addressedit", ""))
|
||||||
self.UsernameEdit.setText(self.config.get_config("usernameedit", ""))
|
self.UsernameEdit.setText(self.config.get_config("usernameedit", ""))
|
||||||
@ -52,132 +52,111 @@ class BibleImportForm(QDialog, Ui_BibleImportDialog, PluginUtils):
|
|||||||
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
|
||||||
|
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.LocationComboBox, QtCore.SIGNAL("activated(int)"), self.onLocationComboBox)
|
############### Buttons
|
||||||
QtCore.QObject.connect(self.BibleComboBox, QtCore.SIGNAL("activated(int)"), self.onBibleComboBox)
|
QtCore.QObject.connect(self.ImportButton, QtCore.SIGNAL("pressed()"), self.onImportButtonClicked)
|
||||||
|
QtCore.QObject.connect(self.CancelButton, QtCore.SIGNAL("pressed()"), self.onCancelButtonClicked)
|
||||||
|
QtCore.QObject.connect(self.VersesFileButton, QtCore.SIGNAL("pressed()"), self.onVersesFileButtonClicked)
|
||||||
|
QtCore.QObject.connect(self.BooksFileButton, QtCore.SIGNAL("pressed()"), self.onBooksFileButtonClicked)
|
||||||
|
QtCore.QObject.connect(self.OsisFileButton, QtCore.SIGNAL("pressed()"), self.onOsisFileButtonClicked)
|
||||||
|
|
||||||
@pyqtSignature("")
|
############### Lost Focus
|
||||||
def on_VersesFileButton_clicked(self):
|
QtCore.QObject.connect(self.OSISLocationEdit, QtCore.SIGNAL("lostFocus()"), self.onOSISLocationEditLostFocus)
|
||||||
|
QtCore.QObject.connect(self.BooksLocationEdit, QtCore.SIGNAL("lostFocus()"),self.onBooksLocationEditLostFocus)
|
||||||
|
QtCore.QObject.connect(self.VerseLocationEdit, QtCore.SIGNAL("lostFocus()"), self.onVerseLocationEditLostFocus)
|
||||||
|
QtCore.QObject.connect(self.AddressEdit, QtCore.SIGNAL("lostFocus()"), self.onProxyAddressEditLostFocus)
|
||||||
|
QtCore.QObject.connect(self.UsernameEdit, QtCore.SIGNAL("lostFocus()"), self.onProxyUsernameEditLostFocus)
|
||||||
|
QtCore.QObject.connect(self.PasswordEdit, QtCore.SIGNAL("lostFocus()"), self.onProxyPasswordEditLostFocus)
|
||||||
|
|
||||||
|
|
||||||
|
def onVersesFileButtonClicked(self):
|
||||||
filename = QtGui.QFileDialog.getOpenFileName(self, 'Open file',self._get_last_dir(1))
|
filename = QtGui.QFileDialog.getOpenFileName(self, 'Open file',self._get_last_dir(1))
|
||||||
self.VerseLocationEdit.setText(filename)
|
self.VerseLocationEdit.setText(filename)
|
||||||
if filename != "":
|
if filename != "":
|
||||||
self._save_last_directory(filename, 1)
|
self._save_last_directory(filename, 1)
|
||||||
self.setCSV()
|
self.set_cvs()
|
||||||
|
|
||||||
@pyqtSignature("")
|
def onBooksFileButtonClicked(self):
|
||||||
def on_BooksFileButton_clicked(self):
|
|
||||||
filename = QtGui.QFileDialog.getOpenFileName(self, 'Open file',self._get_last_dir(2))
|
filename = QtGui.QFileDialog.getOpenFileName(self, 'Open file',self._get_last_dir(2))
|
||||||
self.BooksLocationEdit.setText(filename)
|
self.BooksLocationEdit.setText(filename)
|
||||||
if filename != "":
|
if filename != "":
|
||||||
self._save_last_directory(filename, 2)
|
self._save_last_directory(filename, 2)
|
||||||
self.setCSV()
|
self.set_cvs()
|
||||||
|
|
||||||
@pyqtSignature("")
|
def onOsisFileButtonClicked(self):
|
||||||
def on_OsisFileButton_clicked(self):
|
|
||||||
filename = QtGui.QFileDialog.getOpenFileName(self, 'Open file',self._get_last_dir(3))
|
filename = QtGui.QFileDialog.getOpenFileName(self, 'Open file',self._get_last_dir(3))
|
||||||
self.OSISLocationEdit.setText(filename)
|
self.OSISLocationEdit.setText(filename)
|
||||||
if filename != "":
|
if filename != "":
|
||||||
self._save_last_directory(filename, 3)
|
self._save_last_directory(filename, 3)
|
||||||
self.setOSIS()
|
self.set_osis()
|
||||||
|
|
||||||
def on_OSISLocationEdit_lostFocus(self):
|
def onOSISLocationEditLostFocus(self):
|
||||||
if len(self.OSISLocationEdit.displayText() ) > 0:
|
if len(self.OSISLocationEdit.displayText() ) > 0:
|
||||||
self.setOSIS()
|
self.set_osis()
|
||||||
else:
|
else:
|
||||||
if self.bibletype == "OSIS": # Was OSIS and is not any more stops lostFocus running mad
|
if self.bible_type == "OSIS": # Was OSIS and is not any more stops lostFocus running mad
|
||||||
self.bibletype = None
|
self.bible_type = None
|
||||||
self.freeAll()
|
self.free_all()
|
||||||
|
|
||||||
def on_BooksLocationEdit_lostFocus(self):
|
def onBooksLocationEditLostFocus(self):
|
||||||
self._checkcsv()
|
self.check_osis()
|
||||||
|
|
||||||
def on_VerseLocationEdit_lostFocus(self):
|
def onVerseLocationEditLostFocus(self):
|
||||||
self._checkcsv()
|
self.check_osis()
|
||||||
|
|
||||||
def _checkcsv(self):
|
def onProxyAddressEditLostFocus(self):
|
||||||
if len(self.BooksLocationEdit.displayText()) > 0 or len(self.VerseLocationEdit.displayText()) > 0:
|
|
||||||
self.setCSV()
|
|
||||||
else:
|
|
||||||
if self.bibletype == "CSV": # Was CSV and is not any more stops lostFocus running mad
|
|
||||||
self.bibletype = None
|
|
||||||
self.freeAll()
|
|
||||||
|
|
||||||
@pyqtSignature("")
|
|
||||||
def on_AddressEdit_lostFocus(self):
|
|
||||||
self.config.set_config("addressedit", str(self.AddressEdit.displayText()))
|
self.config.set_config("addressedit", str(self.AddressEdit.displayText()))
|
||||||
|
|
||||||
@pyqtSignature("")
|
def onProxyUsernameEditLostFocus(self):
|
||||||
def on_UsernameEdit_lostFocus(self):
|
|
||||||
self.config.set_config("usernameedit", str(self.UsernameEdit.displayText()))
|
self.config.set_config("usernameedit", str(self.UsernameEdit.displayText()))
|
||||||
|
|
||||||
@pyqtSignature("")
|
def onProxyPasswordEditLostFocus(self):
|
||||||
def on_PasswordEdit_lostFocus(self):
|
|
||||||
self.config.set_config("passwordedit", str(self.PasswordEdit.displayText()))
|
self.config.set_config("passwordedit", str(self.PasswordEdit.displayText()))
|
||||||
|
|
||||||
def onLocationComboBox(self):
|
def onLocationComboBoxSelected(self):
|
||||||
self._checkhttp()
|
self.check_http()
|
||||||
|
|
||||||
def onBibleComboBox(self):
|
def onBibleComboBoxSelected(self):
|
||||||
self._checkhttp()
|
self.check_http()
|
||||||
self.BibleNameEdit.setText(str(self.BibleComboBox.currentText()))
|
self.BibleNameEdit.setText(str(self.BibleComboBox.currentText()))
|
||||||
|
|
||||||
def _checkhttp(self):
|
|
||||||
if len(self.LocationComboBox.currentText()) > 0 or \
|
|
||||||
len(self.BibleComboBox.currentText()) >0 :
|
|
||||||
self.setHTTP()
|
|
||||||
else:
|
|
||||||
if self.bibletype == "HTTP": # Was HTTP and is not any more stops lostFocus running mad
|
|
||||||
self.bibletype = None
|
|
||||||
self.freeAll()
|
|
||||||
|
|
||||||
def on_CopyrightEdit_lostFocus(self):
|
def onCancelButtonClicked(self):
|
||||||
pass
|
|
||||||
|
|
||||||
def on_VersionNameEdit_lostFocus(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def on_PermisionEdit_lostFocus(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def on_BibleNameEdit_lostFocus(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
@pyqtSignature("")
|
|
||||||
def on_CancelButton_clicked(self):
|
|
||||||
Receiver().send_message("openlpstopimport")
|
Receiver().send_message("openlpstopimport")
|
||||||
self.close()
|
self.close()
|
||||||
|
|
||||||
@pyqtSignature("")
|
@pyqtSignature("")
|
||||||
def on_ImportButton_clicked(self):
|
def onImportButtonClicked(self):
|
||||||
if self.biblemanager != None:
|
if self.biblemanager != None:
|
||||||
if not self.bibletype == 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.progress = 0
|
|
||||||
self.biblemanager.process_dialog(self)
|
self.biblemanager.process_dialog(self)
|
||||||
self._import_bible()
|
self._import_bible()
|
||||||
self.MessageLabel.setText("Import Complete")
|
self.MessageLabel.setText("Import Complete")
|
||||||
self.ProgressBar.setValue(self.barmax)
|
self.ProgressBar.setValue(self.barmax)
|
||||||
Receiver().send_message("openlpreloadbibles") # tell bibleplugin to reload the bibles
|
Receiver().send_message("openlpreloadbibles") # tell bibleplugin to reload the bibles
|
||||||
|
|
||||||
def setMax(self, max):
|
def set_max(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 incrementBar(self, text ):
|
def increment_progress_bar(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.progress +=1
|
self.ProgressBar.setValue(self.ProgressBar.value()+1)
|
||||||
self.ProgressBar.setValue(self.progress)
|
|
||||||
|
|
||||||
def _import_bible(self):
|
def _import_bible(self):
|
||||||
log.debug("Import Bible ")
|
log.debug("Import Bible ")
|
||||||
if self.bibletype == "OSIS":
|
if self.bible_type == "OSIS":
|
||||||
self.biblemanager.register_osis_file_bible(str(self.BibleNameEdit.displayText()), self.OSISLocationEdit.displayText())
|
self.biblemanager.register_osis_file_bible(str(self.BibleNameEdit.displayText()), self.OSISLocationEdit.displayText())
|
||||||
elif self.bibletype == "CSV":
|
elif self.bible_type == "CSV":
|
||||||
self.biblemanager.register_csv_file_bible(str(self.BibleNameEdit.displayText()), self.BooksLocationEdit.displayText(), self.VerseLocationEdit.displayText())
|
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
|
||||||
@ -189,49 +168,67 @@ class BibleImportForm(QDialog, Ui_BibleImportDialog, PluginUtils):
|
|||||||
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()))
|
self.biblemanager.save_meta_data(str(self.BibleNameEdit.displayText()), str(self.VersionNameEdit.displayText()), str(self.CopyrightEdit.displayText()), str(self.PermisionEdit.displayText()))
|
||||||
self.bibletype = None
|
self.bible_type = None
|
||||||
self.freeAll() # free the screen state restrictions
|
self.free_all() # free the screen state restrictions
|
||||||
self.resetAll() # reset all the screen fields
|
self.reset_all() # reset all the screen fields
|
||||||
|
|
||||||
def blockCSV(self):
|
def check_osis(self):
|
||||||
|
if len(self.BooksLocationEdit.displayText()) > 0 or len(self.VerseLocationEdit.displayText()) > 0:
|
||||||
|
self.set_cvs()
|
||||||
|
else:
|
||||||
|
if self.bible_type == "CSV": # Was CSV and is not any more stops lostFocus running mad
|
||||||
|
self.bible_type = None
|
||||||
|
self.free_all()
|
||||||
|
|
||||||
|
def check_http(self):
|
||||||
|
if len(self.LocationComboBox.currentText()) > 0 or \
|
||||||
|
len(self.BibleComboBox.currentText()) >0 :
|
||||||
|
self.set_http()
|
||||||
|
else:
|
||||||
|
if self.bible_type == "HTTP": # Was HTTP and is not any more stops lostFocus running mad
|
||||||
|
self.bible_type = None
|
||||||
|
self.free_all()
|
||||||
|
|
||||||
|
|
||||||
|
def block_csv(self):
|
||||||
self.BooksLocationEdit.setReadOnly(True)
|
self.BooksLocationEdit.setReadOnly(True)
|
||||||
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 set_cvs(self):
|
||||||
self.bibletype = "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.block_osis()
|
||||||
self.blockHTTP()
|
self.block_http()
|
||||||
|
|
||||||
def setOSIS(self):
|
def set_osis(self):
|
||||||
self.bibletype = "OSIS"
|
self.bible_type = "OSIS"
|
||||||
self.OSISLocationEdit.setReadOnly(False)
|
self.OSISLocationEdit.setReadOnly(False)
|
||||||
self.OsisFileButton.setEnabled(True)
|
self.OsisFileButton.setEnabled(True)
|
||||||
self.blockCSV()
|
self.block_csv()
|
||||||
self.blockHTTP()
|
self.block_http()
|
||||||
|
|
||||||
def blockOSIS(self):
|
def block_osis(self):
|
||||||
self.OSISLocationEdit.setReadOnly(True)
|
self.OSISLocationEdit.setReadOnly(True)
|
||||||
self.OsisFileButton.setEnabled(False)
|
self.OsisFileButton.setEnabled(False)
|
||||||
|
|
||||||
def setHTTP(self):
|
def set_http(self):
|
||||||
self.bibletype = "HTTP"
|
self.bible_type = "HTTP"
|
||||||
self.LocationComboBox.setEnabled(True)
|
self.LocationComboBox.setEnabled(True)
|
||||||
self.BibleComboBox.setEnabled(True)
|
self.BibleComboBox.setEnabled(True)
|
||||||
self.blockCSV()
|
self.block_csv()
|
||||||
self.blockOSIS()
|
self.block_osis()
|
||||||
|
|
||||||
def blockHTTP(self):
|
def block_http(self):
|
||||||
self.LocationComboBox.setEnabled(False)
|
self.LocationComboBox.setEnabled(False)
|
||||||
self.BibleComboBox.setEnabled(False)
|
self.BibleComboBox.setEnabled(False)
|
||||||
|
|
||||||
def freeAll(self):
|
def free_all(self):
|
||||||
if self.bibletype == 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)
|
||||||
@ -241,7 +238,7 @@ class BibleImportForm(QDialog, Ui_BibleImportDialog, PluginUtils):
|
|||||||
self.LocationComboBox.setEnabled(True)
|
self.LocationComboBox.setEnabled(True)
|
||||||
self.BibleComboBox.setEnabled(True)
|
self.BibleComboBox.setEnabled(True)
|
||||||
|
|
||||||
def resetAll(self):
|
def reset_all(self):
|
||||||
self.BooksLocationEdit.setText("")
|
self.BooksLocationEdit.setText("")
|
||||||
self.VerseLocationEdit.setText("")
|
self.VerseLocationEdit.setText("")
|
||||||
self.OSISLocationEdit.setText("")
|
self.OSISLocationEdit.setText("")
|
||||||
|
@ -33,15 +33,23 @@ class BibleCSVImpl(BibleCommon):
|
|||||||
a clean bible is being loaded.
|
a clean bible is being loaded.
|
||||||
"""
|
"""
|
||||||
self.bibledb = bibledb
|
self.bibledb = bibledb
|
||||||
|
self.loadbible = True
|
||||||
|
QtCore.QObject.connect(Receiver().get_receiver(),QtCore.SIGNAL("openlpstopimport"),self.stop_import)
|
||||||
|
|
||||||
|
def stop_import(self):
|
||||||
|
self.loadbible= False
|
||||||
|
|
||||||
def load_data(self, booksfile, versesfile, dialogobject):
|
def load_data(self, booksfile, versesfile, dialogobject):
|
||||||
#Populate the Tables
|
#Populate the Tables
|
||||||
fbooks=open(booksfile, 'r')
|
fbooks=open(booksfile, 'r')
|
||||||
fverse=open(versesfile, 'r')
|
fverse=open(versesfile, 'r')
|
||||||
|
|
||||||
|
|
||||||
count = 0
|
count = 0
|
||||||
for line in fbooks:
|
for line in fbooks:
|
||||||
#log.debug( line)
|
#log.debug( line)
|
||||||
|
if self.loadbible == False: # cancel pressed
|
||||||
|
break
|
||||||
p = line.split(",")
|
p = line.split(",")
|
||||||
p1 = p[1].replace('"', '')
|
p1 = p[1].replace('"', '')
|
||||||
p2 = p[2].replace('"', '')
|
p2 = p[2].replace('"', '')
|
||||||
@ -55,6 +63,8 @@ class BibleCSVImpl(BibleCommon):
|
|||||||
count = 0
|
count = 0
|
||||||
book_ptr = None
|
book_ptr = None
|
||||||
for line in fverse:
|
for line in fverse:
|
||||||
|
if self.loadbible == False: # cancel pressed
|
||||||
|
break
|
||||||
#log.debug( line)
|
#log.debug( line)
|
||||||
p = line.split(",", 3) # split into 3 units and leave the rest as a single field
|
p = line.split(",", 3) # split into 3 units and leave the rest as a single field
|
||||||
p0 = p[0].replace('"', '')
|
p0 = p[0].replace('"', '')
|
||||||
@ -62,7 +72,7 @@ class BibleCSVImpl(BibleCommon):
|
|||||||
if book_ptr is not p0:
|
if book_ptr is not p0:
|
||||||
book = self.bibledb.get_bible_book(p0)
|
book = self.bibledb.get_bible_book(p0)
|
||||||
book_ptr = book.name
|
book_ptr = book.name
|
||||||
dialogobject.incrementBar(book.name) # increament the progress bar
|
dialogobject.increment_progress_bar(book.name) # increament the progress bar
|
||||||
self.bibledb.add_verse(book.id, p[1], p[2], p3)
|
self.bibledb.add_verse(book.id, p[1], p[2], p3)
|
||||||
count += 1
|
count += 1
|
||||||
if count % 3 == 0: #Every x verses repaint the screen
|
if count % 3 == 0: #Every x verses repaint the screen
|
||||||
|
@ -95,7 +95,7 @@ class BibleOSISImpl():
|
|||||||
testament += 1
|
testament += 1
|
||||||
book_ptr = p[0]
|
book_ptr = p[0]
|
||||||
book = self.bibledb.create_book(self.booksOfBible[p[0]] , self.abbrevOfBible[p[0]], testament)
|
book = self.bibledb.create_book(self.booksOfBible[p[0]] , self.abbrevOfBible[p[0]], testament)
|
||||||
dialogobject.incrementBar(self.booksOfBible[p[0]] )
|
dialogobject.increment_progress_bar(self.booksOfBible[p[0]] )
|
||||||
Receiver().send_message("openlpprocessevents")
|
Receiver().send_message("openlpprocessevents")
|
||||||
count = 0
|
count = 0
|
||||||
self.bibledb.add_verse(book.id, p[1], p[2], t)
|
self.bibledb.add_verse(book.id, p[1], p[2], t)
|
||||||
|
Loading…
Reference in New Issue
Block a user