From 96ed86a13a57d5c11a08656ce1a7b618efd27741 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Thu, 15 Jul 2010 23:45:55 +0100 Subject: [PATCH 1/3] Use populate() for DB objects --- openlp/plugins/songs/lib/songimport.py | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/openlp/plugins/songs/lib/songimport.py b/openlp/plugins/songs/lib/songimport.py index 0e950f18c..bf3b404cd 100644 --- a/openlp/plugins/songs/lib/songimport.py +++ b/openlp/plugins/songs/lib/songimport.py @@ -303,28 +303,22 @@ class SongImport(object): author = self.manager.get_object_filtered(Author, Author.display_name == authortext) if author is None: - author = Author() - author.display_name = authortext - author.last_name = authortext.split(u' ')[-1] - author.first_name = u' '.join(authortext.split(u' ')[:-1]) - self.manager.save_object(author) + author = Author.populate(display_name = authortext, + last_name=authortext.split(u' ')[-1], + first_name=u' '.join(authortext.split(u' ')[:-1])) song.authors.append(author) if self.song_book_name: song_book = self.manager.get_object_filtered(Book, Book.name == self.song_book_name) if song_book is None: - song_book = Book() - song_book.name = self.song_book_name - song_book.publisher = self.song_book_pub - self.manager.save_object(song_book) - song.song_book_id = song_book.id + song_book = Book.populate(name=self.song_book_name, + publisher=self.song_book_pub) + song.book = song_book for topictext in self.topics: topic = self.manager.get_object_filtered(Topic, Topic.name == topictext) if topic is None: - topic = Topic() - topic.name = topictext - self.manager.save_object(topic) + topic = Topic.populate(name=topictext) song.topics.append(topictext) self.manager.save_object(song) From 897929967ae6e92c24e74056e07d01c2e9feff48 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Fri, 16 Jul 2010 13:31:47 +0100 Subject: [PATCH 2/3] Add Theme fix and form tab ordering --- openlp/core/ui/amendthemedialog.py | 64 ------------------- openlp/core/ui/thememanager.py | 3 +- openlp/plugins/alerts/forms/alertdialog.py | 8 --- .../plugins/custom/forms/editcustomdialog.py | 11 ---- openlp/plugins/songs/forms/editsongdialog.py | 36 ----------- 5 files changed, 2 insertions(+), 120 deletions(-) diff --git a/openlp/core/ui/amendthemedialog.py b/openlp/core/ui/amendthemedialog.py index 45fdf236a..8fd26691f 100644 --- a/openlp/core/ui/amendthemedialog.py +++ b/openlp/core/ui/amendthemedialog.py @@ -654,70 +654,6 @@ class Ui_AmendThemeDialog(object): QtCore.QObject.connect(self.ThemeButtonBox, QtCore.SIGNAL(u'rejected()'), AmendThemeDialog.reject) QtCore.QMetaObject.connectSlotsByName(AmendThemeDialog) - AmendThemeDialog.setTabOrder(self.ThemeButtonBox, self.ThemeNameEdit) - AmendThemeDialog.setTabOrder(self.ThemeNameEdit, self.ThemeTabWidget) - AmendThemeDialog.setTabOrder(self.ThemeTabWidget, - self.BackgroundComboBox) - AmendThemeDialog.setTabOrder(self.BackgroundComboBox, - self.BackgroundTypeComboBox) - AmendThemeDialog.setTabOrder(self.BackgroundTypeComboBox, - self.Color1PushButton) - AmendThemeDialog.setTabOrder(self.Color1PushButton, - self.Color2PushButton) - AmendThemeDialog.setTabOrder(self.Color2PushButton, self.ImageLineEdit) - AmendThemeDialog.setTabOrder(self.ImageLineEdit, self.ImageToolButton) - AmendThemeDialog.setTabOrder(self.ImageToolButton, - self.GradientComboBox) - AmendThemeDialog.setTabOrder(self.GradientComboBox, - self.FontMainComboBox) - AmendThemeDialog.setTabOrder(self.FontMainComboBox, - self.FontMainColorPushButton) - AmendThemeDialog.setTabOrder(self.FontMainColorPushButton, - self.FontMainSizeSpinBox) - AmendThemeDialog.setTabOrder(self.FontMainSizeSpinBox, - self.FontMainWeightComboBox) - AmendThemeDialog.setTabOrder(self.FontMainWeightComboBox, - self.FontMainLineSpacingSpinBox) - AmendThemeDialog.setTabOrder(self.FontMainLineSpacingSpinBox, - self.FontMainDefaultCheckBox) - AmendThemeDialog.setTabOrder(self.FontMainDefaultCheckBox, - self.FontMainXSpinBox) - AmendThemeDialog.setTabOrder(self.FontMainXSpinBox, - self.FontMainYSpinBox) - AmendThemeDialog.setTabOrder(self.FontMainYSpinBox, - self.FontMainWidthSpinBox) - AmendThemeDialog.setTabOrder(self.FontMainWidthSpinBox, - self.FontMainHeightSpinBox) - AmendThemeDialog.setTabOrder(self.FontMainHeightSpinBox, - self.FontFooterComboBox) - AmendThemeDialog.setTabOrder(self.FontFooterComboBox, - self.FontFooterColorPushButton) - AmendThemeDialog.setTabOrder(self.FontFooterColorPushButton, - self.FontFooterSizeSpinBox) - AmendThemeDialog.setTabOrder(self.FontFooterSizeSpinBox, - self.FontFooterWeightComboBox) - AmendThemeDialog.setTabOrder(self.FontFooterWeightComboBox, - self.FontFooterDefaultCheckBox) - AmendThemeDialog.setTabOrder(self.FontFooterDefaultCheckBox, - self.FontFooterXSpinBox) - AmendThemeDialog.setTabOrder(self.FontFooterXSpinBox, - self.FontFooterYSpinBox) - AmendThemeDialog.setTabOrder(self.FontFooterYSpinBox, - self.FontFooterWidthSpinBox) - AmendThemeDialog.setTabOrder(self.FontFooterWidthSpinBox, - self.FontFooterHeightSpinBox) - AmendThemeDialog.setTabOrder(self.FontFooterHeightSpinBox, - self.OutlineCheckBox) - AmendThemeDialog.setTabOrder(self.OutlineCheckBox, - self.OutlineColorPushButton) - AmendThemeDialog.setTabOrder(self.OutlineColorPushButton, - self.ShadowCheckBox) - AmendThemeDialog.setTabOrder(self.ShadowCheckBox, - self.ShadowColorPushButton) - AmendThemeDialog.setTabOrder(self.ShadowColorPushButton, - self.HorizontalComboBox) - AmendThemeDialog.setTabOrder(self.HorizontalComboBox, - self.VerticalComboBox) def retranslateUi(self, AmendThemeDialog): AmendThemeDialog.setWindowTitle( diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index dd8c917af..d321630f4 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -118,6 +118,7 @@ class ThemeManager(QtGui.QWidget): self.checkThemesExists(self.thumbPath) self.amendThemeForm.path = self.path self.oldBackgroundImage = None + self.editingDefault = False # Last little bits of setting up self.global_theme = unicode(QtCore.QSettings().value( self.settingsSection + u'/global theme', @@ -184,7 +185,6 @@ class ThemeManager(QtGui.QWidget): Loads the settings for the theme that is to be edited and launches the theme editing form so the user can make their changes. """ - self.editingDefault = False if check_item_selected(self.ThemeListWidget, translate('ThemeManager', 'You must select a theme to edit.')): item = self.ThemeListWidget.currentItem() @@ -610,6 +610,7 @@ class ThemeManager(QtGui.QWidget): 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: # Don't close the dialog - allow the user to change the name of diff --git a/openlp/plugins/alerts/forms/alertdialog.py b/openlp/plugins/alerts/forms/alertdialog.py index 6e914d613..567fecd9c 100644 --- a/openlp/plugins/alerts/forms/alertdialog.py +++ b/openlp/plugins/alerts/forms/alertdialog.py @@ -120,14 +120,6 @@ class Ui_AlertDialog(object): QtCore.QObject.connect(self.CloseButton, QtCore.SIGNAL(u'clicked()'), AlertDialog.close) QtCore.QMetaObject.connectSlotsByName(AlertDialog) - AlertDialog.setTabOrder(self.AlertTextEdit, self.ParameterEdit) - AlertDialog.setTabOrder(self.ParameterEdit, self.AlertListWidget) - AlertDialog.setTabOrder(self.AlertListWidget, self.NewButton) - AlertDialog.setTabOrder(self.NewButton, self.SaveButton) - AlertDialog.setTabOrder(self.SaveButton, self.DeleteButton) - AlertDialog.setTabOrder(self.DeleteButton, self.DisplayButton) - AlertDialog.setTabOrder(self.DisplayButton, self.DisplayCloseButton) - AlertDialog.setTabOrder(self.DisplayCloseButton, self.CloseButton) def retranslateUi(self, AlertDialog): AlertDialog.setWindowTitle( diff --git a/openlp/plugins/custom/forms/editcustomdialog.py b/openlp/plugins/custom/forms/editcustomdialog.py index fb980a224..64b309a5f 100644 --- a/openlp/plugins/custom/forms/editcustomdialog.py +++ b/openlp/plugins/custom/forms/editcustomdialog.py @@ -136,17 +136,6 @@ class Ui_customEditDialog(object): QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'rejected()'), customEditDialog.closePressed) QtCore.QMetaObject.connectSlotsByName(customEditDialog) - customEditDialog.setTabOrder(self.TitleEdit, self.VerseTextEdit) - customEditDialog.setTabOrder(self.VerseTextEdit, self.AddButton) - customEditDialog.setTabOrder(self.AddButton, self.VerseListView) - customEditDialog.setTabOrder(self.VerseListView, self.EditButton) - customEditDialog.setTabOrder(self.EditButton, self.EditAllButton) - customEditDialog.setTabOrder(self.EditAllButton, self.SaveButton) - customEditDialog.setTabOrder(self.SaveButton, self.DeleteButton) - customEditDialog.setTabOrder(self.DeleteButton, self.CreditEdit) - customEditDialog.setTabOrder(self.CreditEdit, self.UpButton) - customEditDialog.setTabOrder(self.UpButton, self.DownButton) - customEditDialog.setTabOrder(self.DownButton, self.ThemeComboBox) def retranslateUi(self, customEditDialog): customEditDialog.setWindowTitle( diff --git a/openlp/plugins/songs/forms/editsongdialog.py b/openlp/plugins/songs/forms/editsongdialog.py index ce3291988..43684c1a9 100644 --- a/openlp/plugins/songs/forms/editsongdialog.py +++ b/openlp/plugins/songs/forms/editsongdialog.py @@ -394,48 +394,12 @@ class Ui_EditSongDialog(object): QtGui.QDialogButtonBox.Cancel | QtGui.QDialogButtonBox.Save) self.ButtonBox.setObjectName(u'ButtonBox') self.verticalLayout.addWidget(self.ButtonBox) - self.retranslateUi(EditSongDialog) QtCore.QObject.connect(self.ButtonBox, QtCore.SIGNAL(u'rejected()'), EditSongDialog.closePressed) QtCore.QObject.connect(self.ButtonBox, QtCore.SIGNAL(u'accepted()'), EditSongDialog.accept) QtCore.QMetaObject.connectSlotsByName(EditSongDialog) - EditSongDialog.setTabOrder(self.SongTabWidget, self.TitleEditItem) - EditSongDialog.setTabOrder(self.TitleEditItem, self.AlternativeEdit) - EditSongDialog.setTabOrder(self.AlternativeEdit, self.VerseListWidget) - EditSongDialog.setTabOrder(self.VerseListWidget, self.VerseAddButton) - EditSongDialog.setTabOrder(self.VerseAddButton, self.VerseEditButton) - EditSongDialog.setTabOrder(self.VerseEditButton, - self.VerseEditAllButton) - EditSongDialog.setTabOrder(self.VerseEditAllButton, - self.VerseDeleteButton) - EditSongDialog.setTabOrder(self.VerseDeleteButton, self.VerseOrderEdit) - EditSongDialog.setTabOrder(self.VerseOrderEdit, - self.AuthorsSelectionComboItem) - EditSongDialog.setTabOrder(self.AuthorsSelectionComboItem, - self.AuthorAddButton) - EditSongDialog.setTabOrder(self.AuthorAddButton, self.AuthorsListView) - EditSongDialog.setTabOrder(self.AuthorsListView, - self.AuthorRemoveButton) - EditSongDialog.setTabOrder(self.AuthorRemoveButton, - self.MaintenanceButton) - EditSongDialog.setTabOrder(self.MaintenanceButton, self.SongTopicCombo) - EditSongDialog.setTabOrder(self.SongTopicCombo, self.TopicAddButton) - EditSongDialog.setTabOrder(self.TopicAddButton, self.TopicsListView) - EditSongDialog.setTabOrder(self.TopicsListView, self.TopicRemoveButton) - EditSongDialog.setTabOrder(self.TopicRemoveButton, self.SongbookCombo) - EditSongDialog.setTabOrder(self.SongbookCombo, - self.ThemeSelectionComboItem) - EditSongDialog.setTabOrder(self.ThemeSelectionComboItem, - self.ThemeAddButton) - EditSongDialog.setTabOrder(self.ThemeAddButton, self.CopyrightEditItem) - EditSongDialog.setTabOrder(self.CopyrightEditItem, - self.CopyrightInsertButton) - EditSongDialog.setTabOrder(self.CopyrightInsertButton, - self.CCLNumberEdit) - EditSongDialog.setTabOrder(self.CCLNumberEdit, self.CommentsEdit) - EditSongDialog.setTabOrder(self.CommentsEdit, self.ButtonBox) def retranslateUi(self, EditSongDialog): EditSongDialog.setWindowTitle( From 65d5f89302f1fdd65b71f6654075fb01fbf6df87 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Fri, 16 Jul 2010 19:53:49 +0100 Subject: [PATCH 3/3] Fix English and alignment --- .../songs/forms/songmaintenanceform.py | 32 ++++++++----------- 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/openlp/plugins/songs/forms/songmaintenanceform.py b/openlp/plugins/songs/forms/songmaintenanceform.py index d50bf747f..2a848ad98 100644 --- a/openlp/plugins/songs/forms/songmaintenanceform.py +++ b/openlp/plugins/songs/forms/songmaintenanceform.py @@ -137,7 +137,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): def checkAuthor(self, new_author, edit=False): """ - Returns False when the given Author is already in the list elsewise + Returns False if the given Author is already in the list otherwise True. """ authors = self.songmanager.get_all_objects_filtered(Author, @@ -163,11 +163,10 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): def checkTopic(self, new_topic, edit=False): """ - Returns False when the given Topic is already in the list elsewise True. + Returns False if the given Topic is already in the list otherwise True. """ topics = self.songmanager.get_all_objects_filtered(Topic, - Topic.name == new_topic.name - ) + Topic.name == new_topic.name) if len(topics) > 0: # If we edit an existing Topic, we need to make sure that we do # not return False when nothing has changed (because this would @@ -184,25 +183,22 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): def checkBook(self, new_book, edit=False): """ - Returns False when the given Book is already in the list elsewise True. + Returns False if the given Book is already in the list otherwise True. """ books = self.songmanager.get_all_objects_filtered(Book, - and_( - Book.name == new_book.name, - Book.publisher == new_book.publisher - ) - ) + and_(Book.name == new_book.name, + Book.publisher == new_book.publisher)) if len(books) > 0: - # If we edit an existing Book, we need to make sure that we do - # not return False when nothing has changed (because this would - # cause an error message later on). - if edit: - if books[0].id == new_book.id: - return True - else: - return False + # If we edit an existing Book, we need to make sure that we do + # not return False when nothing has changed (because this would + # cause an error message later on). + if edit: + if books[0].id == new_book.id: + return True else: return False + else: + return False else: return True