forked from openlp/openlp
Update bible register dialog - Register only 1 bible
Register HTTP Get HTTP verse selection working (part 1) More Orm migrations. bzr-revno: 290
This commit is contained in:
parent
4071118398
commit
44216e6a6a
@ -226,15 +226,12 @@ class BiblePlugin(Plugin, PluginUtils):
|
|||||||
|
|
||||||
def onAdvancedVersionComboBox(self):
|
def onAdvancedVersionComboBox(self):
|
||||||
self._initialise_bible_advanced(str(self.AdvancedVersionComboBox.currentText())) # restet the bible info
|
self._initialise_bible_advanced(str(self.AdvancedVersionComboBox.currentText())) # restet the bible info
|
||||||
|
pass
|
||||||
|
|
||||||
def onAdvancedBookComboBox(self):
|
def onAdvancedBookComboBox(self):
|
||||||
print self.AdvancedVersionComboBox.currentText()
|
|
||||||
self._initialise_bible_advanced(str(self.AdvancedVersionComboBox.currentText())) # restet the bible info
|
self._initialise_bible_advanced(str(self.AdvancedVersionComboBox.currentText())) # restet the bible info
|
||||||
|
|
||||||
def onQuickTabClick(self):
|
def onQuickTabClick(self):
|
||||||
print "onQuickTabClick"
|
|
||||||
print self.SearchTabWidget.currentIndex()
|
|
||||||
print self.SearchTabWidget.tabText(self.SearchTabWidget.currentIndex())
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def onBibleNewClick(self):
|
def onBibleNewClick(self):
|
||||||
@ -253,6 +250,10 @@ class BiblePlugin(Plugin, PluginUtils):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def _initialise_form(self):
|
def _initialise_form(self):
|
||||||
|
log.debug("_initialise_form")
|
||||||
|
self.QuickSearchComboBox.clear()
|
||||||
|
self.QuickVersionComboBox.clear()
|
||||||
|
self.AdvancedVersionComboBox.clear()
|
||||||
bibles = self.biblemanager.get_bibles("full")
|
bibles = self.biblemanager.get_bibles("full")
|
||||||
self.QuickSearchComboBox.addItem("Text Search")
|
self.QuickSearchComboBox.addItem("Text Search")
|
||||||
self.QuickSearchComboBox.addItem("Verse Search")
|
self.QuickSearchComboBox.addItem("Verse Search")
|
||||||
@ -378,7 +379,7 @@ class BiblePlugin(Plugin, PluginUtils):
|
|||||||
#print "from =" + str(v)
|
#print "from =" + str(v)
|
||||||
print "to ="
|
print "to ="
|
||||||
self.searchresults = self.biblemanager.get_verse_text(bible, book,int(chapters[0]), int(chapters[1]), 1, 99)
|
self.searchresults = self.biblemanager.get_verse_text(bible, book,int(chapters[0]), int(chapters[1]), 1, 99)
|
||||||
self._display_results()
|
self._display_results(bible)
|
||||||
|
|
||||||
def _split_chapters(self, text):
|
def _split_chapters(self, text):
|
||||||
txt = text.split("-") # split in to parts
|
txt = text.split("-") # split in to parts
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# Form implementation generated from reading ui file 'bibleimport.ui'
|
# Form implementation generated from reading ui file 'bibleimportdialog.ui'
|
||||||
#
|
#
|
||||||
# Created: Mon Dec 15 18:34:25 2008
|
# Created: Sat Jan 24 07:46:38 2009
|
||||||
# by: PyQt4 UI code generator 4.4.3
|
# 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!
|
||||||
|
|
||||||
@ -13,6 +13,9 @@ class Ui_BibleImportDialog(object):
|
|||||||
def setupUi(self, BibleImportDialog):
|
def setupUi(self, BibleImportDialog):
|
||||||
BibleImportDialog.setObjectName("BibleImportDialog")
|
BibleImportDialog.setObjectName("BibleImportDialog")
|
||||||
BibleImportDialog.resize(494, 725)
|
BibleImportDialog.resize(494, 725)
|
||||||
|
icon = QtGui.QIcon()
|
||||||
|
icon.addPixmap(QtGui.QPixmap(":/icon/openlp.org-icon-32.bmp"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||||
|
BibleImportDialog.setWindowIcon(icon)
|
||||||
self.BibleImportButtonBox = QtGui.QDialogButtonBox(BibleImportDialog)
|
self.BibleImportButtonBox = QtGui.QDialogButtonBox(BibleImportDialog)
|
||||||
self.BibleImportButtonBox.setGeometry(QtCore.QRect(10, 690, 481, 33))
|
self.BibleImportButtonBox.setGeometry(QtCore.QRect(10, 690, 481, 33))
|
||||||
self.BibleImportButtonBox.setOrientation(QtCore.Qt.Horizontal)
|
self.BibleImportButtonBox.setOrientation(QtCore.Qt.Horizontal)
|
||||||
@ -22,7 +25,7 @@ class Ui_BibleImportDialog(object):
|
|||||||
self.ImportToolBox.setGeometry(QtCore.QRect(10, 0, 471, 431))
|
self.ImportToolBox.setGeometry(QtCore.QRect(10, 0, 471, 431))
|
||||||
self.ImportToolBox.setObjectName("ImportToolBox")
|
self.ImportToolBox.setObjectName("ImportToolBox")
|
||||||
self.FileImportPage = QtGui.QWidget()
|
self.FileImportPage = QtGui.QWidget()
|
||||||
self.FileImportPage.setGeometry(QtCore.QRect(0, 0, 461, 361))
|
self.FileImportPage.setGeometry(QtCore.QRect(0, 0, 96, 26))
|
||||||
self.FileImportPage.setObjectName("FileImportPage")
|
self.FileImportPage.setObjectName("FileImportPage")
|
||||||
self.OSISGroupBox = QtGui.QGroupBox(self.FileImportPage)
|
self.OSISGroupBox = QtGui.QGroupBox(self.FileImportPage)
|
||||||
self.OSISGroupBox.setGeometry(QtCore.QRect(8, 65, 451, 81))
|
self.OSISGroupBox.setGeometry(QtCore.QRect(8, 65, 451, 81))
|
||||||
@ -38,9 +41,9 @@ class Ui_BibleImportDialog(object):
|
|||||||
self.OSISLocationEdit.setObjectName("OSISLocationEdit")
|
self.OSISLocationEdit.setObjectName("OSISLocationEdit")
|
||||||
self.gridLayout_2.addWidget(self.OSISLocationEdit, 0, 1, 1, 1)
|
self.gridLayout_2.addWidget(self.OSISLocationEdit, 0, 1, 1, 1)
|
||||||
self.OsisFileButton = QtGui.QPushButton(self.OSISGroupBox)
|
self.OsisFileButton = QtGui.QPushButton(self.OSISGroupBox)
|
||||||
icon = QtGui.QIcon()
|
icon1 = QtGui.QIcon()
|
||||||
icon.addPixmap(QtGui.QPixmap("../images/import_load.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
icon1.addPixmap(QtGui.QPixmap(":/imports/import_load.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||||
self.OsisFileButton.setIcon(icon)
|
self.OsisFileButton.setIcon(icon1)
|
||||||
self.OsisFileButton.setObjectName("OsisFileButton")
|
self.OsisFileButton.setObjectName("OsisFileButton")
|
||||||
self.gridLayout_2.addWidget(self.OsisFileButton, 0, 2, 1, 1)
|
self.gridLayout_2.addWidget(self.OsisFileButton, 0, 2, 1, 1)
|
||||||
self.CVSGroupBox = QtGui.QGroupBox(self.FileImportPage)
|
self.CVSGroupBox = QtGui.QGroupBox(self.FileImportPage)
|
||||||
@ -63,11 +66,11 @@ class Ui_BibleImportDialog(object):
|
|||||||
self.BooksLocationEdit.setObjectName("BooksLocationEdit")
|
self.BooksLocationEdit.setObjectName("BooksLocationEdit")
|
||||||
self.gridLayout.addWidget(self.BooksLocationEdit, 0, 1, 1, 1)
|
self.gridLayout.addWidget(self.BooksLocationEdit, 0, 1, 1, 1)
|
||||||
self.BooksFileButton = QtGui.QPushButton(self.CVSGroupBox)
|
self.BooksFileButton = QtGui.QPushButton(self.CVSGroupBox)
|
||||||
self.BooksFileButton.setIcon(icon)
|
self.BooksFileButton.setIcon(icon1)
|
||||||
self.BooksFileButton.setObjectName("BooksFileButton")
|
self.BooksFileButton.setObjectName("BooksFileButton")
|
||||||
self.gridLayout.addWidget(self.BooksFileButton, 0, 2, 1, 1)
|
self.gridLayout.addWidget(self.BooksFileButton, 0, 2, 1, 1)
|
||||||
self.VersesFileButton = QtGui.QPushButton(self.CVSGroupBox)
|
self.VersesFileButton = QtGui.QPushButton(self.CVSGroupBox)
|
||||||
self.VersesFileButton.setIcon(icon)
|
self.VersesFileButton.setIcon(icon1)
|
||||||
self.VersesFileButton.setObjectName("VersesFileButton")
|
self.VersesFileButton.setObjectName("VersesFileButton")
|
||||||
self.gridLayout.addWidget(self.VersesFileButton, 4, 2, 1, 1)
|
self.gridLayout.addWidget(self.VersesFileButton, 4, 2, 1, 1)
|
||||||
self.BibleNameEdit = QtGui.QLineEdit(self.FileImportPage)
|
self.BibleNameEdit = QtGui.QLineEdit(self.FileImportPage)
|
||||||
@ -78,7 +81,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, 461, 361))
|
self.WebBiblePage.setGeometry(QtCore.QRect(0, 0, 471, 371))
|
||||||
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)
|
||||||
@ -190,7 +193,7 @@ class Ui_BibleImportDialog(object):
|
|||||||
self.gridLayout_3.addWidget(self.ProgressBar, 0, 0, 1, 1)
|
self.gridLayout_3.addWidget(self.ProgressBar, 0, 0, 1, 1)
|
||||||
|
|
||||||
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)
|
||||||
@ -220,7 +223,7 @@ class Ui_BibleImportDialog(object):
|
|||||||
self.ImportToolBox.setItemText(self.ImportToolBox.indexOf(self.FileImportPage), QtGui.QApplication.translate("BibleImportDialog", "File Import Page", None, QtGui.QApplication.UnicodeUTF8))
|
self.ImportToolBox.setItemText(self.ImportToolBox.indexOf(self.FileImportPage), QtGui.QApplication.translate("BibleImportDialog", "File Import Page", None, QtGui.QApplication.UnicodeUTF8))
|
||||||
self.OptionsGroupBox.setTitle(QtGui.QApplication.translate("BibleImportDialog", "Download Options", None, QtGui.QApplication.UnicodeUTF8))
|
self.OptionsGroupBox.setTitle(QtGui.QApplication.translate("BibleImportDialog", "Download Options", None, QtGui.QApplication.UnicodeUTF8))
|
||||||
self.LocationLabel.setText(QtGui.QApplication.translate("BibleImportDialog", "Location:", None, QtGui.QApplication.UnicodeUTF8))
|
self.LocationLabel.setText(QtGui.QApplication.translate("BibleImportDialog", "Location:", None, QtGui.QApplication.UnicodeUTF8))
|
||||||
self.LocationComboBox.setItemText(1, QtGui.QApplication.translate("BibleImportDialog", "CrossWire", None, QtGui.QApplication.UnicodeUTF8))
|
self.LocationComboBox.setItemText(1, QtGui.QApplication.translate("BibleImportDialog", "Crosswalk", None, QtGui.QApplication.UnicodeUTF8))
|
||||||
self.TypeLabel.setText(QtGui.QApplication.translate("BibleImportDialog", "Type:", None, QtGui.QApplication.UnicodeUTF8))
|
self.TypeLabel.setText(QtGui.QApplication.translate("BibleImportDialog", "Type:", None, QtGui.QApplication.UnicodeUTF8))
|
||||||
self.TypeComboBox.setItemText(1, QtGui.QApplication.translate("BibleImportDialog", "Download As Needed", None, QtGui.QApplication.UnicodeUTF8))
|
self.TypeComboBox.setItemText(1, QtGui.QApplication.translate("BibleImportDialog", "Download As Needed", None, QtGui.QApplication.UnicodeUTF8))
|
||||||
self.BibleLabel.setText(QtGui.QApplication.translate("BibleImportDialog", "Bible:", None, QtGui.QApplication.UnicodeUTF8))
|
self.BibleLabel.setText(QtGui.QApplication.translate("BibleImportDialog", "Bible:", None, QtGui.QApplication.UnicodeUTF8))
|
||||||
@ -237,4 +240,3 @@ class Ui_BibleImportDialog(object):
|
|||||||
self.PermisionLabel.setText(QtGui.QApplication.translate("BibleImportDialog", "Permission:", None, QtGui.QApplication.UnicodeUTF8))
|
self.PermisionLabel.setText(QtGui.QApplication.translate("BibleImportDialog", "Permission:", None, QtGui.QApplication.UnicodeUTF8))
|
||||||
self.ProgressGroupBox.setTitle(QtGui.QApplication.translate("BibleImportDialog", "Import Progress", None, QtGui.QApplication.UnicodeUTF8))
|
self.ProgressGroupBox.setTitle(QtGui.QApplication.translate("BibleImportDialog", "Import Progress", None, QtGui.QApplication.UnicodeUTF8))
|
||||||
self.ProgressBar.setFormat(QtGui.QApplication.translate("BibleImportDialog", "%p", None, QtGui.QApplication.UnicodeUTF8))
|
self.ProgressBar.setFormat(QtGui.QApplication.translate("BibleImportDialog", "%p", None, QtGui.QApplication.UnicodeUTF8))
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ import sys
|
|||||||
import os, os.path
|
import os, os.path
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
import logging
|
||||||
|
|
||||||
from openlp.core.resources import *
|
from openlp.core.resources import *
|
||||||
|
|
||||||
@ -18,6 +19,9 @@ from bibleimportdialog import Ui_BibleImportDialog
|
|||||||
from openlp.core.lib import PluginUtils
|
from openlp.core.lib import PluginUtils
|
||||||
|
|
||||||
class BibleImportForm(QDialog, Ui_BibleImportDialog, PluginUtils):
|
class BibleImportForm(QDialog, Ui_BibleImportDialog, PluginUtils):
|
||||||
|
global log
|
||||||
|
log=logging.getLogger("BibleImportForm")
|
||||||
|
log.info("BibleImportForm loaded")
|
||||||
"""
|
"""
|
||||||
Class documentation goes here.
|
Class documentation goes here.
|
||||||
"""
|
"""
|
||||||
@ -29,71 +33,105 @@ class BibleImportForm(QDialog, Ui_BibleImportDialog, PluginUtils):
|
|||||||
self.setupUi(self)
|
self.setupUi(self)
|
||||||
self.biblemanager = biblemanager
|
self.biblemanager = biblemanager
|
||||||
self.config = config
|
self.config = config
|
||||||
|
self.bibletype = None
|
||||||
|
self.barmax = 0
|
||||||
|
|
||||||
|
QtCore.QObject.connect(self.LocationComboBox, QtCore.SIGNAL("activated(int)"), self.onLocationComboBox)
|
||||||
|
QtCore.QObject.connect(self.TypeComboBox, QtCore.SIGNAL("activated(int)"), self.onTypeComboBox)
|
||||||
|
QtCore.QObject.connect(self.BibleComboBox, QtCore.SIGNAL("activated(int)"), self.onBibleComboBox)
|
||||||
|
|
||||||
@pyqtSignature("")
|
@pyqtSignature("")
|
||||||
def on_VersesFileButton_clicked(self):
|
def on_VersesFileButton_clicked(self):
|
||||||
filename = QtGui.QFileDialog.getOpenFileName(self, 'Open file',self._get_last_dir())
|
filename = QtGui.QFileDialog.getOpenFileName(self, 'Open file',self._get_last_dir())
|
||||||
self.VerseLocationEdit.setText(filename)
|
self.VerseLocationEdit.setText(filename)
|
||||||
self._save_last_directory(filename)
|
self._save_last_directory(filename)
|
||||||
|
self.setCSV()
|
||||||
|
|
||||||
@pyqtSignature("")
|
@pyqtSignature("")
|
||||||
def on_BooksFileButton_clicked(self):
|
def on_BooksFileButton_clicked(self):
|
||||||
filename = QtGui.QFileDialog.getOpenFileName(self, 'Open file',self._get_last_dir())
|
filename = QtGui.QFileDialog.getOpenFileName(self, 'Open file',self._get_last_dir())
|
||||||
self.BooksLocationEdit.setText(filename)
|
self.BooksLocationEdit.setText(filename)
|
||||||
self._save_last_directory(filename)
|
self._save_last_directory(filename)
|
||||||
|
self.setCSV()
|
||||||
|
|
||||||
@pyqtSignature("")
|
@pyqtSignature("")
|
||||||
def on_OsisFileButton_clicked(self):
|
def on_OsisFileButton_clicked(self):
|
||||||
filename = QtGui.QFileDialog.getOpenFileName(self, 'Open file',self._get_last_dir())
|
filename = QtGui.QFileDialog.getOpenFileName(self, 'Open file',self._get_last_dir())
|
||||||
self.OSISLocationEdit.setText(filename)
|
self.OSISLocationEdit.setText(filename)
|
||||||
self._save_last_directory(filename)
|
self._save_last_directory(filename)
|
||||||
|
self.setOSIS()
|
||||||
|
|
||||||
def on_OSISLocationEdit_lostFocus(self):
|
def on_OSISLocationEdit_lostFocus(self):
|
||||||
if len(self.OSISLocationEdit.displayText() ) > 1:
|
if len(self.OSISLocationEdit.displayText() ) > 0:
|
||||||
self.BooksLocationEdit.setReadOnly(True)
|
self.setOSIS()
|
||||||
self.VerseLocationEdit.setReadOnly(True)
|
|
||||||
else:
|
else:
|
||||||
self.BooksLocationEdit.setReadOnly(False)
|
if self.bibletype == "OSIS": # Was OSIS and is not any more stops lostFocus running mad
|
||||||
self.VerseLocationEdit.setReadOnly(False)
|
self.bibletype = None
|
||||||
|
self.freeAll()
|
||||||
|
|
||||||
def on_BooksLocationEdit_lostFocus(self):
|
def on_BooksLocationEdit_lostFocus(self):
|
||||||
if len(self.BooksLocationEdit.displayText()) > 1 or len(self.VerseLocationEdit.displayText()) > 1:
|
self._checkcsv()
|
||||||
self.OSISLocationEdit.setReadOnly(True)
|
|
||||||
else:
|
|
||||||
self.OSISLocationEdit.setReadOnly(False)
|
|
||||||
|
|
||||||
def on_VerseLocationEdit_lostFocus(self):
|
def on_VerseLocationEdit_lostFocus(self):
|
||||||
if len(self.BooksLocationEdit.displayText()) > 1 or len(self.VerseLocationEdit.displayText()) > 1:
|
self._checkcsv()
|
||||||
self.OSISLocationEdit.setReadOnly(True)
|
|
||||||
|
def _checkcsv(self):
|
||||||
|
if len(self.BooksLocationEdit.displayText()) > 0 or len(self.VerseLocationEdit.displayText()) > 0:
|
||||||
|
self.setCSV()
|
||||||
else:
|
else:
|
||||||
self.OSISLocationEdit.setReadOnly(False)
|
if self.bibletype == "CVS": # Was CSV and is not any more stops lostFocus running mad
|
||||||
|
self.bibletype = None
|
||||||
|
self.freeAll()
|
||||||
|
|
||||||
|
def onLocationComboBox(self):
|
||||||
|
self._checkhttp()
|
||||||
|
|
||||||
|
def onTypeComboBox(self):
|
||||||
|
self._checkhttp()
|
||||||
|
|
||||||
|
def onBibleComboBox(self):
|
||||||
|
self._checkhttp()
|
||||||
|
|
||||||
|
def _checkhttp(self):
|
||||||
|
if len(self.LocationComboBox.currentText()) > 0 or \
|
||||||
|
len(self.TypeComboBox.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 on_CopyrightEdit_lostFocus(self):
|
||||||
self.validate()
|
A =1
|
||||||
|
|
||||||
def on_VersionNameEdit_lostFocus(self):
|
def on_VersionNameEdit_lostFocus(self):
|
||||||
self.validate()
|
A =1
|
||||||
|
|
||||||
def on_PermisionEdit_lostFocus(self):
|
def on_PermisionEdit_lostFocus(self):
|
||||||
self.validate()
|
A =1
|
||||||
|
|
||||||
def on_BibleNameEdit_lostFocus(self):
|
def on_BibleNameEdit_lostFocus(self):
|
||||||
self.validate()
|
A =1
|
||||||
|
|
||||||
def on_BibleImportButtonBox_clicked(self,button):
|
def on_BibleImportButtonBox_clicked(self,button):
|
||||||
|
log.debug("BibleImportButtonBox %s , %s", button.text() , self.bibletype)
|
||||||
if button.text() == "Save":
|
if button.text() == "Save":
|
||||||
if self.biblemanager != None:
|
if self.biblemanager != None:
|
||||||
|
if not self.bibletype == None:
|
||||||
self.MessageLabel.setText("Import Started")
|
self.MessageLabel.setText("Import Started")
|
||||||
self.ProgressBar.setValue(1)
|
self.ProgressBar.setValue(1)
|
||||||
self.progress = 0
|
self.progress = 0
|
||||||
self.biblemanager.process_dialog(self)
|
self.biblemanager.process_dialog(self)
|
||||||
self.biblemanager.register_osis_file_bible(str(self.BibleNameEdit.displayText()), self.OSISLocationEdit.displayText())
|
self._import_bible()
|
||||||
self.biblemanager.save_meta_data(str(self.BibleNameEdit.displayText()), str(self.VersionNameEdit.displayText()), str(self.CopyrightEdit.displayText()), str(self.PermisionEdit.displayText()))
|
|
||||||
self.MessageLabel.setText("Import Complete")
|
self.MessageLabel.setText("Import Complete")
|
||||||
|
self.ProgressBar.setValue(self.barmax)
|
||||||
|
self.update()
|
||||||
elif button.text() == "Cancel":
|
elif button.text() == "Cancel":
|
||||||
self.close()
|
self.close()
|
||||||
|
|
||||||
def setMax(self, max):
|
def setMax(self, max):
|
||||||
|
self.barmax = max
|
||||||
self.ProgressBar.setMaximum(max)
|
self.ProgressBar.setMaximum(max)
|
||||||
|
|
||||||
def incrementBar(self, text = None):
|
def incrementBar(self, text = None):
|
||||||
@ -105,20 +143,76 @@ class BibleImportForm(QDialog, Ui_BibleImportDialog, PluginUtils):
|
|||||||
self.ProgressBar.setValue(self.progress)
|
self.ProgressBar.setValue(self.progress)
|
||||||
self.update()
|
self.update()
|
||||||
|
|
||||||
def validate(self):
|
def _import_bible(self):
|
||||||
valid = False
|
if self.bibletype == "OSIS":
|
||||||
validcount = 0
|
self.biblemanager.register_osis_file_bible(str(self.BibleNameEdit.displayText()), self.OSISLocationEdit.displayText())
|
||||||
if len(self.BibleNameEdit.displayText()) > 0:
|
elif self.bibletype == "CSV":
|
||||||
validcount += 1
|
self.biblemanager.register_csv_file_bible(str(self.BibleNameEdit.displayText()), self.OSISLocationEdit.displayText())
|
||||||
if len(self.OSISLocationEdit.displayText()) > 0:
|
else:
|
||||||
validcount += 1
|
self.setMax(1) # set a value as it will not be needed
|
||||||
if len(self.BooksLocationEdit.displayText()) > 0:
|
bname = self.biblemanager.register_http_bible(str(self.BibleComboBox.currentText()),str(self.LocationComboBox.currentText()) )
|
||||||
validcount += 1
|
self.BibleNameEdit.setText(bname)
|
||||||
if len(self.VersionNameEdit.displayText()) > 0 and len(self.CopyrightEdit.displayText()) > 0 and len(self.PermisionEdit.displayText()) > 0:
|
|
||||||
valid = True
|
|
||||||
# if validcount == 2 and valid:
|
|
||||||
# self.BibleImportButtonBox.addButton(self.savebutton, QtGui.QDialogButtonBox.AcceptRole) # hide the save button tile screen is valid
|
|
||||||
# else:
|
|
||||||
# self.BibleImportButtonBox.removeButton(self.savebutton) # hide the save button tile screen is valid
|
|
||||||
|
|
||||||
|
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.freeAll() # free the scree state restrictions
|
||||||
|
self.resetAll() # reset all the screen fields
|
||||||
|
|
||||||
|
def blockCSV(self):
|
||||||
|
self.BooksLocationEdit.setReadOnly(True)
|
||||||
|
self.VerseLocationEdit.setReadOnly(True)
|
||||||
|
self.BooksFileButton.setEnabled(False)
|
||||||
|
self.VersesFileButton.setEnabled(False)
|
||||||
|
|
||||||
|
def setCSV(self):
|
||||||
|
self.bibletype = "CVS"
|
||||||
|
self.BooksLocationEdit.setReadOnly(False)
|
||||||
|
self.VerseLocationEdit.setReadOnly(False)
|
||||||
|
self.BooksFileButton.setEnabled(True)
|
||||||
|
self.VersesFileButton.setEnabled(True)
|
||||||
|
self.blockOSIS()
|
||||||
|
self.blockHTTP()
|
||||||
|
|
||||||
|
def setOSIS(self):
|
||||||
|
self.bibletype = "OSIS"
|
||||||
|
self.OSISLocationEdit.setReadOnly(False)
|
||||||
|
self.OsisFileButton.setEnabled(True)
|
||||||
|
self.blockCSV()
|
||||||
|
self.blockHTTP()
|
||||||
|
|
||||||
|
def blockOSIS(self):
|
||||||
|
self.OSISLocationEdit.setReadOnly(True)
|
||||||
|
self.OsisFileButton.setEnabled(False)
|
||||||
|
|
||||||
|
def setHTTP(self):
|
||||||
|
self.bibletype = "HTTP"
|
||||||
|
self.LocationComboBox.setEnabled(True)
|
||||||
|
self.BibleComboBox.setEnabled(True)
|
||||||
|
self.TypeComboBox.setEnabled(True)
|
||||||
|
self.blockCSV()
|
||||||
|
self.blockOSIS()
|
||||||
|
|
||||||
|
def blockHTTP(self):
|
||||||
|
self.LocationComboBox.setEnabled(False)
|
||||||
|
self.BibleComboBox.setEnabled(False)
|
||||||
|
self.TypeComboBox.setEnabled(False)
|
||||||
|
|
||||||
|
def freeAll(self):
|
||||||
|
if self.bibletype == None: # only reset if no bible type set.
|
||||||
|
self.BooksLocationEdit.setReadOnly(False)
|
||||||
|
self.VerseLocationEdit.setReadOnly(False)
|
||||||
|
self.BooksFileButton.setEnabled(True)
|
||||||
|
self.VersesFileButton.setEnabled(True)
|
||||||
|
self.OSISLocationEdit.setReadOnly(False)
|
||||||
|
self.OsisFileButton.setEnabled(True)
|
||||||
|
self.LocationComboBox.setEnabled(True)
|
||||||
|
self.BibleComboBox.setEnabled(True)
|
||||||
|
self.TypeComboBox.setEnabled(True)
|
||||||
|
|
||||||
|
def resetAll(self):
|
||||||
|
self.BooksLocationEdit.setText("")
|
||||||
|
self.VerseLocationEdit.setText("")
|
||||||
|
self.OSISLocationEdit.setText("")
|
||||||
|
self.LocationComboBox.setCurrentIndex(0)
|
||||||
|
self.BibleComboBox.setCurrentIndex(0)
|
||||||
|
self.TypeComboBox.setCurrentIndex(0)
|
||||||
|
@ -63,14 +63,10 @@ class BibleDBImpl(BibleCommon):
|
|||||||
|
|
||||||
def create_tables(self):
|
def create_tables(self):
|
||||||
log.debug( "createTables")
|
log.debug( "createTables")
|
||||||
if os.path.exists(self.biblefile): # delete bible file and set it up again
|
|
||||||
os.remove(self.biblefile)
|
|
||||||
#meta_table.create()
|
|
||||||
#testament_table.create()
|
|
||||||
#book_table.create()
|
|
||||||
#verse_table.create()
|
|
||||||
self.save_meta("dbversion", "2")
|
self.save_meta("dbversion", "2")
|
||||||
self._load_testaments()
|
self._load_testament("Old Testament")
|
||||||
|
self._load_testament("Apocrypha")
|
||||||
|
self._load_testament("New Testament")
|
||||||
|
|
||||||
def add_verse(self, bookid, chap, vse, text):
|
def add_verse(self, bookid, chap, vse, text):
|
||||||
log.debug( "add_verse %s,%s,%s,%s", bookid, chap, vse, text)
|
log.debug( "add_verse %s,%s,%s,%s", bookid, chap, vse, text)
|
||||||
@ -97,12 +93,12 @@ class BibleDBImpl(BibleCommon):
|
|||||||
session.add(verse)
|
session.add(verse)
|
||||||
session.commit()
|
session.commit()
|
||||||
|
|
||||||
def create_book(self, bookid, bookname, bookabbrev):
|
def create_book(self, bookname, bookabbrev):
|
||||||
log.debug( "create_book %s,%s,%s", bookid, bookname, bookabbrev)
|
log.debug( "create_book %s,%s", bookname, bookabbrev)
|
||||||
metadata.bind.echo = False
|
metadata.bind.echo = False
|
||||||
session = self.session()
|
session = self.session()
|
||||||
book = Book()
|
book = Book()
|
||||||
book.tetsament_id = 1
|
book.testament_id = 1
|
||||||
book.name = bookname
|
book.name = bookname
|
||||||
book.abbreviation = bookabbrev
|
book.abbreviation = bookabbrev
|
||||||
session.add(book)
|
session.add(book)
|
||||||
@ -131,16 +127,12 @@ class BibleDBImpl(BibleCommon):
|
|||||||
except:
|
except:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def _load_testaments(self):
|
def _load_testament(self, testament):
|
||||||
log.debug("load_testaments")
|
log.debug("load_testaments %s", testament)
|
||||||
metadata.bind.echo = False
|
metadata.bind.echo = False
|
||||||
session = self.session()
|
session = self.session()
|
||||||
test = ONTestament()
|
test = ONTestament()
|
||||||
test.name = "Old Testament"
|
test.name = testament
|
||||||
session.add(test)
|
|
||||||
test.name = "New Testament"
|
|
||||||
session.add(test)
|
|
||||||
test.name = "Apocrypha"
|
|
||||||
session.add(test)
|
session.add(test)
|
||||||
session.commit()
|
session.commit()
|
||||||
|
|
||||||
@ -164,11 +156,12 @@ class BibleDBImpl(BibleCommon):
|
|||||||
log.debug( "get_bible_book %s", bookname)
|
log.debug( "get_bible_book %s", bookname)
|
||||||
return self.session.query(Book).filter_by(name = bookname).first()
|
return self.session.query(Book).filter_by(name = bookname).first()
|
||||||
|
|
||||||
def get_bible_chapter(self, bookname, chapter):
|
def get_bible_chapter(self, id, chapter):
|
||||||
log.debug( "get_bible_chapter %s,%s", bookname, chapter )
|
log.debug( "get_bible_chapter %s,%s", id, chapter )
|
||||||
metadata.bind.echo = False
|
metadata.bind.echo = False
|
||||||
s = text (""" select book.name FROM verse,book where verse.book_id == book.id AND verse.chapter == :c and book.name == :b """)
|
#s = text (""" select book.name FROM verse,book where verse.book_id == book.id AND verse.chapter == :c and book.name == :b """)
|
||||||
return self.db.execute(s, c=chapter, b=bookname).fetchone()
|
return self.session.query(Verse).filter_by(chapter = chapter ).filter_by(book_id = id).first()
|
||||||
|
#return self.db.execute(s, c=chapter, b=bookname).fetchone()
|
||||||
|
|
||||||
def get_bible_text(self, bookname, chapter, sverse, everse):
|
def get_bible_text(self, bookname, chapter, sverse, everse):
|
||||||
log.debug( "get_bible_text %s,%s,%s,%s ", bookname, chapter, sverse, everse)
|
log.debug( "get_bible_text %s,%s,%s,%s ", bookname, chapter, sverse, everse)
|
||||||
|
@ -169,7 +169,7 @@ class BibleHTTPImpl():
|
|||||||
log.debug( "get_bible_chapter %s,%s,%s,%s", version, bookid, bookname, chapter)
|
log.debug( "get_bible_chapter %s,%s,%s,%s", version, bookid, bookname, chapter)
|
||||||
log.debug("biblesource = %s", self.biblesource)
|
log.debug("biblesource = %s", self.biblesource)
|
||||||
try:
|
try:
|
||||||
if self.biblesource == 'Crosswalk':
|
if self.biblesource.lower() == 'crosswalk':
|
||||||
ev = CWExtract(self.proxyurl)
|
ev = CWExtract(self.proxyurl)
|
||||||
else:
|
else:
|
||||||
ev = BGExtract(self.proxyurl)
|
ev = BGExtract(self.proxyurl)
|
||||||
|
@ -32,14 +32,12 @@ class BibleCommon:
|
|||||||
"""
|
"""
|
||||||
def _get_web_text(self, urlstring, proxyurl):
|
def _get_web_text(self, urlstring, proxyurl):
|
||||||
log.debug( "get_web_text %s %s", proxyurl, urlstring)
|
log.debug( "get_web_text %s %s", proxyurl, urlstring)
|
||||||
|
if not proxyurl == None:
|
||||||
if proxyurl != "" or len(proxyurl) > 0 :
|
|
||||||
print "ProxyUrl " , proxyurl + " " + str(len(proxyurl))
|
print "ProxyUrl " , proxyurl + " " + str(len(proxyurl))
|
||||||
proxy_support = urllib2.ProxyHandler({'http': self.proxyurl})
|
proxy_support = urllib2.ProxyHandler({'http': self.proxyurl})
|
||||||
http_support = urllib2.HTTPHandler()
|
http_support = urllib2.HTTPHandler()
|
||||||
opener= urllib2.build_opener(proxy_support, http_support)
|
opener= urllib2.build_opener(proxy_support, http_support)
|
||||||
urllib2.install_opener(opener)
|
urllib2.install_opener(opener)
|
||||||
|
|
||||||
xml_string = ""
|
xml_string = ""
|
||||||
req = urllib2.Request(urlstring)
|
req = urllib2.Request(urlstring)
|
||||||
req.add_header('User-Agent', 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)')
|
req.add_header('User-Agent', 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)')
|
||||||
|
@ -61,7 +61,7 @@ class BibleManager():
|
|||||||
biblesource = self.bibleDBCache[bname].get_meta("WEB") # look to see if lazy load bible exists and get create getter.
|
biblesource = self.bibleDBCache[bname].get_meta("WEB") # look to see if lazy load bible exists and get create getter.
|
||||||
if biblesource:
|
if biblesource:
|
||||||
nhttp = BibleHTTPImpl()
|
nhttp = BibleHTTPImpl()
|
||||||
nhttp.set_bible_source(biblesource) # tell The Server where to get the verses from.
|
nhttp.set_bible_source(biblesource.value) # tell The Server where to get the verses from.
|
||||||
self.bibleHTTPCache[bname] = nhttp
|
self.bibleHTTPCache[bname] = nhttp
|
||||||
proxy = self.bibleDBCache[bname].get_meta("proxy") # look to see if lazy load bible exists and get create getter.
|
proxy = self.bibleDBCache[bname].get_meta("proxy") # look to see if lazy load bible exists and get create getter.
|
||||||
nhttp.set_proxy(proxy) # tell The Server where to get the verses from.
|
nhttp.set_proxy(proxy) # tell The Server where to get the verses from.
|
||||||
@ -79,7 +79,7 @@ class BibleManager():
|
|||||||
Return a list of bibles from a given URL.
|
Return a list of bibles from a given URL.
|
||||||
The selected Bible can then be registered and LazyLoaded into a database
|
The selected Bible can then be registered and LazyLoaded into a database
|
||||||
"""
|
"""
|
||||||
log.debug( "register_HTTP_bible %s,%s,%s,%s,%s", biblename, biblesource, proxyurl, proxyid, proxypass, mode)
|
log.debug( "register_HTTP_bible %s,%s,%s,%s,%s,%s", biblename, biblesource, proxyurl, proxyid, proxypass, mode)
|
||||||
if self._is_new_bible(biblename):
|
if self._is_new_bible(biblename):
|
||||||
nbible = BibleDBImpl(self.biblePath, biblename, self.config) # Create new Bible
|
nbible = BibleDBImpl(self.biblePath, biblename, self.config) # Create new Bible
|
||||||
nbible.create_tables() # Create Database
|
nbible.create_tables() # Create Database
|
||||||
@ -96,6 +96,7 @@ class BibleManager():
|
|||||||
nbible.save_meta("proxyid", proxyid) # store the proxy userid
|
nbible.save_meta("proxyid", proxyid) # store the proxy userid
|
||||||
if proxypass != None:
|
if proxypass != None:
|
||||||
nbible.save_meta("proxypass", proxypass) # store the proxy password
|
nbible.save_meta("proxypass", proxypass) # store the proxy password
|
||||||
|
return biblename
|
||||||
|
|
||||||
|
|
||||||
def register_cvs_file_bible(self, biblename, booksfile, versefile):
|
def register_cvs_file_bible(self, biblename, booksfile, versefile):
|
||||||
@ -126,6 +127,7 @@ class BibleManager():
|
|||||||
bcsv.load_data(osisfile, self.dialogobject)
|
bcsv.load_data(osisfile, self.dialogobject)
|
||||||
|
|
||||||
def get_bibles(self, mode="full"):
|
def get_bibles(self, mode="full"):
|
||||||
|
log.debug("get_bibles")
|
||||||
"""
|
"""
|
||||||
Returns a list of Books of the bible
|
Returns a list of Books of the bible
|
||||||
Mode "Full" - Returns all the bibles for the Queck seearch
|
Mode "Full" - Returns all the bibles for the Queck seearch
|
||||||
@ -195,18 +197,24 @@ class BibleManager():
|
|||||||
Rest can be guessed at !
|
Rest can be guessed at !
|
||||||
"""
|
"""
|
||||||
text = []
|
text = []
|
||||||
#log.debug( self.bibleDBCache)
|
bookabbrev = ""
|
||||||
#log.debug( self.bibleHTTPCache)
|
|
||||||
log.debug( "get_verse_text %s,%s,%s,%s,%s,%s", bible, bookname, schapter, echapter, sverse, everse)
|
log.debug( "get_verse_text %s,%s,%s,%s,%s,%s", bible, bookname, schapter, echapter, sverse, everse)
|
||||||
# bookid = self.booksOfBible[bookname] # convert to id ie Genesis --> 1 Revelation --> 73
|
if not self.bibleHTTPCache[bible] == None:
|
||||||
# # SORT OUT BOOKNAME BOOK ID.
|
book= self.bibleDBCache[bible].get_bible_book(bookname) # check to see if book/chapter exists
|
||||||
# # NAME COMES IN TO ID AND BACK TO NAME ?
|
if book == None:
|
||||||
# c = self.bibleDBCache[bible].getBibleChapter(bookname, chapter) # check to see if book/chapter exists
|
book = self.bibleDBCache[bible].create_book(bookname, bookabbrev)
|
||||||
# bookabbrev = ""
|
for chapter in range(schapter, echapter+1):
|
||||||
|
print chapter
|
||||||
|
v = self.bibleDBCache[bible].get_bible_chapter(book.id, chapter)
|
||||||
|
if v == None:
|
||||||
|
chaptlist = self.bibleHTTPCache[bible].get_bible_chapter(bible, book.id, bookname, chapter)
|
||||||
|
self.bibleDBCache[bible].create_chapter(book.id, chapter, chaptlist)
|
||||||
|
|
||||||
|
|
||||||
#log.debug( "Bible Chapter %s", c )
|
#log.debug( "Bible Chapter %s", c )
|
||||||
# if not c:
|
# if not c:
|
||||||
# self._loadBook(bible,bookid, bookname, bookabbrev)
|
# self._loadBook(bible,bookid, bookname, bookabbrev)
|
||||||
# self._loadChapter(bible, bookid,bookname, chapter)
|
# self._loadChapter(bible, bookid,bookname, schapter)
|
||||||
if schapter == echapter:
|
if schapter == echapter:
|
||||||
text = self.bibleDBCache[bible].get_bible_text(bookname, schapter, sverse, everse)
|
text = self.bibleDBCache[bible].get_bible_text(bookname, schapter, sverse, everse)
|
||||||
else:
|
else:
|
||||||
@ -223,6 +231,7 @@ class BibleManager():
|
|||||||
|
|
||||||
txt = self.bibleDBCache[bible].get_bible_text(bookname, i, start, end)
|
txt = self.bibleDBCache[bible].get_bible_text(bookname, i, start, end)
|
||||||
text.extend(txt)
|
text.extend(txt)
|
||||||
|
print text
|
||||||
return text
|
return text
|
||||||
|
|
||||||
def _load_book(self, bible, bookid, bookname, bookabbrev):
|
def _load_book(self, bible, bookid, bookname, bookabbrev):
|
||||||
|
@ -50,8 +50,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>471</width>
|
<width>96</width>
|
||||||
<height>369</height>
|
<height>26</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<attribute name="label">
|
<attribute name="label">
|
||||||
@ -192,7 +192,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>471</width>
|
<width>471</width>
|
||||||
<height>369</height>
|
<height>371</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<attribute name="label">
|
<attribute name="label">
|
||||||
@ -245,7 +245,7 @@
|
|||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>CrossWire</string>
|
<string>Crosswalk</string>
|
||||||
</property>
|
</property>
|
||||||
</item>
|
</item>
|
||||||
</widget>
|
</widget>
|
||||||
|
Loading…
Reference in New Issue
Block a user