From a34957297c02b440f45bebdb77dc9779ea14b246 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Sat, 19 Jun 2010 18:56:21 +0100 Subject: [PATCH 01/15] Cleanups --- openlp/core/lib/themexmlhandler.py | 6 ++++-- openlp/core/theme/theme.py | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/openlp/core/lib/themexmlhandler.py b/openlp/core/lib/themexmlhandler.py index b2850d6ec..779dc3507 100644 --- a/openlp/core/lib/themexmlhandler.py +++ b/openlp/core/lib/themexmlhandler.py @@ -339,7 +339,8 @@ class ThemeXML(object): """ Pull out the XML string formatted for human consumption """ - return self.theme_xml.toprettyxml(indent=u' ', newl=u'\n', encoding=u'utf-8') + return self.theme_xml.toprettyxml(indent=u' ', newl=u'\n', + encoding=u'utf-8') def parse(self, xml): """ @@ -364,7 +365,8 @@ class ThemeXML(object): ``xml`` The XML string to parse. """ - theme_xml = ElementTree(element=XML(xml.encode(u'ascii', u'xmlcharrefreplace'))) + theme_xml = ElementTree(element=XML(xml.encode(u'ascii', + u'xmlcharrefreplace'))) xml_iter = theme_xml.getiterator() master = u'' for element in xml_iter: diff --git a/openlp/core/theme/theme.py b/openlp/core/theme/theme.py index b75b55a2e..2ea13d01b 100644 --- a/openlp/core/theme/theme.py +++ b/openlp/core/theme/theme.py @@ -175,7 +175,8 @@ class Theme(object): ``xml`` The data to apply to the theme """ - root = ElementTree(element=XML(xml.encode(u'ascii', u'xmlcharrefreplace'))) + root = ElementTree(element=XML(xml.encode(u'ascii', + u'xmlcharrefreplace'))) xml_iter = root.getiterator() for element in xml_iter: delphi_color_change = False From e6154010078a1bf7238bdf8030aac37e970e9ca6 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Sat, 19 Jun 2010 20:00:50 +0200 Subject: [PATCH 02/15] Make image formats filter in a central location. --- openlp/core/ui/amendthemeform.py | 8 +++++-- openlp/core/utils/__init__.py | 30 +++++++++++++++++++++++--- openlp/plugins/images/lib/mediaitem.py | 14 ++++++------ 3 files changed, 40 insertions(+), 12 deletions(-) diff --git a/openlp/core/ui/amendthemeform.py b/openlp/core/ui/amendthemeform.py index 9306a931c..ff5ea63c0 100644 --- a/openlp/core/ui/amendthemeform.py +++ b/openlp/core/ui/amendthemeform.py @@ -30,6 +30,7 @@ import os.path from PyQt4 import QtCore, QtGui from openlp.core.lib import ThemeXML, translate +from openlp.core.utils import get_images_filter from amendthemedialog import Ui_AmendThemeDialog log = logging.getLogger(u'AmendThemeForm') @@ -209,8 +210,11 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): self.previewTheme() def onImageToolButtonClicked(self): - filename = QtGui.QFileDialog.getOpenFileName( - self, translate(u'AmendThemeForm', u'Open file')) + images_filter = get_images_filter() + images_filter = '%s;;%s (*.*) (*)' % (images_filter, + translate(u'AmendThemeForm', u'All Files')) + filename = QtGui.QFileDialog.getOpenFileName(self, + translate(u'AmendThemeForm', u'Select Image'), u'', images_filter) if filename: self.ImageLineEdit.setText(filename) self.theme.background_filename = filename diff --git a/openlp/core/utils/__init__.py b/openlp/core/utils/__init__.py index 857207896..d7fab0968 100644 --- a/openlp/core/utils/__init__.py +++ b/openlp/core/utils/__init__.py @@ -30,17 +30,20 @@ import os import sys import logging import urllib2 - from datetime import datetime -from PyQt4 import QtCore + +from PyQt4 import QtGui, QtCore import openlp +from openlp.core.lib import translate log = logging.getLogger(__name__) +images_filter = None class AppLocation(object): """ - Retrieve a directory based on the directory type. + The :class:`AppLocation` class is a static class which retrieves a + directory based on the directory type. """ AppDir = 1 ConfigDir = 2 @@ -176,6 +179,27 @@ def get_filesystem_encoding(): encoding = sys.getdefaultencoding() return encoding +def get_images_filter(): + """ + Returns a filter string for a file dialog containing all the supported + image formats. + """ + global images_filter + if not images_filter: + log.debug(u'Generating images filter.') + old_formats = [str(fmt).lower() + for fmt in QtGui.QImageReader.supportedImageFormats()] + new_formats = [] + for fmt in old_formats: + if fmt not in new_formats: + new_formats.append(fmt) + new_formats.sort() + visible_formats = u'(*.%s)' % u'; *.'.join(new_formats) + actual_formats = u'(*.%s)' % u' *.'.join(new_formats) + images_filter = u'%s %s %s' % (translate('OpenLP', 'Image Files'), + visible_formats, actual_formats) + return images_filter + from languagemanager import LanguageManager __all__ = [u'AppLocation', u'check_latest_version', u'add_actions', diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index 3cd498740..182dfca18 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -30,7 +30,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import MediaManagerItem, BaseListWithDnD, build_icon, \ context_menu_action, ItemCapabilities, SettingsManager, translate -from openlp.core.utils import AppLocation +from openlp.core.utils import AppLocation, get_images_filter log = logging.getLogger(__name__) @@ -61,12 +61,12 @@ class ImageMediaItem(MediaManagerItem): def retranslateUi(self): self.OnNewPrompt = translate('ImagePlugin.MediaItem', 'Select Image(s)') - file_formats = u'' - for file_format in QtGui.QImageReader.supportedImageFormats(): - file_formats += u'*.%s ' % file_format - self.OnNewFileMasks = unicode( - translate('ImagePlugin.MediaItem', - 'Images (%s);; All files (*)')) % file_formats + #file_formats = u'' + #for file_format in QtGui.QImageReader.supportedImageFormats(): + # file_formats += u'*.%s ' % file_format + file_formats = get_images_filter() + self.OnNewFileMasks = u'%s;;%s (*.*) (*)' % (file_formats, + unicode(translate('ImagePlugin.MediaItem', 'All Files'))) def requiredIcons(self): MediaManagerItem.requiredIcons(self) From 8c6e033c3d96040af3708ada9ebc07433c096cc3 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Sat, 19 Jun 2010 20:29:08 +0200 Subject: [PATCH 03/15] Fixed up translate parameters. --- openlp/core/ui/amendthemeform.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openlp/core/ui/amendthemeform.py b/openlp/core/ui/amendthemeform.py index 91fecf229..1439e711e 100644 --- a/openlp/core/ui/amendthemeform.py +++ b/openlp/core/ui/amendthemeform.py @@ -212,9 +212,9 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): def onImageToolButtonClicked(self): images_filter = get_images_filter() images_filter = '%s;;%s (*.*) (*)' % (images_filter, - translate(u'AmendThemeForm', u'All Files')) + translate('AmendThemeForm', 'All Files')) filename = QtGui.QFileDialog.getOpenFileName(self, - translate(u'AmendThemeForm', u'Select Image'), u'', images_filter) + translate('AmendThemeForm', 'Select Image'), u'', images_filter) if filename: self.ImageLineEdit.setText(filename) self.theme.background_filename = filename From 1005a3c1b1b3e32e44a3683e64362f1ed6623ca9 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Sat, 19 Jun 2010 19:29:18 +0100 Subject: [PATCH 04/15] Cleanup unneeded trailing backslashes --- openlp/core/lib/mediamanageritem.py | 28 +++++++++---------- openlp/core/ui/servicemanager.py | 2 +- openlp/core/ui/thememanager.py | 2 +- openlp/plugins/alerts/lib/alertstab.py | 2 +- .../songusage/forms/songusagedetailform.py | 7 ++--- openlp/plugins/songusage/lib/manager.py | 2 +- 6 files changed, 21 insertions(+), 22 deletions(-) diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index c0f016f94..a011a1c94 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -208,40 +208,40 @@ class MediaManagerItem(QtGui.QWidget): ## Import Button ## if self.hasImportIcon: self.addToolbarButton( - unicode(translate('MediaManagerItem', 'Import %s')) % \ + unicode(translate('MediaManagerItem', 'Import %s')) % self.PluginNameShort, - unicode(translate('MediaManagerItem', 'Import a %s')) % \ + unicode(translate('MediaManagerItem', 'Import a %s')) % self.PluginNameVisible, u':/general/general_import.png', self.onImportClick) ## File Button ## if self.hasFileIcon: self.addToolbarButton( - unicode(translate('MediaManagerItem', 'Load %s')) % \ + unicode(translate('MediaManagerItem', 'Load %s')) % self.PluginNameShort, - unicode(translate('MediaManagerItem', 'Load a new %s')) % \ + unicode(translate('MediaManagerItem', 'Load a new %s')) % self.PluginNameVisible, u':/general/general_open.png', self.onFileClick) ## New Button ## if self.hasNewIcon: self.addToolbarButton( - unicode(translate('MediaManagerItem', 'New %s')) % \ + unicode(translate('MediaManagerItem', 'New %s')) % self.PluginNameShort, - unicode(translate('MediaManagerItem', 'Add a new %s')) % \ + unicode(translate('MediaManagerItem', 'Add a new %s')) % self.PluginNameVisible, u':/general/general_new.png', self.onNewClick) ## Edit Button ## if self.hasEditIcon: self.addToolbarButton( - unicode(translate('MediaManagerItem', 'Edit %s')) % \ + unicode(translate('MediaManagerItem', 'Edit %s')) % self.PluginNameShort, unicode(translate( - 'MediaManagerItem', 'Edit the selected %s')) % \ + 'MediaManagerItem', 'Edit the selected %s')) % self.PluginNameVisible, u':/general/general_edit.png', self.onEditClick) ## Delete Button ## if self.hasDeleteIcon: self.addToolbarButton( - unicode(translate('MediaManagerItem', 'Delete %s')) % \ + unicode(translate('MediaManagerItem', 'Delete %s')) % self.PluginNameShort, translate('MediaManagerItem', 'Delete the selected item'), u':/general/general_delete.png', self.onDeleteClick) @@ -249,7 +249,7 @@ class MediaManagerItem(QtGui.QWidget): self.addToolbarSeparator() ## Preview ## self.addToolbarButton( - unicode(translate('MediaManagerItem', 'Preview %s')) % \ + unicode(translate('MediaManagerItem', 'Preview %s')) % self.PluginNameShort, translate('MediaManagerItem', 'Preview the selected item'), u':/general/general_preview.png', self.onPreviewClick) @@ -260,7 +260,7 @@ class MediaManagerItem(QtGui.QWidget): u':/general/general_live.png', self.onLiveClick) ## Add to service Button ## self.addToolbarButton( - unicode(translate('MediaManagerItem', 'Add %s to Service')) % \ + unicode(translate('MediaManagerItem', 'Add %s to Service')) % self.PluginNameShort, translate('MediaManagerItem', 'Add the selected item(s) to the service'), @@ -285,7 +285,7 @@ class MediaManagerItem(QtGui.QWidget): self.ListView.addAction( context_menu_action( self.ListView, u':/general/general_edit.png', - unicode(translate('MediaManagerItem', '&Edit %s')) % \ + unicode(translate('MediaManagerItem', '&Edit %s')) % self.PluginNameVisible, self.onEditClick)) self.ListView.addAction(context_menu_separator(self.ListView)) @@ -293,14 +293,14 @@ class MediaManagerItem(QtGui.QWidget): self.ListView.addAction( context_menu_action( self.ListView, u':/general/general_delete.png', - unicode(translate('MediaManagerItem', '&Delete %s')) % \ + unicode(translate('MediaManagerItem', '&Delete %s')) % self.PluginNameVisible, self.onDeleteClick)) self.ListView.addAction(context_menu_separator(self.ListView)) self.ListView.addAction( context_menu_action( self.ListView, u':/general/general_preview.png', - unicode(translate('MediaManagerItem', '&Preview %s')) % \ + unicode(translate('MediaManagerItem', '&Preview %s')) % self.PluginNameVisible, self.onPreviewClick)) self.ListView.addAction( diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index cccd34195..b317c6bf9 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -677,7 +677,7 @@ class ServiceManager(QtGui.QWidget): translate('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' % \ + log.exception(u'Filename "%s" is not valid UTF-8' % file.decode(u'utf-8', u'replace')) continue osfile = unicode(QtCore.QDir.toNativeSeparators(ucsfile)) diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 431b1d450..b645e541b 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -398,7 +398,7 @@ class ThemeManager(QtGui.QWidget): self, translate('ThemeManager', 'Error'), translate('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' % \ + log.exception(u'Filename "%s" is not valid UTF-8' % file.decode(u'utf-8', u'replace')) continue osfile = unicode(QtCore.QDir.toNativeSeparators(ucsfile)) diff --git a/openlp/plugins/alerts/lib/alertstab.py b/openlp/plugins/alerts/lib/alertstab.py index 15f27df6d..fd8722ca9 100644 --- a/openlp/plugins/alerts/lib/alertstab.py +++ b/openlp/plugins/alerts/lib/alertstab.py @@ -294,5 +294,5 @@ class AlertsTab(SettingsTab): font.setBold(True) font.setPointSize(self.font_size) self.FontPreview.setFont(font) - self.FontPreview.setStyleSheet(u'background-color: %s; color: %s' % \ + self.FontPreview.setStyleSheet(u'background-color: %s; color: %s' % (self.bg_color, self.font_color)) diff --git a/openlp/plugins/songusage/forms/songusagedetailform.py b/openlp/plugins/songusage/forms/songusagedetailform.py index fb1d1c73d..50ea87abe 100644 --- a/openlp/plugins/songusage/forms/songusagedetailform.py +++ b/openlp/plugins/songusage/forms/songusagedetailform.py @@ -71,12 +71,11 @@ class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog): def accept(self): log.debug(u'Detailed report generated') - filename = u'usage_detail_%s_%s.txt' % \ + filename = u'usage_detail_%s_%s.txt' % (self.FromDate.selectedDate().toString(u'ddMMyyyy'), self.ToDate.selectedDate().toString(u'ddMMyyyy')) - usage = self.parent.songusagemanager.get_all_songusage(\ - self.FromDate.selectedDate(), \ - self.ToDate.selectedDate()) + usage = self.parent.songusagemanager.get_all_songusage( + self.FromDate.selectedDate(), self.ToDate.selectedDate()) outname = os.path.join(unicode(self.FileLineEdit.text()), filename) file = None try: diff --git a/openlp/plugins/songusage/lib/manager.py b/openlp/plugins/songusage/lib/manager.py index b830fdafd..2339136d0 100644 --- a/openlp/plugins/songusage/lib/manager.py +++ b/openlp/plugins/songusage/lib/manager.py @@ -53,7 +53,7 @@ class SongUsageManager(object): db_type = unicode( settings.value(u'db type', QtCore.QVariant(u'sqlite')).toString()) if db_type == u'sqlite': - self.db_url = u'sqlite:///%s/songusage.sqlite' % \ + self.db_url = u'sqlite:///%s/songusage.sqlite' % AppLocation.get_section_data_path(u'songusage') else: self.db_url = u'%s://%s:%s@%s/%s' % (db_type, From d321249366af1d67fbc2bc9f1d05138b41dc1243 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Sat, 19 Jun 2010 20:38:17 +0200 Subject: [PATCH 05/15] Removed unnecessary comments. --- openlp/plugins/images/lib/mediaitem.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index 182dfca18..4c74c1b5b 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -61,9 +61,6 @@ class ImageMediaItem(MediaManagerItem): def retranslateUi(self): self.OnNewPrompt = translate('ImagePlugin.MediaItem', 'Select Image(s)') - #file_formats = u'' - #for file_format in QtGui.QImageReader.supportedImageFormats(): - # file_formats += u'*.%s ' % file_format file_formats = get_images_filter() self.OnNewFileMasks = u'%s;;%s (*.*) (*)' % (file_formats, unicode(translate('ImagePlugin.MediaItem', 'All Files'))) From ba4b7a9b7f71dc2099336b58254ed0e7a15f2b57 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Sat, 19 Jun 2010 20:42:49 +0200 Subject: [PATCH 06/15] Removed lowercasing of image formats. --- openlp/core/utils/__init__.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/openlp/core/utils/__init__.py b/openlp/core/utils/__init__.py index d7fab0968..78c16e26a 100644 --- a/openlp/core/utils/__init__.py +++ b/openlp/core/utils/__init__.py @@ -187,15 +187,10 @@ def get_images_filter(): global images_filter if not images_filter: log.debug(u'Generating images filter.') - old_formats = [str(fmt).lower() + formats = [unicode(fmt) for fmt in QtGui.QImageReader.supportedImageFormats()] - new_formats = [] - for fmt in old_formats: - if fmt not in new_formats: - new_formats.append(fmt) - new_formats.sort() - visible_formats = u'(*.%s)' % u'; *.'.join(new_formats) - actual_formats = u'(*.%s)' % u' *.'.join(new_formats) + visible_formats = u'(*.%s)' % u'; *.'.join(formats) + actual_formats = u'(*.%s)' % u' *.'.join(formats) images_filter = u'%s %s %s' % (translate('OpenLP', 'Image Files'), visible_formats, actual_formats) return images_filter From e3a07c1e57a0a2bdc2f181c12b9bcddfa7573133 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Sat, 19 Jun 2010 21:21:36 +0100 Subject: [PATCH 07/15] Cleanups --- openlp/core/ui/thememanager.py | 4 ++-- openlp/plugins/songusage/forms/songusagedetailform.py | 6 +++--- openlp/plugins/songusage/lib/manager.py | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index b645e541b..7849175a3 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -424,8 +424,8 @@ class ThemeManager(QtGui.QWidget): xml_data = xml_data.decode(u'utf-8') except UnicodeDecodeError: log.exception(u'Theme XML is not UTF-8 ' - 'encoded.') - break; + u'encoded.') + break if self.checkVersion1(xml_data): # upgrade theme xml filexml = self.migrateVersion122(xml_data) diff --git a/openlp/plugins/songusage/forms/songusagedetailform.py b/openlp/plugins/songusage/forms/songusagedetailform.py index 50ea87abe..80bb18d77 100644 --- a/openlp/plugins/songusage/forms/songusagedetailform.py +++ b/openlp/plugins/songusage/forms/songusagedetailform.py @@ -71,9 +71,9 @@ class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog): def accept(self): log.debug(u'Detailed report generated') - filename = u'usage_detail_%s_%s.txt' % - (self.FromDate.selectedDate().toString(u'ddMMyyyy'), - self.ToDate.selectedDate().toString(u'ddMMyyyy')) + filename = u'usage_detail_%s_%s.txt' % ( + self.FromDate.selectedDate().toString(u'ddMMyyyy'), + self.ToDate.selectedDate().toString(u'ddMMyyyy')) usage = self.parent.songusagemanager.get_all_songusage( self.FromDate.selectedDate(), self.ToDate.selectedDate()) outname = os.path.join(unicode(self.FileLineEdit.text()), filename) diff --git a/openlp/plugins/songusage/lib/manager.py b/openlp/plugins/songusage/lib/manager.py index 2339136d0..b830fdafd 100644 --- a/openlp/plugins/songusage/lib/manager.py +++ b/openlp/plugins/songusage/lib/manager.py @@ -53,7 +53,7 @@ class SongUsageManager(object): db_type = unicode( settings.value(u'db type', QtCore.QVariant(u'sqlite')).toString()) if db_type == u'sqlite': - self.db_url = u'sqlite:///%s/songusage.sqlite' % + self.db_url = u'sqlite:///%s/songusage.sqlite' % \ AppLocation.get_section_data_path(u'songusage') else: self.db_url = u'%s://%s:%s@%s/%s' % (db_type, From 735ae409960daa871971959c6aa830e891335c6b Mon Sep 17 00:00:00 2001 From: M2j Date: Sat, 19 Jun 2010 23:54:53 +0200 Subject: [PATCH 08/15] single character verse entries --- openlp/plugins/songs/forms/editsongform.py | 130 ++++++++++----------- openlp/plugins/songs/lib/mediaitem.py | 6 +- openlp/plugins/songs/lib/songimport.py | 22 +--- 3 files changed, 73 insertions(+), 85 deletions(-) diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index b7d6ffc7f..62fda42a7 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -30,6 +30,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import SongXMLBuilder, SongXMLParser, Receiver, translate from openlp.plugins.songs.forms import EditVerseForm +from openlp.plugins.songs.lib import VerseType from openlp.plugins.songs.lib.models import Song, Author, Topic, Book from editsongdialog import Ui_EditSongDialog @@ -90,16 +91,8 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): self.parent.parent.render_manager.theme_manager.onAddTheme) QtCore.QObject.connect(self.MaintenanceButton, QtCore.SIGNAL(u'clicked()'), self.onMaintenanceButtonClicked) - QtCore.QObject.connect(self.TitleEditItem, - QtCore.SIGNAL(u'editingFinished()'), self.onTitleEditItemLostFocus) - QtCore.QObject.connect(self.CCLNumberEdit, - QtCore.SIGNAL(u'lostFocus()'), self.onCCLNumberEditLostFocus) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'theme_update_list'), self.loadThemes) - QtCore.QObject.connect(self.CommentsEdit, - QtCore.SIGNAL(u'lostFocus()'), self.onCommentsEditLostFocus) - QtCore.QObject.connect(self.VerseOrderEdit, - QtCore.SIGNAL(u'lostFocus()'), self.onVerseOrderEditLostFocus) self.previewButton = QtGui.QPushButton() self.previewButton.setObjectName(u'previewButton') self.previewButton.setText( @@ -247,7 +240,8 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): self.VerseListWidget.setRowCount( self.VerseListWidget.rowCount() + 1) item = QtGui.QTableWidgetItem(verse) - variant = u'Verse:%s' % unicode(count + 1) + variant = u'%s:%s' % \ + (VerseType.to_string(VerseType.Verse), unicode(count + 1)) item.setData(QtCore.Qt.UserRole, QtCore.QVariant(variant)) self.VerseListWidget.setItem(count, 0, item) self.VerseListWidget.resizeRowsToContents() @@ -519,42 +513,63 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): if len(self.TitleEditItem.displayText()) == 0: self.SongTabWidget.setCurrentIndex(0) self.TitleEditItem.setFocus() - return False, translate(u'SongsPlugin.EditSongForm', + return u'failed', translate(u'SongsPlugin.EditSongForm', u'You need to enter a song title.') if self.VerseListWidget.rowCount() == 0: self.SongTabWidget.setCurrentIndex(0) self.VerseListWidget.setFocus() - return False, translate(u'SongsPlugin.EditSongForm', + return u'failed', translate('uSongsPlugin.EditSongForm', u'You need to enter some verses.') if self.AuthorsListView.count() == 0: self.SongTabWidget.setCurrentIndex(1) self.AuthorsListView.setFocus() - #split the verse list by space and mark lower case for testing - taglist = unicode(translate(u'SongsPlugin.EditSongForm', u' bitpeovc')) - for verse in unicode(self.VerseOrderEdit.text()).lower().split(u' '): - if len(verse) > 1: - if taglist.find(verse[0:1]) > -1 \ - and verse[1:].isdigit(): - pass + answer = QtGui.QMessageBox.warning(self, + translate(u'SongsPlugin.EditSongForm', u'Warning'), + translate('SongsPlugin.EditSongForm', + 'You have set no author.\n' + 'Do you want to add now a author?'), + QtGui.QMessageBox.Yes | QtGui.QMessageBox.No) + if answer == QtGui.QMessageBox.Yes: + return u'aborted', u'' + if self.song.verse_order: + order = [] + order_names = self.song.verse_order.split(u' ') + for item in order_names: + if len(item) == 1: + order.append(item.lower() + u'1') else: + order.append(item.lower()) + verses = [] + verse_names = [] + for index in range (0, self.VerseListWidget.rowCount()): + verse = self.VerseListWidget.item(index, 0) + verse = unicode(verse.data(QtCore.Qt.UserRole).toString()) + if verse not in verse_names: + verses.append( + re.sub(r'(.)[^:]*:(.*)', r'\1\2', verse.lower())) + verse_names.append(verse) + for count, item in enumerate(order): + if item not in verses: self.SongTabWidget.setCurrentIndex(0) self.VerseOrderEdit.setFocus() - return False, translate(u'SongsPlugin.EditSongForm', - u'Invalid verse entry, values must be I,B,T,P,E,O,V,C ' - u'followed by a number') - return True, u'' - - def onTitleEditItemLostFocus(self): - self.song.title = unicode(self.TitleEditItem.text()) - - def onVerseOrderEditLostFocus(self): - self.song.verse_order = unicode(self.VerseOrderEdit.text()) - - def onCommentsEditLostFocus(self): - self.song.comments = unicode(self.CommentsEdit.text()) - - def onCCLNumberEditLostFocus(self): - self.song.ccli_number = self.CCLNumberEdit.text() + return u'failed', unicode(translate( + 'SongsPlugin.EditSongForm', 'The verse order is ' + 'invalid. There is no verse corresponding to %s.')) % \ + order_names[count] + for count, verse in enumerate(verses): + if verse not in order: + self.SongTabWidget.setCurrentIndex(0) + self.VerseOrderEdit.setFocus() + answer = QtGui.QMessageBox.warning(self, + translate(u'SongsPlugin.EditSongForm', u'Warning'), + unicode(translate('SongsPlugin.EditSongForm', + '%s is not addressed in the verse order.\n' + 'Do you want to save anyhow?')) % \ + order_names[count].replace(u':', u' '), + QtGui.QMessageBox.Yes | QtGui.QMessageBox.No) + if answer == QtGui.QMessageBox.No: + return u'aborted', u'' + return u'passed', u'' def onCopyrightInsertButtonTriggered(self): text = self.CopyrightEditItem.text() @@ -590,19 +605,19 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): self.close() def saveSong(self): - valid, message = self._validate_song() - if not valid: - QtGui.QMessageBox.critical( - self, translate(u'SongsPlugin.EditSongForm', u'Error'), message, - QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok)) - return False self.song.title = unicode(self.TitleEditItem.text()) self.song.copyright = unicode(self.CopyrightEditItem.text()) - self.song.search_title = unicode(self.TitleEditItem.text()) + \ - u'@'+ unicode(self.AlternativeEdit.text()) + self.song.search_title = self.song.title + u'@' + \ + unicode(self.AlternativeEdit.text()) self.song.comments = unicode(self.CommentsEdit.toPlainText()) self.song.verse_order = unicode(self.VerseOrderEdit.text()) self.song.ccli_number = unicode(self.CCLNumberEdit.text()) + status, message = self._validate_song() + if status == u'failed': + QtGui.QMessageBox.critical(self, + translate(u'SongsPlugin.EditSongForm', u'Error'), message) + if status != u'passed': + return False self.processLyrics() self.processTitle() self.songmanager.save_song(self.song) @@ -614,24 +629,15 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): sxml = SongXMLBuilder() sxml.new_document() sxml.add_lyrics_to_song() - text = u' ' + text = u'' for i in range (0, self.VerseListWidget.rowCount()): item = self.VerseListWidget.item(i, 0) verseId = unicode(item.data(QtCore.Qt.UserRole).toString()) bits = verseId.split(u':') sxml.add_verse_to_lyrics(bits[0], bits[1], unicode(item.text())) - text = text + unicode(self.VerseListWidget.item(i, 0).text()) \ - + u' ' - text = text.replace(u'\'', u'') - text = text.replace(u',', u'') - text = text.replace(u';', u'') - text = text.replace(u':', u'') - text = text.replace(u'(', u'') - text = text.replace(u')', u'') - text = text.replace(u'{', u'') - text = text.replace(u'}', u'') - text = text.replace(u'?', u'') - self.song.search_lyrics = unicode(text) + text = text + re.sub(r'\W+', u' ', + unicode(self.VerseListWidget.item(i, 0).text())) + u' ' + self.song.search_lyrics = text self.song.lyrics = unicode(sxml.extract_xml(), u'utf-8') except: log.exception(u'Problem processing song Lyrics \n%s', @@ -639,16 +645,6 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): def processTitle(self): log.debug(u'processTitle') - self.song.search_title = unicode(self.song.search_title) - self.song.search_title = self.song.search_title.replace(u'\'', u'') - self.song.search_title = self.song.search_title.replace(u'\"', u'') - self.song.search_title = self.song.search_title.replace(u'`', u'') - self.song.search_title = self.song.search_title.replace(u',', u'') - self.song.search_title = self.song.search_title.replace(u';', u'') - self.song.search_title = self.song.search_title.replace(u':', u'') - self.song.search_title = self.song.search_title.replace(u'(', u'') - self.song.search_title = self.song.search_title.replace(u')', u'') - self.song.search_title = self.song.search_title.replace(u'{', u'') - self.song.search_title = self.song.search_title.replace(u'}', u'') - self.song.search_title = self.song.search_title.replace(u'?', u'') + self.song.search_title = \ + re.sub(r'[\'"`,;:(){}?]+', u'', unicode(self.song.search_title)) diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index ecf0684dd..c60a67a42 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -23,6 +23,7 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### +import re import logging from PyQt4 import QtCore, QtGui @@ -160,6 +161,7 @@ class SongMediaItem(MediaManagerItem): def onSearchTextButtonClick(self): search_keywords = unicode(self.SearchTextEdit.displayText()) + search_keywords = re.sub(r'\W+', u' ', search_keywords) search_results = [] search_type = self.SearchTypeComboBox.currentIndex() if search_type == 0: @@ -350,8 +352,8 @@ class SongMediaItem(MediaManagerItem): if len(order) == 0: break for verse in verseList: - if verse[0][u'label'] == order[1:] and \ - verse[0][u'type'][0] == order[0]: + if verse[0][u'type'][0] == order[0] and \ + (verse[0][u'label'] == order[1:] or not order[1:]): verseTag = u'%s:%s' % \ (verse[0][u'type'], verse[0][u'label']) service_item.add_from_text( diff --git a/openlp/plugins/songs/lib/songimport.py b/openlp/plugins/songs/lib/songimport.py index 9fd7194e2..479828ddd 100644 --- a/openlp/plugins/songs/lib/songimport.py +++ b/openlp/plugins/songs/lib/songimport.py @@ -24,6 +24,7 @@ ############################################################################### import string +import re from PyQt4 import QtGui @@ -89,9 +90,6 @@ class SongImport(object): Get rid of some dodgy unicode and formatting characters we're not interested in. Some can be converted to ascii. """ - text = text.replace(u'\t', u' ') - text = text.replace(u'\r\n', u'\n') - text = text.replace(u'\r', u'\n') text = text.replace(u'\u2018', u'\'') text = text.replace(u'\u2019', u'\'') text = text.replace(u'\u201c', u'"') @@ -100,15 +98,9 @@ class SongImport(object): text = text.replace(u'\u2013', u'-') text = text.replace(u'\u2014', u'-') # Remove surplus blank lines, spaces, trailing/leading spaces - while text.find(u' ') >= 0: - text = text.replace(u' ', u' ') - text = text.replace(u'\n ', u'\n') - text = text.replace(u' \n', u'\n') - text = text.replace(u'\n\n\n\n\n', u'\f') - text = text.replace(u'\f ', u'\f') - text = text.replace(u' \f', u'\f') - while text.find(u'\f\f') >= 0: - text = text.replace(u'\f\f', u'\f') + text = re.sub(r'[ \t\v]+', u' ', text) + text = re.sub(r' ?(\r\n?|\n) ?', u'\n', text) + text = re.sub(r' ?(\n{5}|\f)+ ?', u'\f', text) return text def process_song_text(self, text): @@ -264,11 +256,9 @@ class SongImport(object): def remove_punctuation(self, text): """ - Remove punctuation from the string for searchable fields + Extracts alphanumeric words for searchable fields """ - for character in string.punctuation: - text = text.replace(character, u'') - return text + return re.sub(r'\W+', u' ', text) def finish(self): """ From 3061c319d59d340e79fd21602ae85ac41b058e9c Mon Sep 17 00:00:00 2001 From: M2j Date: Sun, 20 Jun 2010 01:16:15 +0200 Subject: [PATCH 09/15] Automatic verse order entry expanding deleted a misplaced QSpacerItem --- openlp/plugins/songs/forms/editsongdialog.py | 3 --- openlp/plugins/songs/forms/editsongform.py | 9 +++++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/openlp/plugins/songs/forms/editsongdialog.py b/openlp/plugins/songs/forms/editsongdialog.py index 3bec03a09..8d145d8bf 100644 --- a/openlp/plugins/songs/forms/editsongdialog.py +++ b/openlp/plugins/songs/forms/editsongdialog.py @@ -384,9 +384,6 @@ class Ui_EditSongDialog(object): self.CommentsLayout.addWidget(self.CommentsEdit) self.ThemeCopyCommentsLayout.addWidget(self.CommentsGroupBox) self.ThemeTabLayout.addWidget(self.ThemeCopyCommentsWidget) - spacerItem5 = QtGui.QSpacerItem(20, 40, - QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) - self.ThemeTabLayout.addItem(spacerItem5) self.SongTabWidget.addTab(self.ThemeTab, u'') self.verticalLayout.addWidget(self.SongTabWidget) self.ButtonBox = QtGui.QDialogButtonBox(EditSongDialog) diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 62fda42a7..f2ee5979f 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -630,6 +630,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): sxml.new_document() sxml.add_lyrics_to_song() text = u'' + multiple = [] for i in range (0, self.VerseListWidget.rowCount()): item = self.VerseListWidget.item(i, 0) verseId = unicode(item.data(QtCore.Qt.UserRole).toString()) @@ -637,8 +638,16 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): sxml.add_verse_to_lyrics(bits[0], bits[1], unicode(item.text())) text = text + re.sub(r'\W+', u' ', unicode(self.VerseListWidget.item(i, 0).text())) + u' ' + if (bits[1] > u'1') and (bits[0][0] not in multiple): + multiple.append(bits[0][0]) + print bits[0][0] self.song.search_lyrics = text self.song.lyrics = unicode(sxml.extract_xml(), u'utf-8') + for verse in multiple: + self.song.verse_order = self.song.verse_order.replace( + verse.upper() + u' ', verse.upper() + u'1 ') + self.song.verse_order = self.song.verse_order.replace( + verse.lower() + u' ', verse.lower() + u'1 ') except: log.exception(u'Problem processing song Lyrics \n%s', sxml.dump_xml()) From 8e25f3850e74aad61b62f9932655980cc28363ec Mon Sep 17 00:00:00 2001 From: M2j Date: Sun, 20 Jun 2010 01:58:42 +0200 Subject: [PATCH 10/15] corrected one string --- openlp/plugins/songs/forms/editsongform.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 797c98d65..9bfed4a86 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -555,10 +555,13 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): if item not in verses: self.SongTabWidget.setCurrentIndex(0) self.VerseOrderEdit.setFocus() + valid = verses.pop(0) + for verse in verses: + valid = valid + u', ' + verse return u'failed', unicode(translate( 'SongsPlugin.EditSongForm', 'The verse order is ' - 'invalid. There is no verse corresponding to %s.')) % \ - order_names[count] + 'invalid. There is no verse corresponding to %s. ' + 'Valid entries are %s.')) % (order_names[count], valid) for count, verse in enumerate(verses): if verse not in order: self.SongTabWidget.setCurrentIndex(0) From 888bc50622ac535218c06805d14607dfd13604a3 Mon Sep 17 00:00:00 2001 From: M2j Date: Sun, 20 Jun 2010 08:48:32 +0200 Subject: [PATCH 11/15] fixes --- openlp/plugins/songs/forms/editsongform.py | 57 +++++++++++----------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 9bfed4a86..e3bec84c2 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -258,7 +258,6 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): topic_name = QtGui.QListWidgetItem(unicode(topic.name)) topic_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(topic.id)) self.TopicsListView.addItem(topic_name) - self._validate_song() self.TitleEditItem.setFocus(QtCore.Qt.OtherFocusReason) #if not preview hide the preview button self.previewButton.setVisible(False) @@ -516,13 +515,19 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): if len(self.TitleEditItem.displayText()) == 0: self.SongTabWidget.setCurrentIndex(0) self.TitleEditItem.setFocus() - return u'failed', translate(u'SongsPlugin.EditSongForm', - u'You need to enter a song title.') + QtGui.QMessageBox.critical(self, + translate(u'SongsPlugin.EditSongForm', u'Error'), + translate(u'SongsPlugin.EditSongForm', + u'You need to enter a song title.')) + return False if self.VerseListWidget.rowCount() == 0: self.SongTabWidget.setCurrentIndex(0) self.VerseListWidget.setFocus() - return u'failed', translate('uSongsPlugin.EditSongForm', - u'You need to enter some verses.') + QtGui.QMessageBox.critical(self, + translate(u'SongsPlugin.EditSongForm', u'Error'), + translate('uSongsPlugin.EditSongForm', + u'You need to enter some verses.')) + return False if self.AuthorsListView.count() == 0: self.SongTabWidget.setCurrentIndex(1) self.AuthorsListView.setFocus() @@ -533,7 +538,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): 'Do you want to add now a author?'), QtGui.QMessageBox.Yes | QtGui.QMessageBox.No) if answer == QtGui.QMessageBox.Yes: - return u'aborted', u'' + return False if self.song.verse_order: order = [] order_names = self.song.verse_order.split(u' ') @@ -558,10 +563,13 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): valid = verses.pop(0) for verse in verses: valid = valid + u', ' + verse - return u'failed', unicode(translate( - 'SongsPlugin.EditSongForm', 'The verse order is ' - 'invalid. There is no verse corresponding to %s. ' - 'Valid entries are %s.')) % (order_names[count], valid) + QtGui.QMessageBox.critical(self, + translate(u'SongsPlugin.EditSongForm', u'Error'), + unicode(translate('SongsPlugin.EditSongForm', + 'The verse order is invalid. There is no verse ' + 'corresponding to %s. Valid entries are %s.')) % \ + (order_names[count], valid)) + return False for count, verse in enumerate(verses): if verse not in order: self.SongTabWidget.setCurrentIndex(0) @@ -571,11 +579,11 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): unicode(translate('SongsPlugin.EditSongForm', '%s is not addressed in the verse order.\n' 'Do you want to save anyhow?')) % \ - order_names[count].replace(u':', u' '), + verse_names[count].replace(u':', u' '), QtGui.QMessageBox.Yes | QtGui.QMessageBox.No) if answer == QtGui.QMessageBox.No: - return u'aborted', u'' - return u'passed', u'' + return False + return True def onCopyrightInsertButtonTriggered(self): text = self.CopyrightEditItem.text() @@ -618,16 +626,12 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): self.song.comments = unicode(self.CommentsEdit.toPlainText()) self.song.verse_order = unicode(self.VerseOrderEdit.text()) self.song.ccli_number = unicode(self.CCLNumberEdit.text()) - status, message = self._validate_song() - if status == u'failed': - QtGui.QMessageBox.critical(self, - translate(u'SongsPlugin.EditSongForm', u'Error'), message) - if status != u'passed': - return False - self.processLyrics() - self.processTitle() - self.songmanager.save_song(self.song) - return True + if self._validate_song(): + self.processLyrics() + self.processTitle() + self.songmanager.save_song(self.song) + return True + return False def processLyrics(self): log.debug(u'processLyrics') @@ -646,14 +650,11 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): unicode(self.VerseListWidget.item(i, 0).text())) + u' ' if (bits[1] > u'1') and (bits[0][0] not in multiple): multiple.append(bits[0][0]) - print bits[0][0] self.song.search_lyrics = text self.song.lyrics = unicode(sxml.extract_xml(), u'utf-8') for verse in multiple: - self.song.verse_order = self.song.verse_order.replace( - verse.upper() + u' ', verse.upper() + u'1 ') - self.song.verse_order = self.song.verse_order.replace( - verse.lower() + u' ', verse.lower() + u'1 ') + self.song.verse_order = re.sub(u'([' + verse.upper() + + verse.lower() + u'])(\W|$)', r'\g<1>1\2', self.song.verse_order) except: log.exception(u'Problem processing song Lyrics \n%s', sxml.dump_xml()) From 28bb5e519d0cefd7ddf6b19749faf647166c78cc Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Sun, 20 Jun 2010 13:09:15 +0200 Subject: [PATCH 12/15] Fix bug #596506 --- openlp/core/lib/serviceitem.py | 15 ++++++++++----- openlp/core/ui/slidecontroller.py | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/openlp/core/lib/serviceitem.py b/openlp/core/lib/serviceitem.py index b3464888e..d9c434987 100644 --- a/openlp/core/lib/serviceitem.py +++ b/openlp/core/lib/serviceitem.py @@ -90,7 +90,7 @@ class ServiceItem(object): self.from_plugin = False self.capabilities = [] self.is_valid = True - self.cache = [] + self.cache = {} self.icon = None def add_capability(self, capability): @@ -129,7 +129,7 @@ class ServiceItem(object): """ log.debug(u'Render called') self._display_frames = [] - self.cache = [] + self.clear_cache() if self.service_item_type == ServiceItemType.Text: log.debug(u'Formatting slides') if self.theme is None: @@ -149,7 +149,8 @@ class ServiceItem(object): self._display_frames.append({u'title': title, u'text': lines.rstrip(), u'verseTag': slide[u'verseTag'] }) - self.cache.insert(len(self._display_frames), None) + if len(self._display_frames) in self.cache.keys(): + del self.cache[len(self._display_frames)] log.log(15, u'Formatting took %4s' % (time.time() - before)) elif self.service_item_type == ServiceItemType.Image: for slide in self._raw_frames: @@ -172,8 +173,7 @@ class ServiceItem(object): else: self.render_manager.set_override_theme(self.theme) format = self._display_frames[row][u'text'].split(u'\n') - #if screen blank then do not display footer - if len(self.cache) > 0 and self.cache[row] is not None: + if self.cache.get(row): frame = self.cache[row] else: if format[0]: @@ -385,3 +385,8 @@ class ServiceItem(object): """ return self._raw_frames[row][u'path'] + def clear_cache(self): + """ + Clear's the service item's cache. + """ + self.cache = {} diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 10cd3cff0..e289e430d 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -537,7 +537,7 @@ class SlideController(QtGui.QWidget): before = time.time() #Clear the old serviceItem cache to release memory if self.serviceItem and self.serviceItem is not serviceItem: - self.serviceItem.cache = [] + self.serviceItem.clear_cache() self.serviceItem = serviceItem self.PreviewListWidget.clear() self.PreviewListWidget.setRowCount(0) From 054ec36e4a556cdff04fb3ff6773756bdf43c80f Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Sun, 20 Jun 2010 13:43:16 +0200 Subject: [PATCH 13/15] Fixed bug #596505 --- openlp/core/ui/servicemanager.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index cccd34195..93004cc64 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -662,8 +662,7 @@ class ServiceManager(QtGui.QWidget): name = filename.split(os.path.sep) if filename: SettingsManager.set_last_dir( - self.parent.serviceSettingsSection, - os.path.split(filename)[0]) + self.parent.serviceSettingsSection, name[0]) zip = None file_to = None try: @@ -697,7 +696,7 @@ class ServiceManager(QtGui.QWidget): self.onNewService() for item in items: serviceitem = ServiceItem() - serviceitem.RenderManager = self.parent.RenderManager + serviceitem.render_manager = self.parent.RenderManager serviceitem.set_from_service(item, self.servicePath) self.validateItem(serviceitem) self.addServiceItem(serviceitem) From ce79049868897169d123ce9e8040af51672b13a6 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Sun, 20 Jun 2010 14:12:49 +0200 Subject: [PATCH 14/15] Reverted a change that could introduce a bug! --- openlp/core/ui/servicemanager.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 93004cc64..84c4f6d0b 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -661,8 +661,8 @@ class ServiceManager(QtGui.QWidget): filename = unicode(filename) name = filename.split(os.path.sep) if filename: - SettingsManager.set_last_dir( - self.parent.serviceSettingsSection, name[0]) + SettingsManager.set_last_dir(self.parent.serviceSettingsSection, + os.path.split(filename)[0]) zip = None file_to = None try: From e7b4e1640579ac5bea654391e3eb4542b2e2cbb3 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Sun, 20 Jun 2010 14:03:06 +0100 Subject: [PATCH 15/15] Couple o' Cleanups --- openlp/plugins/songs/forms/editsongform.py | 5 +++-- openlp/plugins/songs/lib/songimport.py | 1 - 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index e3bec84c2..063fdd71f 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -649,12 +649,13 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): text = text + re.sub(r'\W+', u' ', unicode(self.VerseListWidget.item(i, 0).text())) + u' ' if (bits[1] > u'1') and (bits[0][0] not in multiple): - multiple.append(bits[0][0]) + multiple.append(bits[0][0]) self.song.search_lyrics = text self.song.lyrics = unicode(sxml.extract_xml(), u'utf-8') for verse in multiple: self.song.verse_order = re.sub(u'([' + verse.upper() + - verse.lower() + u'])(\W|$)', r'\g<1>1\2', self.song.verse_order) + verse.lower() + u'])(\W|$)', r'\g<1>1\2', + self.song.verse_order) except: log.exception(u'Problem processing song Lyrics \n%s', sxml.dump_xml()) diff --git a/openlp/plugins/songs/lib/songimport.py b/openlp/plugins/songs/lib/songimport.py index 479828ddd..dbc9fa08d 100644 --- a/openlp/plugins/songs/lib/songimport.py +++ b/openlp/plugins/songs/lib/songimport.py @@ -23,7 +23,6 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### -import string import re from PyQt4 import QtGui