From a0800e842fadae43bb2b460d39241052f7c17a05 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 13 Dec 2008 19:42:25 +0000 Subject: [PATCH] Fix OSIS imports and screen refresh issues. Move Langauge file to Resources. bzr-revno: 217 --- openlp/core/lib/plugin.py | 5 +- .../plugins/bibles/forms/bibleimportform.py | 41 +++++++----- openlp/plugins/bibles/lib/bibleOSISimpl.py | 8 +-- openlp/plugins/bibles/lib/biblemanager.py | 9 +-- resources/bibles/osisbooks_en.txt | 66 +++++++++++++++++++ 5 files changed, 101 insertions(+), 28 deletions(-) create mode 100644 resources/bibles/osisbooks_en.txt diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index 0696526f2..6ccb9a0dd 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -131,4 +131,7 @@ class Plugin(object): return self.Name def initalise_ui(self): - return self.Name + """ + Called by the plugin Manager to setup any UI features on creation after the UI has been created, + """ + pass diff --git a/openlp/plugins/bibles/forms/bibleimportform.py b/openlp/plugins/bibles/forms/bibleimportform.py index 9e6b6e96d..5d18ef34a 100644 --- a/openlp/plugins/bibles/forms/bibleimportform.py +++ b/openlp/plugins/bibles/forms/bibleimportform.py @@ -55,10 +55,19 @@ class BibleImportForm(QDialog, Ui_BibleImportDialog): else: self.BooksLocationEdit.setReadOnly(False) self.VerseLocationEdit.setReadOnly(False) - self.validate() def on_BooksLocationEdit_lostFocus(self): - self.validate() + if len(self.BooksLocationEdit.displayText()) > 1 or len(self.VerseLocationEdit.displayText()) > 1: + self.OSISLocationEdit.setReadOnly(True) + else: + self.OSISLocationEdit.setReadOnly(False) + + def on_VerseLocationEdit_lostFocus(self): + if len(self.BooksLocationEdit.displayText()) > 1 or len(self.VerseLocationEdit.displayText()) > 1: + self.OSISLocationEdit.setReadOnly(True) + else: + self.OSISLocationEdit.setReadOnly(False) + def on_CopyrightEdit_lostFocus(self): self.validate() def on_VersionNameEdit_lostFocus(self): @@ -73,12 +82,22 @@ class BibleImportForm(QDialog, Ui_BibleImportDialog): #bipf = BibleImportProgressForm() #bipf.show() if self.biblemanager != None: - self.biblemanager.processDialog(bipf) + self.MessageLabel.setText("Import Started") + self.ProgressBar.setValue(0) + self.progress = 0 + self.biblemanager.processDialog(self) self.biblemanager.registerOSISFileBible(str(self.BibleNameEdit.displayText()), self.OSISLocationEdit.displayText()) + self.MessageLabel.setText("Import Complete") elif button.text() == "Cancel": self.close() + + def setMax(self, max): + self.ProgressBar.setMaximum(max) - + def incrementBar(self): + self.progress +=1 + self.ProgressBar.setValue(self.progress) + self.update() def validate(self): print "validate" @@ -98,17 +117,3 @@ class BibleImportForm(QDialog, Ui_BibleImportDialog): # self.BibleImportButtonBox.removeButton(self.savebutton) # hide the save button tile screen is valid - -class runner(QtGui.QApplication): - - def run(self): - values = ["Genesis","Matthew","Revelation"] - self.bm = BibleManager("/home/timali/.openlp") - self.bim = BibleImportForm() - self.bim.show() - self.processEvents() - sys.exit(app.exec_()) - -if __name__ == '__main__': - app = runner(sys.argv) - app.run() diff --git a/openlp/plugins/bibles/lib/bibleOSISimpl.py b/openlp/plugins/bibles/lib/bibleOSISimpl.py index 6969bb621..173f318b9 100644 --- a/openlp/plugins/bibles/lib/bibleOSISimpl.py +++ b/openlp/plugins/bibles/lib/bibleOSISimpl.py @@ -34,13 +34,11 @@ class BibleOSISImpl(): global log log=logging.getLogger("BibleOSISImpl") log.info("BibleOSISImpl loaded") - def __init__(self, bibledb): + def __init__(self, biblepath, bibledb): self.bibledb = bibledb self.booksOfBible = {} # books of the bible linked to bibleid {osis , name} self.abbrevOfBible = {} # books of the bible linked to bibleid {osis ,Abbrev } - resourcepath=os.path.split(os.path.abspath(__file__))[0] - resourcepath = os.path.join(resourcepath, 'resources') - fbibles=open(resourcepath+"/osisbooks_en.txt", 'r') + fbibles=open(biblepath+"/osisbooks_en.txt", 'r') for line in fbibles: p = line.split(",") self.booksOfBible[p[0]] = p[1].replace('\n', '') @@ -53,7 +51,7 @@ class BibleOSISImpl(): self.bibledb.saveMeta("Permission", "You Have Some") #TODO: need to see if new / old or both testaments - dialogobject.setMax(66) + dialogobject.setMax(65) osis=open(osisfile, 'r') diff --git a/openlp/plugins/bibles/lib/biblemanager.py b/openlp/plugins/bibles/lib/biblemanager.py index fbdf32e3d..f2f986e92 100644 --- a/openlp/plugins/bibles/lib/biblemanager.py +++ b/openlp/plugins/bibles/lib/biblemanager.py @@ -77,7 +77,7 @@ class BibleManager(): """ log.debug( "registerHTTPBible %s,%s,%s,%s,%s", biblename, biblesource, proxyurl, proxyid, proxypass, mode) if self._isNewBible(biblename): - nbible = BibleDBImpl(biblename) # Create new Bible + nbible = BibleDBImpl(self.biblePath, biblename, self.bibleSuffix) # Create new Bible nbible.createTables() # Create Database self.bibleDBCache[biblename] = nbible @@ -101,7 +101,7 @@ class BibleManager(): from scratch. """ if self._isNewBible(biblename): - nbible = BibleDBImpl(biblename) # Create new Bible + nbible = BibleDBImpl(self.biblePath, biblename, self.bibleSuffix) # Create new Bible nbible.createTables() # Create Database self.bibleDBCache[biblename] = nbible # cache the database for use later bcsv = BibleCSVImpl(nbible) # create the loader and pass in the database @@ -113,11 +113,12 @@ class BibleManager(): If the database exists it is deleted and the database is reloaded from scratch. """ + log.debug( "registerOSISFileBible %s , %s", biblename, osisfile) if self._isNewBible(biblename): - nbible = BibleDBImpl(biblename) # Create new Bible + nbible = BibleDBImpl(self.biblePath, biblename, self.bibleSuffix) # Create new Bible nbible.createTables() # Create Database self.bibleDBCache[biblename] = nbible # cache the database for use later - bcsv = BibleOSISImpl(nbible) # create the loader and pass in the database + bcsv = BibleOSISImpl(self.biblePath, nbible) # create the loader and pass in the database bcsv.loadData(osisfile, self.dialogobject) diff --git a/resources/bibles/osisbooks_en.txt b/resources/bibles/osisbooks_en.txt new file mode 100644 index 000000000..2207ee553 --- /dev/null +++ b/resources/bibles/osisbooks_en.txt @@ -0,0 +1,66 @@ +Gen,Genesis,Gen +Exod,Exodus,Exod +Lev,Leviticus,Lev +Num,Numbers,Num +Deut,Deuteronomy,Deut +Josh,Joshua,Josh +Judg,Judges,Judg +Ruth,Ruth,Ruth +1Sam,1 Samual,1Sam +2Sam,2 Samual,2Sam +1Kgs,1 Kings,1Kgs +2Kgs,2 Kings,2Kgs +1Chr,1 Chronicles,1Chr +2Chr,2 Chronicles,2Chr +Ezra,Ezra,Ezra +Neh,Nehemiah,Neh +Esth,Esther,Esth +Job,Job,Job +Ps,Psalms,Ps +Prov,Proverbs,Prov +Eccl,Ecclesiastes,Eccl +Song,Song of Songs,Song +Isa,Isaiah,Isa +Jer,Jeremiah,Jer +Lam,Lamentations,Lam +Ezek,Ezekiel,Ezek +Dan,Daniel,Dan +Hos,Hosea,Hos +Joel,Joel,Joel +Amos,Amos,Amos +Obad,Obad,Obad +Jonah,Jonah,Jonah +Mic,Micah,Mic +Nah,Naham,Nah +Hab,Habakkuk,Hab +Zeph,Zephaniah,Zeph +Hag,Haggai,Hag +Zech,Zechariah,Zech +Mal,Malachi,Mal +Matt,Matthew,Matt +Mark,Mark,Mark +Luke,Luke,Luke +John,John,John +Acts,Acts,Acts +Rom,Romans,Rom +1Cor,1 Corinthans,1Cor +2Cor,2 Corinthans,2Cor +Gal,Galatians,Gal +Eph,Ephesians,Eph +Phil,Philippians,Phil +Col,Colossians,Col +1Thess,1 Thessalonians,1Thess +2Thess,2 Thessalonians,2Thess +1Tim,1 Timothy,1Tim +2Tim,2 Timothy,2Tim +Titus,Titus,Titus +Phlm,Philemon,Phlm +Heb,Hebrews,Heb +Jas,James,Jas +1Pet,1 Peter,1Pet +2Pet,2 Peter,2Pet +1John,1 John,1John +2John,2 John,2John +3John,3 John,3John +Jude,Jude,Jude +Rev,Revelation,Rev