forked from openlp/openlp
Fix up Bible Plugin to new standards.
bzr-revno: 422
This commit is contained in:
parent
e99239ef12
commit
4bbce39f35
@ -32,12 +32,12 @@ from openlp.plugins.bibles.lib.classes import *
|
|||||||
|
|
||||||
class BiblePlugin(Plugin, PluginUtils):
|
class BiblePlugin(Plugin, PluginUtils):
|
||||||
global log
|
global log
|
||||||
log=logging.getLogger("BiblePlugin")
|
log=logging.getLogger(u'BiblePlugin')
|
||||||
log.info("Bible Plugin loaded")
|
log.info(u'Bible Plugin loaded')
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
# Call the parent constructor
|
# Call the parent constructor
|
||||||
Plugin.__init__(self, 'Bibles', '1.9.0')
|
Plugin.__init__(self, u'Bibles', u'1.9.0')
|
||||||
self.weight = -9
|
self.weight = -9
|
||||||
# Create the plugin icon
|
# Create the plugin icon
|
||||||
self.icon = QtGui.QIcon()
|
self.icon = QtGui.QIcon()
|
||||||
@ -52,7 +52,7 @@ class BiblePlugin(Plugin, PluginUtils):
|
|||||||
|
|
||||||
def get_media_manager_item(self):
|
def get_media_manager_item(self):
|
||||||
# Create the BibleManagerItem object
|
# Create the BibleManagerItem object
|
||||||
self.media_item = BibleMediaItem(self, self.icon, 'Bible Verses')
|
self.media_item = BibleMediaItem(self, self.icon, u'Bible Verses')
|
||||||
return self.media_item
|
return self.media_item
|
||||||
|
|
||||||
def add_import_menu_item(self, import_menu):
|
def add_import_menu_item(self, import_menu):
|
||||||
@ -67,7 +67,8 @@ class BiblePlugin(Plugin, PluginUtils):
|
|||||||
self.ExportBibleItem = QtGui.QAction(export_menu)
|
self.ExportBibleItem = QtGui.QAction(export_menu)
|
||||||
self.ExportBibleItem.setObjectName("ExportBibleItem")
|
self.ExportBibleItem.setObjectName("ExportBibleItem")
|
||||||
export_menu.addAction(self.ExportBibleItem)
|
export_menu.addAction(self.ExportBibleItem)
|
||||||
self.ExportBibleItem.setText(QtGui.QApplication.translate("main_window", "&Bible", None, QtGui.QApplication.UnicodeUTF8))
|
self.ExportBibleItem.setText(
|
||||||
|
QtGui.QApplication.translate("main_window", u'&Bible', None, QtGui.QApplication.UnicodeUTF8))
|
||||||
|
|
||||||
def initialise(self):
|
def initialise(self):
|
||||||
pass
|
pass
|
||||||
|
@ -17,10 +17,10 @@ You should have received a copy of the GNU General Public License along with
|
|||||||
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
||||||
Place, Suite 330, Boston, MA 02111-1307 USA
|
Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
"""
|
"""
|
||||||
|
from textlistdata import TextListData
|
||||||
from common import BibleCommon
|
from common import BibleCommon
|
||||||
from manager import BibleManager
|
from manager import BibleManager
|
||||||
from biblestab import BiblesTab
|
from biblestab import BiblesTab
|
||||||
from biblemediaitem import BibleMediaItem
|
from mediaitem import BibleMediaItem
|
||||||
|
|
||||||
__all__ = ['BibleCommon', 'BibleManager', 'BiblesTab']
|
__all__ = ['BibleCommon', 'BibleManager', 'BiblesTab', 'BibleMediaItem', 'TextListData']
|
||||||
|
@ -24,8 +24,8 @@ from openlp.core.lib import Receiver
|
|||||||
|
|
||||||
class BibleCSVImpl(BibleCommon):
|
class BibleCSVImpl(BibleCommon):
|
||||||
global log
|
global log
|
||||||
log=logging.getLogger("BibleCSVImpl")
|
log=logging.getLogger(u'BibleCSVImpl')
|
||||||
log.info("BibleCVSImpl loaded")
|
log.info(u'BibleCVSImpl loaded')
|
||||||
def __init__(self, bibledb):
|
def __init__(self, bibledb):
|
||||||
"""
|
"""
|
||||||
Loads a Bible from a pair of CVS files passed in
|
Loads a Bible from a pair of CVS files passed in
|
||||||
@ -49,10 +49,10 @@ class BibleCSVImpl(BibleCommon):
|
|||||||
#log.debug( line)
|
#log.debug( line)
|
||||||
if self.loadbible == False: # cancel pressed
|
if self.loadbible == False: # cancel pressed
|
||||||
break
|
break
|
||||||
p = line.split(",")
|
p = line.split(u',')
|
||||||
p1 = p[1].replace('"', '')
|
p1 = p[1].replace(u'"', u'')
|
||||||
p2 = p[2].replace('"', '')
|
p2 = p[2].replace(u'"', u'')
|
||||||
p3 = p[3].replace('"', '')
|
p3 = p[3].replace(u'"', u'')
|
||||||
self.bibledb.create_book(p2, p3, int(p1))
|
self.bibledb.create_book(p2, p3, int(p1))
|
||||||
count += 1
|
count += 1
|
||||||
if count % 3 == 0: #Every x verses repaint the screen
|
if count % 3 == 0: #Every x verses repaint the screen
|
||||||
@ -65,9 +65,9 @@ class BibleCSVImpl(BibleCommon):
|
|||||||
if self.loadbible == False: # cancel pressed
|
if self.loadbible == False: # cancel pressed
|
||||||
break
|
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(u',', 3) # split into 3 units and leave the rest as a single field
|
||||||
p0 = p[0].replace('"', '')
|
p0 = p[0].replace(u'"', u'')
|
||||||
p3 = p[3].replace('"', '')
|
p3 = p[3].replace(u'"',u'')
|
||||||
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
|
||||||
|
@ -30,8 +30,8 @@ from openlp.plugins.bibles.lib.classes import *
|
|||||||
|
|
||||||
class BibleDBImpl(BibleCommon):
|
class BibleDBImpl(BibleCommon):
|
||||||
global log
|
global log
|
||||||
log=logging.getLogger("BibleDBImpl")
|
log=logging.getLogger(u'BibleDBImpl')
|
||||||
log.info("BibleDBimpl loaded")
|
log.info(u'BibleDBimpl loaded')
|
||||||
|
|
||||||
def __init__(self, biblepath , biblename, config):
|
def __init__(self, biblepath , biblename, config):
|
||||||
# Connect to database
|
# Connect to database
|
||||||
@ -42,11 +42,11 @@ class BibleDBImpl(BibleCommon):
|
|||||||
if db_type == u'sqlite':
|
if db_type == u'sqlite':
|
||||||
self.db = create_engine("sqlite:///"+self.biblefile)
|
self.db = create_engine("sqlite:///"+self.biblefile)
|
||||||
else:
|
else:
|
||||||
self.db_url = db_type + 'u://' + \
|
self.db_url = u'%s://%s:%s@%s/%s' % \
|
||||||
self.config.get_config(u'db username') + u':' + \
|
(db_type, self.config.get_config(u'db username'),
|
||||||
self.config.get_config(u'db password') + u'@' + \
|
self.config.get_config(u'db password'),
|
||||||
self.config.get_config(u'db hostname') + u'/' + \
|
self.config.get_config(u'db hostname'),
|
||||||
self.config.get_config(u'db database')
|
self.config.get_config(u'db database'))
|
||||||
self.db.echo = False
|
self.db.echo = False
|
||||||
metadata.bind = self.db
|
metadata.bind = self.db
|
||||||
metadata.bind.echo = False
|
metadata.bind.echo = False
|
||||||
@ -55,8 +55,8 @@ class BibleDBImpl(BibleCommon):
|
|||||||
metadata.create_all(self.db)
|
metadata.create_all(self.db)
|
||||||
|
|
||||||
def create_tables(self):
|
def create_tables(self):
|
||||||
log.debug( "createTables")
|
log.debug( u'createTables')
|
||||||
self.save_meta("dbversion", "2")
|
self.save_meta(u'dbversion', u'2')
|
||||||
self._load_testament("Old Testament")
|
self._load_testament("Old Testament")
|
||||||
self._load_testament("New Testament")
|
self._load_testament("New Testament")
|
||||||
self._load_testament("Apocrypha")
|
self._load_testament("Apocrypha")
|
||||||
@ -174,10 +174,10 @@ class BibleDBImpl(BibleCommon):
|
|||||||
return self.db.execute(s, t=versetext).fetchall()
|
return self.db.execute(s, t=versetext).fetchall()
|
||||||
|
|
||||||
def dump_bible(self):
|
def dump_bible(self):
|
||||||
log.debug( ".........Dumping Bible Database")
|
log.debug( u'.........Dumping Bible Database')
|
||||||
log.debug( "...............................Books ")
|
log.debug( '...............................Books ')
|
||||||
s = text (""" select * FROM book """)
|
s = text (""" select * FROM book """)
|
||||||
log.debug( self.db.execute(s).fetchall())
|
log.debug( self.db.execute(s).fetchall())
|
||||||
log.debug( "...............................Verses ")
|
log.debug( u'...............................Verses ')
|
||||||
s = text (""" select * FROM verse """)
|
s = text (""" select * FROM verse """)
|
||||||
log.debug( self.db.execute(s).fetchall())
|
log.debug( self.db.execute(s).fetchall())
|
||||||
|
@ -26,11 +26,13 @@ import logging
|
|||||||
|
|
||||||
class BGExtract(BibleCommon):
|
class BGExtract(BibleCommon):
|
||||||
global log
|
global log
|
||||||
log=logging.getLogger("BibleHTTPMgr(BG_extract)")
|
log=logging.getLogger(u'BibleHTTPMgr(BG_extract)')
|
||||||
log.info("BG_extract loaded")
|
log.info(u'BG_extract loaded')
|
||||||
|
|
||||||
def __init__(self, proxyurl= None):
|
def __init__(self, proxyurl= None):
|
||||||
log.debug("init %s", proxyurl)
|
log.debug("init %s", proxyurl)
|
||||||
self.proxyurl = proxyurl
|
self.proxyurl = proxyurl
|
||||||
|
|
||||||
def get_bible_chapter(self, version, bookid, bookname, chapter) :
|
def get_bible_chapter(self, version, bookid, bookname, chapter) :
|
||||||
"""
|
"""
|
||||||
Access and decode bibles via the BibleGateway website
|
Access and decode bibles via the BibleGateway website
|
||||||
@ -41,35 +43,35 @@ class BGExtract(BibleCommon):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
version = 49
|
version = 49
|
||||||
log.debug( "get_bible_chapter %s,%s,%s,%s", version, bookid, bookname, chapter)
|
log.debug( u"get_bible_chapter %s,%s,%s,%s", version, bookid, bookname, chapter)
|
||||||
urlstring = "http://www.biblegateway.com/passage/?book_id="+str(bookid)+"&chapter"+str(chapter)+"&version="+str(version)
|
urlstring = u"http://www.biblegateway.com/passage/?book_id="+str(bookid)+"&chapter"+str(chapter)+"&version="+str(version)
|
||||||
xml_string = self._get_web_text(urlstring, self.proxyurl)
|
xml_string = self._get_web_text(urlstring, self.proxyurl)
|
||||||
print xml_string
|
print xml_string
|
||||||
VerseSearch = "class="+'"'+"sup"+'"'+">"
|
VerseSearch = u'class='+'"'+u'sup'+'"'+u'>'
|
||||||
verse = 1
|
verse = 1
|
||||||
i= xml_string.find("result-text-style-normal")
|
i= xml_string.find(u'result-text-style-normal')
|
||||||
xml_string = xml_string[i:len(xml_string)]
|
xml_string = xml_string[i:len(xml_string)]
|
||||||
versePos = xml_string.find(VerseSearch)
|
versePos = xml_string.find(VerseSearch)
|
||||||
#print versePos
|
#print versePos
|
||||||
bible = {}
|
bible = {}
|
||||||
while versePos > -1:
|
while versePos > -1:
|
||||||
verseText = "" # clear out string
|
verseText = '' # clear out string
|
||||||
versePos = xml_string.find("</span", versePos)
|
versePos = xml_string.find(u'</span', versePos)
|
||||||
i = xml_string.find(VerseSearch, versePos+1)
|
i = xml_string.find(VerseSearch, versePos+1)
|
||||||
#print i , versePos
|
#print i , versePos
|
||||||
if i == -1:
|
if i == -1:
|
||||||
i = xml_string.find("</div", versePos+1)
|
i = xml_string.find(u'</div', versePos+1)
|
||||||
j = xml_string.find("<strong", versePos+1)
|
j = xml_string.find(u'<strong', versePos+1)
|
||||||
#print i , j
|
#print i , j
|
||||||
if j > 0 and j < i:
|
if j > 0 and j < i:
|
||||||
i = j
|
i = j
|
||||||
verseText = xml_string[versePos + 7 : i ]
|
verseText = xml_string[versePos + 7 : i ]
|
||||||
#print xml_string
|
#print xml_string
|
||||||
#print "VerseText = " + str(verse) +" "+ verseText
|
#print 'VerseText = ' + str(verse) +' '+ verseText
|
||||||
bible[verse] = self._clean_text(verseText) # store the verse
|
bible[verse] = self._clean_text(verseText) # store the verse
|
||||||
versePos = -1
|
versePos = -1
|
||||||
else:
|
else:
|
||||||
i = xml_string[:i].rfind("<span")+1
|
i = xml_string[:i].rfind(u'<span')+1
|
||||||
verseText = xml_string[versePos + 7 : i - 1 ] # Loose the </span>
|
verseText = xml_string[versePos + 7 : i - 1 ] # Loose the </span>
|
||||||
xml_string = xml_string[i - 1 :len(xml_string)] # chop off verse 1
|
xml_string = xml_string[i - 1 :len(xml_string)] # chop off verse 1
|
||||||
versePos = xml_string.find(VerseSearch) #look for the next verse
|
versePos = xml_string.find(VerseSearch) #look for the next verse
|
||||||
@ -79,13 +81,15 @@ class BGExtract(BibleCommon):
|
|||||||
|
|
||||||
class CWExtract(BibleCommon):
|
class CWExtract(BibleCommon):
|
||||||
global log
|
global log
|
||||||
log=logging.getLogger("BibleHTTPMgr(CWExtract)")
|
log=logging.getLogger(u'BibleHTTPMgr(CWExtract)')
|
||||||
log.info("CWExtract loaded")
|
log.info(u'CWExtract loaded')
|
||||||
|
|
||||||
def __init__(self, proxyurl=None):
|
def __init__(self, proxyurl=None):
|
||||||
log.debug("init %s", proxyurl)
|
log.debug(u"init %s", proxyurl)
|
||||||
self.proxyurl = proxyurl
|
self.proxyurl = proxyurl
|
||||||
|
|
||||||
def get_bible_chapter(self, version, bookid, bookname, chapter) :
|
def get_bible_chapter(self, version, bookid, bookname, chapter) :
|
||||||
log.debug( "getBibleChapter %s,%s,%s,%s", version, bookid, bookname, chapter)
|
log.debug( u"getBibleChapter %s,%s,%s,%s", version, bookid, bookname, chapter)
|
||||||
"""
|
"""
|
||||||
Access and decode bibles via the Crosswalk website
|
Access and decode bibles via the Crosswalk website
|
||||||
Version - the version of the bible like niv for New International version
|
Version - the version of the bible like niv for New International version
|
||||||
@ -94,48 +98,48 @@ class CWExtract(BibleCommon):
|
|||||||
chapter - chapter number
|
chapter - chapter number
|
||||||
"""
|
"""
|
||||||
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)
|
||||||
bookname = bookname.replace(" ", "")
|
bookname = bookname.replace(' ', '')
|
||||||
urlstring = "http://bible.crosswalk.com/OnlineStudyBible/bible.cgi?word="+bookname+"+"+str(chapter)+"&version="+version
|
urlstring = "http://bible.crosswalk.com/OnlineStudyBible/bible.cgi?word="+bookname+"+"+str(chapter)+"&version="+version
|
||||||
xml_string = self._get_web_text(urlstring, self.proxyurl)
|
xml_string = self._get_web_text(urlstring, self.proxyurl)
|
||||||
#log.debug("Return data %s", xml_string)
|
#log.debug('Return data %s', xml_string)
|
||||||
## Strip Book Title from Heading to return it to system
|
## Strip Book Title from Heading to return it to system
|
||||||
##
|
##
|
||||||
i= xml_string.find("<title>")
|
i= xml_string.find(u'<title>')
|
||||||
j= xml_string.find("-", i)
|
j= xml_string.find(u'-', i)
|
||||||
book_title = xml_string[i + 7:j]
|
book_title = xml_string[i + 7:j]
|
||||||
book_title = book_title.rstrip()
|
book_title = book_title.rstrip()
|
||||||
log.debug("Book Title %s", book_title)
|
log.debug(u"Book Title %s", book_title)
|
||||||
i = book_title.rfind(" ")
|
i = book_title.rfind(" ")
|
||||||
book_chapter = book_title[i+1:len(book_title)].rstrip()
|
book_chapter = book_title[i+1:len(book_title)].rstrip()
|
||||||
book_title = book_title[:i].rstrip()
|
book_title = book_title[:i].rstrip()
|
||||||
log.debug("Book Title %s", book_title)
|
log.debug(u"Book Title %s", book_title)
|
||||||
log.debug("Book Chapter %s", book_chapter)
|
log.debug(u"Book Chapter %s", book_chapter)
|
||||||
|
|
||||||
## Strip Verse Data from Page and build an array
|
## Strip Verse Data from Page and build an array
|
||||||
##
|
##
|
||||||
i= xml_string.find("NavCurrentChapter")
|
i= xml_string.find(u'NavCurrentChapter')
|
||||||
xml_string = xml_string[i:len(xml_string)]
|
xml_string = xml_string[i:len(xml_string)]
|
||||||
i= xml_string.find("<TABLE")
|
i= xml_string.find(u'<TABLE')
|
||||||
xml_string = xml_string[i:len(xml_string)]
|
xml_string = xml_string[i:len(xml_string)]
|
||||||
i= xml_string.find("<B>")
|
i= xml_string.find(u'<B>')
|
||||||
xml_string = xml_string[i + 3 :len(xml_string)] #remove the <B> at the front
|
xml_string = xml_string[i + 3 :len(xml_string)] #remove the <B> at the front
|
||||||
i= xml_string.find("<B>") # Remove the heading for the book
|
i= xml_string.find(u'<B>') # Remove the heading for the book
|
||||||
xml_string = xml_string[i + 3 :len(xml_string)] #remove the <B> at the front
|
xml_string = xml_string[i + 3 :len(xml_string)] #remove the <B> at the front
|
||||||
versePos = xml_string.find("<BLOCKQUOTE>")
|
versePos = xml_string.find(u'<BLOCKQUOTE>')
|
||||||
#log.debug( versePos)
|
#log.debug( versePos)
|
||||||
bible = {}
|
bible = {}
|
||||||
while versePos > 0:
|
while versePos > 0:
|
||||||
verseText = "" # clear out string
|
verseText = '' # clear out string
|
||||||
versePos = xml_string.find("<B><I>", versePos) + 6
|
versePos = xml_string.find(u'<B><I>', versePos) + 6
|
||||||
i = xml_string.find("</I></B>", versePos)
|
i = xml_string.find(u'</I></B>', versePos)
|
||||||
#log.debug( versePos, i)
|
#log.debug( versePos, i)
|
||||||
verse= xml_string[versePos:i] # Got the Chapter
|
verse= xml_string[versePos:i] # Got the Chapter
|
||||||
#verse = int(temp)
|
#verse = int(temp)
|
||||||
#log.debug( "Chapter = " + str(temp))
|
#log.debug( 'Chapter = ' + str(temp))
|
||||||
versePos = i + 8 # move the starting position to negining of the text
|
versePos = i + 8 # move the starting position to negining of the text
|
||||||
i = xml_string.find("<B><I>", versePos) # fine the start of the next verse
|
i = xml_string.find(u'<B><I>', versePos) # fine the start of the next verse
|
||||||
if i == -1:
|
if i == -1:
|
||||||
i = xml_string.find("</BLOCKQUOTE>",versePos)
|
i = xml_string.find(u'</BLOCKQUOTE>',versePos)
|
||||||
verseText = xml_string[versePos: i]
|
verseText = xml_string[versePos: i]
|
||||||
versePos = 0
|
versePos = 0
|
||||||
else:
|
else:
|
||||||
@ -150,8 +154,8 @@ class CWExtract(BibleCommon):
|
|||||||
|
|
||||||
class BibleHTTPImpl():
|
class BibleHTTPImpl():
|
||||||
global log
|
global log
|
||||||
log=logging.getLogger("BibleHTTPMgr")
|
log=logging.getLogger(u'BibleHTTPMgr')
|
||||||
log.info("BibleHTTP manager loaded")
|
log.info(u'BibleHTTP manager loaded')
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
"""
|
"""
|
||||||
Finds all the bibles defined for the system
|
Finds all the bibles defined for the system
|
||||||
@ -161,7 +165,7 @@ class BibleHTTPImpl():
|
|||||||
Init confirms the bible exists and stores the database path.
|
Init confirms the bible exists and stores the database path.
|
||||||
"""
|
"""
|
||||||
bible = {}
|
bible = {}
|
||||||
biblesource = ""
|
biblesource = ''
|
||||||
proxyurl = None
|
proxyurl = None
|
||||||
bibleid = None
|
bibleid = None
|
||||||
|
|
||||||
@ -169,7 +173,7 @@ class BibleHTTPImpl():
|
|||||||
"""
|
"""
|
||||||
Set the Proxy Url
|
Set the Proxy Url
|
||||||
"""
|
"""
|
||||||
log.debug("set_proxy %s", proxyurl)
|
log.debug(u"set_proxy %s", proxyurl)
|
||||||
self.proxyurl = proxyurl
|
self.proxyurl = proxyurl
|
||||||
|
|
||||||
def set_bibleid(self,bibleid):
|
def set_bibleid(self,bibleid):
|
||||||
@ -177,30 +181,30 @@ class BibleHTTPImpl():
|
|||||||
Set the bible id.
|
Set the bible id.
|
||||||
The shore identifier of the the bible.
|
The shore identifier of the the bible.
|
||||||
"""
|
"""
|
||||||
log.debug("set_bibleid %s", bibleid)
|
log.debug(u"set_bibleid %s", bibleid)
|
||||||
self.bibleid = bibleid
|
self.bibleid = bibleid
|
||||||
|
|
||||||
def set_bible_source(self,biblesource):
|
def set_bible_source(self,biblesource):
|
||||||
"""
|
"""
|
||||||
Set the source of where the bible text is coming from
|
Set the source of where the bible text is coming from
|
||||||
"""
|
"""
|
||||||
log.debug("set_bible_source %s", biblesource)
|
log.debug(u"set_bible_source %s", biblesource)
|
||||||
self.biblesource = biblesource
|
self.biblesource = biblesource
|
||||||
|
|
||||||
def get_bible_chapter(self, version, bookid, bookname, chapter):
|
def get_bible_chapter(self, version, bookid, bookname, chapter):
|
||||||
"""
|
"""
|
||||||
Receive the request and call the relevant handler methods
|
Receive the request and call the relevant handler methods
|
||||||
"""
|
"""
|
||||||
log.debug( "get_bible_chapter %s,%s,%s,%s", version, bookid, bookname, chapter)
|
log.debug(u"get_bible_chapter %s,%s,%s,%s", version, bookid, bookname, chapter)
|
||||||
log.debug("biblesource = %s", self.biblesource)
|
log.debug(u"biblesource = %s", self.biblesource)
|
||||||
try:
|
try:
|
||||||
if self.biblesource.lower() == 'crosswalk':
|
if self.biblesource.lower() == u'crosswalk':
|
||||||
ev = CWExtract(self.proxyurl)
|
ev = CWExtract(self.proxyurl)
|
||||||
else:
|
else:
|
||||||
ev = BGExtract(self.proxyurl)
|
ev = BGExtract(self.proxyurl)
|
||||||
|
|
||||||
return ev.get_bible_chapter(self.bibleid, bookid, bookname, chapter)
|
return ev.get_bible_chapter(self.bibleid, bookid, bookname, chapter)
|
||||||
except:
|
except:
|
||||||
log.error("Error thrown = %s", sys.exc_info()[1])
|
log.error(u"Error thrown = %s", sys.exc_info()[1])
|
||||||
|
|
||||||
|
|
||||||
|
@ -24,8 +24,9 @@ from PyQt4 import QtCore
|
|||||||
|
|
||||||
class BibleOSISImpl():
|
class BibleOSISImpl():
|
||||||
global log
|
global log
|
||||||
log=logging.getLogger("BibleOSISImpl")
|
log=logging.getLogger(u'BibleOSISImpl')
|
||||||
log.info("BibleOSISImpl loaded")
|
log.info(u'BibleOSISImpl loaded')
|
||||||
|
|
||||||
def __init__(self, biblepath, bibledb):
|
def __init__(self, biblepath, bibledb):
|
||||||
self.bibledb = bibledb
|
self.bibledb = bibledb
|
||||||
self.booksOfBible = {} # books of the bible linked to bibleid {osis , name}
|
self.booksOfBible = {} # books of the bible linked to bibleid {osis , name}
|
||||||
@ -50,7 +51,7 @@ class BibleOSISImpl():
|
|||||||
book_ptr = None
|
book_ptr = None
|
||||||
id = 0
|
id = 0
|
||||||
count = 0
|
count = 0
|
||||||
verseText = "<verse osisID="
|
verseText = u'<verse osisID='
|
||||||
testament = 1
|
testament = 1
|
||||||
for file in osis.readlines():
|
for file in osis.readlines():
|
||||||
# cancel pressed on UI
|
# cancel pressed on UI
|
||||||
@ -69,45 +70,45 @@ class BibleOSISImpl():
|
|||||||
#print pos, e, f[pos:e] # Found Basic Text
|
#print pos, e, f[pos:e] # Found Basic Text
|
||||||
|
|
||||||
#remove tags of extra information
|
#remove tags of extra information
|
||||||
text = self.remove_block('<title','</title>', text)
|
text = self.remove_block(u'<title',u'</title>', text)
|
||||||
text = self.remove_block('<note','</note>', text)
|
text = self.remove_block(u'<note',u'</note>', text)
|
||||||
text = self.remove_block('<divineName','</divineName>', text)
|
text = self.remove_block(u'<divineName',u'</divineName>', text)
|
||||||
|
|
||||||
text = self.remove_tag('<lb', text)
|
text = self.remove_tag(u'<lb', text)
|
||||||
text = self.remove_tag('<q', text)
|
text = self.remove_tag(u'<q', text)
|
||||||
text = self.remove_tag('<l', text)
|
text = self.remove_tag(u'<l', text)
|
||||||
text = self.remove_tag('<lg', text)
|
text = self.remove_tag(u'<lg', text)
|
||||||
|
|
||||||
# Strange tags where the end is not the same as the start
|
# Strange tags where the end is not the same as the start
|
||||||
# The must be in this order as at least one bible has them
|
# The must be in this order as at least one bible has them
|
||||||
# crossing and the removal does not work.
|
# crossing and the removal does not work.
|
||||||
pos = text.find("<FI>")
|
pos = text.find(u'<FI>')
|
||||||
while pos > -1:
|
while pos > -1:
|
||||||
epos = text.find("<Fi>", pos)
|
epos = text.find(u'<Fi>', pos)
|
||||||
if epos == -1: # TODO
|
if epos == -1: # TODO
|
||||||
#print "Y", search_text, e
|
#print "Y", search_text, e
|
||||||
pos = -1
|
pos = -1
|
||||||
else:
|
else:
|
||||||
text = text[:pos] + text[epos + 4: ]
|
text = text[:pos] + text[epos + 4: ]
|
||||||
pos = text.find("<FI>")
|
pos = text.find(u'<FI>')
|
||||||
|
|
||||||
pos = text.find("<RF>")
|
pos = text.find(u'<RF>')
|
||||||
while pos > -1:
|
while pos > -1:
|
||||||
epos = text.find("<Rf>", pos)
|
epos = text.find(u'<Rf>', pos)
|
||||||
text = text[:pos] + text[epos + 4: ]
|
text = text[:pos] + text[epos + 4: ]
|
||||||
#print "X", pos, epos, text
|
#print "X", pos, epos, text
|
||||||
pos = text.find("<RF>")
|
pos = text.find(u'<RF>')
|
||||||
|
|
||||||
p = ref.split(".", 3) # split up the reference
|
p = ref.split(u'.', 3) # split up the reference
|
||||||
#print p, ">>>", text
|
#print p, ">>>", text
|
||||||
|
|
||||||
if book_ptr != p[0]:
|
if book_ptr != p[0]:
|
||||||
if book_ptr == None: # first time through
|
if book_ptr == None: # first time through
|
||||||
if p[0] == "Gen": # set the max book size depending on the first book read
|
if p[0] == u'Gen': # set the max book size depending on the first book read
|
||||||
dialogobject.setMax(65)
|
dialogobject.setMax(65)
|
||||||
else:
|
else:
|
||||||
dialogobject.setMax(27)
|
dialogobject.setMax(27)
|
||||||
if p[0] == "Matt": # First book of NT
|
if p[0] == u'Matt': # First book of NT
|
||||||
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)
|
||||||
@ -143,12 +144,7 @@ class BibleOSISImpl():
|
|||||||
"""
|
"""
|
||||||
pos = text.find(start_tag)
|
pos = text.find(start_tag)
|
||||||
while pos > -1:
|
while pos > -1:
|
||||||
epos = text.find('/>', pos)
|
epos = text.find(u'/>', pos)
|
||||||
text = text[:pos] + text[epos + 2: ]
|
text = text[:pos] + text[epos + 2: ]
|
||||||
pos = text.find(start_tag)
|
pos = text.find(start_tag)
|
||||||
return text
|
return text
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -26,15 +26,15 @@ from openlp.core.lib import MediaManagerItem, Receiver
|
|||||||
from openlp.core.resources import *
|
from openlp.core.resources import *
|
||||||
|
|
||||||
from openlp.plugins.bibles.forms import BibleImportForm
|
from openlp.plugins.bibles.forms import BibleImportForm
|
||||||
#from openlp.plugins.bibles.lib import BiblesTab
|
from openlp.plugins.bibles.lib import TextListData
|
||||||
|
|
||||||
class BibleMediaItem(MediaManagerItem):
|
class BibleMediaItem(MediaManagerItem):
|
||||||
"""
|
"""
|
||||||
This is the custom media manager item for Bibles.
|
This is the custom media manager item for Bibles.
|
||||||
"""
|
"""
|
||||||
global log
|
global log
|
||||||
log=logging.getLogger("BibleMediaItem")
|
log=logging.getLogger(u'BibleMediaItem')
|
||||||
log.info("Bible Media Item loaded")
|
log.info(u'Bible Media Item loaded')
|
||||||
|
|
||||||
def __init__(self, parent, icon, title):
|
def __init__(self, parent, icon, title):
|
||||||
MediaManagerItem.__init__(self, parent, icon, title)
|
MediaManagerItem.__init__(self, parent, icon, title)
|
||||||
@ -47,19 +47,27 @@ class BibleMediaItem(MediaManagerItem):
|
|||||||
self.addToolbar()
|
self.addToolbar()
|
||||||
# Create buttons for the toolbar
|
# Create buttons for the toolbar
|
||||||
## New Bible Button ##
|
## New Bible Button ##
|
||||||
self.addToolbarButton('New Bible', 'Register a new Bible',
|
self.addToolbarButton(
|
||||||
|
translate(u'BibleMediaItem','New Bible'),
|
||||||
|
translate(u'BibleMediaItem','Register a new Bible'),
|
||||||
':/themes/theme_import.png', self.onBibleNewClick, 'BibleNewItem')
|
':/themes/theme_import.png', self.onBibleNewClick, 'BibleNewItem')
|
||||||
## Separator Line ##
|
## Separator Line ##
|
||||||
self.addToolbarSeparator()
|
self.addToolbarSeparator()
|
||||||
## Preview Bible Button ##
|
## Preview Bible Button ##
|
||||||
self.addToolbarButton('Preview Bible', 'Preview the selected Bible Verse',
|
self.addToolbarButton(
|
||||||
|
translate(u'BibleMediaItem','Preview Bible'),
|
||||||
|
translate(u'BibleMediaItem','Preview the selected Bible Verse'),
|
||||||
':/system/system_preview.png', self.onBiblePreviewClick, 'BiblePreviewItem')
|
':/system/system_preview.png', self.onBiblePreviewClick, 'BiblePreviewItem')
|
||||||
## Live Bible Button ##
|
## Live Bible Button ##
|
||||||
self.addToolbarButton('Go Live', 'Send the selected Bible Verse(s) live',
|
self.addToolbarButton(
|
||||||
|
translate(u'BibleMediaItem','Go Live'),
|
||||||
|
translate(u'BibleMediaItem','Send the selected Bible Verse(s) live'),
|
||||||
':/system/system_live.png', self.onBibleLiveClick, 'BibleLiveItem')
|
':/system/system_live.png', self.onBibleLiveClick, 'BibleLiveItem')
|
||||||
## Add Bible Button ##
|
## Add Bible Button ##
|
||||||
self.addToolbarButton('Add Bible Verse(s) To Service',
|
self.addToolbarButton(
|
||||||
'Add the selected Bible(s) to the service', ':/system/system_add.png',
|
translate(u'BibleMediaItem','Add Bible Verse(s) To Service'),
|
||||||
|
translate(u'BibleMediaItem','Add the selected Bible(s) to the service'),
|
||||||
|
':/system/system_add.png',
|
||||||
self.onBibleAddClick, 'BibleAddItem')
|
self.onBibleAddClick, 'BibleAddItem')
|
||||||
|
|
||||||
# Create the tab widget
|
# Create the tab widget
|
||||||
@ -171,19 +179,27 @@ class BibleMediaItem(MediaManagerItem):
|
|||||||
# Add the search tab widget to the page layout
|
# Add the search tab widget to the page layout
|
||||||
self.PageLayout.addWidget(self.SearchTabWidget)
|
self.PageLayout.addWidget(self.SearchTabWidget)
|
||||||
|
|
||||||
self.BibleListView = QtGui.QTableWidget()
|
# self.BibleListView = QtGui.QTableWidget()
|
||||||
self.BibleListView.setColumnCount(2)
|
# self.BibleListView.setColumnCount(2)
|
||||||
self.BibleListView.setColumnHidden(0, True)
|
# self.BibleListView.setColumnHidden(0, True)
|
||||||
self.BibleListView.setColumnWidth(1, 275)
|
# self.BibleListView.setColumnWidth(1, 275)
|
||||||
self.BibleListView.setShowGrid(False)
|
# self.BibleListView.setShowGrid(False)
|
||||||
self.BibleListView.setSortingEnabled(False)
|
# self.BibleListView.setSortingEnabled(False)
|
||||||
self.BibleListView.setAlternatingRowColors(True)
|
# self.BibleListView.setAlternatingRowColors(True)
|
||||||
self.BibleListView.verticalHeader().setVisible(False)
|
# self.BibleListView.verticalHeader().setVisible(False)
|
||||||
self.BibleListView.horizontalHeader().setVisible(False)
|
# self.BibleListView.horizontalHeader().setVisible(False)
|
||||||
self.BibleListView.setGeometry(QtCore.QRect(10, 200, 256, 391))
|
# self.BibleListView.setGeometry(QtCore.QRect(10, 200, 256, 391))
|
||||||
self.BibleListView.setObjectName(u'BibleListView')
|
# self.BibleListView.setObjectName(u'BibleListView')
|
||||||
|
# self.BibleListView.setAlternatingRowColors(True)
|
||||||
|
# self.PageLayout.addWidget(self.BibleListView)
|
||||||
|
|
||||||
|
self.BibleListView = QtGui.QListView()
|
||||||
self.BibleListView.setAlternatingRowColors(True)
|
self.BibleListView.setAlternatingRowColors(True)
|
||||||
|
self.BibleListData = TextListData()
|
||||||
|
self.BibleListView.setModel(self.BibleListData)
|
||||||
|
|
||||||
self.PageLayout.addWidget(self.BibleListView)
|
self.PageLayout.addWidget(self.BibleListView)
|
||||||
|
|
||||||
# Combo Boxes
|
# Combo Boxes
|
||||||
QtCore.QObject.connect(self.AdvancedVersionComboBox,
|
QtCore.QObject.connect(self.AdvancedVersionComboBox,
|
||||||
QtCore.SIGNAL("activated(int)"), self.onAdvancedVersionComboBox)
|
QtCore.SIGNAL("activated(int)"), self.onAdvancedVersionComboBox)
|
||||||
@ -204,15 +220,16 @@ class BibleMediaItem(MediaManagerItem):
|
|||||||
self.BibleListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
|
self.BibleListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
|
||||||
self.BibleListView.addAction(self.contextMenuAction(
|
self.BibleListView.addAction(self.contextMenuAction(
|
||||||
self.BibleListView, ':/system/system_preview.png',
|
self.BibleListView, ':/system/system_preview.png',
|
||||||
"&Preview Verse", self.onBiblePreviewClick))
|
translate(u'BibleMediaItem',u'&Preview Verse'), self.onBiblePreviewClick))
|
||||||
self.BibleListView.addAction(self.contextMenuAction(
|
self.BibleListView.addAction(self.contextMenuAction(
|
||||||
self.BibleListView, ':/system/system_live.png',
|
self.BibleListView, ':/system/system_live.png',
|
||||||
"&Show Live", self.onBibleLiveClick))
|
translate(u'BibleMediaItem',u'&Show Live'), self.onBibleLiveClick))
|
||||||
self.BibleListView.addAction(self.contextMenuAction(
|
self.BibleListView.addAction(self.contextMenuAction(
|
||||||
self.BibleListView, ':/system/system_add.png',
|
self.BibleListView, ':/system/system_add.png',
|
||||||
"&Add to Service", self.onBibleAddClick))
|
translate(u'BibleMediaItem',u'&Add to Service'), self.onBibleAddClick))
|
||||||
|
|
||||||
def retranslateUi(self):
|
def retranslateUi(self):
|
||||||
|
log.debug(u'retranslateUi')
|
||||||
self.QuickVersionLabel.setText(translate(u'BibleMediaItem', u'Version:'))
|
self.QuickVersionLabel.setText(translate(u'BibleMediaItem', u'Version:'))
|
||||||
self.QuickSearchLabel.setText(translate(u'BibleMediaItem', u'Search Type:'))
|
self.QuickSearchLabel.setText(translate(u'BibleMediaItem', u'Search Type:'))
|
||||||
self.QuickSearchLabel.setText(translate(u'BibleMediaItem', u'Find:'))
|
self.QuickSearchLabel.setText(translate(u'BibleMediaItem', u'Find:'))
|
||||||
@ -234,21 +251,20 @@ class BibleMediaItem(MediaManagerItem):
|
|||||||
self.ClearAdvancedSearchComboBox.addItem(translate(u'BibleMediaItem', u'Keep'))
|
self.ClearAdvancedSearchComboBox.addItem(translate(u'BibleMediaItem', u'Keep'))
|
||||||
|
|
||||||
def initialise(self):
|
def initialise(self):
|
||||||
|
log.debug(u'initialise')
|
||||||
self.loadBibles()
|
self.loadBibles()
|
||||||
|
|
||||||
def initialiseForm(self):
|
def loadBibles(self):
|
||||||
self.QuickSearchComboBox.clear()
|
log.debug(u'Loading Bibles')
|
||||||
self.QuickVersionComboBox.clear()
|
self.QuickVersionComboBox.clear()
|
||||||
self.AdvancedVersionComboBox.clear()
|
self.AdvancedVersionComboBox.clear()
|
||||||
self.ClearQuickSearchComboBox.clear()
|
|
||||||
self.ClearAdvancedSearchComboBox.clear()
|
bibles = self.parent.biblemanager.get_bibles(u'full')
|
||||||
|
|
||||||
def loadBibles(self):
|
|
||||||
log.debug("Loading Bibles")
|
|
||||||
bibles = self.parent.biblemanager.get_bibles('full')
|
|
||||||
for bible in bibles: # load bibles into the combo boxes
|
for bible in bibles: # load bibles into the combo boxes
|
||||||
self.QuickVersionComboBox.addItem(bible)
|
self.QuickVersionComboBox.addItem(bible)
|
||||||
bibles = self.parent.biblemanager.get_bibles('partial') # Without HTTP
|
|
||||||
|
bibles = self.parent.biblemanager.get_bibles(u'partial') # Without HTTP
|
||||||
first = True
|
first = True
|
||||||
for bible in bibles: # load bibles into the combo boxes
|
for bible in bibles: # load bibles into the combo boxes
|
||||||
self.AdvancedVersionComboBox.addItem(bible)
|
self.AdvancedVersionComboBox.addItem(bible)
|
||||||
@ -258,10 +274,9 @@ class BibleMediaItem(MediaManagerItem):
|
|||||||
|
|
||||||
def onAdvancedVersionComboBox(self):
|
def onAdvancedVersionComboBox(self):
|
||||||
self.initialiseBible(str(self.AdvancedVersionComboBox.currentText())) # restet the bible info
|
self.initialiseBible(str(self.AdvancedVersionComboBox.currentText())) # restet the bible info
|
||||||
pass
|
|
||||||
|
|
||||||
def onAdvancedBookComboBox(self):
|
def onAdvancedBookComboBox(self):
|
||||||
self.initialiseBible(str(self.AdvancedVersionComboBox.currentText())) # restet the bible info
|
self.initialiseBible(str(self.AdvancedVersionComboBox.currentText())) # reset the bible info
|
||||||
|
|
||||||
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)
|
||||||
@ -288,7 +303,7 @@ class BibleMediaItem(MediaManagerItem):
|
|||||||
self.adjustComboBox(1, vse, self.AdvancedToVerse)
|
self.adjustComboBox(1, vse, self.AdvancedToVerse)
|
||||||
|
|
||||||
def onAdvancedSearchButton(self):
|
def onAdvancedSearchButton(self):
|
||||||
log.debug("Advanced Search Button pressed")
|
log.debug(u'Advanced Search Button pressed')
|
||||||
bible = str(self.AdvancedVersionComboBox.currentText())
|
bible = str(self.AdvancedVersionComboBox.currentText())
|
||||||
book = str(self.AdvancedBookComboBox.currentText())
|
book = str(self.AdvancedBookComboBox.currentText())
|
||||||
chapter_from = int(self.AdvancedFromChapter.currentText())
|
chapter_from = int(self.AdvancedFromChapter.currentText())
|
||||||
@ -298,9 +313,8 @@ class BibleMediaItem(MediaManagerItem):
|
|||||||
self.search_results = self.parent.biblemanager.get_verse_text(bible, book,
|
self.search_results = self.parent.biblemanager.get_verse_text(bible, book,
|
||||||
chapter_from, chapter_to, verse_from, verse_to)
|
chapter_from, chapter_to, verse_from, verse_to)
|
||||||
if self.ClearAdvancedSearchComboBox.currentIndex() == 0:
|
if self.ClearAdvancedSearchComboBox.currentIndex() == 0:
|
||||||
self.BibleListView.clear() # clear the results
|
self.BibleListData.resetStore()
|
||||||
self.BibleListView.setRowCount(0)
|
self.displayResults(bible)
|
||||||
self.displayResults(bible)
|
|
||||||
|
|
||||||
def onAdvancedFromChapter(self):
|
def onAdvancedFromChapter(self):
|
||||||
bible = str(self.AdvancedVersionComboBox.currentText())
|
bible = str(self.AdvancedVersionComboBox.currentText())
|
||||||
@ -312,12 +326,11 @@ class BibleMediaItem(MediaManagerItem):
|
|||||||
self._adjust_combobox(1, vse, self.AdvancedToVerse)
|
self._adjust_combobox(1, vse, self.AdvancedToVerse)
|
||||||
|
|
||||||
def onQuickSearchButton(self):
|
def onQuickSearchButton(self):
|
||||||
log.debug("Quick Search Button pressed")
|
log.debug(u'Quick Search Button pressed')
|
||||||
bible = str(self.QuickVersionComboBox.currentText())
|
bible = str(self.QuickVersionComboBox.currentText())
|
||||||
text = str(self.QuickSearchEdit.displayText())
|
text = str(self.QuickSearchEdit.displayText())
|
||||||
if self.ClearQuickSearchComboBox.currentIndex() == 0:
|
if self.ClearQuickSearchComboBox.currentIndex() == 0:
|
||||||
self.BibleListView.clear() # clear the results
|
self.BibleListData.resetStore()
|
||||||
self.BibleListView.setRowCount(0)
|
|
||||||
if self.QuickSearchComboBox.currentIndex() == 1:
|
if self.QuickSearchComboBox.currentIndex() == 1:
|
||||||
self.search_results = self.parent.biblemanager.get_verse_from_text(bible, text)
|
self.search_results = self.parent.biblemanager.get_verse_from_text(bible, text)
|
||||||
else:
|
else:
|
||||||
@ -326,11 +339,11 @@ class BibleMediaItem(MediaManagerItem):
|
|||||||
self.displayResults(bible)
|
self.displayResults(bible)
|
||||||
|
|
||||||
def onBiblePreviewClick(self):
|
def onBiblePreviewClick(self):
|
||||||
log.debug("Bible Preview Button pressed")
|
log.debug(u'Bible Preview Button pressed')
|
||||||
items = self.BibleListView.selectedItems()
|
items = self.BibleListView.selectedIndexes()
|
||||||
old_chapter = ''
|
old_chapter = ''
|
||||||
for item in items:
|
for item in items:
|
||||||
text = str(item.text())
|
text = self.BibleListData.getValue(item)
|
||||||
verse = text[:text.find("(")]
|
verse = text[:text.find("(")]
|
||||||
bible = text[text.find("(") + 1:text.find(")")]
|
bible = text[text.find("(") + 1:text.find(")")]
|
||||||
self.searchByReference(bible, verse)
|
self.searchByReference(bible, verse)
|
||||||
@ -364,17 +377,16 @@ class BibleMediaItem(MediaManagerItem):
|
|||||||
return loc
|
return loc
|
||||||
|
|
||||||
def reloadBibles(self):
|
def reloadBibles(self):
|
||||||
log.debug("Reloading Bibles")
|
log.debug(u'Reloading Bibles')
|
||||||
self.parent.biblemanager.reload_bibles()
|
self.parent.biblemanager.reload_bibles()
|
||||||
#self.initialiseForm()
|
|
||||||
self.loadBibles()
|
self.loadBibles()
|
||||||
|
|
||||||
def initialiseBible(self, bible):
|
def initialiseBible(self, bible):
|
||||||
log.debug('initialiseBible %s', bible)
|
log.debug(u"initialiseBible %s", bible)
|
||||||
current_book = str(self.AdvancedBookComboBox.currentText())
|
current_book = str(self.AdvancedBookComboBox.currentText())
|
||||||
chapter_count = self.parent.biblemanager.get_book_chapter_count(bible,
|
chapter_count = self.parent.biblemanager.get_book_chapter_count(bible,
|
||||||
current_book)[0]
|
current_book)[0]
|
||||||
log.debug('Book change bible %s book %s ChapterCount %s', bible,
|
log.debug(u'Book change bible %s book %s ChapterCount %s', bible,
|
||||||
current_book, chapter_count)
|
current_book, chapter_count)
|
||||||
if chapter_count == None:
|
if chapter_count == None:
|
||||||
# Only change the search details if the book is missing from the new bible
|
# Only change the search details if the book is missing from the new bible
|
||||||
@ -389,7 +401,7 @@ class BibleMediaItem(MediaManagerItem):
|
|||||||
self.initialiseChapterVerse(bible, book.name)
|
self.initialiseChapterVerse(bible, book.name)
|
||||||
|
|
||||||
def initialiseChapterVerse(self, bible, book):
|
def initialiseChapterVerse(self, bible, book):
|
||||||
log.debug("initialiseChapterVerse %s , %s", bible, book)
|
log.debug(u"initialiseChapterVerse %s , %s", bible, book)
|
||||||
self.chapters_from = self.parent.biblemanager.get_book_chapter_count(bible, book)[0]
|
self.chapters_from = self.parent.biblemanager.get_book_chapter_count(bible, book)[0]
|
||||||
self.verses = self.parent.biblemanager.get_book_verse_count(bible, book, 1)[0]
|
self.verses = self.parent.biblemanager.get_book_verse_count(bible, book, 1)[0]
|
||||||
self.adjustComboBox(1, self.chapters_from, self.AdvancedFromChapter)
|
self.adjustComboBox(1, self.chapters_from, self.AdvancedFromChapter)
|
||||||
@ -398,23 +410,18 @@ class BibleMediaItem(MediaManagerItem):
|
|||||||
self.adjustComboBox(1, self.verses, self.AdvancedToVerse)
|
self.adjustComboBox(1, self.verses, self.AdvancedToVerse)
|
||||||
|
|
||||||
def adjustComboBox(self, frm, to , combo):
|
def adjustComboBox(self, frm, to , combo):
|
||||||
log.debug("adjustComboBox %s , %s , %s", combo, frm, to)
|
log.debug(u"adjustComboBox %s , %s , %s", combo, frm, to)
|
||||||
combo.clear()
|
combo.clear()
|
||||||
for i in range(int(frm), int(to) + 1):
|
for i in range(int(frm), int(to) + 1):
|
||||||
combo.addItem(str(i))
|
combo.addItem(str(i))
|
||||||
|
|
||||||
def displayResults(self, bible):
|
def displayResults(self, bible):
|
||||||
for book, chap, vse , txt in self.search_results:
|
for book, chap, vse , txt in self.search_results:
|
||||||
row_count = self.BibleListView.rowCount()
|
text = str(u" %s %d:%d (%s)"%(book , chap,vse, bible))
|
||||||
self.BibleListView.setRowCount(row_count+1)
|
self.BibleListData.addRow(0,text)
|
||||||
table_data = QtGui.QTableWidgetItem(str(bible))
|
|
||||||
self.BibleListView.setItem(row_count , 0, table_data)
|
|
||||||
table_data = QtGui.QTableWidgetItem(str(book + " " +str(chap) + ":"+ str(vse)) + " ("+str(bible)+")")
|
|
||||||
self.BibleListView.setItem(row_count , 1, table_data)
|
|
||||||
self.BibleListView.setRowHeight(row_count, 20)
|
|
||||||
|
|
||||||
def searchByReference(self, bible, search):
|
def searchByReference(self, bible, search):
|
||||||
log.debug("searchByReference %s ,%s", bible, search)
|
log.debug(u"searchByReference %s ,%s", bible, search)
|
||||||
book = ''
|
book = ''
|
||||||
start_chapter = ''
|
start_chapter = ''
|
||||||
end_chapter = ''
|
end_chapter = ''
|
69
openlp/plugins/bibles/lib/textlistdata.py
Normal file
69
openlp/plugins/bibles/lib/textlistdata.py
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
import logging
|
||||||
|
|
||||||
|
from PyQt4.QtCore import *
|
||||||
|
from PyQt4.QtGui import *
|
||||||
|
|
||||||
|
|
||||||
|
class TextListData(QAbstractListModel):
|
||||||
|
"""
|
||||||
|
An abstract list of strings
|
||||||
|
"""
|
||||||
|
global log
|
||||||
|
log=logging.getLogger(u'TextListData')
|
||||||
|
log.info(u'started')
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
QAbstractListModel.__init__(self)
|
||||||
|
self.items=[] # will be a list of (database id , title) tuples
|
||||||
|
|
||||||
|
def resetStore(self):
|
||||||
|
#reset list so can be reloaded
|
||||||
|
self.items=[]
|
||||||
|
|
||||||
|
def rowCount(self, parent):
|
||||||
|
return len(self.items)
|
||||||
|
|
||||||
|
def insertRow(self, row, id, title):
|
||||||
|
self.beginInsertRows(QModelIndex(),row,row)
|
||||||
|
log.debug("insert row %d:%s for id %d"%(row,title, id))
|
||||||
|
self.items.insert(row, (id, title))
|
||||||
|
self.endInsertRows()
|
||||||
|
|
||||||
|
def removeRow(self, row):
|
||||||
|
self.beginRemoveRows(QModelIndex(), row,row)
|
||||||
|
self.items.pop(row)
|
||||||
|
self.endRemoveRows()
|
||||||
|
|
||||||
|
def addRow(self, id, title):
|
||||||
|
self.insertRow(len(self.items), id, title)
|
||||||
|
|
||||||
|
def data(self, index, role):
|
||||||
|
row=index.row()
|
||||||
|
if row > len(self.items): # if the last row is selected and deleted, we then get called with an empty row!
|
||||||
|
return QVariant()
|
||||||
|
if role==Qt.DisplayRole:
|
||||||
|
retval= self.items[row][1]
|
||||||
|
# elif role == Qt.ToolTipRole: #not sure if need as it shows the database row number
|
||||||
|
# retval= self.items[row][0]
|
||||||
|
else:
|
||||||
|
retval= QVariant()
|
||||||
|
# log.info("Returning"+ str(retval))
|
||||||
|
if type(retval) is not type(QVariant):
|
||||||
|
return QVariant(retval)
|
||||||
|
else:
|
||||||
|
return retval
|
||||||
|
|
||||||
|
def getIdList(self):
|
||||||
|
filelist = [item[0] for item in self.items];
|
||||||
|
return filelist
|
||||||
|
|
||||||
|
def getValue(self, index):
|
||||||
|
row = index.row()
|
||||||
|
return self.items[row][1]
|
||||||
|
|
||||||
|
def deleteRow(self, index):
|
||||||
|
row = index.row()
|
||||||
|
self.removeRow(row)
|
||||||
|
|
||||||
|
if __name__=="__main__":
|
||||||
|
sxml=TextListData()
|
Loading…
Reference in New Issue
Block a user