Changed the Generic importer to multifile as well.

This commit is contained in:
Raoul Snyman 2010-08-23 21:29:39 +02:00
parent 6d0b229860
commit ef44dc72c6
3 changed files with 57 additions and 57 deletions

View File

@ -97,9 +97,12 @@ class ImportWizardForm(QtGui.QWizard, Ui_SongImportWizard):
QtCore.QObject.connect(self.songsOfFellowshipRemoveButton, QtCore.QObject.connect(self.songsOfFellowshipRemoveButton,
QtCore.SIGNAL(u'clicked()'), QtCore.SIGNAL(u'clicked()'),
self.onSongsOfFellowshipRemoveButtonClicked) self.onSongsOfFellowshipRemoveButtonClicked)
QtCore.QObject.connect(self.genericBrowseButton, QtCore.QObject.connect(self.genericAddButton,
QtCore.SIGNAL(u'clicked()'), QtCore.SIGNAL(u'clicked()'),
self.onGenericBrowseButtonClicked) self.onGenericAddButtonClicked)
QtCore.QObject.connect(self.genericRemoveButton,
QtCore.SIGNAL(u'clicked()'),
self.onGenericRemoveButtonClicked)
QtCore.QObject.connect(self.cancelButton, QtCore.QObject.connect(self.cancelButton,
QtCore.SIGNAL(u'clicked(bool)'), QtCore.SIGNAL(u'clicked(bool)'),
self.onCancelButtonClicked) self.onCancelButtonClicked)
@ -185,24 +188,24 @@ class ImportWizardForm(QtGui.QWizard, Ui_SongImportWizard):
self.ccliAddButton.setFocus() self.ccliAddButton.setFocus()
return False return False
elif source_format == SongFormat.SongsOfFellowship: elif source_format == SongFormat.SongsOfFellowship:
if self.songsOfFellowshipFilenameEdit.text().isEmpty(): if self.songsOfFellowshipFileListWidget.count() == 0:
QtGui.QMessageBox.critical(self, QtGui.QMessageBox.critical(self,
translate('SongsPlugin.ImportWizardForm', translate('SongsPlugin.ImportWizardForm',
'No Songs of Fellowship File Selected'), 'No Songs of Fellowship File Selected'),
translate('SongsPlugin.ImportWizardForm', translate('SongsPlugin.ImportWizardForm',
'You need to select a Songs of Fellowship file to ' 'You need to add at least one Songs of Fellowship '
'import from.')) 'file to import from.'))
self.songsOfFellowshipBrowseButton.setFocus() self.songsOfFellowshipAddButton.setFocus()
return False return False
elif source_format == SongFormat.Generic: elif source_format == SongFormat.Generic:
if self.genericFilenameEdit.text().isEmpty(): if self.genericFileListWidget.count() == 0:
QtGui.QMessageBox.critical(self, QtGui.QMessageBox.critical(self,
translate('SongsPlugin.ImportWizardForm', translate('SongsPlugin.ImportWizardForm',
'No Document/Presentation Selected'), 'No Document/Presentation Selected'),
translate('SongsPlugin.ImportWizardForm', translate('SongsPlugin.ImportWizardForm',
'You need to select a document/presentation file ' 'You need to add at least one document or '
'to import from.')) 'presentation file to import from.'))
self.genericBrowseButton.setFocus() self.genericAddButton.setFocus()
return False return False
return True return True
elif self.currentId() == 2: elif self.currentId() == 2:
@ -292,13 +295,16 @@ class ImportWizardForm(QtGui.QWizard, Ui_SongImportWizard):
def onSongsOfFellowshipRemoveButtonClicked(self): def onSongsOfFellowshipRemoveButtonClicked(self):
self.removeSelectedItems(self.songsOfFellowshipFileListWidget) self.removeSelectedItems(self.songsOfFellowshipFileListWidget)
def onGenericBrowseButtonClicked(self): def onGenericAddButtonClicked(self):
self.getFileName( self.getFiles(
translate('SongsPlugin.ImportWizardForm', translate('SongsPlugin.ImportWizardForm',
'Select Document/Presentation File'), 'Select Document/Presentation Files'),
self.genericFilenameEdit self.genericFileListWidget
) )
def onGenericRemoveButtonClicked(self):
self.removeSelectedItems(self.genericFileListWidget)
def onCancelButtonClicked(self, checked): def onCancelButtonClicked(self, checked):
""" """
Stop the import on pressing the cancel button. Stop the import on pressing the cancel button.
@ -325,7 +331,7 @@ class ImportWizardForm(QtGui.QWizard, Ui_SongImportWizard):
self.wordsOfWorshipFileListWidget.clear() self.wordsOfWorshipFileListWidget.clear()
self.ccliFileListWidget.clear() self.ccliFileListWidget.clear()
self.songsOfFellowshipFileListWidget.clear() self.songsOfFellowshipFileListWidget.clear()
self.genericFilenameEdit.setText(u'') self.genericFileListWidget.clear()
#self.csvFilenameEdit.setText(u'') #self.csvFilenameEdit.setText(u'')
def incrementProgressBar(self, status_text): def incrementProgressBar(self, status_text):
@ -386,6 +392,11 @@ class ImportWizardForm(QtGui.QWizard, Ui_SongImportWizard):
importer = self.plugin.importSongs(SongFormat.SongsOfFellowship, importer = self.plugin.importSongs(SongFormat.SongsOfFellowship,
filenames=self.getListOfFiles(self.songsOfFellowshipFileListWidget) filenames=self.getListOfFiles(self.songsOfFellowshipFileListWidget)
) )
elif source_format == SongFormat.Generic:
# Import a generic document or presentatoin
importer = self.plugin.importSongs(SongFormat.Generic,
filenames=self.getListOfFiles(self.genericFileListWidget)
)
success = importer.do_import() success = importer.do_import()
if success: if success:
# reload songs # reload songs

