WE HAVE OUR FIRST INTEGRATING PLUGIN!!

bzr-revno: 144
This commit is contained in:
Raoul Snyman 2008-11-30 18:36:13 +00:00
parent aa55cd9af3
commit dbec7d75b3
11 changed files with 78 additions and 68 deletions

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE UserProject SYSTEM "UserProject-4.0.dtd">
<!-- eric4 user project file for project openlp.org 2.0 -->
<!-- Saved: 2008-11-29, 07:33:22 -->
<!-- Saved: 2008-11-30, 20:32:44 -->
<!-- Copyright (C) 2008 Raoul Snyman, raoulsnyman@openlp.org -->
<UserProject version="4.0">
</UserProject>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Tasks SYSTEM "Tasks-4.2.dtd">
<!-- eric4 tasks file for project openlp.org 2.0 -->
<!-- Saved: 2008-11-29, 07:33:22 -->
<!-- Saved: 2008-11-30, 20:32:44 -->
<Tasks version="4.2">
<Task priority="1" completed="False" bugfix="False">
<Summary>TODO: what is the tags for bridge, pre-chorus?</Summary>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Project SYSTEM "Project-4.4.dtd">
<!-- eric4 project file for project openlp.org 2.0 -->
<!-- Saved: 2008-11-28, 23:40:29 -->
<!-- Saved: 2008-11-30, 20:32:44 -->
<!-- Copyright (C) 2008 Raoul Snyman, raoulsnyman@openlp.org -->
<Project version="4.4">
<ProgLanguage mixed="0">Python</ProgLanguage>
@ -73,7 +73,9 @@
<Source>openlp/plugins/biblemanager/bibleCSVImpl.py</Source>
<Source>openlp/plugins/biblemanager/bibleCommon.py</Source>
<Source>openlp/plugins/biblemanager/bibleManager.py</Source>
<Source>resources/__init__.py</Source>
<Source>openlp/plugins/biblemanager/forms/__init__.py</Source>
<Source>openlp/plugins/biblemanager/forms/bibleimportdialog.py</Source>
<Source>openlp/plugins/biblemanager/forms/bibleimportform.py</Source>
</Sources>
<Forms>
<Form>resources/forms/bibleimport.ui</Form>

View File

@ -66,15 +66,19 @@ class MediaManagerItem(QtGui.QWidget):
"""
if self.Toolbar is None:
self.addToolbar()
self.ToolbarLayout.addWidget(item)
if item.__class__.__name__ == 'QSpacerItem':
self.ToolbarLayout.addSpacerItem(item)
else:
self.ToolbarLayout.addWidget(item)
def addToolbarButton(self, title, tooltip, icon, slot=None, objectname=None):
"""
A method to help developers easily add a button to the toolbar.
"""
ToolbarButton = QtGui.QToolButton(self.Toolbar)
ToolbarButton.setText(QtCore.QObject.trUtf8(title))
ToolbarButton.setToolTip(QtCore.QObject.trUtf8(tooltip))
ToolbarButton.setText(QtCore.QObject.trUtf8(ToolbarButton, title))
ToolbarButton.setToolTip(QtCore.QObject.trUtf8(ToolbarButton, tooltip))
self.addToolbarItem(ToolbarButton)
if type(icon) is QtGui.QIcon:
ButtonIcon = icon
elif type(icon) is types.StringType:
@ -88,11 +92,11 @@ class MediaManagerItem(QtGui.QWidget):
ToolbarButton.setIcon(ButtonIcon)
ToolbarButton.setIconSize(QtCore.QSize(20, 20))
ToolbarButton.setAutoRaise(True)
ToolbarButton.setMinimumSize(QtCore.QSize(20, 20))
if objectname is not None:
ToolbarButton.setObjectName(objectname)
if slot is not None:
QtCore.QObject.connect(ToolbarButton, QtCore.SIGNAL("clicked()"), slot)
self.addToolbarItem(ToolbarButton)
def addToolbarLine(self):
ToolbarLine = QtGui.QFrame(self.Toolbar)

View File

@ -69,7 +69,7 @@ class Plugin(object):
else:
self.Name = 'Plugin'
if version is not None:
self.__version__ = version
self.Version = version
self.MediaManagerItem = None
self.SettingsTab = None
self.ImportMenuItem = None
@ -113,3 +113,6 @@ class Plugin(object):
Handle the event contained in the event object.
"""
pass
def getName(self):
return self.Name

