forked from openlp/openlp
Continue fixing up the bible plugin screen interactions.
Data extracted from Database now! Improve bible plugin logging bzr-revno: 197
This commit is contained in:
parent
aed4a2763b
commit
f0f73a16ce
@ -20,6 +20,8 @@ Place, Suite 330, Boston, MA 02111-1307 USA
|
|||||||
|
|
||||||
from openlp.core.lib import PluginConfig
|
from openlp.core.lib import PluginConfig
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
class Plugin(object):
|
class Plugin(object):
|
||||||
"""
|
"""
|
||||||
Base class for openlp plugins to inherit from.
|
Base class for openlp plugins to inherit from.
|
||||||
@ -55,7 +57,7 @@ class Plugin(object):
|
|||||||
* handleEvent(event)
|
* handleEvent(event)
|
||||||
A method use to handle events, given an Event object.
|
A method use to handle events, given an Event object.
|
||||||
"""
|
"""
|
||||||
|
global log
|
||||||
def __init__(self, name=None, version=None):
|
def __init__(self, name=None, version=None):
|
||||||
"""
|
"""
|
||||||
This is the constructor for the plugin object. This provides an easy
|
This is the constructor for the plugin object. This provides an easy
|
||||||
|
@ -25,14 +25,18 @@ from openlp.core.lib import Plugin, MediaManagerItem
|
|||||||
from openlp.plugins.bibles.lib.biblemanager import BibleManager
|
from openlp.plugins.bibles.lib.biblemanager import BibleManager
|
||||||
from openlp.plugins.bibles.forms.bibleimportform import BibleImportForm
|
from openlp.plugins.bibles.forms.bibleimportform import BibleImportForm
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
class BiblePlugin(Plugin):
|
class BiblePlugin(Plugin):
|
||||||
|
global log
|
||||||
|
log=logging.getLogger("BiblePlugin")
|
||||||
|
log.info("Bible Plugin loaded")
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
# Call the parent constructor
|
# Call the parent constructor
|
||||||
Plugin.__init__(self, 'Bible', '1.9.0')
|
Plugin.__init__(self, 'Bible', '1.9.0')
|
||||||
self.Weight = -9
|
self.Weight = -9
|
||||||
#Register the bible Manager
|
#Register the bible Manager
|
||||||
self.biblemanager = BibleManager(self.config.get_data_path())
|
self.biblemanager = BibleManager(self.config)
|
||||||
self.textsearch = True
|
|
||||||
|
|
||||||
def getMediaManagerItem(self):
|
def getMediaManagerItem(self):
|
||||||
# Create the plugin icon
|
# Create the plugin icon
|
||||||
@ -164,18 +168,21 @@ class BiblePlugin(Plugin):
|
|||||||
#QtCore.QObject.connect(self.QuickTab, QtCore.SIGNAL("triggered()"), self.onQuickTabClick)
|
#QtCore.QObject.connect(self.QuickTab, QtCore.SIGNAL("triggered()"), self.onQuickTabClick)
|
||||||
QtCore.QObject.connect( self.SearchTabWidget, QtCore.SIGNAL("currentChanged ( QWidget * )" ), self.onQuickTabClick)
|
QtCore.QObject.connect( self.SearchTabWidget, QtCore.SIGNAL("currentChanged ( QWidget * )" ), self.onQuickTabClick)
|
||||||
QtCore.QObject.connect(self.AdvancedVersionComboBox, QtCore.SIGNAL("activated(int)"), self.onAdvancedVersionComboBox)
|
QtCore.QObject.connect(self.AdvancedVersionComboBox, QtCore.SIGNAL("activated(int)"), self.onAdvancedVersionComboBox)
|
||||||
|
QtCore.QObject.connect(self.AdvancedBookComboBox, QtCore.SIGNAL("activated(int)"), self.onAdvancedBookComboBox)
|
||||||
|
QtCore.QObject.connect(self.AdvancedFromChapter, QtCore.SIGNAL("activated(int)"), self.onAdvancedFromChapter)
|
||||||
|
QtCore.QObject.connect(self.AdvancedFromVerse, QtCore.SIGNAL("activated(int)"), self.onAdvancedFromVerse)
|
||||||
|
QtCore.QObject.connect(self.AdvancedToChapter, QtCore.SIGNAL("activated(int)"), self.onAdvancedToChapter)
|
||||||
|
|
||||||
|
self._initialiseForm()
|
||||||
self._initialiseform()
|
|
||||||
|
|
||||||
return self.MediaManagerItem
|
return self.MediaManagerItem
|
||||||
|
|
||||||
def onAdvancedVersionComboBox(self):
|
def onAdvancedVersionComboBox(self):
|
||||||
|
self._initialiseBibleAdvanced(str(self.AdvancedVersionComboBox.currentText())) # restet the bible info
|
||||||
|
|
||||||
|
def onAdvancedBookComboBox(self):
|
||||||
print self.AdvancedVersionComboBox.currentText()
|
print self.AdvancedVersionComboBox.currentText()
|
||||||
books = self.biblemanager.getBibleBooks(str(self.AdvancedVersionComboBox.currentText()))
|
self._initialiseBibleAdvanced(str(self.AdvancedVersionComboBox.currentText())) # restet the bible info
|
||||||
self.AdvancedBookComboBox.clear()
|
|
||||||
for b in books:
|
|
||||||
self.AdvancedBookComboBox.addItem(b[0])
|
|
||||||
|
|
||||||
def onQuickTabClick(self):
|
def onQuickTabClick(self):
|
||||||
print "onQuickTabClick"
|
print "onQuickTabClick"
|
||||||
@ -197,20 +204,75 @@ class BiblePlugin(Plugin):
|
|||||||
def onBibleAddClick(self):
|
def onBibleAddClick(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def _initialiseform(self):
|
def _initialiseForm(self):
|
||||||
bibles = self.biblemanager.getBibles()
|
bibles = self.biblemanager.getBibles()
|
||||||
for b in bibles:
|
first = True
|
||||||
|
for b in bibles: # load bibles into the combo boxes
|
||||||
self.QuickVersionComboBox.addItem(b)
|
self.QuickVersionComboBox.addItem(b)
|
||||||
self.AdvancedVersionComboBox.addItem(b)
|
self.AdvancedVersionComboBox.addItem(b)
|
||||||
|
if first:
|
||||||
|
first = False
|
||||||
|
self._initialiseBible(b) # use the fist bible as the trigger
|
||||||
|
|
||||||
|
|
||||||
|
def _initialiseBible(self, bible):
|
||||||
|
log.debug("_initialiseBible %s ", bible)
|
||||||
|
self._initialiseBibleQuick(bible)
|
||||||
|
self._initialiseBibleAdvanced(bible)
|
||||||
|
|
||||||
for i in range(1, 10):
|
def _initialiseBibleAdvanced(self, bible):
|
||||||
self.AdvancedFromChapter.addItem(str(i))
|
log.debug("_initialiseBibleAdvanced %s ", bible)
|
||||||
for i in range(1, 20):
|
currentBook = str(self.AdvancedBookComboBox.currentText())
|
||||||
self.AdvancedToChapter.addItem(str(i))
|
cf = self.biblemanager.getBookChapterCount(bible, currentBook)[0]
|
||||||
for i in range(1, 30):
|
log.debug("Book change bible %s book %s ChapterCount %s", bible, currentBook, cf)
|
||||||
self.AdvancedFromVerse.addItem(str(i))
|
if cf == None: # Only change the search details if the book is missing from the new bible
|
||||||
for i in range(1, 40):
|
books = self.biblemanager.getBibleBooks(str(self.AdvancedVersionComboBox.currentText()))
|
||||||
self.AdvancedToVerse.addItem(str(i))
|
self.AdvancedBookComboBox.clear()
|
||||||
|
first = True
|
||||||
|
for b in books:
|
||||||
|
self.AdvancedBookComboBox.addItem(b[0])
|
||||||
|
if first:
|
||||||
|
book = b
|
||||||
|
first = False
|
||||||
|
self._initialiseChapterVerse(bible, b[0])
|
||||||
|
|
||||||
|
def _initialiseChapterVerse(self, bible, book):
|
||||||
|
log.debug("_initialiseChapterVerse %s , %s", bible, book)
|
||||||
|
self.chaptersfrom = self.biblemanager.getBookChapterCount(bible, book)[0]
|
||||||
|
self.verses = self.biblemanager.getBookVerseCount(bible, book, 1)[0]
|
||||||
|
self._adjustComboBox(1, self.chaptersfrom, self.AdvancedFromChapter)
|
||||||
|
self._adjustComboBox(1, self.chaptersfrom, self.AdvancedToChapter)
|
||||||
|
self._adjustComboBox(1, self.verses, self.AdvancedFromVerse)
|
||||||
|
self._adjustComboBox(1, self.verses, self.AdvancedToVerse)
|
||||||
|
|
||||||
|
def onAdvancedFromChapter(self):
|
||||||
|
bible = str(self.AdvancedVersionComboBox.currentText())
|
||||||
|
book = str(self.AdvancedBookComboBox.currentText())
|
||||||
|
cf = self.AdvancedFromChapter.currentText()
|
||||||
|
self._adjustComboBox(cf, self.chaptersfrom, self.AdvancedToChapter)
|
||||||
|
vse = self.biblemanager.getBookVerseCount(bible, book, int(cf))[0] # get the verse count for new chapter
|
||||||
|
self._adjustComboBox(1, vse, self.AdvancedFromVerse)
|
||||||
|
self._adjustComboBox(1, vse, self.AdvancedToVerse)
|
||||||
|
|
||||||
|
def _adjustComboBox(self, frm, to , combo):
|
||||||
|
log.debug("_adjustComboBox %s , %s , %s", combo, frm, to)
|
||||||
|
combo.clear()
|
||||||
|
for i in range(int(frm), int(to) + 1):
|
||||||
|
combo.addItem(str(i))
|
||||||
|
|
||||||
|
def onAdvancedFromVerse(self):
|
||||||
|
frm = self.AdvancedFromVerse.currentText()
|
||||||
|
self._adjustComboBox(frm, self.verses, self.AdvancedToVerse)
|
||||||
|
|
||||||
|
def onAdvancedToChapter(self):
|
||||||
|
t1 = self.AdvancedFromChapter.currentText()
|
||||||
|
t2 = self.AdvancedToChapter.currentText()
|
||||||
|
if t1 != t2:
|
||||||
|
bible = str(self.AdvancedVersionComboBox.currentText())
|
||||||
|
book = str(self.AdvancedBookComboBox.currentText())
|
||||||
|
vse = self.biblemanager.getBookVerseCount(bible, book, int(t2))[0] # get the verse count for new chapter
|
||||||
|
self._adjustComboBox(1, vse, self.AdvancedToVerse)
|
||||||
|
|
||||||
|
|
||||||
|
def _initialiseBibleQuick(self, bible): # not sure if needed yet!
|
||||||
|
a=1
|
||||||
|
@ -25,18 +25,12 @@ import string
|
|||||||
from sqlalchemy import *
|
from sqlalchemy import *
|
||||||
from sqlalchemy.sql import select
|
from sqlalchemy.sql import select
|
||||||
from sqlalchemy.orm import sessionmaker, mapper
|
from sqlalchemy.orm import sessionmaker, mapper
|
||||||
mypath=os.path.split(os.path.abspath(__file__))[0]
|
|
||||||
sys.path.insert(0,(os.path.join(mypath, '..', '..', '..')))
|
|
||||||
|
|
||||||
from openlp.plugins.bibles.lib.biblecommon import BibleCommon
|
from openlp.plugins.bibles.lib.biblecommon import BibleCommon
|
||||||
from openlp.core.utils import ConfigHelper
|
from openlp.core.utils import ConfigHelper
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
logging.basicConfig(level=logging.DEBUG,
|
|
||||||
format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s',
|
|
||||||
datefmt='%m-%d %H:%M',
|
|
||||||
filename='plugins.log',
|
|
||||||
filemode='w')
|
|
||||||
class BibleDBException(Exception):
|
class BibleDBException(Exception):
|
||||||
pass
|
pass
|
||||||
class BibleInvalidDatabaseError(Exception):
|
class BibleInvalidDatabaseError(Exception):
|
||||||
|
@ -20,8 +20,6 @@ Place, Suite 330, Boston, MA 02111-1307 USA
|
|||||||
|
|
||||||
import os, os.path
|
import os, os.path
|
||||||
import sys
|
import sys
|
||||||
mypath=os.path.split(os.path.abspath(__file__))[0]
|
|
||||||
sys.path.insert(0,(os.path.join(mypath, '..', '..', '..')))
|
|
||||||
|
|
||||||
from bibleOSISimpl import BibleOSISImpl
|
from bibleOSISimpl import BibleOSISImpl
|
||||||
from bibleCSVimpl import BibleCSVImpl
|
from bibleCSVimpl import BibleCSVImpl
|
||||||
@ -29,17 +27,12 @@ from bibleDBimpl import BibleDBImpl
|
|||||||
from bibleHTTPimpl import BibleHTTPImpl
|
from bibleHTTPimpl import BibleHTTPImpl
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
logging.basicConfig(level=logging.DEBUG,
|
|
||||||
format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s',
|
|
||||||
datefmt='%m-%d %H:%M',
|
|
||||||
filename='plugins.log',
|
|
||||||
filemode='w')
|
|
||||||
|
|
||||||
class BibleManager():
|
class BibleManager():
|
||||||
global log
|
global log
|
||||||
log=logging.getLogger("BibleMgr")
|
log=logging.getLogger("BibleMgr")
|
||||||
log.info("Bible manager loaded")
|
log.info("Bible manager loaded")
|
||||||
def __init__(self, path):
|
def __init__(self, config):
|
||||||
"""
|
"""
|
||||||
Finds all the bibles defined for the system
|
Finds all the bibles defined for the system
|
||||||
Creates an Interface Object for each bible containing connection information
|
Creates an Interface Object for each bible containing connection information
|
||||||
@ -47,11 +40,13 @@ class BibleManager():
|
|||||||
|
|
||||||
Init confirms the bible exists and stores the database path.
|
Init confirms the bible exists and stores the database path.
|
||||||
"""
|
"""
|
||||||
|
self.config = config
|
||||||
log.debug( "Bible Initialising")
|
log.debug( "Bible Initialising")
|
||||||
self.bibleDBCache = {} # dict of bible database classes
|
self.bibleDBCache = {} # dict of bible database classes
|
||||||
self.bibleHTTPCache = {} # dict of bible http readers
|
self.bibleHTTPCache = {} # dict of bible http readers
|
||||||
self.biblePath = path
|
self.biblePath = self.config.get_data_path()
|
||||||
self.bibleSuffix = "bible3"
|
self.proxyname = self.config.get_config("proxy name") #get proxy name for screen
|
||||||
|
self.bibleSuffix = self.config.get_config("suffix name")
|
||||||
self.dialogobject = None
|
self.dialogobject = None
|
||||||
|
|
||||||
log.debug("Bible Path %s", self.biblePath )
|
log.debug("Bible Path %s", self.biblePath )
|
||||||
@ -159,9 +154,10 @@ class BibleManager():
|
|||||||
"""
|
"""
|
||||||
Returns a list of the books of the bible from the database
|
Returns a list of the books of the bible from the database
|
||||||
"""
|
"""
|
||||||
|
log.debug("getbibleBooks %s", bible)
|
||||||
return self.bibleDBCache[bible].getBibleBooks()
|
return self.bibleDBCache[bible].getBibleBooks()
|
||||||
|
|
||||||
def getBookChapterCount(self,bible, book):
|
def getBookChapterCount(self, bible, book):
|
||||||
"""
|
"""
|
||||||
Returns the number of Chapters for a given book
|
Returns the number of Chapters for a given book
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user