SongImport.__init__()

This commit is contained in:
Jonathan Corwin 2010-08-23 22:52:21 +01:00
commit 2c3e732453
7 changed files with 219 additions and 104 deletions

View File

@ -91,12 +91,18 @@ class ImportWizardForm(QtGui.QWizard, Ui_SongImportWizard):
QtCore.QObject.connect(self.wordsOfWorshipRemoveButton, QtCore.QObject.connect(self.wordsOfWorshipRemoveButton,
QtCore.SIGNAL(u'clicked()'), QtCore.SIGNAL(u'clicked()'),
self.onWordsOfWorshipRemoveButtonClicked) self.onWordsOfWorshipRemoveButtonClicked)
QtCore.QObject.connect(self.songsOfFellowshipBrowseButton, QtCore.QObject.connect(self.songsOfFellowshipAddButton,
QtCore.SIGNAL(u'clicked()'), QtCore.SIGNAL(u'clicked()'),
self.onSongsOfFellowshipBrowseButtonClicked) self.onSongsOfFellowshipAddButtonClicked)
QtCore.QObject.connect(self.genericBrowseButton, QtCore.QObject.connect(self.songsOfFellowshipRemoveButton,
QtCore.SIGNAL(u'clicked()'), QtCore.SIGNAL(u'clicked()'),
self.onGenericBrowseButtonClicked) 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.cancelButton, QtCore.QObject.connect(self.cancelButton,
QtCore.SIGNAL(u'clicked(bool)'), QtCore.SIGNAL(u'clicked(bool)'),
self.onCancelButtonClicked) self.onCancelButtonClicked)
@ -171,7 +177,7 @@ class ImportWizardForm(QtGui.QWizard, Ui_SongImportWizard):
'file to import from.')) 'file to import from.'))
self.wordsOfWorshipAddButton.setFocus() self.wordsOfWorshipAddButton.setFocus()
return False return False
elif source_format == SongFormat.ccli: elif source_format == SongFormat.CCLI:
if self.ccliFileListWidget.count() == 0: if self.ccliFileListWidget.count() == 0:
QtGui.QMessageBox.critical(self, QtGui.QMessageBox.critical(self,
translate('SongsPlugin.ImportWizardForm', translate('SongsPlugin.ImportWizardForm',
@ -182,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:
@ -279,20 +285,26 @@ class ImportWizardForm(QtGui.QWizard, Ui_SongImportWizard):
def onWordsOfWorshipRemoveButtonClicked(self): def onWordsOfWorshipRemoveButtonClicked(self):
self.removeSelectedItems(self.wordsOfWorshipFileListWidget) self.removeSelectedItems(self.wordsOfWorshipFileListWidget)
def onSongsOfFellowshipBrowseButtonClicked(self): def onSongsOfFellowshipAddButtonClicked(self):
self.getFileName( self.getFiles(
translate('SongsPlugin.ImportWizardForm', translate('SongsPlugin.ImportWizardForm',
'Select Songs of Fellowship File'), 'Select Songs of Fellowship Files'),
self.songsOfFellowshipFilenameEdit self.songsOfFellowshipFileListWidget
) )
def onGenericBrowseButtonClicked(self): def onSongsOfFellowshipRemoveButtonClicked(self):
self.getFileName( self.removeSelectedItems(self.songsOfFellowshipFileListWidget)
def onGenericAddButtonClicked(self):
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.
@ -318,8 +330,8 @@ class ImportWizardForm(QtGui.QWizard, Ui_SongImportWizard):
self.openSongFileListWidget.clear() self.openSongFileListWidget.clear()
self.wordsOfWorshipFileListWidget.clear() self.wordsOfWorshipFileListWidget.clear()
self.ccliFileListWidget.clear() self.ccliFileListWidget.clear()
self.songsOfFellowshipFilenameEdit.setText(u'') 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):
@ -378,7 +390,12 @@ class ImportWizardForm(QtGui.QWizard, Ui_SongImportWizard):
elif source_format == SongFormat.SongsOfFellowship: elif source_format == SongFormat.SongsOfFellowship:
# Import a Songs of Fellowship RTF file # Import a Songs of Fellowship RTF file
importer = self.plugin.importSongs(SongFormat.SongsOfFellowship, importer = self.plugin.importSongs(SongFormat.SongsOfFellowship,
filename=unicode(self.songsOfFellowshipFilenameEdit.text()) 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:

View File

@ -238,79 +238,87 @@ class Ui_SongImportWizard(object):
self.formatStackedWidget.addWidget(self.wordsOfWorshipPage) self.formatStackedWidget.addWidget(self.wordsOfWorshipPage)
# CCLI File import # CCLI File import
self.ccliPage = QtGui.QWidget() self.ccliPage = QtGui.QWidget()
self.ccliPage.setObjectName(u'CCLIPage') self.ccliPage.setObjectName(u'ccliPage')
self.ccliLayout = QtGui.QVBoxLayout(self.ccliPage) self.ccliLayout = QtGui.QVBoxLayout(self.ccliPage)
self.ccliLayout.setSpacing(8) self.ccliLayout.setSpacing(8)
self.ccliLayout.setMargin(0) self.ccliLayout.setMargin(0)
self.ccliLayout.setObjectName(u'CCLILayout') self.ccliLayout.setObjectName(u'ccliLayout')
self.ccliFileListWidget = QtGui.QListWidget(self.ccliPage) self.ccliFileListWidget = QtGui.QListWidget(self.ccliPage)
self.ccliFileListWidget.setSelectionMode( self.ccliFileListWidget.setSelectionMode(
QtGui.QAbstractItemView.ExtendedSelection) QtGui.QAbstractItemView.ExtendedSelection)
self.ccliFileListWidget.setObjectName(u'CCLIFileListWidget') self.ccliFileListWidget.setObjectName(u'ccliFileListWidget')
self.ccliLayout.addWidget(self.ccliFileListWidget) self.ccliLayout.addWidget(self.ccliFileListWidget)
self.ccliButtonLayout = QtGui.QHBoxLayout() self.ccliButtonLayout = QtGui.QHBoxLayout()
self.ccliButtonLayout.setSpacing(8) self.ccliButtonLayout.setSpacing(8)
self.ccliButtonLayout.setObjectName(u'CCLIButtonLayout') self.ccliButtonLayout.setObjectName(u'ccliButtonLayout')
self.ccliAddButton = QtGui.QPushButton(self.ccliPage) self.ccliAddButton = QtGui.QPushButton(self.ccliPage)
self.ccliAddButton.setIcon(openIcon) self.ccliAddButton.setIcon(openIcon)
self.ccliAddButton.setObjectName(u'CCLIAddButton') self.ccliAddButton.setObjectName(u'ccliAddButton')
self.ccliButtonLayout.addWidget(self.ccliAddButton) self.ccliButtonLayout.addWidget(self.ccliAddButton)
self.ccliButtonSpacer = QtGui.QSpacerItem(40, 20, self.ccliButtonSpacer = QtGui.QSpacerItem(40, 20,
QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.ccliButtonLayout.addItem(self.ccliButtonSpacer) self.ccliButtonLayout.addItem(self.ccliButtonSpacer)
self.ccliRemoveButton = QtGui.QPushButton(self.ccliPage) self.ccliRemoveButton = QtGui.QPushButton(self.ccliPage)
self.ccliRemoveButton.setIcon(deleteIcon) self.ccliRemoveButton.setIcon(deleteIcon)
self.ccliRemoveButton.setObjectName(u'CCLIRemoveButton') self.ccliRemoveButton.setObjectName(u'ccliRemoveButton')
self.ccliButtonLayout.addWidget(self.ccliRemoveButton) self.ccliButtonLayout.addWidget(self.ccliRemoveButton)
self.ccliLayout.addLayout(self.ccliButtonLayout) self.ccliLayout.addLayout(self.ccliButtonLayout)
self.formatStackedWidget.addWidget(self.ccliPage) self.formatStackedWidget.addWidget(self.ccliPage)
# Songs of Fellowship # Songs of Fellowship
self.songsOfFellowshipPage = QtGui.QWidget() self.songsOfFellowshipPage = QtGui.QWidget()
self.songsOfFellowshipPage.setObjectName(u'songsOfFellowshipPage') self.songsOfFellowshipPage.setObjectName(u'songsOfFellowshipPage')
self.songsOfFellowshipLayout = QtGui.QFormLayout(self.songsOfFellowshipPage) self.songsOfFellowshipLayout = QtGui.QVBoxLayout(self.songsOfFellowshipPage)
self.songsOfFellowshipLayout.setMargin(0) self.songsOfFellowshipLayout.setMargin(0)
self.songsOfFellowshipLayout.setSpacing(8) self.songsOfFellowshipLayout.setSpacing(8)
self.songsOfFellowshipLayout.setObjectName(u'songsOfFellowshipLayout') self.songsOfFellowshipLayout.setObjectName(u'songsOfFellowshipLayout')
self.songsOfFellowshipFilenameLabel = QtGui.QLabel(self.songsOfFellowshipPage) self.songsOfFellowshipFileListWidget = QtGui.QListWidget(self.songsOfFellowshipPage)
self.songsOfFellowshipFilenameLabel.setObjectName(u'songsOfFellowshipFilenameLabel') self.songsOfFellowshipFileListWidget.setSelectionMode(
self.songsOfFellowshipLayout.setWidget(0, QtGui.QFormLayout.LabelRole, QtGui.QAbstractItemView.ExtendedSelection)
self.songsOfFellowshipFilenameLabel) self.songsOfFellowshipFileListWidget.setObjectName(u'songsOfFellowshipFileListWidget')
self.songsOfFellowshipFileLayout = QtGui.QHBoxLayout() self.songsOfFellowshipLayout.addWidget(self.songsOfFellowshipFileListWidget)
self.songsOfFellowshipFileLayout.setSpacing(8) self.songsOfFellowshipButtonLayout = QtGui.QHBoxLayout()
self.songsOfFellowshipFileLayout.setObjectName(u'songsOfFellowshipFileLayout') self.songsOfFellowshipButtonLayout.setSpacing(8)
self.songsOfFellowshipFilenameEdit = QtGui.QLineEdit(self.songsOfFellowshipPage) self.songsOfFellowshipButtonLayout.setObjectName(u'songsOfFellowshipButtonLayout')
self.songsOfFellowshipFilenameEdit.setObjectName(u'songsOfFellowshipFilenameEdit') self.songsOfFellowshipAddButton = QtGui.QPushButton(self.songsOfFellowshipPage)
self.songsOfFellowshipFileLayout.addWidget(self.songsOfFellowshipFilenameEdit) self.songsOfFellowshipAddButton.setIcon(openIcon)
self.songsOfFellowshipBrowseButton = QtGui.QToolButton(self.songsOfFellowshipPage) self.songsOfFellowshipAddButton.setObjectName(u'songsOfFellowshipAddButton')
self.songsOfFellowshipBrowseButton.setIcon(openIcon) self.songsOfFellowshipButtonLayout.addWidget(self.songsOfFellowshipAddButton)
self.songsOfFellowshipBrowseButton.setObjectName(u'songsOfFellowshipBrowseButton') self.songsOfFellowshipButtonSpacer = QtGui.QSpacerItem(40, 20,
self.songsOfFellowshipFileLayout.addWidget(self.songsOfFellowshipBrowseButton) QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.songsOfFellowshipLayout.setLayout(0, QtGui.QFormLayout.FieldRole, self.songsOfFellowshipButtonLayout.addItem(self.songsOfFellowshipButtonSpacer)
self.songsOfFellowshipFileLayout) self.songsOfFellowshipRemoveButton = QtGui.QPushButton(self.songsOfFellowshipPage)
self.songsOfFellowshipRemoveButton.setIcon(deleteIcon)
self.songsOfFellowshipRemoveButton.setObjectName(u'songsOfFellowshipRemoveButton')
self.songsOfFellowshipButtonLayout.addWidget(self.songsOfFellowshipRemoveButton)
self.songsOfFellowshipLayout.addLayout(self.songsOfFellowshipButtonLayout)
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()
@ -362,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.'))
@ -390,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,
@ -422,20 +430,20 @@ class Ui_SongImportWizard(object):
translate('SongsPlugin.ImportWizardForm', 'Add Files...')) translate('SongsPlugin.ImportWizardForm', 'Add Files...'))
self.ccliRemoveButton.setText( self.ccliRemoveButton.setText(
translate('SongsPlugin.ImportWizardForm', 'Remove File(s)')) translate('SongsPlugin.ImportWizardForm', 'Remove File(s)'))
self.songsOfFellowshipFilenameLabel.setText( self.songsOfFellowshipAddButton.setText(
translate('SongsPlugin.ImportWizardForm', 'Filename:')) translate('SongsPlugin.ImportWizardForm', 'Add Files...'))
self.songsOfFellowshipBrowseButton.setText( self.songsOfFellowshipRemoveButton.setText(
translate('SongsPlugin.ImportWizardForm', 'Browse...')) 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

@ -0,0 +1,87 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
# --------------------------------------------------------------------------- #
# Copyright (c) 2008-2010 Raoul Snyman #
# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael #
# Gorven, Scott Guerrieri, Meinert Jordan, Andreas Preikschat, Christian #
# Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon Tibble, #
# Carsten Tinggaard, Frode Woldsund #
# --------------------------------------------------------------------------- #
# 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 #
###############################################################################
from opensongimport import OpenSongImport
from olpimport import OpenLPSongImport
try:
from sofimport import SofImport
from oooimport import OooImport
except ImportError:
pass
class SongFormat(object):
"""
This is a special enumeration class that holds the various types of songs,
plus a few helper functions to facilitate generic handling of song types
for importing.
"""
Unknown = -1
OpenLP2 = 0
OpenLP1 = 1
OpenLyrics = 2
OpenSong = 3
WordsOfWorship = 4
CCLI = 5
SongsOfFellowship = 6
Generic = 7
CSV = 8
@staticmethod
def get_class(format):
"""
Return the appropriate imeplementation class.
``format``
The song format.
"""
if format == SongFormat.OpenLP2:
return OpenLPSongImport
elif format == SongFormat.OpenSong:
return OpenSongImport
elif format == SongFormat.SongsOfFellowship:
return SofImport
elif format == SongFormat.Generic:
return OooImport
# else:
return None
@staticmethod
def list():
"""
Return a list of the supported song formats.
"""
return [
SongFormat.OpenLP2,
SongFormat.OpenLP1,
SongFormat.OpenLyrics,
SongFormat.OpenSong,
SongFormat.WordsOfWorship,
SongFormat.CCLI,
SongFormat.SongsOfFellowship,
SongFormat.Generic
]
__all__ = [u'SongFormat']

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)

View File

@ -53,6 +53,7 @@ class OooImport(SongImport):
Initialise the class. Requires a songmanager class which is passed Initialise the class. Requires a songmanager class which is passed
to SongImport for writing song to disk to SongImport for writing song to disk
""" """
SongImport.__init__(self, master_manager)
self.song = None self.song = None
self.master_manager = master_manager self.master_manager = master_manager
self.document = None self.document = None
@ -64,6 +65,9 @@ class OooImport(SongImport):
def do_import(self): def do_import(self):
self.abort = False self.abort = False
self.start_ooo() self.start_ooo()
# Note this doesn't work, because kwargs[u'filenames'] doesn't appear
# to be anything sensible like an array of strings. No idea what it is
# though, I'm meant to guess
for filename in self.filenames: for filename in self.filenames:
if self.abort: if self.abort:
self.wizard.incrementProgressBar(u'Import cancelled') self.wizard.incrementProgressBar(u'Import cancelled')

View File

@ -73,7 +73,7 @@ class SofImport(OooImport):
Initialise the class. Requires a songmanager class which is passed Initialise the class. Requires a songmanager class which is passed
to SongImport for writing song to disk to SongImport for writing song to disk
""" """
OooImport.__init__(self,master_manager, **kwargs) OooImport.__init__(self, master_manager, **kwargs)
def do_import(self): def do_import(self):
self.abort = False self.abort = False

View File

@ -10,8 +10,8 @@
xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="1052.3622" width="467.39178"
height="744.09448" height="467.39178"
id="svg5740" id="svg5740"
sodipodi:version="0.32" sodipodi:version="0.32"
inkscape:version="0.47 r22583" inkscape:version="0.47 r22583"
@ -66,7 +66,8 @@
id="perspective5748" /> id="perspective5748" />
<filter <filter
inkscape:collect="always" inkscape:collect="always"
id="filter6926"> id="filter6926"
color-interpolation-filters="sRGB">
<feGaussianBlur <feGaussianBlur
inkscape:collect="always" inkscape:collect="always"
stdDeviation="3.5771872" stdDeviation="3.5771872"
@ -165,14 +166,6 @@
y1="276.68851" y1="276.68851"
x2="469.44925" x2="469.44925"
y2="104.30029" /> y2="104.30029" />
<filter
inkscape:collect="always"
id="filter4005">
<feGaussianBlur
inkscape:collect="always"
stdDeviation="4.333215"
id="feGaussianBlur4007" />
</filter>
<linearGradient <linearGradient
inkscape:collect="always" inkscape:collect="always"
xlink:href="#linearGradient3208" xlink:href="#linearGradient3208"
@ -262,14 +255,14 @@
inkscape:pageopacity="0.0" inkscape:pageopacity="0.0"
inkscape:pageshadow="2" inkscape:pageshadow="2"
inkscape:zoom="1.0119683" inkscape:zoom="1.0119683"
inkscape:cx="513.59551" inkscape:cx="501.72348"
inkscape:cy="490.71958" inkscape:cy="187.6618"
inkscape:document-units="px" inkscape:document-units="px"
inkscape:current-layer="layer6" inkscape:current-layer="layer6"
showgrid="false" showgrid="false"
inkscape:window-width="1600" inkscape:window-width="1600"
inkscape:window-height="839" inkscape:window-height="839"
inkscape:window-x="-4" inkscape:window-x="1022"
inkscape:window-y="-3" inkscape:window-y="-3"
inkscape:window-maximized="1" /> inkscape:window-maximized="1" />
<metadata <metadata
@ -287,27 +280,32 @@
inkscape:label="Shadow" inkscape:label="Shadow"
inkscape:groupmode="layer" inkscape:groupmode="layer"
id="layer1" id="layer1"
style="display:inline" /> style="display:inline"
transform="translate(-11.872025,-13.171852)" />
<g <g
inkscape:groupmode="layer" inkscape:groupmode="layer"
id="layer5" id="layer5"
inkscape:label="Border" inkscape:label="Border"
style="display:inline" /> style="display:inline"
transform="translate(-11.872025,-13.171852)" />
<g <g
inkscape:groupmode="layer" inkscape:groupmode="layer"
id="layer3" id="layer3"
inkscape:label="Rays Background" inkscape:label="Rays Background"
style="display:inline" /> style="display:inline"
transform="translate(-11.872025,-13.171852)" />
<g <g
inkscape:groupmode="layer" inkscape:groupmode="layer"
id="layer2" id="layer2"
inkscape:label="Rays Foreground" inkscape:label="Rays Foreground"
style="display:inline" /> style="display:inline"
transform="translate(-11.872025,-13.171852)" />
<g <g
inkscape:groupmode="layer" inkscape:groupmode="layer"
id="layer6" id="layer6"
inkscape:label="Reflection" inkscape:label="Reflection"
style="display:inline"> style="display:inline"
transform="translate(-11.872025,-13.171852)">
<g <g
id="g4018" id="g4018"
transform="translate(9.8817328,9.8817328)"> transform="translate(9.8817328,9.8817328)">
@ -322,14 +320,14 @@
sodipodi:cy="395.26932" sodipodi:cy="395.26932"
sodipodi:cx="475.31134" sodipodi:cx="475.31134"
id="path6903" id="path6903"
style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:5.00028753;stroke-linecap:butt;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;display:inline;filter:url(#filter6926)" style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none;display:inline;filter:url(#filter6926)"
sodipodi:type="arc" /> sodipodi:type="arc" />
<path <path
inkscape:export-ydpi="90" inkscape:export-ydpi="90"
inkscape:export-xdpi="90" inkscape:export-xdpi="90"
inkscape:export-filename="/home/raoul/openlp-logo-0.2.png" inkscape:export-filename="/home/raoul/openlp-logo-0.2.png"
sodipodi:type="arc" sodipodi:type="arc"
style="fill:#051e52;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:5.00028753;stroke-linecap:butt;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;display:inline" style="fill:#051e52;fill-opacity:1;fill-rule:nonzero;stroke:none;display:inline"
id="path6900" id="path6900"
sodipodi:cx="475.31134" sodipodi:cx="475.31134"
sodipodi:cy="395.26932" sodipodi:cy="395.26932"
@ -348,19 +346,19 @@
sodipodi:cy="395.26932" sodipodi:cy="395.26932"
sodipodi:cx="475.31134" sodipodi:cx="475.31134"
id="path6317" id="path6317"
style="fill:url(#linearGradient4053);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:5.00028753;stroke-linecap:butt;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;display:inline" style="fill:url(#linearGradient4053);fill-opacity:1;fill-rule:nonzero;stroke:none;display:inline"
sodipodi:type="arc" /> sodipodi:type="arc" />
<path <path
inkscape:export-ydpi="90" inkscape:export-ydpi="90"
inkscape:export-xdpi="90" inkscape:export-xdpi="90"
inkscape:export-filename="/home/raoul/openlp-logo-0.2.png" inkscape:export-filename="/home/raoul/openlp-logo-0.2.png"
id="path6327" id="path6327"
d="M 235.67972,13.233984 C 199.75196,13.233984 165.79894,21.722639 135.704,36.792417 L 296.72396,165.96674 L 452.81639,291.19091 C 457.1409,273.83274 459.43393,255.67894 459.43393,236.98819 C 459.43393,113.48164 359.18627,13.233985 235.67972,13.233984 z M 79.118968,77.210299 C 71.146114,85.023824 63.764822,93.431949 57.026574,102.35694 L 274.63156,209.66285 L 434.20584,288.36064 L 275.3035,193.86221 L 79.118968,77.210299 z M 24.488653,162.95322 C 20.860793,173.29149 17.984378,183.97391 15.896035,194.94138 L 260.17479,255.29332 L 422.98657,295.52794 L 260.21551,241.36595 L 24.488653,162.95322 z M 13.513722,263.49906 C 14.818764,274.53653 16.911081,285.32646 19.764749,295.81301 L 248.30394,302.32874 L 421.76487,307.29698 L 253.55725,289.23619 L 13.513722,263.49906 z M 428.50457,317.76287 L 249.79034,336.84174 L 47.782384,358.40473 C 53.741585,367.60372 60.347088,376.34577 67.553549,384.54909 L 244.45559,351.80755 L 428.50457,317.76287 z M 442.28941,322.97545 L 253.92376,385.15994 L 120.92144,429.05966 C 154.48464,449.16902 193.73296,460.72203 235.67972,460.72204 C 328.7226,460.72204 408.56552,403.84299 442.28941,322.97545 z" d="m 235.67972,13.233984 c -35.92776,0 -69.88078,8.488655 -99.97572,23.558433 L 296.72396,165.96674 452.81639,291.19091 c 4.32451,-17.35817 6.61754,-35.51197 6.61754,-54.20272 0,-123.50655 -100.24766,-223.754205 -223.75421,-223.754206 z M 79.118968,77.210299 C 71.146114,85.023824 63.764822,93.431949 57.026574,102.35694 L 274.63156,209.66285 434.20584,288.36064 275.3035,193.86221 79.118968,77.210299 z M 24.488653,162.95322 c -3.62786,10.33827 -6.504275,21.02069 -8.592618,31.98816 L 260.17479,255.29332 422.98657,295.52794 260.21551,241.36595 24.488653,162.95322 z M 13.513722,263.49906 c 1.305042,11.03747 3.397359,21.8274 6.251027,32.31395 l 228.539191,6.51573 173.46093,4.96824 L 253.55725,289.23619 13.513722,263.49906 z M 428.50457,317.76287 249.79034,336.84174 47.782384,358.40473 c 5.959201,9.19899 12.564704,17.94104 19.771165,26.14436 L 244.45559,351.80755 428.50457,317.76287 z m 13.78484,5.21258 -188.36565,62.18449 -133.00232,43.89972 c 33.5632,20.10936 72.81152,31.66237 114.75828,31.66238 93.04288,0 172.8858,-56.87905 206.60969,-137.74659 z"
style="fill:url(#linearGradient4055);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:5;stroke-linecap:butt;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;display:inline" /> style="fill:url(#linearGradient4055);fill-opacity:1;fill-rule:nonzero;stroke:none;display:inline" />
<path <path
id="path3203" id="path3203"
d="M 235.67972,13.233984 C 199.75196,13.233984 165.79894,21.722639 135.704,36.792417 L 296.72396,165.96674 L 349.27738,208.13573 C 388.42508,203.26072 423.85383,195.91016 453.73266,186.69491 C 430.89209,87.375898 341.89666,13.233985 235.67972,13.233984 z M 79.118968,77.210299 C 71.146114,85.023824 63.764822,93.431949 57.026574,102.35694 L 274.63156,209.66285 L 282.95948,213.77591 C 290.87301,213.39575 298.68426,212.91815 306.39574,212.35059 L 275.3035,193.86221 L 79.118968,77.210299 z M 24.488653,162.95322 C 21.826867,170.53849 19.56686,178.3145 17.728584,186.24695 C 60.352717,199.56405 114.44154,209.03001 174.67621,212.92072 L 24.488653,162.95322 z" d="m 235.67972,13.233984 c -35.92776,0 -69.88078,8.488655 -99.97572,23.558433 l 161.01996,129.174323 52.55342,42.16899 c 39.1477,-4.87501 74.57645,-12.22557 104.45528,-21.44082 C 430.89209,87.375898 341.89666,13.233985 235.67972,13.233984 z M 79.118968,77.210299 c -7.972854,7.813525 -15.354146,16.22165 -22.092394,25.146641 l 217.604986,107.30591 8.32792,4.11306 c 7.91353,-0.38016 15.72478,-0.85776 23.43626,-1.42532 L 275.3035,193.86221 79.118968,77.210299 z M 24.488653,162.95322 c -2.661786,7.58527 -4.921793,15.36128 -6.760069,23.29373 42.624133,13.3171 96.712956,22.78306 156.947626,26.67377 L 24.488653,162.95322 z"
style="fill:url(#linearGradient4057);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:4.80000019;stroke-linecap:butt;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;display:inline" /> style="fill:url(#linearGradient4057);fill-opacity:1;fill-rule:nonzero;stroke:none;display:inline" />
</g> </g>
</g> </g>
</svg> </svg>

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB