forked from openlp/openlp
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
This commit is contained in:
parent
eb1b1010c0
commit
f042e5e2d8
@ -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
|
||||
|
@ -49,13 +49,12 @@ class BibleManager():
|
||||
self.bibleSuffix = self.config.get_config("suffix name")
|
||||
self.dialogobject = None
|
||||
|
||||
log.debug("Bible Path %s", self.biblePath )
|
||||
files = os.listdir(self.biblePath)
|
||||
files = self.config.get_files()
|
||||
log.debug("Bible Files %s", files )
|
||||
|
||||
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:
|
||||
|
@ -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')
|
||||
@ -68,10 +68,15 @@ class SongsPlugin(Plugin):
|
||||
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()
|
||||
|
@ -8,3 +8,6 @@ data path = /home/timali/.openlp/data
|
||||
[songs]
|
||||
file name = songs.sqlite
|
||||
data path = songs
|
||||
|
||||
[presentations]
|
||||
suffix name = ppt,pps,odi
|
@ -8,3 +8,6 @@ data path = /home/<username>/.openlp/data
|
||||
[songs]
|
||||
file name = songs.sqlite
|
||||
data path = songs
|
||||
|
||||
[presentations]
|
||||
suffix name = ppt,pps,odi
|
@ -8,3 +8,6 @@ data path = c:\\Documents and Settings\\<username>\\Application Data\\.openlp\\d
|
||||
[songs]
|
||||
file name = songs.sqlite
|
||||
data path = songs
|
||||
|
||||
[presentations]
|
||||
suffix name = ppt,pps,odi
|
||||
|
Loading…
Reference in New Issue
Block a user