From 356027768432a016a317a9ac7aadb7ac544481e7 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Tue, 20 Jul 2010 21:43:42 +0100 Subject: [PATCH 1/8] Cleanups --- openlp/core/ui/generaltab.py | 21 +++++++++++--------- openlp/plugins/songs/forms/editsongdialog.py | 3 ++- openlp/plugins/songs/lib/opensongimport.py | 10 ++++++---- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/openlp/core/ui/generaltab.py b/openlp/core/ui/generaltab.py index 72718bb2c..1392992d3 100644 --- a/openlp/core/ui/generaltab.py +++ b/openlp/core/ui/generaltab.py @@ -287,16 +287,16 @@ class GeneralTab(SettingsTab): Translate the general settings tab to the currently selected language """ self.MonitorGroupBox.setTitle(translate('GeneralTab', 'Monitors')) - self.MonitorLabel.setText( - translate('OpenLP.GeneralTab', 'Select monitor for output display:')) + self.MonitorLabel.setText(translate('OpenLP.GeneralTab', + 'Select monitor for output display:')) self.DisplayOnMonitorCheck.setText( translate('OpenLP.GeneralTab', 'Display if a single screen')) self.StartupGroupBox.setTitle( translate('OpenLP.GeneralTab', 'Application Startup')) self.WarningCheckBox.setText( translate('OpenLP.GeneralTab', 'Show blank screen warning')) - self.AutoOpenCheckBox.setText( - translate('OpenLP.GeneralTab', 'Automatically open the last service')) + self.AutoOpenCheckBox.setText(translate('OpenLP.GeneralTab', + 'Automatically open the last service')) self.ShowSplashCheckBox.setText( translate('OpenLP.GeneralTab', 'Show the splash screen')) self.SettingsGroupBox.setTitle(translate('OpenLP.GeneralTab', @@ -318,7 +318,8 @@ class GeneralTab(SettingsTab): self.currentXValueLabel.setText(u'0') self.currentYLabel.setText(translate('OpenLP.GeneralTab', 'Y')) self.currentYValueLabel.setText(u'0') - self.currentHeightLabel.setText(translate('OpenLP.GeneralTab', 'Height')) + self.currentHeightLabel.setText( + translate('OpenLP.GeneralTab', 'Height')) self.currentHeightValueLabel.setText(u'0') self.currentWidthLabel.setText(translate('OpenLP.GeneralTab', 'Width')) self.currentWidthValueLabel.setText(u'0') @@ -375,10 +376,12 @@ class GeneralTab(SettingsTab): QtCore.QVariant(self.screens.current[u'size'].x())).toString()) self.customYValueEdit.setText(settings.value(u'y position', QtCore.QVariant(self.screens.current[u'size'].y())).toString()) - self.customHeightValueEdit.setText(settings.value(u'height', - QtCore.QVariant(self.screens.current[u'size'].height())).toString()) - self.customWidthValueEdit.setText(settings.value(u'width', - QtCore.QVariant(self.screens.current[u'size'].width())).toString()) + self.customHeightValueEdit.setText( + settings.value(u'height', QtCore.QVariant( + self.screens.current[u'size'].height())).toString()) + self.customWidthValueEdit.setText( + settings.value(u'width', QtCore.QVariant( + self.screens.current[u'size'].width())).toString()) else: self.customXValueEdit.setText( unicode(self.screens.current[u'size'].x())) diff --git a/openlp/plugins/songs/forms/editsongdialog.py b/openlp/plugins/songs/forms/editsongdialog.py index 922147628..dccc6d6ba 100644 --- a/openlp/plugins/songs/forms/editsongdialog.py +++ b/openlp/plugins/songs/forms/editsongdialog.py @@ -441,7 +441,8 @@ class Ui_EditSongDialog(object): translate('SongsPlugin.EditSongForm', 'Song Book')) self.SongTabWidget.setTabText( self.SongTabWidget.indexOf(self.AuthorsTab), - translate('SongsPlugin.EditSongForm', 'Authors, Topics && Song Book')) + translate('SongsPlugin.EditSongForm', + 'Authors, Topics && Song Book')) self.ThemeGroupBox.setTitle( translate('SongsPlugin.EditSongForm', 'Theme')) self.ThemeAddButton.setText( diff --git a/openlp/plugins/songs/lib/opensongimport.py b/openlp/plugins/songs/lib/opensongimport.py index d6a257d71..345b0922f 100644 --- a/openlp/plugins/songs/lib/opensongimport.py +++ b/openlp/plugins/songs/lib/opensongimport.py @@ -195,11 +195,12 @@ class OpenSongImport(object): versetype is not None: words = thisline if versenum is not None: - versetag = u'%s%s'%(versetype,versenum) + versetag = u'%s%s' % (versetype, versenum) if not verses.has_key(versetype): verses[versetype] = {} if not verses[versetype].has_key(versenum): - verses[versetype][versenum] = [] # storage for lines in this verse + # storage for lines in this verse + verses[versetype][versenum] = [] if not verses_seen.has_key(versetag): verses_seen[versetag] = 1 our_verse_order.append(versetag) @@ -216,10 +217,11 @@ class OpenSongImport(object): versenums = verses[versetype].keys() versenums.sort() for num in versenums: - versetag = u'%s%s' %(versetype,num) + versetag = u'%s%s' % (versetype, num) lines = u'\n'.join(verses[versetype][num]) self.song_import.verses.append([versetag, lines]) - versetags[versetag] = 1 # keep track of what we have for error checking later + # Keep track of what we have for error checking later + versetags[versetag] = 1 # now figure out the presentation order if u'presentation' in fields and root.presentation != u'': order = unicode(root.presentation) From 5bb55fb63e1720bd2a7ef69ada9abc2092f1a595 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Wed, 21 Jul 2010 01:36:15 +0100 Subject: [PATCH 2/8] Form parent cleanup --- openlp/core/ui/servicemanager.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index cf9afe066..19811b979 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -108,8 +108,8 @@ class ServiceManager(QtGui.QWidget): self.droppos = 0 #is a new service and has not been saved self.isNew = True - self.serviceNoteForm = ServiceNoteForm() - self.serviceItemEditForm = ServiceItemEditForm() + self.serviceNoteForm = ServiceNoteForm(self.parent) + self.serviceItemEditForm = ServiceItemEditForm(self.parent) #start with the layout self.Layout = QtGui.QVBoxLayout(self) self.Layout.setSpacing(0) From db025be243d82fc01e27262d03d69f08a7198bdf Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Wed, 21 Jul 2010 02:34:27 +0100 Subject: [PATCH 3/8] Do not rename when name has not changed --- openlp/core/ui/thememanager.py | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index bf4dabb2d..5f4b934c4 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -605,19 +605,21 @@ class ThemeManager(QtGui.QWidget): if newThemeIndex != -1: self.serviceComboBox.setCurrentIndex(newThemeIndex) if self.editingDefault: - newThemeItem = self.ThemeListWidget.findItems(name, - QtCore.Qt.MatchExactly)[0] - newThemeIndex = self.ThemeListWidget.indexFromItem( - newThemeItem).row() - self.global_theme = unicode( - self.ThemeListWidget.item(newThemeIndex).text()) - newName = unicode(translate('ThemeManager', '%s (default)')) % \ - self.global_theme - self.ThemeListWidget.item(newThemeIndex).setText(newName) - QtCore.QSettings().setValue( - self.settingsSection + u'/global theme', - QtCore.QVariant(self.global_theme)) - Receiver.send_message(u'theme_update_global', self.global_theme) + if self.saveThemeName != name: + newThemeItem = self.ThemeListWidget.findItems(name, + QtCore.Qt.MatchExactly)[0] + newThemeIndex = self.ThemeListWidget.indexFromItem( + newThemeItem).row() + self.global_theme = unicode( + self.ThemeListWidget.item(newThemeIndex).text()) + newName = unicode(translate('ThemeManager', + '%s (default)')) % self.global_theme + self.ThemeListWidget.item(newThemeIndex).setText(newName) + QtCore.QSettings().setValue( + self.settingsSection + u'/global theme', + QtCore.QVariant(self.global_theme)) + Receiver.send_message(u'theme_update_global', + self.global_theme) self.editingDefault = False self.pushThemes() else: From 42619d455b03a2852c9102c26b4571ba6237bdee Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Wed, 21 Jul 2010 10:52:00 +0100 Subject: [PATCH 4/8] deleteTheme cleanups --- openlp/core/ui/thememanager.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 5f4b934c4..4deea519f 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -1,3 +1,4 @@ +import os.path # -*- coding: utf-8 -*- # vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 @@ -253,15 +254,14 @@ class ThemeManager(QtGui.QWidget): The theme to delete. """ self.themelist.remove(theme) - th = theme + u'.png' + thumb = theme + u'.png' try: - os.remove(os.path.join(self.path, th)) - os.remove(os.path.join(self.thumbPath, th)) + os.remove(os.path.join(self.path, thumb)) + os.remove(os.path.join(self.thumbPath, thumb)) encoding = get_filesystem_encoding() shutil.rmtree(os.path.join(self.path, theme).encode(encoding)) except OSError: - #if not present do not worry - pass + log.exception(u'Error deleting theme %s', theme) # As we do not reload the themes push out the change # Reaload the list as the internal lists and events need # to be triggered From 2691636e716183dabcc7fcc8eec08125986443d3 Mon Sep 17 00:00:00 2001 From: andreas Date: Wed, 21 Jul 2010 12:30:29 +0200 Subject: [PATCH 5/8] fixed Song Book publisher fixed Authors like "0123hallo" which cannot be splitted --- openlp/plugins/songs/forms/editsongform.py | 63 +++++++++++----------- 1 file changed, 33 insertions(+), 30 deletions(-) diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index c61b2435f..65e997a56 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -48,7 +48,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): """ QtGui.QDialog.__init__(self, parent) self.parent = parent - #can this be automated? + # can this be automated? self.width = 400 self.setupUi(self) # Connecting signals and slots @@ -171,7 +171,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): self.loadAuthors() self.loadTopics() self.loadBooks() - #it's a new song to preview is not possible + # it's a new song to preview is not possible self.previewButton.setVisible(False) def loadSong(self, id, preview): @@ -221,7 +221,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): self.CCLNumberEdit.setText(self.song.ccli_number) else: self.CCLNumberEdit.setText(u'') - #lazy xml migration for now + # lazy xml migration for now self.VerseListWidget.clear() self.VerseListWidget.setRowCount(0) self.VerseListWidget.setColumnWidth(0, self.width) @@ -263,7 +263,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): topic_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(topic.id)) self.TopicsListView.addItem(topic_name) self.TitleEditItem.setFocus(QtCore.Qt.OtherFocusReason) - #if not preview hide the preview button + # if not preview hide the preview button self.previewButton.setVisible(False) if preview: self.previewButton.setVisible(True) @@ -288,11 +288,15 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): if QtGui.QMessageBox.question(self, translate('SongsPlugin.EditSongForm', 'Add Author'), translate('SongsPlugin.EditSongForm', 'This author does not ' - 'exist, do you want to add them?'), + 'exist, do you want to add them?'), QtGui.QMessageBox.Yes | QtGui.QMessageBox.No, QtGui.QMessageBox.Yes) == QtGui.QMessageBox.Yes: - author = Author.populate(first_name=text.rsplit(u' ', 1)[0], - last_name=text.rsplit(u' ', 1)[1], display_name=text) + if text.find(' ') == -1: + author = Author.populate(first_name=u'', last_name=u'', + display_name=text) + else: + author = Author.populate(first_name=text.rsplit(u' ', 1)[0], + last_name=text.rsplit(u' ', 1)[1], display_name=text) self.songmanager.save_object(author, False) self.song.authors.append(author) author_item = QtGui.QListWidgetItem( @@ -324,9 +328,9 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): QtGui.QMessageBox.warning(self, translate('SongsPlugin.EditSongForm', 'No Author Selected'), translate('SongsPlugin.EditSongForm', 'You have not selected ' - 'a valid author. Either select an author from the list, ' - 'or type in a new author and click the "Add Author to ' - 'Song" button to add the new author.'), + 'a valid author. Either select an author from the list, ' + 'or type in a new author and click the "Add Author to ' + 'Song" button to add the new author.'), QtGui.QMessageBox.Ok, QtGui.QMessageBox.Ok) def onAuthorsListViewPressed(self): @@ -349,7 +353,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): if QtGui.QMessageBox.question(self, translate('SongsPlugin.EditSongForm', 'Add Topic'), translate('SongsPlugin.EditSongForm', 'This topic does not ' - 'exist, do you want to add it?'), + 'exist, do you want to add it?'), QtGui.QMessageBox.Yes | QtGui.QMessageBox.No, QtGui.QMessageBox.Yes) == QtGui.QMessageBox.Yes: topic = Topic.populate(name=text) @@ -382,9 +386,9 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): QtGui.QMessageBox.warning(self, translate('SongsPlugin.EditSongForm', 'No Topic Selected'), translate('SongsPlugin.EditSongForm', 'You have not selected ' - 'a valid topic. Either select a topic from the list, or ' - 'type in a new topic and click the "Add Topic to Song" ' - 'button to add the new topic.'), + 'a valid topic. Either select a topic from the list, or ' + 'type in a new topic and click the "Add Topic to Song" ' + 'button to add the new topic.'), QtGui.QMessageBox.Ok, QtGui.QMessageBox.Ok) def onTopicListViewPressed(self): @@ -408,7 +412,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): def onThemeComboChanged(self, item): if item == 0: - #None means no Theme + # None means no Theme self.song.theme_name = None else: them_name = unicode(self.ThemeSelectionComboItem.itemText(item)) @@ -445,7 +449,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): data = u'%s:%s' % (verse, subVerse) item.setData(QtCore.Qt.UserRole, QtCore.QVariant(data)) item.setText(afterText) - #number of lines has change so repaint the list moving the data + # number of lines has change so repaint the list moving the data if len(tempText.split(u'\n')) != len(afterText.split(u'\n')): tempList = {} tempId = {} @@ -484,7 +488,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): for count, parts in enumerate(match.split(u']---\n')): if len(parts) > 1: if count == 0: - #make sure the tag is correctly cased + # make sure the tag is correctly cased variant = u'%s%s' % \ (parts[0:1].upper(), parts[1:].lower()) else: @@ -521,7 +525,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): QtGui.QMessageBox.critical(self, translate('SongsPlugin.EditSongForm', 'Error'), translate('SongsPlugin.EditSongForm', - 'You need to type in a song title.')) + 'You need to type in a song title.')) return False if self.VerseListWidget.rowCount() == 0: self.SongTabWidget.setCurrentIndex(0) @@ -529,7 +533,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): QtGui.QMessageBox.critical(self, translate('SongsPlugin.EditSongForm', 'Error'), translate('SongsPlugin.EditSongForm', - 'You need to type in at least one verse.')) + 'You need to type in at least one verse.')) return False if self.AuthorsListView.count() == 0: self.SongTabWidget.setCurrentIndex(1) @@ -537,8 +541,8 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): answer = QtGui.QMessageBox.warning(self, translate('SongsPlugin.EditSongForm', 'Warning'), translate('SongsPlugin.EditSongForm', - 'You have not added any authors for this song. Do you ' - 'want to add an author now?'), + 'You have not added any authors for this song. Do you ' + 'want to add an author now?'), QtGui.QMessageBox.Yes | QtGui.QMessageBox.No) if answer == QtGui.QMessageBox.Yes: return False @@ -569,9 +573,9 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): QtGui.QMessageBox.critical(self, translate('SongsPlugin.EditSongForm', 'Error'), unicode(translate('SongsPlugin.EditSongForm', - 'The verse order is invalid. There is no verse ' - 'corresponding to %s. Valid entries are %s.')) % \ - (order_names[count], valid)) + 'The verse order is invalid. There is no verse ' + 'corresponding to %s. Valid entries are %s.')) % \ + (order_names[count], valid)) return False for count, verse in enumerate(verses): if verse not in order: @@ -580,10 +584,9 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): answer = QtGui.QMessageBox.warning(self, translate('SongsPlugin.EditSongForm', 'Warning'), unicode(translate('SongsPlugin.EditSongForm', - 'You have not used %s anywhere in the verse ' - 'order. Are you sure you want to save the song ' - 'like this?')) % \ - verse_names[count].replace(u':', u' '), + 'You have not used %s anywhere in the verse ' + 'order. Are you sure you want to save the song ' + 'like this?')) % verse_names[count].replace(u':', u' '), QtGui.QMessageBox.Yes | QtGui.QMessageBox.No) if answer == QtGui.QMessageBox.No: return False @@ -624,10 +627,10 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): if QtGui.QMessageBox.question(self, translate('SongsPlugin.EditSongForm', 'Add Book'), translate('SongsPlugin.EditSongForm', 'This song book does ' - 'not exist, do you want to add it?'), + 'not exist, do you want to add it?'), QtGui.QMessageBox.Yes | QtGui.QMessageBox.No, QtGui.QMessageBox.Yes) == QtGui.QMessageBox.Yes: - book = Book.populate(name=text) + book = Book.populate(name=text, publisher=u'') self.songmanager.save_object(book) self.song.book = book self.loadBooks() From cf02c7100126e24d52e3be32322ba53867b337b5 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Wed, 21 Jul 2010 13:11:32 +0100 Subject: [PATCH 6/8] Fix v2 song DB importing --- openlp/plugins/songs/lib/olpimport.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/plugins/songs/lib/olpimport.py b/openlp/plugins/songs/lib/olpimport.py index a73684e00..a2044b497 100644 --- a/openlp/plugins/songs/lib/olpimport.py +++ b/openlp/plugins/songs/lib/olpimport.py @@ -169,7 +169,7 @@ class OpenLPSongImport(object): else: new_song.authors.append(Author.populate( display_name=u'Author Unknown')) - if song.song_book_id != 0: + if song.book: existing_song_book = self.master_manager.get_object_filtered( Book, Book.name == song.book.name) if existing_song_book: From d368f15713b8d05c82c6068fca16f373ac8c0a07 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Wed, 21 Jul 2010 13:28:41 +0100 Subject: [PATCH 7/8] Import fix --- openlp/core/ui/thememanager.py | 1 - 1 file changed, 1 deletion(-) diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 4deea519f..1745e6030 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -1,4 +1,3 @@ -import os.path # -*- coding: utf-8 -*- # vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 From c4a59586a665984c3da5ac16765592e839d30b7e Mon Sep 17 00:00:00 2001 From: andreas Date: Wed, 21 Jul 2010 15:13:03 +0200 Subject: [PATCH 8/8] improvement + fix --- openlp/plugins/songs/forms/editsongform.py | 2 +- openlp/plugins/songs/forms/songmaintenanceform.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 65e997a56..440371c83 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -291,7 +291,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): 'exist, do you want to add them?'), QtGui.QMessageBox.Yes | QtGui.QMessageBox.No, QtGui.QMessageBox.Yes) == QtGui.QMessageBox.Yes: - if text.find(' ') == -1: + if text.find(u' ') == -1: author = Author.populate(first_name=u'', last_name=u'', display_name=text) else: diff --git a/openlp/plugins/songs/forms/songmaintenanceform.py b/openlp/plugins/songs/forms/songmaintenanceform.py index 67f60bfee..e0506e5bc 100644 --- a/openlp/plugins/songs/forms/songmaintenanceform.py +++ b/openlp/plugins/songs/forms/songmaintenanceform.py @@ -350,6 +350,8 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): book_id = self._getCurrentItemId(self.BooksListWidget) if book_id != -1: book = self.songmanager.get_object(Book, book_id) + if book.publisher is None: + book.publisher = u'' self.bookform.NameEdit.setText(book.name) self.bookform.PublisherEdit.setText(book.publisher) # Save the book's name and publisher for the case that they have to