View File

@ -72,14 +72,16 @@ class PluginManager(object):
self.plugins = Plugin.__subclasses__()
self.plugin_by_name = {}
for p in self.plugins:
self.plugin_by_name[p.Name] = p;
plugin = p()
self.plugin_by_name[plugin.Name] = plugin;
def hook_media_manager(self, MediaToolBox):
"""
Loop through all the plugins. If a plugin has a valid media manager item,
add it to the media manager.
"""
for plugin in self.plugins:
for pname in self.plugin_by_name:
plugin = self.plugin_by_name[pname]
if plugin.MediaManagerItem is not None:
log.debug('Inserting media manager item from %s' % plugin.Name)
MediaToolBox.addItem(plugin.MediaManagerItem, plugin.Icon, plugin.Name)

View File

@ -18,7 +18,10 @@ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place, Suite 330, Boston, MA 02111-1307 USA
"""
from openlp.core.ui.mainwindow import MainWindow
from openlp.core.ui.splashscreen import SplashScreen
from splashscreen import SplashScreen
from about import AboutForm
from alertform import AlertForm
from settings import SettingsDialog
from mainwindow import MainWindow
__all__ = ['MainWindow', 'SplashScreen']
__all__ = ['SplashScreen', 'AboutForm', 'AlertForm', 'SettingsDialog', 'MainWindow']

View File

@ -22,25 +22,18 @@ from time import sleep
from PyQt4 import QtCore, QtGui
from openlp.core.resources import *
from openlp.core.ui.about import AboutForm
from openlp.core.ui.alertform import AlertForm
from openlp.core.ui.settings import SettingsDialog
from openlp.core.ui import AboutForm, AlertForm, SettingsDialog
from openlp.core import Plugin, PluginManager, MediaManagerItem, SettingsTab
class MainWindow(object):
def __init__(self):
self.main_window = QtGui.QMainWindow()
self.setupUi()
self.about_form = AboutForm()
self.alert_form = AlertForm()
#self.edit_song_form = EditSongForm()
#self.openlpexportform = OpenLPExportForm()
#self.openlpimportform = OpenLPImportForm()
#self.opensongexportform = OpenSongExportForm()
#self.opensongimportform = OpenSongImportForm()
self.settings_form = SettingsDialog()
self.plugin_manager = PluginManager('/home/raoul/Projects/openlp-2/openlp/plugins')
self.setupUi()
def setupUi(self):
self.main_window.setObjectName("main_window")
@ -149,6 +142,7 @@ class MainWindow(object):
self.MediaManagerDock.setWindowIcon(icon)
self.MediaManagerDock.setFloating(False)
self.MediaManagerDock.setObjectName("MediaManagerDock")
self.MediaManagerDock.setMinimumWidth(250)
self.MediaManagerContents = QtGui.QWidget()
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
@ -164,6 +158,8 @@ class MainWindow(object):
self.MediaToolBox.setObjectName("MediaToolBox")
# This is where we will eventually get the Plugin Manager to pull in
# the media manager items.
self.plugin_manager.hook_media_manager(self.MediaToolBox)
# End adding media manager items.
self.MediaManagerLayout.addWidget(self.MediaToolBox)
self.MediaManagerDock.setWidget(self.MediaManagerContents)
self.main_window.addDockWidget(QtCore.Qt.DockWidgetArea(1), self.MediaManagerDock)

View File

@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
"""
OpenLP - Open Source Lyrics Projection
Copyright (c) 2008 Raoul Snyman
@ -35,7 +37,7 @@ logging.basicConfig(level=logging.DEBUG,
filemode='w')
class BibleManager():
global log
global log
log=logging.getLogger("BibleMgr")
log.info("Bible manager loaded")
def __init__(self):
@ -45,7 +47,7 @@ class BibleManager():
Throws Exception if no Bibles are found.
Init confirms the bible exists and stores the database path.
"""
"""
log.debug( "Bible Initialising")
self.bibleDBCache = {} # dict of bible database classes
self.bibleHTTPCache = {} # dict of bible http readers
@ -63,23 +65,23 @@ class BibleManager():
self.bibleHTTPCache[b] = nhttp
proxy = self.bibleDBCache[b].getMeta("proxy") # look to see if lazy load bible exists and get create getter.
nhttp.setProxy(proxy) # tell The Server where to get the verses from.
#
#
log.debug( "Bible Initialised")
log.debug( "Bible Initialised")
def processDialog(self, dialogobject):
self.dialogobject = dialogobject
def registerHTTPBible(self, biblename, biblesource, proxyurl=None, proxyid=None, proxypass=None):
"""
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
"""
log.debug( "registerHTTPBible %s,%s,%s,%s,%s", biblename, biblesource, proxyurl, proxyid, proxypass)
log.debug( "registerHTTPBible %s,%s,%s,%s,%s", biblename, biblesource, proxyurl, proxyid, proxypass)
if self._isNewBible(biblename):
nbible = BibleDBImpl(biblename) # Create new Bible
nbible.createTables() # Create Database
self.bibleDBCache[biblename] = nbible
self.bibleDBCache[biblename] = nbible
nhttp = BibleHTTPImpl()
nhttp.setBibleSource(biblesource)
@ -87,59 +89,59 @@ class BibleManager():
nbible.saveMeta("WEB", biblesource) # register a lazy loading interest
if proxyurl != None:
nbible.saveMeta("proxy", proxyurl) # store the proxy URL
nhttp.setProxy(proxyurl)
nhttp.setProxy(proxyurl)
if proxyid != None:
nbible.saveMeta("proxyid", proxyid) # store the proxy userid
nbible.saveMeta("proxyid", proxyid) # store the proxy userid
if proxypass != None:
nbible.saveMeta("proxypass", proxypass) # store the proxy password
def registerCVSFileBible(self, biblename, booksfile, versefile):
"""
Method to load a bible from a set of files into a database.
If the database exists it is deleted and the database is reloaded
If the database exists it is deleted and the database is reloaded
from scratch.
"""
if self._isNewBible(biblename):
nbible = BibleDBImpl(biblename) # Create new Bible
nbible.createTables() # Create Database
self.bibleDBCache[biblename] = nbible # cache the database for use later
self.bibleDBCache[biblename] = nbible # cache the database for use later
bcsv = BibleCSVImpl(nbible) # create the loader and pass in the database
bcsv.loadData(booksfile, versefile)
def registerOSISFileBible(self, biblename, osisfile):
"""
Method to load a bible from a osis xml file extracted from Sword bible viewer.
If the database exists it is deleted and the database is reloaded
If the database exists it is deleted and the database is reloaded
from scratch.
"""
if self._isNewBible(biblename):
nbible = BibleDBImpl(biblename) # Create new Bible
nbible.createTables() # Create Database
self.bibleDBCache[biblename] = nbible # cache the database for use later
self.bibleDBCache[biblename] = nbible # cache the database for use later
bcsv = BibleOSISImpl(nbible) # create the loader and pass in the database
bcsv.loadData(osisfile, self.dialogobject)
bcsv.loadData(osisfile, self.dialogobject)
def loadBible(self,biblename):
"""
Downloads all the books of the bible
Downloads all the books of the bible
and loads it into the database
"""
"""
log.debug( "loadBible %s", biblename)
bookabbrev = ""
bookabbrev = ""
for bookname in self.listOfBooks:
cptrs = self.booksChapters[ self.booksOfBible[bookname]]
cptrs = self.booksChapters[ self.booksOfBible[bookname]]
log.debug( "book and chapter %s %s", bookname , self.booksChapters[ self.booksOfBible[bookname]] )
for chptr in range(1 , int(cptrs)): # loop through all the chapters in book
c = self.bibleDBCache[biblename].getBibleChapter(bookname, chptr) # check to see if book/chapter exists
log.debug( "got chapter %s", c)
if not c:
bookid = self.booksOfBible[bookname] # convert to id ie Genesis --> 1 Revelation --> 73
bookid = self.booksOfBible[bookname] # convert to id ie Genesis --> 1 Revelation --> 73
log.debug( "missing %s,%s", bookname, chptr)
self._loadBook(biblename,bookid, bookname, bookabbrev)
self._loadChapter(biblename,bookid, bookname, chptr)
def getBibles(self):
"""
Returns a list of Books of the bible
@ -152,9 +154,9 @@ class BibleManager():
def getBibleBooks(self,bible):
"""
Returns a list of the books of the bible from the database
"""
"""
return self.bibleDBCache[bible].getBibleBooks()
def getBookChapterCount(self,bible, book):
"""
Returns the number of Chapters for a given book
@ -189,8 +191,8 @@ class BibleManager():
#log.debug( self.bibleDBCache)
#log.debug( self.bibleHTTPCache)
log.debug( "getVerseText %s,%s,%s,%s,%s", bible,bookname, chapter, sverse, everse)
# bookid = self.booksOfBible[bookname] # convert to id ie Genesis --> 1 Revelation --> 73
# # SORT OUT BOOKNAME BOOK ID.
# bookid = self.booksOfBible[bookname] # convert to id ie Genesis --> 1 Revelation --> 73
# # SORT OUT BOOKNAME BOOK ID.
# # NAME COMES IN TO ID AND BACK TO NAME ?
# c = self.bibleDBCache[bible].getBibleChapter(bookname, chapter) # check to see if book/chapter exists
# bookabbrev = ""
@ -204,28 +206,28 @@ class BibleManager():
#log.debug( text)
#self.bibleDBCache[bible].dumpBible()
return text
def _loadBook(self, bible, bookid, bookname, bookabbrev):
log.debug( "loadbook %s,%s,%s,%s", bible, bookid, bookname, bookabbrev)
cl = self.bibleDBCache[bible].getBibleBook(bookname)
log.debug( "get bible book %s" , cl)
if not cl :
self.bibleDBCache[bible].createBook(bookid, bookname, bookabbrev)
def _loadChapter(self, bible, bookid, bookname, chapter):
log.debug( "loadChapter %s,%s,%s,%s", bible, bookid,bookname, chapter)
log.debug( "loadChapter %s,%s,%s,%s", bible, bookid,bookname, chapter)
try :
chaptlist = self.bibleHTTPCache[bible].getBibleChapter(bible, bookid,bookname, chapter)
self.bibleDBCache[bible].createChapter(bookname, chapter, chaptlist)
except :
log.error("Errow thrown %s", sys.exc_info()[1])
def _isNewBible(self, name):
"""
Check cache to see if new bible
"""
for b , o in self.bibleDBCache.iteritems():
log.debug( b )
if b == name :
if b == name :
return False
return True

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
"""
OpenLP - Open Source Lyrics Projection
Copyright (c) 2008 Raoul Snyman
@ -22,8 +22,8 @@ from PyQt4 import QtCore, QtGui
from openlp.core.resources import *
from openlp.core import Plugin
from openlp.plugins.biblemanager.biblemanager import BibleManager
from openlp.plugins.biblemanager.bibleimportform import BibleImportForm
from biblemanager import BibleManager
from bibleimportform import BibleImportForm
class BiblePlugin(Plugin):
def __init__(self):
@ -78,5 +78,3 @@ class BiblePlugin(Plugin):
def onBibleAddClick(self):
pass
s

View File

@ -25,7 +25,7 @@ from openlp.core import Plugin, MediaManagerItem
class SongsPlugin(Plugin):
def __init__(self):
# Call the parent constructor
Plugin.__init__(self, 'Song', '1.9.0')
Plugin.__init__(self, 'Songs', '1.9.0')
# Create the plugin icon
self.Icon = QtGui.QIcon()
self.Icon.addPixmap(QtGui.QPixmap(':/media/media_song.png'),
@ -61,11 +61,11 @@ class SongsPlugin(Plugin):
QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.MediaManagerItem.addToolbarItem(self.SongSpacerItem)
# Add the songlist widget
self.SongList = QtGui.QTableWidget(self.MediaManagerItem)
self.SongList.setObjectName("SongList")
self.SongList.setColumnCount(0)
self.SongList.setRowCount(0)
self.MediaManagerItem.PageLayout.addWidget(self.SongList)
#self.SongList = QtGui.QTableWidget(self.MediaManagerItem)
#self.SongList.setObjectName("SongList")
#self.SongList.setColumnCount(0)
#self.SongList.setRowCount(0)
#self.MediaManagerItem.PageLayout.addWidget(self.SongList)
def onSongNewClick(self):
pass