From e2124942ccc42bb482330283e11c4cf424d096f7 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Tue, 11 Jan 2011 17:49:53 +0100 Subject: [PATCH 1/9] clean ups --- openlp/plugins/songs/lib/mediaitem.py | 2 +- openlp/plugins/songs/lib/openlyricsimport.py | 2 +- openlp/plugins/songs/lib/xml.py | 17 +++++++++-------- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 5d6544346..858d7bbf2 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -448,7 +448,7 @@ class SongMediaItem(MediaManagerItem): if self.addSongFromService: editId = self.openLyrics.xml_to_song(item.xml_version) # Update service with correct song id. - if editId != 0: + if editId is not None: Receiver.send_message(u'service_item_update', u'%s:%s' % (editId, item._uuid)) diff --git a/openlp/plugins/songs/lib/openlyricsimport.py b/openlp/plugins/songs/lib/openlyricsimport.py index f11ba7642..c4610dfc0 100644 --- a/openlp/plugins/songs/lib/openlyricsimport.py +++ b/openlp/plugins/songs/lib/openlyricsimport.py @@ -70,7 +70,7 @@ class OpenLyricsImport(SongImport): parser = etree.XMLParser(remove_blank_text=True) file = etree.parse(file_path, parser) xml = unicode(etree.tostring(file)) - if self.openLyrics.xml_to_song(xml) == 0: + if self.openLyrics.xml_to_song(xml) is None: log.debug(u'File could not be imported: %s' % file_path) # Importing this song failed! For now we stop import. return False diff --git a/openlp/plugins/songs/lib/xml.py b/openlp/plugins/songs/lib/xml.py index 588ff923c..cbe313212 100644 --- a/openlp/plugins/songs/lib/xml.py +++ b/openlp/plugins/songs/lib/xml.py @@ -143,10 +143,11 @@ class SongXML(object): class OpenLyrics(object): """ - This class represents the converter for OpenLyrics XML to/from a song. + This class represents the converter for OpenLyrics XML (version 0.7) + to/from a song. As OpenLyrics has a rich set of different features, we cannot support them - all. The following features are supported by the :class:`OpenLyricsParser`:: + all. The following features are supported by the :class:`OpenLyrics`:: ** OpenLP does not support the attribute *type* and *lang*. @@ -203,7 +204,7 @@ class OpenLyrics(object): def __init__(self, manager): self.manager = manager - def song_to_xml(self, song, pretty_print=False): + def song_to_xml(self, song): """ Convert the song to OpenLyrics Format. """ @@ -253,7 +254,7 @@ class OpenLyrics(object): element = self._add_text_to_element(u'lines', element) for line in unicode(verse[1]).split(u'\n'): self._add_text_to_element(u'line', element, line) - return self._extract_xml(song_xml, pretty_print) + return self._extract_xml(song_xml) def xml_to_song(self, xml): """ @@ -266,7 +267,7 @@ class OpenLyrics(object): """ # No xml get out of here. if not xml: - return 0 + return None song = Song() if xml[:5] == u' Date: Tue, 11 Jan 2011 20:56:55 +0100 Subject: [PATCH 2/9] removed showprogress and hideprogress and added cursor_busy and cursor_normal --- openlp/core/lib/eventreceiver.py | 6 ------ openlp/plugins/bibles/lib/http.py | 4 ++-- openlp/plugins/bibles/lib/mediaitem.py | 29 -------------------------- 3 files changed, 2 insertions(+), 37 deletions(-) diff --git a/openlp/core/lib/eventreceiver.py b/openlp/core/lib/eventreceiver.py index 63ad5b796..5811ae933 100644 --- a/openlp/core/lib/eventreceiver.py +++ b/openlp/core/lib/eventreceiver.py @@ -207,12 +207,6 @@ class EventReceiver(QtCore.QObject): ``bibles_nobook`` Attempt to find book resulted in no match - ``bibles_showprogress`` - Show progress of bible verse import - - ``bibles_hideprogress`` - Hide progress of bible verse import - ``bibles_stop_import`` Stops the Bible Import diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index 54fb5237c..05880871f 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -438,7 +438,7 @@ class HTTPBible(BibleDB): book_details[u'testament_id']) book = db_book.name if BibleDB.get_verse_count(self, book, reference[1]) == 0: - Receiver.send_message(u'bibles_showprogress') + Receiver.send_message(u'cursor_busy') Receiver.send_message(u'openlp_process_events') search_results = self.get_chapter(book, reference[1]) if search_results and search_results.has_verselist(): @@ -453,7 +453,7 @@ class HTTPBible(BibleDB): self.create_chapter(db_book.id, search_results.chapter, search_results.verselist) Receiver.send_message(u'openlp_process_events') - Receiver.send_message(u'bibles_hideprogress') + Receiver.send_message(u'cursor_normal') Receiver.send_message(u'openlp_process_events') return BibleDB.get_verses(self, reference_list) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 253cc2c62..a21a993ce 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -44,10 +44,6 @@ class BibleListView(BaseListWithDnD): self.PluginName = u'Bibles' BaseListWithDnD.__init__(self, parent) - def resizeEvent(self, event): - self.parent().onListViewResize(event.size().width(), - event.size().width()) - class BibleMediaItem(MediaManagerItem): """ @@ -257,22 +253,9 @@ class BibleMediaItem(MediaManagerItem): # Other stuff QtCore.QObject.connect(self.quickSearchEdit, QtCore.SIGNAL(u'returnPressed()'), self.onQuickSearchButton) - QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'bibles_showprogress'), self.onSearchProgressShow) - QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'bibles_hideprogress'), self.onSearchProgressHide) def addListViewToToolBar(self): MediaManagerItem.addListViewToToolBar(self) - # Progress Bar - self.SearchProgress = QtGui.QProgressBar(self) - self.SearchProgress.setFormat('') - self.SearchProgress.setMinimum(0) - self.SearchProgress.setMaximum(0) - self.SearchProgress.setGeometry(self.listView.geometry().left(), - self.listView.geometry().top(), 81, 23) - self.SearchProgress.setVisible(False) - self.SearchProgress.setObjectName(u'SearchProgress') def configUpdated(self): log.debug(u'configUpdated') @@ -341,18 +324,6 @@ class BibleMediaItem(MediaManagerItem): self.configUpdated() log.debug(u'bible manager initialise complete') - def onListViewResize(self, width, height): - listViewGeometry = self.listView.geometry() - self.SearchProgress.setGeometry(listViewGeometry.x(), - (listViewGeometry.y() + listViewGeometry.height()) - 23, 81, 23) - - def onSearchProgressShow(self): - self.SearchProgress.setVisible(True) - Receiver.send_message(u'openlp_process_events') - - def onSearchProgressHide(self): - self.SearchProgress.setVisible(False) - def onImportClick(self): if not hasattr(self, u'import_wizard'): self.import_wizard = BibleImportForm(self, self.parent.manager, From 64367909ba07a7c13a74e4217b52698f9904f680 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Wed, 12 Jan 2011 15:31:32 +0000 Subject: [PATCH 3/9] Improve bibleserver code resiliance --- openlp/plugins/bibles/lib/http.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index 2476ae65d..e7beeda29 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -269,11 +269,12 @@ class BSExtract(object): if not soup: return None Receiver.send_message(u'openlp_process_events') - content = soup.find(u'div', u'content').find(u'div').findAll(u'div') + content = soup.find(u'div', u'content') if not content: log.exception(u'No verses found in the Bibleserver response.') send_error_message(u'parse') return None + content = content.find(u'div').findAll(u'div') verse_number = re.compile(r'v(\d{1,2})(\d{3})(\d{3}) verse') verses = {} for verse in content: From 9bb2b942a015c137a97a392745b73c6204f93d51 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 12 Jan 2011 17:45:32 +0100 Subject: [PATCH 4/9] fix for merge --- openlp/plugins/songs/lib/mediaitem.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 858d7bbf2..93e40f58a 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -448,7 +448,7 @@ class SongMediaItem(MediaManagerItem): if self.addSongFromService: editId = self.openLyrics.xml_to_song(item.xml_version) # Update service with correct song id. - if editId is not None: + if editId: Receiver.send_message(u'service_item_update', u'%s:%s' % (editId, item._uuid)) From 0a5b44c6a35588bba808d0bd28716c916f44d58c Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Wed, 12 Jan 2011 19:12:30 +0000 Subject: [PATCH 5/9] BibleGateway fix --- openlp/plugins/bibles/lib/http.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index e7beeda29..da3a1e9e5 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -208,7 +208,8 @@ class BGExtract(object): u'version': u'%s' % version}) cleaner = [(re.compile(' |
|\'\+\''), lambda match: '')] soup = get_soup_for_bible_ref( - u'http://www.biblegateway.com/passage/?%s' % url_params, cleaner) + u'http://www.biblegateway.com/passage/?%s' % url_params, + cleaner=cleaner) if not soup: return None Receiver.send_message(u'openlp_process_events') From 727f7fe7bf5163f350478cf1a3038b562a5734bb Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 12 Jan 2011 20:31:46 +0100 Subject: [PATCH 6/9] --- openlp/core/lib/mediamanageritem.py | 10 +++++----- openlp/core/lib/serviceitem.py | 1 + openlp/core/ui/slidecontroller.py | 20 ++++++++++++-------- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 2d6bcce46..6fb834e05 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -266,7 +266,7 @@ class MediaManagerItem(QtGui.QWidget): """ Creates the main widget for listing items the media item is tracking """ - #Add the List widget + # Add the List widget self.listView = self.ListViewWithDnD_class(self) self.listView.uniformItemSizes = True self.listView.setSpacing(1) @@ -275,9 +275,9 @@ class MediaManagerItem(QtGui.QWidget): self.listView.setAlternatingRowColors(True) self.listView.setDragEnabled(True) self.listView.setObjectName(u'%sListView' % self.plugin.name) - #Add to pageLayout + # Add to pageLayout self.pageLayout.addWidget(self.listView) - #define and add the context menu + # define and add the context menu self.listView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) name_string = self.plugin.getString(StringContent.Name) if self.hasEditIcon: @@ -314,7 +314,7 @@ class MediaManagerItem(QtGui.QWidget): context_menu_action( self.listView, u':/general/general_add.png', translate('OpenLP.MediaManagerItem', - '&Add to selected Service Item'), + '&Add to selected Service Item'), self.onAddEditClick)) QtCore.QObject.connect(self.listView, QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), @@ -441,7 +441,7 @@ class MediaManagerItem(QtGui.QWidget): QtGui.QMessageBox.information(self, translate('OpenLP.MediaManagerItem', 'No Items Selected'), translate('OpenLP.MediaManagerItem', - 'You must select one or more items to preview.')) + 'You must select one or more items to preview.')) else: log.debug(u'%s Preview requested', self.plugin.name) serviceItem = self.buildServiceItem() diff --git a/openlp/core/lib/serviceitem.py b/openlp/core/lib/serviceitem.py index f18605711..ce0907fbb 100644 --- a/openlp/core/lib/serviceitem.py +++ b/openlp/core/lib/serviceitem.py @@ -60,6 +60,7 @@ class ItemCapabilities(object): AddIfNewItem = 9 ProvidesOwnDisplay = 10 + class ServiceItem(object): """ The service item is a base class for the plugins to use to interact with diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 690cb9264..92b59a900 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -412,13 +412,17 @@ class SlideController(QtGui.QWidget): max_width = self.PreviewFrame.width() - self.grid.margin() * 2 self.SlidePreview.setFixedSize(QtCore.QSize(max_width, max_width / self.ratio)) - width = self.parent.ControlSplitter.sizes()[self.split] - self.PreviewListWidget.setColumnWidth(0, width) - # Sort out image heights (Songs, bibles excluded) - if self.serviceItem and not self.serviceItem.is_text(): - for framenumber in range(len(self.serviceItem.get_frames())): - self.PreviewListWidget.setRowHeight( - framenumber, width / self.ratio) + # Make sure that the frames have the correct size. + if self.serviceItem: + self.PreviewListWidget.resizeRowsToContents() + # Sort out image heights (Songs, bibles excluded) + if not self.serviceItem.is_text(): + width = self.parent.ControlSplitter.sizes()[self.split] + for framenumber in range(len(self.serviceItem.get_frames())): + self.PreviewListWidget.setRowHeight( + framenumber, width / self.ratio) + self.PreviewListWidget.setColumnWidth(0, + self.PreviewListWidget.viewport().size().width()) def onSongBarHandler(self): request = unicode(self.sender().text()) @@ -590,7 +594,7 @@ class SlideController(QtGui.QWidget): self.parent.renderManager.height) else: image = self.parent.renderManager.image_manager. \ - get_image(frame[u'title']) + get_image(frame[u'title']) label.setPixmap(QtGui.QPixmap.fromImage(image)) self.PreviewListWidget.setCellWidget(framenumber, 0, label) slideHeight = width * self.parent.renderManager.screen_ratio From 7f5293c4c8ba8fbe28913e7488868762ba2807c3 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Thu, 13 Jan 2011 01:14:38 +0000 Subject: [PATCH 7/9] Cleanup and refactor file unicode check --- openlp/core/lib/imagemanager.py | 1 - openlp/core/ui/servicemanager.py | 12 ++++-------- openlp/core/ui/thememanager.py | 21 ++++++--------------- openlp/core/utils/__init__.py | 22 +++++++++++++++++++++- 4 files changed, 31 insertions(+), 25 deletions(-) diff --git a/openlp/core/lib/imagemanager.py b/openlp/core/lib/imagemanager.py index dcfc50f0f..02d7010be 100644 --- a/openlp/core/lib/imagemanager.py +++ b/openlp/core/lib/imagemanager.py @@ -30,7 +30,6 @@ A Thread is used to convert the image to a byte array so the user does not need to wait for the conversion to happen. """ import logging -import os import time from PyQt4 import QtCore diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 2d85e4b7f..ffc2bee25 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -37,7 +37,7 @@ from openlp.core.lib import OpenLPToolbar, ServiceItem, context_menu_action, \ Receiver, build_icon, ItemCapabilities, SettingsManager, translate, \ ThemeLevel from openlp.core.ui import ServiceNoteForm, ServiceItemEditForm -from openlp.core.utils import AppLocation, split_filename +from openlp.core.utils import AppLocation, file_is_unicode, split_filename class ServiceManagerList(QtGui.QTreeWidget): """ @@ -484,16 +484,13 @@ class ServiceManager(QtGui.QWidget): try: zip = zipfile.ZipFile(fileName) for file in zip.namelist(): - try: - ucsfile = file.decode(u'utf-8') - except UnicodeDecodeError: + ucsfile = file_is_unicode(file) + if not ucsfile: QtGui.QMessageBox.critical( self, translate('OpenLP.ServiceManager', 'Error'), translate('OpenLP.ServiceManager', 'File is not a valid service.\n' 'The content encoding is not UTF-8.')) - log.exception(u'Filename "%s" is not valid UTF-8' % - file.decode(u'utf-8', u'replace')) continue osfile = unicode(QtCore.QDir.toNativeSeparators(ucsfile)) filePath = os.path.join(self.servicePath, @@ -515,8 +512,7 @@ class ServiceManager(QtGui.QWidget): serviceItem.set_from_service(item, self.servicePath) self.validateItem(serviceItem) self.addServiceItem(serviceItem) - if serviceItem.is_capable( - ItemCapabilities.OnLoadUpdate): + if serviceItem.is_capable(ItemCapabilities.OnLoadUpdate): Receiver.send_message(u'%s_service_load' % serviceItem.name.lower(), serviceItem) try: diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 73f1a6d8b..81e191396 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -37,7 +37,8 @@ from openlp.core.theme import Theme from openlp.core.lib import OpenLPToolbar, ThemeXML, get_text_file_string, \ build_icon, Receiver, SettingsManager, translate, check_item_selected, \ BackgroundType, BackgroundGradientType, check_directory_exists -from openlp.core.utils import AppLocation, get_filesystem_encoding +from openlp.core.utils import AppLocation, file_is_unicode, \ + get_filesystem_encoding log = logging.getLogger(__name__) @@ -475,7 +476,8 @@ class ThemeManager(QtGui.QWidget): unicode(themeName) + u'.xml') xml = get_text_file_string(xmlFile) if not xml: - return self._baseTheme() + log.debug("No theme data - using default theme") + return ThemeXML() else: return self._createThemeFromXml(xml, self.path) @@ -494,16 +496,13 @@ class ThemeManager(QtGui.QWidget): filexml = None themename = None for file in zip.namelist(): - try: - ucsfile = file.decode(u'utf-8') - except UnicodeDecodeError: + ucsfile = file_is_unicode(file) + if not ucsfile: QtGui.QMessageBox.critical( self, translate('OpenLP.ThemeManager', 'Error'), translate('OpenLP.ThemeManager', 'File is not a valid theme.\n' 'The content encoding is not UTF-8.')) - log.exception(u'Filename "%s" is not valid UTF-8' % - file.decode(u'utf-8', u'replace')) continue osfile = unicode(QtCore.QDir.toNativeSeparators(ucsfile)) theme_dir = None @@ -668,14 +667,6 @@ class ThemeManager(QtGui.QWidget): image = os.path.join(self.path, theme + u'.png') return image - def _baseTheme(self): - """ - Provide a base theme with sensible defaults - """ - log.debug(u'base theme created') - newtheme = ThemeXML() - return newtheme - def _createThemeFromXml(self, themeXml, path): """ Return a theme object using information parsed from XML diff --git a/openlp/core/utils/__init__.py b/openlp/core/utils/__init__.py index ccdb2afa1..75f00f298 100644 --- a/openlp/core/utils/__init__.py +++ b/openlp/core/utils/__init__.py @@ -317,9 +317,29 @@ def get_web_page(url, header=None, update_openlp=False): Receiver.send_message(u'openlp_process_events') return page +def file_is_unicode(filename): + """ + Checks if a file is valid unicode and returns the unicode decoded file or + None. + + ``filename`` + File to check is valid unicode. + """ + if not filename: + return None + ucsfile = None + try: + ucsfile = filename.decode(u'utf-8') + except UnicodeDecodeError: + log.exception(u'Filename "%s" is not valid UTF-8' % + filename.decode(u'utf-8', u'replace')) + if not ucsfile: + return None + return ucsfile + from languagemanager import LanguageManager from actions import ActionList __all__ = [u'AppLocation', u'check_latest_version', u'add_actions', u'get_filesystem_encoding', u'LanguageManager', u'ActionList', - u'get_web_page'] + u'get_web_page', u'file_is_unicode'] From f487464280f87594adcb9da463aa0fedfe70e753 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Thu, 13 Jan 2011 02:28:03 +0000 Subject: [PATCH 8/9] Cleanup exceptions --- openlp/plugins/bibles/lib/csvbible.py | 2 +- openlp/plugins/bibles/lib/opensong.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/bibles/lib/csvbible.py b/openlp/plugins/bibles/lib/csvbible.py index 8b1d70128..2e9e9523b 100644 --- a/openlp/plugins/bibles/lib/csvbible.py +++ b/openlp/plugins/bibles/lib/csvbible.py @@ -72,7 +72,7 @@ class CSVBible(BibleDB): self.create_book(unicode(line[1], details['encoding']), line[2], int(line[0])) Receiver.send_message(u'openlp_process_events') - except IOError, IndexError: + except (IOError, IndexError): log.exception(u'Loading books from file failed') success = False finally: diff --git a/openlp/plugins/bibles/lib/opensong.py b/openlp/plugins/bibles/lib/opensong.py index c0b60f911..03d243390 100644 --- a/openlp/plugins/bibles/lib/opensong.py +++ b/openlp/plugins/bibles/lib/opensong.py @@ -89,7 +89,7 @@ class OpenSongBible(BibleDB): 'Importing ...')) % (db_book.name, int(chapter.attrib[u'n']))) self.session.commit() - except IOError, AttributeError: + except (IOError, AttributeError): log.exception(u'Loading bible from OpenSong file failed') success = False finally: From 74909281907a29f17bc1e324fa6267cdb03d27eb Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Thu, 13 Jan 2011 17:55:29 +0000 Subject: [PATCH 9/9] Refactor wizards --- openlp/core/lib/eventreceiver.py | 4 +- openlp/core/ui/wizard.py | 171 ++++++ openlp/core/utils/__init__.py | 21 +- .../plugins/bibles/forms/bibleimportform.py | 522 ++++++++++++++---- .../plugins/bibles/forms/bibleimportwizard.py | 391 ------------- openlp/plugins/bibles/lib/csvbible.py | 4 +- openlp/plugins/bibles/lib/http.py | 18 +- openlp/plugins/bibles/lib/mediaitem.py | 2 +- openlp/plugins/bibles/lib/openlp1.py | 6 +- openlp/plugins/bibles/lib/opensong.py | 4 +- openlp/plugins/bibles/lib/osis.py | 8 +- openlp/plugins/songs/forms/songimportform.py | 444 +++++++++++++-- .../plugins/songs/forms/songimportwizard.py | 362 ------------ openlp/plugins/songs/lib/cclifileimport.py | 2 +- openlp/plugins/songs/lib/ewimport.py | 2 +- openlp/plugins/songs/lib/olp1import.py | 2 +- openlp/plugins/songs/lib/olpimport.py | 2 +- openlp/plugins/songs/lib/oooimport.py | 6 +- openlp/plugins/songs/lib/openlyricsimport.py | 6 +- openlp/plugins/songs/lib/opensongimport.py | 2 +- openlp/plugins/songs/lib/sofimport.py | 4 +- openlp/plugins/songs/lib/songbeamerimport.py | 3 +- openlp/plugins/songs/lib/songimport.py | 4 +- .../songs/lib/test/test_opensongimport.py | 2 +- openlp/plugins/songs/lib/wowimport.py | 4 +- 25 files changed, 1029 insertions(+), 967 deletions(-) create mode 100644 openlp/core/ui/wizard.py delete mode 100644 openlp/plugins/bibles/forms/bibleimportwizard.py delete mode 100644 openlp/plugins/songs/forms/songimportwizard.py diff --git a/openlp/core/lib/eventreceiver.py b/openlp/core/lib/eventreceiver.py index 5811ae933..6fa8e624a 100644 --- a/openlp/core/lib/eventreceiver.py +++ b/openlp/core/lib/eventreceiver.py @@ -207,8 +207,8 @@ class EventReceiver(QtCore.QObject): ``bibles_nobook`` Attempt to find book resulted in no match - ``bibles_stop_import`` - Stops the Bible Import + ``openlp_stop_wizard`` + Stops a wizard before completion ``remotes_poll_request`` Waits for openlp to do something "interesting" and sends a diff --git a/openlp/core/ui/wizard.py b/openlp/core/ui/wizard.py new file mode 100644 index 000000000..3b221455b --- /dev/null +++ b/openlp/core/ui/wizard.py @@ -0,0 +1,171 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2011 Raoul Snyman # +# Portions copyright (c) 2008-2011 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:``wizard`` module provides generic wizard tools for OpenLP. +""" +import logging + +from PyQt4 import QtCore, QtGui + +from openlp.core.lib import build_icon, Receiver + +log = logging.getLogger(__name__) + +class OpenLPWizard(QtGui.QWizard): + """ + Generic OpenLP wizard to provide generic functionality and a unified look + and feel. + """ + def __init__(self, parent, plugin, name, image): + QtGui.QWizard.__init__(self, parent) + self.setObjectName(name) + self.openIcon = build_icon(u':/general/general_open.png') + self.deleteIcon = build_icon(u':/general/general_delete.png') + self.finishButton = self.button(QtGui.QWizard.FinishButton) + self.cancelButton = self.button(QtGui.QWizard.CancelButton) + self.setupUi(image) + self.registerFields() + self.plugin = plugin + self.customInit() + self.customSignals() + QtCore.QObject.connect(self, QtCore.SIGNAL(u'currentIdChanged(int)'), + self.onCurrentIdChanged) + + def setupUi(self, image): + """ + Set up the wizard UI + """ + self.setModal(True) + self.setWizardStyle(QtGui.QWizard.ModernStyle) + self.setOptions(QtGui.QWizard.IndependentPages | + QtGui.QWizard.NoBackButtonOnStartPage | + QtGui.QWizard.NoBackButtonOnLastPage) + self.addWelcomePage(image) + self.addCustomPages() + self.addProgressPage() + self.retranslateUi() + QtCore.QMetaObject.connectSlotsByName(self) + + def addWelcomePage(self, image): + """ + Add the opening welcome page to the wizard. + + ``image`` + A splash image for the wizard + """ + self.welcomePage = QtGui.QWizardPage() + self.welcomePage.setPixmap(QtGui.QWizard.WatermarkPixmap, + QtGui.QPixmap(image)) + self.welcomePage.setObjectName(u'WelcomePage') + self.welcomeLayout = QtGui.QVBoxLayout(self.welcomePage) + self.welcomeLayout.setObjectName(u'WelcomeLayout') + self.titleLabel = QtGui.QLabel(self.welcomePage) + self.titleLabel.setObjectName(u'TitleLabel') + self.welcomeLayout.addWidget(self.titleLabel) + self.welcomeLayout.addSpacing(40) + self.informationLabel = QtGui.QLabel(self.welcomePage) + self.informationLabel.setWordWrap(True) + self.informationLabel.setObjectName(u'InformationLabel') + self.welcomeLayout.addWidget(self.informationLabel) + self.welcomeLayout.addStretch() + self.addPage(self.welcomePage) + + def addProgressPage(self): + """ + Add the progress page for the wizard. This page informs the user how + the wizard is progressing with its task. + """ + self.progressPage = QtGui.QWizardPage() + self.progressPage.setObjectName(u'progressPage') + self.progressLayout = QtGui.QVBoxLayout(self.progressPage) + self.progressLayout.setMargin(48) + self.progressLayout.setObjectName(u'progressLayout') + self.progressLabel = QtGui.QLabel(self.progressPage) + self.progressLabel.setObjectName(u'progressLabel') + self.progressLayout.addWidget(self.progressLabel) + self.progressBar = QtGui.QProgressBar(self.progressPage) + self.progressBar.setObjectName(u'progressBar') + self.progressLayout.addWidget(self.progressBar) + self.addPage(self.progressPage) + + def exec_(self): + """ + Run the wizard. + """ + self.setDefaults() + return QtGui.QWizard.exec_(self) + + def reject(self): + """ + Stop the wizard on cancel button, close button or ESC key. + """ + log.debug(u'Wizard cancelled by user.') + if self.currentPage() == self.progressPage: + Receiver.send_message(u'openlp_stop_wizard') + self.done(QtGui.QDialog.Rejected) + + def onCurrentIdChanged(self, pageId): + """ + Perform necessary functions depending on which wizard page is active. + """ + if self.page(pageId) == self.progressPage: + self.preWizard() + self.performWizard() + self.postWizard() + + def incrementProgressBar(self, status_text, increment=1): + """ + Update the wizard progress page. + + ``status_text`` + Current status information to display. + + ``increment`` + The value to increment the progress bar by. + """ + log.debug(u'IncrementBar %s', status_text) + self.progressLabel.setText(status_text) + if increment > 0: + self.progressBar.setValue(self.progressBar.value() + increment) + Receiver.send_message(u'openlp_process_events') + + def preWizard(self): + """ + Prepare the UI for the import. + """ + self.finishButton.setVisible(False) + self.progressBar.setMinimum(0) + self.progressBar.setMaximum(1188) + self.progressBar.setValue(0) + + def postWizard(self): + """ + Clean up the UI after the import has finished. + """ + self.progressBar.setValue(self.progressBar.maximum()) + self.finishButton.setVisible(True) + self.cancelButton.setVisible(False) + Receiver.send_message(u'openlp_process_events') diff --git a/openlp/core/utils/__init__.py b/openlp/core/utils/__init__.py index 75f00f298..d8012f433 100644 --- a/openlp/core/utils/__init__.py +++ b/openlp/core/utils/__init__.py @@ -337,9 +337,28 @@ def file_is_unicode(filename): return None return ucsfile +def string_is_unicode(test_string): + """ + Makes sure a string is unicode. + + ``test_string`` + The string to confirm is unicode. + """ + return_string = u'' + if not test_string: + return return_string + if isinstance(test_string, unicode): + return_string = test_string + if not isinstance(test_string, unicode): + try: + return_string = unicode(test_string, u'utf-8') + except UnicodeError: + log.exception("Error encoding string to unicode") + return return_string + from languagemanager import LanguageManager from actions import ActionList __all__ = [u'AppLocation', u'check_latest_version', u'add_actions', u'get_filesystem_encoding', u'LanguageManager', u'ActionList', - u'get_web_page', u'file_is_unicode'] + u'get_web_page', u'file_is_unicode', u'string_is_unicode'] diff --git a/openlp/plugins/bibles/forms/bibleimportform.py b/openlp/plugins/bibles/forms/bibleimportform.py index 4590ea739..d79051126 100644 --- a/openlp/plugins/bibles/forms/bibleimportform.py +++ b/openlp/plugins/bibles/forms/bibleimportform.py @@ -23,7 +23,9 @@ # with this program; if not, write to the Free Software Foundation, Inc., 59 # # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### - +""" +The bible import functions for OpenLP +""" import csv import logging import os @@ -31,15 +33,18 @@ import os.path from PyQt4 import QtCore, QtGui -from bibleimportwizard import Ui_BibleImportWizard from openlp.core.lib import Receiver, SettingsManager, translate from openlp.core.lib.db import delete_database -from openlp.core.utils import AppLocation +from openlp.core.ui.wizard import OpenLPWizard +from openlp.core.utils import AppLocation, string_is_unicode from openlp.plugins.bibles.lib.manager import BibleFormat log = logging.getLogger(__name__) class WebDownload(object): + """ + Provides an enumeration for the web bible types available to OpenLP. + """ Unknown = -1 Crosswalk = 0 BibleGateway = 1 @@ -53,10 +58,13 @@ class WebDownload(object): @classmethod def get_name(cls, name): + """ + Get the web bible type name. + """ return cls.Names[name] -class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard): +class BibleImportForm(OpenLPWizard): """ This is the Bible Import Wizard, which allows easy importing of Bibles into OpenLP from other formats like OSIS, CSV and OpenSong. @@ -76,27 +84,42 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard): ``bibleplugin`` The Bible plugin. """ - QtGui.QWizard.__init__(self, parent) - self.setupUi(self) - self.registerFields() + self.manager = manager + self.web_bible_list = {} + OpenLPWizard.__init__(self, parent, bibleplugin, u'bibleImportWizard', + u':/wizards/wizard_importbible.bmp') + + def setupUi(self, image): + """ + Set up the UI for the bible wizard. + """ + OpenLPWizard.setupUi(self, image) + QtCore.QObject.connect(self.formatComboBox, + QtCore.SIGNAL(u'currentIndexChanged(int)'), self.selectStack, + QtCore.SLOT(u'setCurrentIndex(int)')) + + def customInit(self): + """ + Perform any custom initialisation for bible importing. + """ if BibleFormat.get_availability(BibleFormat.OpenLP1): self.openlp1DisabledLabel.hide() else: self.openlp1FileLabel.hide() self.openlp1FileEdit.hide() self.openlp1BrowseButton.hide() - self.finishButton = self.button(QtGui.QWizard.FinishButton) - self.cancelButton = self.button(QtGui.QWizard.CancelButton) - self.manager = manager - self.bibleplugin = bibleplugin self.manager.set_process_dialog(self) - self.web_bible_list = {} self.loadWebBibles() self.restart() self.selectStack.setCurrentIndex(0) + + def customSignals(self): + """ + Set up the signals used in the bible importer. + """ QtCore.QObject.connect(self.webSourceComboBox, QtCore.SIGNAL(u'currentIndexChanged(int)'), - self.onWebSourceComboBoxCurrentIndexChanged) + self.onWebSourceComboBoxIndexChanged) QtCore.QObject.connect(self.osisBrowseButton, QtCore.SIGNAL(u'clicked()'), self.onOsisBrowseButtonClicked) @@ -112,25 +135,329 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard): QtCore.QObject.connect(self.openlp1BrowseButton, QtCore.SIGNAL(u'clicked()'), self.onOpenlp1BrowseButtonClicked) - QtCore.QObject.connect(self, - QtCore.SIGNAL(u'currentIdChanged(int)'), - self.onCurrentIdChanged) - def exec_(self): + def addCustomPages(self): """ - Run the wizard. + Add the bible import specific wizard pages. """ - self.setDefaults() - return QtGui.QWizard.exec_(self) + # Select Page + self.selectPage = QtGui.QWizardPage() + self.selectPage.setObjectName(u'SelectPage') + self.selectPageLayout = QtGui.QVBoxLayout(self.selectPage) + self.selectPageLayout.setObjectName(u'SelectPageLayout') + self.formatLayout = QtGui.QFormLayout() + self.formatLayout.setObjectName(u'FormatLayout') + self.formatLabel = QtGui.QLabel(self.selectPage) + self.formatLabel.setObjectName(u'FormatLabel') + self.formatComboBox = QtGui.QComboBox(self.selectPage) + self.formatComboBox.addItems([u'', u'', u'', u'', u'']) + self.formatComboBox.setObjectName(u'FormatComboBox') + self.formatLayout.addRow(self.formatLabel, self.formatComboBox) + self.formatSpacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed, + QtGui.QSizePolicy.Minimum) + self.formatLayout.setItem(1, QtGui.QFormLayout.LabelRole, + self.formatSpacer) + self.selectPageLayout.addLayout(self.formatLayout) + self.selectStack = QtGui.QStackedLayout() + self.selectStack.setObjectName(u'SelectStack') + self.osisWidget = QtGui.QWidget(self.selectPage) + self.osisWidget.setObjectName(u'OsisWidget') + self.osisLayout = QtGui.QFormLayout(self.osisWidget) + self.osisLayout.setMargin(0) + self.osisLayout.setObjectName(u'OsisLayout') + self.osisFileLabel = QtGui.QLabel(self.osisWidget) + self.osisFileLabel.setObjectName(u'OsisFileLabel') + self.osisFileLayout = QtGui.QHBoxLayout() + self.osisFileLayout.setObjectName(u'OsisFileLayout') + self.osisFileEdit = QtGui.QLineEdit(self.osisWidget) + self.osisFileEdit.setObjectName(u'OsisFileEdit') + self.osisFileLayout.addWidget(self.osisFileEdit) + self.osisBrowseButton = QtGui.QToolButton(self.osisWidget) + self.osisBrowseButton.setIcon(self.openIcon) + self.osisBrowseButton.setObjectName(u'OsisBrowseButton') + self.osisFileLayout.addWidget(self.osisBrowseButton) + self.osisLayout.addRow(self.osisFileLabel, self.osisFileLayout) + self.osisSpacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed, + QtGui.QSizePolicy.Minimum) + self.osisLayout.setItem(1, QtGui.QFormLayout.LabelRole, self.osisSpacer) + self.selectStack.addWidget(self.osisWidget) + self.csvWidget = QtGui.QWidget(self.selectPage) + self.csvWidget.setObjectName(u'CsvWidget') + self.csvLayout = QtGui.QFormLayout(self.csvWidget) + self.csvLayout.setMargin(0) + self.csvLayout.setObjectName(u'CsvLayout') + self.csvBooksLabel = QtGui.QLabel(self.csvWidget) + self.csvBooksLabel.setObjectName(u'CsvBooksLabel') + self.csvBooksLayout = QtGui.QHBoxLayout() + self.csvBooksLayout.setObjectName(u'CsvBooksLayout') + self.csvBooksEdit = QtGui.QLineEdit(self.csvWidget) + self.csvBooksEdit.setObjectName(u'CsvBooksEdit') + self.csvBooksLayout.addWidget(self.csvBooksEdit) + self.csvBooksButton = QtGui.QToolButton(self.csvWidget) + self.csvBooksButton.setIcon(self.openIcon) + self.csvBooksButton.setObjectName(u'CsvBooksButton') + self.csvBooksLayout.addWidget(self.csvBooksButton) + self.csvLayout.addRow(self.csvBooksLabel, self.csvBooksLayout) + self.csvVersesLabel = QtGui.QLabel(self.csvWidget) + self.csvVersesLabel.setObjectName(u'CsvVersesLabel') + self.csvVersesLayout = QtGui.QHBoxLayout() + self.csvVersesLayout.setObjectName(u'CsvVersesLayout') + self.csvVersesEdit = QtGui.QLineEdit(self.csvWidget) + self.csvVersesEdit.setObjectName(u'CsvVersesEdit') + self.csvVersesLayout.addWidget(self.csvVersesEdit) + self.csvVersesButton = QtGui.QToolButton(self.csvWidget) + self.csvVersesButton.setIcon(self.openIcon) + self.csvVersesButton.setObjectName(u'CsvVersesButton') + self.csvVersesLayout.addWidget(self.csvVersesButton) + self.csvLayout.addRow(self.csvVersesLabel, self.csvVersesLayout) + self.csvSpacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed, + QtGui.QSizePolicy.Minimum) + self.csvLayout.setItem(2, QtGui.QFormLayout.LabelRole, self.csvSpacer) + self.selectStack.addWidget(self.csvWidget) + self.openSongWidget = QtGui.QWidget(self.selectPage) + self.openSongWidget.setObjectName(u'OpenSongWidget') + self.openSongLayout = QtGui.QFormLayout(self.openSongWidget) + self.openSongLayout.setMargin(0) + self.openSongLayout.setObjectName(u'OpenSongLayout') + self.openSongFileLabel = QtGui.QLabel(self.openSongWidget) + self.openSongFileLabel.setObjectName(u'OpenSongFileLabel') + self.openSongFileLayout = QtGui.QHBoxLayout() + self.openSongFileLayout.setObjectName(u'OpenSongFileLayout') + self.openSongFileEdit = QtGui.QLineEdit(self.openSongWidget) + self.openSongFileEdit.setObjectName(u'OpenSongFileEdit') + self.openSongFileLayout.addWidget(self.openSongFileEdit) + self.openSongBrowseButton = QtGui.QToolButton(self.openSongWidget) + self.openSongBrowseButton.setIcon(self.openIcon) + self.openSongBrowseButton.setObjectName(u'OpenSongBrowseButton') + self.openSongFileLayout.addWidget(self.openSongBrowseButton) + self.openSongLayout.addRow(self.openSongFileLabel, + self.openSongFileLayout) + self.openSongSpacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed, + QtGui.QSizePolicy.Minimum) + self.openSongLayout.setItem(1, QtGui.QFormLayout.LabelRole, + self.openSongSpacer) + self.selectStack.addWidget(self.openSongWidget) + self.webTabWidget = QtGui.QTabWidget(self.selectPage) + self.webTabWidget.setObjectName(u'WebTabWidget') + self.webBibleTab = QtGui.QWidget() + self.webBibleTab.setObjectName(u'WebBibleTab') + self.webBibleLayout = QtGui.QFormLayout(self.webBibleTab) + self.webBibleLayout.setObjectName(u'WebBibleLayout') + self.webSourceLabel = QtGui.QLabel(self.webBibleTab) + self.webSourceLabel.setObjectName(u'WebSourceLabel') + self.webBibleLayout.setWidget(0, QtGui.QFormLayout.LabelRole, + self.webSourceLabel) + self.webSourceComboBox = QtGui.QComboBox(self.webBibleTab) + self.webSourceComboBox.setObjectName(u'WebSourceComboBox') + self.webSourceComboBox.addItems([u'', u'', u'']) + self.webBibleLayout.setWidget(0, QtGui.QFormLayout.FieldRole, + self.webSourceComboBox) + self.webTranslationLabel = QtGui.QLabel(self.webBibleTab) + self.webTranslationLabel.setObjectName(u'webTranslationLabel') + self.webBibleLayout.setWidget(1, QtGui.QFormLayout.LabelRole, + self.webTranslationLabel) + self.webTranslationComboBox = QtGui.QComboBox(self.webBibleTab) + self.webTranslationComboBox.setSizeAdjustPolicy( + QtGui.QComboBox.AdjustToContents) + self.webTranslationComboBox.setObjectName(u'WebTranslationComboBox') + self.webBibleLayout.setWidget(1, QtGui.QFormLayout.FieldRole, + self.webTranslationComboBox) + self.webTabWidget.addTab(self.webBibleTab, u'') + self.webProxyTab = QtGui.QWidget() + self.webProxyTab.setObjectName(u'WebProxyTab') + self.webProxyLayout = QtGui.QFormLayout(self.webProxyTab) + self.webProxyLayout.setObjectName(u'WebProxyLayout') + self.webServerLabel = QtGui.QLabel(self.webProxyTab) + self.webServerLabel.setObjectName(u'WebServerLabel') + self.webProxyLayout.setWidget(0, QtGui.QFormLayout.LabelRole, + self.webServerLabel) + self.webServerEdit = QtGui.QLineEdit(self.webProxyTab) + self.webServerEdit.setObjectName(u'WebServerEdit') + self.webProxyLayout.setWidget(0, QtGui.QFormLayout.FieldRole, + self.webServerEdit) + self.webUserLabel = QtGui.QLabel(self.webProxyTab) + self.webUserLabel.setObjectName(u'WebUserLabel') + self.webProxyLayout.setWidget(1, QtGui.QFormLayout.LabelRole, + self.webUserLabel) + self.webUserEdit = QtGui.QLineEdit(self.webProxyTab) + self.webUserEdit.setObjectName(u'WebUserEdit') + self.webProxyLayout.setWidget(1, QtGui.QFormLayout.FieldRole, + self.webUserEdit) + self.webPasswordLabel = QtGui.QLabel(self.webProxyTab) + self.webPasswordLabel.setObjectName(u'WebPasswordLabel') + self.webProxyLayout.setWidget(2, QtGui.QFormLayout.LabelRole, + self.webPasswordLabel) + self.webPasswordEdit = QtGui.QLineEdit(self.webProxyTab) + self.webPasswordEdit.setObjectName(u'WebPasswordEdit') + self.webProxyLayout.setWidget(2, QtGui.QFormLayout.FieldRole, + self.webPasswordEdit) + self.webTabWidget.addTab(self.webProxyTab, u'') + self.selectStack.addWidget(self.webTabWidget) + self.openlp1Widget = QtGui.QWidget(self.selectPage) + self.openlp1Widget.setObjectName(u'Openlp1Widget') + self.openlp1Layout = QtGui.QFormLayout(self.openlp1Widget) + self.openlp1Layout.setMargin(0) + self.openlp1Layout.setObjectName(u'Openlp1Layout') + self.openlp1FileLabel = QtGui.QLabel(self.openlp1Widget) + self.openlp1FileLabel.setObjectName(u'Openlp1FileLabel') + self.openlp1FileLayout = QtGui.QHBoxLayout() + self.openlp1FileLayout.setObjectName(u'Openlp1FileLayout') + self.openlp1FileEdit = QtGui.QLineEdit(self.openlp1Widget) + self.openlp1FileEdit.setObjectName(u'Openlp1FileEdit') + self.openlp1FileLayout.addWidget(self.openlp1FileEdit) + self.openlp1BrowseButton = QtGui.QToolButton(self.openlp1Widget) + self.openlp1BrowseButton.setIcon(self.openIcon) + self.openlp1BrowseButton.setObjectName(u'Openlp1BrowseButton') + self.openlp1FileLayout.addWidget(self.openlp1BrowseButton) + self.openlp1Layout.addRow(self.openlp1FileLabel, self.openlp1FileLayout) + self.openlp1DisabledLabel = QtGui.QLabel(self.openlp1Widget) + self.openlp1DisabledLabel.setWordWrap(True) + self.openlp1DisabledLabel.setObjectName(u'Openlp1DisabledLabel') + self.openlp1Layout.addRow(self.openlp1DisabledLabel) + self.openlp1Spacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed, + QtGui.QSizePolicy.Minimum) + self.openlp1Layout.setItem(1, QtGui.QFormLayout.LabelRole, + self.openlp1Spacer) + self.selectStack.addWidget(self.openlp1Widget) + self.selectPageLayout.addLayout(self.selectStack) + self.addPage(self.selectPage) + # License Page + self.licenseDetailsPage = QtGui.QWizardPage() + self.licenseDetailsPage.setObjectName(u'LicenseDetailsPage') + self.licenseDetailsLayout = QtGui.QFormLayout(self.licenseDetailsPage) + self.licenseDetailsLayout.setObjectName(u'LicenseDetailsLayout') + self.versionNameLabel = QtGui.QLabel(self.licenseDetailsPage) + self.versionNameLabel.setObjectName(u'VersionNameLabel') + self.licenseDetailsLayout.setWidget(0, QtGui.QFormLayout.LabelRole, + self.versionNameLabel) + self.versionNameEdit = QtGui.QLineEdit(self.licenseDetailsPage) + self.versionNameEdit.setObjectName(u'VersionNameEdit') + self.licenseDetailsLayout.setWidget(0, QtGui.QFormLayout.FieldRole, + self.versionNameEdit) + self.copyrightLabel = QtGui.QLabel(self.licenseDetailsPage) + self.copyrightLabel.setObjectName(u'CopyrightLabel') + self.licenseDetailsLayout.setWidget(1, QtGui.QFormLayout.LabelRole, + self.copyrightLabel) + self.copyrightEdit = QtGui.QLineEdit(self.licenseDetailsPage) + self.copyrightEdit.setObjectName(u'CopyrightEdit') + self.licenseDetailsLayout.setWidget(1, QtGui.QFormLayout.FieldRole, + self.copyrightEdit) + self.permissionsLabel = QtGui.QLabel(self.licenseDetailsPage) + self.permissionsLabel.setObjectName(u'PermissionsLabel') + self.licenseDetailsLayout.setWidget(2, QtGui.QFormLayout.LabelRole, + self.permissionsLabel) + self.permissionsEdit = QtGui.QLineEdit(self.licenseDetailsPage) + self.permissionsEdit.setObjectName(u'PermissionsEdit') + self.licenseDetailsLayout.setWidget(2, QtGui.QFormLayout.FieldRole, + self.permissionsEdit) + self.addPage(self.licenseDetailsPage) - def reject(self): + def retranslateUi(self): """ - Stop the import on cancel button, close button or ESC key. + Allow for localisation of the bible import wizard. """ - log.debug(u'Import canceled by user.') - if self.currentPage() == self.importPage: - Receiver.send_message(u'bibles_stop_import') - self.done(QtGui.QDialog.Rejected) + self.setWindowTitle( + translate('BiblesPlugin.ImportWizardForm', 'Bible Import Wizard')) + self.titleLabel.setText( + u'%s' % \ + translate('BiblesPlugin.ImportWizardForm', + 'Welcome to the Bible Import Wizard')) + self.informationLabel.setText( + translate('BiblesPlugin.ImportWizardForm', + 'This wizard will help you to import Bibles from a ' + 'variety of formats. Click the next button below to start the ' + 'process by selecting a format to import from.')) + self.selectPage.setTitle(translate('BiblesPlugin.ImportWizardForm', + 'Select Import Source')) + self.selectPage.setSubTitle( + translate('BiblesPlugin.ImportWizardForm', + 'Select the import format, and where to import from.')) + self.formatLabel.setText( + translate('BiblesPlugin.ImportWizardForm', 'Format:')) + self.formatComboBox.setItemText(0, + translate('BiblesPlugin.ImportWizardForm', 'OSIS')) + self.formatComboBox.setItemText(1, + translate('BiblesPlugin.ImportWizardForm', 'CSV')) + self.formatComboBox.setItemText(2, + translate('BiblesPlugin.ImportWizardForm', 'OpenSong')) + self.formatComboBox.setItemText(3, + translate('BiblesPlugin.ImportWizardForm', 'Web Download')) + self.formatComboBox.setItemText(4, + translate('BiblesPlugin.ImportWizardForm', 'openlp.org 1.x')) + self.openlp1FileLabel.setText( + translate('BiblesPlugin.ImportWizardForm', 'File location:')) + self.osisFileLabel.setText( + translate('BiblesPlugin.ImportWizardForm', 'File location:')) + self.csvBooksLabel.setText( + translate('BiblesPlugin.ImportWizardForm', 'Books location:')) + self.csvVersesLabel.setText( + translate('BiblesPlugin.ImportWizardForm', 'Verse location:')) + self.openSongFileLabel.setText( + translate('BiblesPlugin.ImportWizardForm', 'Bible filename:')) + self.webSourceLabel.setText( + translate('BiblesPlugin.ImportWizardForm', 'Location:')) + self.webSourceComboBox.setItemText(0, + translate('BiblesPlugin.ImportWizardForm', 'Crosswalk')) + self.webSourceComboBox.setItemText(1, + translate('BiblesPlugin.ImportWizardForm', 'BibleGateway')) + self.webSourceComboBox.setItemText(2, + translate('BiblesPlugin.ImportWizardForm', 'Bibleserver')) + self.webTranslationLabel.setText( + translate('BiblesPlugin.ImportWizardForm', 'Bible:')) + self.webTabWidget.setTabText( + self.webTabWidget.indexOf(self.webBibleTab), + translate('BiblesPlugin.ImportWizardForm', 'Download Options')) + self.webServerLabel.setText( + translate('BiblesPlugin.ImportWizardForm', 'Server:')) + self.webUserLabel.setText( + translate('BiblesPlugin.ImportWizardForm', 'Username:')) + self.webPasswordLabel.setText( + translate('BiblesPlugin.ImportWizardForm', 'Password:')) + self.webTabWidget.setTabText( + self.webTabWidget.indexOf(self.webProxyTab), + translate('BiblesPlugin.ImportWizardForm', + 'Proxy Server (Optional)')) + self.licenseDetailsPage.setTitle( + translate('BiblesPlugin.ImportWizardForm', 'License Details')) + self.licenseDetailsPage.setSubTitle( + translate('BiblesPlugin.ImportWizardForm', + 'Set up the Bible\'s license details.')) + self.versionNameLabel.setText( + translate('BiblesPlugin.ImportWizardForm', 'Version name:')) + self.copyrightLabel.setText( + translate('BiblesPlugin.ImportWizardForm', 'Copyright:')) + self.permissionsLabel.setText( + translate('BiblesPlugin.ImportWizardForm', 'Permissions:')) + self.progressPage.setTitle( + translate('BiblesPlugin.ImportWizardForm', 'Importing')) + self.progressPage.setSubTitle( + translate('BiblesPlugin.ImportWizardForm', + 'Please wait while your Bible is imported.')) + self.progressLabel.setText( + translate('BiblesPlugin.ImportWizardForm', 'Ready.')) + self.progressBar.setFormat(u'%p%') + self.openlp1DisabledLabel.setText( + translate('BiblesPlugin.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.')) + # Align all QFormLayouts towards each other. + labelWidth = max(self.formatLabel.minimumSizeHint().width(), + self.osisFileLabel.minimumSizeHint().width(), + self.csvBooksLabel.minimumSizeHint().width(), + self.csvVersesLabel.minimumSizeHint().width(), + self.openSongFileLabel.minimumSizeHint().width(), + self.openlp1FileLabel.minimumSizeHint().width()) + self.formatSpacer.changeSize(labelWidth, 0, + QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) + self.osisSpacer.changeSize(labelWidth, 0, + QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) + self.csvSpacer.changeSize(labelWidth, 0, + QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) + self.openSongSpacer.changeSize(labelWidth, 0, + QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) + self.openlp1Spacer.changeSize(labelWidth, 0, + QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) def validateCurrentPage(self): """ @@ -220,10 +547,10 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard): self.versionNameEdit.setFocus() return False return True - if self.currentPage() == self.importPage: + if self.currentPage() == self.progressPage: return True - def onWebSourceComboBoxCurrentIndexChanged(self, index): + def onWebSourceComboBoxIndexChanged(self, index): """ Setup the list of Bibles when you select a different source on the web download page. @@ -279,13 +606,10 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard): u'%s (*.bible)' % translate('BiblesPlugin.ImportWizardForm', 'openlp.org 1.x bible')) - def onCurrentIdChanged(self, pageId): - if self.page(pageId) == self.importPage: - self.preImport() - self.performImport() - self.postImport() - def registerFields(self): + """ + Register the bible import wizard fields. + """ self.selectPage.registerField(u'source_format', self.formatComboBox) self.selectPage.registerField(u'osis_location', self.osisFileEdit) self.selectPage.registerField(u'csv_booksfile', self.csvBooksEdit) @@ -306,8 +630,11 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard): u'license_permissions', self.permissionsEdit) def setDefaults(self): + """ + Set default values for the wizard pages. + """ settings = QtCore.QSettings() - settings.beginGroup(self.bibleplugin.settingsSection) + settings.beginGroup(self.plugin.settingsSection) self.restart() self.finishButton.setVisible(False) self.cancelButton.setVisible(True) @@ -332,72 +659,50 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard): QtCore.QVariant(self.copyrightEdit.text())) self.setField(u'license_permissions', QtCore.QVariant(self.permissionsEdit.text())) - self.onWebSourceComboBoxCurrentIndexChanged(WebDownload.Crosswalk) + self.onWebSourceComboBoxIndexChanged(WebDownload.Crosswalk) settings.endGroup() def loadWebBibles(self): """ - Load the list of Crosswalk and BibleGateway bibles. + Load the lists of Crosswalk, BibleGateway and Bibleserver bibles. """ + filepath = AppLocation.get_directory(AppLocation.PluginsDir) + filepath = os.path.join(filepath, u'bibles', u'resources') # Load Crosswalk Bibles. - filepath = AppLocation.get_directory(AppLocation.PluginsDir) - filepath = os.path.join(filepath, u'bibles', u'resources') - books_file = None - try: - self.web_bible_list[WebDownload.Crosswalk] = {} - books_file = open( - os.path.join(filepath, u'crosswalkbooks.csv'), 'rb') - dialect = csv.Sniffer().sniff(books_file.read(1024)) - books_file.seek(0) - books_reader = csv.reader(books_file, dialect) - for line in books_reader: - ver = unicode(line[0], u'utf-8') - name = unicode(line[1], u'utf-8') - self.web_bible_list[WebDownload.Crosswalk][ver] = name.strip() - except IOError: - log.exception(u'Crosswalk resources missing') - finally: - if books_file: - books_file.close() + self.loadBibleResourceFile( + os.path.join(filepath, u'crosswalkbooks.csv'), + WebDownload.Crosswalk) # Load BibleGateway Bibles. - books_file = None - try: - self.web_bible_list[WebDownload.BibleGateway] = {} - books_file = open(os.path.join(filepath, u'biblegateway.csv'), 'r') - dialect = csv.Sniffer().sniff(books_file.read(1024)) - books_file.seek(0) - books_reader = csv.reader(books_file, dialect) - for line in books_reader: - ver = line[0] - name = line[1] - if not isinstance(ver, unicode): - ver = unicode(ver, u'utf8') - if not isinstance(name, unicode): - name = unicode(name, u'utf8') - self.web_bible_list[WebDownload.BibleGateway][ver] = \ - name.strip() - except IOError: - log.exception(u'Biblegateway resources missing') - finally: - if books_file: - books_file.close() + self.loadBibleResourceFile(os.path.join(filepath, u'biblegateway.csv'), + WebDownload.BibleGateway) # Load and Bibleserver Bibles. - filepath = AppLocation.get_directory(AppLocation.PluginsDir) - filepath = os.path.join(filepath, u'bibles', u'resources') + self.loadBibleResourceFile(os.path.join(filepath, u'bibleserver.csv'), + WebDownload.Bibleserver) + + def loadBibleResourceFile(self, file_path_name, download_type): + """ + Loads a web bible resource file. + + ``file_path_name`` + The file to load including the file's path. + + ``download_type`` + The WebDownload type this file is for. + """ + self.web_bible_list[download_type] = {} books_file = None try: - self.web_bible_list[WebDownload.Bibleserver] = {} - books_file = open( - os.path.join(filepath, u'bibleserver.csv'), 'rb') + books_file = open(file_path_name, 'rb') dialect = csv.Sniffer().sniff(books_file.read(1024)) books_file.seek(0) books_reader = csv.reader(books_file, dialect) for line in books_reader: - ver = unicode(line[0], u'utf-8') - name = unicode(line[1], u'utf-8') - self.web_bible_list[WebDownload.Bibleserver][ver] = name.strip() - except IOError, UnicodeError: - log.exception(u'Bibleserver resources missing') + ver = string_is_unicode(line[0]) + name = string_is_unicode(line[1]) + self.web_bible_list[download_type][ver] = name.strip() + except IOError: + log.exception(u'%s resources missing' % + WebDownload.get_name(download_type)) finally: if books_file: books_file.close() @@ -413,8 +718,8 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard): A editbox (QLineEdit). ``filters`` - The file extension filters. It should contain the file description as - well as the file extension. For example:: + The file extension filters. It should contain the file description + as well as the file extension. For example:: u'openlp.org 1.x bible (*.bible)' """ @@ -424,37 +729,28 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard): 'All Files') filename = QtGui.QFileDialog.getOpenFileName(self, title, os.path.dirname(SettingsManager.get_last_dir( - self.bibleplugin.settingsSection, 1)), filters) + self.plugin.settingsSection, 1)), filters) if filename: editbox.setText(filename) SettingsManager.set_last_dir( - self.bibleplugin.settingsSection, filename, 1) + self.plugin.settingsSection, filename, 1) - def incrementProgressBar(self, status_text): - log.debug(u'IncrementBar %s', status_text) - self.importProgressLabel.setText(status_text) - self.importProgressBar.setValue(self.importProgressBar.value() + 1) - Receiver.send_message(u'openlp_process_events') - - def preImport(self): + def preWizard(self): """ Prepare the UI for the import. """ + OpenLPWizard.preWizard(self) bible_type = self.field(u'source_format').toInt()[0] - self.finishButton.setVisible(False) - self.importProgressBar.setMinimum(0) - self.importProgressBar.setMaximum(1188) - self.importProgressBar.setValue(0) if bible_type == BibleFormat.WebDownload: - self.importProgressLabel.setText(translate( + self.progressLabel.setText(translate( 'BiblesPlugin.ImportWizardForm', 'Starting Registering bible...')) else: - self.importProgressLabel.setText(translate( + self.progressLabel.setText(translate( 'BiblesPlugin.ImportWizardForm', 'Starting import...')) Receiver.send_message(u'openlp_process_events') - def performImport(self): + def performWizard(self): """ Perform the actual import. """ @@ -485,7 +781,7 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard): ) elif bible_type == BibleFormat.WebDownload: # Import a bible from the web. - self.importProgressBar.setMaximum(1) + self.progressBar.setMaximum(1) download_location = self.field(u'web_location').toInt()[0] bible_version = unicode(self.webTranslationComboBox.currentText()) if download_location == WebDownload.Crosswalk: @@ -518,20 +814,14 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard): license_copyright, license_permissions) self.manager.reload_bibles() if bible_type == BibleFormat.WebDownload: - self.importProgressLabel.setText( + self.progressLabel.setText( translate('BiblesPlugin.ImportWizardForm', 'Registered ' 'bible. Please note, that verses will be downloaded on\n' 'demand and thus an internet connection is required.')) else: - self.importProgressLabel.setText(translate( + self.progressLabel.setText(translate( 'BiblesPlugin.ImportWizardForm', 'Finished import.')) else: - self.importProgressLabel.setText(translate( + self.progressLabel.setText(translate( 'BiblesPlugin.ImportWizardForm', 'Your Bible import failed.')) - delete_database(self.bibleplugin.settingsSection, importer.file) - - def postImport(self): - self.importProgressBar.setValue(self.importProgressBar.maximum()) - self.finishButton.setVisible(True) - self.cancelButton.setVisible(False) - Receiver.send_message(u'openlp_process_events') + delete_database(self.plugin.settingsSection, importer.file) diff --git a/openlp/plugins/bibles/forms/bibleimportwizard.py b/openlp/plugins/bibles/forms/bibleimportwizard.py deleted file mode 100644 index c6a6775a5..000000000 --- a/openlp/plugins/bibles/forms/bibleimportwizard.py +++ /dev/null @@ -1,391 +0,0 @@ -# -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 - -############################################################################### -# OpenLP - Open Source Lyrics Projection # -# --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 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_BibleImportWizard(object): - def setupUi(self, bibleImportWizard): - bibleImportWizard.setObjectName(u'bibleImportWizard') - bibleImportWizard.setModal(True) - bibleImportWizard.setWizardStyle(QtGui.QWizard.ModernStyle) - bibleImportWizard.setOptions( - QtGui.QWizard.IndependentPages | - QtGui.QWizard.NoBackButtonOnStartPage | - QtGui.QWizard.NoBackButtonOnLastPage) - # Welcome Page - self.welcomePage = QtGui.QWizardPage() - self.welcomePage.setPixmap(QtGui.QWizard.WatermarkPixmap, - QtGui.QPixmap(u':/wizards/wizard_importbible.bmp')) - self.welcomePage.setObjectName(u'WelcomePage') - self.welcomeLayout = QtGui.QVBoxLayout(self.welcomePage) - self.welcomeLayout.setObjectName(u'WelcomeLayout') - self.titleLabel = QtGui.QLabel(self.welcomePage) - self.titleLabel.setObjectName(u'TitleLabel') - self.welcomeLayout.addWidget(self.titleLabel) - self.welcomeLayout.addSpacing(40) - self.informationLabel = QtGui.QLabel(self.welcomePage) - self.informationLabel.setWordWrap(True) - self.informationLabel.setObjectName(u'InformationLabel') - self.welcomeLayout.addWidget(self.informationLabel) - self.welcomeLayout.addStretch() - bibleImportWizard.addPage(self.welcomePage) - # Select Page - self.selectPage = QtGui.QWizardPage() - self.selectPage.setObjectName(u'SelectPage') - self.selectPageLayout = QtGui.QVBoxLayout(self.selectPage) - self.selectPageLayout.setObjectName(u'SelectPageLayout') - self.formatLayout = QtGui.QFormLayout() - self.formatLayout.setObjectName(u'FormatLayout') - self.formatLabel = QtGui.QLabel(self.selectPage) - self.formatLabel.setObjectName(u'FormatLabel') - self.formatComboBox = QtGui.QComboBox(self.selectPage) - self.formatComboBox.addItems([u'', u'', u'', u'', u'']) - self.formatComboBox.setObjectName(u'FormatComboBox') - self.formatLayout.addRow(self.formatLabel, self.formatComboBox) - self.formatSpacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed, - QtGui.QSizePolicy.Minimum) - self.formatLayout.setItem(1, QtGui.QFormLayout.LabelRole, - self.formatSpacer) - self.selectPageLayout.addLayout(self.formatLayout) - self.selectStack = QtGui.QStackedLayout() - self.selectStack.setObjectName(u'SelectStack') - self.osisWidget = QtGui.QWidget(self.selectPage) - self.osisWidget.setObjectName(u'OsisWidget') - self.osisLayout = QtGui.QFormLayout(self.osisWidget) - self.osisLayout.setMargin(0) - self.osisLayout.setObjectName(u'OsisLayout') - self.osisFileLabel = QtGui.QLabel(self.osisWidget) - self.osisFileLabel.setObjectName(u'OsisFileLabel') - self.osisFileLayout = QtGui.QHBoxLayout() - self.osisFileLayout.setObjectName(u'OsisFileLayout') - self.osisFileEdit = QtGui.QLineEdit(self.osisWidget) - self.osisFileEdit.setObjectName(u'OsisFileEdit') - self.osisFileLayout.addWidget(self.osisFileEdit) - self.osisBrowseButton = QtGui.QToolButton(self.osisWidget) - self.osisBrowseButton.setIcon(build_icon(u':/general/general_open.png')) - self.osisBrowseButton.setObjectName(u'OsisBrowseButton') - self.osisFileLayout.addWidget(self.osisBrowseButton) - self.osisLayout.addRow(self.osisFileLabel, self.osisFileLayout) - self.osisSpacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed, - QtGui.QSizePolicy.Minimum) - self.osisLayout.setItem(1, QtGui.QFormLayout.LabelRole, self.osisSpacer) - self.selectStack.addWidget(self.osisWidget) - self.csvWidget = QtGui.QWidget(self.selectPage) - self.csvWidget.setObjectName(u'CsvWidget') - self.csvLayout = QtGui.QFormLayout(self.csvWidget) - self.csvLayout.setMargin(0) - self.csvLayout.setObjectName(u'CsvLayout') - self.csvBooksLabel = QtGui.QLabel(self.csvWidget) - self.csvBooksLabel.setObjectName(u'CsvBooksLabel') - self.csvBooksLayout = QtGui.QHBoxLayout() - self.csvBooksLayout.setObjectName(u'CsvBooksLayout') - self.csvBooksEdit = QtGui.QLineEdit(self.csvWidget) - self.csvBooksEdit.setObjectName(u'CsvBooksEdit') - self.csvBooksLayout.addWidget(self.csvBooksEdit) - self.csvBooksButton = QtGui.QToolButton(self.csvWidget) - self.csvBooksButton.setIcon(build_icon(u':/general/general_open.png')) - self.csvBooksButton.setObjectName(u'CsvBooksButton') - self.csvBooksLayout.addWidget(self.csvBooksButton) - self.csvLayout.addRow(self.csvBooksLabel, self.csvBooksLayout) - self.csvVersesLabel = QtGui.QLabel(self.csvWidget) - self.csvVersesLabel.setObjectName(u'CsvVersesLabel') - self.csvVersesLayout = QtGui.QHBoxLayout() - self.csvVersesLayout.setObjectName(u'CsvVersesLayout') - self.csvVersesEdit = QtGui.QLineEdit(self.csvWidget) - self.csvVersesEdit.setObjectName(u'CsvVersesEdit') - self.csvVersesLayout.addWidget(self.csvVersesEdit) - self.csvVersesButton = QtGui.QToolButton(self.csvWidget) - self.csvVersesButton.setIcon(build_icon(u':/general/general_open.png')) - self.csvVersesButton.setObjectName(u'CsvVersesButton') - self.csvVersesLayout.addWidget(self.csvVersesButton) - self.csvLayout.addRow(self.csvVersesLabel, self.csvVersesLayout) - self.csvSpacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed, - QtGui.QSizePolicy.Minimum) - self.csvLayout.setItem(2, QtGui.QFormLayout.LabelRole, self.csvSpacer) - self.selectStack.addWidget(self.csvWidget) - self.openSongWidget = QtGui.QWidget(self.selectPage) - self.openSongWidget.setObjectName(u'OpenSongWidget') - self.openSongLayout = QtGui.QFormLayout(self.openSongWidget) - self.openSongLayout.setMargin(0) - self.openSongLayout.setObjectName(u'OpenSongLayout') - self.openSongFileLabel = QtGui.QLabel(self.openSongWidget) - self.openSongFileLabel.setObjectName(u'OpenSongFileLabel') - self.openSongFileLayout = QtGui.QHBoxLayout() - self.openSongFileLayout.setObjectName(u'OpenSongFileLayout') - self.openSongFileEdit = QtGui.QLineEdit(self.openSongWidget) - self.openSongFileEdit.setObjectName(u'OpenSongFileEdit') - self.openSongFileLayout.addWidget(self.openSongFileEdit) - self.openSongBrowseButton = QtGui.QToolButton(self.openSongWidget) - self.openSongBrowseButton.setIcon( - build_icon(u':/general/general_open.png')) - self.openSongBrowseButton.setObjectName(u'OpenSongBrowseButton') - self.openSongFileLayout.addWidget(self.openSongBrowseButton) - self.openSongLayout.addRow(self.openSongFileLabel, - self.openSongFileLayout) - self.openSongSpacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed, - QtGui.QSizePolicy.Minimum) - self.openSongLayout.setItem(1, QtGui.QFormLayout.LabelRole, - self.openSongSpacer) - self.selectStack.addWidget(self.openSongWidget) - self.webTabWidget = QtGui.QTabWidget(self.selectPage) - self.webTabWidget.setObjectName(u'WebTabWidget') - self.webBibleTab = QtGui.QWidget() - self.webBibleTab.setObjectName(u'WebBibleTab') - self.webBibleLayout = QtGui.QFormLayout(self.webBibleTab) - self.webBibleLayout.setObjectName(u'WebBibleLayout') - self.webSourceLabel = QtGui.QLabel(self.webBibleTab) - self.webSourceLabel.setObjectName(u'WebSourceLabel') - self.webBibleLayout.setWidget(0, QtGui.QFormLayout.LabelRole, - self.webSourceLabel) - self.webSourceComboBox = QtGui.QComboBox(self.webBibleTab) - self.webSourceComboBox.setObjectName(u'WebSourceComboBox') - self.webSourceComboBox.addItems([u'', u'', u'']) - self.webBibleLayout.setWidget(0, QtGui.QFormLayout.FieldRole, - self.webSourceComboBox) - self.webTranslationLabel = QtGui.QLabel(self.webBibleTab) - self.webTranslationLabel.setObjectName(u'webTranslationLabel') - self.webBibleLayout.setWidget(1, QtGui.QFormLayout.LabelRole, - self.webTranslationLabel) - self.webTranslationComboBox = QtGui.QComboBox(self.webBibleTab) - self.webTranslationComboBox.setSizeAdjustPolicy( - QtGui.QComboBox.AdjustToContents) - self.webTranslationComboBox.setObjectName(u'WebTranslationComboBox') - self.webBibleLayout.setWidget(1, QtGui.QFormLayout.FieldRole, - self.webTranslationComboBox) - self.webTabWidget.addTab(self.webBibleTab, u'') - self.webProxyTab = QtGui.QWidget() - self.webProxyTab.setObjectName(u'WebProxyTab') - self.webProxyLayout = QtGui.QFormLayout(self.webProxyTab) - self.webProxyLayout.setObjectName(u'WebProxyLayout') - self.webServerLabel = QtGui.QLabel(self.webProxyTab) - self.webServerLabel.setObjectName(u'WebServerLabel') - self.webProxyLayout.setWidget(0, QtGui.QFormLayout.LabelRole, - self.webServerLabel) - self.webServerEdit = QtGui.QLineEdit(self.webProxyTab) - self.webServerEdit.setObjectName(u'WebServerEdit') - self.webProxyLayout.setWidget(0, QtGui.QFormLayout.FieldRole, - self.webServerEdit) - self.webUserLabel = QtGui.QLabel(self.webProxyTab) - self.webUserLabel.setObjectName(u'WebUserLabel') - self.webProxyLayout.setWidget(1, QtGui.QFormLayout.LabelRole, - self.webUserLabel) - self.webUserEdit = QtGui.QLineEdit(self.webProxyTab) - self.webUserEdit.setObjectName(u'WebUserEdit') - self.webProxyLayout.setWidget(1, QtGui.QFormLayout.FieldRole, - self.webUserEdit) - self.webPasswordLabel = QtGui.QLabel(self.webProxyTab) - self.webPasswordLabel.setObjectName(u'WebPasswordLabel') - self.webProxyLayout.setWidget(2, QtGui.QFormLayout.LabelRole, - self.webPasswordLabel) - self.webPasswordEdit = QtGui.QLineEdit(self.webProxyTab) - self.webPasswordEdit.setObjectName(u'WebPasswordEdit') - self.webProxyLayout.setWidget(2, QtGui.QFormLayout.FieldRole, - self.webPasswordEdit) - self.webTabWidget.addTab(self.webProxyTab, u'') - self.selectStack.addWidget(self.webTabWidget) - self.openlp1Widget = QtGui.QWidget(self.selectPage) - self.openlp1Widget.setObjectName(u'Openlp1Widget') - self.openlp1Layout = QtGui.QFormLayout(self.openlp1Widget) - self.openlp1Layout.setMargin(0) - self.openlp1Layout.setObjectName(u'Openlp1Layout') - self.openlp1FileLabel = QtGui.QLabel(self.openlp1Widget) - self.openlp1FileLabel.setObjectName(u'Openlp1FileLabel') - self.openlp1FileLayout = QtGui.QHBoxLayout() - self.openlp1FileLayout.setObjectName(u'Openlp1FileLayout') - self.openlp1FileEdit = QtGui.QLineEdit(self.openlp1Widget) - self.openlp1FileEdit.setObjectName(u'Openlp1FileEdit') - self.openlp1FileLayout.addWidget(self.openlp1FileEdit) - self.openlp1BrowseButton = QtGui.QToolButton(self.openlp1Widget) - self.openlp1BrowseButton.setIcon( - build_icon(u':/general/general_open.png')) - self.openlp1BrowseButton.setObjectName(u'Openlp1BrowseButton') - self.openlp1FileLayout.addWidget(self.openlp1BrowseButton) - self.openlp1Layout.addRow(self.openlp1FileLabel, self.openlp1FileLayout) - self.openlp1DisabledLabel = QtGui.QLabel(self.openlp1Widget) - self.openlp1DisabledLabel.setWordWrap(True) - self.openlp1DisabledLabel.setObjectName(u'Openlp1DisabledLabel') - self.openlp1Layout.addRow(self.openlp1DisabledLabel) - self.openlp1Spacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed, - QtGui.QSizePolicy.Minimum) - self.openlp1Layout.setItem(1, QtGui.QFormLayout.LabelRole, - self.openlp1Spacer) - self.selectStack.addWidget(self.openlp1Widget) - self.selectPageLayout.addLayout(self.selectStack) - bibleImportWizard.addPage(self.selectPage) - # License Page - self.licenseDetailsPage = QtGui.QWizardPage() - self.licenseDetailsPage.setObjectName(u'LicenseDetailsPage') - self.licenseDetailsLayout = QtGui.QFormLayout(self.licenseDetailsPage) - self.licenseDetailsLayout.setObjectName(u'LicenseDetailsLayout') - self.versionNameLabel = QtGui.QLabel(self.licenseDetailsPage) - self.versionNameLabel.setObjectName(u'VersionNameLabel') - self.licenseDetailsLayout.setWidget(0, QtGui.QFormLayout.LabelRole, - self.versionNameLabel) - self.versionNameEdit = QtGui.QLineEdit(self.licenseDetailsPage) - self.versionNameEdit.setObjectName(u'VersionNameEdit') - self.licenseDetailsLayout.setWidget(0, QtGui.QFormLayout.FieldRole, - self.versionNameEdit) - self.copyrightLabel = QtGui.QLabel(self.licenseDetailsPage) - self.copyrightLabel.setObjectName(u'CopyrightLabel') - self.licenseDetailsLayout.setWidget(1, QtGui.QFormLayout.LabelRole, - self.copyrightLabel) - self.copyrightEdit = QtGui.QLineEdit(self.licenseDetailsPage) - self.copyrightEdit.setObjectName(u'CopyrightEdit') - self.licenseDetailsLayout.setWidget(1, QtGui.QFormLayout.FieldRole, - self.copyrightEdit) - self.permissionsLabel = QtGui.QLabel(self.licenseDetailsPage) - self.permissionsLabel.setObjectName(u'PermissionsLabel') - self.licenseDetailsLayout.setWidget(2, QtGui.QFormLayout.LabelRole, - self.permissionsLabel) - self.permissionsEdit = QtGui.QLineEdit(self.licenseDetailsPage) - self.permissionsEdit.setObjectName(u'PermissionsEdit') - self.licenseDetailsLayout.setWidget(2, QtGui.QFormLayout.FieldRole, - self.permissionsEdit) - bibleImportWizard.addPage(self.licenseDetailsPage) - # Progress Page - self.importPage = QtGui.QWizardPage() - self.importPage.setObjectName(u'ImportPage') - self.importLayout = QtGui.QVBoxLayout(self.importPage) - self.importLayout.setMargin(48) - 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.setObjectName(u'ImportProgressBar') - self.importLayout.addWidget(self.importProgressBar) - bibleImportWizard.addPage(self.importPage) - self.retranslateUi(bibleImportWizard) - QtCore.QMetaObject.connectSlotsByName(bibleImportWizard) - QtCore.QObject.connect(self.formatComboBox, - QtCore.SIGNAL(u'currentIndexChanged(int)'), self.selectStack, - QtCore.SLOT(u'setCurrentIndex(int)')) - - def retranslateUi(self, bibleImportWizard): - bibleImportWizard.setWindowTitle( - translate('BiblesPlugin.ImportWizardForm', 'Bible Import Wizard')) - self.titleLabel.setText( - u'%s' % \ - translate('BiblesPlugin.ImportWizardForm', - 'Welcome to the Bible Import Wizard')) - self.informationLabel.setText( - translate('BiblesPlugin.ImportWizardForm', - 'This wizard will help you to import Bibles from a ' - 'variety of formats. Click the next button below to start the ' - 'process by selecting a format to import from.')) - self.selectPage.setTitle(translate('BiblesPlugin.ImportWizardForm', - 'Select Import Source')) - self.selectPage.setSubTitle( - translate('BiblesPlugin.ImportWizardForm', - 'Select the import format, and where to import from.')) - self.formatLabel.setText( - translate('BiblesPlugin.ImportWizardForm', 'Format:')) - self.formatComboBox.setItemText(0, - translate('BiblesPlugin.ImportWizardForm', 'OSIS')) - self.formatComboBox.setItemText(1, - translate('BiblesPlugin.ImportWizardForm', 'CSV')) - self.formatComboBox.setItemText(2, - translate('BiblesPlugin.ImportWizardForm', 'OpenSong')) - self.formatComboBox.setItemText(3, - translate('BiblesPlugin.ImportWizardForm', 'Web Download')) - self.formatComboBox.setItemText(4, - translate('BiblesPlugin.ImportWizardForm', 'openlp.org 1.x')) - self.openlp1FileLabel.setText( - translate('BiblesPlugin.ImportWizardForm', 'File location:')) - self.osisFileLabel.setText( - translate('BiblesPlugin.ImportWizardForm', 'File location:')) - self.csvBooksLabel.setText( - translate('BiblesPlugin.ImportWizardForm', 'Books location:')) - self.csvVersesLabel.setText( - translate('BiblesPlugin.ImportWizardForm', 'Verse location:')) - self.openSongFileLabel.setText( - translate('BiblesPlugin.ImportWizardForm', 'Bible filename:')) - self.webSourceLabel.setText( - translate('BiblesPlugin.ImportWizardForm', 'Location:')) - self.webSourceComboBox.setItemText(0, - translate('BiblesPlugin.ImportWizardForm', 'Crosswalk')) - self.webSourceComboBox.setItemText(1, - translate('BiblesPlugin.ImportWizardForm', 'BibleGateway')) - self.webSourceComboBox.setItemText(2, - translate('BiblesPlugin.ImportWizardForm', 'Bibleserver')) - self.webTranslationLabel.setText( - translate('BiblesPlugin.ImportWizardForm', 'Bible:')) - self.webTabWidget.setTabText( - self.webTabWidget.indexOf(self.webBibleTab), - translate('BiblesPlugin.ImportWizardForm', 'Download Options')) - self.webServerLabel.setText( - translate('BiblesPlugin.ImportWizardForm', 'Server:')) - self.webUserLabel.setText( - translate('BiblesPlugin.ImportWizardForm', 'Username:')) - self.webPasswordLabel.setText( - translate('BiblesPlugin.ImportWizardForm', 'Password:')) - self.webTabWidget.setTabText( - self.webTabWidget.indexOf(self.webProxyTab), - translate('BiblesPlugin.ImportWizardForm', - 'Proxy Server (Optional)')) - self.licenseDetailsPage.setTitle( - translate('BiblesPlugin.ImportWizardForm', 'License Details')) - self.licenseDetailsPage.setSubTitle( - translate('BiblesPlugin.ImportWizardForm', - 'Set up the Bible\'s license details.')) - self.versionNameLabel.setText( - translate('BiblesPlugin.ImportWizardForm', 'Version name:')) - self.copyrightLabel.setText( - translate('BiblesPlugin.ImportWizardForm', 'Copyright:')) - self.permissionsLabel.setText( - translate('BiblesPlugin.ImportWizardForm', 'Permissions:')) - self.importPage.setTitle( - translate('BiblesPlugin.ImportWizardForm', 'Importing')) - self.importPage.setSubTitle( - translate('BiblesPlugin.ImportWizardForm', - 'Please wait while your Bible is imported.')) - self.importProgressLabel.setText( - translate('BiblesPlugin.ImportWizardForm', 'Ready.')) - self.importProgressBar.setFormat(u'%p%') - self.openlp1DisabledLabel.setText( - translate('BiblesPlugin.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.')) - # Align all QFormLayouts towards each other. - labelWidth = max(self.formatLabel.minimumSizeHint().width(), - self.osisFileLabel.minimumSizeHint().width(), - self.csvBooksLabel.minimumSizeHint().width(), - self.csvVersesLabel.minimumSizeHint().width(), - self.openSongFileLabel.minimumSizeHint().width(), - self.openlp1FileLabel.minimumSizeHint().width()) - self.formatSpacer.changeSize(labelWidth, 0, - QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) - self.osisSpacer.changeSize(labelWidth, 0, - QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) - self.csvSpacer.changeSize(labelWidth, 0, - QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) - self.openSongSpacer.changeSize(labelWidth, 0, - QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) - self.openlp1Spacer.changeSize(labelWidth, 0, - QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) diff --git a/openlp/plugins/bibles/lib/csvbible.py b/openlp/plugins/bibles/lib/csvbible.py index 2e9e9523b..8959167a6 100644 --- a/openlp/plugins/bibles/lib/csvbible.py +++ b/openlp/plugins/bibles/lib/csvbible.py @@ -31,7 +31,7 @@ import csv from PyQt4 import QtCore from openlp.core.lib import Receiver, translate -from db import BibleDB +from openlp.plugins.bibles.lib.db import BibleDB log = logging.getLogger(__name__) @@ -51,7 +51,7 @@ class CSVBible(BibleDB): self.booksfile = kwargs[u'booksfile'] self.versesfile = kwargs[u'versefile'] QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'bibles_stop_import'), self.stop_import) + QtCore.SIGNAL(u'openlp_stop_wizard'), self.stop_import) def do_import(self): success = True diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index f5468a63a..6f6b861e9 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -387,7 +387,7 @@ class HTTPBible(BibleDB): Run the import. This method overrides the parent class method. Returns ``True`` on success, ``False`` on failure. """ - self.wizard.importProgressBar.setMaximum(2) + self.wizard.progressBar.setMaximum(2) self.wizard.incrementProgressBar('Registering bible...') self.create_meta(u'download source', self.download_source) self.create_meta(u'download name', self.download_name) @@ -532,19 +532,25 @@ def get_soup_for_bible_ref(reference_url, header=None, cleaner=None): Receiver.send_message(u'openlp_process_events') return soup -def send_error_message(reason): - if reason == u'download': +def send_error_message(error_type): + """ + Send a standard error message informing the user of an issue. + + ``error_type`` + The type of error that occured for the issue. + """ + if error_type == u'download': Receiver.send_message(u'openlp_error_message', { u'title': translate('BiblePlugin.HTTPBible', 'Download Error'), u'message': translate('BiblePlugin.HTTPBible', 'There was a ' 'problem downloading your verse selection. Please check your ' 'Internet connection, and if this error continues to occur ' - 'consider reporting a bug.') + 'please consider reporting a bug.') }) - elif reason == u'parse': + elif error_type == u'parse': Receiver.send_message(u'openlp_error_message', { u'title': translate('BiblePlugin.HTTPBible', 'Parse Error'), u'message': translate('BiblePlugin.HTTPBible', 'There was a ' 'problem extracting your verse selection. If this error continues ' - 'to occur consider reporting a bug.') + 'to occur please consider reporting a bug.') }) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 40d76c36a..d60afccd5 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -327,7 +327,7 @@ class BibleMediaItem(MediaManagerItem): if not hasattr(self, u'import_wizard'): self.import_wizard = BibleImportForm(self, self.parent.manager, self.parent) - # If the import was not canceled then reload. + # If the import was not cancelled then reload. if self.import_wizard.exec_(): self.reloadBibles() diff --git a/openlp/plugins/bibles/lib/openlp1.py b/openlp/plugins/bibles/lib/openlp1.py index 866652e5b..2df6b1677 100644 --- a/openlp/plugins/bibles/lib/openlp1.py +++ b/openlp/plugins/bibles/lib/openlp1.py @@ -30,7 +30,7 @@ import sqlite from PyQt4 import QtCore from openlp.core.lib import Receiver, translate -from db import BibleDB +from openlp.plugins.bibles.lib.db import BibleDB log = logging.getLogger(__name__) @@ -46,7 +46,7 @@ class OpenLP1Bible(BibleDB): BibleDB.__init__(self, parent, **kwargs) self.filename = kwargs[u'filename'] QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'bibles_stop_import'), self.stop_import) + QtCore.SIGNAL(u'openlp_stop_wizard'), self.stop_import) def do_import(self): """ @@ -62,7 +62,7 @@ class OpenLP1Bible(BibleDB): # Create all books. cursor.execute(u'SELECT id, testament_id, name, abbreviation FROM book') books = cursor.fetchall() - self.wizard.importProgressBar.setMaximum(len(books) + 1) + self.wizard.progressBar.setMaximum(len(books) + 1) for book in books: if self.stop_import_flag: connection.close() diff --git a/openlp/plugins/bibles/lib/opensong.py b/openlp/plugins/bibles/lib/opensong.py index 03d243390..2b3b6dfb7 100644 --- a/openlp/plugins/bibles/lib/opensong.py +++ b/openlp/plugins/bibles/lib/opensong.py @@ -30,7 +30,7 @@ from lxml import objectify from PyQt4 import QtCore from openlp.core.lib import Receiver, translate -from db import BibleDB +from openlp.plugins.bibles.lib.db import BibleDB log = logging.getLogger(__name__) @@ -48,7 +48,7 @@ class OpenSongBible(BibleDB): BibleDB.__init__(self, parent, **kwargs) self.filename = kwargs['filename'] QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'bibles_stop_import'), self.stop_import) + QtCore.SIGNAL(u'openlp_stop_wizard'), self.stop_import) def do_import(self): """ diff --git a/openlp/plugins/bibles/lib/osis.py b/openlp/plugins/bibles/lib/osis.py index bf070c4bd..4a001987d 100644 --- a/openlp/plugins/bibles/lib/osis.py +++ b/openlp/plugins/bibles/lib/osis.py @@ -35,7 +35,7 @@ from PyQt4 import QtCore from openlp.core.lib import Receiver, translate from openlp.core.utils import AppLocation -from db import BibleDB +from openlp.plugins.bibles.lib.db import BibleDB log = logging.getLogger(__name__) @@ -87,7 +87,7 @@ class OSISBible(BibleDB): if fbibles: fbibles.close() QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'bibles_stop_import'), self.stop_import) + QtCore.SIGNAL(u'openlp_stop_wizard'), self.stop_import) def do_import(self): """ @@ -134,9 +134,9 @@ class OSISBible(BibleDB): testament) if last_chapter == 0: if book == u'Gen': - self.wizard.importProgressBar.setMaximum(1188) + self.wizard.progressBar.setMaximum(1188) else: - self.wizard.importProgressBar.setMaximum(260) + self.wizard.progressBar.setMaximum(260) if last_chapter != chapter: if last_chapter != 0: self.session.commit() diff --git a/openlp/plugins/songs/forms/songimportform.py b/openlp/plugins/songs/forms/songimportform.py index 5776dd21a..22a7ab61f 100644 --- a/openlp/plugins/songs/forms/songimportform.py +++ b/openlp/plugins/songs/forms/songimportform.py @@ -23,19 +23,21 @@ # with this program; if not, write to the Free Software Foundation, Inc., 59 # # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### - +""" +The song import functions for OpenLP. +""" import logging import os from PyQt4 import QtCore, QtGui -from songimportwizard import Ui_SongImportWizard from openlp.core.lib import Receiver, SettingsManager, translate +from openlp.core.ui.wizard import OpenLPWizard from openlp.plugins.songs.lib.importer import SongFormat log = logging.getLogger(__name__) -class SongImportForm(QtGui.QWizard, Ui_SongImportWizard): +class SongImportForm(OpenLPWizard): """ This is the Song Import Wizard, which allows easy importing of Songs into OpenLP from other formats like OpenLyrics, OpenSong and CCLI. @@ -52,11 +54,23 @@ class SongImportForm(QtGui.QWizard, Ui_SongImportWizard): ``plugin`` The songs plugin. """ - QtGui.QWizard.__init__(self, parent) - self.setupUi(self) - self.registerFields() - self.finishButton = self.button(QtGui.QWizard.FinishButton) - self.cancelButton = self.button(QtGui.QWizard.CancelButton) + OpenLPWizard.__init__(self, parent, plugin, u'songImportWizard', + u':/wizards/wizard_importsong.bmp') + + def setupUi(self, image): + """ + Set up the song wizard UI. + """ + OpenLPWizard.setupUi(self, image) + self.formatStack.setCurrentIndex(0) + QtCore.QObject.connect(self.formatComboBox, + QtCore.SIGNAL(u'currentIndexChanged(int)'), + self.formatStack.setCurrentIndex) + + def customInit(self): + """ + Song wizard specific initialisation. + """ if not SongFormat.get_availability(SongFormat.OpenLP1): self.openLP1DisabledWidget.setVisible(True) self.openLP1ImportWidget.setVisible(False) @@ -66,7 +80,11 @@ class SongImportForm(QtGui.QWizard, Ui_SongImportWizard): if not SongFormat.get_availability(SongFormat.Generic): self.genericDisabledWidget.setVisible(True) self.genericImportWidget.setVisible(False) - self.plugin = plugin + + def customSignals(self): + """ + Song wizard specific signals. + """ QtCore.QObject.connect(self.openLP2BrowseButton, QtCore.SIGNAL(u'clicked()'), self.onOpenLP2BrowseButtonClicked) @@ -118,25 +136,184 @@ class SongImportForm(QtGui.QWizard, Ui_SongImportWizard): QtCore.QObject.connect(self.songBeamerRemoveButton, QtCore.SIGNAL(u'clicked()'), self.onSongBeamerRemoveButtonClicked) - QtCore.QObject.connect(self, - QtCore.SIGNAL(u'currentIdChanged(int)'), - self.onCurrentIdChanged) - def exec_(self): + def addCustomPages(self): """ - Run the wizard. + Add song wizard specific pages. """ - self.setDefaults() - return QtGui.QWizard.exec_(self) + # Source Page + self.sourcePage = QtGui.QWizardPage() + self.sourcePage.setObjectName(u'SourcePage') + self.sourceLayout = QtGui.QVBoxLayout(self.sourcePage) + self.sourceLayout.setObjectName(u'SourceLayout') + self.formatLayout = QtGui.QFormLayout() + self.formatLayout.setObjectName(u'FormatLayout') + self.formatLabel = QtGui.QLabel(self.sourcePage) + self.formatLabel.setObjectName(u'FormatLabel') + self.formatComboBox = QtGui.QComboBox(self.sourcePage) + self.formatComboBox.setObjectName(u'FormatComboBox') + self.formatLayout.addRow(self.formatLabel, self.formatComboBox) + self.formatSpacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed, + QtGui.QSizePolicy.Minimum) + self.formatLayout.setItem(1, QtGui.QFormLayout.LabelRole, + self.formatSpacer) + self.sourceLayout.addLayout(self.formatLayout) + self.formatStack = QtGui.QStackedLayout() + self.formatStack.setObjectName(u'FormatStack') + # 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) + # 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.addLayout(self.formatStack) + self.addPage(self.sourcePage) - def reject(self): + def retranslateUi(self): """ - Stop the import on cancel button, close button or ESC key. + Song wizard localisation. """ - log.debug(u'Import canceled by user.') - if self.currentPage() == self.importPage: - Receiver.send_message(u'songs_stop_import') - self.done(QtGui.QDialog.Rejected) + self.setWindowTitle( + translate('SongsPlugin.ImportWizardForm', 'Song Import Wizard')) + self.titleLabel.setText( + u'%s' % \ + 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.progressPage.setTitle( + translate('SongsPlugin.ImportWizardForm', 'Importing')) + self.progressPage.setSubTitle( + translate('SongsPlugin.ImportWizardForm', + 'Please wait while your songs are imported.')) + self.progressLabel.setText( + translate('SongsPlugin.ImportWizardForm', 'Ready.')) + self.progressBar.setFormat( + translate('SongsPlugin.ImportWizardForm', '%p%')) + # Align all QFormLayouts towards each other. + width = max(self.formatLabel.minimumSizeHint().width(), + self.openLP2FilenameLabel.minimumSizeHint().width()) + self.formatSpacer.changeSize(width, 0, QtGui.QSizePolicy.Fixed, + QtGui.QSizePolicy.Fixed) + self.openLP2FormLabelSpacer.changeSize(width, 0, + QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) + self.openLP1FormLabelSpacer.changeSize(width, 0, + QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) + self.ewFormLabelSpacer.changeSize(width, 0, QtGui.QSizePolicy.Fixed, + QtGui.QSizePolicy.Fixed) +# self.csvFormLabelSpacer.changeSize(width, 0, QtGui.QSizePolicy.Fixed, +# QtGui.QSizePolicy.Fixed) def validateCurrentPage(self): """ @@ -247,7 +424,7 @@ class SongImportForm(QtGui.QWizard, Ui_SongImportWizard): self.songBeamerAddButton.setFocus() return False return True - elif self.currentPage() == self.importPage: + elif self.currentPage() == self.progressPage: return True def getFileName(self, title, editbox, filters=u''): @@ -308,17 +485,26 @@ class SongImportForm(QtGui.QWizard, Ui_SongImportWizard): os.path.split(unicode(filenames[0]))[0], 1) def getListOfFiles(self, listbox): + """ + Return a list of file from the listbox + """ files = [] for row in range(0, listbox.count()): files.append(unicode(listbox.item(row).text())) return files def removeSelectedItems(self, listbox): + """ + Remove selected listbox items + """ for item in listbox.selectedItems(): item = listbox.takeItem(listbox.row(item)) del item def onOpenLP2BrowseButtonClicked(self): + """ + Get OpenLP v2 song database file + """ self.getFileName( translate('SongsPlugin.ImportWizardForm', 'Select OpenLP 2.0 Database File'), @@ -328,6 +514,9 @@ class SongImportForm(QtGui.QWizard, Ui_SongImportWizard): ) def onOpenLP1BrowseButtonClicked(self): + """ + Get OpenLP v1 song database file + """ self.getFileName( translate('SongsPlugin.ImportWizardForm', 'Select openlp.org 1.x Database File'), @@ -337,6 +526,9 @@ class SongImportForm(QtGui.QWizard, Ui_SongImportWizard): ) def onOpenLyricsAddButtonClicked(self): + """ + Get OpenLyrics song database files + """ self.getFiles( translate('SongsPlugin.ImportWizardForm', 'Select OpenLyrics Files'), @@ -344,19 +536,30 @@ class SongImportForm(QtGui.QWizard, Ui_SongImportWizard): ) def onOpenLyricsRemoveButtonClicked(self): + """ + Remove selected OpenLyrics files from the import list + """ self.removeSelectedItems(self.openLyricsFileListWidget) def onOpenSongAddButtonClicked(self): + """ + Get OpenSong song database files + """ self.getFiles( - translate('SongsPlugin.ImportWizardForm', - 'Select Open Song Files'), + translate('SongsPlugin.ImportWizardForm', 'Select Open Song Files'), self.openSongFileListWidget ) def onOpenSongRemoveButtonClicked(self): + """ + Remove selected OpenSong files from the import list + """ self.removeSelectedItems(self.openSongFileListWidget) def onWordsOfWorshipAddButtonClicked(self): + """ + Get Words of Worship song database files + """ self.getFiles( translate('SongsPlugin.ImportWizardForm', 'Select Words of Worship Files'), @@ -366,9 +569,15 @@ class SongImportForm(QtGui.QWizard, Ui_SongImportWizard): ) def onWordsOfWorshipRemoveButtonClicked(self): + """ + Remove selected Words of Worship files from the import list + """ self.removeSelectedItems(self.wordsOfWorshipFileListWidget) def onCCLIAddButtonClicked(self): + """ + Get CCLI song database files + """ self.getFiles( translate('SongsPlugin.ImportWizardForm', 'Select CCLI Files'), @@ -376,9 +585,15 @@ class SongImportForm(QtGui.QWizard, Ui_SongImportWizard): ) def onCCLIRemoveButtonClicked(self): + """ + Remove selected CCLI files from the import list + """ self.removeSelectedItems(self.ccliFileListWidget) def onSongsOfFellowshipAddButtonClicked(self): + """ + Get Songs of Fellowship song database files + """ self.getFiles( translate('SongsPlugin.ImportWizardForm', 'Select Songs of Fellowship Files'), @@ -388,9 +603,15 @@ class SongImportForm(QtGui.QWizard, Ui_SongImportWizard): ) def onSongsOfFellowshipRemoveButtonClicked(self): + """ + Remove selected Songs of Fellowship files from the import list + """ self.removeSelectedItems(self.songsOfFellowshipFileListWidget) def onGenericAddButtonClicked(self): + """ + Get song database files + """ self.getFiles( translate('SongsPlugin.ImportWizardForm', 'Select Document/Presentation Files'), @@ -398,9 +619,15 @@ class SongImportForm(QtGui.QWizard, Ui_SongImportWizard): ) def onGenericRemoveButtonClicked(self): + """ + Remove selected files from the import list + """ self.removeSelectedItems(self.genericFileListWidget) def onEWBrowseButtonClicked(self): + """ + Get EasyWorship song database files + """ self.getFileName( translate('SongsPlugin.ImportWizardForm', 'Select EasyWorship Database File'), @@ -408,6 +635,9 @@ class SongImportForm(QtGui.QWizard, Ui_SongImportWizard): ) def onSongBeamerAddButtonClicked(self): + """ + Get SongBeamer song database files + """ self.getFiles( translate('SongsPlugin.ImportWizardForm', 'Select SongBeamer Files'), @@ -416,18 +646,21 @@ class SongImportForm(QtGui.QWizard, Ui_SongImportWizard): ) def onSongBeamerRemoveButtonClicked(self): + """ + Remove selected SongBeamer files from the import list + """ self.removeSelectedItems(self.songBeamerFileListWidget) - def onCurrentIdChanged(self, id): - if self.page(id) == self.importPage: - self.preImport() - self.performImport() - self.postImport() - def registerFields(self): + """ + Register song import wizard fields. + """ pass def setDefaults(self): + """ + Set default form values for the song import wizard. + """ self.restart() self.finishButton.setVisible(False) self.cancelButton.setVisible(True) @@ -444,25 +677,16 @@ class SongImportForm(QtGui.QWizard, Ui_SongImportWizard): self.songBeamerFileListWidget.clear() #self.csvFilenameEdit.setText(u'') - def incrementProgressBar(self, status_text, increment=1): - log.debug(u'IncrementBar %s', status_text) - if status_text: - self.importProgressLabel.setText(status_text) - if increment > 0: - self.importProgressBar.setValue(self.importProgressBar.value() + - increment) - Receiver.send_message(u'openlp_process_events') - - def preImport(self): - self.finishButton.setVisible(False) - self.importProgressBar.setMinimum(0) - self.importProgressBar.setMaximum(1188) - self.importProgressBar.setValue(0) - self.importProgressLabel.setText( + def preWizard(self): + """ + Perform pre import tasks + """ + OpenLPWizard.preWizard(self) + self.progressLabel.setText( translate('SongsPlugin.ImportWizardForm', 'Starting import...')) Receiver.send_message(u'openlp_process_events') - def performImport(self): + def performWizard(self): """ Perform the actual import. This method pulls in the correct importer class, and then runs the ``do_import`` method of the importer to do @@ -520,20 +744,128 @@ class SongImportForm(QtGui.QWizard, Ui_SongImportWizard): elif source_format == SongFormat.SongBeamer: # Import SongBeamer songs importer = self.plugin.importSongs(SongFormat.SongBeamer, - filenames=self.getListOfFiles( - self.songBeamerFileListWidget) + filenames=self.getListOfFiles(self.songBeamerFileListWidget) ) if importer.do_import(): # reload songs - self.importProgressLabel.setText( + self.progressLabel.setText( translate('SongsPlugin.SongImportForm', 'Finished import.')) else: - self.importProgressLabel.setText( + self.progressLabel.setText( translate('SongsPlugin.SongImportForm', 'Your song import failed.')) - def postImport(self): - self.importProgressBar.setValue(self.importProgressBar.maximum()) - self.finishButton.setVisible(True) - self.cancelButton.setVisible(False) - Receiver.send_message(u'openlp_process_events') + 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) + 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') + fileLayout = QtGui.QHBoxLayout() + 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.addRow(filenameLabel, fileLayout) + formSpacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed, + QtGui.QSizePolicy.Minimum) + importLayout.setItem(1, QtGui.QFormLayout.LabelRole, formSpacer) + self.formatStack.addWidget(page) + setattr(self, prefix + u'Page', page) + setattr(self, prefix + u'FilenameLabel', filenameLabel) + setattr(self, prefix + u'FormLabelSpacer', formSpacer) + 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) + 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.setObjectName(obj_prefix + u'ButtonLayout') + addButton = QtGui.QPushButton(importWidget) + addButton.setIcon(self.openIcon) + addButton.setObjectName(obj_prefix + u'AddButton') + buttonLayout.addWidget(addButton) + buttonLayout.addStretch() + removeButton = QtGui.QPushButton(importWidget) + removeButton.setIcon(self.deleteIcon) + removeButton.setObjectName(obj_prefix + u'RemoveButton') + buttonLayout.addWidget(removeButton) + importLayout.addLayout(buttonLayout) + self.formatStack.addWidget(page) + setattr(self, prefix + u'Page', page) + setattr(self, prefix + u'FileListWidget', fileListWidget) + setattr(self, prefix + u'ButtonLayout', buttonLayout) + 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.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 diff --git a/openlp/plugins/songs/forms/songimportwizard.py b/openlp/plugins/songs/forms/songimportwizard.py deleted file mode 100644 index 903300d0c..000000000 --- a/openlp/plugins/songs/forms/songimportwizard.py +++ /dev/null @@ -1,362 +0,0 @@ -# -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 - -############################################################################### -# OpenLP - Open Source Lyrics Projection # -# --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 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.setModal(True) - songImportWizard.setWizardStyle(QtGui.QWizard.ModernStyle) - songImportWizard.setOptions( - QtGui.QWizard.IndependentPages | - QtGui.QWizard.NoBackButtonOnStartPage | - QtGui.QWizard.NoBackButtonOnLastPage) - # Welcome Page - self.welcomePage = QtGui.QWizardPage() - self.welcomePage.setPixmap(QtGui.QWizard.WatermarkPixmap, - QtGui.QPixmap(u':/wizards/wizard_importsong.bmp')) - self.welcomePage.setObjectName(u'WelcomePage') - self.welcomeLayout = QtGui.QVBoxLayout(self.welcomePage) - self.welcomeLayout.setObjectName(u'WelcomeLayout') - self.titleLabel = QtGui.QLabel(self.welcomePage) - self.titleLabel.setObjectName(u'TitleLabel') - self.welcomeLayout.addWidget(self.titleLabel) - self.welcomeLayout.addSpacing(40) - self.informationLabel = QtGui.QLabel(self.welcomePage) - self.informationLabel.setWordWrap(True) - self.informationLabel.setObjectName(u'InformationLabel') - self.welcomeLayout.addWidget(self.informationLabel) - self.welcomeLayout.addStretch() - songImportWizard.addPage(self.welcomePage) - # Source Page - self.sourcePage = QtGui.QWizardPage() - self.sourcePage.setObjectName(u'SourcePage') - self.sourceLayout = QtGui.QVBoxLayout(self.sourcePage) - self.sourceLayout.setObjectName(u'SourceLayout') - self.formatLayout = QtGui.QFormLayout() - self.formatLayout.setObjectName(u'FormatLayout') - self.formatLabel = QtGui.QLabel(self.sourcePage) - self.formatLabel.setObjectName(u'FormatLabel') - self.formatComboBox = QtGui.QComboBox(self.sourcePage) - self.formatComboBox.setObjectName(u'FormatComboBox') - self.formatLayout.addRow(self.formatLabel, self.formatComboBox) - self.formatSpacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed, - QtGui.QSizePolicy.Minimum) - self.formatLayout.setItem(1, QtGui.QFormLayout.LabelRole, - self.formatSpacer) - self.sourceLayout.addLayout(self.formatLayout) - self.formatStack = QtGui.QStackedLayout() - self.formatStack.setObjectName(u'FormatStack') - # 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) - # 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.addLayout(self.formatStack) - songImportWizard.addPage(self.sourcePage) - # Import Page - self.importPage = QtGui.QWizardPage() - self.importPage.setObjectName(u'ImportPage') - self.importLayout = QtGui.QVBoxLayout(self.importPage) - self.importLayout.setMargin(48) - 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.setObjectName(u'ImportProgressBar') - self.importLayout.addWidget(self.importProgressBar) - songImportWizard.addPage(self.importPage) - self.retranslateUi(songImportWizard) - self.formatStack.setCurrentIndex(0) - QtCore.QObject.connect(self.formatComboBox, - QtCore.SIGNAL(u'currentIndexChanged(int)'), - self.formatStack.setCurrentIndex) - QtCore.QMetaObject.connectSlotsByName(songImportWizard) - - def retranslateUi(self, songImportWizard): - songImportWizard.setWindowTitle( - translate('SongsPlugin.ImportWizardForm', 'Song Import Wizard')) - self.titleLabel.setText( - u'%s' % \ - 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%')) - # Align all QFormLayouts towards each other. - width = max(self.formatLabel.minimumSizeHint().width(), - self.openLP2FilenameLabel.minimumSizeHint().width()) - self.formatSpacer.changeSize(width, 0, QtGui.QSizePolicy.Fixed, - QtGui.QSizePolicy.Fixed) - self.openLP2FormLabelSpacer.changeSize(width, 0, - QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) - self.openLP1FormLabelSpacer.changeSize(width, 0, - QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) - self.ewFormLabelSpacer.changeSize(width, 0, QtGui.QSizePolicy.Fixed, - QtGui.QSizePolicy.Fixed) -# self.csvFormLabelSpacer.changeSize(width, 0, QtGui.QSizePolicy.Fixed, -# QtGui.QSizePolicy.Fixed) - - 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) - 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') - fileLayout = QtGui.QHBoxLayout() - 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.addRow(filenameLabel, fileLayout) - formSpacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed, - QtGui.QSizePolicy.Minimum) - importLayout.setItem(1, QtGui.QFormLayout.LabelRole, formSpacer) - self.formatStack.addWidget(page) - setattr(self, prefix + u'Page', page) - setattr(self, prefix + u'FilenameLabel', filenameLabel) - setattr(self, prefix + u'FormLabelSpacer', formSpacer) - 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) - 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.setObjectName(obj_prefix + u'ButtonLayout') - addButton = QtGui.QPushButton(importWidget) - addButton.setIcon(self.openIcon) - addButton.setObjectName(obj_prefix + u'AddButton') - buttonLayout.addWidget(addButton) - buttonLayout.addStretch() - removeButton = QtGui.QPushButton(importWidget) - removeButton.setIcon(self.deleteIcon) - removeButton.setObjectName(obj_prefix + u'RemoveButton') - buttonLayout.addWidget(removeButton) - importLayout.addLayout(buttonLayout) - self.formatStack.addWidget(page) - setattr(self, prefix + u'Page', page) - setattr(self, prefix + u'FileListWidget', fileListWidget) - setattr(self, prefix + u'ButtonLayout', buttonLayout) - 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.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 diff --git a/openlp/plugins/songs/lib/cclifileimport.py b/openlp/plugins/songs/lib/cclifileimport.py index 1b8531755..2234a81b7 100644 --- a/openlp/plugins/songs/lib/cclifileimport.py +++ b/openlp/plugins/songs/lib/cclifileimport.py @@ -67,7 +67,7 @@ class CCLIFileImport(SongImport): """ log.debug(u'Starting CCLI File Import') song_total = len(self.filenames) - self.import_wizard.importProgressBar.setMaximum(song_total) + self.import_wizard.progressBar.setMaximum(song_total) song_count = 1 for filename in self.filenames: self.import_wizard.incrementProgressBar(unicode(translate( diff --git a/openlp/plugins/songs/lib/ewimport.py b/openlp/plugins/songs/lib/ewimport.py index d74cd284f..312e3b759 100644 --- a/openlp/plugins/songs/lib/ewimport.py +++ b/openlp/plugins/songs/lib/ewimport.py @@ -186,7 +186,7 @@ class EasyWorshipSongImport(SongImport): # There does not appear to be a _reliable_ way of getting the number # of songs/records, so let's use file blocks for measuring progress. total_blocks = (db_size - header_size) / (block_size * 1024) - self.import_wizard.importProgressBar.setMaximum(total_blocks) + self.import_wizard.progressBar.setMaximum(total_blocks) # Read the field description information db_file.seek(120) field_info = db_file.read(num_fields * 2) diff --git a/openlp/plugins/songs/lib/olp1import.py b/openlp/plugins/songs/lib/olp1import.py index ceaee3302..c3e1ca6b4 100644 --- a/openlp/plugins/songs/lib/olp1import.py +++ b/openlp/plugins/songs/lib/olp1import.py @@ -78,7 +78,7 @@ class OpenLP1SongImport(SongImport): cursor.execute(u'SELECT COUNT(songid) FROM songs') count = cursor.fetchone()[0] success = True - self.import_wizard.importProgressBar.setMaximum(count) + self.import_wizard.progressBar.setMaximum(count) # "cache" our list of authors cursor.execute(u'-- types int, unicode') cursor.execute(u'SELECT authorid, authorname FROM authors') diff --git a/openlp/plugins/songs/lib/olpimport.py b/openlp/plugins/songs/lib/olpimport.py index e366ddf4b..d2a00447f 100644 --- a/openlp/plugins/songs/lib/olpimport.py +++ b/openlp/plugins/songs/lib/olpimport.py @@ -146,7 +146,7 @@ class OpenLPSongImport(SongImport): source_songs = self.source_session.query(OldSong).all() song_total = len(source_songs) - self.import_wizard.importProgressBar.setMaximum(song_total) + self.import_wizard.progressBar.setMaximum(song_total) song_count = 1 for song in source_songs: self.import_wizard.incrementProgressBar(unicode(translate( diff --git a/openlp/plugins/songs/lib/oooimport.py b/openlp/plugins/songs/lib/oooimport.py index c5cca4fd6..be33cb8fb 100644 --- a/openlp/plugins/songs/lib/oooimport.py +++ b/openlp/plugins/songs/lib/oooimport.py @@ -63,11 +63,11 @@ class OooImport(SongImport): self.filenames = kwargs[u'filenames'] self.uno_connection_type = u'pipe' #u'socket' QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'song_stop_import'), self.stop_import) + QtCore.SIGNAL(u'openlp_stop_wizard'), self.stop_import) def do_import(self): self.abort = False - self.import_wizard.importProgressBar.setMaximum(0) + self.import_wizard.progressBar.setMaximum(0) self.start_ooo() for filename in self.filenames: if self.abort: @@ -85,7 +85,7 @@ class OooImport(SongImport): self.process_doc() self.close_ooo_file() self.close_ooo() - self.import_wizard.importProgressBar.setMaximum(1) + self.import_wizard.progressBar.setMaximum(1) self.import_wizard.incrementProgressBar(u'', 1) return True diff --git a/openlp/plugins/songs/lib/openlyricsimport.py b/openlp/plugins/songs/lib/openlyricsimport.py index c4610dfc0..220160b1d 100644 --- a/openlp/plugins/songs/lib/openlyricsimport.py +++ b/openlp/plugins/songs/lib/openlyricsimport.py @@ -60,7 +60,7 @@ class OpenLyricsImport(SongImport): """ Imports the songs. """ - self.import_wizard.importProgressBar.setMaximum(len(self.import_source)) + self.import_wizard.progressBar.setMaximum(len(self.import_source)) for file_path in self.import_source: if self.stop_import_flag: return False @@ -68,8 +68,8 @@ class OpenLyricsImport(SongImport): 'SongsPlugin.OpenLyricsImport', 'Importing %s...')) % os.path.basename(file_path)) parser = etree.XMLParser(remove_blank_text=True) - file = etree.parse(file_path, parser) - xml = unicode(etree.tostring(file)) + parsed_file = etree.parse(file_path, parser) + xml = unicode(etree.tostring(parsed_file)) if self.openLyrics.xml_to_song(xml) is None: log.debug(u'File could not be imported: %s' % file_path) # Importing this song failed! For now we stop import. diff --git a/openlp/plugins/songs/lib/opensongimport.py b/openlp/plugins/songs/lib/opensongimport.py index 6a60fcc6c..eb16f4ba4 100644 --- a/openlp/plugins/songs/lib/opensongimport.py +++ b/openlp/plugins/songs/lib/opensongimport.py @@ -129,7 +129,7 @@ class OpenSongImport(SongImport): else: numfiles += 1 log.debug(u'Total number of files: %d', numfiles) - self.import_wizard.importProgressBar.setMaximum(numfiles) + self.import_wizard.progressBar.setMaximum(numfiles) for filename in self.filenames: if self.stop_import_flag: success = False diff --git a/openlp/plugins/songs/lib/sofimport.py b/openlp/plugins/songs/lib/sofimport.py index 3e6ee8c3a..8475b0824 100644 --- a/openlp/plugins/songs/lib/sofimport.py +++ b/openlp/plugins/songs/lib/sofimport.py @@ -89,7 +89,7 @@ class SofImport(OooImport): self.process_sof_file() self.close_ooo_file() self.close_ooo() - self.import_wizard.importProgressBar.setMaximum(1) + self.import_wizard.progressBar.setMaximum(1) self.import_wizard.incrementProgressBar(u'', 1) return True @@ -550,4 +550,4 @@ class SofImport(OooImport): return 6 if song_number == 1119: return 7 - return None \ No newline at end of file + return None diff --git a/openlp/plugins/songs/lib/songbeamerimport.py b/openlp/plugins/songs/lib/songbeamerimport.py index 12ff53428..c783793db 100644 --- a/openlp/plugins/songs/lib/songbeamerimport.py +++ b/openlp/plugins/songs/lib/songbeamerimport.py @@ -75,7 +75,6 @@ class SongBeamerImport(SongImport): The song manager for the running OpenLP installation. """ SongImport.__init__(self, master_manager) - self.master_manager = master_manager if kwargs.has_key(u'filename'): self.import_source = kwargs[u'filename'] if kwargs.has_key(u'filenames'): @@ -87,7 +86,7 @@ class SongBeamerImport(SongImport): Recieve a single file, or a list of files to import. """ if isinstance(self.import_source, list): - self.import_wizard.importProgressBar.setMaximum( + self.import_wizard.progressBar.setMaximum( len(self.import_source)) for file in self.import_source: # TODO: check that it is a valid SongBeamer file diff --git a/openlp/plugins/songs/lib/songimport.py b/openlp/plugins/songs/lib/songimport.py index 05ed320a9..c1105a578 100644 --- a/openlp/plugins/songs/lib/songimport.py +++ b/openlp/plugins/songs/lib/songimport.py @@ -55,7 +55,7 @@ class SongImport(QtCore.QObject): self.stop_import_flag = False self.set_defaults() QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'songs_stop_import'), self.stop_import) + QtCore.SIGNAL(u'openlp_stop_wizard'), self.stop_import) def set_defaults(self): """ @@ -364,4 +364,4 @@ class SongImport(QtCore.QObject): if self.theme_name: print u'THEME: ' + self.theme_name if self.ccli_number: - print u'CCLI: ' + self.ccli_number \ No newline at end of file + print u'CCLI: ' + self.ccli_number diff --git a/openlp/plugins/songs/lib/test/test_opensongimport.py b/openlp/plugins/songs/lib/test/test_opensongimport.py index 27c7cca48..fd1d37e3e 100644 --- a/openlp/plugins/songs/lib/test/test_opensongimport.py +++ b/openlp/plugins/songs/lib/test/test_opensongimport.py @@ -35,7 +35,7 @@ logging.basicConfig(filename=LOG_FILENAME,level=logging.INFO) # Stubs to replace the UI functions for raw testing class wizard_stub: def __init__(self): - self.importProgressBar=progbar_stub() + self.progressBar=progbar_stub() def incrementProgressBar(self, str): pass class progbar_stub: diff --git a/openlp/plugins/songs/lib/wowimport.py b/openlp/plugins/songs/lib/wowimport.py index 1d5470f9b..d0c308413 100644 --- a/openlp/plugins/songs/lib/wowimport.py +++ b/openlp/plugins/songs/lib/wowimport.py @@ -99,7 +99,6 @@ class WowImport(SongImport): The song manager for the running OpenLP installation. """ SongImport.__init__(self, master_manager) - self.master_manager = master_manager if kwargs.has_key(u'filename'): self.import_source = kwargs[u'filename'] if kwargs.has_key(u'filenames'): @@ -112,8 +111,7 @@ class WowImport(SongImport): """ if isinstance(self.import_source, list): - self.import_wizard.importProgressBar.setMaximum( - len(self.import_source)) + self.import_wizard.progressBar.setMaximum(len(self.import_source)) for file in self.import_source: self.author = u'' self.copyright = u''