From 46f9153ea8e49612892d1f4db19c442670b759c7 Mon Sep 17 00:00:00 2001 From: Stevan Pettit Date: Sun, 29 May 2011 09:12:11 -0400 Subject: [PATCH 01/52] Remove some whitespace in editsongform.py --- openlp/plugins/songs/forms/editsongform.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index f30c618b4..d30a1be10 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -757,7 +757,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): self.manager.save_object(self.song) if self.parent.new: self.parent.auto_select_id = self.song.id - + def _processLyrics(self): """ Process the lyric data entered by the user into the OpenLP XML format. From fe35a5775c3036d6bf41a474e1f2eae248fa428d Mon Sep 17 00:00:00 2001 From: Stevan Pettit Date: Sun, 29 May 2011 19:52:36 -0400 Subject: [PATCH 02/52] bug-789102 - Removed code that auto-selects new items. --- openlp/plugins/custom/forms/editcustomform.py | 2 -- openlp/plugins/custom/lib/mediaitem.py | 3 --- openlp/plugins/songs/forms/editsongform.py | 2 -- openlp/plugins/songs/lib/mediaitem.py | 3 --- 4 files changed, 10 deletions(-) diff --git a/openlp/plugins/custom/forms/editcustomform.py b/openlp/plugins/custom/forms/editcustomform.py index b74954fe6..eb4a13fda 100644 --- a/openlp/plugins/custom/forms/editcustomform.py +++ b/openlp/plugins/custom/forms/editcustomform.py @@ -137,8 +137,6 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): self.customSlide.credits = unicode(self.creditEdit.text()) self.customSlide.theme_name = unicode(self.themeComboBox.currentText()) success = self.manager.save_object(self.customSlide) - if self.parent.new: - self.parent.auto_select_id = self.customSlide.id return success def onUpButtonClicked(self): diff --git a/openlp/plugins/custom/lib/mediaitem.py b/openlp/plugins/custom/lib/mediaitem.py index 718c78d75..d0a3de061 100644 --- a/openlp/plugins/custom/lib/mediaitem.py +++ b/openlp/plugins/custom/lib/mediaitem.py @@ -66,7 +66,6 @@ class CustomMediaItem(MediaManagerItem): # which Custom is required. self.remoteCustom = -1 self.manager = parent.manager - self.new = False def addEndHeaderBar(self): self.addToolbarSeparator() @@ -157,11 +156,9 @@ class CustomMediaItem(MediaManagerItem): self.auto_select_id = -1 def onNewClick(self): - self.new = True self.edit_custom_form.loadCustom(0) self.edit_custom_form.exec_() self.initialise() - self.new = False def onRemoteEditClear(self): self.remoteTriggered = None diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index d30a1be10..e6643568c 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -755,8 +755,6 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): self.song.topics.append(self.manager.get_object(Topic, topicId)) clean_song(self.manager, self.song) self.manager.save_object(self.song) - if self.parent.new: - self.parent.auto_select_id = self.song.id def _processLyrics(self): """ diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 5454d5401..3d9a9ef76 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -74,7 +74,6 @@ class SongMediaItem(MediaManagerItem): self.editItem = None self.quickPreviewAllowed = True self.hasSearch = True - self.new = False def addEndHeaderBar(self): self.addToolbarSeparator() @@ -297,10 +296,8 @@ class SongMediaItem(MediaManagerItem): def onNewClick(self): log.debug(u'onNewClick') - self.new = True self.edit_song_form.newSong() self.edit_song_form.exec_() - self.new = False def onSongMaintenanceClick(self): self.song_maintenance_form.exec_() From 8a8580f359b982dae79344998e4e9776af9ff054 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Mon, 30 May 2011 22:58:30 +0200 Subject: [PATCH 03/52] Fix unicode bookname handling on Biblegateway --- openlp/plugins/bibles/lib/http.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index 5fc742cce..891fd4a1b 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -72,9 +72,8 @@ class BGExtract(object): log.debug(u'BGExtract.get_bible_chapter("%s", "%s", "%s")', version, bookname, chapter) urlbookname = urllib.quote(bookname.encode("utf-8")) - url_params = urllib.urlencode( - {u'search': u'%s %s' % (urlbookname, chapter), - u'version': u'%s' % version}) + url_params = u'search=%s+%s&version=%s' % (urlbookname, chapter, + version) cleaner = [(re.compile(' |
|\'\+\''), lambda match: '')] soup = get_soup_for_bible_ref( u'http://www.biblegateway.com/passage/?%s' % url_params, @@ -97,7 +96,7 @@ class BGExtract(object): verse_list = {} # Cater for inconsistent mark up in the first verse of a chapter. first_verse = verses.find(u'versenum') - if first_verse: + if first_verse and 0 in first_verse.contents: verse_list[1] = unicode(first_verse.contents[0]) for verse in verses(u'sup', u'versenum'): raw_verse_num = verse.next From 729fe2cfa3371c59e4a3584ee5391079b217c1a9 Mon Sep 17 00:00:00 2001 From: Stevan Pettit Date: Mon, 30 May 2011 23:52:17 -0400 Subject: [PATCH 04/52] bug-789102, moved mediaitem list updates out of editforms into mediaitems --- openlp/core/lib/mediamanageritem.py | 3 ++- openlp/plugins/custom/forms/editcustomform.py | 1 - openlp/plugins/custom/lib/mediaitem.py | 6 +++++- openlp/plugins/songs/forms/editsongform.py | 1 - openlp/plugins/songs/lib/mediaitem.py | 10 ++++++++++ 5 files changed, 17 insertions(+), 4 deletions(-) diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 602b3c55b..223dd9385 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -453,7 +453,8 @@ class MediaManagerItem(QtGui.QWidget): """ if QtCore.QSettings().value(u'advanced/single click preview', QtCore.QVariant(False)).toBool() and self.quickPreviewAllowed \ - and self.listView.selectedIndexes(): + and self.listView.selectedIndexes() \ + and self.auto_select_id == -1: self.onPreviewClick(True) def onPreviewClick(self, keepFocus=False): diff --git a/openlp/plugins/custom/forms/editcustomform.py b/openlp/plugins/custom/forms/editcustomform.py index 5c9c035b7..4a7585f11 100644 --- a/openlp/plugins/custom/forms/editcustomform.py +++ b/openlp/plugins/custom/forms/editcustomform.py @@ -115,7 +115,6 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): def accept(self): log.debug(u'accept') if self.saveCustom(): - Receiver.send_message(u'custom_load_list') QtGui.QDialog.accept(self) def saveCustom(self): diff --git a/openlp/plugins/custom/lib/mediaitem.py b/openlp/plugins/custom/lib/mediaitem.py index 0398d8fa2..9113352e7 100644 --- a/openlp/plugins/custom/lib/mediaitem.py +++ b/openlp/plugins/custom/lib/mediaitem.py @@ -131,7 +131,7 @@ class CustomMediaItem(MediaManagerItem): QtCore.QVariant(CustomSearch.Titles)).toInt()[0]) # Called to redisplay the custom list screen edith from a search # or from the exit of the Custom edit dialog. If remote editing is - # active trigger it and clean up so it will not update again. + # active trigger it and clean up so it will not update again. if self.remoteTriggered == u'L': self.onAddClick() if self.remoteTriggered == u'P': @@ -160,6 +160,7 @@ class CustomMediaItem(MediaManagerItem): self.edit_custom_form.loadCustom(0) self.edit_custom_form.exec_() self.initialise() + self.onSelectionChange() def onRemoteEditClear(self): self.remoteTriggered = None @@ -179,6 +180,8 @@ class CustomMediaItem(MediaManagerItem): self.remoteTriggered = remote_type self.edit_custom_form.loadCustom(custom_id, (remote_type == u'P')) self.edit_custom_form.exec_() + self.auto_select_id = -1 + self.initialise() def onEditClick(self): """ @@ -189,6 +192,7 @@ class CustomMediaItem(MediaManagerItem): item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0] self.edit_custom_form.loadCustom(item_id, False) self.edit_custom_form.exec_() + self.auto_select_id = -1 self.initialise() def onDeleteClick(self): diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index c8c351509..a07ceb6c9 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -696,7 +696,6 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): self.clearCaches() if self._validate_song(): self.saveSong() - Receiver.send_message(u'songs_load_list') self.song = None QtGui.QDialog.accept(self) diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 02108a846..ca93ed896 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -214,6 +214,7 @@ class SongMediaItem(MediaManagerItem): Handle the exit from the edit dialog and trigger remote updates of songs """ + print "reload list" log.debug(u'onSongListLoad - start') # Called to redisplay the song list screen edit from a search # or from the exit of the Song edit dialog. If remote editing is active @@ -248,6 +249,7 @@ class SongMediaItem(MediaManagerItem): self.listView.addItem(song_name) # Auto-select the item if name has been set if song.id == self.auto_select_id: + print "have match" , song.id self.listView.setCurrentItem(song_name) self.auto_select_id = -1 @@ -297,8 +299,12 @@ class SongMediaItem(MediaManagerItem): def onNewClick(self): log.debug(u'onNewClick') + print "New" self.edit_song_form.newSong() self.edit_song_form.exec_() + print "back from edit" + self.onSongListLoad() + self.onSelectionChange() def onSongMaintenanceClick(self): self.song_maintenance_form.exec_() @@ -323,6 +329,8 @@ class SongMediaItem(MediaManagerItem): self.remoteTriggered = remote_type self.edit_song_form.loadSong(song_id, (remote_type == u'P')) self.edit_song_form.exec_() + self.auto_select_id = -1 + self.onSongListLoad() def onEditClick(self): """ @@ -334,6 +342,8 @@ class SongMediaItem(MediaManagerItem): item_id = (self.editItem.data(QtCore.Qt.UserRole)).toInt()[0] self.edit_song_form.loadSong(item_id, False) self.edit_song_form.exec_() + self.auto_select_id = -1 + self.onSongListLoad() self.editItem = None def onDeleteClick(self): From efc678d51883d99f2292637312964be04fc12246 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Tue, 31 May 2011 09:26:44 +0200 Subject: [PATCH 05/52] bug fix --- openlp/plugins/bibles/lib/http.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index 891fd4a1b..49728637d 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -96,7 +96,7 @@ class BGExtract(object): verse_list = {} # Cater for inconsistent mark up in the first verse of a chapter. first_verse = verses.find(u'versenum') - if first_verse and 0 in first_verse.contents: + if first_verse and len(first_verse.contents): verse_list[1] = unicode(first_verse.contents[0]) for verse in verses(u'sup', u'versenum'): raw_verse_num = verse.next From 63102855e8392fecfdca5c7aa72bccaf87945145 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Tue, 31 May 2011 09:31:38 +0200 Subject: [PATCH 06/52] remove unnecessary whitespace --- openlp/plugins/bibles/lib/http.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index 49728637d..edb111d93 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -99,7 +99,7 @@ class BGExtract(object): if first_verse and len(first_verse.contents): verse_list[1] = unicode(first_verse.contents[0]) for verse in verses(u'sup', u'versenum'): - raw_verse_num = verse.next + raw_verse_num = verse.next clean_verse_num = 0 # Not all verses exist in all translations and may or may not be # represented by a verse number. If they are not fine, if they are From 227cd75b5cbc8b8787b459f99cf9a8a0d17b6b8c Mon Sep 17 00:00:00 2001 From: Stevan Pettit Date: Tue, 31 May 2011 10:02:44 -0400 Subject: [PATCH 07/52] Cleanup whitespace, remove debug prints --- openlp/plugins/custom/lib/mediaitem.py | 2 +- openlp/plugins/songs/lib/mediaitem.py | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/openlp/plugins/custom/lib/mediaitem.py b/openlp/plugins/custom/lib/mediaitem.py index 9113352e7..387221610 100644 --- a/openlp/plugins/custom/lib/mediaitem.py +++ b/openlp/plugins/custom/lib/mediaitem.py @@ -131,7 +131,7 @@ class CustomMediaItem(MediaManagerItem): QtCore.QVariant(CustomSearch.Titles)).toInt()[0]) # Called to redisplay the custom list screen edith from a search # or from the exit of the Custom edit dialog. If remote editing is - # active trigger it and clean up so it will not update again. + # active trigger it and clean up so it will not update again. if self.remoteTriggered == u'L': self.onAddClick() if self.remoteTriggered == u'P': diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index c7f37946e..df8fef820 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -215,7 +215,6 @@ class SongMediaItem(MediaManagerItem): Handle the exit from the edit dialog and trigger remote updates of songs """ - print "reload list" log.debug(u'onSongListLoad - start') # Called to redisplay the song list screen edit from a search # or from the exit of the Song edit dialog. If remote editing is active @@ -250,7 +249,6 @@ class SongMediaItem(MediaManagerItem): self.listView.addItem(song_name) # Auto-select the item if name has been set if song.id == self.auto_select_id: - print "have match" , song.id self.listView.setCurrentItem(song_name) self.auto_select_id = -1 @@ -300,10 +298,8 @@ class SongMediaItem(MediaManagerItem): def onNewClick(self): log.debug(u'onNewClick') - print "New" self.edit_song_form.newSong() self.edit_song_form.exec_() - print "back from edit" self.onSongListLoad() self.onSelectionChange() From 4ce960d0cc433a3c1165423313e56e3d546a3d64 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 1 Jun 2011 07:42:56 +0200 Subject: [PATCH 08/52] do not override the file class --- openlp/core/ui/exceptionform.py | 18 +++++++++--------- openlp/plugins/songs/forms/songimportform.py | 6 +++--- openlp/plugins/songs/lib/easislidesimport.py | 4 ++-- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/openlp/core/ui/exceptionform.py b/openlp/core/ui/exceptionform.py index ab61ef24d..2521ebaba 100644 --- a/openlp/core/ui/exceptionform.py +++ b/openlp/core/ui/exceptionform.py @@ -106,7 +106,7 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog): """ Saving exception log and system informations to a file. """ - report = unicode(translate('OpenLP.ExceptionForm', + report_text = unicode(translate('OpenLP.ExceptionForm', '**OpenLP Bug Report**\n' 'Version: %s\n\n' '--- Details of the Exception. ---\n\n%s\n\n ' @@ -122,21 +122,21 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog): filename = unicode(QtCore.QDir.toNativeSeparators(filename)) SettingsManager.set_last_dir(self.settingsSection, os.path.dirname( filename)) - report = report % self._createReport() + report_text = report_text % self._createReport() try: - file = open(filename, u'w') + report_file = open(filename, u'w') try: - file.write(report) + report_file.write(report_text) except UnicodeError: - file.close() - file = open(filename, u'wb') - file.write(report.encode(u'utf-8')) + report_file.close() + report_file = open(filename, u'wb') + report_file.write(report_text.encode(u'utf-8')) finally: - file.close() + report_file.close() except IOError: log.exception(u'Failed to write crash report') finally: - file.close() + report_file.close() def onSendReportButtonPressed(self): """ diff --git a/openlp/plugins/songs/forms/songimportform.py b/openlp/plugins/songs/forms/songimportform.py index 61e9fc7c8..7ef494cf5 100644 --- a/openlp/plugins/songs/forms/songimportform.py +++ b/openlp/plugins/songs/forms/songimportform.py @@ -772,9 +772,9 @@ class SongImportForm(OpenLPWizard): SettingsManager.get_last_dir(self.plugin.settingsSection, 1)) if not filename: return - file = codecs.open(filename, u'w', u'utf-8') - file.write(self.errorReportTextEdit.toPlainText()) - file.close() + report_file = codecs.open(filename, u'w', u'utf-8') + report_file.write(self.errorReportTextEdit.toPlainText()) + report_file.close() def addFileSelectItem(self, prefix, obj_prefix=None, can_disable=False, single_select=False): diff --git a/openlp/plugins/songs/lib/easislidesimport.py b/openlp/plugins/songs/lib/easislidesimport.py index 7a370534d..373eb7c42 100644 --- a/openlp/plugins/songs/lib/easislidesimport.py +++ b/openlp/plugins/songs/lib/easislidesimport.py @@ -61,8 +61,8 @@ class EasiSlidesImport(SongImport): """ log.info(u'Importing EasiSlides XML file %s', self.import_source) parser = etree.XMLParser(remove_blank_text=True) - file = etree.parse(self.import_source, parser) - xml = unicode(etree.tostring(file)) + parsed_file = etree.parse(self.import_source, parser) + xml = unicode(etree.tostring(parsed_file)) song_xml = objectify.fromstring(xml) self.import_wizard.progressBar.setMaximum(len(song_xml.Item)) for song in song_xml.Item: From 9a81e8dbe60dc5d43c00a26c430f28706018e584 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 1 Jun 2011 07:46:34 +0200 Subject: [PATCH 09/52] added blank line --- openlp/plugins/songs/lib/importer.py | 1 + 1 file changed, 1 insertion(+) diff --git a/openlp/plugins/songs/lib/importer.py b/openlp/plugins/songs/lib/importer.py index ab92033c4..8fbbdbeaf 100644 --- a/openlp/plugins/songs/lib/importer.py +++ b/openlp/plugins/songs/lib/importer.py @@ -28,6 +28,7 @@ The :mod:`importer` modules provides the general song import functionality. """ import logging + from opensongimport import OpenSongImport from easislidesimport import EasiSlidesImport from olpimport import OpenLPSongImport From d7ebb73fd1a2a6d12395aaa614ee3f08cb11d30d Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 1 Jun 2011 08:24:35 +0200 Subject: [PATCH 10/52] - do not show an error message when the directory does not exist, instead create items - trivial clean ups --- .../plugins/bibles/forms/bibleupgradeform.py | 43 +++++++++---------- openlp/plugins/bibles/forms/booknameform.py | 8 ++-- 2 files changed, 24 insertions(+), 27 deletions(-) diff --git a/openlp/plugins/bibles/forms/bibleupgradeform.py b/openlp/plugins/bibles/forms/bibleupgradeform.py index 0fdcdfd11..9ba7e36d3 100644 --- a/openlp/plugins/bibles/forms/bibleupgradeform.py +++ b/openlp/plugins/bibles/forms/bibleupgradeform.py @@ -33,7 +33,8 @@ import shutil from PyQt4 import QtCore, QtGui -from openlp.core.lib import Receiver, SettingsManager, translate +from openlp.core.lib import Receiver, SettingsManager, translate, \ + check_directory_exists from openlp.core.lib.db import delete_database from openlp.core.lib.ui import UiStrings, critical_error_message_box from openlp.core.ui.wizard import OpenLPWizard, WizardStrings @@ -94,7 +95,7 @@ class BibleUpgradeForm(OpenLPWizard): def onCheckBoxIndexChanged(self, index): """ - Show/ Hide warnings if CheckBox state has changed + Show/Hide warnings if CheckBox state has changed """ for number, filename in enumerate(self.files): if not self.checkBox[number].checkState() == QtCore.Qt.Checked: @@ -154,17 +155,19 @@ class BibleUpgradeForm(OpenLPWizard): self.backupDirectoryEdit.setEnabled(not checked) self.backupBrowseButton.setEnabled(not checked) - def backupOldBibles(self, backupdirectory): + def backupOldBibles(self, backup_directory): """ Backup old bible databases in a given folder. """ + check_directory_exists(backup_directory) + success = True for filename in self.files: try: - shutil.copy(os.path.join(self.path, filename[0]), - backupdirectory) + shutil.copy(os.path.join(self.path, filename[0]), + backup_directory) except: - return False - return True + success = False + return success def customInit(self): """ @@ -318,7 +321,7 @@ class BibleUpgradeForm(OpenLPWizard): QtGui.QFormLayout.FieldRole, self.versionNameEdit[number]) self.versionNameEdit[number].setText(bible.get_name()) self.formLayout.addWidget(self.formWidget[number]) - #Set up the Signal for the checkbox + # Set up the Signal for the checkbox. QtCore.QObject.connect(self.checkBox[number], QtCore.SIGNAL(u'stateChanged(int)'), self.onCheckBoxIndexChanged) @@ -414,29 +417,23 @@ class BibleUpgradeForm(OpenLPWizard): return True elif self.currentPage() == self.backupPage: if not self.noBackupCheckBox.checkState() == QtCore.Qt.Checked: - if not unicode(self.backupDirectoryEdit.text()): + backup_path = unicode(self.backupDirectoryEdit.text()) + if not backup_path: critical_error_message_box(UiStrings().EmptyField, translate('BiblesPlugin.UpgradeWizardForm', 'You need to specify a Backup Directory for your ' 'Bibles.')) self.backupDirectoryEdit.setFocus() return False - elif not os.path.exists(unicode( - self.backupDirectoryEdit.text())): - critical_error_message_box(UiStrings().Error, - translate('BiblesPlugin.UpgradeWizardForm', - 'The given path is not an existing directory.')) - self.backupDirectoryEdit.setFocus() - return False else: - if not self.backupOldBibles(unicode( - self.backupDirectoryEdit.text())): + if not self.backupOldBibles(backup_path): critical_error_message_box(UiStrings().Error, - translate('BiblesPlugin.UpgradeWizardForm', - 'The backup was not successfull.\nTo backup your ' - 'Bibles you need the permission to write in the given ' - 'directory. If you have a permissions to write and ' - 'this error still occurs, please report a bug.')) + translate('BiblesPlugin.UpgradeWizardForm', + 'The backup was not successfull.\nTo backup your ' + 'Bibles you need the permission to write in the ' + 'given directory. If you have a permissions to ' + 'write and this error still occurs, please report ' + 'a bug.')) return False return True elif self.currentPage() == self.selectPage: diff --git a/openlp/plugins/bibles/forms/booknameform.py b/openlp/plugins/bibles/forms/booknameform.py index 28e4c9df1..b07f28bf1 100644 --- a/openlp/plugins/bibles/forms/booknameform.py +++ b/openlp/plugins/bibles/forms/booknameform.py @@ -70,15 +70,15 @@ class BookNameForm(QDialog, Ui_BookNameDialog): self.onCheckBoxIndexChanged) def onCheckBoxIndexChanged(self, index): - ''' + """ Reload Combobox if CheckBox state has changed - ''' + """ self.reloadComboBox() def reloadComboBox(self): - ''' + """ Reload the Combobox items - ''' + """ self.correspondingComboBox.clear() items = BiblesResourcesDB.get_books() for item in items: From 5494b20805c6d26261571443853ee5d9a15506fe Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 1 Jun 2011 08:31:22 +0200 Subject: [PATCH 11/52] added more debug --- openlp/core/ui/screen.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/openlp/core/ui/screen.py b/openlp/core/ui/screen.py index 2b6e10644..68d4c37ae 100644 --- a/openlp/core/ui/screen.py +++ b/openlp/core/ui/screen.py @@ -79,7 +79,7 @@ class ScreenList(object): ``number`` The number of the screen, which size has changed. """ - log.info(u'screenResolutionChanged %d' % number) + log.info(u'screen_resolution_changed %d' % number) for screen in self.screen_list: if number == screen[u'number']: newScreen = { @@ -104,6 +104,9 @@ class ScreenList(object): ``changed_screen`` The screen's number which has been (un)plugged. """ + # Do not log at start up. + if changed_screen != -1: + log.info(u'screen_count_changed %d' % number) # Remove unplugged screens. for screen in copy.deepcopy(self.screen_list): if screen[u'number'] == self.desktop.numScreens(): @@ -116,8 +119,7 @@ class ScreenList(object): u'size': self.desktop.screenGeometry(number), u'primary': (self.desktop.primaryScreen() == number) }) - # We do not want to send this message, when the method is called the - # first time. + # We do not want to send this message at start up. if changed_screen != -1: # Reload setting tabs to apply possible changes. Receiver.send_message(u'config_screen_changed') From 91718326ea28865305cf1b788f40019351ebddaf Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 1 Jun 2011 08:47:19 +0200 Subject: [PATCH 12/52] removed dangling list --- openlp/plugins/bibles/lib/mediaitem.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 8158465c7..15f5e7bee 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -845,7 +845,8 @@ class BibleMediaItem(MediaManagerItem): service_item.theme = None else: service_item.theme = self.settings.bible_theme - [service_item.add_from_text(slide[:30], slide) for slide in raw_slides] + for slide in raw_slides: + service_item.add_from_text(slide[:30], slide) return True def formatTitle(self, start_bitem, old_bitem): From c7a90102a2cd09a6fd2369d4f8935c9badcff8db Mon Sep 17 00:00:00 2001 From: Jonathan Corwin Date: Wed, 1 Jun 2011 08:38:19 +0100 Subject: [PATCH 13/52] Fix some startup blank/hide problems --- openlp.pyw | 1 + openlp/core/lib/renderer.py | 2 +- openlp/core/ui/maindisplay.py | 1 - openlp/core/ui/mainwindow.py | 5 ++--- openlp/core/ui/screen.py | 1 + openlp/core/ui/slidecontroller.py | 4 +++- openlp/core/utils/__init__.py | 1 - 7 files changed, 8 insertions(+), 7 deletions(-) diff --git a/openlp.pyw b/openlp.pyw index afd0b01f8..0bd7c940d 100755 --- a/openlp.pyw +++ b/openlp.pyw @@ -133,6 +133,7 @@ class OpenLP(QtGui.QApplication): u'general/update check', QtCore.QVariant(True)).toBool() if update_check: VersionThread(self.mainWindow).start() + Receiver.send_message(u'maindisplay_blank_check') self.mainWindow.appStartup() DelayStartThread(self.mainWindow).start() return self.exec_() diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index 4acf88202..c6e729be8 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -67,7 +67,7 @@ class Renderer(object): ``theme_manager`` The ThemeManager instance, used to get the current theme details. """ - log.debug(u'Initilisation started') + log.debug(u'Initialisation started') self.theme_manager = theme_manager self.image_manager = image_manager self.screens = ScreenList.get_instance() diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 715bb3b5b..e2117cc10 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -148,7 +148,6 @@ class MainDisplay(QtGui.QGraphicsView): self.__hideMouse() # To display or not to display? if not self.screen[u'primary']: - self.show() self.primary = False else: self.primary = True diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 6a5a753f3..7f41027a3 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -678,13 +678,12 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): def blankCheck(self): """ Check and display message if screen blank on setup. - Triggered by delay thread. """ settings = QtCore.QSettings() + self.liveController.mainDisplaySetBackground() if settings.value(u'%s/screen blank' % self.generalSettingsSection, QtCore.QVariant(False)).toBool(): - self.liveController.mainDisplaySetBackground() - if settings.value(u'blank warning', + if settings.value(u'%s/blank warning' % self.generalSettingsSection, QtCore.QVariant(False)).toBool(): QtGui.QMessageBox.question(self, translate('OpenLP.MainWindow', diff --git a/openlp/core/ui/screen.py b/openlp/core/ui/screen.py index 2b6e10644..1e24c8681 100644 --- a/openlp/core/ui/screen.py +++ b/openlp/core/ui/screen.py @@ -241,6 +241,7 @@ class ScreenList(object): height = settings.value(u'height', QtCore.QVariant(self.current[u'size'].height())).toInt()[0] self.override[u'size'] = QtCore.QRect(x, y, width, height) + self.override[u'primary'] = False settings.endGroup() if override_display: self.set_override_display() diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index a59f00f21..5b6212cf8 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -742,8 +742,10 @@ class SlideController(QtGui.QWidget): self.onThemeDisplay(True) elif display_type == u'hidden': self.onHideDisplay(True) - else: + elif display_type == u'blanked': self.onBlankDisplay(True) + else: + Receiver.send_message(u'maindisplay_show') def onSlideBlank(self): """ diff --git a/openlp/core/utils/__init__.py b/openlp/core/utils/__init__.py index 4ef445e36..ec20346d8 100644 --- a/openlp/core/utils/__init__.py +++ b/openlp/core/utils/__init__.py @@ -69,7 +69,6 @@ class VersionThread(QtCore.QThread): Run the thread. """ time.sleep(1) - Receiver.send_message(u'maindisplay_blank_check') app_version = get_application_version() version = check_latest_version(app_version) remote_version = {} From 6b1f8f36f2623b47a37a14e07a38311becb28cb7 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 1 Jun 2011 11:35:08 +0200 Subject: [PATCH 14/52] fixed spelling --- openlp/plugins/bibles/forms/bibleupgradeform.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/plugins/bibles/forms/bibleupgradeform.py b/openlp/plugins/bibles/forms/bibleupgradeform.py index 9ba7e36d3..a60fbec8f 100644 --- a/openlp/plugins/bibles/forms/bibleupgradeform.py +++ b/openlp/plugins/bibles/forms/bibleupgradeform.py @@ -429,7 +429,7 @@ class BibleUpgradeForm(OpenLPWizard): if not self.backupOldBibles(backup_path): critical_error_message_box(UiStrings().Error, translate('BiblesPlugin.UpgradeWizardForm', - 'The backup was not successfull.\nTo backup your ' + 'The backup was not successful.\nTo backup your ' 'Bibles you need the permission to write in the ' 'given directory. If you have a permissions to ' 'write and this error still occurs, please report ' From b9dfd1f7d22510855782c6c0fcaf6926b4511030 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 1 Jun 2011 14:08:40 +0200 Subject: [PATCH 15/52] more spelling fixes --- openlp/plugins/bibles/forms/bibleupgradeform.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/openlp/plugins/bibles/forms/bibleupgradeform.py b/openlp/plugins/bibles/forms/bibleupgradeform.py index a60fbec8f..a29ef25d0 100644 --- a/openlp/plugins/bibles/forms/bibleupgradeform.py +++ b/openlp/plugins/bibles/forms/bibleupgradeform.py @@ -430,10 +430,9 @@ class BibleUpgradeForm(OpenLPWizard): critical_error_message_box(UiStrings().Error, translate('BiblesPlugin.UpgradeWizardForm', 'The backup was not successful.\nTo backup your ' - 'Bibles you need the permission to write in the ' - 'given directory. If you have a permissions to ' - 'write and this error still occurs, please report ' - 'a bug.')) + 'Bibles you need permission to write to the given ' + 'directory. If you have write permissions and this ' + 'error still occurs, please report a bug.')) return False return True elif self.currentPage() == self.selectPage: From 40f2b4d1381d668554ca2af5e9f02a5524ae023f Mon Sep 17 00:00:00 2001 From: Jonathan Corwin Date: Wed, 1 Jun 2011 19:58:27 +0100 Subject: [PATCH 16/52] Fix unhidden toolbox that appears in the media manager --- openlp/core/lib/mediamanageritem.py | 1 + 1 file changed, 1 insertion(+) diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 602b3c55b..374617664 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -91,6 +91,7 @@ class MediaManagerItem(QtGui.QWidget): Constructor to create the media manager item. """ QtGui.QWidget.__init__(self, parent) + self.hide() self.whitespace = re.compile(r'\W+', re.UNICODE) self.plugin = plugin visible_title = self.plugin.getString(StringContent.VisibleName) From 975808d11e893489e04bfb087ebc4bd49563a06f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Wed, 1 Jun 2011 21:25:26 +0200 Subject: [PATCH 17/52] fix Traceback with appStartup() if plugin is disabled --- openlp/core/ui/mainwindow.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 6a5a753f3..c9fb5553b 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -655,7 +655,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): # Give all the plugins a chance to perform some tasks at startup Receiver.send_message(u'openlp_process_events') for plugin in self.pluginManager.plugins: - if hasattr(plugin, u'appStartup'): + if plugin.isActive() and hasattr(plugin, u'appStartup'): Receiver.send_message(u'openlp_process_events') plugin.appStartup() Receiver.send_message(u'openlp_process_events') From 0969f4ffc3bde56e32b23c691bc987823a40e1d7 Mon Sep 17 00:00:00 2001 From: Stevan Pettit Date: Wed, 1 Jun 2011 17:06:45 -0400 Subject: [PATCH 18/52] Removed repeated calls to self.initalize() --- openlp/plugins/custom/lib/mediaitem.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/openlp/plugins/custom/lib/mediaitem.py b/openlp/plugins/custom/lib/mediaitem.py index 387221610..94ee6d94e 100644 --- a/openlp/plugins/custom/lib/mediaitem.py +++ b/openlp/plugins/custom/lib/mediaitem.py @@ -109,7 +109,7 @@ class CustomMediaItem(MediaManagerItem): QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'custom_edit_clear'), self.onRemoteEditClear) QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'custom_load_list'), self.initialise) + QtCore.SIGNAL(u'custom_load_list'), self.loadList) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'custom_preview'), self.onPreviewClick) @@ -129,14 +129,6 @@ class CustomMediaItem(MediaManagerItem): self.searchTextEdit.setCurrentSearchType(QtCore.QSettings().value( u'%s/last search type' % self.settingsSection, QtCore.QVariant(CustomSearch.Titles)).toInt()[0]) - # Called to redisplay the custom list screen edith from a search - # or from the exit of the Custom edit dialog. If remote editing is - # active trigger it and clean up so it will not update again. - if self.remoteTriggered == u'L': - self.onAddClick() - if self.remoteTriggered == u'P': - self.onPreviewClick() - self.onRemoteEditClear() def loadList(self, custom_slides): # Sort out what custom we want to select after loading the list. @@ -155,11 +147,19 @@ class CustomMediaItem(MediaManagerItem): if custom_slide.id == self.auto_select_id: self.listView.setCurrentItem(custom_name) self.auto_select_id = -1 + # Called to redisplay the custom list screen edith from a search + # or from the exit of the Custom edit dialog. If remote editing is + # active trigger it and clean up so it will not update again. + if self.remoteTriggered == u'L': + self.onAddClick() + if self.remoteTriggered == u'P': + self.onPreviewClick() + self.onRemoteEditClear() def onNewClick(self): self.edit_custom_form.loadCustom(0) self.edit_custom_form.exec_() - self.initialise() + self.onClearTextButtonClick() self.onSelectionChange() def onRemoteEditClear(self): @@ -181,7 +181,7 @@ class CustomMediaItem(MediaManagerItem): self.edit_custom_form.loadCustom(custom_id, (remote_type == u'P')) self.edit_custom_form.exec_() self.auto_select_id = -1 - self.initialise() + self.onSearchTextButtonClick() def onEditClick(self): """ @@ -193,7 +193,7 @@ class CustomMediaItem(MediaManagerItem): self.edit_custom_form.loadCustom(item_id, False) self.edit_custom_form.exec_() self.auto_select_id = -1 - self.initialise() + self.onSearchTextButtonClick() def onDeleteClick(self): """ From 364de1af86d950f2a35ef17653d7d987d4b0f926 Mon Sep 17 00:00:00 2001 From: Jonathan Corwin Date: Wed, 1 Jun 2011 23:47:42 +0100 Subject: [PATCH 19/52] aphrostrophe fix for song searching --- openlp/core/lib/mediamanageritem.py | 2 +- openlp/plugins/songs/lib/__init__.py | 22 +++++++++++++++++----- openlp/plugins/songs/lib/mediaitem.py | 20 +++++++++++--------- 3 files changed, 29 insertions(+), 15 deletions(-) diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 602b3c55b..d74ea04b0 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -91,7 +91,7 @@ class MediaManagerItem(QtGui.QWidget): Constructor to create the media manager item. """ QtGui.QWidget.__init__(self, parent) - self.whitespace = re.compile(r'\W+', re.UNICODE) + self.whitespace = re.compile(r'[\W_]+', re.UNICODE) self.plugin = plugin visible_title = self.plugin.getString(StringContent.VisibleName) self.title = unicode(visible_title[u'title']) diff --git a/openlp/plugins/songs/lib/__init__.py b/openlp/plugins/songs/lib/__init__.py index 53b3d7cb1..323db9fe4 100644 --- a/openlp/plugins/songs/lib/__init__.py +++ b/openlp/plugins/songs/lib/__init__.py @@ -32,6 +32,8 @@ from openlp.core.lib import translate from db import Author from ui import SongStrings +WHITESPACE = re.compile(r'[\W_]+', re.UNICODE) + class VerseType(object): """ VerseType provides an enumeration for the tags that may be associated @@ -246,6 +248,12 @@ def retrieve_windows_encoding(recommendation=None): return None return filter(lambda item: item[1] == choice[0], encodings)[0][0] +def clean_string(string): + """ + Strips punctuation from the passed string to assist searching + """ + return WHITESPACE.sub(u' ', string.replace(u'\'', u'')).lower() + def clean_song(manager, song): """ Cleans the search title, rebuilds the search lyrics, adds a default author @@ -262,9 +270,8 @@ def clean_song(manager, song): if song.alternate_title is None: song.alternate_title = u'' song.alternate_title = song.alternate_title.strip() - whitespace = re.compile(r'\W+', re.UNICODE) - song.search_title = (whitespace.sub(u' ', song.title).strip() + u'@' + - whitespace.sub(u' ', song.alternate_title).strip()).strip().lower() + song.search_title = clean_string(song.title) + u'@' + \ + clean_string(song.alternate_title) # Only do this, if we the song is a 1.9.4 song (or older). if song.lyrics.find(u'') != -1: # Remove the old "language" attribute from lyrics tag (prior to 1.9.5). @@ -273,8 +280,8 @@ def clean_song(manager, song): song.lyrics = song.lyrics.replace( u'', u'') verses = SongXML().get_verses(song.lyrics) - lyrics = u' '.join([whitespace.sub(u' ', verse[1]) for verse in verses]) - song.search_lyrics = lyrics.lower() + song.search_lyrics = u' '.join([clean_string(verse[1]) + for verse in verses]) # We need a new and clean SongXML instance. sxml = SongXML() # Rebuild the song's verses, to remove any wrong verse names (for @@ -316,6 +323,11 @@ def clean_song(manager, song): if order not in compare_order: song.verse_order = u'' break + else: + verses = SongXML().get_verses(song.lyrics) + song.search_lyrics = u' '.join([clean_string(verse[1]) + for verse in verses]) + # The song does not have any author, add one. if not song.authors: name = SongStrings.AuthorUnknown diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index b24fbf64a..df9b6a41f 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -38,7 +38,8 @@ from openlp.core.lib.searchedit import SearchEdit from openlp.core.lib.ui import UiStrings from openlp.plugins.songs.forms import EditSongForm, SongMaintenanceForm, \ SongImportForm, SongExportForm -from openlp.plugins.songs.lib import OpenLyrics, SongXML, VerseType +from openlp.plugins.songs.lib import OpenLyrics, SongXML, VerseType, \ + clean_string from openlp.plugins.songs.lib.db import Author, Song from openlp.plugins.songs.lib.ui import SongStrings @@ -181,13 +182,14 @@ class SongMediaItem(MediaManagerItem): elif search_type == SongSearch.Titles: log.debug(u'Titles Search') search_results = self.plugin.manager.get_all_objects(Song, - Song.search_title.like(u'%' + self.whitespace.sub(u' ', - search_keywords.lower()) + u'%')) + Song.search_title.like(u'%' + clean_string(search_keywords) + + u'%')) self.displayResultsSong(search_results) elif search_type == SongSearch.Lyrics: log.debug(u'Lyrics Search') search_results = self.plugin.manager.get_all_objects(Song, - Song.search_lyrics.like(u'%' + search_keywords.lower() + u'%')) + Song.search_lyrics.like(u'%' + clean_string(search_keywords) + + u'%')) self.displayResultsSong(search_results) elif search_type == SongSearch.Authors: log.debug(u'Authors Search') @@ -198,16 +200,16 @@ class SongMediaItem(MediaManagerItem): elif search_type == SongSearch.Themes: log.debug(u'Theme Search') search_results = self.plugin.manager.get_all_objects(Song, - Song.theme_name.like(u'%' + self.whitespace.sub(u' ', - search_keywords) + u'%')) + Song.theme_name.like(u'%' + search_keywords + u'%')) self.displayResultsSong(search_results) self.check_search_result() def searchEntire(self, search_keywords): return self.plugin.manager.get_all_objects(Song, - or_(Song.search_title.like(u'%' + self.whitespace.sub(u' ', - search_keywords.lower()) + u'%'), - Song.search_lyrics.like(u'%' + search_keywords.lower() + u'%'), + or_(Song.search_title.like(u'%' + clean_string(search_keywords) + + u'%'), + Song.search_lyrics.like(u'%' + clean_string(search_keywords) + + u'%'), Song.comments.like(u'%' + search_keywords.lower() + u'%'))) def onSongListLoad(self): From 8067f669b161733af128ee8cac000511b087b473 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Thu, 2 Jun 2011 07:45:02 +0200 Subject: [PATCH 20/52] Fix Bug 788762 - error "No matching book" is now only shown once If a Second Bible is choosen Text Search Results contains now only Passages which are in both bibles. --- openlp/plugins/bibles/lib/db.py | 14 ++++++++------ openlp/plugins/bibles/lib/mediaitem.py | 26 ++++++++++++++++++++++++-- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index 776521aa6..e44dd0a25 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -381,6 +381,7 @@ class BibleDB(QtCore.QObject, Manager): """ log.debug(u'BibleDB.get_verses("%s")', reference_list) verse_list = [] + book_error = False for book_id, chapter, start_verse, end_verse in reference_list: db_book = self.get_book_by_book_ref_id(book_id) if db_book: @@ -398,12 +399,13 @@ class BibleDB(QtCore.QObject, Manager): verse_list.extend(verses) else: log.debug(u'OpenLP failed to find book with id "%s"', book_id) - if show_error: - critical_error_message_box( - translate('BiblesPlugin', 'No Book Found'), - translate('BiblesPlugin', 'No matching book ' - 'could be found in this Bible. Check that you ' - 'have spelled the name of the book correctly.')) + book_error = True + if book_error and show_error: + critical_error_message_box( + translate('BiblesPlugin', 'No Book Found'), + translate('BiblesPlugin', 'No matching book ' + 'could be found in this Bible. Check that you ' + 'have spelled the name of the book correctly.')) return verse_list def verse_search(self, text): diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 8158465c7..9d90a9f12 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -675,9 +675,31 @@ class BibleMediaItem(MediaManagerItem): second_bible, text) if second_bible and self.search_results: text = [] + new_search_results = [] + count = 0 + passage_not_found = False for verse in self.search_results: - text.append((verse.book.name, verse.chapter, verse.verse, - verse.verse)) + db_book = bibles[second_bible].get_book_by_book_ref_id( + verse.book.book_reference_id) + if not db_book: + log.debug(u'Passage "%s %d:%d" not found in Second ' + u'Bible' % (verse.book.name, verse.chapter, + verse.verse)) + passage_not_found = True + count += 1 + continue + new_search_results.append(verse) + text.append((verse.book.book_reference_id, verse.chapter, + verse.verse, verse.verse)) + if passage_not_found: + QtGui.QMessageBox.information(self, + translate('BiblePlugin.MediaItem', 'Information'), + unicode(translate('BiblePlugin.MediaItem', + 'The Second Bible not contains as much books as the ' + 'First Bible. Only search results which are found in ' + 'both Bibles are shown.\n%d results dropped.')) % count, + QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok)) + self.search_results = new_search_results self.second_search_results = \ bibles[second_bible].get_verses(text) if not self.quickLockButton.isChecked(): From 877ea4e13d7d840fd5de5a58b05587a5a4de770a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Thu, 2 Jun 2011 12:42:42 +0200 Subject: [PATCH 21/52] Change upgrade of bibles: bibleupgradeform now trys to upgrade existing verses from webbibles. --- .../plugins/bibles/forms/bibleupgradeform.py | 21 ++++++++++++++++-- openlp/plugins/bibles/lib/db.py | 22 +++++++++++++++++++ 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/bibles/forms/bibleupgradeform.py b/openlp/plugins/bibles/forms/bibleupgradeform.py index 0fdcdfd11..3d25d6092 100644 --- a/openlp/plugins/bibles/forms/bibleupgradeform.py +++ b/openlp/plugins/bibles/forms/bibleupgradeform.py @@ -671,8 +671,25 @@ class BibleUpgradeForm(OpenLPWizard): bible_failed = True break book_details = BiblesResourcesDB.get_book_by_id(book_ref_id) - self.newbibles[number].create_book(book, book_ref_id, - book_details[u'testament_id']) + db_book = self.newbibles[number].create_book(book, + book_ref_id, book_details[u'testament_id']) + # Try to import still downloaded verses + oldbook = oldbible.get_book(book) + if oldbook: + verses = oldbible.get_verses(oldbook[u'id']) + if not verses: + log.exception(u'No verses found to import for book ' + u'"%s"', book) + continue + for verse in verses: + if self.stop_import_flag: + bible_failed = True + break + self.newbibles[number].create_verse(db_book.id, + int(verse[u'chapter']), + int(verse[u'verse']), unicode(verse[u'text'])) + Receiver.send_message(u'openlp_process_events') + self.newbibles[number].session.commit() else: language_id = self.newbibles[number].get_object(BibleMeta, u'language_id') diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index 776521aa6..975b4093d 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -1043,6 +1043,28 @@ class OldBibleDB(QtCore.QObject, Manager): else: return None + def get_book(self, name): + """ + Return a book by name or abbreviation. + + ``name`` + The name or abbreviation of the book. + """ + if not isinstance(name, unicode): + name = unicode(name) + books = self.run_sql(u'SELECT id, testament_id, name, ' + u'abbreviation FROM book WHERE LOWER(name) = ? OR ' + u'LOWER(abbreviation) = ?', (name.lower(), name.lower())) + if books: + return { + u'id': books[0][0], + u'testament_id': books[0][1], + u'name': unicode(books[0][2]), + u'abbreviation': unicode(books[0][3]) + } + else: + return None + def get_books(self): """ Returns the books of the Bible. From 0b2cd7d9369fb7581ab22685cb675e1897e3877e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Thu, 2 Jun 2011 13:01:41 +0200 Subject: [PATCH 22/52] Change string --- openlp/plugins/bibles/lib/mediaitem.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 9d90a9f12..294148c57 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -695,9 +695,10 @@ class BibleMediaItem(MediaManagerItem): QtGui.QMessageBox.information(self, translate('BiblePlugin.MediaItem', 'Information'), unicode(translate('BiblePlugin.MediaItem', - 'The Second Bible not contains as much books as the ' - 'First Bible. Only search results which are found in ' - 'both Bibles are shown.\n%d results dropped.')) % count, + 'The second Bibles does not contain all the verses ' + 'that are in the main Bible. Only verses found in both ' + 'Bibles will be shown. %d verses have not been ' + 'included in the results.')) % count, QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok)) self.search_results = new_search_results self.second_search_results = \ From eda3e9ebe00d3aec754d719734e0f6f40d31bace Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Thu, 2 Jun 2011 13:52:06 +0200 Subject: [PATCH 23/52] change log usage --- openlp/plugins/bibles/forms/bibleupgradeform.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/openlp/plugins/bibles/forms/bibleupgradeform.py b/openlp/plugins/bibles/forms/bibleupgradeform.py index 3d25d6092..ecfb676f6 100644 --- a/openlp/plugins/bibles/forms/bibleupgradeform.py +++ b/openlp/plugins/bibles/forms/bibleupgradeform.py @@ -606,7 +606,7 @@ class BibleUpgradeForm(OpenLPWizard): handler = BSExtract(proxy_server) books = handler.get_books_from_http(meta_data[u'download name']) if not books: - log.exception(u'Upgrading books from %s - download '\ + log.error(u'Upgrading books from %s - download '\ u'name: "%s" failed' % ( meta_data[u'download source'], meta_data[u'download name'])) @@ -637,7 +637,7 @@ class BibleUpgradeForm(OpenLPWizard): else: language_id = self.newbibles[number].get_language(name) if not language_id: - log.exception(u'Upgrading from "%s" failed' % filename[0]) + log.error(u'Upgrading from "%s" failed' % filename[0]) delete_database(self.path, clean_filename(self.newbibles[number].get_name())) del self.newbibles[number] @@ -661,7 +661,7 @@ class BibleUpgradeForm(OpenLPWizard): book_ref_id = self.newbibles[number].\ get_book_ref_id_by_name(book, len(books), language_id) if not book_ref_id: - log.exception(u'Upgrading books from %s - download '\ + log.error(u'Upgrading books from %s - download '\ u'name: "%s" aborted by user' % ( meta_data[u'download source'], meta_data[u'download name'])) @@ -678,7 +678,7 @@ class BibleUpgradeForm(OpenLPWizard): if oldbook: verses = oldbible.get_verses(oldbook[u'id']) if not verses: - log.exception(u'No verses found to import for book ' + log.warn(u'No verses found to import for book ' u'"%s"', book) continue for verse in verses: @@ -696,7 +696,7 @@ class BibleUpgradeForm(OpenLPWizard): if not language_id: language_id = self.newbibles[number].get_language(name) if not language_id: - log.exception(u'Upgrading books from "%s" failed' % name) + log.error(u'Upgrading books from "%s" failed' % name) delete_database(self.path, clean_filename(self.newbibles[number].get_name())) del self.newbibles[number] @@ -722,7 +722,7 @@ class BibleUpgradeForm(OpenLPWizard): get_book_ref_id_by_name(book[u'name'], len(books), language_id) if not book_ref_id: - log.exception(u'Upgrading books from %s " '\ + log.error(u'Upgrading books from %s " '\ 'failed - aborted by user' % name) delete_database(self.path, clean_filename(self.newbibles[number].get_name())) @@ -734,7 +734,7 @@ class BibleUpgradeForm(OpenLPWizard): book_ref_id, book_details[u'testament_id']) verses = oldbible.get_verses(book[u'id']) if not verses: - log.exception(u'No verses found to import for book ' + log.error(u'No verses found to import for book ' u'"%s"', book[u'name']) self.newbibles[number].delete_book(db_book) continue From 0b8fe770d5c969b909e597c135936e5a3dd499ac Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 2 Jun 2011 15:58:49 +0200 Subject: [PATCH 24/52] Do not show qm files which start with qt_ Fixes: https://launchpad.net/bugs/791814 --- openlp/core/utils/languagemanager.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/openlp/core/utils/languagemanager.py b/openlp/core/utils/languagemanager.py index 0c0a4ed56..475d0a47a 100644 --- a/openlp/core/utils/languagemanager.py +++ b/openlp/core/utils/languagemanager.py @@ -77,6 +77,8 @@ class LanguageManager(object): AppLocation.LanguageDir)) file_names = trans_dir.entryList(QtCore.QStringList(u'*.qm'), QtCore.QDir.Files, QtCore.QDir.Name) + # Remove qm files from the list which start with "qt_". + file_names = file_names.filter(QtCore.QRegExp("^(?!qt_)")) for name in file_names: file_names.replaceInStrings(name, trans_dir.filePath(name)) return file_names From d4031a62d367c18e2d176d3464585ebb7f66c049 Mon Sep 17 00:00:00 2001 From: Jonathan Corwin Date: Thu, 2 Jun 2011 22:13:32 +0100 Subject: [PATCH 25/52] More apostrophes --- openlp/plugins/songs/lib/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openlp/plugins/songs/lib/__init__.py b/openlp/plugins/songs/lib/__init__.py index 323db9fe4..05e402776 100644 --- a/openlp/plugins/songs/lib/__init__.py +++ b/openlp/plugins/songs/lib/__init__.py @@ -33,6 +33,7 @@ from db import Author from ui import SongStrings WHITESPACE = re.compile(r'[\W_]+', re.UNICODE) +APOSTROPHE = re.compile(u'[\'`’ʻ′]', re.UNICODE) class VerseType(object): """ @@ -252,7 +253,7 @@ def clean_string(string): """ Strips punctuation from the passed string to assist searching """ - return WHITESPACE.sub(u' ', string.replace(u'\'', u'')).lower() + return WHITESPACE.sub(u' ', APOSTROPHE.sub(u'', string)).lower() def clean_song(manager, song): """ From 4b20a3571f3da001487e26dfc716a31539c92684 Mon Sep 17 00:00:00 2001 From: Stevan Pettit Date: Thu, 2 Jun 2011 23:39:28 -0400 Subject: [PATCH 26/52] Song add clears search --- openlp/plugins/songs/lib/mediaitem.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index df8fef820..0dc40330f 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -300,8 +300,9 @@ class SongMediaItem(MediaManagerItem): log.debug(u'onNewClick') self.edit_song_form.newSong() self.edit_song_form.exec_() - self.onSongListLoad() + self.onClearTextButtonClick() self.onSelectionChange() + self.auto_select_id = -1 def onSongMaintenanceClick(self): self.song_maintenance_form.exec_() From 9aed776186dd4fa024895db3416b83f6019cd5df Mon Sep 17 00:00:00 2001 From: Jonathan Corwin Date: Fri, 3 Jun 2011 07:52:16 +0100 Subject: [PATCH 27/52] Change presentation log.exceptions to log.warn's --- .../presentations/lib/impresscontroller.py | 18 +++++++++--------- .../presentations/presentationplugin.py | 4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/openlp/plugins/presentations/lib/impresscontroller.py b/openlp/plugins/presentations/lib/impresscontroller.py index 0d0cc43a3..ee49948ac 100644 --- a/openlp/plugins/presentations/lib/impresscontroller.py +++ b/openlp/plugins/presentations/lib/impresscontroller.py @@ -125,7 +125,7 @@ class ImpressController(PresentationController): try: uno_instance = get_uno_instance(resolver) except: - log.exception(u'Unable to find running instance ') + log.warn(u'Unable to find running instance ') self.start_process() loop += 1 try: @@ -136,7 +136,7 @@ class ImpressController(PresentationController): "com.sun.star.frame.Desktop", uno_instance) return desktop except: - log.exception(u'Failed to get UNO desktop') + log.warn(u'Failed to get UNO desktop') return None def get_com_desktop(self): @@ -151,7 +151,7 @@ class ImpressController(PresentationController): try: desktop = self.manager.createInstance(u'com.sun.star.frame.Desktop') except AttributeError: - log.exception(u'Failure to find desktop - Impress may have closed') + log.warn(u'Failure to find desktop - Impress may have closed') return desktop if desktop else None def get_com_servicemanager(self): @@ -162,7 +162,7 @@ class ImpressController(PresentationController): try: return Dispatch(u'com.sun.star.ServiceManager') except pywintypes.com_error: - log.exception(u'Failed to get COM service manager. ' + log.warn(u'Failed to get COM service manager. ' u'Impress Controller has been disabled') return None @@ -180,7 +180,7 @@ class ImpressController(PresentationController): else: desktop = self.get_com_desktop() except: - log.exception(u'Failed to find an OpenOffice desktop to terminate') + log.warn(u'Failed to find an OpenOffice desktop to terminate') if not desktop: return docs = desktop.getComponents() @@ -191,7 +191,7 @@ class ImpressController(PresentationController): desktop.terminate() log.debug(u'OpenOffice killed') except: - log.exception(u'Failed to terminate OpenOffice') + log.warn(u'Failed to terminate OpenOffice') class ImpressDocument(PresentationDocument): @@ -244,7 +244,7 @@ class ImpressDocument(PresentationDocument): self.document = desktop.loadComponentFromURL(url, u'_blank', 0, properties) except: - log.exception(u'Failed to load presentation %s' % url) + log.warn(u'Failed to load presentation %s' % url) return False if os.name == u'nt': # As we can't start minimized the Impress window gets in the way. @@ -323,7 +323,7 @@ class ImpressDocument(PresentationDocument): self.presentation = None self.document.dispose() except: - log.exception("Closing presentation failed") + log.warn("Closing presentation failed") self.document = None self.controller.remove_doc(self) @@ -341,7 +341,7 @@ class ImpressDocument(PresentationDocument): log.debug("getPresentation failed to find a presentation") return False except: - log.exception("getPresentation failed to find a presentation") + log.warn("getPresentation failed to find a presentation") return False return True diff --git a/openlp/plugins/presentations/presentationplugin.py b/openlp/plugins/presentations/presentationplugin.py index 29acb73f4..aa9e5ba24 100644 --- a/openlp/plugins/presentations/presentationplugin.py +++ b/openlp/plugins/presentations/presentationplugin.py @@ -77,7 +77,7 @@ class PresentationPlugin(Plugin): try: self.controllers[controller].start_process() except: - log.exception(u'Failed to start controller process') + log.warn(u'Failed to start controller process') self.controllers[controller].available = False self.mediaItem.buildFileMaskString() @@ -128,7 +128,7 @@ class PresentationPlugin(Plugin): try: __import__(modulename, globals(), locals(), []) except ImportError: - log.exception(u'Failed to import %s on path %s', + log.warn(u'Failed to import %s on path %s', modulename, path) controller_classes = PresentationController.__subclasses__() for controller_class in controller_classes: From c4e6e91c81f10b510173d5ae051b22814057be7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Fri, 3 Jun 2011 14:43:54 +0200 Subject: [PATCH 28/52] change log usage --- openlp/plugins/bibles/forms/bibleupgradeform.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/openlp/plugins/bibles/forms/bibleupgradeform.py b/openlp/plugins/bibles/forms/bibleupgradeform.py index ecfb676f6..0b1556f07 100644 --- a/openlp/plugins/bibles/forms/bibleupgradeform.py +++ b/openlp/plugins/bibles/forms/bibleupgradeform.py @@ -637,7 +637,7 @@ class BibleUpgradeForm(OpenLPWizard): else: language_id = self.newbibles[number].get_language(name) if not language_id: - log.error(u'Upgrading from "%s" failed' % filename[0]) + log.warn(u'Upgrading from "%s" failed' % filename[0]) delete_database(self.path, clean_filename(self.newbibles[number].get_name())) del self.newbibles[number] @@ -661,7 +661,7 @@ class BibleUpgradeForm(OpenLPWizard): book_ref_id = self.newbibles[number].\ get_book_ref_id_by_name(book, len(books), language_id) if not book_ref_id: - log.error(u'Upgrading books from %s - download '\ + log.warn(u'Upgrading books from %s - download '\ u'name: "%s" aborted by user' % ( meta_data[u'download source'], meta_data[u'download name'])) @@ -696,7 +696,7 @@ class BibleUpgradeForm(OpenLPWizard): if not language_id: language_id = self.newbibles[number].get_language(name) if not language_id: - log.error(u'Upgrading books from "%s" failed' % name) + log.warn(u'Upgrading books from "%s" failed' % name) delete_database(self.path, clean_filename(self.newbibles[number].get_name())) del self.newbibles[number] @@ -722,7 +722,7 @@ class BibleUpgradeForm(OpenLPWizard): get_book_ref_id_by_name(book[u'name'], len(books), language_id) if not book_ref_id: - log.error(u'Upgrading books from %s " '\ + log.warn(u'Upgrading books from %s " '\ 'failed - aborted by user' % name) delete_database(self.path, clean_filename(self.newbibles[number].get_name())) @@ -734,7 +734,7 @@ class BibleUpgradeForm(OpenLPWizard): book_ref_id, book_details[u'testament_id']) verses = oldbible.get_verses(book[u'id']) if not verses: - log.error(u'No verses found to import for book ' + log.warn(u'No verses found to import for book ' u'"%s"', book[u'name']) self.newbibles[number].delete_book(db_book) continue From 860b64f28e46535490adb445a1c576dc912c4e8b Mon Sep 17 00:00:00 2001 From: Stevan Pettit Date: Fri, 3 Jun 2011 11:44:40 -0400 Subject: [PATCH 29/52] Fix traceback in windows-builder.py if bzr version string contains non-ascii chars --- scripts/windows-builder.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/windows-builder.py b/scripts/windows-builder.py index e99de670b..be9f7d6aa 100644 --- a/scripts/windows-builder.py +++ b/scripts/windows-builder.py @@ -194,7 +194,8 @@ def write_version_file(): code = bzr.wait() if code != 0: raise Exception(u'Error running bzr log') - latest = output.split(u':')[0] + outputAscii = unicode(output, errors='ignore') + latest = outputAscii.split(u':')[0] versionstring = latest == revision and tag or u'%s-bzr%s' % (tag, latest) f = open(os.path.join(dist_path, u'.version'), u'w') f.write(versionstring) From 47936e34a74c2afbc5311cb258c53bed40a2688f Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Fri, 3 Jun 2011 17:57:56 +0200 Subject: [PATCH 30/52] improved thumbnail creation speed --- openlp/core/lib/mediamanageritem.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 31890a252..0f6c24829 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -391,21 +391,23 @@ class MediaManagerItem(QtGui.QWidget): self.iconFromFile(image, thumb) return True - def iconFromFile(self, image, thumb): + def iconFromFile(self, image_path, thumb_path): """ Create a thumbnail icon from a given image. - ``image`` + ``image_path`` The image file to create the icon from. - ``thumb`` - The filename to save the thumbnail to + ``thumb_path`` + The filename to save the thumbnail to. """ - icon = build_icon(unicode(image)) - pixmap = icon.pixmap(QtCore.QSize(88, 50)) - ext = os.path.splitext(thumb)[1].lower() - pixmap.save(thumb, ext[1:]) - return icon + ext = os.path.splitext(thumb_path)[1].lower() + reader = QtGui.QImageReader(image_path) + reader.setScaledSize(QtCore.QSize( + reader.size().width() / reader.size().height() * 88, 88)) + thumb = reader.read() + thumb.save(thumb_path, ext[1:]) + return build_icon(unicode(thumb_path)) def loadList(self, list): raise NotImplementedError(u'MediaManagerItem.loadList needs to be ' From 7c4474810fd5ff73dc03feb5482ffbeadd3cd830 Mon Sep 17 00:00:00 2001 From: Stevan Pettit Date: Fri, 3 Jun 2011 12:40:17 -0400 Subject: [PATCH 31/52] Added Mako requirement documentation --- scripts/windows-builder.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/windows-builder.py b/scripts/windows-builder.py index be9f7d6aa..854c927c9 100644 --- a/scripts/windows-builder.py +++ b/scripts/windows-builder.py @@ -102,6 +102,13 @@ psvince.dll the install will fail. The dll can be obtained from here: http://www.vincenzo.net/isxkb/index.php?title=PSVince) +Mako + Mako Templates for Python. This package is required for building the + remote plugin. It can be installed by going to your + python_directory\scripts\.. and running "easy_install Mako". If you do not + have easy_install, the Mako package can be obtained here: + http://www.makotemplates.org/download.html + """ import os From 0841802ddc7180734c73fafb6a1710b3369e2ac6 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 4 Jun 2011 19:08:48 +0100 Subject: [PATCH 32/52] Fix state for service items --- openlp/core/ui/servicemanager.py | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 349b0a4a3..cc5ecdbaa 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -652,7 +652,7 @@ class ServiceManager(QtGui.QWidget): self.loadFile(fileName) def contextMenu(self, point): - item = self.serviceManagerList.itemAt(point) + item = self.serviceManagerList.currentItem() if item is None: return if item.parent() is None: @@ -959,6 +959,7 @@ class ServiceManager(QtGui.QWidget): treewidgetitem.setToolTip(0, serviceitem.notes) treewidgetitem.setData(0, QtCore.Qt.UserRole, QtCore.QVariant(item[u'order'])) + treewidgetitem.setSelected(item[u'selected']) # Add the children to their parent treewidgetitem. for count, frame in enumerate(serviceitem.get_frames()): child = QtGui.QTreeWidgetItem(treewidgetitem) @@ -1030,16 +1031,34 @@ class ServiceManager(QtGui.QWidget): # force reset of renderer as theme data has changed self.mainwindow.renderer.themedata = None if self.serviceItems: + for item in self.serviceItems: + item[u'selected'] = False + serviceIterator = QtGui.QTreeWidgetItemIterator( + self.serviceManagerList) + while serviceIterator.value(): + if serviceIterator.value().isSelected(): + selectedItem = serviceIterator.value() + serviceIterator += 1 + if selectedItem is not None: + if selectedItem.parent() is None: + pos = selectedItem.data(0, QtCore.Qt.UserRole).toInt()[0] + else: + pos = selectedItem.parent().data(0, QtCore.Qt.UserRole). \ + toInt()[0] + self.serviceItems[pos - 1][u'selected'] = True tempServiceItems = self.serviceItems self.serviceManagerList.clear() self.serviceItems = [] self.isNew = True for item in tempServiceItems: self.addServiceItem( - item[u'service_item'], False, expand=item[u'expanded']) + item[u'service_item'], False, expand=item[u'expanded'], + repaint=False, selected=item[u'selected']) # Set to False as items may have changed rendering # does not impact the saved song so True may also be valid self.setModified() + # Repaint it once only at the end + self.repaintServiceList(-1, -1) Receiver.send_message(u'cursor_normal') def serviceItemUpdate(self, message): @@ -1069,7 +1088,7 @@ class ServiceManager(QtGui.QWidget): self.setModified() def addServiceItem(self, item, rebuild=False, expand=None, replace=False, - repaint=True): + repaint=True, selected=False): """ Add a Service item to the list @@ -1097,17 +1116,17 @@ class ServiceManager(QtGui.QWidget): for inditem in item: self.serviceItems.append({u'service_item': inditem, u'order': len(self.serviceItems) + 1, - u'expanded': expand}) + u'expanded': expand, u'selected': selected}) else: self.serviceItems.append({u'service_item': item, u'order': len(self.serviceItems) + 1, - u'expanded': expand}) + u'expanded': expand, u'selected': selected}) if repaint: self.repaintServiceList(len(self.serviceItems) - 1, -1) else: self.serviceItems.insert(self.dropPosition, {u'service_item': item, u'order': self.dropPosition, - u'expanded': expand}) + u'expanded': expand, u'selected': selected}) self.repaintServiceList(self.dropPosition, -1) # if rebuilding list make sure live is fixed. if rebuild: From b6d0f2243da07a757aada5f536e0b87a76506bf2 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 4 Jun 2011 19:14:32 +0100 Subject: [PATCH 33/52] Fix error if cnp --- openlp/core/ui/servicemanager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index cc5ecdbaa..8ecd89bc7 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -652,7 +652,7 @@ class ServiceManager(QtGui.QWidget): self.loadFile(fileName) def contextMenu(self, point): - item = self.serviceManagerList.currentItem() + item = self.serviceManagerList.itemAt(point) if item is None: return if item.parent() is None: From 937cfd22607bda61a4c1bdb56004c21b96c8b972 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Sat, 4 Jun 2011 20:43:59 +0200 Subject: [PATCH 34/52] Fix Bug #792811 - Traceback UnicodeEncodeError while importing a webbible If upgrade fails new bible databases now should be deleted always --- .../plugins/bibles/forms/bibleupgradeform.py | 5 ++--- openlp/plugins/bibles/lib/http.py | 8 +++++--- .../bibles/resources/bibles_resources.sqlite | Bin 104448 -> 104448 bytes 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/openlp/plugins/bibles/forms/bibleupgradeform.py b/openlp/plugins/bibles/forms/bibleupgradeform.py index 524ad4435..fc5ea1e54 100644 --- a/openlp/plugins/bibles/forms/bibleupgradeform.py +++ b/openlp/plugins/bibles/forms/bibleupgradeform.py @@ -586,8 +586,6 @@ class BibleUpgradeForm(OpenLPWizard): if not meta[u'key'] == u'Version': self.newbibles[number].create_meta(meta[u'key'], meta[u'value']) - else: - self.newbibles[number].create_meta(meta[u'key'], name) if meta[u'key'] == u'download source': webbible = True include_webbible = True @@ -626,7 +624,7 @@ class BibleUpgradeForm(OpenLPWizard): bible = BiblesResourcesDB.get_webbible( meta_data[u'download name'], meta_data[u'download source'].lower()) - if bible[u'language_id']: + if bible and bible[u'language_id']: language_id = bible[u'language_id'] self.newbibles[number].create_meta(u'language_id', language_id) @@ -744,6 +742,7 @@ class BibleUpgradeForm(OpenLPWizard): Receiver.send_message(u'openlp_process_events') self.newbibles[number].session.commit() if not bible_failed: + self.newbibles[number].create_meta(u'Version', name) self.incrementProgressBar(unicode(translate( 'BiblesPlugin.UpgradeWizardForm', 'Upgrading Bible %s of %s: "%s"\n' diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index edb111d93..fdf8c2def 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -199,9 +199,10 @@ class BSExtract(object): """ log.debug(u'BSExtract.get_bible_chapter("%s", "%s", "%s")', version, bookname, chapter) + urlversion = urllib.quote(version.encode("utf-8")) urlbookname = urllib.quote(bookname.encode("utf-8")) - chapter_url = u'http://m.bibleserver.com/text/%s/%s%s' % \ - (version, urlbookname, chapter) + chapter_url = u'http://m.bibleserver.com/text/%s/%s%d' % \ + (urlversion, urlbookname, chapter) header = (u'Accept-Language', u'en') soup = get_soup_for_bible_ref(chapter_url, header) if not soup: @@ -230,8 +231,9 @@ class BSExtract(object): The version of the Bible like NIV for New International Version """ log.debug(u'BSExtract.get_books_from_http("%s")', version) + urlversion = urllib.quote(version.encode("utf-8")) chapter_url = u'http://m.bibleserver.com/overlay/selectBook?'\ - 'translation=%s' % (version) + 'translation=%s' % (urlversion) soup = get_soup_for_bible_ref(chapter_url) if not soup: return None diff --git a/openlp/plugins/bibles/resources/bibles_resources.sqlite b/openlp/plugins/bibles/resources/bibles_resources.sqlite index 9336918f2d187da2a2e0a96819dfc2ceda31dabe..3235c95629f3d00cde01ef172cf7727e3edd4670 100644 GIT binary patch delta 82 zcmV-Y0ImOkum*sz29O&8;;|ft3kIJe0|Q9`lk0LGv&IWP;2aDAd=vw@1Cj%214sh; o0?PuL0$&0L0qOy}0erI|1Y7|FJb@pR)#*3{+yE#8v%Bp@s$c&b#sB~S delta 67 zcmV-J0KETzum*sz29O&8;jtWs3kIGd0|Q9`lk0LGv&IWP;2H}7yA%Vt1Cj%214sh; Z0?PuL0$&0L0qOy}vmpeX0kga9MXCd47f}EJ From 522e68c38cb2ada41cae934585a4c4cc0f649a65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Sat, 4 Jun 2011 21:34:36 +0200 Subject: [PATCH 35/52] Biblegateway.com has changed it's Bible-Book-List Layout. Addapt the regex for importing booklist of a bible from biblegateway changed log usage --- openlp/plugins/bibles/lib/http.py | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index fdf8c2def..76a99ea50 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -109,7 +109,7 @@ class BGExtract(object): try: clean_verse_num = int(str(raw_verse_num)) except ValueError: - log.exception(u'Illegal verse number in %s %s %s:%s', + log.warn(u'Illegal verse number in %s %s %s:%s', version, bookname, chapter, unicode(raw_verse_num)) if clean_verse_num: verse_text = raw_verse_num.next @@ -139,16 +139,17 @@ class BGExtract(object): """ log.debug(u'BGExtract.get_books_from_http("%s")', version) url_params = urllib.urlencode( - {u'search': 'Bible-List', u'version': u'%s' % version}) - reference_url = u'http://www.biblegateway.com/passage/?%s' % url_params + {u'action': 'getVersionInfo', u'vid': u'%s' % version}) + reference_url = u'http://www.biblegateway.com/versions/?%s#books' % \ + url_params page = get_web_page(reference_url) if not page: send_error_message(u'download') return None page_source = page.read() page_source = unicode(page_source, 'utf8') - page_source_temp = re.search(u'.*?
', \ - page_source, re.DOTALL) + page_source_temp = re.search(u'.*?'\ + u'
', page_source, re.DOTALL) if page_source_temp: soup = page_source_temp.group(0) else: @@ -156,15 +157,17 @@ class BGExtract(object): try: soup = BeautifulSoup(soup) except HTMLParseError: - log.exception(u'BeautifulSoup could not parse the Bible page.') + log.error(u'BeautifulSoup could not parse the Bible page.') + send_error_message(u'parse') + return None if not soup: send_error_message(u'parse') return None Receiver.send_message(u'openlp_process_events') - content = soup.find(u'table', {u'id': u'booklist'}) + content = soup.find(u'table', {u'class': u'infotable'}) content = content.findAll(u'tr') if not content: - log.exception(u'No books found in the Biblegateway response.') + log.error(u'No books found in the Biblegateway response.') send_error_message(u'parse') return None books = [] @@ -210,7 +213,7 @@ class BSExtract(object): Receiver.send_message(u'openlp_process_events') content = soup.find(u'div', u'content') if not content: - log.exception(u'No verses found in the Bibleserver response.') + log.error(u'No verses found in the Bibleserver response.') send_error_message(u'parse') return None content = content.find(u'div').findAll(u'div') @@ -239,7 +242,7 @@ class BSExtract(object): return None content = soup.find(u'ul') if not content: - log.exception(u'No books found in the Bibleserver response.') + log.error(u'No books found in the Bibleserver response.') send_error_message(u'parse') return None content = content.findAll(u'li') @@ -283,7 +286,7 @@ class CWExtract(object): Receiver.send_message(u'openlp_process_events') htmlverses = soup.findAll(u'span', u'versetext') if not htmlverses: - log.debug(u'No verses found in the CrossWalk response.') + log.error(u'No verses found in the CrossWalk response.') send_error_message(u'parse') return None verses = {} @@ -335,7 +338,7 @@ class CWExtract(object): content = soup.find(u'div', {u'class': u'Body'}) content = content.find(u'ul', {u'class': u'parent'}) if not content: - log.exception(u'No books found in the Crosswalk response.') + log.error(u'No books found in the Crosswalk response.') send_error_message(u'parse') return None content = content.findAll(u'li') From 52bab3e4155ba234a54221df5ba22d5f663c26f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Sat, 4 Jun 2011 22:35:24 +0200 Subject: [PATCH 36/52] Fix right parent for all used dialogs small fixes --- .../plugins/bibles/forms/bibleupgradeform.py | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/openlp/plugins/bibles/forms/bibleupgradeform.py b/openlp/plugins/bibles/forms/bibleupgradeform.py index fc5ea1e54..bbd6c1d20 100644 --- a/openlp/plugins/bibles/forms/bibleupgradeform.py +++ b/openlp/plugins/bibles/forms/bibleupgradeform.py @@ -68,6 +68,7 @@ class BibleUpgradeForm(OpenLPWizard): """ self.manager = manager self.mediaItem = bibleplugin.mediaItem + self.plugin = bibleplugin self.suffix = u'.sqlite' self.settingsSection = u'bibles' self.path = AppLocation.get_section_data_path( @@ -578,12 +579,14 @@ class BibleUpgradeForm(OpenLPWizard): name = unicode(self.versionNameEdit[biblenumber].text()) self.newbibles[number] = BibleDB(self.mediaItem, path=self.path, name=name) + self.newbibles[number].register(self.plugin.upgrade_wizard) metadata = oldbible.get_metadata() webbible = False meta_data = {} for meta in metadata: meta_data[meta[u'key']] = meta[u'value'] - if not meta[u'key'] == u'Version': + if not meta[u'key'] == u'Version' and not meta[u'key'] == \ + u'dbversion': self.newbibles[number].create_meta(meta[u'key'], meta[u'value']) if meta[u'key'] == u'download source': @@ -605,7 +608,7 @@ class BibleUpgradeForm(OpenLPWizard): meta_data[u'download source'], meta_data[u'download name'])) delete_database(self.path, - clean_filename(self.newbibles[number].get_name())) + clean_filename(name)) del self.newbibles[number] critical_error_message_box( translate('BiblesPlugin.UpgradeWizardForm', @@ -633,7 +636,7 @@ class BibleUpgradeForm(OpenLPWizard): if not language_id: log.warn(u'Upgrading from "%s" failed' % filename[0]) delete_database(self.path, - clean_filename(self.newbibles[number].get_name())) + clean_filename(name)) del self.newbibles[number] self.incrementProgressBar(unicode(translate( 'BiblesPlugin.UpgradeWizardForm', @@ -659,8 +662,7 @@ class BibleUpgradeForm(OpenLPWizard): u'name: "%s" aborted by user' % ( meta_data[u'download source'], meta_data[u'download name'])) - delete_database(self.path, - clean_filename(self.newbibles[number].get_name())) + delete_database(self.path, clean_filename(name)) del self.newbibles[number] bible_failed = True break @@ -691,8 +693,7 @@ class BibleUpgradeForm(OpenLPWizard): language_id = self.newbibles[number].get_language(name) if not language_id: log.warn(u'Upgrading books from "%s" failed' % name) - delete_database(self.path, - clean_filename(self.newbibles[number].get_name())) + delete_database(self.path, clean_filename(name)) del self.newbibles[number] self.incrementProgressBar(unicode(translate( 'BiblesPlugin.UpgradeWizardForm', @@ -718,8 +719,7 @@ class BibleUpgradeForm(OpenLPWizard): if not book_ref_id: log.warn(u'Upgrading books from %s " '\ 'failed - aborted by user' % name) - delete_database(self.path, - clean_filename(self.newbibles[number].get_name())) + delete_database(self.path, clean_filename(name)) del self.newbibles[number] bible_failed = True break @@ -755,8 +755,7 @@ class BibleUpgradeForm(OpenLPWizard): 'Upgrading Bible %s of %s: "%s"\nFailed')) % (number + 1, self.maxBibles, name), self.progressBar.maximum() - self.progressBar.value()) - delete_database(self.path, - clean_filename(name)) + delete_database(self.path, clean_filename(name)) number += 1 self.mediaItem.reloadBibles() successful_import = 0 From 346bf2426749360fcb831cf7da45cfdae67f4cd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Sun, 5 Jun 2011 14:40:26 +0200 Subject: [PATCH 37/52] changed behaviour if the user cancel the import so that after a traceback it is possible to cancel the dialog --- .../plugins/bibles/forms/bibleupgradeform.py | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/openlp/plugins/bibles/forms/bibleupgradeform.py b/openlp/plugins/bibles/forms/bibleupgradeform.py index bbd6c1d20..f776c3e5d 100644 --- a/openlp/plugins/bibles/forms/bibleupgradeform.py +++ b/openlp/plugins/bibles/forms/bibleupgradeform.py @@ -116,6 +116,8 @@ class BibleUpgradeForm(OpenLPWizard): self.stop_import_flag = True if not self.currentPage() == self.progressPage: self.done(QtGui.QDialog.Rejected) + else: + self.postWizard() def onCurrentIdChanged(self, pageId): """ @@ -132,9 +134,7 @@ class BibleUpgradeForm(OpenLPWizard): """ Some cleanup while finishing """ - for number, filename in enumerate(self.files): - if number in self.success and self.success[number] == True: - delete_file(os.path.join(self.path, filename[0])) + self.mediaItem.reloadBibles() def onBackupBrowseButtonClicked(self): """ @@ -537,7 +537,7 @@ class BibleUpgradeForm(OpenLPWizard): """ Perform the actual upgrade. """ - include_webbible = False + self.include_webbible = False proxy_server = None if self.maxBibles == 0: self.progressLabel.setText( @@ -591,7 +591,7 @@ class BibleUpgradeForm(OpenLPWizard): meta[u'value']) if meta[u'key'] == u'download source': webbible = True - include_webbible = True + self.include_webbible = True if meta.has_key(u'proxy server'): proxy_server = meta[u'proxy server'] if webbible: @@ -607,8 +607,7 @@ class BibleUpgradeForm(OpenLPWizard): u'name: "%s" failed' % ( meta_data[u'download source'], meta_data[u'download name'])) - delete_database(self.path, - clean_filename(name)) + delete_database(self.path, clean_filename(name)) del self.newbibles[number] critical_error_message_box( translate('BiblesPlugin.UpgradeWizardForm', @@ -635,8 +634,7 @@ class BibleUpgradeForm(OpenLPWizard): language_id = self.newbibles[number].get_language(name) if not language_id: log.warn(u'Upgrading from "%s" failed' % filename[0]) - delete_database(self.path, - clean_filename(name)) + delete_database(self.path, clean_filename(name)) del self.newbibles[number] self.incrementProgressBar(unicode(translate( 'BiblesPlugin.UpgradeWizardForm', @@ -743,6 +741,7 @@ class BibleUpgradeForm(OpenLPWizard): self.newbibles[number].session.commit() if not bible_failed: self.newbibles[number].create_meta(u'Version', name) + delete_file(os.path.join(self.path, filename[0])) self.incrementProgressBar(unicode(translate( 'BiblesPlugin.UpgradeWizardForm', 'Upgrading Bible %s of %s: "%s"\n' @@ -757,7 +756,11 @@ class BibleUpgradeForm(OpenLPWizard): self.progressBar.maximum() - self.progressBar.value()) delete_database(self.path, clean_filename(name)) number += 1 - self.mediaItem.reloadBibles() + + def postWizard(self): + """ + Clean up the UI after the import has finished. + """ successful_import = 0 failed_import = 0 for number, filename in enumerate(self.files): @@ -772,7 +775,7 @@ class BibleUpgradeForm(OpenLPWizard): else: failed_import_text = u'' if successful_import > 0: - if include_webbible: + if self.include_webbible: self.progressLabel.setText(unicode( translate('BiblesPlugin.UpgradeWizardForm', 'Upgrading ' 'Bible(s): %s successful%s\nPlease note, that verses from ' @@ -788,3 +791,4 @@ class BibleUpgradeForm(OpenLPWizard): self.progressLabel.setText( translate('BiblesPlugin.UpgradeWizardForm', 'Upgrade ' 'failed.')) + OpenLPWizard.postWizard(self) From e08c65aa45ee047074bae86726711017ed33ea8d Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sun, 5 Jun 2011 18:33:28 +0200 Subject: [PATCH 38/52] fixed ratio --- openlp/core/lib/mediamanageritem.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 0f6c24829..954179288 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -403,8 +403,8 @@ class MediaManagerItem(QtGui.QWidget): """ ext = os.path.splitext(thumb_path)[1].lower() reader = QtGui.QImageReader(image_path) - reader.setScaledSize(QtCore.QSize( - reader.size().width() / reader.size().height() * 88, 88)) + ratio = float(reader.size().width()) / float(reader.size().height()) + reader.setScaledSize(QtCore.QSize(int(ratio * 88), 88)) thumb = reader.read() thumb.save(thumb_path, ext[1:]) return build_icon(unicode(thumb_path)) From 1b2956a9e6ba629d3ac50e3f08af841dd44cd29a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Sun, 5 Jun 2011 19:33:46 +0200 Subject: [PATCH 39/52] remove unnecessary code --- openlp/plugins/bibles/forms/bibleupgradeform.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/openlp/plugins/bibles/forms/bibleupgradeform.py b/openlp/plugins/bibles/forms/bibleupgradeform.py index f776c3e5d..b7a4c3853 100644 --- a/openlp/plugins/bibles/forms/bibleupgradeform.py +++ b/openlp/plugins/bibles/forms/bibleupgradeform.py @@ -130,12 +130,6 @@ class BibleUpgradeForm(OpenLPWizard): elif self.page(pageId) == self.selectPage and self.maxBibles == 0: self.next() - def onFinishButton(self): - """ - Some cleanup while finishing - """ - self.mediaItem.reloadBibles() - def onBackupBrowseButtonClicked(self): """ Show the file open dialog for the OSIS file. @@ -181,8 +175,6 @@ class BibleUpgradeForm(OpenLPWizard): """ Set up the signals used in the bible importer. """ - QtCore.QObject.connect(self.finishButton, - QtCore.SIGNAL(u'clicked()'), self.onFinishButton) QtCore.QObject.connect(self.backupBrowseButton, QtCore.SIGNAL(u'clicked()'), self.onBackupBrowseButtonClicked) QtCore.QObject.connect(self.noBackupCheckBox, From c85e953d4e774d6341fbff79d7e1305296b6bad2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Sun, 5 Jun 2011 19:39:13 +0200 Subject: [PATCH 40/52] remove unnecessary code --- openlp/plugins/bibles/forms/bibleupgradeform.py | 1 - 1 file changed, 1 deletion(-) diff --git a/openlp/plugins/bibles/forms/bibleupgradeform.py b/openlp/plugins/bibles/forms/bibleupgradeform.py index b7a4c3853..7913aac31 100644 --- a/openlp/plugins/bibles/forms/bibleupgradeform.py +++ b/openlp/plugins/bibles/forms/bibleupgradeform.py @@ -68,7 +68,6 @@ class BibleUpgradeForm(OpenLPWizard): """ self.manager = manager self.mediaItem = bibleplugin.mediaItem - self.plugin = bibleplugin self.suffix = u'.sqlite' self.settingsSection = u'bibles' self.path = AppLocation.get_section_data_path( From 5505644176fa66c35d81364710bdf50057a4c6a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Sun, 5 Jun 2011 20:19:44 +0200 Subject: [PATCH 41/52] Fix Bug #793091 - if plugin changed status from inactive to active plugin.appStartup is called --- openlp/core/ui/pluginform.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/openlp/core/ui/pluginform.py b/openlp/core/ui/pluginform.py index c93b08ccb..37c6c8d63 100644 --- a/openlp/core/ui/pluginform.py +++ b/openlp/core/ui/pluginform.py @@ -132,6 +132,9 @@ class PluginForm(QtGui.QDialog, Ui_PluginViewDialog): Receiver.send_message(u'cursor_busy') self.activePlugin.toggleStatus(PluginStatus.Active) Receiver.send_message(u'cursor_normal') + if hasattr(self.activePlugin, u'appStartup'): + Receiver.send_message(u'openlp_process_events') + self.activePlugin.appStartup() else: self.activePlugin.toggleStatus(PluginStatus.Inactive) status_text = unicode( From 17209fcc293dd99cce386241d6c9a87a2f43ae42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Sun, 5 Jun 2011 20:46:00 +0200 Subject: [PATCH 42/52] define appStartup() in plugin.py remove hassattr(plugin, appStartup) --- openlp/core/lib/plugin.py | 6 ++++++ openlp/core/ui/mainwindow.py | 2 +- openlp/core/ui/pluginform.py | 4 +--- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index 65ed76dfe..910c52d2c 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -300,6 +300,12 @@ class Plugin(QtCore.QObject): if self.mediaItem: self.mediadock.remove_dock(self.mediaItem) + def appStartup(self): + """ + Perform tasks on application starup + """ + pass + def usesTheme(self, theme): """ Called to find out if a plugin is currently using a theme. diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index bacbff073..b4a3b3640 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -655,7 +655,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): # Give all the plugins a chance to perform some tasks at startup Receiver.send_message(u'openlp_process_events') for plugin in self.pluginManager.plugins: - if plugin.isActive() and hasattr(plugin, u'appStartup'): + if plugin.isActive(): Receiver.send_message(u'openlp_process_events') plugin.appStartup() Receiver.send_message(u'openlp_process_events') diff --git a/openlp/core/ui/pluginform.py b/openlp/core/ui/pluginform.py index 37c6c8d63..b4c87488c 100644 --- a/openlp/core/ui/pluginform.py +++ b/openlp/core/ui/pluginform.py @@ -132,9 +132,7 @@ class PluginForm(QtGui.QDialog, Ui_PluginViewDialog): Receiver.send_message(u'cursor_busy') self.activePlugin.toggleStatus(PluginStatus.Active) Receiver.send_message(u'cursor_normal') - if hasattr(self.activePlugin, u'appStartup'): - Receiver.send_message(u'openlp_process_events') - self.activePlugin.appStartup() + self.activePlugin.appStartup() else: self.activePlugin.toggleStatus(PluginStatus.Inactive) status_text = unicode( From b5810b271ef25f7459762d786ce86b00b8b3614c Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 6 Jun 2011 08:03:06 +0200 Subject: [PATCH 43/52] fixed bug #788770 --- openlp/plugins/bibles/lib/mediaitem.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index bd84e2bb5..d94368f52 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -772,7 +772,7 @@ class BibleMediaItem(MediaManagerItem): log.exception(u'The second_search_results does not have as ' 'many verses as the search_results.') break - bible_text = u' %s %d%s%d (%s, %s)' % (verse.book.name, + bible_text = u'%s %d%s%d (%s, %s)' % (verse.book.name, verse.chapter, verse_separator, verse.verse, version, second_version) else: @@ -830,7 +830,7 @@ class BibleMediaItem(MediaManagerItem): bible_text = u'' # If we are 'Verse Per Line' then force a new line. elif self.settings.layout_style == LayoutStyle.VersePerLine: - bible_text = u'%s %s %s\n' % (bible_text, verse_text, text) + bible_text = u'%s%s %s\n' % (bible_text, verse_text, text) # We have to be 'Continuous'. else: bible_text = u'%s %s %s\n' % (bible_text, verse_text, text) From 98e731ee9a340040ac6230779ce72d501a19ed34 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 6 Jun 2011 09:05:10 +0200 Subject: [PATCH 44/52] fallback if thumb was not created --- openlp/core/lib/mediamanageritem.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 954179288..9aa159981 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -407,7 +407,11 @@ class MediaManagerItem(QtGui.QWidget): reader.setScaledSize(QtCore.QSize(int(ratio * 88), 88)) thumb = reader.read() thumb.save(thumb_path, ext[1:]) - return build_icon(unicode(thumb_path)) + if os.path.exists(thumb_path): + return build_icon(unicode(thumb_path)) + # When the thumbnail creation was not successful then create the icon + # from the original file. + return build_icon(unicode(image_path)) def loadList(self, list): raise NotImplementedError(u'MediaManagerItem.loadList needs to be ' From 6047dd9f5b75b98bb000c7125d95dd9a6acc63ab Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 6 Jun 2011 16:17:39 +0200 Subject: [PATCH 45/52] fixed bug 793537 Fixes: https://launchpad.net/bugs/793537 --- openlp/core/ui/screen.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/ui/screen.py b/openlp/core/ui/screen.py index 160080c5a..b970158b2 100644 --- a/openlp/core/ui/screen.py +++ b/openlp/core/ui/screen.py @@ -106,7 +106,7 @@ class ScreenList(object): """ # Do not log at start up. if changed_screen != -1: - log.info(u'screen_count_changed %d' % number) + log.info(u'screen_count_changed %d' % self.desktop.numScreens()) # Remove unplugged screens. for screen in copy.deepcopy(self.screen_list): if screen[u'number'] == self.desktop.numScreens(): From 5d9e6acfbf1aa916bfc9ea7e606d3e0ddd5fa03a Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 6 Jun 2011 16:58:14 +0200 Subject: [PATCH 46/52] better comment --- openlp/core/lib/mediamanageritem.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 9aa159981..cfd4948cb 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -409,8 +409,7 @@ class MediaManagerItem(QtGui.QWidget): thumb.save(thumb_path, ext[1:]) if os.path.exists(thumb_path): return build_icon(unicode(thumb_path)) - # When the thumbnail creation was not successful then create the icon - # from the original file. + # Fallback for files with animation support. return build_icon(unicode(image_path)) def loadList(self, list): From b2bb583fb04eb19d80b148fbcbe2b183b0cfe9a3 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Mon, 6 Jun 2011 18:35:47 +0100 Subject: [PATCH 47/52] Fixes --- openlp/core/lib/renderer.py | 6 +++--- openlp/core/ui/themeform.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index c6e729be8..250991d2a 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -241,7 +241,7 @@ class Renderer(object): ``screen`` The QSize of the screen. """ - log.debug(u'calculate default %s', screen) + log.debug(u'_calculate default %s', screen) self.width = screen.width() self.height = screen.height() self.screen_ratio = float(self.height) / float(self.width) @@ -286,7 +286,7 @@ class Renderer(object): ``rect_footer`` The footer text block. """ - log.debug(u'set_text_rectangle %s , %s' % (rect_main, rect_footer)) + log.debug(u'_set_text_rectangle %s , %s' % (rect_main, rect_footer)) self._rect = rect_main self._rect_footer = rect_footer self.page_width = self._rect.width() @@ -339,7 +339,7 @@ class Renderer(object): # Text too long so go to next page. if self.web_frame.contentsSize().height() > self.page_height: if force_page and line_count > 0: - Receiver.send_message(u'theme_line_count', line_count) + Receiver.send_message(u'theme_line_count', line_count - 1) line_count = -1 while html_text.endswith(u'
'): html_text = html_text[:-4] diff --git a/openlp/core/ui/themeform.py b/openlp/core/ui/themeform.py index bae3e8692..921cab048 100644 --- a/openlp/core/ui/themeform.py +++ b/openlp/core/ui/themeform.py @@ -202,7 +202,7 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): Updates the lines on a page on the wizard """ self.mainLineCountLabel.setText(unicode(translate('OpenLP.ThemeForm', - '(%d lines per slide)')) % int(lines)) + '(approximately %d lines per slide)')) % int(lines)) def resizeEvent(self, event=None): """ From f263dfa0c88d566606db227c70193d9787241836 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Tue, 7 Jun 2011 09:30:50 +0200 Subject: [PATCH 48/52] --- openlp/core/lib/__init__.py | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index 2d3e55355..d335fc244 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -137,13 +137,12 @@ def image_to_byte(image): # convert to base64 encoding so does not get missed! return byte_array.toBase64() -def resize_image(image, width, height, background=QtCore.Qt.black): +def resize_image(image_path, width, height, background=QtCore.Qt.black): """ Resize an image to fit on the current screen. - ``image`` - The image to resize. It has to be either a ``QImage`` instance or the - path to the image. + ``image_path`` + The path to the image to resize. ``width`` The new image width. @@ -155,16 +154,27 @@ def resize_image(image, width, height, background=QtCore.Qt.black): The background colour defaults to black. """ log.debug(u'resize_image - start') - if isinstance(image, QtGui.QImage): - preview = image + if isinstance(image_path, QtGui.QImage): + print u'wrong instance!' else: - preview = QtGui.QImage(image) - if not preview.isNull(): - # Only resize if different size - if preview.width() == width and preview.height == height: - return preview - preview = preview.scaled(width, height, QtCore.Qt.KeepAspectRatio, - QtCore.Qt.SmoothTransformation) + reader = QtGui.QImageReader(image_path) + # The image's ratio. + image_ratio = float(reader.size().width()) / float(reader.size().height()) + resize_ratio = float(width) / float(height) + # Figure out the size we want to resize the image to (keep aspect ratio). + if image_ratio == resize_ratio: + size = QtCore.QSize(width, height) + elif image_ratio < resize_ratio: + # Use the image's height as reference for the new size. + size = QtCore.QSize(image_ratio * height, height) + else: + # Use the image's width as reference for the new size. + size = QtCore.QSize(width, 1 / (image_ratio / width)) + reader.setScaledSize(size) + preview = reader.read() + if image_ratio == resize_ratio: + # We neither need to centre the image nor add "bars" to the image. + return preview realw = preview.width() realh = preview.height() # and move it to the centre of the preview space From 56783d8a4126f1094effba061855c6bea8a2d692 Mon Sep 17 00:00:00 2001 From: Jonathan Corwin Date: Wed, 8 Jun 2011 21:03:32 +0100 Subject: [PATCH 49/52] Fix Bible error message if search from remote --- openlp/plugins/bibles/lib/mediaitem.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index d94368f52..f2b9a57d3 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -683,17 +683,17 @@ class BibleMediaItem(MediaManagerItem): verse.book.book_reference_id) if not db_book: log.debug(u'Passage "%s %d:%d" not found in Second ' - u'Bible' % (verse.book.name, verse.chapter, + u'Bible' % (verse.book.name, verse.chapter, verse.verse)) passage_not_found = True count += 1 continue new_search_results.append(verse) - text.append((verse.book.book_reference_id, verse.chapter, + text.append((verse.book.book_reference_id, verse.chapter, verse.verse, verse.verse)) if passage_not_found: - QtGui.QMessageBox.information(self, - translate('BiblePlugin.MediaItem', 'Information'), + QtGui.QMessageBox.information(self, + translate('BiblePlugin.MediaItem', 'Information'), unicode(translate('BiblePlugin.MediaItem', 'The second Bibles does not contain all the verses ' 'that are in the main Bible. Only verses found in both ' @@ -983,7 +983,7 @@ class BibleMediaItem(MediaManagerItem): Search for some Bible verses (by reference). """ bible = unicode(self.quickVersionComboBox.currentText()) - search_results = self.plugin.manager.get_verses(bible, string, False) + search_results = self.plugin.manager.get_verses(bible, string, False, False) results = [] if search_results: versetext = u' '.join([verse.text for verse in search_results]) From 7cdd9b2fbc26b41af6d217dd8dc0d4d4e3e72d1e Mon Sep 17 00:00:00 2001 From: Jonathan Corwin Date: Wed, 8 Jun 2011 22:39:07 +0100 Subject: [PATCH 50/52] Close and delete old display window when creating a new one --- openlp/core/lib/renderer.py | 2 ++ openlp/core/ui/maindisplay.py | 1 + openlp/core/ui/servicemanager.py | 1 + openlp/core/ui/slidecontroller.py | 3 +++ 4 files changed, 7 insertions(+) diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index 250991d2a..f9af00f6e 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -86,6 +86,8 @@ class Renderer(object): """ log.debug(u'Update Display') self._calculate_default(self.screens.current[u'size']) + if self.display: + self.display.close() self.display = MainDisplay(None, self.image_manager, False) self.display.setup() self.bg_frame = None diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index e2117cc10..0db8bb26f 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -63,6 +63,7 @@ class MainDisplay(QtGui.QGraphicsView): self.setStyleSheet(u'border: 0px; margin: 0px; padding: 0px;') self.setWindowFlags(QtCore.Qt.FramelessWindowHint | QtCore.Qt.Tool | QtCore.Qt.WindowStaysOnTopHint) + self.setAttribute(QtCore.Qt.WA_DeleteOnClose) if self.isLive: QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'maindisplay_hide'), self.hideDisplay) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 8ecd89bc7..8a018d915 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -1035,6 +1035,7 @@ class ServiceManager(QtGui.QWidget): item[u'selected'] = False serviceIterator = QtGui.QTreeWidgetItemIterator( self.serviceManagerList) + selectedItem = None while serviceIterator.value(): if serviceIterator.value().isSelected(): selectedItem = serviceIterator.value() diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 5b6212cf8..d490f3bce 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -59,6 +59,7 @@ class SlideController(QtGui.QWidget): """ QtGui.QWidget.__init__(self, parent) self.isLive = isLive + self.display = None self.screens = ScreenList.get_instance() self.ratio = float(self.screens.current[u'size'].width()) / \ float(self.screens.current[u'size'].height()) @@ -422,6 +423,8 @@ class SlideController(QtGui.QWidget): screen previews. """ # rebuild display as screen size changed + if self.display: + self.display.close() self.display = MainDisplay(self, self.image_manager, self.isLive) self.display.alertTab = self.alertTab self.display.setup() From 8fc4305b43cb5822161bcbc616eb08b9468d801d Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 9 Jun 2011 12:41:02 +0200 Subject: [PATCH 51/52] removed test lines --- openlp/core/lib/__init__.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index d335fc244..75bafc5e8 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -154,10 +154,7 @@ def resize_image(image_path, width, height, background=QtCore.Qt.black): The background colour defaults to black. """ log.debug(u'resize_image - start') - if isinstance(image_path, QtGui.QImage): - print u'wrong instance!' - else: - reader = QtGui.QImageReader(image_path) + reader = QtGui.QImageReader(image_path) # The image's ratio. image_ratio = float(reader.size().width()) / float(reader.size().height()) resize_ratio = float(width) / float(height) From c298146b1f8a51974ab7333b337487d2f9d83750 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 9 Jun 2011 17:14:41 +0200 Subject: [PATCH 52/52] give the title edit focus when creating a new customs --- openlp/plugins/custom/forms/editcustomform.py | 1 + 1 file changed, 1 insertion(+) diff --git a/openlp/plugins/custom/forms/editcustomform.py b/openlp/plugins/custom/forms/editcustomform.py index 4a7585f11..32a2a3146 100644 --- a/openlp/plugins/custom/forms/editcustomform.py +++ b/openlp/plugins/custom/forms/editcustomform.py @@ -93,6 +93,7 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): self.titleEdit.setText(u'') self.creditEdit.setText(u'') self.themeComboBox.setCurrentIndex(0) + self.titleEdit.setFocus(QtCore.Qt.OtherFocusReason) else: self.customSlide = self.manager.get_object(CustomSlide, id) self.titleEdit.setText(self.customSlide.title)