forked from openlp/openlp
Added file extension checking to words of worship import
Added the ability for importers to specifiy file fillters, and added the relevent filters for most importers (the ones where I could easily find the file ext, still need easiworship and song beamer, and maybe a few others!)
This commit is contained in:
parent
37dcddc6e6
commit
881cb4e3c3
@ -248,18 +248,24 @@ class ImportWizardForm(QtGui.QWizard, Ui_SongImportWizard):
|
||||
# Progress page
|
||||
return True
|
||||
|
||||
def getFileName(self, title, editbox):
|
||||
def getFileName(self, title, editbox,
|
||||
filters = '%s (*)' % translate('SongsPlugin.ImportWizardForm',
|
||||
'All Files')):
|
||||
filename = QtGui.QFileDialog.getOpenFileName(self, title,
|
||||
SettingsManager.get_last_dir(self.plugin.settingsSection, 1))
|
||||
SettingsManager.get_last_dir(self.plugin.settingsSection, 1),
|
||||
filters)
|
||||
if filename:
|
||||
editbox.setText(filename)
|
||||
SettingsManager.set_last_dir(
|
||||
self.plugin.settingsSection,
|
||||
os.path.split(unicode(filename))[0], 1)
|
||||
|
||||
def getFiles(self, title, listbox):
|
||||
def getFiles(self, title, listbox,
|
||||
filters = '%s (*)' % translate('SongsPlugin.ImportWizardForm',
|
||||
'All Files')):
|
||||
filenames = QtGui.QFileDialog.getOpenFileNames(self, title,
|
||||
SettingsManager.get_last_dir(self.plugin.settingsSection, 1))
|
||||
SettingsManager.get_last_dir(self.plugin.settingsSection, 1),
|
||||
filters)
|
||||
if filenames:
|
||||
listbox.addItems(filenames)
|
||||
SettingsManager.set_last_dir(
|
||||
@ -281,14 +287,24 @@ class ImportWizardForm(QtGui.QWizard, Ui_SongImportWizard):
|
||||
self.getFileName(
|
||||
translate('SongsPlugin.ImportWizardForm',
|
||||
'Select OpenLP 2.0 Database File'),
|
||||
self.openLP2FilenameEdit
|
||||
self.openLP2FilenameEdit,
|
||||
'%s (*.sqlite);;%s (*)'
|
||||
% (translate('SongsPlugin.ImportWizardForm',
|
||||
'OpenLP 2.0 Databases'),
|
||||
translate('SongsPlugin.ImportWizardForm',
|
||||
'All Files'))
|
||||
)
|
||||
|
||||
def onOpenLP1BrowseButtonClicked(self):
|
||||
self.getFileName(
|
||||
translate('SongsPlugin.ImportWizardForm',
|
||||
'Select openlp.org 1.x Database File'),
|
||||
self.openLP1FilenameEdit
|
||||
self.openLP1FilenameEdit,
|
||||
'%s (*.olp);;%s (*)'
|
||||
% (translate('SongsPlugin.ImportWizardForm',
|
||||
'openlp.org v1.x Databases'),
|
||||
translate('SongsPlugin.ImportWizardForm',
|
||||
'All Files'))
|
||||
)
|
||||
|
||||
#def onOpenLyricsAddButtonClicked(self):
|
||||
@ -305,7 +321,12 @@ class ImportWizardForm(QtGui.QWizard, Ui_SongImportWizard):
|
||||
self.getFiles(
|
||||
translate('SongsPlugin.ImportWizardForm',
|
||||
'Select Open Song Files'),
|
||||
self.openSongFileListWidget
|
||||
self.openSongFileListWidget,
|
||||
'%s (*.html);;%s (*)'
|
||||
% (translate('SongsPlugin.ImportWizardForm',
|
||||
'OpenSong html Files'),
|
||||
translate('SongsPlugin.ImportWizardForm',
|
||||
'All Files'))
|
||||
)
|
||||
|
||||
def onOpenSongRemoveButtonClicked(self):
|
||||
@ -315,7 +336,12 @@ class ImportWizardForm(QtGui.QWizard, Ui_SongImportWizard):
|
||||
self.getFiles(
|
||||
translate('SongsPlugin.ImportWizardForm',
|
||||
'Select Words of Worship Files'),
|
||||
self.wordsOfWorshipFileListWidget
|
||||
self.wordsOfWorshipFileListWidget,
|
||||
'%s (*.wsg *.wow-song);;%s (*)'
|
||||
% (translate('SongsPlugin.ImportWizardForm',
|
||||
'Words Of Worship Song Files'),
|
||||
translate('SongsPlugin.ImportWizardForm',
|
||||
'All Files'))
|
||||
)
|
||||
|
||||
def onWordsOfWorshipRemoveButtonClicked(self):
|
||||
@ -335,7 +361,12 @@ class ImportWizardForm(QtGui.QWizard, Ui_SongImportWizard):
|
||||
self.getFiles(
|
||||
translate('SongsPlugin.ImportWizardForm',
|
||||
'Select Songs of Fellowship Files'),
|
||||
self.songsOfFellowshipFileListWidget
|
||||
self.songsOfFellowshipFileListWidget,
|
||||
'%s (*.rtf);;%s (*)'
|
||||
% (translate('SongsPlugin.ImportWizardForm',
|
||||
'Songs Of Felloship Song Files'),
|
||||
translate('SongsPlugin.ImportWizardForm',
|
||||
'All Files'))
|
||||
)
|
||||
|
||||
def onSongsOfFellowshipRemoveButtonClicked(self):
|
||||
|
@ -118,6 +118,10 @@ class WowImport(SongImport):
|
||||
for file in self.import_source:
|
||||
# TODO: check that it is a valid words of worship file (could
|
||||
# check header for WoW File Song Word)
|
||||
os.path.splitext( file )
|
||||
self.ext = os.path.splitext(file)[1]
|
||||
if self.ext != u'.wsg' and self.ext != u'.wow-song':
|
||||
continue
|
||||
self.author = u''
|
||||
self.copyright = u''
|
||||
# Get the song title
|
||||
|
Loading…
Reference in New Issue
Block a user