Implementation of SongSelect file import

This commit is contained in:
Derek Scotney 2010-08-21 17:33:31 +02:00
parent a043407e25
commit 54736fdac0
2 changed files with 32 additions and 0 deletions

View File

@ -144,6 +144,7 @@ from mediaitem import SongMediaItem
from songimport import SongImport from songimport import SongImport
from opensongimport import OpenSongImport from opensongimport import OpenSongImport
from olpimport import OpenLPSongImport from olpimport import OpenLPSongImport
from songselectfileimport import SongSelectFileImport
try: try:
from sofimport import SofImport from sofimport import SofImport
from oooimport import OooImport from oooimport import OooImport

31
openlp/plugins/songs/songsplugin.py Normal file → Executable file
View File

@ -41,6 +41,8 @@ except ImportError:
from openlp.plugins.songs.lib import OpenSongImport from openlp.plugins.songs.lib import OpenSongImport
from openlp.plugins.songs.lib import SongSelectFileImport
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
class SongsPlugin(Plugin): class SongsPlugin(Plugin):
@ -169,6 +171,19 @@ class SongsPlugin(Plugin):
import_menu.addAction(self.ImportOpenLPSongItem) import_menu.addAction(self.ImportOpenLPSongItem)
QtCore.QObject.connect(self.ImportOpenLPSongItem, QtCore.QObject.connect(self.ImportOpenLPSongItem,
QtCore.SIGNAL(u'triggered()'), self.onImportOpenLPSongItemClick) QtCore.SIGNAL(u'triggered()'), self.onImportOpenLPSongItemClick)
# SongSelect file import menu item
# an import wizard
self.ImportSongSelectSongItem = QtGui.QAction(import_menu)
self.ImportSongSelectSongItem.setObjectName(u'ImportSongSelectSongItem')
self.ImportSongSelectSongItem.setText(translate('SongsPlugin',
'SongSelect File (temporary)'))
self.ImportSongSelectSongItem.setToolTip(translate('SongsPlugin',
'Import a SongSelect song file'))
self.ImportSongSelectSongItem.setStatusTip(translate('SongsPlugin',
'Import a SongSelect song file'))
import_menu.addAction(self.ImportSongSelectSongItem)
QtCore.QObject.connect(self.ImportSongSelectSongItem,
QtCore.SIGNAL(u'triggered()'), self.onImportSongSelectSongItemClick)
def addExportMenuItem(self, export_menu): def addExportMenuItem(self, export_menu):
""" """
@ -248,6 +263,22 @@ class SongsPlugin(Plugin):
oooimport.import_docs(filenames) oooimport.import_docs(filenames)
Receiver.send_message(u'songs_load_list') Receiver.send_message(u'songs_load_list')
def onImportSongSelectSongItemClick(self):
filenames = QtGui.QFileDialog.getOpenFileNames(
None, translate('SongsPlugin',
'Open SongSelect file'),
u'', u'SongSelect files (*.usr *.txt)')
try:
for filename in filenames:
importer = SongSelectFileImport(self.manager)
importer.do_import(unicode(filename))
except:
log.exception('Could not import SongSelect file')
QtGui.QMessageBox.critical(None,
translate('SongsPlugin', 'Import Error'),
translate('SongsPlugin', 'Error importing SongSelect file'))
Receiver.send_message(u'songs_load_list')
def about(self): def about(self):
about_text = translate('SongsPlugin', '<strong>Songs Plugin</strong>' about_text = translate('SongsPlugin', '<strong>Songs Plugin</strong>'
'<br />The songs plugin provides the ability to display and ' '<br />The songs plugin provides the ability to display and '