openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #04683
[Merge] lp:~aljsteiner/openlp/openlp into lp:openlp
Albert Steiner has proposed merging lp:~aljsteiner/openlp/openlp into lp:openlp.
Requested reviews:
OpenLP Core (openlp-core)
This re-enables the import of OpenLp1 databases, and fixes the bug #652380. It requires that python2.6 contain all of the sqlite code that was in dashing daniel original release.
--
https://code.launchpad.net/~aljsteiner/openlp/openlp/+merge/42998
Your team OpenLP Core is requested to review the proposed merge of lp:~aljsteiner/openlp/openlp into lp:openlp.
=== modified file 'openlp/plugins/songs/forms/songimportform.py'
--- openlp/plugins/songs/forms/songimportform.py 2010-11-26 14:23:48 +0000
+++ openlp/plugins/songs/forms/songimportform.py 2010-12-07 19:44:09 +0000
@@ -57,9 +57,9 @@
self.registerFields()
self.finishButton = self.button(QtGui.QWizard.FinishButton)
self.cancelButton = self.button(QtGui.QWizard.CancelButton)
- if not SongFormat.get_availability(SongFormat.OpenLP1):
- self.openLP1DisabledWidget.setVisible(True)
- self.openLP1ImportWidget.setVisible(False)
+ # 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)
=== modified file 'openlp/plugins/songs/forms/songimportwizard.py'
--- openlp/plugins/songs/forms/songimportwizard.py 2010-09-30 05:04:43 +0000
+++ openlp/plugins/songs/forms/songimportwizard.py 2010-12-07 19:44:09 +0000
@@ -1,379 +1,376 @@
-# -*- 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 PyQt4 import QtCore, QtGui
-
-from openlp.core.lib import build_icon, translate
-
-class Ui_SongImportWizard(object):
- def setupUi(self, songImportWizard):
- self.openIcon = build_icon(u':/general/general_open.png')
- self.deleteIcon = build_icon(u':/general/general_delete.png')
- songImportWizard.setObjectName(u'songImportWizard')
- songImportWizard.resize(550, 386)
- songImportWizard.setModal(True)
- songImportWizard.setWizardStyle(QtGui.QWizard.ModernStyle)
- songImportWizard.setOptions(
- QtGui.QWizard.IndependentPages |
- QtGui.QWizard.NoBackButtonOnStartPage |
- QtGui.QWizard.NoBackButtonOnLastPage)
- self.welcomePage = QtGui.QWizardPage()
- self.welcomePage.setObjectName(u'welcomePage')
- self.welcomePage.setPixmap(QtGui.QWizard.WatermarkPixmap,
- QtGui.QPixmap(u':/wizards/wizard_importsong.bmp'))
- self.welcomeLayout = QtGui.QHBoxLayout(self.welcomePage)
- self.welcomeLayout.setSpacing(8)
- self.welcomeLayout.setMargin(0)
- self.welcomeLayout.setObjectName(u'welcomeLayout')
- self.welcomeTextLayout = QtGui.QVBoxLayout()
- self.welcomeTextLayout.setSpacing(8)
- self.welcomeTextLayout.setObjectName(u'welcomeTextLayout')
- self.titleLabel = QtGui.QLabel(self.welcomePage)
- self.titleLabel.setObjectName(u'TitleLabel')
- self.welcomeTextLayout.addWidget(self.titleLabel)
- self.welcomeTopSpacer = QtGui.QSpacerItem(20, 40,
- QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed)
- self.welcomeTextLayout.addItem(self.welcomeTopSpacer)
- self.informationLabel = QtGui.QLabel(self.welcomePage)
- self.informationLabel.setWordWrap(True)
- self.informationLabel.setMargin(10)
- self.informationLabel.setObjectName(u'InformationLabel')
- self.welcomeTextLayout.addWidget(self.informationLabel)
- self.welcomeBottomSpacer = QtGui.QSpacerItem(20, 40,
- QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
- self.welcomeTextLayout.addItem(self.welcomeBottomSpacer)
- self.welcomeLayout.addLayout(self.welcomeTextLayout)
- songImportWizard.addPage(self.welcomePage)
- self.sourcePage = QtGui.QWizardPage()
- self.sourcePage.setObjectName(u'SourcePage')
- self.sourceLayout = QtGui.QVBoxLayout(self.sourcePage)
- self.sourceLayout.setSpacing(8)
- self.sourceLayout.setMargin(20)
- self.sourceLayout.setObjectName(u'SourceLayout')
- self.formatLayout = QtGui.QHBoxLayout()
- self.formatLayout.setSpacing(8)
- self.formatLayout.setObjectName(u'FormatLayout')
- self.formatLabel = QtGui.QLabel(self.sourcePage)
- self.formatLabel.setObjectName(u'FormatLabel')
- self.formatLayout.addWidget(self.formatLabel)
- self.formatComboBox = QtGui.QComboBox(self.sourcePage)
- sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.MinimumExpanding,
- QtGui.QSizePolicy.Fixed)
- sizePolicy.setHorizontalStretch(0)
- sizePolicy.setVerticalStretch(0)
- sizePolicy.setHeightForWidth(
- self.formatComboBox.sizePolicy().hasHeightForWidth())
- self.formatComboBox.setSizePolicy(sizePolicy)
- self.formatComboBox.setObjectName(u'formatComboBox')
- self.formatLayout.addWidget(self.formatComboBox)
- self.formatSpacer = QtGui.QSpacerItem(40, 20,
- QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
- self.formatLayout.addItem(self.formatSpacer)
- self.sourceLayout.addLayout(self.formatLayout)
- self.formatStackedWidget = QtGui.QStackedWidget(self.sourcePage)
- self.formatStackedWidget.setObjectName(u'FormatStackedWidget')
- # OpenLP 2.0
- self.addSingleFileSelectItem(u'openLP2')
- # openlp.org 1.x
- self.addSingleFileSelectItem(u'openLP1', None, True)
- # OpenLyrics
- self.addMultiFileSelectItem(u'openLyrics', u'OpenLyrics', True)
- # set OpenLyrics to disabled by default
- self.openLyricsDisabledWidget.setVisible(True)
- self.openLyricsImportWidget.setVisible(False)
- # Open Song
- self.addMultiFileSelectItem(u'openSong', u'OpenSong')
- # Words of Worship
- self.addMultiFileSelectItem(u'wordsOfWorship')
- # CCLI File import
- self.addMultiFileSelectItem(u'ccli')
- # Songs of Fellowship
- self.addMultiFileSelectItem(u'songsOfFellowship', None, True)
- # Generic Document/Presentation import
- self.addMultiFileSelectItem(u'generic', None, True)
- # EasyWorship
- self.addSingleFileSelectItem(u'ew')
- # Words of Worship
- self.addMultiFileSelectItem(u'songBeamer')
-# Commented out for future use.
-# self.addSingleFileSelectItem(u'csv', u'CSV')
- self.sourceLayout.addWidget(self.formatStackedWidget)
- songImportWizard.addPage(self.sourcePage)
- self.importPage = QtGui.QWizardPage()
- self.importPage.setObjectName(u'importPage')
- self.importLayout = QtGui.QVBoxLayout(self.importPage)
- self.importLayout.setSpacing(8)
- self.importLayout.setMargin(50)
- self.importLayout.setObjectName(u'importLayout')
- self.importProgressLabel = QtGui.QLabel(self.importPage)
- self.importProgressLabel.setObjectName(u'importProgressLabel')
- self.importLayout.addWidget(self.importProgressLabel)
- self.importProgressBar = QtGui.QProgressBar(self.importPage)
- self.importProgressBar.setProperty(u'value', 0)
- self.importProgressBar.setInvertedAppearance(False)
- self.importProgressBar.setObjectName(u'importProgressBar')
- self.importLayout.addWidget(self.importProgressBar)
- songImportWizard.addPage(self.importPage)
- self.retranslateUi(songImportWizard)
- self.formatStackedWidget.setCurrentIndex(0)
- QtCore.QObject.connect(self.formatComboBox,
- QtCore.SIGNAL(u'currentIndexChanged(int)'),
- self.formatStackedWidget.setCurrentIndex)
- QtCore.QMetaObject.connectSlotsByName(songImportWizard)
-
- def retranslateUi(self, songImportWizard):
- songImportWizard.setWindowTitle(
- translate('SongsPlugin.ImportWizardForm', 'Song Import Wizard'))
- self.titleLabel.setText(
- u'<span style="font-size:14pt; font-weight:600;">%s</span>' % \
- translate('SongsPlugin.ImportWizardForm',
- 'Welcome to the Song Import Wizard'))
- self.informationLabel.setText(
- translate('SongsPlugin.ImportWizardForm',
- 'This wizard will help you to import songs from a variety of '
- 'formats. Click the next button below to start the process by '
- 'selecting a format to import from.'))
- self.sourcePage.setTitle(
- translate('SongsPlugin.ImportWizardForm', 'Select Import Source'))
- self.sourcePage.setSubTitle(
- translate('SongsPlugin.ImportWizardForm',
- 'Select the import format, and where to import from.'))
- self.formatLabel.setText(
- translate('SongsPlugin.ImportWizardForm', 'Format:'))
- self.formatComboBox.setItemText(0,
- translate('SongsPlugin.ImportWizardForm', 'OpenLP 2.0'))
- self.formatComboBox.setItemText(1,
- translate('SongsPlugin.ImportWizardForm', 'openlp.org 1.x'))
- self.formatComboBox.setItemText(2,
- translate('SongsPlugin.ImportWizardForm', 'OpenLyrics'))
- self.formatComboBox.setItemText(3,
- translate('SongsPlugin.ImportWizardForm', 'OpenSong'))
- self.formatComboBox.setItemText(4,
- translate('SongsPlugin.ImportWizardForm', 'Words of Worship'))
- self.formatComboBox.setItemText(5,
- translate('SongsPlugin.ImportWizardForm', 'CCLI/SongSelect'))
- self.formatComboBox.setItemText(6,
- translate('SongsPlugin.ImportWizardForm', 'Songs of Fellowship'))
- self.formatComboBox.setItemText(7,
- translate('SongsPlugin.ImportWizardForm',
- 'Generic Document/Presentation'))
- self.formatComboBox.setItemText(8,
- translate('SongsPlugin.ImportWizardForm', 'EasyWorship'))
- self.formatComboBox.setItemText(9,
- translate('SongsPlugin.ImportWizardForm', 'SongBeamer'))
-# self.formatComboBox.setItemText(9,
-# translate('SongsPlugin.ImportWizardForm', 'CSV'))
- self.openLP2FilenameLabel.setText(
- translate('SongsPlugin.ImportWizardForm', 'Filename:'))
- self.openLP2BrowseButton.setText(
- translate('SongsPlugin.ImportWizardForm', 'Browse...'))
- self.openLP1FilenameLabel.setText(
- translate('SongsPlugin.ImportWizardForm', 'Filename:'))
- self.openLP1BrowseButton.setText(
- translate('SongsPlugin.ImportWizardForm', 'Browse...'))
- self.openLP1DisabledLabel.setText(
- translate('SongsPlugin.ImportWizardForm', 'The openlp.org 1.x '
- 'importer has been disabled due to a missing Python module. If '
- 'you want to use this importer, you will need to install the '
- '"python-sqlite" module.'))
- #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.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 '
- 'find OpenOffice.org on your computer.'))
- 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 '
- 'find OpenOffice.org on your computer.'))
- self.ewFilenameLabel.setText(
- translate('SongsPlugin.ImportWizardForm', 'Filename:'))
- self.ewBrowseButton.setText(
- translate('SongsPlugin.ImportWizardForm', 'Browse...'))
- self.songBeamerAddButton.setText(
- translate('SongsPlugin.ImportWizardForm', 'Add Files...'))
- self.songBeamerRemoveButton.setText(
- translate('SongsPlugin.ImportWizardForm', 'Remove File(s)'))
-# self.csvFilenameLabel.setText(
-# translate('SongsPlugin.ImportWizardForm', 'Filename:'))
-# self.csvBrowseButton.setText(
-# translate('SongsPlugin.ImportWizardForm', 'Browse...'))
- self.importPage.setTitle(
- translate('SongsPlugin.ImportWizardForm', 'Importing'))
- self.importPage.setSubTitle(
- translate('SongsPlugin.ImportWizardForm',
- 'Please wait while your songs are imported.'))
- self.importProgressLabel.setText(
- translate('SongsPlugin.ImportWizardForm', 'Ready.'))
- self.importProgressBar.setFormat(
- translate('SongsPlugin.ImportWizardForm', '%p%'))
-
- def addSingleFileSelectItem(self, prefix, obj_prefix=None,
- can_disable=False):
- if not obj_prefix:
- obj_prefix = prefix
- page = QtGui.QWidget()
- page.setObjectName(obj_prefix + u'Page')
- if can_disable:
- importWidget = self.disablableWidget(page, prefix, obj_prefix)
- else:
- importWidget = page
- importLayout = QtGui.QFormLayout(importWidget)
- importLayout.setMargin(0)
- importLayout.setSpacing(8)
- if can_disable:
- importLayout.setObjectName(obj_prefix + u'ImportLayout')
- else:
- importLayout.setObjectName(obj_prefix + u'Layout')
- filenameLabel = QtGui.QLabel(importWidget)
- filenameLabel.setObjectName(obj_prefix + u'FilenameLabel')
- importLayout.setWidget(0, QtGui.QFormLayout.LabelRole, filenameLabel)
- fileLayout = QtGui.QHBoxLayout()
- fileLayout.setSpacing(8)
- fileLayout.setObjectName(obj_prefix + u'FileLayout')
- filenameEdit = QtGui.QLineEdit(importWidget)
- filenameEdit.setObjectName(obj_prefix + u'FilenameEdit')
- fileLayout.addWidget(filenameEdit)
- browseButton = QtGui.QToolButton(importWidget)
- browseButton.setIcon(self.openIcon)
- browseButton.setObjectName(obj_prefix + u'BrowseButton')
- fileLayout.addWidget(browseButton)
- importLayout.setLayout(0, QtGui.QFormLayout.FieldRole, fileLayout)
- self.formatStackedWidget.addWidget(page)
- setattr(self, prefix + u'Page', page)
- setattr(self, prefix + u'FilenameLabel', filenameLabel)
- setattr(self, prefix + u'FileLayout', fileLayout)
- setattr(self, prefix + u'FilenameEdit', filenameEdit)
- setattr(self, prefix + u'BrowseButton', browseButton)
- if can_disable:
- setattr(self, prefix + u'ImportLayout', importLayout)
- else:
- setattr(self, prefix + u'Layout', importLayout)
- self.formatComboBox.addItem(u'')
-
- def addMultiFileSelectItem(self, prefix, obj_prefix=None,
- can_disable=False):
- if not obj_prefix:
- obj_prefix = prefix
- page = QtGui.QWidget()
- page.setObjectName(obj_prefix + u'Page')
- if can_disable:
- importWidget = self.disablableWidget(page, prefix, obj_prefix)
- else:
- importWidget = page
- importLayout = QtGui.QVBoxLayout(importWidget)
- importLayout.setMargin(0)
- importLayout.setSpacing(8)
- if can_disable:
- importLayout.setObjectName(obj_prefix + u'ImportLayout')
- else:
- importLayout.setObjectName(obj_prefix + u'Layout')
- fileListWidget = QtGui.QListWidget(importWidget)
- fileListWidget.setSelectionMode(
- QtGui.QAbstractItemView.ExtendedSelection)
- fileListWidget.setObjectName(obj_prefix + u'FileListWidget')
- importLayout.addWidget(fileListWidget)
- buttonLayout = QtGui.QHBoxLayout()
- buttonLayout.setSpacing(8)
- buttonLayout.setObjectName(obj_prefix + u'ButtonLayout')
- addButton = QtGui.QPushButton(importWidget)
- addButton.setIcon(self.openIcon)
- addButton.setObjectName(obj_prefix + u'AddButton')
- buttonLayout.addWidget(addButton)
- buttonSpacer = QtGui.QSpacerItem(40, 20,
- QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
- buttonLayout.addItem(buttonSpacer)
- removeButton = QtGui.QPushButton(importWidget)
- removeButton.setIcon(self.deleteIcon)
- removeButton.setObjectName(obj_prefix + u'RemoveButton')
- buttonLayout.addWidget(removeButton)
- importLayout.addLayout(buttonLayout)
- self.formatStackedWidget.addWidget(page)
- setattr(self, prefix + u'Page', page)
- setattr(self, prefix + u'FileListWidget', fileListWidget)
- setattr(self, prefix + u'ButtonLayout', buttonLayout)
- setattr(self, prefix + u'ButtonSpacer', buttonSpacer)
- setattr(self, prefix + u'AddButton', addButton)
- setattr(self, prefix + u'RemoveButton', removeButton)
- if can_disable:
- setattr(self, prefix + u'ImportLayout', importLayout)
- else:
- setattr(self, prefix + u'Layout', importLayout)
- self.formatComboBox.addItem(u'')
-
- def disablableWidget(self, page, prefix, obj_prefix):
- layout = QtGui.QVBoxLayout(page)
- layout.setMargin(0)
- layout.setSpacing(0)
- layout.setObjectName(obj_prefix + u'Layout')
- disabledWidget = QtGui.QWidget(page)
- disabledWidget.setVisible(False)
- disabledWidget.setObjectName(obj_prefix + u'DisabledWidget')
- disabledLayout = QtGui.QVBoxLayout(disabledWidget)
- disabledLayout.setMargin(0)
- disabledLayout.setSpacing(8)
- disabledLayout.setObjectName(obj_prefix + u'DisabledLayout')
- disabledLabel = QtGui.QLabel(disabledWidget)
- disabledLabel.setWordWrap(True)
- disabledLabel.setObjectName(obj_prefix + u'DisabledLabel')
- disabledLayout.addWidget(disabledLabel)
- layout.addWidget(disabledWidget)
- 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)
- return importWidget
+# -*- 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 PyQt4 import QtCore, QtGui
+
+from openlp.core.lib import build_icon, translate
+
+class Ui_SongImportWizard(object):
+ def setupUi(self, songImportWizard):
+ self.openIcon = build_icon(u':/general/general_open.png')
+ self.deleteIcon = build_icon(u':/general/general_delete.png')
+ songImportWizard.setObjectName(u'songImportWizard')
+ songImportWizard.resize(550, 386)
+ songImportWizard.setModal(True)
+ songImportWizard.setWizardStyle(QtGui.QWizard.ModernStyle)
+ songImportWizard.setOptions(
+ QtGui.QWizard.IndependentPages |
+ QtGui.QWizard.NoBackButtonOnStartPage |
+ QtGui.QWizard.NoBackButtonOnLastPage)
+ self.welcomePage = QtGui.QWizardPage()
+ self.welcomePage.setObjectName(u'welcomePage')
+ self.welcomePage.setPixmap(QtGui.QWizard.WatermarkPixmap,
+ QtGui.QPixmap(u':/wizards/wizard_importsong.bmp'))
+ self.welcomeLayout = QtGui.QHBoxLayout(self.welcomePage)
+ self.welcomeLayout.setSpacing(8)
+ self.welcomeLayout.setMargin(0)
+ self.welcomeLayout.setObjectName(u'welcomeLayout')
+ self.welcomeTextLayout = QtGui.QVBoxLayout()
+ self.welcomeTextLayout.setSpacing(8)
+ self.welcomeTextLayout.setObjectName(u'welcomeTextLayout')
+ self.titleLabel = QtGui.QLabel(self.welcomePage)
+ self.titleLabel.setObjectName(u'TitleLabel')
+ self.welcomeTextLayout.addWidget(self.titleLabel)
+ self.welcomeTopSpacer = QtGui.QSpacerItem(20, 40,
+ QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed)
+ self.welcomeTextLayout.addItem(self.welcomeTopSpacer)
+ self.informationLabel = QtGui.QLabel(self.welcomePage)
+ self.informationLabel.setWordWrap(True)
+ self.informationLabel.setMargin(10)
+ self.informationLabel.setObjectName(u'InformationLabel')
+ self.welcomeTextLayout.addWidget(self.informationLabel)
+ self.welcomeBottomSpacer = QtGui.QSpacerItem(20, 40,
+ QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
+ self.welcomeTextLayout.addItem(self.welcomeBottomSpacer)
+ self.welcomeLayout.addLayout(self.welcomeTextLayout)
+ songImportWizard.addPage(self.welcomePage)
+ self.sourcePage = QtGui.QWizardPage()
+ self.sourcePage.setObjectName(u'SourcePage')
+ self.sourceLayout = QtGui.QVBoxLayout(self.sourcePage)
+ self.sourceLayout.setSpacing(8)
+ self.sourceLayout.setMargin(20)
+ self.sourceLayout.setObjectName(u'SourceLayout')
+ self.formatLayout = QtGui.QHBoxLayout()
+ self.formatLayout.setSpacing(8)
+ self.formatLayout.setObjectName(u'FormatLayout')
+ self.formatLabel = QtGui.QLabel(self.sourcePage)
+ self.formatLabel.setObjectName(u'FormatLabel')
+ self.formatLayout.addWidget(self.formatLabel)
+ self.formatComboBox = QtGui.QComboBox(self.sourcePage)
+ sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.MinimumExpanding,
+ QtGui.QSizePolicy.Fixed)
+ sizePolicy.setHorizontalStretch(0)
+ sizePolicy.setVerticalStretch(0)
+ sizePolicy.setHeightForWidth(
+ self.formatComboBox.sizePolicy().hasHeightForWidth())
+ self.formatComboBox.setSizePolicy(sizePolicy)
+ self.formatComboBox.setObjectName(u'formatComboBox')
+ self.formatLayout.addWidget(self.formatComboBox)
+ self.formatSpacer = QtGui.QSpacerItem(40, 20,
+ QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
+ self.formatLayout.addItem(self.formatSpacer)
+ self.sourceLayout.addLayout(self.formatLayout)
+ self.formatStackedWidget = QtGui.QStackedWidget(self.sourcePage)
+ self.formatStackedWidget.setObjectName(u'FormatStackedWidget')
+ # OpenLP 2.0
+ self.addSingleFileSelectItem(u'openLP2')
+ # openlp.org 1.x
+ self.addSingleFileSelectItem(u'openLP1')
+ # OpenLyrics
+ self.addMultiFileSelectItem(u'openLyrics', u'OpenLyrics', True)
+ # set OpenLyrics to disabled by default
+ self.openLyricsDisabledWidget.setVisible(True)
+ self.openLyricsImportWidget.setVisible(False)
+ # Open Song
+ self.addMultiFileSelectItem(u'openSong', u'OpenSong')
+ # Words of Worship
+ self.addMultiFileSelectItem(u'wordsOfWorship')
+ # CCLI File import
+ self.addMultiFileSelectItem(u'ccli')
+ # Songs of Fellowship
+ self.addMultiFileSelectItem(u'songsOfFellowship', None, True)
+ # Generic Document/Presentation import
+ self.addMultiFileSelectItem(u'generic', None, True)
+ # EasyWorship
+ self.addSingleFileSelectItem(u'ew')
+ # Words of Worship
+ self.addMultiFileSelectItem(u'songBeamer')
+# Commented out for future use.
+# self.addSingleFileSelectItem(u'csv', u'CSV')
+ self.sourceLayout.addWidget(self.formatStackedWidget)
+ songImportWizard.addPage(self.sourcePage)
+ self.importPage = QtGui.QWizardPage()
+ self.importPage.setObjectName(u'importPage')
+ self.importLayout = QtGui.QVBoxLayout(self.importPage)
+ self.importLayout.setSpacing(8)
+ self.importLayout.setMargin(50)
+ self.importLayout.setObjectName(u'importLayout')
+ self.importProgressLabel = QtGui.QLabel(self.importPage)
+ self.importProgressLabel.setObjectName(u'importProgressLabel')
+ self.importLayout.addWidget(self.importProgressLabel)
+ self.importProgressBar = QtGui.QProgressBar(self.importPage)
+ self.importProgressBar.setProperty(u'value', 0)
+ self.importProgressBar.setInvertedAppearance(False)
+ self.importProgressBar.setObjectName(u'importProgressBar')
+ self.importLayout.addWidget(self.importProgressBar)
+ songImportWizard.addPage(self.importPage)
+ self.retranslateUi(songImportWizard)
+ self.formatStackedWidget.setCurrentIndex(0)
+ QtCore.QObject.connect(self.formatComboBox,
+ QtCore.SIGNAL(u'currentIndexChanged(int)'),
+ self.formatStackedWidget.setCurrentIndex)
+ QtCore.QMetaObject.connectSlotsByName(songImportWizard)
+
+ def retranslateUi(self, songImportWizard):
+ songImportWizard.setWindowTitle(
+ translate('SongsPlugin.ImportWizardForm', 'Song Import Wizard'))
+ self.titleLabel.setText(
+ u'<span style="font-size:14pt; font-weight:600;">%s</span>' % \
+ translate('SongsPlugin.ImportWizardForm',
+ 'Welcome to the Song Import Wizard'))
+ self.informationLabel.setText(
+ translate('SongsPlugin.ImportWizardForm',
+ 'This wizard will help you to import songs from a variety of '
+ 'formats. Click the next button below to start the process by '
+ 'selecting a format to import from.'))
+ self.sourcePage.setTitle(
+ translate('SongsPlugin.ImportWizardForm', 'Select Import Source'))
+ self.sourcePage.setSubTitle(
+ translate('SongsPlugin.ImportWizardForm',
+ 'Select the import format, and where to import from.'))
+ self.formatLabel.setText(
+ translate('SongsPlugin.ImportWizardForm', 'Format:'))
+ self.formatComboBox.setItemText(0,
+ translate('SongsPlugin.ImportWizardForm', 'OpenLP 2.0'))
+ self.formatComboBox.setItemText(1,
+ translate('SongsPlugin.ImportWizardForm', 'openlp.org 1.x'))
+ self.formatComboBox.setItemText(2,
+ translate('SongsPlugin.ImportWizardForm', 'OpenLyrics'))
+ self.formatComboBox.setItemText(3,
+ translate('SongsPlugin.ImportWizardForm', 'OpenSong'))
+ self.formatComboBox.setItemText(4,
+ translate('SongsPlugin.ImportWizardForm', 'Words of Worship'))
+ self.formatComboBox.setItemText(5,
+ translate('SongsPlugin.ImportWizardForm', 'CCLI/SongSelect'))
+ self.formatComboBox.setItemText(6,
+ translate('SongsPlugin.ImportWizardForm', 'Songs of Fellowship'))
+ self.formatComboBox.setItemText(7,
+ translate('SongsPlugin.ImportWizardForm',
+ 'Generic Document/Presentation'))
+ self.formatComboBox.setItemText(8,
+ translate('SongsPlugin.ImportWizardForm', 'EasyWorship'))
+ self.formatComboBox.setItemText(9,
+ translate('SongsPlugin.ImportWizardForm', 'SongBeamer'))
+# self.formatComboBox.setItemText(9,
+# translate('SongsPlugin.ImportWizardForm', 'CSV'))
+ self.openLP2FilenameLabel.setText(
+ translate('SongsPlugin.ImportWizardForm', 'Filename:'))
+ self.openLP2BrowseButton.setText(
+ translate('SongsPlugin.ImportWizardForm', 'Browse...'))
+ self.openLP1FilenameLabel.setText(
+ translate('SongsPlugin.ImportWizardForm', 'Filename:'))
+ self.openLP1BrowseButton.setText(
+ translate('SongsPlugin.ImportWizardForm', 'Browse...'))
+ self.formatComboBox.setItemText(1,
+ translate('SongsPlugin.ImportWizardForm', 'openlp.org 1.x'))
+ #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.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 '
+ 'find OpenOffice.org on your computer.'))
+ 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 '
+ 'find OpenOffice.org on your computer.'))
+ self.ewFilenameLabel.setText(
+ translate('SongsPlugin.ImportWizardForm', 'Filename:'))
+ self.ewBrowseButton.setText(
+ translate('SongsPlugin.ImportWizardForm', 'Browse...'))
+ self.songBeamerAddButton.setText(
+ translate('SongsPlugin.ImportWizardForm', 'Add Files...'))
+ self.songBeamerRemoveButton.setText(
+ translate('SongsPlugin.ImportWizardForm', 'Remove File(s)'))
+# self.csvFilenameLabel.setText(
+# translate('SongsPlugin.ImportWizardForm', 'Filename:'))
+# self.csvBrowseButton.setText(
+# translate('SongsPlugin.ImportWizardForm', 'Browse...'))
+ self.importPage.setTitle(
+ translate('SongsPlugin.ImportWizardForm', 'Importing'))
+ self.importPage.setSubTitle(
+ translate('SongsPlugin.ImportWizardForm',
+ 'Please wait while your songs are imported.'))
+ self.importProgressLabel.setText(
+ translate('SongsPlugin.ImportWizardForm', 'Ready.'))
+ self.importProgressBar.setFormat(
+ translate('SongsPlugin.ImportWizardForm', '%p%'))
+
+ def addSingleFileSelectItem(self, prefix, obj_prefix=None,
+ can_disable=False):
+ if not obj_prefix:
+ obj_prefix = prefix
+ page = QtGui.QWidget()
+ page.setObjectName(obj_prefix + u'Page')
+ if can_disable:
+ importWidget = self.disablableWidget(page, prefix, obj_prefix)
+ else:
+ importWidget = page
+ importLayout = QtGui.QFormLayout(importWidget)
+ importLayout.setMargin(0)
+ importLayout.setSpacing(8)
+ if can_disable:
+ importLayout.setObjectName(obj_prefix + u'ImportLayout')
+ else:
+ importLayout.setObjectName(obj_prefix + u'Layout')
+ filenameLabel = QtGui.QLabel(importWidget)
+ filenameLabel.setObjectName(obj_prefix + u'FilenameLabel')
+ importLayout.setWidget(0, QtGui.QFormLayout.LabelRole, filenameLabel)
+ fileLayout = QtGui.QHBoxLayout()
+ fileLayout.setSpacing(8)
+ fileLayout.setObjectName(obj_prefix + u'FileLayout')
+ filenameEdit = QtGui.QLineEdit(importWidget)
+ filenameEdit.setObjectName(obj_prefix + u'FilenameEdit')
+ fileLayout.addWidget(filenameEdit)
+ browseButton = QtGui.QToolButton(importWidget)
+ browseButton.setIcon(self.openIcon)
+ browseButton.setObjectName(obj_prefix + u'BrowseButton')
+ fileLayout.addWidget(browseButton)
+ importLayout.setLayout(0, QtGui.QFormLayout.FieldRole, fileLayout)
+ self.formatStackedWidget.addWidget(page)
+ setattr(self, prefix + u'Page', page)
+ setattr(self, prefix + u'FilenameLabel', filenameLabel)
+ setattr(self, prefix + u'FileLayout', fileLayout)
+ setattr(self, prefix + u'FilenameEdit', filenameEdit)
+ setattr(self, prefix + u'BrowseButton', browseButton)
+ if can_disable:
+ setattr(self, prefix + u'ImportLayout', importLayout)
+ else:
+ setattr(self, prefix + u'Layout', importLayout)
+ self.formatComboBox.addItem(u'')
+
+ def addMultiFileSelectItem(self, prefix, obj_prefix=None,
+ can_disable=False):
+ if not obj_prefix:
+ obj_prefix = prefix
+ page = QtGui.QWidget()
+ page.setObjectName(obj_prefix + u'Page')
+ if can_disable:
+ importWidget = self.disablableWidget(page, prefix, obj_prefix)
+ else:
+ importWidget = page
+ importLayout = QtGui.QVBoxLayout(importWidget)
+ importLayout.setMargin(0)
+ importLayout.setSpacing(8)
+ if can_disable:
+ importLayout.setObjectName(obj_prefix + u'ImportLayout')
+ else:
+ importLayout.setObjectName(obj_prefix + u'Layout')
+ fileListWidget = QtGui.QListWidget(importWidget)
+ fileListWidget.setSelectionMode(
+ QtGui.QAbstractItemView.ExtendedSelection)
+ fileListWidget.setObjectName(obj_prefix + u'FileListWidget')
+ importLayout.addWidget(fileListWidget)
+ buttonLayout = QtGui.QHBoxLayout()
+ buttonLayout.setSpacing(8)
+ buttonLayout.setObjectName(obj_prefix + u'ButtonLayout')
+ addButton = QtGui.QPushButton(importWidget)
+ addButton.setIcon(self.openIcon)
+ addButton.setObjectName(obj_prefix + u'AddButton')
+ buttonLayout.addWidget(addButton)
+ buttonSpacer = QtGui.QSpacerItem(40, 20,
+ QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
+ buttonLayout.addItem(buttonSpacer)
+ removeButton = QtGui.QPushButton(importWidget)
+ removeButton.setIcon(self.deleteIcon)
+ removeButton.setObjectName(obj_prefix + u'RemoveButton')
+ buttonLayout.addWidget(removeButton)
+ importLayout.addLayout(buttonLayout)
+ self.formatStackedWidget.addWidget(page)
+ setattr(self, prefix + u'Page', page)
+ setattr(self, prefix + u'FileListWidget', fileListWidget)
+ setattr(self, prefix + u'ButtonLayout', buttonLayout)
+ setattr(self, prefix + u'ButtonSpacer', buttonSpacer)
+ setattr(self, prefix + u'AddButton', addButton)
+ setattr(self, prefix + u'RemoveButton', removeButton)
+ if can_disable:
+ setattr(self, prefix + u'ImportLayout', importLayout)
+ else:
+ setattr(self, prefix + u'Layout', importLayout)
+ self.formatComboBox.addItem(u'')
+
+ def disablableWidget(self, page, prefix, obj_prefix):
+ layout = QtGui.QVBoxLayout(page)
+ layout.setMargin(0)
+ layout.setSpacing(0)
+ layout.setObjectName(obj_prefix + u'Layout')
+ disabledWidget = QtGui.QWidget(page)
+ disabledWidget.setVisible(False)
+ disabledWidget.setObjectName(obj_prefix + u'DisabledWidget')
+ disabledLayout = QtGui.QVBoxLayout(disabledWidget)
+ disabledLayout.setMargin(0)
+ disabledLayout.setSpacing(8)
+ disabledLayout.setObjectName(obj_prefix + u'DisabledLayout')
+ disabledLabel = QtGui.QLabel(disabledWidget)
+ disabledLabel.setWordWrap(True)
+ disabledLabel.setObjectName(obj_prefix + u'DisabledLabel')
+ disabledLayout.addWidget(disabledLabel)
+ layout.addWidget(disabledWidget)
+ 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)
+ return importWidget
=== modified file 'openlp/plugins/songs/lib/importer.py'
--- openlp/plugins/songs/lib/importer.py 2010-09-30 05:04:43 +0000
+++ openlp/plugins/songs/lib/importer.py 2010-12-07 19:44:09 +0000
@@ -26,16 +26,17 @@
from opensongimport import OpenSongImport
from olpimport import OpenLPSongImport
+from olp1import import OpenLP1SongImport
from wowimport import WowImport
from cclifileimport import CCLIFileImport
from ewimport import EasyWorshipSongImport
from songbeamerimport import SongBeamerImport
# Imports that might fail
-try:
- from olp1import import OpenLP1SongImport
- has_openlp1 = True
-except ImportError:
- has_openlp1 = False
+#try:
+# from olp1import import OpenLP1SongImport
+# has_openlp1 = True
+#except ImportError:
+# has_openlp1 = False
try:
from sofimport import SofImport
has_sof = True
@@ -122,7 +123,7 @@
def get_availability(format):
return SongFormat._format_availability.get(format, True)
-SongFormat.set_availability(SongFormat.OpenLP1, has_openlp1)
+#SongFormat.set_availability(SongFormat.OpenLP1, has_openlp1)
SongFormat.set_availability(SongFormat.SongsOfFellowship, has_sof)
SongFormat.set_availability(SongFormat.Generic, has_ooo)
=== modified file 'openlp/plugins/songs/lib/olp1import.py'
--- openlp/plugins/songs/lib/olp1import.py 2010-11-03 18:03:28 +0000
+++ openlp/plugins/songs/lib/olp1import.py 2010-12-07 19:44:09 +0000
@@ -1,164 +1,165 @@
-# -*- 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 #
-###############################################################################
-"""
-The :mod:`olp1import` module provides the functionality for importing
-openlp.org 1.x song databases into the current installation database.
-"""
-import logging
-import chardet
-import sqlite
-
-from openlp.core.lib import translate
-from songimport import SongImport
-
-log = logging.getLogger(__name__)
-
-class OpenLP1SongImport(SongImport):
- """
- The :class:`OpenLP1SongImport` class provides OpenLP with the ability to
- import song databases from installations of openlp.org 1.x.
- """
- last_encoding = u'windows-1252'
-
- def __init__(self, manager, **kwargs):
- """
- Initialise the import.
-
- ``manager``
- The song manager for the running OpenLP installation.
-
- ``filename``
- The database providing the data to import.
- """
- SongImport.__init__(self, manager)
- self.import_source = kwargs[u'filename']
-
- def decode_string(self, raw, guess):
- """
- Use chardet to detect the encoding of the raw string, and convert it
- to unicode.
-
- ``raw``
- The raw bytestring to decode.
- ``guess``
- What chardet guessed the encoding to be.
- """
- if guess[u'confidence'] < 0.8:
- codec = u'windows-1252'
- else:
- codec = guess[u'encoding']
- try:
- decoded = unicode(raw, codec)
- self.last_encoding = codec
- except UnicodeDecodeError:
- log.exception(
- u'Error in detecting openlp.org 1.x database encoding.')
- try:
- decoded = unicode(raw, self.last_encoding)
- except UnicodeDecodeError:
- # possibly show an error form
- #self.import_wizard.showError(u'There was a problem '
- # u'detecting the encoding of a string')
- decoded = raw
- return decoded
-
- def do_import(self):
- """
- Run the import for an openlp.org 1.x song database.
- """
- # Connect to the database
- connection = sqlite.connect(self.import_source)
- cursor = connection.cursor()
- # Determine if we're using a new or an old DB
- cursor.execute(u'SELECT name FROM sqlite_master '
- u'WHERE type = \'table\' AND name = \'tracks\'')
- table_list = cursor.fetchall()
- new_db = len(table_list) > 0
- # Count the number of records we need to import, for the progress bar
- cursor.execute(u'SELECT COUNT(songid) FROM songs')
- count = int(cursor.fetchone()[0])
- success = True
- self.import_wizard.importProgressBar.setMaximum(count)
- # "cache" our list of authors
- cursor.execute(u'SELECT authorid, authorname FROM authors')
- authors = cursor.fetchall()
- if new_db:
- # "cache" our list of tracks
- cursor.execute(u'SELECT trackid, fulltrackname FROM tracks')
- tracks = cursor.fetchall()
- # Import the songs
- cursor.execute(u'SELECT songid, songtitle, lyrics || \'\' AS lyrics, '
- u'copyrightinfo FROM songs')
- songs = cursor.fetchall()
- for song in songs:
- self.set_defaults()
- if self.stop_import_flag:
- success = False
- break
- song_id = song[0]
- guess = chardet.detect(song[2])
- title = self.decode_string(song[1], guess)
- lyrics = self.decode_string(song[2], guess).replace(u'\r', u'')
- copyright = self.decode_string(song[3], guess)
- self.import_wizard.incrementProgressBar(
- unicode(translate('SongsPlugin.ImportWizardForm',
- 'Importing "%s"...')) % title)
- self.title = title
- self.process_song_text(lyrics)
- self.add_copyright(copyright)
- cursor.execute(u'SELECT authorid FROM songauthors '
- u'WHERE songid = %s' % song_id)
- author_ids = cursor.fetchall()
- for author_id in author_ids:
- if self.stop_import_flag:
- success = False
- break
- for author in authors:
- if author[0] == author_id[0]:
- self.parse_author(self.decode_string(author[1], guess))
- break
- if self.stop_import_flag:
- success = False
- break
- if new_db:
- cursor.execute(u'SELECT trackid FROM songtracks '
- u'WHERE songid = %s ORDER BY listindex' % song_id)
- track_ids = cursor.fetchall()
- for track_id in track_ids:
- if self.stop_import_flag:
- success = False
- break
- for track in tracks:
- if track[0] == track_id[0]:
- self.add_media_file(self.decode_string(track[1],
- guess))
- break
- if self.stop_import_flag:
- success = False
- break
- self.finish()
- return success
-
+# -*- 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 #
+###############################################################################
+"""
+The :mod:`olp1import` module provides the functionality for importing
+openlp.org 1.x song databases into the current installation database.
+"""
+import logging
+import chardet
+import sqlite
+
+from openlp.core.lib import translate
+from songimport import SongImport
+
+log = logging.getLogger(__name__)
+
+class OpenLP1SongImport(SongImport):
+ """
+ The :class:`OpenLP1SongImport` class provides OpenLP with the ability to
+ import song databases from installations of openlp.org 1.x.
+ """
+ last_encoding = u'windows-1252'
+
+ def __init__(self, manager, **kwargs):
+ """
+ Initialise the import.
+
+ ``manager``
+ The song manager for the running OpenLP installation.
+
+ ``filename``
+ The database providing the data to import.
+ """
+ SongImport.__init__(self, manager)
+ self.import_source = kwargs[u'filename']
+
+ def decode_string(self, raw, guess):
+ """
+ Use chardet to detect the encoding of the raw string, and convert it
+ to unicode.
+
+ ``raw``
+ The raw bytestring to decode.
+ ``guess``
+ What chardet guessed the encoding to be.
+ """
+ if guess[u'confidence'] < 0.8:
+ codec = u'windows-1252'
+ else:
+ codec = guess[u'encoding']
+ try:
+ decoded = unicode(raw, codec)
+ self.last_encoding = codec
+ except UnicodeDecodeError:
+ log.exception(
+ u'Error in detecting openlp.org 1.x database encoding.')
+ try:
+ decoded = unicode(raw, u'windows-1252')
+ except UnicodeDecodeError:
+ # possibly show an error form
+ #self.import_wizard.showError(u'There was a problem '
+ # u'detecting the encoding of a string')
+ decoded = raw
+ return decoded
+
+ def do_import(self):
+ """
+ Run the import for an openlp.org 1.x song database.
+ """
+ # Connect to the database
+ connection = sqlite.connect(self.import_source)
+ cursor = connection.cursor()
+ # Determine if we're using a new or an old DB
+ cursor.execute(u'SELECT name FROM sqlite_master '
+ u'WHERE type = \'table\' AND name = \'tracks\'')
+ table_list = cursor.fetchall()
+ new_db = len(table_list) > 0
+ # Count the number of records we need to import, for the progress bar
+ cursor.execute(u'SELECT COUNT(songid) FROM songs')
+ count = int(cursor.fetchone()[0])
+ success = True
+ self.import_wizard.importProgressBar.setMaximum(count)
+ # "cache" our list of authors
+ cursor.execute(u'SELECT authorid, authorname FROM authors')
+ authors = cursor.fetchall()
+ if new_db:
+ # "cache" our list of tracks
+ cursor.execute(u'SELECT trackid, fulltrackname FROM tracks')
+ tracks = cursor.fetchall()
+ # Import the songs
+ cursor.execute(u'SELECT songid, songtitle, lyrics || \'\' AS lyrics, '
+ u'copyrightinfo FROM songs')
+ songs = cursor.fetchall()
+ for song in songs:
+ self.set_defaults()
+ if self.stop_import_flag:
+ success = False
+ break
+ song_id = song[0]
+ guess = chardet.detect(song[2])
+ title = self.decode_string(song[1], guess)
+ lyrics = self.decode_string(song[2], guess).replace(u'\r', u'')
+ guess3 = chardet.detect(song[3])
+ copyright = self.decode_string(song[3], guess3)
+ self.import_wizard.incrementProgressBar(
+ unicode(translate('SongsPlugin.ImportWizardForm',
+ 'Importing "%s"...')) % title)
+ self.title = title
+ self.process_song_text(lyrics)
+ self.add_copyright(copyright)
+ cursor.execute(u'SELECT authorid FROM songauthors '
+ u'WHERE songid = %s' % song_id)
+ author_ids = cursor.fetchall()
+ for author_id in author_ids:
+ if self.stop_import_flag:
+ success = False
+ break
+ for author in authors:
+ if author[0] == author_id[0]:
+ self.parse_author(self.decode_string(author[1], guess))
+ break
+ if self.stop_import_flag:
+ success = False
+ break
+ if new_db:
+ cursor.execute(u'SELECT trackid FROM songtracks '
+ u'WHERE songid = %s ORDER BY listindex' % song_id)
+ track_ids = cursor.fetchall()
+ for track_id in track_ids:
+ if self.stop_import_flag:
+ success = False
+ break
+ for track in tracks:
+ if track[0] == track_id[0]:
+ self.add_media_file(self.decode_string(track[1],
+ guess))
+ break
+ if self.stop_import_flag:
+ success = False
+ break
+ self.finish()
+ return success
+
=== modified file 'scripts/openlp-1to2-converter.py'
--- scripts/openlp-1to2-converter.py 2010-07-27 09:32:52 +0000
+++ scripts/openlp-1to2-converter.py 2010-12-07 19:44:09 +0000
@@ -253,7 +253,7 @@
+ str(sys.exc_info()[1])
else:
errormsg = sys.exc_info()[1]
- print 'There was a problem connecting to the old database:', errormsg
+ print 'There was a sqlite problem connecting to the old database:', errormsg
return 1
try:
new_connection = sqlite3.connect(new_db)
Follow ups