forked from openlp/openlp
Mostly complete attempt at refactor. Tidy ups needed.
This commit is contained in:
parent
b909d27b3b
commit
465aecc61c
@ -36,7 +36,8 @@ from PyQt4 import QtCore, QtGui
|
||||
from openlp.core.lib import Receiver, SettingsManager, translate
|
||||
from openlp.core.lib.ui import UiStrings, critical_error_message_box
|
||||
from openlp.core.ui.wizard import OpenLPWizard, WizardStrings
|
||||
from openlp.plugins.songs.lib.importer import SongFormat
|
||||
from openlp.plugins.songs.lib.importer import SongFormat, SongFormatAttribute, \
|
||||
SongFormatSelect
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@ -58,6 +59,8 @@ class SongImportForm(OpenLPWizard):
|
||||
The songs plugin.
|
||||
"""
|
||||
self.clipboard = plugin.formParent.clipboard
|
||||
self.activeFormat = None
|
||||
self.formatWidgets = dict([(f, {}) for f in SongFormat.get_formats()])
|
||||
OpenLPWizard.__init__(self, parent, plugin, u'songImportWizard',
|
||||
u':/wizards/wizard_importsong.bmp')
|
||||
|
||||
@ -66,7 +69,8 @@ class SongImportForm(OpenLPWizard):
|
||||
Set up the song wizard UI.
|
||||
"""
|
||||
OpenLPWizard.setupUi(self, image)
|
||||
self.formatStack.setCurrentIndex(0)
|
||||
self.activeFormat = SongFormat.OpenLyrics
|
||||
self.formatStack.setCurrentIndex(self.activeFormat)
|
||||
QtCore.QObject.connect(self.formatComboBox,
|
||||
QtCore.SIGNAL(u'currentIndexChanged(int)'),
|
||||
self.onCurrentIndexChanged)
|
||||
@ -77,103 +81,39 @@ class SongImportForm(OpenLPWizard):
|
||||
the import is available and accordingly to disable or enable the next
|
||||
button.
|
||||
"""
|
||||
self.formatStack.setCurrentIndex(index)
|
||||
self.activeFormat = index
|
||||
self.formatStack.setCurrentIndex(self.activeFormat)
|
||||
next_button = self.button(QtGui.QWizard.NextButton)
|
||||
next_button.setEnabled(SongFormat.get_availability(index))
|
||||
next_button.setEnabled(SongFormatAttribute.get(self.activeFormat,
|
||||
SongFormatAttribute.availability))
|
||||
|
||||
def customInit(self):
|
||||
"""
|
||||
Song wizard specific initialisation.
|
||||
"""
|
||||
if not SongFormat.get_availability(SongFormat.OpenLP1):
|
||||
self.openLP1DisabledWidget.setVisible(True)
|
||||
self.openLP1ImportWidget.setVisible(False)
|
||||
if not SongFormat.get_availability(SongFormat.SongsOfFellowship):
|
||||
self.songsOfFellowshipDisabledWidget.setVisible(True)
|
||||
self.songsOfFellowshipImportWidget.setVisible(False)
|
||||
if not SongFormat.get_availability(SongFormat.Generic):
|
||||
self.genericDisabledWidget.setVisible(True)
|
||||
self.genericImportWidget.setVisible(False)
|
||||
for format in SongFormat.get_formats():
|
||||
if not SongFormatAttribute.get(format,
|
||||
SongFormatAttribute.availability):
|
||||
self.formatWidgets[format][u'disabledWidget'].setVisible(True)
|
||||
self.formatWidgets[format][u'importWidget'].setVisible(False)
|
||||
|
||||
def customSignals(self):
|
||||
"""
|
||||
Song wizard specific signals.
|
||||
"""
|
||||
QtCore.QObject.connect(self.openLP2BrowseButton,
|
||||
QtCore.SIGNAL(u'clicked()'),
|
||||
self.onOpenLP2BrowseButtonClicked)
|
||||
QtCore.QObject.connect(self.openLP1BrowseButton,
|
||||
QtCore.SIGNAL(u'clicked()'),
|
||||
self.onOpenLP1BrowseButtonClicked)
|
||||
QtCore.QObject.connect(self.powerSongBrowseButton,
|
||||
QtCore.SIGNAL(u'clicked()'),
|
||||
self.onPowerSongBrowseButtonClicked)
|
||||
QtCore.QObject.connect(self.openLyricsAddButton,
|
||||
QtCore.SIGNAL(u'clicked()'),
|
||||
self.onOpenLyricsAddButtonClicked)
|
||||
QtCore.QObject.connect(self.openLyricsRemoveButton,
|
||||
QtCore.SIGNAL(u'clicked()'),
|
||||
self.onOpenLyricsRemoveButtonClicked)
|
||||
QtCore.QObject.connect(self.openSongAddButton,
|
||||
QtCore.SIGNAL(u'clicked()'),
|
||||
self.onOpenSongAddButtonClicked)
|
||||
QtCore.QObject.connect(self.openSongRemoveButton,
|
||||
QtCore.SIGNAL(u'clicked()'),
|
||||
self.onOpenSongRemoveButtonClicked)
|
||||
QtCore.QObject.connect(self.wordsOfWorshipAddButton,
|
||||
QtCore.SIGNAL(u'clicked()'),
|
||||
self.onWordsOfWorshipAddButtonClicked)
|
||||
QtCore.QObject.connect(self.wordsOfWorshipRemoveButton,
|
||||
QtCore.SIGNAL(u'clicked()'),
|
||||
self.onWordsOfWorshipRemoveButtonClicked)
|
||||
QtCore.QObject.connect(self.ccliAddButton,
|
||||
QtCore.SIGNAL(u'clicked()'),
|
||||
self.onCCLIAddButtonClicked)
|
||||
QtCore.QObject.connect(self.ccliRemoveButton,
|
||||
QtCore.SIGNAL(u'clicked()'),
|
||||
self.onCCLIRemoveButtonClicked)
|
||||
QtCore.QObject.connect(self.dreamBeamAddButton,
|
||||
QtCore.SIGNAL(u'clicked()'),
|
||||
self.onDreamBeamAddButtonClicked)
|
||||
QtCore.QObject.connect(self.dreamBeamRemoveButton,
|
||||
QtCore.SIGNAL(u'clicked()'),
|
||||
self.onDreamBeamRemoveButtonClicked)
|
||||
QtCore.QObject.connect(self.songsOfFellowshipAddButton,
|
||||
QtCore.SIGNAL(u'clicked()'),
|
||||
self.onSongsOfFellowshipAddButtonClicked)
|
||||
QtCore.QObject.connect(self.songsOfFellowshipRemoveButton,
|
||||
QtCore.SIGNAL(u'clicked()'),
|
||||
self.onSongsOfFellowshipRemoveButtonClicked)
|
||||
QtCore.QObject.connect(self.genericAddButton,
|
||||
QtCore.SIGNAL(u'clicked()'),
|
||||
self.onGenericAddButtonClicked)
|
||||
QtCore.QObject.connect(self.genericRemoveButton,
|
||||
QtCore.SIGNAL(u'clicked()'),
|
||||
self.onGenericRemoveButtonClicked)
|
||||
QtCore.QObject.connect(self.easySlidesBrowseButton,
|
||||
QtCore.SIGNAL(u'clicked()'),
|
||||
self.onEasySlidesBrowseButtonClicked)
|
||||
QtCore.QObject.connect(self.ewBrowseButton,
|
||||
QtCore.SIGNAL(u'clicked()'),
|
||||
self.onEWBrowseButtonClicked)
|
||||
QtCore.QObject.connect(self.songBeamerAddButton,
|
||||
QtCore.SIGNAL(u'clicked()'),
|
||||
self.onSongBeamerAddButtonClicked)
|
||||
QtCore.QObject.connect(self.songBeamerRemoveButton,
|
||||
QtCore.SIGNAL(u'clicked()'),
|
||||
self.onSongBeamerRemoveButtonClicked)
|
||||
QtCore.QObject.connect(self.songShowPlusAddButton,
|
||||
QtCore.SIGNAL(u'clicked()'),
|
||||
self.onSongShowPlusAddButtonClicked)
|
||||
QtCore.QObject.connect(self.songShowPlusRemoveButton,
|
||||
QtCore.SIGNAL(u'clicked()'),
|
||||
self.onSongShowPlusRemoveButtonClicked)
|
||||
QtCore.QObject.connect(self.foilPresenterAddButton,
|
||||
QtCore.SIGNAL(u'clicked()'),
|
||||
self.onFoilPresenterAddButtonClicked)
|
||||
QtCore.QObject.connect(self.foilPresenterRemoveButton,
|
||||
QtCore.SIGNAL(u'clicked()'),
|
||||
self.onFoilPresenterRemoveButtonClicked)
|
||||
for format in SongFormat.get_formats():
|
||||
select_mode = SongFormatAttribute.get(format,
|
||||
SongFormatAttribute.select_mode)
|
||||
if select_mode == SongFormatSelect.MultipleFiles:
|
||||
QtCore.QObject.connect(self.formatWidgets[format][u'addButton'],
|
||||
QtCore.SIGNAL(u'clicked()'), self.onAddButtonClicked)
|
||||
QtCore.QObject.connect(
|
||||
self.formatWidgets[format][u'removeButton'],
|
||||
QtCore.SIGNAL(u'clicked()'), self.onRemoveButtonClicked)
|
||||
else:
|
||||
QtCore.QObject.connect(
|
||||
self.formatWidgets[format][u'browseButton'],
|
||||
QtCore.SIGNAL(u'clicked()'), self.onBrowseButtonClicked)
|
||||
|
||||
def addCustomPages(self):
|
||||
"""
|
||||
@ -200,38 +140,9 @@ class SongImportForm(OpenLPWizard):
|
||||
QtGui.QSizePolicy.Expanding)
|
||||
self.formatStack = QtGui.QStackedLayout()
|
||||
self.formatStack.setObjectName(u'FormatStack')
|
||||
# OpenLyrics
|
||||
self.addFileSelectItem(u'openLyrics', u'OpenLyrics', True)
|
||||
# OpenLP 2.0
|
||||
self.addFileSelectItem(u'openLP2', single_select=True)
|
||||
# openlp.org 1.x
|
||||
self.addFileSelectItem(u'openLP1', None, True, True)
|
||||
# Generic Document/Presentation import
|
||||
self.addFileSelectItem(u'generic', None, True)
|
||||
# CCLI File import
|
||||
self.addFileSelectItem(u'ccli')
|
||||
# DreamBeam
|
||||
self.addFileSelectItem(u'dreamBeam')
|
||||
# EasySlides
|
||||
self.addFileSelectItem(u'easySlides', single_select=True)
|
||||
# EasyWorship
|
||||
self.addFileSelectItem(u'ew', single_select=True)
|
||||
# Foilpresenter
|
||||
self.addFileSelectItem(u'foilPresenter')
|
||||
# Open Song
|
||||
self.addFileSelectItem(u'openSong', u'OpenSong')
|
||||
# PowerSong
|
||||
self.addFileSelectItem(u'powerSong', single_select=True)
|
||||
# SongBeamer
|
||||
self.addFileSelectItem(u'songBeamer')
|
||||
# Song Show Plus
|
||||
self.addFileSelectItem(u'songShowPlus')
|
||||
# Songs of Fellowship
|
||||
self.addFileSelectItem(u'songsOfFellowship', None, True)
|
||||
# Words of Worship
|
||||
self.addFileSelectItem(u'wordsOfWorship')
|
||||
# Commented out for future use.
|
||||
# self.addFileSelectItem(u'csv', u'CSV', single_select=True)
|
||||
self.disablableFormats = []
|
||||
for self.activeFormat in SongFormat.get_formats():
|
||||
self.addFileSelectItem()
|
||||
self.sourceLayout.addLayout(self.formatStack)
|
||||
self.addPage(self.sourcePage)
|
||||
|
||||
@ -251,107 +162,31 @@ class SongImportForm(OpenLPWizard):
|
||||
self.sourcePage.setTitle(WizardStrings.ImportSelect)
|
||||
self.sourcePage.setSubTitle(WizardStrings.ImportSelectLong)
|
||||
self.formatLabel.setText(WizardStrings.FormatLabel)
|
||||
self.formatComboBox.setItemText(SongFormat.OpenLyrics,
|
||||
translate('SongsPlugin.ImportWizardForm',
|
||||
'OpenLyrics or OpenLP 2.0 Exported Song'))
|
||||
self.formatComboBox.setItemText(SongFormat.OpenLP2, UiStrings().OLPV2)
|
||||
self.formatComboBox.setItemText(SongFormat.OpenLP1, UiStrings().OLPV1)
|
||||
self.formatComboBox.setItemText(SongFormat.Generic,
|
||||
translate('SongsPlugin.ImportWizardForm',
|
||||
'Generic Document/Presentation'))
|
||||
self.formatComboBox.setItemText(SongFormat.CCLI, WizardStrings.CCLI)
|
||||
self.formatComboBox.setItemText(
|
||||
SongFormat.DreamBeam, WizardStrings.DB)
|
||||
self.formatComboBox.setItemText(
|
||||
SongFormat.EasySlides, WizardStrings.ES)
|
||||
self.formatComboBox.setItemText(
|
||||
SongFormat.EasyWorship, WizardStrings.EW)
|
||||
self.formatComboBox.setItemText(
|
||||
SongFormat.FoilPresenter, WizardStrings.FP)
|
||||
self.formatComboBox.setItemText(SongFormat.OpenSong, WizardStrings.OS)
|
||||
self.formatComboBox.setItemText(
|
||||
SongFormat.PowerSong, WizardStrings.PS)
|
||||
self.formatComboBox.setItemText(
|
||||
SongFormat.SongBeamer, WizardStrings.SB)
|
||||
self.formatComboBox.setItemText(
|
||||
SongFormat.SongShowPlus, WizardStrings.SSP)
|
||||
self.formatComboBox.setItemText(
|
||||
SongFormat.SongsOfFellowship, WizardStrings.SoF)
|
||||
self.formatComboBox.setItemText(
|
||||
SongFormat.WordsOfWorship, WizardStrings.WoW)
|
||||
# self.formatComboBox.setItemText(SongFormat.CSV, WizardStrings.CSV)
|
||||
self.openLP2FilenameLabel.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Filename:'))
|
||||
self.openLP2BrowseButton.setText(UiStrings().Browse)
|
||||
self.openLP1FilenameLabel.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Filename:'))
|
||||
self.openLP1BrowseButton.setText(UiStrings().Browse)
|
||||
self.openLP1DisabledLabel.setText(WizardStrings.NoSqlite)
|
||||
self.powerSongFilenameLabel.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Folder:'))
|
||||
self.powerSongBrowseButton.setText(UiStrings().Browse)
|
||||
self.openLyricsAddButton.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Add Files...'))
|
||||
self.openLyricsRemoveButton.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Remove File(s)'))
|
||||
self.openLyricsDisabledLabel.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'The OpenLyrics '
|
||||
'importer has not yet been developed, but as you can see, we are '
|
||||
'still intending to do so. Hopefully it will be in the next '
|
||||
'release.'))
|
||||
self.openSongAddButton.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Add Files...'))
|
||||
self.openSongRemoveButton.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Remove File(s)'))
|
||||
self.wordsOfWorshipAddButton.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Add Files...'))
|
||||
self.wordsOfWorshipRemoveButton.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Remove File(s)'))
|
||||
self.ccliAddButton.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Add Files...'))
|
||||
self.ccliRemoveButton.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Remove File(s)'))
|
||||
self.dreamBeamAddButton.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Add Files...'))
|
||||
self.dreamBeamRemoveButton.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Remove File(s)'))
|
||||
self.songsOfFellowshipAddButton.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Add Files...'))
|
||||
self.songsOfFellowshipRemoveButton.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Remove File(s)'))
|
||||
self.songsOfFellowshipDisabledLabel.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'The Songs of '
|
||||
'Fellowship importer has been disabled because OpenLP cannot '
|
||||
'access OpenOffice or LibreOffice.'))
|
||||
self.genericAddButton.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Add Files...'))
|
||||
self.genericRemoveButton.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Remove File(s)'))
|
||||
self.genericDisabledLabel.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'The generic document/'
|
||||
'presentation importer has been disabled because OpenLP cannot '
|
||||
'access OpenOffice or LibreOffice.'))
|
||||
self.easySlidesFilenameLabel.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Filename:'))
|
||||
self.easySlidesBrowseButton.setText(UiStrings().Browse)
|
||||
self.ewFilenameLabel.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Filename:'))
|
||||
self.ewBrowseButton.setText(UiStrings().Browse)
|
||||
self.songBeamerAddButton.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Add Files...'))
|
||||
self.songBeamerRemoveButton.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Remove File(s)'))
|
||||
self.songShowPlusAddButton.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Add Files...'))
|
||||
self.songShowPlusRemoveButton.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Remove File(s)'))
|
||||
self.foilPresenterAddButton.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Add Files...'))
|
||||
self.foilPresenterRemoveButton.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Remove File(s)'))
|
||||
# self.csvFilenameLabel.setText(
|
||||
# translate('SongsPlugin.ImportWizardForm', 'Filename:'))
|
||||
# self.csvBrowseButton.setText(UiStrings().Browse)
|
||||
|
||||
for format in SongFormat.get_formats():
|
||||
self.formatComboBox.setItemText(format, SongFormatAttribute.get(
|
||||
format, SongFormatAttribute.combo_box_text))
|
||||
select_mode = SongFormatAttribute.get(format,
|
||||
SongFormatAttribute.select_mode)
|
||||
if select_mode == SongFormatSelect.MultipleFiles:
|
||||
self.formatWidgets[format][u'addButton'].setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Add Files...'))
|
||||
self.formatWidgets[format][u'removeButton'].setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Remove File(s)'))
|
||||
else:
|
||||
if select_mode == SongFormatSelect.SingleFile:
|
||||
label = 'Filename:'
|
||||
elif select_mode == SongFormatSelect.SingleFolder:
|
||||
label = 'Folder:'
|
||||
self.formatWidgets[format][u'browseButton'].setText(
|
||||
UiStrings().Browse)
|
||||
self.formatWidgets[format][u'filepathLabel'].setText(
|
||||
translate('SongsPlugin.ImportWizardForm', label))
|
||||
for format in self.disablableFormats:
|
||||
self.formatWidgets[format][u'disabledLabel'].setText(
|
||||
SongFormatAttribute.get(format,
|
||||
SongFormatAttribute.disabled_label_text))
|
||||
|
||||
self.progressPage.setTitle(WizardStrings.Importing)
|
||||
self.progressPage.setSubTitle(
|
||||
translate('SongsPlugin.ImportWizardForm',
|
||||
@ -382,104 +217,48 @@ class SongImportForm(OpenLPWizard):
|
||||
if self.currentPage() == self.welcomePage:
|
||||
return True
|
||||
elif self.currentPage() == self.sourcePage:
|
||||
source_format = self.formatComboBox.currentIndex()
|
||||
#source_format = self.formatComboBox.currentIndex()
|
||||
format = self.activeFormat
|
||||
QtCore.QSettings().setValue(u'songs/last import type',
|
||||
source_format)
|
||||
import_class = SongFormat.get_class(source_format)
|
||||
if source_format == SongFormat.OpenLP2:
|
||||
if self.openLP2FilenameEdit.text().isEmpty():
|
||||
critical_error_message_box(UiStrings().NFSs,
|
||||
WizardStrings.YouSpecifyFile % UiStrings().OLPV2)
|
||||
self.openLP2BrowseButton.setFocus()
|
||||
format)
|
||||
select_mode = SongFormatAttribute.get(format,
|
||||
SongFormatAttribute.select_mode)
|
||||
format_name = SongFormatAttribute.get(format,
|
||||
SongFormatAttribute.name)
|
||||
class_ = SongFormatAttribute.get(format,
|
||||
SongFormatAttribute.class_)
|
||||
if select_mode == SongFormatSelect.MultipleFiles:
|
||||
fileListWidget = self.formatWidgets[format][u'fileListWidget']
|
||||
if fileListWidget.count() == 0 or not class_.isValidSource(
|
||||
filenames=self.getListOfFiles(fileListWidget)):
|
||||
critical_error_message_box(UiStrings().NFSp,
|
||||
WizardStrings.YouSpecifyFile % format_name)
|
||||
self.formatWidgets[format][u'addButton'].setFocus()
|
||||
return False
|
||||
elif source_format == SongFormat.OpenLP1:
|
||||
if self.openLP1FilenameEdit.text().isEmpty():
|
||||
elif select_mode == SongFormatSelect.SingleFile:
|
||||
filepathEdit = self.formatWidgets[format][u'filepathEdit']
|
||||
if filepathEdit.text().isEmpty() or not class_.isValidSource(
|
||||
filename=filepathEdit.text()):
|
||||
critical_error_message_box(UiStrings().NFSs,
|
||||
WizardStrings.YouSpecifyFile % UiStrings().OLPV1)
|
||||
self.openLP1BrowseButton.setFocus()
|
||||
WizardStrings.YouSpecifyFile % format_name)
|
||||
self.formatWidgets[format][u'browseButton'].setFocus()
|
||||
return False
|
||||
elif source_format == SongFormat.PowerSong:
|
||||
if self.powerSongFilenameEdit.text().isEmpty() or \
|
||||
not import_class.isValidSource(
|
||||
folder=self.powerSongFilenameEdit.text()):
|
||||
elif select_mode == SongFormatSelect.SingleFolder:
|
||||
filepathEdit = self.formatWidgets[format][u'filepathEdit']
|
||||
if filepathEdit.text().isEmpty() or not class_.isValidSource(
|
||||
folder=filepathEdit.text()):
|
||||
critical_error_message_box(UiStrings().NFdSs,
|
||||
WizardStrings.YouSpecifyFolder % WizardStrings.PS)
|
||||
self.powerSongBrowseButton.setFocus()
|
||||
return False
|
||||
elif source_format == SongFormat.OpenLyrics:
|
||||
if self.openLyricsFileListWidget.count() == 0:
|
||||
critical_error_message_box(UiStrings().NFSp,
|
||||
WizardStrings.YouSpecifyFile % WizardStrings.OL)
|
||||
self.openLyricsAddButton.setFocus()
|
||||
return False
|
||||
elif source_format == SongFormat.OpenSong:
|
||||
if self.openSongFileListWidget.count() == 0:
|
||||
critical_error_message_box(UiStrings().NFSp,
|
||||
WizardStrings.YouSpecifyFile % WizardStrings.OS)
|
||||
self.openSongAddButton.setFocus()
|
||||
return False
|
||||
elif source_format == SongFormat.WordsOfWorship:
|
||||
if self.wordsOfWorshipFileListWidget.count() == 0:
|
||||
critical_error_message_box(UiStrings().NFSp,
|
||||
WizardStrings.YouSpecifyFile % WizardStrings.WoW)
|
||||
self.wordsOfWorshipAddButton.setFocus()
|
||||
return False
|
||||
elif source_format == SongFormat.CCLI:
|
||||
if self.ccliFileListWidget.count() == 0:
|
||||
critical_error_message_box(UiStrings().NFSp,
|
||||
WizardStrings.YouSpecifyFile % WizardStrings.CCLI)
|
||||
self.ccliAddButton.setFocus()
|
||||
return False
|
||||
elif source_format == SongFormat.DreamBeam:
|
||||
if self.dreamBeamFileListWidget.count() == 0:
|
||||
critical_error_message_box(UiStrings().NFSp,
|
||||
WizardStrings.YouSpecifyFile % WizardStrings.DB)
|
||||
self.dreamBeamAddButton.setFocus()
|
||||
return False
|
||||
elif source_format == SongFormat.SongsOfFellowship:
|
||||
if self.songsOfFellowshipFileListWidget.count() == 0:
|
||||
critical_error_message_box(UiStrings().NFSp,
|
||||
WizardStrings.YouSpecifyFile % WizardStrings.SoF)
|
||||
self.songsOfFellowshipAddButton.setFocus()
|
||||
return False
|
||||
elif source_format == SongFormat.Generic:
|
||||
if self.genericFileListWidget.count() == 0:
|
||||
critical_error_message_box(UiStrings().NFSp,
|
||||
translate('SongsPlugin.ImportWizardForm',
|
||||
'You need to specify at least one document or '
|
||||
'presentation file to import from.'))
|
||||
self.genericAddButton.setFocus()
|
||||
return False
|
||||
elif source_format == SongFormat.EasySlides:
|
||||
if self.easySlidesFilenameEdit.text().isEmpty():
|
||||
critical_error_message_box(UiStrings().NFSp,
|
||||
WizardStrings.YouSpecifyFile % WizardStrings.ES)
|
||||
self.easySlidesBrowseButton.setFocus()
|
||||
return False
|
||||
elif source_format == SongFormat.EasyWorship:
|
||||
if self.ewFilenameEdit.text().isEmpty():
|
||||
critical_error_message_box(UiStrings().NFSs,
|
||||
WizardStrings.YouSpecifyFile % WizardStrings.EW)
|
||||
self.ewBrowseButton.setFocus()
|
||||
return False
|
||||
elif source_format == SongFormat.SongBeamer:
|
||||
if self.songBeamerFileListWidget.count() == 0:
|
||||
critical_error_message_box(UiStrings().NFSp,
|
||||
WizardStrings.YouSpecifyFile % WizardStrings.SB)
|
||||
self.songBeamerAddButton.setFocus()
|
||||
return False
|
||||
elif source_format == SongFormat.SongShowPlus:
|
||||
if self.songShowPlusFileListWidget.count() == 0:
|
||||
critical_error_message_box(UiStrings().NFSp,
|
||||
WizardStrings.YouSpecifyFile % WizardStrings.SSP)
|
||||
self.songShowPlusAddButton.setFocus()
|
||||
return False
|
||||
elif source_format == SongFormat.FoilPresenter:
|
||||
if self.foilPresenterFileListWidget.count() == 0:
|
||||
critical_error_message_box(UiStrings().NFSp,
|
||||
WizardStrings.YouSpecifyFile % WizardStrings.FP)
|
||||
self.foilPresenterAddButton.setFocus()
|
||||
WizardStrings.YouSpecifyFolder % format_name)
|
||||
self.formatWidgets[format][u'browseButton'].setFocus()
|
||||
return False
|
||||
# elif source_format == SongFormat.Generic:
|
||||
# if self.genericFileListWidget.count() == 0:
|
||||
# critical_error_message_box(UiStrings().NFSp,
|
||||
# translate('SongsPlugin.ImportWizardForm',
|
||||
# 'You need to specify at least one document or '
|
||||
# 'presentation file to import from.'))
|
||||
# self.genericAddButton.setFocus()
|
||||
# return False
|
||||
return True
|
||||
elif self.currentPage() == self.progressPage:
|
||||
return True
|
||||
@ -525,203 +304,46 @@ class SongImportForm(OpenLPWizard):
|
||||
item = listbox.takeItem(listbox.row(item))
|
||||
del item
|
||||
|
||||
def onOpenLP2BrowseButtonClicked(self):
|
||||
"""
|
||||
Get OpenLP v2 song database file
|
||||
"""
|
||||
self.getFileName(WizardStrings.OpenTypeFile % UiStrings().OLPV2,
|
||||
self.openLP2FilenameEdit, u'%s (*.sqlite)'
|
||||
% (translate('SongsPlugin.ImportWizardForm',
|
||||
'OpenLP 2.0 Databases'))
|
||||
)
|
||||
def onBrowseButtonClicked(self):
|
||||
format = self.activeFormat
|
||||
select_mode = SongFormatAttribute.get(format,
|
||||
SongFormatAttribute.select_mode)
|
||||
name = SongFormatAttribute.get(format,
|
||||
SongFormatAttribute.name)
|
||||
filter = SongFormatAttribute.get(format,
|
||||
SongFormatAttribute.filter)
|
||||
filepathEdit = self.formatWidgets[format][u'filepathEdit']
|
||||
if select_mode == SongFormatSelect.SingleFile:
|
||||
self.getFileName(WizardStrings.OpenTypeFile % name, filepathEdit,
|
||||
filter)
|
||||
elif select_mode == SongFormatSelect.SingleFolder:
|
||||
self.getFolder(WizardStrings.OpenTypeFile % name, filepathEdit)
|
||||
|
||||
def onOpenLP1BrowseButtonClicked(self):
|
||||
"""
|
||||
Get OpenLP v1 song database file
|
||||
"""
|
||||
self.getFileName(WizardStrings.OpenTypeFile % UiStrings().OLPV1,
|
||||
self.openLP1FilenameEdit, u'%s (*.olp)'
|
||||
% translate('SongsPlugin.ImportWizardForm',
|
||||
'openlp.org v1.x Databases')
|
||||
)
|
||||
def onAddButtonClicked(self):
|
||||
format = self.activeFormat
|
||||
select_mode = SongFormatAttribute.get(format,
|
||||
SongFormatAttribute.select_mode)
|
||||
name = SongFormatAttribute.get(format,
|
||||
SongFormatAttribute.name)
|
||||
filter = SongFormatAttribute.get(format,
|
||||
SongFormatAttribute.filter)
|
||||
if select_mode == SongFormatSelect.MultipleFiles:
|
||||
self.getFiles(WizardStrings.OpenTypeFile % name,
|
||||
self.formatWidgets[format][u'FileListWidget'], filter)
|
||||
|
||||
def onPowerSongBrowseButtonClicked(self):
|
||||
"""
|
||||
Get PowerSong song database folder
|
||||
"""
|
||||
self.getFolder(WizardStrings.OpenTypeFolder % WizardStrings.PS,
|
||||
self.powerSongFilenameEdit)
|
||||
def onRemoveButtonClicked(self):
|
||||
self.removeSelectedItems(
|
||||
self.formatWidgets[self.activeFormat][u'FileListWidget'])
|
||||
|
||||
def onOpenLyricsAddButtonClicked(self):
|
||||
"""
|
||||
Get OpenLyrics song database files
|
||||
"""
|
||||
self.getFiles(WizardStrings.OpenTypeFile % WizardStrings.OL,
|
||||
self.openLyricsFileListWidget, u'%s (*.xml)' %
|
||||
translate('SongsPlugin.ImportWizardForm', 'OpenLyrics Files'))
|
||||
|
||||
def onOpenLyricsRemoveButtonClicked(self):
|
||||
"""
|
||||
Remove selected OpenLyrics files from the import list
|
||||
"""
|
||||
self.removeSelectedItems(self.openLyricsFileListWidget)
|
||||
|
||||
def onOpenSongAddButtonClicked(self):
|
||||
"""
|
||||
Get OpenSong song database files
|
||||
"""
|
||||
self.getFiles(WizardStrings.OpenTypeFile % WizardStrings.OS,
|
||||
self.openSongFileListWidget)
|
||||
|
||||
def onOpenSongRemoveButtonClicked(self):
|
||||
"""
|
||||
Remove selected OpenSong files from the import list
|
||||
"""
|
||||
self.removeSelectedItems(self.openSongFileListWidget)
|
||||
|
||||
def onWordsOfWorshipAddButtonClicked(self):
|
||||
"""
|
||||
Get Words of Worship song database files
|
||||
"""
|
||||
self.getFiles(WizardStrings.OpenTypeFile % WizardStrings.WoW,
|
||||
self.wordsOfWorshipFileListWidget, u'%s (*.wsg *.wow-song)'
|
||||
% translate('SongsPlugin.ImportWizardForm',
|
||||
'Words Of Worship Song Files')
|
||||
)
|
||||
|
||||
def onWordsOfWorshipRemoveButtonClicked(self):
|
||||
"""
|
||||
Remove selected Words of Worship files from the import list
|
||||
"""
|
||||
self.removeSelectedItems(self.wordsOfWorshipFileListWidget)
|
||||
|
||||
def onCCLIAddButtonClicked(self):
|
||||
"""
|
||||
Get CCLI song database files
|
||||
"""
|
||||
self.getFiles(WizardStrings.OpenTypeFile % WizardStrings.CCLI,
|
||||
self.ccliFileListWidget, u'%s (*.usr *.txt)'
|
||||
% translate('SongsPlugin.ImportWizardForm',
|
||||
'CCLI SongSelect Files'))
|
||||
|
||||
def onCCLIRemoveButtonClicked(self):
|
||||
"""
|
||||
Remove selected CCLI files from the import list
|
||||
"""
|
||||
self.removeSelectedItems(self.ccliFileListWidget)
|
||||
|
||||
def onDreamBeamAddButtonClicked(self):
|
||||
"""
|
||||
Get DreamBeam song database files
|
||||
"""
|
||||
self.getFiles(WizardStrings.OpenTypeFile % WizardStrings.DB,
|
||||
self.dreamBeamFileListWidget, u'%s (*.xml)'
|
||||
% translate('SongsPlugin.ImportWizardForm',
|
||||
'DreamBeam Song Files')
|
||||
)
|
||||
|
||||
def onDreamBeamRemoveButtonClicked(self):
|
||||
"""
|
||||
Remove selected DreamBeam files from the import list
|
||||
"""
|
||||
self.removeSelectedItems(self.dreamBeamFileListWidget)
|
||||
|
||||
def onSongsOfFellowshipAddButtonClicked(self):
|
||||
"""
|
||||
Get Songs of Fellowship song database files
|
||||
"""
|
||||
self.getFiles(WizardStrings.OpenTypeFile % WizardStrings.SoF,
|
||||
self.songsOfFellowshipFileListWidget, u'%s (*.rtf)'
|
||||
% translate('SongsPlugin.ImportWizardForm',
|
||||
'Songs Of Fellowship Song Files')
|
||||
)
|
||||
|
||||
def onSongsOfFellowshipRemoveButtonClicked(self):
|
||||
"""
|
||||
Remove selected Songs of Fellowship files from the import list
|
||||
"""
|
||||
self.removeSelectedItems(self.songsOfFellowshipFileListWidget)
|
||||
|
||||
def onGenericAddButtonClicked(self):
|
||||
"""
|
||||
Get song database files
|
||||
"""
|
||||
self.getFiles(
|
||||
translate('SongsPlugin.ImportWizardForm',
|
||||
'Select Document/Presentation Files'),
|
||||
self.genericFileListWidget
|
||||
)
|
||||
|
||||
def onGenericRemoveButtonClicked(self):
|
||||
"""
|
||||
Remove selected files from the import list
|
||||
"""
|
||||
self.removeSelectedItems(self.genericFileListWidget)
|
||||
|
||||
def onEasySlidesBrowseButtonClicked(self):
|
||||
"""
|
||||
Get EasySlides song database file
|
||||
"""
|
||||
self.getFileName(WizardStrings.OpenTypeFile % WizardStrings.ES,
|
||||
self.easySlidesFilenameEdit, u'%s (*.xml)'
|
||||
% translate('SongsPlugin.ImportWizardForm',
|
||||
'EasySlides XML File'))
|
||||
|
||||
def onEWBrowseButtonClicked(self):
|
||||
"""
|
||||
Get EasyWorship song database files
|
||||
"""
|
||||
self.getFileName(WizardStrings.OpenTypeFile % WizardStrings.EW,
|
||||
self.ewFilenameEdit, u'%s (*.db)'
|
||||
% translate('SongsPlugin.ImportWizardForm',
|
||||
'EasyWorship Song Database'))
|
||||
|
||||
def onSongBeamerAddButtonClicked(self):
|
||||
"""
|
||||
Get SongBeamer song database files
|
||||
"""
|
||||
self.getFiles(WizardStrings.OpenTypeFile % WizardStrings.SB,
|
||||
self.songBeamerFileListWidget, u'%s (*.sng)' %
|
||||
translate('SongsPlugin.ImportWizardForm', 'SongBeamer Files')
|
||||
)
|
||||
|
||||
def onSongBeamerRemoveButtonClicked(self):
|
||||
"""
|
||||
Remove selected SongBeamer files from the import list
|
||||
"""
|
||||
self.removeSelectedItems(self.songBeamerFileListWidget)
|
||||
|
||||
def onSongShowPlusAddButtonClicked(self):
|
||||
"""
|
||||
Get SongShow Plus song database files
|
||||
"""
|
||||
self.getFiles(WizardStrings.OpenTypeFile % WizardStrings.SSP,
|
||||
self.songShowPlusFileListWidget, u'%s (*.sbsong)'
|
||||
% translate('SongsPlugin.ImportWizardForm',
|
||||
'SongShow Plus Song Files')
|
||||
)
|
||||
|
||||
def onSongShowPlusRemoveButtonClicked(self):
|
||||
"""
|
||||
Remove selected SongShow Plus files from the import list
|
||||
"""
|
||||
self.removeSelectedItems(self.songShowPlusFileListWidget)
|
||||
|
||||
def onFoilPresenterAddButtonClicked(self):
|
||||
"""
|
||||
Get FoilPresenter song database files
|
||||
"""
|
||||
self.getFiles(WizardStrings.OpenTypeFile % WizardStrings.FP,
|
||||
self.foilPresenterFileListWidget, u'%s (*.foil)'
|
||||
% translate('SongsPlugin.ImportWizardForm',
|
||||
'Foilpresenter Song Files')
|
||||
)
|
||||
|
||||
def onFoilPresenterRemoveButtonClicked(self):
|
||||
"""
|
||||
Remove selected FoilPresenter files from the import list
|
||||
"""
|
||||
self.removeSelectedItems(self.foilPresenterFileListWidget)
|
||||
# def onGenericAddButtonClicked(self):
|
||||
# """
|
||||
# Get song database files
|
||||
# """
|
||||
# self.getFiles(
|
||||
# translate('SongsPlugin.ImportWizardForm',
|
||||
# 'Select Document/Presentation Files'),
|
||||
# self.genericFileListWidget
|
||||
# )
|
||||
|
||||
def setDefaults(self):
|
||||
"""
|
||||
@ -736,22 +358,13 @@ class SongImportForm(OpenLPWizard):
|
||||
last_import_type >= self.formatComboBox.count():
|
||||
last_import_type = 0
|
||||
self.formatComboBox.setCurrentIndex(last_import_type)
|
||||
self.openLP2FilenameEdit.setText(u'')
|
||||
self.openLP1FilenameEdit.setText(u'')
|
||||
self.powerSongFilenameEdit.setText(u'')
|
||||
self.openLyricsFileListWidget.clear()
|
||||
self.openSongFileListWidget.clear()
|
||||
self.wordsOfWorshipFileListWidget.clear()
|
||||
self.ccliFileListWidget.clear()
|
||||
self.dreamBeamFileListWidget.clear()
|
||||
self.songsOfFellowshipFileListWidget.clear()
|
||||
self.genericFileListWidget.clear()
|
||||
self.easySlidesFilenameEdit.setText(u'')
|
||||
self.ewFilenameEdit.setText(u'')
|
||||
self.songBeamerFileListWidget.clear()
|
||||
self.songShowPlusFileListWidget.clear()
|
||||
self.foilPresenterFileListWidget.clear()
|
||||
#self.csvFilenameEdit.setText(u'')
|
||||
for format in SongFormat.get_formats():
|
||||
select_mode = SongFormatAttribute.get(format,
|
||||
SongFormatAttribute.select_mode)
|
||||
if select_mode == SongFormatSelect.MultipleFiles:
|
||||
self.formatWidgets[format][u'fileListWidget'].clear()
|
||||
else:
|
||||
self.formatWidgets[format][u'filepathEdit'].setText(u'')
|
||||
self.errorReportTextEdit.clear()
|
||||
self.errorReportTextEdit.setHidden(True)
|
||||
self.errorCopyToButton.setHidden(True)
|
||||
@ -771,87 +384,21 @@ class SongImportForm(OpenLPWizard):
|
||||
class, and then runs the ``doImport`` method of the importer to do
|
||||
the actual importing.
|
||||
"""
|
||||
source_format = self.formatComboBox.currentIndex()
|
||||
importer = None
|
||||
if source_format == SongFormat.OpenLP2:
|
||||
# Import an OpenLP 2.0 database
|
||||
importer = self.plugin.importSongs(SongFormat.OpenLP2,
|
||||
filename=unicode(self.openLP2FilenameEdit.text())
|
||||
)
|
||||
elif source_format == SongFormat.OpenLP1:
|
||||
# Import an openlp.org database
|
||||
importer = self.plugin.importSongs(SongFormat.OpenLP1,
|
||||
filename=unicode(self.openLP1FilenameEdit.text()),
|
||||
plugin=self.plugin
|
||||
)
|
||||
elif source_format == SongFormat.PowerSong:
|
||||
# Import PowerSong folder
|
||||
importer = self.plugin.importSongs(SongFormat.PowerSong,
|
||||
folder=unicode(self.powerSongFilenameEdit.text())
|
||||
)
|
||||
elif source_format == SongFormat.OpenLyrics:
|
||||
# Import OpenLyrics songs
|
||||
importer = self.plugin.importSongs(SongFormat.OpenLyrics,
|
||||
filenames=self.getListOfFiles(self.openLyricsFileListWidget)
|
||||
)
|
||||
elif source_format == SongFormat.OpenSong:
|
||||
# Import OpenSong songs
|
||||
importer = self.plugin.importSongs(SongFormat.OpenSong,
|
||||
filenames=self.getListOfFiles(self.openSongFileListWidget)
|
||||
)
|
||||
elif source_format == SongFormat.WordsOfWorship:
|
||||
# Import Words Of Worship songs
|
||||
importer = self.plugin.importSongs(SongFormat.WordsOfWorship,
|
||||
source_format = self.activeFormat
|
||||
select_mode = SongFormatAttribute.get(source_format,
|
||||
SongFormatAttribute.select_mode)
|
||||
if select_mode == SongFormatSelect.SingleFile:
|
||||
importer = self.plugin.importSongs(source_format,
|
||||
filename=unicode(
|
||||
self.formatWidgets[source_format][u'filepathEdit'].text()))
|
||||
elif select_mode == SongFormatSelect.MultipleFiles:
|
||||
importer = self.plugin.importSongs(source_format,
|
||||
filenames=self.getListOfFiles(
|
||||
self.wordsOfWorshipFileListWidget)
|
||||
)
|
||||
elif source_format == SongFormat.CCLI:
|
||||
# Import Words Of Worship songs
|
||||
importer = self.plugin.importSongs(SongFormat.CCLI,
|
||||
filenames=self.getListOfFiles(self.ccliFileListWidget)
|
||||
)
|
||||
elif source_format == SongFormat.DreamBeam:
|
||||
# Import DreamBeam songs
|
||||
importer = self.plugin.importSongs(SongFormat.DreamBeam,
|
||||
filenames=self.getListOfFiles(
|
||||
self.dreamBeamFileListWidget)
|
||||
)
|
||||
elif source_format == SongFormat.SongsOfFellowship:
|
||||
# Import a Songs of Fellowship RTF file
|
||||
importer = self.plugin.importSongs(SongFormat.SongsOfFellowship,
|
||||
filenames=self.getListOfFiles(
|
||||
self.songsOfFellowshipFileListWidget)
|
||||
)
|
||||
elif source_format == SongFormat.Generic:
|
||||
# Import a generic document or presentation
|
||||
importer = self.plugin.importSongs(SongFormat.Generic,
|
||||
filenames=self.getListOfFiles(self.genericFileListWidget)
|
||||
)
|
||||
elif source_format == SongFormat.EasySlides:
|
||||
# Import an EasySlides export file
|
||||
importer = self.plugin.importSongs(SongFormat.EasySlides,
|
||||
filename=unicode(self.easySlidesFilenameEdit.text())
|
||||
)
|
||||
elif source_format == SongFormat.EasyWorship:
|
||||
# Import an EasyWorship database
|
||||
importer = self.plugin.importSongs(SongFormat.EasyWorship,
|
||||
filename=unicode(self.ewFilenameEdit.text())
|
||||
)
|
||||
elif source_format == SongFormat.SongBeamer:
|
||||
# Import SongBeamer songs
|
||||
importer = self.plugin.importSongs(SongFormat.SongBeamer,
|
||||
filenames=self.getListOfFiles(self.songBeamerFileListWidget)
|
||||
)
|
||||
elif source_format == SongFormat.SongShowPlus:
|
||||
# Import ShongShow Plus songs
|
||||
importer = self.plugin.importSongs(SongFormat.SongShowPlus,
|
||||
filenames=self.getListOfFiles(self.songShowPlusFileListWidget)
|
||||
)
|
||||
elif source_format == SongFormat.FoilPresenter:
|
||||
# Import Foilpresenter songs
|
||||
importer = self.plugin.importSongs(SongFormat.FoilPresenter,
|
||||
filenames=self.getListOfFiles(self.foilPresenterFileListWidget)
|
||||
)
|
||||
self.formatWidgets[source_format][u'fileListWidget']))
|
||||
elif select_mode == SongFormatSelect.SingleFolder:
|
||||
importer = self.plugin.importSongs(source_format,
|
||||
folder=unicode(
|
||||
self.formatWidgets[source_format][u'filepathEdit'].text()))
|
||||
importer.doImport()
|
||||
self.progressLabel.setText(WizardStrings.FinishedImport)
|
||||
|
||||
@ -873,8 +420,15 @@ class SongImportForm(OpenLPWizard):
|
||||
report_file.write(self.errorReportTextEdit.toPlainText())
|
||||
report_file.close()
|
||||
|
||||
def addFileSelectItem(self, prefix, obj_prefix=None, can_disable=False,
|
||||
single_select=False):
|
||||
def addFileSelectItem(self):
|
||||
format = self.activeFormat
|
||||
prefix = SongFormatAttribute.get(format, SongFormatAttribute.prefix)
|
||||
obj_prefix = SongFormatAttribute.get(format,
|
||||
SongFormatAttribute.obj_prefix)
|
||||
can_disable = SongFormatAttribute.get(format,
|
||||
SongFormatAttribute.can_disable)
|
||||
select_mode = SongFormatAttribute.get(format,
|
||||
SongFormatAttribute.select_mode)
|
||||
if not obj_prefix:
|
||||
obj_prefix = prefix
|
||||
page = QtGui.QWidget()
|
||||
@ -886,22 +440,23 @@ class SongImportForm(OpenLPWizard):
|
||||
importLayout = QtGui.QVBoxLayout(importWidget)
|
||||
importLayout.setMargin(0)
|
||||
importLayout.setObjectName(obj_prefix + u'ImportLayout')
|
||||
if single_select:
|
||||
fileLayout = QtGui.QHBoxLayout()
|
||||
fileLayout.setObjectName(obj_prefix + u'FileLayout')
|
||||
filenameLabel = QtGui.QLabel(importWidget)
|
||||
filenameLabel.setObjectName(obj_prefix + u'FilenameLabel')
|
||||
fileLayout.addWidget(filenameLabel)
|
||||
filenameEdit = QtGui.QLineEdit(importWidget)
|
||||
filenameEdit.setObjectName(obj_prefix + u'FilenameEdit')
|
||||
fileLayout.addWidget(filenameEdit)
|
||||
if select_mode == SongFormatSelect.SingleFile or \
|
||||
select_mode == SongFormatSelect.SingleFolder:
|
||||
filepathLayout = QtGui.QHBoxLayout()
|
||||
filepathLayout.setObjectName(obj_prefix + u'FilepathLayout')
|
||||
filepathLabel = QtGui.QLabel(importWidget)
|
||||
filepathLabel.setObjectName(obj_prefix + u'FilepathLabel')
|
||||
filepathLayout.addWidget(filepathLabel)
|
||||
filepathEdit = QtGui.QLineEdit(importWidget)
|
||||
filepathEdit.setObjectName(obj_prefix + u'FilepathEdit')
|
||||
filepathLayout.addWidget(filepathEdit)
|
||||
browseButton = QtGui.QToolButton(importWidget)
|
||||
browseButton.setIcon(self.openIcon)
|
||||
browseButton.setObjectName(obj_prefix + u'BrowseButton')
|
||||
fileLayout.addWidget(browseButton)
|
||||
importLayout.addLayout(fileLayout)
|
||||
filepathLayout.addWidget(browseButton)
|
||||
importLayout.addLayout(filepathLayout)
|
||||
importLayout.addSpacerItem(self.stackSpacer)
|
||||
else:
|
||||
elif select_mode == SongFormatSelect.MultipleFiles:
|
||||
fileListWidget = QtGui.QListWidget(importWidget)
|
||||
fileListWidget.setSelectionMode(
|
||||
QtGui.QAbstractItemView.ExtendedSelection)
|
||||
@ -920,21 +475,24 @@ class SongImportForm(OpenLPWizard):
|
||||
buttonLayout.addWidget(removeButton)
|
||||
importLayout.addLayout(buttonLayout)
|
||||
self.formatStack.addWidget(page)
|
||||
setattr(self, prefix + u'Page', page)
|
||||
if single_select:
|
||||
setattr(self, prefix + u'FilenameLabel', filenameLabel)
|
||||
setattr(self, prefix + u'FileLayout', fileLayout)
|
||||
setattr(self, prefix + u'FilenameEdit', filenameEdit)
|
||||
setattr(self, prefix + u'BrowseButton', browseButton)
|
||||
#setattr(self, prefix + u'Page', page)
|
||||
if select_mode == SongFormatSelect.SingleFile or \
|
||||
select_mode == SongFormatSelect.SingleFolder:
|
||||
self.formatWidgets[format][u'filepathLabel'] = filepathLabel
|
||||
#setattr(self, prefix + u'FileLayout', fileLayout)
|
||||
self.formatWidgets[format][u'filepathEdit'] = filepathEdit
|
||||
self.formatWidgets[format][u'browseButton'] = browseButton
|
||||
else:
|
||||
setattr(self, prefix + u'FileListWidget', fileListWidget)
|
||||
setattr(self, prefix + u'ButtonLayout', buttonLayout)
|
||||
setattr(self, prefix + u'AddButton', addButton)
|
||||
setattr(self, prefix + u'RemoveButton', removeButton)
|
||||
setattr(self, prefix + u'ImportLayout', importLayout)
|
||||
self.formatWidgets[format][u'fileListWidget'] = fileListWidget
|
||||
#setattr(self, prefix + u'ButtonLayout', buttonLayout)
|
||||
self.formatWidgets[format][u'addButton'] = addButton
|
||||
self.formatWidgets[format][u'removeButton'] = removeButton
|
||||
#setattr(self, prefix + u'ImportLayout', importLayout)
|
||||
self.formatComboBox.addItem(u'')
|
||||
|
||||
def disablableWidget(self, page, prefix, obj_prefix):
|
||||
format = self.activeFormat
|
||||
self.disablableFormats.append(format)
|
||||
layout = QtGui.QVBoxLayout(page)
|
||||
layout.setMargin(0)
|
||||
layout.setSpacing(0)
|
||||
@ -954,9 +512,9 @@ class SongImportForm(OpenLPWizard):
|
||||
importWidget = QtGui.QWidget(page)
|
||||
importWidget.setObjectName(obj_prefix + u'ImportWidget')
|
||||
layout.addWidget(importWidget)
|
||||
setattr(self, prefix + u'Layout', layout)
|
||||
setattr(self, prefix + u'DisabledWidget', disabledWidget)
|
||||
setattr(self, prefix + u'DisabledLayout', disabledLayout)
|
||||
setattr(self, prefix + u'DisabledLabel', disabledLabel)
|
||||
setattr(self, prefix + u'ImportWidget', importWidget)
|
||||
#setattr(self, prefix + u'Layout', layout)
|
||||
self.formatWidgets[format][u'disabledWidget'] = disabledWidget
|
||||
#setattr(self, prefix + u'DisabledLayout', disabledLayout)
|
||||
self.formatWidgets[format][u'disabledLabel'] = disabledLabel
|
||||
self.formatWidgets[format][u'importWidget'] = importWidget
|
||||
return importWidget
|
||||
|
@ -29,6 +29,8 @@ The :mod:`importer` modules provides the general song import functionality.
|
||||
"""
|
||||
import logging
|
||||
|
||||
from openlp.core.lib.ui import UiStrings
|
||||
from openlp.core.ui.wizard import WizardStrings
|
||||
from opensongimport import OpenSongImport
|
||||
from easyslidesimport import EasySlidesImport
|
||||
from olpimport import OpenLPSongImport
|
||||
@ -68,7 +70,6 @@ class SongFormat(object):
|
||||
plus a few helper functions to facilitate generic handling of song types
|
||||
for importing.
|
||||
"""
|
||||
_format_availability = {}
|
||||
Unknown = -1
|
||||
OpenLyrics = 0
|
||||
OpenLP2 = 1
|
||||
@ -88,47 +89,7 @@ class SongFormat(object):
|
||||
#CSV = 15
|
||||
|
||||
@staticmethod
|
||||
def get_class(format):
|
||||
"""
|
||||
Return the appropriate implementation class.
|
||||
|
||||
``format``
|
||||
The song format.
|
||||
"""
|
||||
if format == SongFormat.OpenLP2:
|
||||
return OpenLPSongImport
|
||||
elif format == SongFormat.OpenLP1:
|
||||
return OpenLP1SongImport
|
||||
elif format == SongFormat.OpenLyrics:
|
||||
return OpenLyricsImport
|
||||
elif format == SongFormat.OpenSong:
|
||||
return OpenSongImport
|
||||
elif format == SongFormat.SongsOfFellowship:
|
||||
return SofImport
|
||||
elif format == SongFormat.WordsOfWorship:
|
||||
return WowImport
|
||||
elif format == SongFormat.Generic:
|
||||
return OooImport
|
||||
elif format == SongFormat.CCLI:
|
||||
return CCLIFileImport
|
||||
elif format == SongFormat.DreamBeam:
|
||||
return DreamBeamImport
|
||||
elif format == SongFormat.PowerSong:
|
||||
return PowerSongImport
|
||||
elif format == SongFormat.EasySlides:
|
||||
return EasySlidesImport
|
||||
elif format == SongFormat.EasyWorship:
|
||||
return EasyWorshipSongImport
|
||||
elif format == SongFormat.SongBeamer:
|
||||
return SongBeamerImport
|
||||
elif format == SongFormat.SongShowPlus:
|
||||
return SongShowPlusImport
|
||||
elif format == SongFormat.FoilPresenter:
|
||||
return FoilPresenterImport
|
||||
return None
|
||||
|
||||
@staticmethod
|
||||
def get_formats_list():
|
||||
def get_formats():
|
||||
"""
|
||||
Return a list of the supported song formats.
|
||||
"""
|
||||
@ -138,7 +99,7 @@ class SongFormat(object):
|
||||
SongFormat.OpenLP1,
|
||||
SongFormat.Generic,
|
||||
SongFormat.CCLI,
|
||||
SongFormat.DreamBeam,
|
||||
SongFormat.DreamBeam,
|
||||
SongFormat.EasySlides,
|
||||
SongFormat.EasyWorship,
|
||||
SongFormat.FoilPresenter,
|
||||
@ -150,23 +111,202 @@ class SongFormat(object):
|
||||
SongFormat.WordsOfWorship
|
||||
]
|
||||
|
||||
@staticmethod
|
||||
def set_availability(format, available):
|
||||
"""
|
||||
Set the availability for a given song format.
|
||||
"""
|
||||
SongFormat._format_availability[format] = available
|
||||
class SongFormatAttribute(object):
|
||||
# Required attributes:
|
||||
class_ = 0
|
||||
name = 1
|
||||
prefix = 2
|
||||
# Optional attributes:
|
||||
obj_prefix = 10
|
||||
can_disable = 11
|
||||
availability = 12
|
||||
select_mode = 13
|
||||
# Required widget Text:
|
||||
combo_box_text = 20
|
||||
# Optional widget Text
|
||||
disabled_label_text = 30
|
||||
filter = 31
|
||||
|
||||
# Set attribute defaults (if not specified here, default is None)
|
||||
_defaults = {
|
||||
obj_prefix: None,
|
||||
can_disable: False,
|
||||
availability: True,
|
||||
select_mode: SongFormatSelect.MultipleFiles,
|
||||
disabled_label_text: u'',
|
||||
filter: u''
|
||||
}
|
||||
|
||||
# Set attribute values
|
||||
_attributes = {
|
||||
SongFormat.OpenLyrics: {
|
||||
class_: OpenLyricsImport,
|
||||
name: WizardStrings.OL,
|
||||
prefix: u'openLyrics',
|
||||
obj_prefix: u'OpenLyrics',
|
||||
can_disable: True,
|
||||
combo_box_text: translate('SongsPlugin.ImportWizardForm',
|
||||
'OpenLyrics or OpenLP 2.0 Exported Song'),
|
||||
disabled_label_text: translate('SongsPlugin.ImportWizardForm',
|
||||
'The OpenLyrics importer has not yet been developed, but as '
|
||||
'you can see, we are still intending to do so. Hopefully it '
|
||||
'will be in the next release.'),
|
||||
filter: u'%s (*.xml)' % translate('SongsPlugin.ImportWizardForm',
|
||||
'OpenLyrics Files')
|
||||
},
|
||||
SongFormat.OpenLP2: {
|
||||
class_: OpenLPSongImport,
|
||||
name: UiStrings().OLPV2,
|
||||
prefix: u'openLP2',
|
||||
select_mode: SongFormatSelect.SingleFile,
|
||||
combo_box_text: UiStrings().OLPV2,
|
||||
filter: u'%s (*.sqlite)' % (translate(
|
||||
'SongsPlugin.ImportWizardForm', 'OpenLP 2.0 Databases'))
|
||||
},
|
||||
SongFormat.OpenLP1: {
|
||||
class_: OpenLP1SongImport,
|
||||
name: UiStrings().OLPV1,
|
||||
prefix: u'openLP1',
|
||||
can_disable: True,
|
||||
select_mode: SongFormatSelect.SingleFile,
|
||||
combo_box_text: UiStrings().OLPV1,
|
||||
disabled_label_text: WizardStrings.NoSqlite,
|
||||
filter: u'%s (*.olp)' % translate('SongsPlugin.ImportWizardForm',
|
||||
'openlp.org v1.x Databases')
|
||||
},
|
||||
SongFormat.Generic: {
|
||||
class_: OooImport,
|
||||
# name: ,
|
||||
prefix: u'generic',
|
||||
can_disable: True,
|
||||
combo_box_text: translate('SongsPlugin.ImportWizardForm',
|
||||
'Generic Document/Presentation'),
|
||||
disabled_label_text: translate('SongsPlugin.ImportWizardForm',
|
||||
'The generic document/presentation importer has been disabled '
|
||||
'because OpenLP cannot access OpenOffice or LibreOffice.')
|
||||
},
|
||||
SongFormat.CCLI: {
|
||||
class_: CCLIFileImport,
|
||||
name: WizardStrings.CCLI,
|
||||
prefix: u'ccli',
|
||||
combo_box_text: WizardStrings.CCLI,
|
||||
filter: u'%s (*.usr *.txt)' % translate(
|
||||
'SongsPlugin.ImportWizardForm', 'CCLI SongSelect Files')
|
||||
},
|
||||
SongFormat.DreamBeam: {
|
||||
class_: DreamBeamImport,
|
||||
name: WizardStrings.DB,
|
||||
prefix: u'dreamBeam',
|
||||
combo_box_text: WizardStrings.DB,
|
||||
filter: u'%s (*.xml)' % translate('SongsPlugin.ImportWizardForm',
|
||||
'DreamBeam Song Files')
|
||||
},
|
||||
SongFormat.EasySlides: {
|
||||
class_: EasySlidesImport,
|
||||
name: WizardStrings.ES,
|
||||
prefix: u'easySlides',
|
||||
select_mode: SongFormatSelect.SingleFile,
|
||||
combo_box_text: WizardStrings.ES,
|
||||
filter: u'%s (*.xml)' % translate('SongsPlugin.ImportWizardForm',
|
||||
'EasySlides XML File')
|
||||
},
|
||||
SongFormat.EasyWorship: {
|
||||
class_: EasyWorshipSongImport,
|
||||
name: WizardStrings.EW,
|
||||
prefix: u'ew',
|
||||
select_mode: SongFormatSelect.SingleFile,
|
||||
combo_box_text: WizardStrings.EW,
|
||||
filter: u'%s (*.db)' % translate('SongsPlugin.ImportWizardForm',
|
||||
'EasyWorship Song Database')
|
||||
},
|
||||
SongFormat.FoilPresenter: {
|
||||
class_: FoilPresenterImport,
|
||||
name: WizardStrings.FP,
|
||||
prefix: u'foilPresenter',
|
||||
combo_box_text: WizardStrings.FP,
|
||||
filter: u'%s (*.foil)' % translate('SongsPlugin.ImportWizardForm',
|
||||
'Foilpresenter Song Files')
|
||||
},
|
||||
SongFormat.OpenSong: {
|
||||
class_: OpenSongImport,
|
||||
name: WizardStrings.OS,
|
||||
prefix: u'openSong',
|
||||
obj_prefix: u'OpenSong',
|
||||
combo_box_text: WizardStrings.OS
|
||||
},
|
||||
SongFormat.PowerSong: {
|
||||
class_: PowerSongImport,
|
||||
name: WizardStrings.PS,
|
||||
prefix: u'powerSong',
|
||||
select_mode: SongFormatSelect.SingleFolder,
|
||||
combo_box_text: WizardStrings.PS
|
||||
},
|
||||
SongFormat.SongBeamer: {
|
||||
class_: SongBeamerImport,
|
||||
name: WizardStrings.SB,
|
||||
prefix: u'songBeamer',
|
||||
combo_box_text: WizardStrings.SB,
|
||||
filter: u'%s (*.sng)' % translate('SongsPlugin.ImportWizardForm',
|
||||
'SongBeamer Files')
|
||||
},
|
||||
SongFormat.SongShowPlus: {
|
||||
class_: SongShowPlusImport,
|
||||
name: WizardStrings.SSP,
|
||||
prefix: u'songShowPlus',
|
||||
combo_box_text: WizardStrings.SSP,
|
||||
filter: u'%s (*.sbsong)' % translate('SongsPlugin.ImportWizardForm',
|
||||
'SongShow Plus Song Files')
|
||||
},
|
||||
SongFormat.SongsOfFellowship: {
|
||||
class_: SofImport,
|
||||
name: WizardStrings.SoF,
|
||||
prefix: u'songsOfFellowship',
|
||||
can_disable: True,
|
||||
combo_box_text: WizardStrings.SoF,
|
||||
disabled_label_text: translate('SongsPlugin.ImportWizardForm',
|
||||
'The Songs of Fellowship importer has been disabled because '
|
||||
'OpenLP cannot access OpenOffice or LibreOffice.'),
|
||||
filter: u'%s (*.rtf)' % translate('SongsPlugin.ImportWizardForm',
|
||||
'Songs Of Fellowship Song Files')
|
||||
},
|
||||
SongFormat.WordsOfWorship: {
|
||||
class_: WowImport,
|
||||
name: WizardStrings.WoW,
|
||||
prefix: u'wordsOfWorship',
|
||||
combo_box_text: WizardStrings.WoW,
|
||||
filter: u'%s (*.wsg *.wow-song)' % translate(
|
||||
'SongsPlugin.ImportWizardForm', 'Words Of Worship Song Files')
|
||||
# },
|
||||
# SongFormat.CSV: {
|
||||
# class_: CSVImport,
|
||||
# name: WizardStrings.CSV,
|
||||
# prefix: u'csv',
|
||||
# obj_prefix: u'CSV',
|
||||
# select_mode: SongFormatSelect.SingleFile,
|
||||
# combo_box_text: WizardStrings.CSV
|
||||
}
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
def get_availability(format):
|
||||
"""
|
||||
Return the availability of a given song format.
|
||||
"""
|
||||
return SongFormat._format_availability.get(format, True)
|
||||
def get(format, attribute):
|
||||
default = _defaults.get(attribute)
|
||||
return SongFormat._attributes[format].get(attribute, default)
|
||||
|
||||
SongFormat.set_availability(SongFormat.OpenLP1, HAS_OPENLP1)
|
||||
SongFormat.set_availability(SongFormat.SongsOfFellowship, HAS_SOF)
|
||||
SongFormat.set_availability(SongFormat.Generic, HAS_OOO)
|
||||
@staticmethod
|
||||
def set(format, attribute, value):
|
||||
SongFormat._attributes[format][attribute] = value
|
||||
|
||||
class SongFormatSelect(object):
|
||||
SingleFile = 0
|
||||
MultipleFiles = 1
|
||||
SingleFolder = 2
|
||||
|
||||
SongFormatAttribute.set(
|
||||
SongFormat.OpenLP1, SongFormatAttribute.availability, HAS_OPENLP1)
|
||||
SongFormatAttribute.set(
|
||||
SongFormat.SongsOfFellowship, SongFormatAttribute.availability, HAS_SOF)
|
||||
SongFormatAttribute.set(
|
||||
SongFormat.Generic, SongFormatAttribute.availability, HAS_OOO)
|
||||
|
||||
__all__ = [u'SongFormat']
|
||||
|
||||
|
@ -39,7 +39,7 @@ from openlp.core.utils.actions import ActionList
|
||||
from openlp.plugins.songs.lib import clean_song, upgrade, SongMediaItem, \
|
||||
SongsTab
|
||||
from openlp.plugins.songs.lib.db import init_schema, Song
|
||||
from openlp.plugins.songs.lib.importer import SongFormat
|
||||
from openlp.plugins.songs.lib.importer import SongFormatAttribute
|
||||
from openlp.plugins.songs.lib.olpimport import OpenLPSongImport
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
@ -194,7 +194,7 @@ class SongsPlugin(Plugin):
|
||||
self.manager.save_object(song)
|
||||
|
||||
def importSongs(self, format, **kwargs):
|
||||
class_ = SongFormat.get_class(format)
|
||||
class_ = SongFormatAttribute.get(format, SongFormatAttribute.class_)
|
||||
importer = class_(self.manager, **kwargs)
|
||||
importer.register(self.mediaItem.importWizard)
|
||||
return importer
|
||||
|
Loading…
Reference in New Issue
Block a user