Added a wizard. Non functional yet. Changed OpenLPWizard to allow for no

progressPage to be added.
This commit is contained in:
Patrick Zimmermann 2013-01-08 21:06:57 +01:00
parent a4ce06fa9b
commit d85ede45b8
3 changed files with 154 additions and 6 deletions

View File

@ -79,9 +79,10 @@ class OpenLPWizard(QtGui.QWizard):
Generic OpenLP wizard to provide generic functionality and a unified look Generic OpenLP wizard to provide generic functionality and a unified look
and feel. and feel.
""" """
def __init__(self, parent, plugin, name, image): def __init__(self, parent, plugin, name, image, addProgressPage=True):
QtGui.QWizard.__init__(self, parent) QtGui.QWizard.__init__(self, parent)
self.plugin = plugin self.plugin = plugin
self.withProgressPage = addProgressPage
self.setObjectName(name) self.setObjectName(name)
self.openIcon = build_icon(u':/general/general_open.png') self.openIcon = build_icon(u':/general/general_open.png')
self.deleteIcon = build_icon(u':/general/general_delete.png') self.deleteIcon = build_icon(u':/general/general_delete.png')
@ -92,6 +93,7 @@ class OpenLPWizard(QtGui.QWizard):
self.customInit() self.customInit()
self.customSignals() self.customSignals()
QtCore.QObject.connect(self, QtCore.SIGNAL(u'currentIdChanged(int)'), self.onCurrentIdChanged) QtCore.QObject.connect(self, QtCore.SIGNAL(u'currentIdChanged(int)'), self.onCurrentIdChanged)
if self.withProgressPage:
QtCore.QObject.connect(self.errorCopyToButton, QtCore.SIGNAL(u'clicked()'), self.onErrorCopyToButtonClicked) QtCore.QObject.connect(self.errorCopyToButton, QtCore.SIGNAL(u'clicked()'), self.onErrorCopyToButtonClicked)
QtCore.QObject.connect(self.errorSaveToButton, QtCore.SIGNAL(u'clicked()'), self.onErrorSaveToButtonClicked) QtCore.QObject.connect(self.errorSaveToButton, QtCore.SIGNAL(u'clicked()'), self.onErrorSaveToButtonClicked)
@ -106,6 +108,7 @@ class OpenLPWizard(QtGui.QWizard):
QtGui.QWizard.NoBackButtonOnLastPage) QtGui.QWizard.NoBackButtonOnLastPage)
add_welcome_page(self, image) add_welcome_page(self, image)
self.addCustomPages() self.addCustomPages()
if self.withProgressPage:
self.addProgressPage() self.addProgressPage()
self.retranslateUi() self.retranslateUi()
@ -168,7 +171,7 @@ class OpenLPWizard(QtGui.QWizard):
Stop the wizard on cancel button, close button or ESC key. Stop the wizard on cancel button, close button or ESC key.
""" """
log.debug(u'Wizard cancelled by user.') log.debug(u'Wizard cancelled by user.')
if self.currentPage() == self.progressPage: if self.withProgressPage and self.currentPage() == self.progressPage:
Receiver.send_message(u'openlp_stop_wizard') Receiver.send_message(u'openlp_stop_wizard')
self.done(QtGui.QDialog.Rejected) self.done(QtGui.QDialog.Rejected)
@ -176,7 +179,7 @@ class OpenLPWizard(QtGui.QWizard):
""" """
Perform necessary functions depending on which wizard page is active. Perform necessary functions depending on which wizard page is active.
""" """
if self.page(pageId) == self.progressPage: if self.withProgressPage and self.page(pageId) == self.progressPage:
self.preWizard() self.preWizard()
self.performWizard() self.performWizard()
self.postWizard() self.postWizard()

View File

