From f042e5e2d835def0ddd8a22e72daa77b86c721ca Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Fri, 12 Dec 2008 19:42:51 +0000 Subject: [PATCH] Update plugins to load from directory and filter by file suffix. Updated Bibles and Presentations. Changed Add presentations to Reload from directory Updated base Config files to reflect changes bzr-revno: 214 --- openlp/core/lib/pluginconfig.py | 20 +++++++++++++++ openlp/plugins/bibles/lib/biblemanager.py | 25 +++++++++---------- .../presentations/presentationplugin.py | 19 ++++++++------ resources/.openlp/openlp.conf | 3 +++ resources/.openlp/openlp.conf_posix | 3 +++ resources/.openlp/openlp.conf_win | 3 +++ 6 files changed, 53 insertions(+), 20 deletions(-) diff --git a/openlp/core/lib/pluginconfig.py b/openlp/core/lib/pluginconfig.py index 0aca1b3f1..95c38a4a2 100644 --- a/openlp/core/lib/pluginconfig.py +++ b/openlp/core/lib/pluginconfig.py @@ -52,3 +52,23 @@ class PluginConfig(object): def set_data_path(self, path): return self.set_config('data path', os.path.basename(path)) + + def get_files(self): + returnfiles = [] + suffix = self.get_config("suffix name") + try: + files = os.listdir(self.get_data_path()) + except: + return returnfiles + if suffix != None: + for f in files: + if f.find('.') != -1: + nme = f.split('.') + bname = nme[0] + sfx = nme[1] + sfx.lower() + if suffix.find(sfx) > -1 : # only load files with the correct suffix + returnfiles.append(f) + return returnfiles + else: + return files # no filtering required diff --git a/openlp/plugins/bibles/lib/biblemanager.py b/openlp/plugins/bibles/lib/biblemanager.py index cd9fc1d51..fbdf32e3d 100644 --- a/openlp/plugins/bibles/lib/biblemanager.py +++ b/openlp/plugins/bibles/lib/biblemanager.py @@ -48,23 +48,22 @@ class BibleManager(): self.proxyname = self.config.get_config("proxy name") #get proxy name for screen self.bibleSuffix = self.config.get_config("suffix name") self.dialogobject = None + + files = self.config.get_files() + log.debug("Bible Files %s", files ) - log.debug("Bible Path %s", self.biblePath ) - files = os.listdir(self.biblePath) for f in files: nme = f.split('.') bname = nme[0] - sfx = nme[1] - if sfx == self.bibleSuffix: # only load files with the correct suffix - self.bibleDBCache[bname] = BibleDBImpl(self.biblePath, bname, self.bibleSuffix) - biblesource = self.bibleDBCache[bname].getMeta("WEB") # look to see if lazy load bible exists and get create getter. - if biblesource: - nhttp = BibleHTTPImpl() - nhttp.setBibleSource(biblesource) # tell The Server where to get the verses from. - self.bibleHTTPCache[bname] = nhttp - proxy = self.bibleDBCache[bname].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. - # + self.bibleDBCache[bname] = BibleDBImpl(self.biblePath, bname, self.bibleSuffix) + biblesource = self.bibleDBCache[bname].getMeta("WEB") # look to see if lazy load bible exists and get create getter. + if biblesource: + nhttp = BibleHTTPImpl() + nhttp.setBibleSource(biblesource) # tell The Server where to get the verses from. + self.bibleHTTPCache[bname] = nhttp + proxy = self.bibleDBCache[bname].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") diff --git a/openlp/plugins/presentations/presentationplugin.py b/openlp/plugins/presentations/presentationplugin.py index 7c43b88c1..035328d7c 100644 --- a/openlp/plugins/presentations/presentationplugin.py +++ b/openlp/plugins/presentations/presentationplugin.py @@ -23,12 +23,12 @@ from openlp.core.resources import * from openlp.core.lib import Plugin, MediaManagerItem #from forms import EditSongForm -class SongsPlugin(Plugin): +class PresentationPlugin(Plugin): def __init__(self): # Call the parent constructor Plugin.__init__(self, 'Presentations', '1.9.0') self.Weight = -8 - #self.edit_song_form = EditSongForm() + def getMediaManagerItem(self): # Create the plugin icon @@ -41,11 +41,11 @@ class SongsPlugin(Plugin): self.MediaManagerItem.addToolbar() # Create buttons for the toolbar ## New Song Button ## - self.MediaManagerItem.addToolbarButton('New Song', 'Add a new song', - ':/songs/song_new.png', self.onSongNewClick, 'SongNewItem') + self.MediaManagerItem.addToolbarButton('Update', 'Update Presentations', + ':/songs/song_new.png', self.onPresentationNewClick, 'PresentationNewItem') ## Edit Song Button ## self.MediaManagerItem.addToolbarButton('Edit Song', 'Edit the selected song', - ':/songs/song_edit.png', self.onSongEditClick, 'SongEditItem') + ':/songs/song_edit.png', self.onSongEditClick, 'PresentationEditItem') ## Delete Song Button ## self.MediaManagerItem.addToolbarButton('Delete Song', 'Delete the selected song', ':/songs/song_delete.png', self.onSongDeleteClick, 'SongDeleteItem') @@ -67,11 +67,16 @@ class SongsPlugin(Plugin): self.listView.setGeometry(QtCore.QRect(10, 100, 256, 591)) self.listView.setObjectName("listView") self.MediaManagerItem.PageLayout.addWidget(self.listView) + + self.onPresentationNewClick() return self.MediaManagerItem - def onSongNewClick(self): - pass + def onPresentationNewClick(self): + files = self.config.get_files() + self.listView.clear() + for f in files: + self.listView.addItem(f) def onSongEditClick(self): self.edit_song_form.show() diff --git a/resources/.openlp/openlp.conf b/resources/.openlp/openlp.conf index 331e3fc87..bf8ce0ebe 100644 --- a/resources/.openlp/openlp.conf +++ b/resources/.openlp/openlp.conf @@ -8,3 +8,6 @@ data path = /home/timali/.openlp/data [songs] file name = songs.sqlite data path = songs + +[presentations] +suffix name = ppt,pps,odi \ No newline at end of file diff --git a/resources/.openlp/openlp.conf_posix b/resources/.openlp/openlp.conf_posix index cf29fae15..01bd62aa8 100644 --- a/resources/.openlp/openlp.conf_posix +++ b/resources/.openlp/openlp.conf_posix @@ -8,3 +8,6 @@ data path = /home//.openlp/data [songs] file name = songs.sqlite data path = songs + +[presentations] +suffix name = ppt,pps,odi \ No newline at end of file diff --git a/resources/.openlp/openlp.conf_win b/resources/.openlp/openlp.conf_win index eb2cd81e5..af27e8bdd 100644 --- a/resources/.openlp/openlp.conf_win +++ b/resources/.openlp/openlp.conf_win @@ -8,3 +8,6 @@ data path = c:\\Documents and Settings\\\\Application Data\\.openlp\\d [songs] file name = songs.sqlite data path = songs + +[presentations] +suffix name = ppt,pps,odi