View File

@ -291,46 +291,34 @@ class Ui_SongImportWizard(object):
self.songsOfFellowshipRemoveButton.setObjectName(u'songsOfFellowshipRemoveButton') self.songsOfFellowshipRemoveButton.setObjectName(u'songsOfFellowshipRemoveButton')
self.songsOfFellowshipButtonLayout.addWidget(self.songsOfFellowshipRemoveButton) self.songsOfFellowshipButtonLayout.addWidget(self.songsOfFellowshipRemoveButton)
self.songsOfFellowshipLayout.addLayout(self.songsOfFellowshipButtonLayout) self.songsOfFellowshipLayout.addLayout(self.songsOfFellowshipButtonLayout)
# self.songsOfFellowshipFilenameLabel = QtGui.QLabel(self.songsOfFellowshipPage)
# self.songsOfFellowshipFilenameLabel.setObjectName(u'songsOfFellowshipFilenameLabel')
# self.songsOfFellowshipLayout.setWidget(0, QtGui.QFormLayout.LabelRole,
# self.songsOfFellowshipFilenameLabel)
# self.songsOfFellowshipFileLayout = QtGui.QHBoxLayout()
# self.songsOfFellowshipFileLayout.setSpacing(8)
# self.songsOfFellowshipFileLayout.setObjectName(u'songsOfFellowshipFileLayout')
# self.songsOfFellowshipFilenameEdit = QtGui.QLineEdit(self.songsOfFellowshipPage)
# self.songsOfFellowshipFilenameEdit.setObjectName(u'songsOfFellowshipFilenameEdit')
# self.songsOfFellowshipFileLayout.addWidget(self.songsOfFellowshipFilenameEdit)
# self.songsOfFellowshipBrowseButton = QtGui.QToolButton(self.songsOfFellowshipPage)
# self.songsOfFellowshipBrowseButton.setIcon(openIcon)
# self.songsOfFellowshipBrowseButton.setObjectName(u'songsOfFellowshipBrowseButton')
# self.songsOfFellowshipFileLayout.addWidget(self.songsOfFellowshipBrowseButton)
# self.songsOfFellowshipLayout.setLayout(0, QtGui.QFormLayout.FieldRole,
# self.songsOfFellowshipFileLayout)
self.formatStackedWidget.addWidget(self.songsOfFellowshipPage) self.formatStackedWidget.addWidget(self.songsOfFellowshipPage)
# Generic Document/Presentation import # Generic Document/Presentation import
self.genericPage = QtGui.QWidget() self.genericPage = QtGui.QWidget()
self.genericPage.setObjectName(u'genericPage') self.genericPage.setObjectName(u'genericPage')
self.genericLayout = QtGui.QFormLayout(self.genericPage) self.genericLayout = QtGui.QVBoxLayout(self.genericPage)
self.genericLayout.setMargin(0) self.genericLayout.setMargin(0)
self.genericLayout.setSpacing(8) self.genericLayout.setSpacing(8)
self.genericLayout.setObjectName(u'genericLayout') self.genericLayout.setObjectName(u'genericLayout')
self.genericFilenameLabel = QtGui.QLabel(self.genericPage) self.genericFileListWidget = QtGui.QListWidget(self.genericPage)
self.genericFilenameLabel.setObjectName(u'genericFilenameLabel') self.genericFileListWidget.setSelectionMode(
self.genericLayout.setWidget(0, QtGui.QFormLayout.LabelRole, QtGui.QAbstractItemView.ExtendedSelection)
self.genericFilenameLabel) self.genericFileListWidget.setObjectName(u'genericFileListWidget')
self.genericFileLayout = QtGui.QHBoxLayout() self.genericLayout.addWidget(self.genericFileListWidget)
self.genericFileLayout.setSpacing(8) self.genericButtonLayout = QtGui.QHBoxLayout()
self.genericFileLayout.setObjectName(u'genericFileLayout') self.genericButtonLayout.setSpacing(8)
self.genericFilenameEdit = QtGui.QLineEdit(self.genericPage) self.genericButtonLayout.setObjectName(u'genericButtonLayout')
self.genericFilenameEdit.setObjectName(u'genericFilenameEdit') self.genericAddButton = QtGui.QPushButton(self.genericPage)
self.genericFileLayout.addWidget(self.genericFilenameEdit) self.genericAddButton.setIcon(openIcon)
self.genericBrowseButton = QtGui.QToolButton(self.genericPage) self.genericAddButton.setObjectName(u'genericAddButton')
self.genericBrowseButton.setIcon(openIcon) self.genericButtonLayout.addWidget(self.genericAddButton)
self.genericBrowseButton.setObjectName(u'genericBrowseButton') self.genericButtonSpacer = QtGui.QSpacerItem(40, 20,
self.genericFileLayout.addWidget(self.genericBrowseButton) QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.genericLayout.setLayout(0, QtGui.QFormLayout.FieldRole, self.genericButtonLayout.addItem(self.genericButtonSpacer)
self.genericFileLayout) self.genericRemoveButton = QtGui.QPushButton(self.genericPage)
self.genericRemoveButton.setIcon(deleteIcon)
self.genericRemoveButton.setObjectName(u'genericRemoveButton')
self.genericButtonLayout.addWidget(self.genericRemoveButton)
self.genericLayout.addLayout(self.genericButtonLayout)
self.formatStackedWidget.addWidget(self.genericPage) self.formatStackedWidget.addWidget(self.genericPage)
# Commented out for future use. # Commented out for future use.
# self.csvPage = QtGui.QWidget() # self.csvPage = QtGui.QWidget()
@ -382,18 +370,18 @@ class Ui_SongImportWizard(object):
def retranslateUi(self, songImportWizard): def retranslateUi(self, songImportWizard):
songImportWizard.setWindowTitle( songImportWizard.setWindowTitle(
translate('SongsPlugin.ImportWizardForm', 'Song import Wizard')) translate('SongsPlugin.ImportWizardForm', 'Song Import Wizard'))
self.titleLabel.setText( self.titleLabel.setText(
u'<span style="font-size:14pt; font-weight:600;">%s</span>' % \ u'<span style="font-size:14pt; font-weight:600;">%s</span>' % \
translate('SongsPlugin.ImportWizardForm', translate('SongsPlugin.ImportWizardForm',
'Welcome to the Song import Wizard')) 'Welcome to the Song Import Wizard'))
self.informationLabel.setText( self.informationLabel.setText(
translate('SongsPlugin.ImportWizardForm', translate('SongsPlugin.ImportWizardForm',
'This wizard will help you to import songs from a variety of ' 'This wizard will help you to import songs from a variety of '
'formats. Click the next button below to start the process by ' 'formats. Click the next button below to start the process by '
'selecting a format to import from.')) 'selecting a format to import from.'))
self.sourcePage.setTitle( self.sourcePage.setTitle(
translate('SongsPlugin.ImportWizardForm', 'Select import Source')) translate('SongsPlugin.ImportWizardForm', 'Select Import Source'))
self.sourcePage.setSubTitle( self.sourcePage.setSubTitle(
translate('SongsPlugin.ImportWizardForm', translate('SongsPlugin.ImportWizardForm',
'Select the import format, and where to import from.')) 'Select the import format, and where to import from.'))
@ -410,7 +398,7 @@ class Ui_SongImportWizard(object):
self.formatComboBox.setItemText(4, self.formatComboBox.setItemText(4,
translate('SongsPlugin.ImportWizardForm', 'Words of Worship')) translate('SongsPlugin.ImportWizardForm', 'Words of Worship'))
self.formatComboBox.setItemText(5, self.formatComboBox.setItemText(5,
translate('SongsPlugin.ImportWizardForm', 'CCLI')) translate('SongsPlugin.ImportWizardForm', 'CCLI/SongSelect'))
self.formatComboBox.setItemText(6, self.formatComboBox.setItemText(6,
translate('SongsPlugin.ImportWizardForm', 'Songs of Fellowship')) translate('SongsPlugin.ImportWizardForm', 'Songs of Fellowship'))
self.formatComboBox.setItemText(7, self.formatComboBox.setItemText(7,
@ -446,16 +434,16 @@ class Ui_SongImportWizard(object):
translate('SongsPlugin.ImportWizardForm', 'Add Files...')) translate('SongsPlugin.ImportWizardForm', 'Add Files...'))
self.songsOfFellowshipRemoveButton.setText( self.songsOfFellowshipRemoveButton.setText(
translate('SongsPlugin.ImportWizardForm', 'Remove File(s)')) translate('SongsPlugin.ImportWizardForm', 'Remove File(s)'))
self.genericFilenameLabel.setText( self.genericAddButton.setText(
translate('SongsPlugin.ImportWizardForm', 'Filename:')) translate('SongsPlugin.ImportWizardForm', 'Add Files...'))
self.genericBrowseButton.setText( self.genericRemoveButton.setText(
translate('SongsPlugin.ImportWizardForm', 'Browse...')) translate('SongsPlugin.ImportWizardForm', 'Remove File(s)'))
# self.csvFilenameLabel.setText( # self.csvFilenameLabel.setText(
# translate('SongsPlugin.ImportWizardForm', 'Filename:')) # translate('SongsPlugin.ImportWizardForm', 'Filename:'))
# self.csvBrowseButton.setText( # self.csvBrowseButton.setText(
# translate('SongsPlugin.ImportWizardForm', 'Browse...')) # translate('SongsPlugin.ImportWizardForm', 'Browse...'))
self.importPage.setTitle( self.importPage.setTitle(
translate('SongsPlugin.ImportWizardForm', 'importing')) translate('SongsPlugin.ImportWizardForm', 'Importing'))
self.importPage.setSubTitle( self.importPage.setSubTitle(
translate('SongsPlugin.ImportWizardForm', translate('SongsPlugin.ImportWizardForm',
'Please wait while your songs are imported.')) 'Please wait while your songs are imported.'))

View File

@ -85,6 +85,7 @@ class OpenLPSongImport(SongImport):
``source_db`` ``source_db``
The database providing the data to import. The database providing the data to import.
""" """
SongImport.__init__(self, master_manager)
self.master_manager = master_manager self.master_manager = master_manager
self.import_source = u'sqlite:///%s' % kwargs[u'filename'] self.import_source = u'sqlite:///%s' % kwargs[u'filename']
log.debug(self.import_source) log.debug(self.import_source)