@ -0,0 +1,139 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
# --------------------------------------------------------------------------- #
# Copyright (c) 2008-2013 Raoul Snyman #
# Portions copyright (c) 2008-2013 Tim Bentley, Gerald Britton, Jonathan #
# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, #
# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. #
# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, #
# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, #
# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, #
# Frode Woldsund, Martin Zibricky, Patrick Zimmermann #
# --------------------------------------------------------------------------- #
# 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 duplicate song removal logic for OpenLP.
"""
import codecs
import logging
import os
from PyQt4 import QtCore, QtGui
from openlp.core.lib import Receiver, Settings, SettingsManager, translate
from openlp.core.lib.ui import UiStrings, critical_error_message_box
from openlp.core.ui.wizard import OpenLPWizard, WizardStrings
from openlp.plugins.songs.lib.importer import SongFormat, SongFormatSelect
log = logging.getLogger(__name__)
class DuplicateSongRemovalForm(OpenLPWizard):
"""
This is the Duplicate Song Removal Wizard. It provides functionality to
search for and remove duplicate songs in the database.
"""
log.info(u'DuplicateSongRemovalForm loaded')
def __init__(self, parent, plugin):
"""
Instantiate the wizard, and run any extra setup we need to.
``parent``
The QWidget-derived parent of the wizard.
``plugin``
The songs plugin.
"""
self.clipboard = plugin.formParent.clipboard
OpenLPWizard.__init__(self, parent, plugin, u'duplicateSongRemovalWizard',
u':/wizards/wizard_importsong.bmp', False)
def customInit(self):
"""
Song wizard specific initialisation.
"""
pass
def customSignals(self):
"""
Song wizard specific signals.
"""
#QtCore.QObject.connect(self.addButton,
# QtCore.SIGNAL(u'clicked()'), self.onAddButtonClicked)
#QtCore.QObject.connect(self.removeButton,
# QtCore.SIGNAL(u'clicked()'), self.onRemoveButtonClicked)
def addCustomPages(self):
"""
Add song wizard specific pages.
"""
self.searchingPage = QtGui.QWizardPage()
self.searchingPage.setObjectName('searchingPage')
self.verticalLayout = QtGui.QVBoxLayout(self.searchingPage)
self.verticalLayout.setObjectName('verticalLayout')
self.duplicateSearchProgressBar = QtGui.QProgressBar(self.searchingPage)
self.duplicateSearchProgressBar.setObjectName(u'duplicateSearchProgressBar')
self.verticalLayout.addWidget(self.duplicateSearchProgressBar)
self.foundDuplicatesEdit = QtGui.QPlainTextEdit(self.searchingPage)
self.foundDuplicatesEdit.setUndoRedoEnabled(False)
self.foundDuplicatesEdit.setReadOnly(True)
self.foundDuplicatesEdit.setObjectName('foundDuplicatesEdit')
self.verticalLayout.addWidget(self.foundDuplicatesEdit)
self.addPage(self.searchingPage)
self.reviewPage = QtGui.QWizardPage()
self.reviewPage.setObjectName('reviewPage')
self.addPage(self.reviewPage)
def retranslateUi(self):
"""
Song wizard localisation.
"""
self.setWindowTitle(translate('Wizard', 'Wizard'))
self.titleLabel.setText(WizardStrings.HeaderStyle % translate('OpenLP.Ui',
'Welcome to the Duplicate Song Removal Wizard'))
self.informationLabel.setText(translate("Wizard",
'This wizard will help you to remove duplicate songs from the song database.'))
self.searchingPage.setTitle(translate('Wizard', 'Searching for doubles'))
self.searchingPage.setSubTitle(translate('Wizard', 'The song database is searched for double songs.'))
def customPageChanged(self, pageId):
"""
Called when changing to a page other than the progress page.
"""
pass
def onAddButtonClicked(self):
pass
def onRemoveButtonClicked(self):
pass
def setDefaults(self):
"""
Set default form values for the song import wizard.
"""
self.restart()
self.foundDuplicatesEdit.clear()
def performWizard(self):
"""
Perform the actual import. This method pulls in the correct importer
class, and then runs the ``doImport`` method of the importer to do
the actual importing.
"""
pass

View File

@ -46,6 +46,8 @@ from openlp.plugins.songs.lib.db import init_schema, Song
from openlp.plugins.songs.lib.importer import SongFormat from openlp.plugins.songs.lib.importer import SongFormat
from openlp.plugins.songs.lib.olpimport import OpenLPSongImport from openlp.plugins.songs.lib.olpimport import OpenLPSongImport
from openlp.plugins.songs.lib.duplicatesongfinder import DuplicateSongFinder from openlp.plugins.songs.lib.duplicatesongfinder import DuplicateSongFinder
from openlp.plugins.songs.forms.duplicatesongremovalform import \
DuplicateSongRemovalForm
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -184,6 +186,10 @@ class SongsPlugin(Plugin):
QtGui.QMessageBox.information(self.formParent, QtGui.QMessageBox.information(self.formParent,
"Double found", str(innerSongCounter) + " " + "Double found", str(innerSongCounter) + " " +
str(outerSongCounter)) str(outerSongCounter))
if not hasattr(self, u'duplicate_removal_wizard'):
self.duplicate_removal_wizard = \
DuplicateSongRemovalForm(self.formParent, self)
self.duplicate_removal_wizard.exec_()
def onSongImportItemClicked(self): def onSongImportItemClicked(self):
if self.mediaItem: if self.mediaItem: