2010-04-02 12:23:40 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
# OpenLP - Open Source Lyrics Projection #
|
|
|
|
# --------------------------------------------------------------------------- #
|
2010-12-26 11:04:47 +00:00
|
|
|
# Copyright (c) 2008-2011 Raoul Snyman #
|
|
|
|
# Portions copyright (c) 2008-2011 Tim Bentley, Jonathan Corwin, Michael #
|
2010-07-24 22:10:47 +00:00
|
|
|
# Gorven, Scott Guerrieri, Meinert Jordan, Andreas Preikschat, Christian #
|
|
|
|
# Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon Tibble, #
|
|
|
|
# Carsten Tinggaard, Frode Woldsund #
|
2010-04-02 12:23:40 +00:00
|
|
|
# --------------------------------------------------------------------------- #
|
|
|
|
# This program is free software; you can redistribute it and/or modify it #
|
|
|
|
# under the terms of the GNU General Public License as published by the Free #
|
|
|
|
# Software Foundation; version 2 of the License. #
|
|
|
|
# #
|
|
|
|
# This program is distributed in the hope that it will be useful, but WITHOUT #
|
|
|
|
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
|
|
|
|
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
|
|
|
|
# more details. #
|
|
|
|
# #
|
|
|
|
# You should have received a copy of the GNU General Public License along #
|
|
|
|
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
|
|
|
|
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
import logging
|
2010-08-20 19:40:07 +00:00
|
|
|
import os
|
2010-04-02 12:23:40 +00:00
|
|
|
|
|
|
|
from PyQt4 import QtCore, QtGui
|
|
|
|
|
|
|
|
from songimportwizard import Ui_SongImportWizard
|
2010-05-31 22:06:16 +00:00
|
|
|
from openlp.core.lib import Receiver, SettingsManager, translate
|
2010-08-22 19:50:30 +00:00
|
|
|
from openlp.plugins.songs.lib.importer import SongFormat
|
2010-04-02 12:23:40 +00:00
|
|
|
|
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
2010-10-16 19:38:23 +00:00
|
|
|
class SongImportForm(QtGui.QWizard, Ui_SongImportWizard):
|
2010-04-02 12:23:40 +00:00
|
|
|
"""
|
2010-08-08 14:38:51 +00:00
|
|
|
This is the Song Import Wizard, which allows easy importing of Songs
|
|
|
|
into OpenLP from other formats like OpenLyrics, OpenSong and CCLI.
|
2010-04-02 12:23:40 +00:00
|
|
|
"""
|
2010-08-08 14:38:51 +00:00
|
|
|
log.info(u'SongImportForm loaded')
|
2010-04-02 12:23:40 +00:00
|
|
|
|
2010-08-24 19:08:57 +00:00
|
|
|
def __init__(self, parent, plugin):
|
2010-04-02 12:23:40 +00:00
|
|
|
"""
|
|
|
|
Instantiate the wizard, and run any extra setup we need to.
|
|
|
|
|
|
|
|
``parent``
|
|
|
|
The QWidget-derived parent of the wizard.
|
|
|
|
|
2010-08-08 14:38:51 +00:00
|
|
|
``plugin``
|
|
|
|
The songs plugin.
|
2010-04-02 12:23:40 +00:00
|
|
|
"""
|
|
|
|
QtGui.QWizard.__init__(self, parent)
|
|
|
|
self.setupUi(self)
|
2010-04-03 00:13:07 +00:00
|
|
|
self.registerFields()
|
2010-04-02 12:23:40 +00:00
|
|
|
self.finishButton = self.button(QtGui.QWizard.FinishButton)
|
|
|
|
self.cancelButton = self.button(QtGui.QWizard.CancelButton)
|
2010-09-13 21:09:13 +00:00
|
|
|
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)
|
2010-08-08 14:38:51 +00:00
|
|
|
self.plugin = plugin
|
2010-08-20 19:40:07 +00:00
|
|
|
QtCore.QObject.connect(self.openLP2BrowseButton,
|
|
|
|
QtCore.SIGNAL(u'clicked()'),
|
|
|
|
self.onOpenLP2BrowseButtonClicked)
|
|
|
|
QtCore.QObject.connect(self.openLP1BrowseButton,
|
|
|
|
QtCore.SIGNAL(u'clicked()'),
|
|
|
|
self.onOpenLP1BrowseButtonClicked)
|
2011-01-02 16:42:09 +00:00
|
|
|
QtCore.QObject.connect(self.openLyricsAddButton,
|
|
|
|
QtCore.SIGNAL(u'clicked()'),
|
|
|
|
self.onOpenLyricsAddButtonClicked)
|
|
|
|
QtCore.QObject.connect(self.openLyricsRemoveButton,
|
|
|
|
QtCore.SIGNAL(u'clicked()'),
|
|
|
|
self.onOpenLyricsRemoveButtonClicked)
|
2010-08-20 19:40:07 +00:00
|
|
|
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)
|
2010-08-26 19:45:09 +00:00
|
|
|
QtCore.QObject.connect(self.ccliAddButton,
|
|
|
|
QtCore.SIGNAL(u'clicked()'),
|
|
|
|
self.onCCLIAddButtonClicked)
|
|
|
|
QtCore.QObject.connect(self.ccliRemoveButton,
|
|
|
|
QtCore.SIGNAL(u'clicked()'),
|
|
|
|
self.onCCLIRemoveButtonClicked)
|
2010-08-23 17:36:42 +00:00
|
|
|
QtCore.QObject.connect(self.songsOfFellowshipAddButton,
|
2010-08-20 19:40:07 +00:00
|
|
|
QtCore.SIGNAL(u'clicked()'),
|
2010-08-23 17:36:42 +00:00
|
|
|
self.onSongsOfFellowshipAddButtonClicked)
|
|
|
|
QtCore.QObject.connect(self.songsOfFellowshipRemoveButton,
|
|
|
|
QtCore.SIGNAL(u'clicked()'),
|
|
|
|
self.onSongsOfFellowshipRemoveButtonClicked)
|
2010-08-23 19:29:39 +00:00
|
|
|
QtCore.QObject.connect(self.genericAddButton,
|
2010-08-20 19:40:07 +00:00
|
|
|
QtCore.SIGNAL(u'clicked()'),
|
2010-08-23 19:29:39 +00:00
|
|
|
self.onGenericAddButtonClicked)
|
|
|
|
QtCore.QObject.connect(self.genericRemoveButton,
|
|
|
|
QtCore.SIGNAL(u'clicked()'),
|
|
|
|
self.onGenericRemoveButtonClicked)
|
2010-09-20 18:22:57 +00:00
|
|
|
QtCore.QObject.connect(self.ewBrowseButton,
|
|
|
|
QtCore.SIGNAL(u'clicked()'),
|
|
|
|
self.onEWBrowseButtonClicked)
|
2010-09-23 19:01:52 +00:00
|
|
|
QtCore.QObject.connect(self.songBeamerAddButton,
|
|
|
|
QtCore.SIGNAL(u'clicked()'),
|
|
|
|
self.onSongBeamerAddButtonClicked)
|
|
|
|
QtCore.QObject.connect(self.songBeamerRemoveButton,
|
|
|
|
QtCore.SIGNAL(u'clicked()'),
|
|
|
|
self.onSongBeamerRemoveButtonClicked)
|
2010-04-03 00:13:07 +00:00
|
|
|
QtCore.QObject.connect(self,
|
|
|
|
QtCore.SIGNAL(u'currentIdChanged(int)'),
|
|
|
|
self.onCurrentIdChanged)
|
2010-04-02 12:23:40 +00:00
|
|
|
|
|
|
|
def exec_(self):
|
|
|
|
"""
|
|
|
|
Run the wizard.
|
|
|
|
"""
|
2010-04-03 00:13:07 +00:00
|
|
|
self.setDefaults()
|
2010-04-02 12:23:40 +00:00
|
|
|
return QtGui.QWizard.exec_(self)
|
|
|
|
|
2010-12-08 22:55:28 +00:00
|
|
|
def reject(self):
|
|
|
|
"""
|
2010-12-08 23:33:38 +00:00
|
|
|
Stop the import on cancel button, close button or ESC key.
|
2010-12-08 22:55:28 +00:00
|
|
|
"""
|
2010-12-28 11:18:56 +00:00
|
|
|
log.debug(u'Import canceled by user.')
|
2010-12-27 18:23:46 +00:00
|
|
|
if self.currentPage() == self.importPage:
|
2010-12-08 22:55:28 +00:00
|
|
|
Receiver.send_message(u'songs_stop_import')
|
2010-12-11 12:07:38 +00:00
|
|
|
self.done(QtGui.QDialog.Rejected)
|
2010-12-08 22:55:28 +00:00
|
|
|
|
2010-04-02 12:23:40 +00:00
|
|
|
def validateCurrentPage(self):
|
|
|
|
"""
|
|
|
|
Validate the current page before moving on to the next page.
|
|
|
|
"""
|
2010-12-27 18:23:46 +00:00
|
|
|
if self.currentPage() == self.welcomePage:
|
2010-04-03 00:13:07 +00:00
|
|
|
return True
|
2010-12-28 21:24:21 +00:00
|
|
|
elif self.currentPage() == self.sourcePage:
|
2010-08-22 19:50:30 +00:00
|
|
|
source_format = self.formatComboBox.currentIndex()
|
2010-08-20 19:40:07 +00:00
|
|
|
if source_format == SongFormat.OpenLP2:
|
|
|
|
if self.openLP2FilenameEdit.text().isEmpty():
|
|
|
|
QtGui.QMessageBox.critical(self,
|
|
|
|
translate('SongsPlugin.ImportWizardForm',
|
2010-12-21 13:40:41 +00:00
|
|
|
'No OpenLP 2.0 Song Database Selected'),
|
2010-08-20 19:40:07 +00:00
|
|
|
translate('SongsPlugin.ImportWizardForm',
|
2010-12-21 13:40:41 +00:00
|
|
|
'You need to select an OpenLP 2.0 song database '
|
|
|
|
'file to import from.'))
|
2010-08-20 19:40:07 +00:00
|
|
|
self.openLP2BrowseButton.setFocus()
|
|
|
|
return False
|
|
|
|
elif source_format == SongFormat.OpenLP1:
|
2010-09-06 22:02:48 +00:00
|
|
|
if self.openLP1FilenameEdit.text().isEmpty():
|
2010-08-20 19:40:07 +00:00
|
|
|
QtGui.QMessageBox.critical(self,
|
|
|
|
translate('SongsPlugin.ImportWizardForm',
|
2010-12-21 13:40:41 +00:00
|
|
|
'No openlp.org 1.x Song Database Selected'),
|
2010-08-20 19:40:07 +00:00
|
|
|
translate('SongsPlugin.ImportWizardForm',
|
2010-12-21 13:40:41 +00:00
|
|
|
'You need to select an openlp.org 1.x song '
|
|
|
|
'database file to import from.'))
|
2010-08-20 19:40:07 +00:00
|
|
|
self.openLP1BrowseButton.setFocus()
|
|
|
|
return False
|
|
|
|
elif source_format == SongFormat.OpenLyrics:
|
2011-01-02 16:42:09 +00:00
|
|
|
if self.openLyricsFileListWidget.count() == 0:
|
|
|
|
QtGui.QMessageBox.critical(self,
|
|
|
|
translate('SongsPlugin.ImportWizardForm',
|
|
|
|
'No OpenLyrics Files Selected'),
|
|
|
|
translate('SongsPlugin.ImportWizardForm',
|
|
|
|
'You need to add at least one OpenLyrics '
|
|
|
|
'song file to import from.'))
|
|
|
|
self.openLyricsAddButton.setFocus()
|
|
|
|
return False
|
2010-04-03 00:13:07 +00:00
|
|
|
elif source_format == SongFormat.OpenSong:
|
2010-08-20 19:40:07 +00:00
|
|
|
if self.openSongFileListWidget.count() == 0:
|
2010-04-03 00:13:07 +00:00
|
|
|
QtGui.QMessageBox.critical(self,
|
2010-06-21 16:43:59 +00:00
|
|
|
translate('SongsPlugin.ImportWizardForm',
|
2010-12-21 13:40:41 +00:00
|
|
|
'No OpenSong Files Selected'),
|
2010-06-21 16:43:59 +00:00
|
|
|
translate('SongsPlugin.ImportWizardForm',
|
2010-12-21 13:40:41 +00:00
|
|
|
'You need to add at least one OpenSong '
|
|
|
|
'song file to import from.'))
|
2010-08-20 19:40:07 +00:00
|
|
|
self.openSongAddButton.setFocus()
|
|
|
|
return False
|
|
|
|
elif source_format == SongFormat.WordsOfWorship:
|
2010-08-27 19:53:22 +00:00
|
|
|
if self.wordsOfWorshipFileListWidget.count() == 0:
|
2010-08-20 19:40:07 +00:00
|
|
|
QtGui.QMessageBox.critical(self,
|
|
|
|
translate('SongsPlugin.ImportWizardForm',
|
2010-12-21 13:40:41 +00:00
|
|
|
'No Words of Worship Files Selected'),
|
2010-08-20 19:40:07 +00:00
|
|
|
translate('SongsPlugin.ImportWizardForm',
|
2010-12-21 13:40:41 +00:00
|
|
|
'You need to add at least one Words of Worship '
|
|
|
|
'file to import from.'))
|
2010-08-20 19:40:07 +00:00
|
|
|
self.wordsOfWorshipAddButton.setFocus()
|
2010-04-03 00:13:07 +00:00
|
|
|
return False
|
|
|
|
elif source_format == SongFormat.CCLI:
|
2010-08-22 19:50:30 +00:00
|
|
|
if self.ccliFileListWidget.count() == 0:
|
2010-04-03 00:13:07 +00:00
|
|
|
QtGui.QMessageBox.critical(self,
|
2010-06-21 16:43:59 +00:00
|
|
|
translate('SongsPlugin.ImportWizardForm',
|
2010-12-21 13:40:41 +00:00
|
|
|
'No CCLI Files Selected'),
|
2010-06-21 16:43:59 +00:00
|
|
|
translate('SongsPlugin.ImportWizardForm',
|
2010-12-21 13:40:41 +00:00
|
|
|
'You need to add at least one CCLI file '
|
|
|
|
'to import from.'))
|
2010-08-22 19:50:30 +00:00
|
|
|
self.ccliAddButton.setFocus()
|
2010-04-03 00:13:07 +00:00
|
|
|
return False
|
2010-08-20 19:40:07 +00:00
|
|
|
elif source_format == SongFormat.SongsOfFellowship:
|
2010-08-23 19:29:39 +00:00
|
|
|
if self.songsOfFellowshipFileListWidget.count() == 0:
|
2010-04-03 00:13:07 +00:00
|
|
|
QtGui.QMessageBox.critical(self,
|
2010-06-21 16:43:59 +00:00
|
|
|
translate('SongsPlugin.ImportWizardForm',
|
2010-12-21 13:40:41 +00:00
|
|
|
'No Songs of Fellowship File Selected'),
|
2010-06-21 16:43:59 +00:00
|
|
|
translate('SongsPlugin.ImportWizardForm',
|
2010-12-21 13:40:41 +00:00
|
|
|
'You need to add at least one Songs of Fellowship '
|
|
|
|
'file to import from.'))
|
2010-08-23 19:29:39 +00:00
|
|
|
self.songsOfFellowshipAddButton.setFocus()
|
2010-04-03 00:13:07 +00:00
|
|
|
return False
|
2010-08-20 19:40:07 +00:00
|
|
|
elif source_format == SongFormat.Generic:
|
2010-08-23 19:29:39 +00:00
|
|
|
if self.genericFileListWidget.count() == 0:
|
2010-04-03 00:13:07 +00:00
|
|
|
QtGui.QMessageBox.critical(self,
|
2010-06-21 16:43:59 +00:00
|
|
|
translate('SongsPlugin.ImportWizardForm',
|
2010-12-21 13:40:41 +00:00
|
|
|
'No Document/Presentation Selected'),
|
2010-06-21 16:43:59 +00:00
|
|
|
translate('SongsPlugin.ImportWizardForm',
|
2010-12-21 13:40:41 +00:00
|
|
|
'You need to add at least one document or '
|
|
|
|
'presentation file to import from.'))
|
2010-08-23 19:29:39 +00:00
|
|
|
self.genericAddButton.setFocus()
|
2010-04-03 00:13:07 +00:00
|
|
|
return False
|
2010-09-20 18:22:57 +00:00
|
|
|
elif source_format == SongFormat.EasyWorship:
|
|
|
|
if self.ewFilenameEdit.text().isEmpty():
|
|
|
|
QtGui.QMessageBox.critical(self,
|
|
|
|
translate('SongsPlugin.ImportWizardForm',
|
2010-12-21 13:40:41 +00:00
|
|
|
'No EasyWorship Song Database Selected'),
|
2010-09-20 18:22:57 +00:00
|
|
|
translate('SongsPlugin.ImportWizardForm',
|
2010-12-21 13:40:41 +00:00
|
|
|
'You need to select an EasyWorship song database '
|
|
|
|
'file to import from.'))
|
2010-09-20 18:22:57 +00:00
|
|
|
self.ewBrowseButton.setFocus()
|
|
|
|
return False
|
2010-09-23 19:01:52 +00:00
|
|
|
elif source_format == SongFormat.SongBeamer:
|
|
|
|
if self.songBeamerFileListWidget.count() == 0:
|
|
|
|
QtGui.QMessageBox.critical(self,
|
|
|
|
translate('SongsPlugin.ImportWizardForm',
|
2010-12-21 13:40:41 +00:00
|
|
|
'No SongBeamer File Selected'),
|
2010-09-23 19:01:52 +00:00
|
|
|
translate('SongsPlugin.ImportWizardForm',
|
2010-12-21 13:40:41 +00:00
|
|
|
'You need to add at least one SongBeamer '
|
|
|
|
'file to import from.'))
|
2010-09-23 19:01:52 +00:00
|
|
|
self.songBeamerAddButton.setFocus()
|
|
|
|
return False
|
2010-04-03 00:13:07 +00:00
|
|
|
return True
|
2010-12-27 18:23:46 +00:00
|
|
|
elif self.currentPage() == self.importPage:
|
2010-04-03 00:13:07 +00:00
|
|
|
return True
|
2010-04-02 12:23:40 +00:00
|
|
|
|
2010-12-21 13:40:41 +00:00
|
|
|
def getFileName(self, title, editbox, filters=u''):
|
|
|
|
"""
|
|
|
|
Opens a QFileDialog and writes the filename to the given editbox.
|
|
|
|
|
|
|
|
``title``
|
|
|
|
The title of the dialog (unicode).
|
|
|
|
|
|
|
|
``editbox``
|
|
|
|
A editbox (QLineEdit).
|
|
|
|
|
|
|
|
``filters``
|
|
|
|
The file extension filters. It should contain the file descriptions
|
|
|
|
as well as the file extensions. For example::
|
|
|
|
|
|
|
|
u'OpenLP 2.0 Databases (*.sqlite)'
|
|
|
|
"""
|
|
|
|
if filters:
|
|
|
|
filters += u';;'
|
|
|
|
filters += u'%s (*)' % translate('SongsPlugin.ImportWizardForm',
|
|
|
|
'All Files')
|
2010-08-20 19:40:07 +00:00
|
|
|
filename = QtGui.QFileDialog.getOpenFileName(self, title,
|
2010-12-29 16:35:10 +00:00
|
|
|
SettingsManager.get_last_dir(self.plugin.settingsSection, 1),
|
|
|
|
filters)
|
2010-08-20 19:40:07 +00:00
|
|
|
if filename:
|
|
|
|
editbox.setText(filename)
|
2010-12-21 13:40:41 +00:00
|
|
|
SettingsManager.set_last_dir(self.plugin.settingsSection,
|
2010-08-20 19:40:07 +00:00
|
|
|
os.path.split(unicode(filename))[0], 1)
|
|
|
|
|
2010-12-21 13:40:41 +00:00
|
|
|
def getFiles(self, title, listbox, filters=u''):
|
|
|
|
"""
|
|
|
|
Opens a QFileDialog and writes the filenames to the given listbox.
|
|
|
|
|
|
|
|
``title``
|
|
|
|
The title of the dialog (unicode).
|
|
|
|
|
|
|
|
``listbox``
|
|
|
|
A listbox (QListWidget).
|
|
|
|
|
|
|
|
``filters``
|
|
|
|
The file extension filters. It should contain the file descriptions
|
|
|
|
as well as the file extensions. For example::
|
|
|
|
|
|
|
|
u'SongBeamer files (*.sng)'
|
|
|
|
"""
|
|
|
|
if filters:
|
|
|
|
filters += u';;'
|
|
|
|
filters += u'%s (*)' % translate('SongsPlugin.ImportWizardForm',
|
|
|
|
'All Files')
|
2010-08-08 14:38:51 +00:00
|
|
|
filenames = QtGui.QFileDialog.getOpenFileNames(self, title,
|
2010-12-29 16:35:10 +00:00
|
|
|
SettingsManager.get_last_dir(self.plugin.settingsSection, 1),
|
|
|
|
filters)
|
2010-08-08 14:38:51 +00:00
|
|
|
if filenames:
|
|
|
|
listbox.addItems(filenames)
|
2010-08-20 19:40:07 +00:00
|
|
|
SettingsManager.set_last_dir(
|
|
|
|
self.plugin.settingsSection,
|
|
|
|
os.path.split(unicode(filenames[0]))[0], 1)
|
2010-08-08 14:38:51 +00:00
|
|
|
|
2010-08-22 19:50:30 +00:00
|
|
|
def getListOfFiles(self, listbox):
|
|
|
|
files = []
|
|
|
|
for row in range(0, listbox.count()):
|
2010-08-24 08:08:07 +00:00
|
|
|
files.append(unicode(listbox.item(row).text()))
|
2010-08-22 19:50:30 +00:00
|
|
|
return files
|
|
|
|
|
2010-08-08 14:38:51 +00:00
|
|
|
def removeSelectedItems(self, listbox):
|
|
|
|
for item in listbox.selectedItems():
|
|
|
|
item = listbox.takeItem(listbox.row(item))
|
|
|
|
del item
|
|
|
|
|
2010-08-20 19:40:07 +00:00
|
|
|
def onOpenLP2BrowseButtonClicked(self):
|
|
|
|
self.getFileName(
|
|
|
|
translate('SongsPlugin.ImportWizardForm',
|
|
|
|
'Select OpenLP 2.0 Database File'),
|
2010-12-21 13:40:41 +00:00
|
|
|
self.openLP2FilenameEdit, u'%s (*.sqlite)'
|
2010-10-03 22:28:47 +00:00
|
|
|
% (translate('SongsPlugin.ImportWizardForm',
|
2010-12-21 13:40:41 +00:00
|
|
|
'OpenLP 2.0 Databases'))
|
2010-08-20 19:40:07 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
def onOpenLP1BrowseButtonClicked(self):
|
|
|
|
self.getFileName(
|
|
|
|
translate('SongsPlugin.ImportWizardForm',
|
|
|
|
'Select openlp.org 1.x Database File'),
|
2010-12-21 13:40:41 +00:00
|
|
|
self.openLP1FilenameEdit, u'%s (*.olp)'
|
|
|
|
% translate('SongsPlugin.ImportWizardForm',
|
|
|
|
'openlp.org v1.x Databases')
|
2010-08-20 19:40:07 +00:00
|
|
|
)
|
|
|
|
|
2011-01-02 16:42:09 +00:00
|
|
|
def onOpenLyricsAddButtonClicked(self):
|
|
|
|
self.getFiles(
|
|
|
|
translate('SongsPlugin.ImportWizardForm',
|
|
|
|
'Select OpenLyrics Files'),
|
|
|
|
self.openLyricsFileListWidget
|
|
|
|
)
|
2010-08-08 14:38:51 +00:00
|
|
|
|
2011-01-02 16:42:09 +00:00
|
|
|
def onOpenLyricsRemoveButtonClicked(self):
|
|
|
|
self.removeSelectedItems(self.openLyricsFileListWidget)
|
2010-08-20 19:40:07 +00:00
|
|
|
|
|
|
|
def onOpenSongAddButtonClicked(self):
|
|
|
|
self.getFiles(
|
2010-08-22 19:50:30 +00:00
|
|
|
translate('SongsPlugin.ImportWizardForm',
|
|
|
|
'Select Open Song Files'),
|
2010-10-05 21:32:03 +00:00
|
|
|
self.openSongFileListWidget
|
2010-08-20 19:40:07 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
def onOpenSongRemoveButtonClicked(self):
|
|
|
|
self.removeSelectedItems(self.openSongFileListWidget)
|
|
|
|
|
|
|
|
def onWordsOfWorshipAddButtonClicked(self):
|
|
|
|
self.getFiles(
|
2010-08-22 19:50:30 +00:00
|
|
|
translate('SongsPlugin.ImportWizardForm',
|
|
|
|
'Select Words of Worship Files'),
|
2010-12-21 13:40:41 +00:00
|
|
|
self.wordsOfWorshipFileListWidget, u'%s (*.wsg *.wow-song)'
|
|
|
|
% translate('SongsPlugin.ImportWizardForm',
|
|
|
|
'Words Of Worship Song Files')
|
2010-08-20 19:40:07 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
def onWordsOfWorshipRemoveButtonClicked(self):
|
|
|
|
self.removeSelectedItems(self.wordsOfWorshipFileListWidget)
|
|
|
|
|
2010-08-26 19:45:09 +00:00
|
|
|
def onCCLIAddButtonClicked(self):
|
|
|
|
self.getFiles(
|
|
|
|
translate('SongsPlugin.ImportWizardForm',
|
|
|
|
'Select CCLI Files'),
|
|
|
|
self.ccliFileListWidget
|
|
|
|
)
|
|
|
|
|
|
|
|
def onCCLIRemoveButtonClicked(self):
|
|
|
|
self.removeSelectedItems(self.ccliFileListWidget)
|
2010-09-06 22:02:48 +00:00
|
|
|
|
2010-08-23 17:36:42 +00:00
|
|
|
def onSongsOfFellowshipAddButtonClicked(self):
|
|
|
|
self.getFiles(
|
2010-08-20 19:40:07 +00:00
|
|
|
translate('SongsPlugin.ImportWizardForm',
|
2010-08-23 17:36:42 +00:00
|
|
|
'Select Songs of Fellowship Files'),
|
2010-12-21 13:40:41 +00:00
|
|
|
self.songsOfFellowshipFileListWidget, u'%s (*.rtf)'
|
|
|
|
% translate('SongsPlugin.ImportWizardForm',
|
|
|
|
'Songs Of Felloship Song Files')
|
2010-08-20 19:40:07 +00:00
|
|
|
)
|
|
|
|
|
2010-08-23 17:36:42 +00:00
|
|
|
def onSongsOfFellowshipRemoveButtonClicked(self):
|
|
|
|
self.removeSelectedItems(self.songsOfFellowshipFileListWidget)
|
|
|
|
|
2010-08-23 19:29:39 +00:00
|
|
|
def onGenericAddButtonClicked(self):
|
|
|
|
self.getFiles(
|
2010-08-20 19:40:07 +00:00
|
|
|
translate('SongsPlugin.ImportWizardForm',
|
2010-08-23 19:29:39 +00:00
|
|
|
'Select Document/Presentation Files'),
|
|
|
|
self.genericFileListWidget
|
2010-08-20 19:40:07 +00:00
|
|
|
)
|
2010-08-08 14:38:51 +00:00
|
|
|
|
2010-08-23 19:29:39 +00:00
|
|
|
def onGenericRemoveButtonClicked(self):
|
|
|
|
self.removeSelectedItems(self.genericFileListWidget)
|
|
|
|
|
2010-09-20 18:22:57 +00:00
|
|
|
def onEWBrowseButtonClicked(self):
|
|
|
|
self.getFileName(
|
|
|
|
translate('SongsPlugin.ImportWizardForm',
|
|
|
|
'Select EasyWorship Database File'),
|
|
|
|
self.ewFilenameEdit
|
|
|
|
)
|
|
|
|
|
2010-09-23 19:01:52 +00:00
|
|
|
def onSongBeamerAddButtonClicked(self):
|
|
|
|
self.getFiles(
|
|
|
|
translate('SongsPlugin.ImportWizardForm',
|
|
|
|
'Select SongBeamer Files'),
|
2010-12-21 13:40:41 +00:00
|
|
|
self.songBeamerFileListWidget, u'%s (*.sng)' %
|
|
|
|
translate('SongsPlugin.ImportWizardForm', 'SongBeamer files')
|
2010-09-23 19:01:52 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
def onSongBeamerRemoveButtonClicked(self):
|
|
|
|
self.removeSelectedItems(self.songBeamerFileListWidget)
|
|
|
|
|
2010-04-03 00:13:07 +00:00
|
|
|
def onCurrentIdChanged(self, id):
|
2010-12-27 18:23:46 +00:00
|
|
|
if self.page(id) == self.importPage:
|
2010-04-03 00:13:07 +00:00
|
|
|
self.preImport()
|
|
|
|
self.performImport()
|
|
|
|
self.postImport()
|
2010-04-02 20:03:51 +00:00
|
|
|
|
|
|
|
def registerFields(self):
|
2010-08-22 19:50:30 +00:00
|
|
|
pass
|
2010-04-02 20:03:51 +00:00
|
|
|
|
|
|
|
def setDefaults(self):
|
2010-08-27 19:53:22 +00:00
|
|
|
self.restart()
|
2010-09-21 18:12:46 +00:00
|
|
|
self.finishButton.setVisible(False)
|
|
|
|
self.cancelButton.setVisible(True)
|
2010-08-22 19:50:30 +00:00
|
|
|
self.formatComboBox.setCurrentIndex(0)
|
2010-08-20 19:40:07 +00:00
|
|
|
self.openLP2FilenameEdit.setText(u'')
|
|
|
|
self.openLP1FilenameEdit.setText(u'')
|
2011-01-02 16:42:09 +00:00
|
|
|
self.openLyricsFileListWidget.clear()
|
2010-08-20 19:40:07 +00:00
|
|
|
self.openSongFileListWidget.clear()
|
|
|
|
self.wordsOfWorshipFileListWidget.clear()
|
2010-08-22 19:50:30 +00:00
|
|
|
self.ccliFileListWidget.clear()
|
2010-08-23 17:36:42 +00:00
|
|
|
self.songsOfFellowshipFileListWidget.clear()
|
2010-08-23 19:29:39 +00:00
|
|
|
self.genericFileListWidget.clear()
|
2010-09-20 18:22:57 +00:00
|
|
|
self.ewFilenameEdit.setText(u'')
|
2010-09-23 19:01:52 +00:00
|
|
|
self.songBeamerFileListWidget.clear()
|
2010-08-22 19:50:30 +00:00
|
|
|
#self.csvFilenameEdit.setText(u'')
|
2010-04-02 12:23:40 +00:00
|
|
|
|
2010-08-24 15:28:45 +00:00
|
|
|
def incrementProgressBar(self, status_text, increment=1):
|
2010-04-02 12:23:40 +00:00
|
|
|
log.debug(u'IncrementBar %s', status_text)
|
2010-08-24 15:31:33 +00:00
|
|
|
if status_text:
|
2010-08-24 15:28:45 +00:00
|
|
|
self.importProgressLabel.setText(status_text)
|
2010-08-24 15:31:33 +00:00
|
|
|
if increment > 0:
|
2010-08-24 15:28:45 +00:00
|
|
|
self.importProgressBar.setValue(self.importProgressBar.value() +
|
|
|
|
increment)
|
2010-08-24 15:25:26 +00:00
|
|
|
Receiver.send_message(u'openlp_process_events')
|
2010-04-02 12:23:40 +00:00
|
|
|
|
|
|
|
def preImport(self):
|
|
|
|
self.finishButton.setVisible(False)
|
2010-08-22 19:50:30 +00:00
|
|
|
self.importProgressBar.setMinimum(0)
|
|
|
|
self.importProgressBar.setMaximum(1188)
|
|
|
|
self.importProgressBar.setValue(0)
|
|
|
|
self.importProgressLabel.setText(
|
2010-06-21 16:43:59 +00:00
|
|
|
translate('SongsPlugin.ImportWizardForm', 'Starting import...'))
|
2010-08-24 15:25:26 +00:00
|
|
|
Receiver.send_message(u'openlp_process_events')
|
2010-04-02 12:23:40 +00:00
|
|
|
|
|
|
|
def performImport(self):
|
2010-08-22 19:50:30 +00:00
|
|
|
"""
|
|
|
|
Perform the actual import. This method pulls in the correct importer
|
|
|
|
class, and then runs the ``do_import`` 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())
|
|
|
|
)
|
2010-09-06 22:02:48 +00:00
|
|
|
elif source_format == SongFormat.OpenLP1:
|
|
|
|
# Import an openlp.org database
|
|
|
|
importer = self.plugin.importSongs(SongFormat.OpenLP1,
|
|
|
|
filename=unicode(self.openLP1FilenameEdit.text())
|
|
|
|
)
|
2010-08-22 19:50:30 +00:00
|
|
|
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,
|
2010-08-24 19:08:57 +00:00
|
|
|
filenames=self.getListOfFiles(
|
|
|
|
self.wordsOfWorshipFileListWidget)
|
2010-08-22 19:50:30 +00:00
|
|
|
)
|
|
|
|
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.SongsOfFellowship:
|
|
|
|
# Import a Songs of Fellowship RTF file
|
|
|
|
importer = self.plugin.importSongs(SongFormat.SongsOfFellowship,
|
2010-08-24 19:08:57 +00:00
|
|
|
filenames=self.getListOfFiles(
|
|
|
|
self.songsOfFellowshipFileListWidget)
|
2010-08-22 19:50:30 +00:00
|
|
|
)
|
2010-08-23 19:29:39 +00:00
|
|
|
elif source_format == SongFormat.Generic:
|
|
|
|
# Import a generic document or presentatoin
|
|
|
|
importer = self.plugin.importSongs(SongFormat.Generic,
|
|
|
|
filenames=self.getListOfFiles(self.genericFileListWidget)
|
|
|
|
)
|
2010-09-20 18:22:57 +00:00
|
|
|
elif source_format == SongFormat.EasyWorship:
|
|
|
|
# Import an OpenLP 2.0 database
|
|
|
|
importer = self.plugin.importSongs(SongFormat.EasyWorship,
|
|
|
|
filename=unicode(self.ewFilenameEdit.text())
|
|
|
|
)
|
2010-09-23 19:01:52 +00:00
|
|
|
elif source_format == SongFormat.SongBeamer:
|
|
|
|
# Import SongBeamer songs
|
|
|
|
importer = self.plugin.importSongs(SongFormat.SongBeamer,
|
|
|
|
filenames=self.getListOfFiles(
|
|
|
|
self.songBeamerFileListWidget)
|
|
|
|
)
|
2010-11-26 14:23:48 +00:00
|
|
|
if importer.do_import():
|
2010-08-22 19:50:30 +00:00
|
|
|
# reload songs
|
2010-08-24 19:08:57 +00:00
|
|
|
self.importProgressLabel.setText(
|
2010-08-22 19:50:30 +00:00
|
|
|
translate('SongsPlugin.SongImportForm', 'Finished import.'))
|
|
|
|
else:
|
2010-08-24 19:08:57 +00:00
|
|
|
self.importProgressLabel.setText(
|
2010-08-22 19:50:30 +00:00
|
|
|
translate('SongsPlugin.SongImportForm',
|
|
|
|
'Your song import failed.'))
|
2010-04-02 12:23:40 +00:00
|
|
|
|
|
|
|
def postImport(self):
|
2010-08-22 19:50:30 +00:00
|
|
|
self.importProgressBar.setValue(self.importProgressBar.maximum())
|
2010-04-02 12:23:40 +00:00
|
|
|
self.finishButton.setVisible(True)
|
|
|
|
self.cancelButton.setVisible(False)
|
2010-12-27 18:23:46 +00:00
|
|
|
Receiver.send_message(u'openlp_process_events')
|