From d4780cb37b632ed3af222c5b90e968d499d74c6a Mon Sep 17 00:00:00 2001 From: andreas Date: Mon, 12 Jul 2010 22:56:09 +0200 Subject: [PATCH 01/21] code style --- openlp/core/ui/maindisplay.py | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index b0ef8eaf4..69c51f551 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -167,7 +167,7 @@ class DisplayWidget(QtGui.QGraphicsView): def keyPressEvent(self, event): if isinstance(event, QtGui.QKeyEvent): - #here accept the event and do something + # here accept the event and do something if event.key() == QtCore.Qt.Key_Up: Receiver.send_message(u'slidecontroller_live_previous') event.accept() @@ -233,8 +233,8 @@ class MainDisplay(DisplayWidget): self.setupBlank() self.blankFrame = None self.frame = None - #Hide desktop for now until we know where to put it - #and what size it should be. + # Hide desktop for now until we know where to put it + # and what size it should be. self.setVisible(False) def setup(self): @@ -245,13 +245,12 @@ class MainDisplay(DisplayWidget): self.screens, self.screens.monitor_number)) self.setVisible(False) self.screen = self.screens.current - #Sort out screen locations and sizes + # Sort out screen locations and sizes self.setGeometry(self.screen[u'size']) - self.scene.setSceneRect(0, 0, self.size().width(), - self.size().height()) + self.scene.setSceneRect(0, 0, self.size().width(), self.size().height()) self.webView.setGeometry(0, 0, self.size().width(), self.size().height()) - #Build a custom splash screen + # Build a custom splash screen. self.initialFrame = QtGui.QImage( self.screen[u'size'].width(), self.screen[u'size'].height(), @@ -266,7 +265,7 @@ class MainDisplay(DisplayWidget): splash_image) self.displayImage(self.initialFrame) self.repaint() - #Build a Black screen + # Build a Black screen. painter = QtGui.QPainter() self.blankFrame = QtGui.QImage( self.screen[u'size'].width(), @@ -274,11 +273,11 @@ class MainDisplay(DisplayWidget): QtGui.QImage.Format_ARGB32_Premultiplied) painter.begin(self.blankFrame) painter.fillRect(self.blankFrame.rect(), QtCore.Qt.black) - #build a blank transparent image + # Build a blank transparent image. self.transparent = QtGui.QPixmap( self.screen[u'size'].width(), self.screen[u'size'].height()) self.transparent.fill(QtCore.Qt.transparent) -# self.displayText.setPixmap(self.transparent) + #self.displayText.setPixmap(self.transparent) #self.frameView(self.transparent) # To display or not to display? if not self.screen[u'primary']: @@ -297,13 +296,13 @@ class MainDisplay(DisplayWidget): self.webView = QtWebKit.QWebView() self.page = self.webView.page() self.videoDisplay = self.page.mainFrame() - self.videoDisplay.setScrollBarPolicy(QtCore.Qt.Vertical, + self.videoDisplay.setScrollBarPolicy(QtCore.Qt.Vertical, QtCore.Qt.ScrollBarAlwaysOff) - self.videoDisplay.setScrollBarPolicy(QtCore.Qt.Horizontal, + self.videoDisplay.setScrollBarPolicy(QtCore.Qt.Horizontal, QtCore.Qt.ScrollBarAlwaysOff) self.proxy = QtGui.QGraphicsProxyWidget() self.proxy.setWidget(self.webView) - self.proxy.setWindowFlags(QtCore.Qt.Window | + self.proxy.setWindowFlags(QtCore.Qt.Window | QtCore.Qt.FramelessWindowHint) self.proxy.setZValue(1) self.scene.addItem(self.proxy) @@ -367,7 +366,7 @@ class MainDisplay(DisplayWidget): """ log.debug(u'showDisplay') self.displayBlank.setPixmap(self.transparent) - #Trigger actions when display is active again + # Trigger actions when display is active again. Receiver.send_message(u'maindisplay_active') def addImageWithText(self, frame): @@ -417,8 +416,7 @@ class MainDisplay(DisplayWidget): log.debug(u'adddisplayVideo') self.displayImage(self.transparent) self.videoDisplay.setHtml(HTMLVIDEO % - (path, self.screen[u'size'].width(), - self.screen[u'size'].height())) + (path, self.screen[u'size'].width(), self.screen[u'size'].height())) def frameView(self, frame, transition=False): """ @@ -506,7 +504,7 @@ class VideoDisplay(Phonon.VideoWidget): def keyPressEvent(self, event): if isinstance(event, QtGui.QKeyEvent): - #here accept the event and do something + # here accept the event and do something if event.key() == QtCore.Qt.Key_Escape: self.onMediaStop() event.accept() @@ -521,7 +519,7 @@ class VideoDisplay(Phonon.VideoWidget): log.debug(u'VideoDisplay Setup %s for %s ' % (self.screens, self.screens.monitor_number)) self.screen = self.screens.current - #Sort out screen locations and sizes + # Sort out screen locations and sizes. self.setGeometry(self.screen[u'size']) # To display or not to display? if not self.screen[u'primary']: # and self.isVisible(): From 1031125932dff7622656bf377e2fa8ba7b397264 Mon Sep 17 00:00:00 2001 From: andreas Date: Mon, 12 Jul 2010 23:02:06 +0200 Subject: [PATCH 02/21] code style --- openlp/core/ui/maindisplay.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 69c51f551..6c52c1a23 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -245,7 +245,7 @@ class MainDisplay(DisplayWidget): self.screens, self.screens.monitor_number)) self.setVisible(False) self.screen = self.screens.current - # Sort out screen locations and sizes + # Sort out screen locations and sizes. self.setGeometry(self.screen[u'size']) self.scene.setSceneRect(0, 0, self.size().width(), self.size().height()) self.webView.setGeometry(0, 0, self.size().width(), @@ -296,13 +296,13 @@ class MainDisplay(DisplayWidget): self.webView = QtWebKit.QWebView() self.page = self.webView.page() self.videoDisplay = self.page.mainFrame() - self.videoDisplay.setScrollBarPolicy(QtCore.Qt.Vertical, + self.videoDisplay.setScrollBarPolicy(QtCore.Qt.Vertical, QtCore.Qt.ScrollBarAlwaysOff) - self.videoDisplay.setScrollBarPolicy(QtCore.Qt.Horizontal, + self.videoDisplay.setScrollBarPolicy(QtCore.Qt.Horizontal, QtCore.Qt.ScrollBarAlwaysOff) self.proxy = QtGui.QGraphicsProxyWidget() self.proxy.setWidget(self.webView) - self.proxy.setWindowFlags(QtCore.Qt.Window | + self.proxy.setWindowFlags(QtCore.Qt.Window | QtCore.Qt.FramelessWindowHint) self.proxy.setZValue(1) self.scene.addItem(self.proxy) @@ -546,10 +546,10 @@ class VideoDisplay(Phonon.VideoWidget): # if it is triggered from the plugin # """ # log.debug(u'VideoDisplay Queue new media message %s' % message) -# #If not file take the stored one +# # If not file take the stored one. # if not message: # message = self.message -# # still no file name then stop as it was a normal video stopping +# # Still no file name then stop as it was a normal video stopping. # if message: # self.mediaObject.setCurrentSource(Phonon.MediaSource(message)) # self.message = message From eaf2f568f44a455b17bfcf525909e5b9a2ab0bfa Mon Sep 17 00:00:00 2001 From: andreas Date: Fri, 16 Jul 2010 11:00:20 +0200 Subject: [PATCH 03/21] error messages added --- .../songs/forms/songmaintenanceform.py | 45 ++++++++++++++++--- 1 file changed, 39 insertions(+), 6 deletions(-) diff --git a/openlp/plugins/songs/forms/songmaintenanceform.py b/openlp/plugins/songs/forms/songmaintenanceform.py index d50bf747f..54289767f 100644 --- a/openlp/plugins/songs/forms/songmaintenanceform.py +++ b/openlp/plugins/songs/forms/songmaintenanceform.py @@ -216,11 +216,16 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): if self.checkAuthor(author): if self.songmanager.save_object(author): self.resetAuthors() + else: + QtGui.QMessageBox.critical(self, + translate('SongsPlugin.SongMaintenanceForm', 'Error'), + translate('SongsPlugin.SongMaintenanceForm', + 'Could not add your author.')) else: QtGui.QMessageBox.critical(self, translate('SongsPlugin.SongMaintenanceForm', 'Error'), translate('SongsPlugin.SongMaintenanceForm', - 'Could not add your author.')) + 'Could not add your author, because he already exists.')) def onTopicAddButtonClick(self): if self.topicform.exec_(): @@ -228,11 +233,16 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): if self.checkTopic(topic): if self.songmanager.save_object(topic): self.resetTopics() + else: + QtGui.QMessageBox.critical(self, + translate('SongsPlugin.SongMaintenanceForm', 'Error'), + translate('SongsPlugin.SongMaintenanceForm', + 'Could not add your topic.')) else: QtGui.QMessageBox.critical(self, translate('SongsPlugin.SongMaintenanceForm', 'Error'), translate('SongsPlugin.SongMaintenanceForm', - 'Could not add your topic.')) + 'Could not add your topic, because it already exists.')) def onBookAddButtonClick(self): if self.bookform.exec_(): @@ -242,11 +252,16 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): if self.checkBook(book): if self.songmanager.save_object(book): self.resetBooks() + else: + QtGui.QMessageBox.critical(self, + translate('SongsPlugin.SongMaintenanceForm', 'Error'), + translate('SongsPlugin.SongMaintenanceForm', + 'Could not add your book.')) else: QtGui.QMessageBox.critical(self, translate('SongsPlugin.SongMaintenanceForm', 'Error'), translate('SongsPlugin.SongMaintenanceForm', - 'Could not add your book.')) + 'Could not add your book, because it already exists.')) def onAuthorEditButtonClick(self): author_id = self._getCurrentItemId(self.AuthorsListWidget) @@ -270,6 +285,11 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): if self.checkAuthor(author, True): if self.songmanager.save_object(author): self.resetAuthors() + else: + QtGui.QMessageBox.critical(self, + translate('SongsPlugin.SongMaintenanceForm', 'Error'), + translate('SongsPlugin.SongMaintenanceForm', + 'Could not save your changes.')) else: # We restore the author's old first and last name as well as # his display name. @@ -279,7 +299,8 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): QtGui.QMessageBox.critical(self, translate('SongsPlugin.SongMaintenanceForm', 'Error'), translate('SongsPlugin.SongMaintenanceForm', - 'Could not save your author.')) + 'Could not save your modified author, because he ' + 'already exists.')) def onTopicEditButtonClick(self): topic_id = self._getCurrentItemId(self.TopicsListWidget) @@ -293,13 +314,19 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): if self.checkTopic(topic, True): if self.songmanager.save_object(topic): self.resetTopics() + else: + QtGui.QMessageBox.critical(self, + translate('SongsPlugin.SongMaintenanceForm', 'Error'), + translate('SongsPlugin.SongMaintenanceForm', + 'Could not save your changes.')) else: # We restore the topics's old name. topic.name = temp_name QtGui.QMessageBox.critical(self, translate('SongsPlugin.SongMaintenanceForm', 'Error'), translate('SongsPlugin.SongMaintenanceForm', - 'Could not save your topic.')) + 'Could not save your modified topic, because it ' + 'already exists.')) def onBookEditButtonClick(self): book_id = self._getCurrentItemId(self.BooksListWidget) @@ -317,6 +344,11 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): if self.checkBook(book, True): if self.songmanager.save_object(book): self.resetBooks() + else: + QtGui.QMessageBox.critical(self, + translate('SongsPlugin.SongMaintenanceForm', 'Error'), + translate('SongsPlugin.SongMaintenanceForm', + 'Could not save your changes.')) else: # We restore the book's old name and publisher. book.name = temp_name @@ -324,7 +356,8 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): QtGui.QMessageBox.critical(self, translate('SongsPlugin.SongMaintenanceForm', 'Error'), translate('SongsPlugin.SongMaintenanceForm', - 'Could not save your book.')) + 'Could not save your modified book, because it already ' + 'exists.')) def onAuthorDeleteButtonClick(self): """ From 853ae906d367bad78e6506eeef2ca685e523d975 Mon Sep 17 00:00:00 2001 From: andreas Date: Fri, 16 Jul 2010 11:09:11 +0200 Subject: [PATCH 04/21] reverted changed done before we official changed line length from 79 to 80 --- openlp/plugins/bibles/bibleplugin.py | 6 +++--- openlp/plugins/bibles/lib/mediaitem.py | 12 ++++-------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/openlp/plugins/bibles/bibleplugin.py b/openlp/plugins/bibles/bibleplugin.py index 10a4c9551..d4593c6d8 100644 --- a/openlp/plugins/bibles/bibleplugin.py +++ b/openlp/plugins/bibles/bibleplugin.py @@ -40,7 +40,7 @@ class BiblePlugin(Plugin): self.weight = -9 self.icon_path = u':/plugins/plugin_bibles.png' self.icon = build_icon(self.icon_path) - #Register the bible Manager + # Register the bible Manager. self.status = PluginStatus.Active self.manager = None @@ -62,7 +62,7 @@ class BiblePlugin(Plugin): return BiblesTab(self.name) def getMediaManagerItem(self): - # Create the BibleManagerItem object + # Create the BibleManagerItem object. return BibleMediaItem(self, self.icon, self.name) def addImportMenuItem(self, import_menu): @@ -71,7 +71,7 @@ class BiblePlugin(Plugin): import_menu.addAction(self.ImportBibleItem) self.ImportBibleItem.setText( translate('BiblePlugin', '&Bible')) - # Signals and slots + # signals and slots QtCore.QObject.connect(self.ImportBibleItem, QtCore.SIGNAL(u'triggered()'), self.onBibleImportClick) self.ImportBibleItem.setVisible(False) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 9324e74ce..4063edec7 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -129,8 +129,7 @@ class BibleMediaItem(MediaManagerItem): self.QuickClearLabel.setObjectName(u'QuickSearchLabel') self.QuickLayout.addWidget(self.QuickClearLabel, 4, 0, 1, 1) self.ClearQuickSearchComboBox = QtGui.QComboBox(self.QuickTab) - self.ClearQuickSearchComboBox.setObjectName( - u'ClearQuickSearchComboBox') + self.ClearQuickSearchComboBox.setObjectName(u'ClearQuickSearchComboBox') self.QuickLayout.addWidget(self.ClearQuickSearchComboBox, 4, 1, 1, 2) self.QuickSearchButtonLayout = QtGui.QHBoxLayout() self.QuickSearchButtonLayout.setMargin(0) @@ -168,8 +167,7 @@ class BibleMediaItem(MediaManagerItem): self.AdvancedVersionComboBox.setObjectName(u'AdvancedVersionComboBox') self.AdvancedLayout.addWidget(self.AdvancedVersionComboBox, 0, 1, 1, 2) self.AdvancedSecondBibleLabel = QtGui.QLabel(self.AdvancedTab) - self.AdvancedSecondBibleLabel.setObjectName( - u'AdvancedSecondBibleLabel') + self.AdvancedSecondBibleLabel.setObjectName(u'AdvancedSecondBibleLabel') self.AdvancedLayout.addWidget(self.AdvancedSecondBibleLabel, 1, 0, 1, 1) self.AdvancedSecondBibleComboBox = QtGui.QComboBox(self.AdvancedTab) self.AdvancedSecondBibleComboBox.setSizeAdjustPolicy( @@ -223,8 +221,7 @@ class BibleMediaItem(MediaManagerItem): u'AdvancedSearchButtonLayout') self.AdvancedSearchButtonSpacer = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) - self.AdvancedSearchButtonLayout.addItem( - self.AdvancedSearchButtonSpacer) + self.AdvancedSearchButtonLayout.addItem(self.AdvancedSearchButtonSpacer) self.AdvancedSearchButton = QtGui.QPushButton(self.AdvancedTab) self.AdvancedSearchButton.setObjectName(u'AdvancedSearchButton') self.AdvancedSearchButtonLayout.addWidget(self.AdvancedSearchButton) @@ -618,8 +615,7 @@ class BibleMediaItem(MediaManagerItem): else: self.AdvancedSearchButton.setEnabled(True) self.AdvancedMessage.setText(u'') - self.adjustComboBox(1, self.chapters_from, - self.AdvancedFromChapter) + self.adjustComboBox(1, self.chapters_from, self.AdvancedFromChapter) self.adjustComboBox(1, self.chapters_from, self.AdvancedToChapter) self.adjustComboBox(1, self.verses, self.AdvancedFromVerse) self.adjustComboBox(1, self.verses, self.AdvancedToVerse) From 0c038095265618c5f252a2b227ed1a2d50bc3584 Mon Sep 17 00:00:00 2001 From: andreas Date: Fri, 16 Jul 2010 11:16:40 +0200 Subject: [PATCH 05/21] comment cleanup --- openlp/core/ui/maindisplay.py | 2 +- openlp/core/ui/mainwindow.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 6c52c1a23..90be52925 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -167,7 +167,7 @@ class DisplayWidget(QtGui.QGraphicsView): def keyPressEvent(self, event): if isinstance(event, QtGui.QKeyEvent): - # here accept the event and do something + # Here accept the event and do something. if event.key() == QtCore.Qt.Key_Up: Receiver.send_message(u'slidecontroller_live_previous') event.accept() diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index ec34a483b..b014747a2 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -114,7 +114,7 @@ class Ui_MainWindow(object): MainWindow.setSizePolicy(sizePolicy) MainIcon = build_icon(u':/icon/openlp-logo-16x16.png') MainWindow.setWindowIcon(MainIcon) - # Set up the main container, which contains all the other form widgets + # Set up the main container, which contains all the other form widgets. self.MainContent = QtGui.QWidget(MainWindow) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) From 1050e216e1952c3a188cb14b331c860b1ffecddb Mon Sep 17 00:00:00 2001 From: andreas Date: Fri, 16 Jul 2010 11:19:02 +0200 Subject: [PATCH 06/21] comment cleanup --- openlp/core/ui/maindisplay.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 90be52925..099c75ab5 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -504,7 +504,7 @@ class VideoDisplay(Phonon.VideoWidget): def keyPressEvent(self, event): if isinstance(event, QtGui.QKeyEvent): - # here accept the event and do something + # Here accept the event and do something. if event.key() == QtCore.Qt.Key_Escape: self.onMediaStop() event.accept() From e11ebea96333715a0df7ade2d6ee930d44b35e64 Mon Sep 17 00:00:00 2001 From: andreas Date: Fri, 16 Jul 2010 15:22:53 +0200 Subject: [PATCH 07/21] error messages changes --- openlp/plugins/songs/forms/authorsform.py | 2 +- openlp/plugins/songs/forms/songmaintenanceform.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/openlp/plugins/songs/forms/authorsform.py b/openlp/plugins/songs/forms/authorsform.py index c219b12ac..fdc704294 100644 --- a/openlp/plugins/songs/forms/authorsform.py +++ b/openlp/plugins/songs/forms/authorsform.py @@ -97,7 +97,7 @@ class AuthorsForm(QtGui.QDialog, Ui_AuthorsDialog): if QtGui.QMessageBox.critical( self, translate('SongsPlugin.AuthorsForm', 'Error'), translate('SongsPlugin.AuthorsForm', - 'You haven\'t set a display name for the ' + 'You have not set a display name for the ' 'author, would you like me to combine the first and ' 'last names for you?'), QtGui.QMessageBox.StandardButtons( diff --git a/openlp/plugins/songs/forms/songmaintenanceform.py b/openlp/plugins/songs/forms/songmaintenanceform.py index 54289767f..ae37aab95 100644 --- a/openlp/plugins/songs/forms/songmaintenanceform.py +++ b/openlp/plugins/songs/forms/songmaintenanceform.py @@ -225,7 +225,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): QtGui.QMessageBox.critical(self, translate('SongsPlugin.SongMaintenanceForm', 'Error'), translate('SongsPlugin.SongMaintenanceForm', - 'Could not add your author, because he already exists.')) + 'This author already exists.')) def onTopicAddButtonClick(self): if self.topicform.exec_(): @@ -242,7 +242,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): QtGui.QMessageBox.critical(self, translate('SongsPlugin.SongMaintenanceForm', 'Error'), translate('SongsPlugin.SongMaintenanceForm', - 'Could not add your topic, because it already exists.')) + 'This topic already exists.')) def onBookAddButtonClick(self): if self.bookform.exec_(): @@ -261,7 +261,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): QtGui.QMessageBox.critical(self, translate('SongsPlugin.SongMaintenanceForm', 'Error'), translate('SongsPlugin.SongMaintenanceForm', - 'Could not add your book, because it already exists.')) + 'This book already exists.')) def onAuthorEditButtonClick(self): author_id = self._getCurrentItemId(self.AuthorsListWidget) From fedde147aeace7f3c20686bccd9c649e06d91585 Mon Sep 17 00:00:00 2001 From: andreas Date: Fri, 16 Jul 2010 18:39:18 +0200 Subject: [PATCH 08/21] started working on 'merging' song books, topics, authors (NOT finished yet) --- .../songs/forms/songmaintenanceform.py | 47 +++++++++++++++---- 1 file changed, 39 insertions(+), 8 deletions(-) diff --git a/openlp/plugins/songs/forms/songmaintenanceform.py b/openlp/plugins/songs/forms/songmaintenanceform.py index ae37aab95..5aac9d887 100644 --- a/openlp/plugins/songs/forms/songmaintenanceform.py +++ b/openlp/plugins/songs/forms/songmaintenanceform.py @@ -28,7 +28,7 @@ from sqlalchemy.sql import and_ from openlp.core.lib import translate from openlp.plugins.songs.forms import AuthorsForm, TopicsForm, SongBookForm -from openlp.plugins.songs.lib.db import Author, Book, Topic +from openlp.plugins.songs.lib.db import Author, Book, Topic, Song from songmaintenancedialog import Ui_SongMaintenanceDialog class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): @@ -188,7 +188,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): """ books = self.songmanager.get_all_objects_filtered(Book, and_( - Book.name == new_book.name, + Book.name == new_book.name, Book.publisher == new_book.publisher ) ) @@ -349,15 +349,46 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): translate('SongsPlugin.SongMaintenanceForm', 'Error'), translate('SongsPlugin.SongMaintenanceForm', 'Could not save your changes.')) + elif self.mergeItems(Book, book): + self.resetBooks() else: - # We restore the book's old name and publisher. + # We restore the book's old name and publisher, because + # the user did not want to merge the two topics. book.name = temp_name book.publisher = temp_publisher - QtGui.QMessageBox.critical(self, - translate('SongsPlugin.SongMaintenanceForm', 'Error'), - translate('SongsPlugin.SongMaintenanceForm', - 'Could not save your modified book, because it already ' - 'exists.')) + + def mergeItems(self, item_class, existing_item): + ''' + Called when a song book is edited, but the modified song book is a + duplicate (of an existing one). The user can merges the modified item + with the existing one in terms to be able to fix e. g. spelling mistakes in + the name. + ''' + if QtGui.QMessageBox.critical(self, + translate('SongsPlugin.SongMaintenanceForm', 'Error'), + translate('SongsPlugin.SongMaintenanceForm', 'The book "bla"' + 'already exists. Would you like to make songs with book "blu" use ' + 'the existing book "bla"?'), + QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.No | \ + QtGui.QMessageBox.Yes)) == QtGui.QMessageBox.Yes: + #if item_class == Author: + #if item_class == Topic: + if item_class == Book: + songs = self.songmanager.get_all_objects_filtered(Song, + Song.song_book_id == existing_item.id) + book = self.songmanager.get_object_filtered(Book, + and_( + Book.name == existing_item.name, + Book.publisher == existing_item.publisher + ) + ) + for song in songs: + song.song_book_id = book.id + self.songmanager.save_object(song) + self.songmanager.delete_object(Book, existing_item.id) + return True + else: + return False def onAuthorDeleteButtonClick(self): """ From 1f3656f7926fd6ee2c4b41fedcf1c33ac7edc249 Mon Sep 17 00:00:00 2001 From: andreas Date: Fri, 16 Jul 2010 20:20:18 +0200 Subject: [PATCH 09/21] continued working on 'merging' song books, topics, authors (NOT finished yet) --- .../songs/forms/songmaintenanceform.py | 80 +++++++++++-------- 1 file changed, 47 insertions(+), 33 deletions(-) diff --git a/openlp/plugins/songs/forms/songmaintenanceform.py b/openlp/plugins/songs/forms/songmaintenanceform.py index 5aac9d887..6737898bd 100644 --- a/openlp/plugins/songs/forms/songmaintenanceform.py +++ b/openlp/plugins/songs/forms/songmaintenanceform.py @@ -28,7 +28,7 @@ from sqlalchemy.sql import and_ from openlp.core.lib import translate from openlp.plugins.songs.forms import AuthorsForm, TopicsForm, SongBookForm -from openlp.plugins.songs.lib.db import Author, Book, Topic, Song +from openlp.plugins.songs.lib.db import Author, Book, Topic, Song from songmaintenancedialog import Ui_SongMaintenanceDialog class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): @@ -319,7 +319,16 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): translate('SongsPlugin.SongMaintenanceForm', 'Error'), translate('SongsPlugin.SongMaintenanceForm', 'Could not save your changes.')) - else: + elif QtGui.QMessageBox.critical(self, + translate('SongsPlugin.SongMaintenanceForm', 'Error'), + translate('SongsPlugin.SongMaintenanceForm', 'The topic %s ' + 'already exists. Would you like to make songs with topic %s ' + 'use the existing topic %s?' % (topic.name, temp_name, + topic.name)), + QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.No | \ + QtGui.QMessageBox.Yes)) == QtGui.QMessageBox.Yes: + self.mergeTopics(topic) + self.resetTopics() # We restore the topics's old name. topic.name = temp_name QtGui.QMessageBox.critical(self, @@ -349,7 +358,15 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): translate('SongsPlugin.SongMaintenanceForm', 'Error'), translate('SongsPlugin.SongMaintenanceForm', 'Could not save your changes.')) - elif self.mergeItems(Book, book): + elif QtGui.QMessageBox.critical(self, + translate('SongsPlugin.SongMaintenanceForm', 'Error'), + translate('SongsPlugin.SongMaintenanceForm', 'The book %s ' + 'already exists. Would you like to make songs with book %s ' + 'use the existing book %s?' % (book.name, temp_name, + book.name)), + QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.No | \ + QtGui.QMessageBox.Yes)) == QtGui.QMessageBox.Yes: + self.mergeBooks(book) self.resetBooks() else: # We restore the book's old name and publisher, because @@ -357,38 +374,35 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): book.name = temp_name book.publisher = temp_publisher - def mergeItems(self, item_class, existing_item): + #def mergeAuthors(selfs, existing_author): + +# def mergeTopics(self, existing_topic): +# ''' +# ''' +# new_topic = self.songmanager.get_object_filtered(Topic, +# Topic.name == existing_topic.name) +# songs = self.songmanager.get_all_objects_filtered(....., +# songs_topics.topic_id == existing_topic.id) +# for song in songs: +# song.songs_topic.id = new_topic.id +# self.songmanager.save_object(song) +# self.songmanager.delete_object(Book, existing_topic.id) + + def mergeBooks(self, existing_book): ''' - Called when a song book is edited, but the modified song book is a - duplicate (of an existing one). The user can merges the modified item - with the existing one in terms to be able to fix e. g. spelling mistakes in - the name. ''' - if QtGui.QMessageBox.critical(self, - translate('SongsPlugin.SongMaintenanceForm', 'Error'), - translate('SongsPlugin.SongMaintenanceForm', 'The book "bla"' - 'already exists. Would you like to make songs with book "blu" use ' - 'the existing book "bla"?'), - QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.No | \ - QtGui.QMessageBox.Yes)) == QtGui.QMessageBox.Yes: - #if item_class == Author: - #if item_class == Topic: - if item_class == Book: - songs = self.songmanager.get_all_objects_filtered(Song, - Song.song_book_id == existing_item.id) - book = self.songmanager.get_object_filtered(Book, - and_( - Book.name == existing_item.name, - Book.publisher == existing_item.publisher - ) - ) - for song in songs: - song.song_book_id = book.id - self.songmanager.save_object(song) - self.songmanager.delete_object(Book, existing_item.id) - return True - else: - return False + new_book = self.songmanager.get_object_filtered(Book, + and_( + Book.name == existing_book.name, + Book.publisher == existing_book.publisher + ) + ) + songs = self.songmanager.get_all_objects_filtered(Song, + Song.song_book_id == existing_book.id) + for song in songs: + song.song_book_id = new_book.id + self.songmanager.save_object(song) + self.songmanager.delete_object(Book, existing_book.id) def onAuthorDeleteButtonClick(self): """ From 94660ee798ed250a39ad5f43d2677d7a9f8fb007 Mon Sep 17 00:00:00 2001 From: andreas Date: Sat, 17 Jul 2010 11:55:48 +0200 Subject: [PATCH 10/21] continued working on 'merging' song books, topics, authors (NOT finished yet) --- .../songs/forms/songmaintenanceform.py | 60 ++++++++++++------- 1 file changed, 38 insertions(+), 22 deletions(-) diff --git a/openlp/plugins/songs/forms/songmaintenanceform.py b/openlp/plugins/songs/forms/songmaintenanceform.py index f7e8c37b6..0767d5b19 100644 --- a/openlp/plugins/songs/forms/songmaintenanceform.py +++ b/openlp/plugins/songs/forms/songmaintenanceform.py @@ -140,13 +140,10 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): Returns False if the given Author is already in the list otherwise True. """ - authors = self.songmanager.get_all_objects_filtered(Author, - and_( - Author.first_name == new_author.first_name, - Author.last_name == new_author.last_name, - Author.display_name == new_author.display_name - ) - ) + authors = self.songmanager.get_all_objects_filtered(Author, + and_(Author.first_name == new_author.first_name, + Author.last_name == new_author.last_name, + Author.display_name == new_author.display_name)) if len(authors) > 0: # If we edit an existing Author, we need to make sure that we do # not return False when nothing has changed (because this would @@ -186,7 +183,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): 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, + 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 @@ -242,8 +239,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): def onBookAddButtonClick(self): if self.bookform.exec_(): - book = Book.populate( - name=unicode(self.bookform.NameEdit.text()), + book = Book.populate(name=unicode(self.bookform.NameEdit.text()), publisher=unicode(self.bookform.PublisherEdit.text())) if self.checkBook(book): if self.songmanager.save_object(book): @@ -286,6 +282,16 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): translate('SongsPlugin.SongMaintenanceForm', 'Error'), translate('SongsPlugin.SongMaintenanceForm', 'Could not save your changes.')) + elif QtGui.QMessageBox.critical(self, + translate('SongsPlugin.SongMaintenanceForm', 'Error'), + translate('SongsPlugin.SongMaintenanceForm', 'The author %s' + ' already exists. Would you like to make songs with author ' + '%s use the existing author %s?' % (author.display_name, + temp_display_name, author.display_name)), + QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.No | \ + QtGui.QMessageBox.Yes)) == QtGui.QMessageBox.Yes: + self.mergeAuthors(authors) + self.resetAuthors() else: # We restore the author's old first and last name as well as # his display name. @@ -318,13 +324,14 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): elif QtGui.QMessageBox.critical(self, translate('SongsPlugin.SongMaintenanceForm', 'Error'), translate('SongsPlugin.SongMaintenanceForm', 'The topic %s ' - 'already exists. Would you like to make songs with topic %s ' - 'use the existing topic %s?' % (topic.name, temp_name, + 'already exists. Would you like to make songs with topic %s' + ' use the existing topic %s?' % (topic.name, temp_name, topic.name)), QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.No | \ QtGui.QMessageBox.Yes)) == QtGui.QMessageBox.Yes: self.mergeTopics(topic) self.resetTopics() + else: # We restore the topics's old name. topic.name = temp_name QtGui.QMessageBox.critical(self, @@ -370,7 +377,19 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): book.name = temp_name book.publisher = temp_publisher - #def mergeAuthors(selfs, existing_author): +# def mergeAuthors(self, existing_author): +# ''' +# ''' +# new_author = self.songmanager.get_object_filtered(Author, +# and_(Author.first_name == existing_author.first_name, +# Author.last_name == existing_author.last_name, +# Author.display_name == existing_author.display_name)) +# songs = self.songmanager.get_all_objects_filtered(......, +# Song.song_book_id == existing_book.id) +# for song in songs: +# # +# self.songmanager.save_object(song) +# self.songmanager.delete_object(Author, existing_author.id) # def mergeTopics(self, existing_topic): # ''' @@ -380,7 +399,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): # songs = self.songmanager.get_all_objects_filtered(....., # songs_topics.topic_id == existing_topic.id) # for song in songs: -# song.songs_topic.id = new_topic.id +# # # self.songmanager.save_object(song) # self.songmanager.delete_object(Book, existing_topic.id) @@ -388,11 +407,8 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): ''' ''' new_book = self.songmanager.get_object_filtered(Book, - and_( - Book.name == existing_book.name, - Book.publisher == existing_book.publisher - ) - ) + and_(Book.name == existing_book.name, + Book.publisher == existing_book.publisher)) songs = self.songmanager.get_all_objects_filtered(Song, Song.song_book_id == existing_book.id) for song in songs: @@ -402,7 +418,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): def onAuthorDeleteButtonClick(self): """ - Delete the author if the author is not attached to any songs + Delete the author if the author is not attached to any songs. """ self._deleteItem(Author, self.AuthorsListWidget, self.resetAuthors, translate('SongsPlugin.SongMaintenanceForm', 'Delete Author'), @@ -415,7 +431,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): def onTopicDeleteButtonClick(self): """ - Delete the Book is the Book is not attached to any songs + Delete the Book is the Book is not attached to any songs. """ self._deleteItem(Topic, self.TopicsListWidget, self.resetTopics, translate('SongsPlugin.SongMaintenanceForm', 'Delete Topic'), @@ -428,7 +444,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): def onBookDeleteButtonClick(self): """ - Delete the Book is the Book is not attached to any songs + Delete the Book is the Book is not attached to any songs. """ self._deleteItem(Book, self.BooksListWidget, self.resetBooks, translate('SongsPlugin.SongMaintenanceForm', 'Delete Book'), From dacfe58beaab7242220a65273e00427bc3a5bd10 Mon Sep 17 00:00:00 2001 From: andreas Date: Sat, 17 Jul 2010 13:49:54 +0200 Subject: [PATCH 11/21] continued working on 'merging' song books, topics, authors (still not finished) --- .../songs/forms/songmaintenanceform.py | 55 ++++++++++--------- openlp/plugins/songs/lib/db.py | 14 +++++ 2 files changed, 43 insertions(+), 26 deletions(-) diff --git a/openlp/plugins/songs/forms/songmaintenanceform.py b/openlp/plugins/songs/forms/songmaintenanceform.py index 0767d5b19..822735755 100644 --- a/openlp/plugins/songs/forms/songmaintenanceform.py +++ b/openlp/plugins/songs/forms/songmaintenanceform.py @@ -28,7 +28,8 @@ from sqlalchemy.sql import and_ from openlp.core.lib import translate from openlp.plugins.songs.forms import AuthorsForm, TopicsForm, SongBookForm -from openlp.plugins.songs.lib.db import Author, Book, Topic, Song +from openlp.plugins.songs.lib.db import Author, Book, Topic, Song, \ + SongsTopics, AuthorsSongs from songmaintenancedialog import Ui_SongMaintenanceDialog class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): @@ -290,7 +291,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): temp_display_name, author.display_name)), QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.No | \ QtGui.QMessageBox.Yes)) == QtGui.QMessageBox.Yes: - self.mergeAuthors(authors) + self.mergeAuthors(author) self.resetAuthors() else: # We restore the author's old first and last name as well as @@ -377,31 +378,33 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): book.name = temp_name book.publisher = temp_publisher -# def mergeAuthors(self, existing_author): -# ''' -# ''' -# new_author = self.songmanager.get_object_filtered(Author, -# and_(Author.first_name == existing_author.first_name, -# Author.last_name == existing_author.last_name, -# Author.display_name == existing_author.display_name)) -# songs = self.songmanager.get_all_objects_filtered(......, -# Song.song_book_id == existing_book.id) -# for song in songs: -# # -# self.songmanager.save_object(song) -# self.songmanager.delete_object(Author, existing_author.id) + def mergeAuthors(self, existing_author): + ''' + ''' + new_author = self.songmanager.get_object_filtered(Author, + and_(Author.first_name == existing_author.first_name, + Author.last_name == existing_author.last_name, + Author.display_name == existing_author.display_name)) + songs = self.songmanager.get_all_objects_filtered(AuthorsSongs, + AuthorsSongs.author_id == existing_author.id) + for song in songs: + song.author_id = new_author.id + self.songmanager.save_object(song) + self.songmanager.delete_object(Author, existing_author.id) -# def mergeTopics(self, existing_topic): -# ''' -# ''' -# new_topic = self.songmanager.get_object_filtered(Topic, -# Topic.name == existing_topic.name) -# songs = self.songmanager.get_all_objects_filtered(....., -# songs_topics.topic_id == existing_topic.id) -# for song in songs: -# # -# self.songmanager.save_object(song) -# self.songmanager.delete_object(Book, existing_topic.id) + def mergeTopics(self, existing_topic): + ''' + ''' + new_topic = self.songmanager.get_object_filtered(Topic, + Topic.name == existing_topic.name) + songs = self.songmanager.get_all_objects_filtered(SongsTopics, + SongsTopics.topic_id == existing_topic.id) + for song in songs: + song.topic_id = new_topic.id + self.songmanager.save_object(song) + songs = self.songmanager.get_all_objects_filtered(SongsTopics, + SongsTopics.topic_id == new_topic.id) + self.songmanager.delete_object(Topic, existing_topic.id) def mergeBooks(self, existing_book): ''' diff --git a/openlp/plugins/songs/lib/db.py b/openlp/plugins/songs/lib/db.py index 655043144..f37a23ff9 100644 --- a/openlp/plugins/songs/lib/db.py +++ b/openlp/plugins/songs/lib/db.py @@ -58,6 +58,18 @@ class Topic(BaseModel): """ pass +class SongsTopics(BaseModel): + """ + Songs topics model + """ + pass + +class AuthorsSongs(BaseModel): + """ + Songs authors model + """ + pass + def init_schema(url): """ Setup the songs database connection and initialise the database schema @@ -146,6 +158,8 @@ def init_schema(url): 'topics': relation(Topic, backref='songs', secondary=songs_topics_table)}) mapper(Topic, topics_table) + mapper(SongsTopics, songs_topics_table) + mapper(AuthorsSongs, authors_songs_table) metadata.create_all(checkfirst=True) return session From f458f80ce2bcf206fa7cdc55cc03de102f85f1ea Mon Sep 17 00:00:00 2001 From: andreas Date: Sat, 17 Jul 2010 17:01:47 +0200 Subject: [PATCH 12/21] added check to prevent an author/topic being associated (with one song) twice (causing an error) --- .../songs/forms/songmaintenanceform.py | 26 ++++++++++++++----- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/openlp/plugins/songs/forms/songmaintenanceform.py b/openlp/plugins/songs/forms/songmaintenanceform.py index 822735755..98dd42495 100644 --- a/openlp/plugins/songs/forms/songmaintenanceform.py +++ b/openlp/plugins/songs/forms/songmaintenanceform.py @@ -388,9 +388,16 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): songs = self.songmanager.get_all_objects_filtered(AuthorsSongs, AuthorsSongs.author_id == existing_author.id) for song in songs: - song.author_id = new_author.id - self.songmanager.save_object(song) - self.songmanager.delete_object(Author, existing_author.id) + # We have to check if the song has already the new_author as author. + # If that is the case we must not change song.author_id to the + # new_author's id, because then they were not unique. + temp_song = self.songmanager.get_all_objects_filtered(AuthorsSongs, + and_(AuthorsSongs.author_id == new_author.id, + AuthorsSongs.song_id == song.song_id)) + if len(temp_song) < 1: + song.author_id = new_author.id + self.songmanager.save_object(song) + self.songmanager.delete_object(Author, existing_author.id) def mergeTopics(self, existing_topic): ''' @@ -400,10 +407,15 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): songs = self.songmanager.get_all_objects_filtered(SongsTopics, SongsTopics.topic_id == existing_topic.id) for song in songs: - song.topic_id = new_topic.id - self.songmanager.save_object(song) - songs = self.songmanager.get_all_objects_filtered(SongsTopics, - SongsTopics.topic_id == new_topic.id) + # We have to check if the song has already the new_topic as topic. + # If that is the case we must not change song.topic_id to the + # new_topic's id, because then they were not unique. + temp_song = self.songmanager.get_all_objects_filtered(SongsTopics, + and_(SongsTopics.topic_id == new_topic.id, + SongsTopics.song_id == song.song_id)) + if len(temp_song) < 1: + song.topic_id = new_topic.id + self.songmanager.save_object(song) self.songmanager.delete_object(Topic, existing_topic.id) def mergeBooks(self, existing_book): From c7f32e280c63925d0b07aa43557404ff146591f1 Mon Sep 17 00:00:00 2001 From: andreas Date: Sat, 17 Jul 2010 17:10:46 +0200 Subject: [PATCH 13/21] docs --- openlp/plugins/songs/forms/songmaintenanceform.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/openlp/plugins/songs/forms/songmaintenanceform.py b/openlp/plugins/songs/forms/songmaintenanceform.py index 98dd42495..869130c40 100644 --- a/openlp/plugins/songs/forms/songmaintenanceform.py +++ b/openlp/plugins/songs/forms/songmaintenanceform.py @@ -359,7 +359,8 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): self.resetBooks() else: QtGui.QMessageBox.critical(self, - translate('SongsPlugin.SongMaintenanceForm', 'Error'), + translate('SongsPlugin.SongMaintenanceForm', + 'Error'), translate('SongsPlugin.SongMaintenanceForm', 'Could not save your changes.')) elif QtGui.QMessageBox.critical(self, @@ -380,6 +381,10 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): def mergeAuthors(self, existing_author): ''' + Merges two authors into one author. + + ``existing_author`` + The author which will be deleted afterwards. ''' new_author = self.songmanager.get_object_filtered(Author, and_(Author.first_name == existing_author.first_name, @@ -401,6 +406,10 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): def mergeTopics(self, existing_topic): ''' + Merges two topics into one topic. + + ``existing_topic`` + The topic which will be deleted afterwards. ''' new_topic = self.songmanager.get_object_filtered(Topic, Topic.name == existing_topic.name) @@ -420,6 +429,10 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): def mergeBooks(self, existing_book): ''' + Merges two books into one book. + + ``existing_book`` + The book which will be deleted afterwards. ''' new_book = self.songmanager.get_object_filtered(Book, and_(Book.name == existing_book.name, From d0e914a681a7b8082941b7edde75e57c7c95d06b Mon Sep 17 00:00:00 2001 From: andreas Date: Sat, 17 Jul 2010 18:03:59 +0200 Subject: [PATCH 14/21] name standardisation + reloads song list after author(s) have been edited/merged --- openlp/plugins/songs/forms/editsongdialog.py | 4 ++-- openlp/plugins/songs/forms/songbookdialog.py | 2 +- openlp/plugins/songs/forms/songmaintenancedialog.py | 2 +- openlp/plugins/songs/forms/songmaintenanceform.py | 10 +++++++--- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/openlp/plugins/songs/forms/editsongdialog.py b/openlp/plugins/songs/forms/editsongdialog.py index 43684c1a9..922147628 100644 --- a/openlp/plugins/songs/forms/editsongdialog.py +++ b/openlp/plugins/songs/forms/editsongdialog.py @@ -430,7 +430,7 @@ class Ui_EditSongDialog(object): self.AuthorRemoveButton.setText( translate('SongsPlugin.EditSongForm', '&Remove')) self.MaintenanceButton.setText(translate('SongsPlugin.EditSongForm', - '&Manage Authors, Topics, Books')) + '&Manage Authors, Topics, Song Books')) self.TopicGroupBox.setTitle( translate('SongsPlugin.EditSongForm', 'Topic')) self.TopicAddButton.setText( @@ -441,7 +441,7 @@ class Ui_EditSongDialog(object): translate('SongsPlugin.EditSongForm', 'Song Book')) self.SongTabWidget.setTabText( self.SongTabWidget.indexOf(self.AuthorsTab), - translate('SongsPlugin.EditSongForm', 'Authors, Topics && Book')) + translate('SongsPlugin.EditSongForm', 'Authors, Topics && Song Book')) self.ThemeGroupBox.setTitle( translate('SongsPlugin.EditSongForm', 'Theme')) self.ThemeAddButton.setText( diff --git a/openlp/plugins/songs/forms/songbookdialog.py b/openlp/plugins/songs/forms/songbookdialog.py index 2ab223b34..0401ff75b 100644 --- a/openlp/plugins/songs/forms/songbookdialog.py +++ b/openlp/plugins/songs/forms/songbookdialog.py @@ -68,7 +68,7 @@ class Ui_SongBookDialog(object): def retranslateUi(self, SongBookDialog): SongBookDialog.setWindowTitle( - translate('SongsPlugin.SongBookForm', 'Edit Book')) + translate('SongsPlugin.SongBookForm', 'Song Book Maintenance')) self.NameLabel.setText(translate('SongsPlugin.SongBookForm', '&Name:')) self.PublisherLabel.setText( translate('SongsPlugin.SongBookForm', '&Publisher:')) diff --git a/openlp/plugins/songs/forms/songmaintenancedialog.py b/openlp/plugins/songs/forms/songmaintenancedialog.py index f86754e0c..3e2f37dd3 100644 --- a/openlp/plugins/songs/forms/songmaintenancedialog.py +++ b/openlp/plugins/songs/forms/songmaintenancedialog.py @@ -217,7 +217,7 @@ class Ui_SongMaintenanceDialog(object): self.TypeListWidget.item(1).setText( translate('SongsPlugin.SongMaintenanceForm', 'Topics')) self.TypeListWidget.item(2).setText( - translate('SongsPlugin.SongMaintenanceForm', 'Books/Hymnals')) + translate('SongsPlugin.SongMaintenanceForm', 'Song Books')) self.AuthorAddButton.setText( translate('SongsPlugin.SongMaintenanceForm', '&Add')) self.AuthorEditButton.setText( diff --git a/openlp/plugins/songs/forms/songmaintenanceform.py b/openlp/plugins/songs/forms/songmaintenanceform.py index 869130c40..9ed68d31f 100644 --- a/openlp/plugins/songs/forms/songmaintenanceform.py +++ b/openlp/plugins/songs/forms/songmaintenanceform.py @@ -26,7 +26,7 @@ from PyQt4 import QtGui, QtCore from sqlalchemy.sql import and_ -from openlp.core.lib import translate +from openlp.core.lib import Receiver, translate from openlp.plugins.songs.forms import AuthorsForm, TopicsForm, SongBookForm from openlp.plugins.songs.lib.db import Author, Book, Topic, Song, \ SongsTopics, AuthorsSongs @@ -278,9 +278,11 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): if self.checkAuthor(author, True): if self.songmanager.save_object(author): self.resetAuthors() + Receiver.send_message(u'songs_load_list') else: QtGui.QMessageBox.critical(self, - translate('SongsPlugin.SongMaintenanceForm', 'Error'), + translate('SongsPlugin.SongMaintenanceForm', + 'Error'), translate('SongsPlugin.SongMaintenanceForm', 'Could not save your changes.')) elif QtGui.QMessageBox.critical(self, @@ -293,6 +295,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): QtGui.QMessageBox.Yes)) == QtGui.QMessageBox.Yes: self.mergeAuthors(author) self.resetAuthors() + Receiver.send_message(u'songs_load_list') else: # We restore the author's old first and last name as well as # his display name. @@ -319,7 +322,8 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): self.resetTopics() else: QtGui.QMessageBox.critical(self, - translate('SongsPlugin.SongMaintenanceForm', 'Error'), + translate('SongsPlugin.SongMaintenanceForm', + 'Error'), translate('SongsPlugin.SongMaintenanceForm', 'Could not save your changes.')) elif QtGui.QMessageBox.critical(self, From 6ab287cfaab80092ad5e74f65b3c7f2f8b345b7f Mon Sep 17 00:00:00 2001 From: andreas Date: Mon, 19 Jul 2010 09:54:22 +0200 Subject: [PATCH 15/21] reverted changes --- openlp/core/ui/maindisplay.py | 28 +++++++++++++++------------- openlp/core/ui/mainwindow.py | 2 +- openlp/plugins/songs/lib/db.py | 14 -------------- 3 files changed, 16 insertions(+), 28 deletions(-) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index c8dc06cf7..6183c23c2 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -167,7 +167,7 @@ class DisplayWidget(QtGui.QGraphicsView): def keyPressEvent(self, event): if isinstance(event, QtGui.QKeyEvent): - # Here accept the event and do something. + #here accept the event and do something if event.key() == QtCore.Qt.Key_Up: Receiver.send_message(u'slidecontroller_live_previous') event.accept() @@ -233,8 +233,8 @@ class MainDisplay(DisplayWidget): self.setupBlank() self.blankFrame = None self.frame = None - # Hide desktop for now until we know where to put it - # and what size it should be. + #Hide desktop for now until we know where to put it + #and what size it should be. self.setVisible(False) def setup(self): @@ -245,12 +245,13 @@ class MainDisplay(DisplayWidget): self.screens, self.screens.monitor_number)) self.setVisible(False) self.screen = self.screens.current - # Sort out screen locations and sizes. + #Sort out screen locations and sizes self.setGeometry(self.screen[u'size']) - self.scene.setSceneRect(0, 0, self.size().width(), self.size().height()) + self.scene.setSceneRect(0, 0, self.size().width(), + self.size().height()) self.webView.setGeometry(0, 0, self.size().width(), self.size().height()) - # Build a custom splash screen. + #Build a custom splash screen self.initialFrame = QtGui.QImage( self.screen[u'size'].width(), self.screen[u'size'].height(), @@ -269,7 +270,7 @@ class MainDisplay(DisplayWidget): self.transparent.fill(QtCore.Qt.transparent) self.displayImage(self.initialFrame) self.repaint() - # Build a Black screen. + #Build a Black screen painter = QtGui.QPainter() self.blankFrame = QtGui.QImage( self.screen[u'size'].width(), @@ -368,7 +369,7 @@ class MainDisplay(DisplayWidget): self.displayBlank.setPixmap(self.transparent) if self.isHidden(): self.setVisible(True) - # Trigger actions when display is active again. + #Trigger actions when display is active again Receiver.send_message(u'maindisplay_active') def addImageWithText(self, frame): @@ -419,7 +420,8 @@ class MainDisplay(DisplayWidget): log.debug(u'adddisplayVideo') self.displayImage(self.transparent) self.videoDisplay.setHtml(HTMLVIDEO % - (path, self.screen[u'size'].width(), self.screen[u'size'].height())) + (path, self.screen[u'size'].width(), + self.screen[u'size'].height())) def frameView(self, frame, transition=False): """ @@ -507,7 +509,7 @@ class VideoDisplay(Phonon.VideoWidget): def keyPressEvent(self, event): if isinstance(event, QtGui.QKeyEvent): - # Here accept the event and do something. + #here accept the event and do something if event.key() == QtCore.Qt.Key_Escape: self.onMediaStop() event.accept() @@ -522,7 +524,7 @@ class VideoDisplay(Phonon.VideoWidget): log.debug(u'VideoDisplay Setup %s for %s ' % (self.screens, self.screens.monitor_number)) self.screen = self.screens.current - # Sort out screen locations and sizes. + #Sort out screen locations and sizes self.setGeometry(self.screen[u'size']) # To display or not to display? if not self.screen[u'primary']: # and self.isVisible(): @@ -549,10 +551,10 @@ class VideoDisplay(Phonon.VideoWidget): # if it is triggered from the plugin # """ # log.debug(u'VideoDisplay Queue new media message %s' % message) -# # If not file take the stored one. +# #If not file take the stored one # if not message: # message = self.message -# # Still no file name then stop as it was a normal video stopping. +# # still no file name then stop as it was a normal video stopping # if message: # self.mediaObject.setCurrentSource(Phonon.MediaSource(message)) # self.message = message diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index b014747a2..ec34a483b 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -114,7 +114,7 @@ class Ui_MainWindow(object): MainWindow.setSizePolicy(sizePolicy) MainIcon = build_icon(u':/icon/openlp-logo-16x16.png') MainWindow.setWindowIcon(MainIcon) - # Set up the main container, which contains all the other form widgets. + # Set up the main container, which contains all the other form widgets self.MainContent = QtGui.QWidget(MainWindow) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) diff --git a/openlp/plugins/songs/lib/db.py b/openlp/plugins/songs/lib/db.py index f37a23ff9..655043144 100644 --- a/openlp/plugins/songs/lib/db.py +++ b/openlp/plugins/songs/lib/db.py @@ -58,18 +58,6 @@ class Topic(BaseModel): """ pass -class SongsTopics(BaseModel): - """ - Songs topics model - """ - pass - -class AuthorsSongs(BaseModel): - """ - Songs authors model - """ - pass - def init_schema(url): """ Setup the songs database connection and initialise the database schema @@ -158,8 +146,6 @@ def init_schema(url): 'topics': relation(Topic, backref='songs', secondary=songs_topics_table)}) mapper(Topic, topics_table) - mapper(SongsTopics, songs_topics_table) - mapper(AuthorsSongs, authors_songs_table) metadata.create_all(checkfirst=True) return session From 1a462e1a65c51e37349961a6e26406f2f2777eef Mon Sep 17 00:00:00 2001 From: andreas Date: Mon, 19 Jul 2010 09:54:57 +0200 Subject: [PATCH 16/21] reverted changes --- openlp/plugins/songs/forms/songmaintenanceform.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/openlp/plugins/songs/forms/songmaintenanceform.py b/openlp/plugins/songs/forms/songmaintenanceform.py index 9ed68d31f..1d86bdbd9 100644 --- a/openlp/plugins/songs/forms/songmaintenanceform.py +++ b/openlp/plugins/songs/forms/songmaintenanceform.py @@ -28,8 +28,7 @@ from sqlalchemy.sql import and_ from openlp.core.lib import Receiver, translate from openlp.plugins.songs.forms import AuthorsForm, TopicsForm, SongBookForm -from openlp.plugins.songs.lib.db import Author, Book, Topic, Song, \ - SongsTopics, AuthorsSongs +from openlp.plugins.songs.lib.db import Author, Book, Topic, Song from songmaintenancedialog import Ui_SongMaintenanceDialog class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): From 35021495565f96fec2c8ace45993ee949a2391cc Mon Sep 17 00:00:00 2001 From: andreas Date: Mon, 19 Jul 2010 10:50:44 +0200 Subject: [PATCH 17/21] reworked code --- .../songs/forms/songmaintenanceform.py | 34 ++++++++----------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/openlp/plugins/songs/forms/songmaintenanceform.py b/openlp/plugins/songs/forms/songmaintenanceform.py index 1d86bdbd9..c0de48fcf 100644 --- a/openlp/plugins/songs/forms/songmaintenanceform.py +++ b/openlp/plugins/songs/forms/songmaintenanceform.py @@ -393,17 +393,14 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): and_(Author.first_name == existing_author.first_name, Author.last_name == existing_author.last_name, Author.display_name == existing_author.display_name)) - songs = self.songmanager.get_all_objects_filtered(AuthorsSongs, - AuthorsSongs.author_id == existing_author.id) + songs = self.songmanager.get_all_objects(Song) for song in songs: - # We have to check if the song has already the new_author as author. - # If that is the case we must not change song.author_id to the - # new_author's id, because then they were not unique. - temp_song = self.songmanager.get_all_objects_filtered(AuthorsSongs, - and_(AuthorsSongs.author_id == new_author.id, - AuthorsSongs.song_id == song.song_id)) - if len(temp_song) < 1: - song.author_id = new_author.id + if existing_author in song.authors: + # We check if the song has already the new_author as author. + # If that is not the case we add it. + if new_author not in song.authors: + song.authors.append(new_author) + song.authors.remove(existing_author) self.songmanager.save_object(song) self.songmanager.delete_object(Author, existing_author.id) @@ -416,17 +413,14 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): ''' new_topic = self.songmanager.get_object_filtered(Topic, Topic.name == existing_topic.name) - songs = self.songmanager.get_all_objects_filtered(SongsTopics, - SongsTopics.topic_id == existing_topic.id) + songs = self.songmanager.get_all_objects(Song) for song in songs: - # We have to check if the song has already the new_topic as topic. - # If that is the case we must not change song.topic_id to the - # new_topic's id, because then they were not unique. - temp_song = self.songmanager.get_all_objects_filtered(SongsTopics, - and_(SongsTopics.topic_id == new_topic.id, - SongsTopics.song_id == song.song_id)) - if len(temp_song) < 1: - song.topic_id = new_topic.id + if existing_topic in song.topics: + # We check if the song has already the new_topic as topic. + # If that is not the case we add it. + if new_topic not in song.topics: + song.topics.append(new_topic) + song.topics.remove(existing_topic) self.songmanager.save_object(song) self.songmanager.delete_object(Topic, existing_topic.id) From 30cbaafb09d4e22fb01d8fe70cc5ee21a17255fd Mon Sep 17 00:00:00 2001 From: andreas Date: Mon, 19 Jul 2010 12:17:41 +0200 Subject: [PATCH 18/21] fixed comment --- openlp/plugins/songs/forms/songmaintenanceform.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/openlp/plugins/songs/forms/songmaintenanceform.py b/openlp/plugins/songs/forms/songmaintenanceform.py index c0de48fcf..1eb9e3ce6 100644 --- a/openlp/plugins/songs/forms/songmaintenanceform.py +++ b/openlp/plugins/songs/forms/songmaintenanceform.py @@ -377,8 +377,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): self.mergeBooks(book) self.resetBooks() else: - # We restore the book's old name and publisher, because - # the user did not want to merge the two topics. + # We restore the book's old name and publisher. book.name = temp_name book.publisher = temp_publisher From a21154addc0a621705068192ec1cc3d266475100 Mon Sep 17 00:00:00 2001 From: andreas Date: Mon, 19 Jul 2010 15:39:18 +0200 Subject: [PATCH 19/21] names --- .../songs/forms/songmaintenanceform.py | 64 +++++++++---------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/openlp/plugins/songs/forms/songmaintenanceform.py b/openlp/plugins/songs/forms/songmaintenanceform.py index 1eb9e3ce6..511fbc333 100644 --- a/openlp/plugins/songs/forms/songmaintenanceform.py +++ b/openlp/plugins/songs/forms/songmaintenanceform.py @@ -381,64 +381,64 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): book.name = temp_name book.publisher = temp_publisher - def mergeAuthors(self, existing_author): + def mergeAuthors(self, old_author): ''' Merges two authors into one author. - ``existing_author`` + ``old_author`` The author which will be deleted afterwards. ''' - new_author = self.songmanager.get_object_filtered(Author, - and_(Author.first_name == existing_author.first_name, - Author.last_name == existing_author.last_name, - Author.display_name == existing_author.display_name)) + existing_author = self.songmanager.get_object_filtered(Author, + and_(Author.first_name == old_author.first_name, + Author.last_name == old_author.last_name, + Author.display_name == old_author.display_name)) songs = self.songmanager.get_all_objects(Song) for song in songs: - if existing_author in song.authors: - # We check if the song has already the new_author as author. - # If that is not the case we add it. - if new_author not in song.authors: - song.authors.append(new_author) - song.authors.remove(existing_author) + if old_author in song.authors: + # We check if the song has already existing_author + # as author. If that is not the case we add it. + if existing_author not in song.authors: + song.authors.append(existing_author) + song.authors.remove(old_author) self.songmanager.save_object(song) - self.songmanager.delete_object(Author, existing_author.id) + self.songmanager.delete_object(Author, old_author.id) - def mergeTopics(self, existing_topic): + def mergeTopics(self, old_topic): ''' Merges two topics into one topic. - ``existing_topic`` + ``old_topic`` The topic which will be deleted afterwards. ''' - new_topic = self.songmanager.get_object_filtered(Topic, - Topic.name == existing_topic.name) + existing_topic = self.songmanager.get_object_filtered(Topic, + Topic.name == old_topic.name) songs = self.songmanager.get_all_objects(Song) for song in songs: - if existing_topic in song.topics: - # We check if the song has already the new_topic as topic. - # If that is not the case we add it. - if new_topic not in song.topics: - song.topics.append(new_topic) - song.topics.remove(existing_topic) + if old_topic in song.topics: + # We check if the song has already existing_topic + # as topic. If that is not the case we add it. + if existing_topic not in song.topics: + song.topics.append(existing_topic) + song.topics.remove(old_topic) self.songmanager.save_object(song) - self.songmanager.delete_object(Topic, existing_topic.id) + self.songmanager.delete_object(Topic, old_topic.id) - def mergeBooks(self, existing_book): + def mergeBooks(self, old_book): ''' Merges two books into one book. - ``existing_book`` + ``old_book`` The book which will be deleted afterwards. ''' - new_book = self.songmanager.get_object_filtered(Book, - and_(Book.name == existing_book.name, - Book.publisher == existing_book.publisher)) + existing_book = self.songmanager.get_object_filtered(Book, + and_(Book.name == old_book.name, + Book.publisher == old_book.publisher)) songs = self.songmanager.get_all_objects_filtered(Song, - Song.song_book_id == existing_book.id) + Song.song_book_id == old_book.id) for song in songs: - song.song_book_id = new_book.id + song.song_book_id = existing_book.id self.songmanager.save_object(song) - self.songmanager.delete_object(Book, existing_book.id) + self.songmanager.delete_object(Book, old_book.id) def onAuthorDeleteButtonClick(self): """ From dd662dc277d0c13d186355d51972b7b84900017a Mon Sep 17 00:00:00 2001 From: andreas Date: Mon, 19 Jul 2010 16:56:24 +0200 Subject: [PATCH 20/21] now filtering songs --- .../songs/forms/songmaintenanceform.py | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/openlp/plugins/songs/forms/songmaintenanceform.py b/openlp/plugins/songs/forms/songmaintenanceform.py index 511fbc333..7c7f2d252 100644 --- a/openlp/plugins/songs/forms/songmaintenanceform.py +++ b/openlp/plugins/songs/forms/songmaintenanceform.py @@ -392,15 +392,15 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): and_(Author.first_name == old_author.first_name, Author.last_name == old_author.last_name, Author.display_name == old_author.display_name)) - songs = self.songmanager.get_all_objects(Song) + songs = self.songmanager.get_all_objects_filtered(Song, + Song.authors.contains(old_author)) for song in songs: - if old_author in song.authors: - # We check if the song has already existing_author - # as author. If that is not the case we add it. - if existing_author not in song.authors: - song.authors.append(existing_author) - song.authors.remove(old_author) - self.songmanager.save_object(song) + # We check if the song has already existing_author as author. If + # that is not the case we add it. + if existing_author not in song.authors: + song.authors.append(existing_author) + song.authors.remove(old_author) + self.songmanager.save_object(song) self.songmanager.delete_object(Author, old_author.id) def mergeTopics(self, old_topic): @@ -412,15 +412,15 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): ''' existing_topic = self.songmanager.get_object_filtered(Topic, Topic.name == old_topic.name) - songs = self.songmanager.get_all_objects(Song) + songs = self.songmanager.get_all_objects_filtered(Song, + Song.topics.contains(old_topic)) for song in songs: - if old_topic in song.topics: - # We check if the song has already existing_topic - # as topic. If that is not the case we add it. - if existing_topic not in song.topics: - song.topics.append(existing_topic) - song.topics.remove(old_topic) - self.songmanager.save_object(song) + # We check if the song has already existing_topic as topic. If that + # is not the case we add it. + if existing_topic not in song.topics: + song.topics.append(existing_topic) + song.topics.remove(old_topic) + self.songmanager.save_object(song) self.songmanager.delete_object(Topic, old_topic.id) def mergeBooks(self, old_book): From 6eb260a64ea54b06906274cc6f46c10acc6068c0 Mon Sep 17 00:00:00 2001 From: andreas Date: Mon, 19 Jul 2010 17:03:49 +0200 Subject: [PATCH 21/21] fix --- openlp/plugins/songs/forms/songmaintenanceform.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openlp/plugins/songs/forms/songmaintenanceform.py b/openlp/plugins/songs/forms/songmaintenanceform.py index 7c7f2d252..cc98f5cb5 100644 --- a/openlp/plugins/songs/forms/songmaintenanceform.py +++ b/openlp/plugins/songs/forms/songmaintenanceform.py @@ -290,7 +290,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): ' already exists. Would you like to make songs with author ' '%s use the existing author %s?' % (author.display_name, temp_display_name, author.display_name)), - QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.No | \ + QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.No | QtGui.QMessageBox.Yes)) == QtGui.QMessageBox.Yes: self.mergeAuthors(author) self.resetAuthors() @@ -331,7 +331,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): 'already exists. Would you like to make songs with topic %s' ' use the existing topic %s?' % (topic.name, temp_name, topic.name)), - QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.No | \ + QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.No | QtGui.QMessageBox.Yes)) == QtGui.QMessageBox.Yes: self.mergeTopics(topic) self.resetTopics() @@ -372,7 +372,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): 'already exists. Would you like to make songs with book %s ' 'use the existing book %s?' % (book.name, temp_name, book.name)), - QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.No | \ + QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.No | QtGui.QMessageBox.Yes)) == QtGui.QMessageBox.Yes: self.mergeBooks(book) self.resetBooks()