← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~meths/openlp/trivialfixes into lp:openlp

 

Jon Tibble has proposed merging lp:~meths/openlp/trivialfixes into lp:openlp.

Requested reviews:
  OpenLP Core (openlp-core)

For more details, see:
https://code.launchpad.net/~meths/openlp/trivialfixes/+merge/48091

Deduplication in various places.
-- 
https://code.launchpad.net/~meths/openlp/trivialfixes/+merge/48091
Your team OpenLP Core is requested to review the proposed merge of lp:~meths/openlp/trivialfixes into lp:openlp.
=== modified file 'openlp/core/lib/__init__.py'
--- openlp/core/lib/__init__.py	2011-01-28 18:41:37 +0000
+++ openlp/core/lib/__init__.py	2011-02-01 01:07:42 +0000
@@ -319,6 +319,20 @@
     if not os.path.exists(dir):
         os.makedirs(dir)
 
+def save_cancel_button_box(parent):
+    """
+    Return a standard dialog button box with save and cancel buttons.
+    """
+    button_box = QtGui.QDialogButtonBox(parent)
+    button_box.setStandardButtons(QtGui.QDialogButtonBox.Save |
+        QtGui.QDialogButtonBox.Cancel)
+    button_box.setObjectName(u'%sButtonBox' % parent)
+    QtCore.QObject.connect(button_box, QtCore.SIGNAL(u'accepted()'),
+        parent.accept)
+    QtCore.QObject.connect(button_box, QtCore.SIGNAL(u'rejected()'),
+        parent.reject)
+    return button_box
+
 from theme import ThemeLevel, ThemeXML, BackgroundGradientType, \
     BackgroundType, HorizontalType, VerticalType
 from displaytags import DisplayTags

=== modified file 'openlp/core/lib/mediamanageritem.py'
--- openlp/core/lib/mediamanageritem.py	2011-01-25 04:42:15 +0000
+++ openlp/core/lib/mediamanageritem.py	2011-02-01 01:07:42 +0000
@@ -540,3 +540,25 @@
         individual service items need to be processed by the plugins
         """
         pass
+
+    def _getIdOfItemToGenerate(self, item, remoteItem):
+        """
+        Utility method to check items being submitted for slide generation.
+
+        ``item``
+            The item to check.
+
+        ``remoteItem``
+            The id to assign if the slide generation was remotely triggered.
+        """
+        if item is None:
+            if self.remoteTriggered is None:
+                item = self.listView.currentItem()
+                if item is None:
+                    return False
+                item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
+            else:
+                item_id = remoteItem
+        else:
+            item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
+        return item_id

=== modified file 'openlp/core/ui/serviceitemeditdialog.py'
--- openlp/core/ui/serviceitemeditdialog.py	2011-01-02 22:24:14 +0000
+++ openlp/core/ui/serviceitemeditdialog.py	2011-02-01 01:07:42 +0000
@@ -26,7 +26,7 @@
 
 from PyQt4 import QtCore, QtGui
 
-from openlp.core.lib import translate, build_icon
+from openlp.core.lib import translate, build_icon, save_cancel_button_box
 
 class Ui_ServiceItemEditDialog(object):
     def setupUi(self, serviceItemEditDialog):
@@ -52,12 +52,8 @@
         self.downButton.setObjectName(u'downButton')
         self.buttonLayout.addWidget(self.downButton)
         self.dialogLayout.addLayout(self.buttonLayout, 0, 1)
-        self.buttonBox = QtGui.QDialogButtonBox(serviceItemEditDialog)
-        self.buttonBox.setStandardButtons(
-            QtGui.QDialogButtonBox.Cancel | QtGui.QDialogButtonBox.Save)
-        self.buttonBox.setObjectName(u'buttonBox')
-        self.dialogLayout.addWidget(self.buttonBox, 1, 0, 1, 2)
-
+        self.dialogLayout.addWidget(
+            save_cancel_button_box(serviceItemEditDialog), 1, 0, 1, 2)
         self.retranslateUi(serviceItemEditDialog)
         QtCore.QMetaObject.connectSlotsByName(serviceItemEditDialog)
 

=== modified file 'openlp/core/ui/serviceitemeditform.py'
--- openlp/core/ui/serviceitemeditform.py	2011-01-18 16:09:34 +0000
+++ openlp/core/ui/serviceitemeditform.py	2011-02-01 01:07:42 +0000
@@ -46,10 +46,6 @@
             QtCore.SIGNAL(u'clicked()'), self.onItemDown)
         QtCore.QObject.connect(self.deleteButton,
             QtCore.SIGNAL(u'clicked()'), self.onItemDelete)
-        QtCore.QObject.connect(self.buttonBox,
-            QtCore.SIGNAL(u'accepted()'), self.accept)
-        QtCore.QObject.connect(self.buttonBox,
-            QtCore.SIGNAL(u'rejected()'), self.reject)
         QtCore.QObject.connect(self.listWidget,
             QtCore.SIGNAL(u'currentRowChanged(int)'), self.onCurrentRowChanged)
 
@@ -100,27 +96,30 @@
         """
         Move the current row up in the list.
         """
-        item = self.listWidget.currentItem()
-        if not item:
-            return
-        row = self.listWidget.row(item)
-        temp = self.itemList[row]
-        self.itemList.remove(self.itemList[row])
-        self.itemList.insert(row - 1, temp)
-        self.loadData()
-        self.listWidget.setCurrentRow(row - 1)
+        self.__moveItem(u'up')
 
     def onItemDown(self):
         """
         Move the current row down in the list
         """
+        self.__moveItem(u'down')
+
+    def __moveItem(self, direction=u''):
+        """
+        Move the current item.
+        """
+        if not direction:
+            return
         item = self.listWidget.currentItem()
         if not item:
             return
         row = self.listWidget.row(item)
         temp = self.itemList[row]
         self.itemList.remove(self.itemList[row])
-        self.itemList.insert(row + 1, temp)
+        if direction == u'up':
+            self.itemList.insert(row - 1, temp)
+        else:
+            self.itemList.insert(row + 1, temp)
         self.loadData()
         self.listWidget.setCurrentRow(row + 1)
 

=== removed file 'openlp/core/ui/servicenotedialog.py'
--- openlp/core/ui/servicenotedialog.py	2011-01-02 22:24:14 +0000
+++ openlp/core/ui/servicenotedialog.py	1970-01-01 00:00:00 +0000
@@ -1,48 +0,0 @@
-# -*- coding: utf-8 -*-
-# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
-
-###############################################################################
-# OpenLP - Open Source Lyrics Projection                                      #
-# --------------------------------------------------------------------------- #
-# Copyright (c) 2008-2011 Raoul Snyman                                        #
-# Portions copyright (c) 2008-2011 Tim Bentley, Jonathan Corwin, Michael      #
-# Gorven, Scott Guerrieri, Meinert Jordan, Andreas Preikschat, Christian      #
-# Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon Tibble,    #
-# Carsten Tinggaard, Frode Woldsund                                           #
-# --------------------------------------------------------------------------- #
-# This program is free software; you can redistribute it and/or modify it     #
-# under the terms of the GNU General Public License as published by the Free  #
-# Software Foundation; version 2 of the License.                              #
-#                                                                             #
-# This program is distributed in the hope that it will be useful, but WITHOUT #
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or       #
-# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for    #
-# more details.                                                               #
-#                                                                             #
-# You should have received a copy of the GNU General Public License along     #
-# with this program; if not, write to the Free Software Foundation, Inc., 59  #
-# Temple Place, Suite 330, Boston, MA 02111-1307 USA                          #
-###############################################################################
-
-from PyQt4 import QtCore, QtGui
-from openlp.core.lib import translate
-
-class Ui_ServiceNoteEdit(object):
-    def setupUi(self, serviceNoteEdit):
-        serviceNoteEdit.setObjectName(u'serviceNoteEdit')
-        self.dialogLayout = QtGui.QVBoxLayout(serviceNoteEdit)
-        self.dialogLayout.setObjectName(u'verticalLayout')
-        self.textEdit = QtGui.QTextEdit(serviceNoteEdit)
-        self.textEdit.setObjectName(u'textEdit')
-        self.dialogLayout.addWidget(self.textEdit)
-        self.buttonBox = QtGui.QDialogButtonBox(serviceNoteEdit)
-        self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel |
-            QtGui.QDialogButtonBox.Save)
-        self.buttonBox.setObjectName(u'buttonBox')
-        self.dialogLayout.addWidget(self.buttonBox)
-        self.retranslateUi(serviceNoteEdit)
-        QtCore.QMetaObject.connectSlotsByName(serviceNoteEdit)
-
-    def retranslateUi(self, serviceNoteEdit):
-        serviceNoteEdit.setWindowTitle(
-            translate('OpenLP.ServiceNoteForm', 'Service Item Notes'))

=== modified file 'openlp/core/ui/servicenoteform.py'
--- openlp/core/ui/servicenoteform.py	2010-12-26 11:04:47 +0000
+++ openlp/core/ui/servicenoteform.py	2011-02-01 01:07:42 +0000
@@ -26,6 +26,7 @@
 
 from PyQt4 import QtCore, QtGui
 
+from openlp.core.lib import save_cancel_button_box, translate
 from servicenotedialog import Ui_ServiceNoteEdit
 
 class ServiceNoteForm(QtGui.QDialog, Ui_ServiceNoteEdit):
@@ -37,8 +38,19 @@
         Constructor
         """
         QtGui.QDialog.__init__(self, parent)
-        self.setupUi(self)
-        QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'accepted()'),
-            self.accept)
-        QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'rejected()'),
-            self.reject)
\ No newline at end of file
+        self.setupUi()
+        self.retranslateUi()
+
+    def setupUi(self):
+        self.setObjectName(u'serviceNoteEdit')
+        self.dialogLayout = QtGui.QVBoxLayout(self)
+        self.dialogLayout.setObjectName(u'verticalLayout')
+        self.textEdit = QtGui.QTextEdit(self)
+        self.textEdit.setObjectName(u'textEdit')
+        self.dialogLayout.addWidget(self.textEdit)
+        self.dialogLayout.addWidget(save_cancel_button_box(self))
+        QtCore.QMetaObject.connectSlotsByName(self)
+
+    def retranslateUi(self):
+        self.setWindowTitle(
+            translate('OpenLP.ServiceNoteForm', 'Service Item Notes')) 

=== modified file 'openlp/core/ui/slidecontroller.py'
--- openlp/core/ui/slidecontroller.py	2011-01-27 16:40:17 +0000
+++ openlp/core/ui/slidecontroller.py	2011-02-01 01:07:42 +0000
@@ -482,14 +482,7 @@
     def onSongBarHandler(self):
         request = unicode(self.sender().text())
         slideno = self.slideList[request]
-        if slideno > self.previewListWidget.rowCount():
-            self.previewListWidget.selectRow(
-                self.previewListWidget.rowCount() - 1)
-        else:
-            if slideno + 1 < self.previewListWidget.rowCount():
-                self.previewListWidget.scrollToItem(
-                    self.previewListWidget.item(slideno + 1, 0))
-            self.previewListWidget.selectRow(slideno)
+        self.__updatePreviewSelection(slideno)
         self.onSlideSelected()
 
     def receiveSpinDelay(self, value):
@@ -665,14 +658,7 @@
             self.previewListWidget.resizeRowsToContents()
         self.previewListWidget.setColumnWidth(0,
             self.previewListWidget.viewport().size().width())
-        if slideno > self.previewListWidget.rowCount():
-            self.previewListWidget.selectRow(
-                self.previewListWidget.rowCount() - 1)
-        else:
-            if slideno + 1 < self.previewListWidget.rowCount():
-                self.previewListWidget.scrollToItem(
-                    self.previewListWidget.item(slideno + 1, 0))
-            self.previewListWidget.selectRow(slideno)
+        self.__updatePreviewSelection(slideno)
         self.enableToolBar(serviceItem)
         # Pass to display for viewing
         self.display.buildHtml(self.serviceItem)
@@ -683,6 +669,19 @@
         Receiver.send_message(u'slidecontroller_%s_started' % self.typePrefix,
             [serviceItem])
 
+    def __updatePreviewSelection(self, slideno):
+        """
+        Utility method to update the selected slide in the list.
+        """
+        if slideno > self.previewListWidget.rowCount():
+            self.previewListWidget.selectRow(
+                self.previewListWidget.rowCount() - 1)
+        else:
+            if slideno + 1 < self.previewListWidget.rowCount():
+                self.previewListWidget.scrollToItem(
+                    self.previewListWidget.item(slideno + 1, 0))
+            self.previewListWidget.selectRow(slideno)
+
     def onTextRequest(self):
         """
         Return the text for the current item in controller

=== modified file 'openlp/core/ui/themestab.py'
--- openlp/core/ui/themestab.py	2011-01-09 15:37:45 +0000
+++ openlp/core/ui/themestab.py	2011-02-01 01:07:42 +0000
@@ -165,13 +165,7 @@
         self.global_theme = unicode(self.DefaultComboBox.currentText())
         self.parent.renderManager.set_global_theme(
             self.global_theme, self.theme_level)
-        image = self.parent.ThemeManagerContents.getPreviewImage(
-            self.global_theme)
-        preview = QtGui.QPixmap(unicode(image))
-        if not preview.isNull():
-            preview = preview.scaled(300, 255, QtCore.Qt.KeepAspectRatio,
-                QtCore.Qt.SmoothTransformation)
-        self.DefaultListView.setPixmap(preview)
+        self.__previewGlobalTheme()
 
     def updateThemeList(self, theme_list):
         """
@@ -198,10 +192,16 @@
         self.parent.renderManager.set_global_theme(
             self.global_theme, self.theme_level)
         if self.global_theme is not u'':
-            image = self.parent.ThemeManagerContents.getPreviewImage(
-                self.global_theme)
-            preview = QtGui.QPixmap(unicode(image))
-            if not preview.isNull():
-                preview = preview.scaled(300, 255, QtCore.Qt.KeepAspectRatio,
-                    QtCore.Qt.SmoothTransformation)
-            self.DefaultListView.setPixmap(preview)
+            self.__previewGlobalTheme()
+
+    def __previewGlobalTheme(self):
+        """
+        Utility method to update the global theme preview image.
+        """
+        image = self.parent.ThemeManagerContents.getPreviewImage(
+            self.global_theme)
+        preview = QtGui.QPixmap(unicode(image))
+        if not preview.isNull():
+            preview = preview.scaled(300, 255, QtCore.Qt.KeepAspectRatio,
+                QtCore.Qt.SmoothTransformation)
+        self.DefaultListView.setPixmap(preview)

=== modified file 'openlp/plugins/bibles/lib/mediaitem.py'
--- openlp/plugins/bibles/lib/mediaitem.py	2011-01-26 23:26:09 +0000
+++ openlp/plugins/bibles/lib/mediaitem.py	2011-02-01 01:07:42 +0000
@@ -525,19 +525,7 @@
         if self.advancedClearComboBox.currentIndex() == 0:
             self.listView.clear()
         if self.listView.count() != 0:
-            # Check if the first item is a second bible item or not.
-            bitem = self.listView.item(0)
-            item_second_bible = self._decodeQtObject(bitem, 'second_bible')
-            if item_second_bible and second_bible or not item_second_bible and \
-                not second_bible:
-                self.displayResults(bible, second_bible)
-            elif criticalErrorMessageBox(
-                message=translate('BiblePlugin.MediaItem',
-                'You cannot combine single and second bible verses. Do you '
-                'want to delete your search results and start a new search?'),
-                parent=self, question=True) == QtGui.QMessageBox.Yes:
-                self.listView.clear()
-                self.displayResults(bible, second_bible)
+            self.__checkSecondBible()
         else:
             self.displayResults(bible, second_bible)
         Receiver.send_message(u'cursor_normal')
@@ -577,24 +565,29 @@
         if self.quickClearComboBox.currentIndex() == 0:
             self.listView.clear()
         if self.listView.count() != 0 and self.search_results:
-            bitem = self.listView.item(0)
-            item_second_bible = self._decodeQtObject(bitem, 'second_bible')
-            if item_second_bible and second_bible or not item_second_bible and \
-                not second_bible:
-                self.displayResults(bible, second_bible)
-            elif criticalErrorMessageBox(
-                message=translate('BiblePlugin.MediaItem',
-                'You cannot combine single and second bible verses. Do you '
-                'want to delete your search results and start a new search?'),
-                parent=self, question=True) == QtGui.QMessageBox.Yes:
-                self.listView.clear()
-                self.displayResults(bible, second_bible)
+            self.__checkSecondBible()
         elif self.search_results:
             self.displayResults(bible, second_bible)
         self.quickSearchButton.setEnabled(True)
         Receiver.send_message(u'cursor_normal')
         Receiver.send_message(u'openlp_process_events')
 
+    def __checkSecondBible(self):
+        """
+        Check if the first item is a second bible item or not.
+        """
+        bitem = self.listView.item(0)
+        item_second_bible = self._decodeQtObject(bitem, 'second_bible')
+        if item_second_bible and second_bible or not item_second_bible and \
+            not second_bible:
+            self.displayResults(bible, second_bible)
+        elif criticalErrorMessageBox(message=translate('BiblePlugin.MediaItem',
+            'You cannot combine single and second bible verses. Do you '
+            'want to delete your search results and start a new search?'),
+            parent=self, question=True) == QtGui.QMessageBox.Yes:
+            self.listView.clear()
+            self.displayResults(bible, second_bible)
+
     def displayResults(self, bible, second_bible=u''):
         """
         Displays the search results in the media manager. All data needed for

=== modified file 'openlp/plugins/custom/forms/editcustomdialog.py'
--- openlp/plugins/custom/forms/editcustomdialog.py	2011-01-04 21:06:50 +0000
+++ openlp/plugins/custom/forms/editcustomdialog.py	2011-02-01 01:07:42 +0000
@@ -26,7 +26,7 @@
 
 from PyQt4 import QtCore, QtGui
 
-from openlp.core.lib import build_icon, translate
+from openlp.core.lib import build_icon, translate, save_cancel_button_box
 
 class Ui_CustomEditDialog(object):
     def setupUi(self, customEditDialog):
@@ -93,16 +93,9 @@
         self.creditLabel.setBuddy(self.creditEdit)
         self.bottomFormLayout.addRow(self.creditLabel, self.creditEdit)
         self.dialogLayout.addLayout(self.bottomFormLayout)
-        self.buttonBox = QtGui.QDialogButtonBox(customEditDialog)
-        self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel |
-            QtGui.QDialogButtonBox.Save)
-        self.buttonBox.setObjectName(u'buttonBox')
+        self.buttonBox = save_cancel_button_box(customEditDialog)
         self.dialogLayout.addWidget(self.buttonBox)
         self.retranslateUi(customEditDialog)
-        QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'accepted()'),
-            customEditDialog.accept)
-        QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'rejected()'),
-            customEditDialog.closePressed)
         QtCore.QMetaObject.connectSlotsByName(customEditDialog)
 
     def retranslateUi(self, customEditDialog):

=== modified file 'openlp/plugins/custom/forms/editcustomform.py'
--- openlp/plugins/custom/forms/editcustomform.py	2011-01-15 19:24:50 +0000
+++ openlp/plugins/custom/forms/editcustomform.py	2011-02-01 01:07:42 +0000
@@ -136,7 +136,7 @@
         if preview:
             self.previewButton.setVisible(True)
 
-    def closePressed(self):
+    def reject(self):
         Receiver.send_message(u'custom_edit_clear')
         self.close()
 

=== modified file 'openlp/plugins/custom/forms/editcustomslidedialog.py'
--- openlp/plugins/custom/forms/editcustomslidedialog.py	2011-01-04 21:06:50 +0000
+++ openlp/plugins/custom/forms/editcustomslidedialog.py	2011-02-01 01:07:42 +0000
@@ -26,7 +26,7 @@
 
 from PyQt4 import QtCore, QtGui
 
-from openlp.core.lib import translate, SpellTextEdit
+from openlp.core.lib import translate, SpellTextEdit, save_cancel_button_box
 
 class Ui_CustomSlideEditDialog(object):
     def setupUi(self, customSlideEditDialog):
@@ -36,20 +36,13 @@
         self.slideTextEdit = SpellTextEdit(self)
         self.slideTextEdit.setObjectName(u'slideTextEdit')
         self.dialogLayout.addWidget(self.slideTextEdit)
-        self.buttonBox = QtGui.QDialogButtonBox(customSlideEditDialog)
-        self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel |
-            QtGui.QDialogButtonBox.Save)
-        self.buttonBox.setObjectName(u'buttonBox')
+        self.buttonBox = save_cancel_button_box(customSlideEditDialog)
         self.splitButton = QtGui.QPushButton(customSlideEditDialog)
         self.splitButton.setObjectName(u'splitButton')
         self.buttonBox.addButton(self.splitButton,
             QtGui.QDialogButtonBox.ActionRole)
         self.dialogLayout.addWidget(self.buttonBox)
         self.retranslateUi(customSlideEditDialog)
-        QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'accepted()'),
-            customSlideEditDialog.accept)
-        QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'rejected()'),
-            customSlideEditDialog.reject)
         QtCore.QMetaObject.connectSlotsByName(customSlideEditDialog)
 
     def retranslateUi(self, customSlideEditDialog):

=== modified file 'openlp/plugins/custom/lib/mediaitem.py'
--- openlp/plugins/custom/lib/mediaitem.py	2011-01-26 18:14:46 +0000
+++ openlp/plugins/custom/lib/mediaitem.py	2011-02-01 01:07:42 +0000
@@ -146,16 +146,7 @@
         raw_footer = []
         slide = None
         theme = None
-        if item is None:
-            if self.remoteTriggered is None:
-                item = self.listView.currentItem()
-                if item is None:
-                    return False
-                item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
-            else:
-                item_id = self.remoteCustom
-        else:
-            item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
+        item_id = self._getIdOfItemToGenerate(item, self.remoteCustom)
         service_item.add_capability(ItemCapabilities.AllowsEdit)
         service_item.add_capability(ItemCapabilities.AllowsPreview)
         service_item.add_capability(ItemCapabilities.AllowsLoop)

=== modified file 'openlp/plugins/presentations/lib/messagelistener.py'
--- openlp/plugins/presentations/lib/messagelistener.py	2010-12-27 22:57:35 +0000
+++ openlp/plugins/presentations/lib/messagelistener.py	2011-02-01 01:07:42 +0000
@@ -116,7 +116,7 @@
 
     def last(self):
         """
-        Based on the handler passed at startup triggers the first slide
+        Based on the handler passed at startup triggers the last slide
         """
         log.debug(u'Live = %s, last' % self.is_live)
         if not self.is_live:

=== modified file 'openlp/plugins/songs/forms/authorsdialog.py'
--- openlp/plugins/songs/forms/authorsdialog.py	2011-01-08 20:59:46 +0000
+++ openlp/plugins/songs/forms/authorsdialog.py	2011-02-01 01:07:42 +0000
@@ -26,7 +26,7 @@
 
 from PyQt4 import QtCore, QtGui
 
-from openlp.core.lib import translate
+from openlp.core.lib import translate, save_cancel_button_box
 
 class Ui_AuthorsDialog(object):
     def setupUi(self, authorsDialog):
@@ -55,17 +55,9 @@
         self.displayLabel.setBuddy(self.displayEdit)
         self.authorLayout.addRow(self.displayLabel, self.displayEdit)
         self.dialogLayout.addLayout(self.authorLayout)
-        self.buttonBox = QtGui.QDialogButtonBox(authorsDialog)
-        self.buttonBox.setStandardButtons(
-            QtGui.QDialogButtonBox.Save | QtGui.QDialogButtonBox.Cancel)
-        self.buttonBox.setObjectName(u'buttonBox')
-        self.dialogLayout.addWidget(self.buttonBox)
+        self.dialogLayout.addWidget(save_cancel_button_box(authorsDialog))
         self.retranslateUi(authorsDialog)
         authorsDialog.setMaximumHeight(authorsDialog.sizeHint().height())
-        QtCore.QObject.connect(self.buttonBox,
-            QtCore.SIGNAL(u'accepted()'), authorsDialog.accept)
-        QtCore.QObject.connect(self.buttonBox,
-            QtCore.SIGNAL(u'rejected()'), authorsDialog.reject)
         QtCore.QMetaObject.connectSlotsByName(authorsDialog)
 
     def retranslateUi(self, authorsDialog):

=== modified file 'openlp/plugins/songs/forms/editsongdialog.py'
--- openlp/plugins/songs/forms/editsongdialog.py	2011-01-09 15:37:45 +0000
+++ openlp/plugins/songs/forms/editsongdialog.py	2011-02-01 01:07:42 +0000
@@ -26,7 +26,7 @@
 
 from PyQt4 import QtCore, QtGui
 
-from openlp.core.lib import build_icon, translate
+from openlp.core.lib import build_icon, translate, save_cancel_button_box
 
 class Ui_EditSongDialog(object):
     def setupUi(self, editSongDialog):
@@ -264,16 +264,9 @@
         self.themeTabLayout.addWidget(self.commentsGroupBox)
         self.songTabWidget.addTab(self.themeTab, u'')
         self.dialogLayout.addWidget(self.songTabWidget)
-        self.buttonBox = QtGui.QDialogButtonBox(editSongDialog)
-        self.buttonBox.setStandardButtons(
-            QtGui.QDialogButtonBox.Cancel | QtGui.QDialogButtonBox.Save)
-        self.buttonBox.setObjectName(u'buttonBox')
+        self.buttonBox = save_cancel_button_box(editSongDialog)
         self.dialogLayout.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)
 
     def retranslateUi(self, editSongDialog):

=== modified file 'openlp/plugins/songs/forms/editsongform.py'
--- openlp/plugins/songs/forms/editsongform.py	2011-01-18 19:31:03 +0000
+++ openlp/plugins/songs/forms/editsongform.py	2011-02-01 01:07:42 +0000
@@ -333,11 +333,7 @@
                     author = Author.populate(first_name=text.rsplit(u' ', 1)[0],
                         last_name=text.rsplit(u' ', 1)[1], display_name=text)
                 self.manager.save_object(author)
-                author_item = QtGui.QListWidgetItem(
-                    unicode(author.display_name))
-                author_item.setData(QtCore.Qt.UserRole,
-                    QtCore.QVariant(author.id))
-                self.authorsListView.addItem(author_item)
+                self.__addAuthorToList(author)
                 self.loadAuthors()
                 self.authorsComboBox.setCurrentIndex(0)
             else:
@@ -351,11 +347,7 @@
                     message=translate('SongsPlugin.EditSongForm',
                     'This author is already in the list.'))
             else:
-                author_item = QtGui.QListWidgetItem(unicode(
-                    author.display_name))
-                author_item.setData(QtCore.Qt.UserRole,
-                    QtCore.QVariant(author.id))
-                self.authorsListView.addItem(author_item)
+                self.__addAuthorToList(author)
             self.authorsComboBox.setCurrentIndex(0)
         else:
             QtGui.QMessageBox.warning(self,
@@ -365,6 +357,14 @@
                 'or type in a new author and click the "Add Author to '
                 'Song" button to add the new author.'))
 
+    def __addAuthorToList(self, author):
+        """
+        Add an author to the author list.
+        """
+        author_item = QtGui.QListWidgetItem(unicode(author.display_name))
+        author_item.setData(QtCore.Qt.UserRole, QtCore.QVariant(author.id))
+        self.authorsListView.addItem(author_item)
+
     def onAuthorsListViewPressed(self):
         if self.authorsListView.count() > 1:
             self.authorRemoveButton.setEnabled(True)
@@ -653,7 +653,7 @@
         self.books = []
         self.topics = []
 
-    def closePressed(self):
+    def reject(self):
         """
         Exit Dialog and do not save
         """

=== modified file 'openlp/plugins/songs/forms/editversedialog.py'
--- openlp/plugins/songs/forms/editversedialog.py	2011-01-04 21:06:50 +0000
+++ openlp/plugins/songs/forms/editversedialog.py	2011-02-01 01:07:42 +0000
@@ -26,7 +26,8 @@
 
 from PyQt4 import QtCore, QtGui
 
-from openlp.core.lib import build_icon, translate, SpellTextEdit
+from openlp.core.lib import build_icon, save_cancel_button_box, translate, \
+    SpellTextEdit
 from openlp.plugins.songs.lib import VerseType
 
 class Ui_EditVerseDialog(object):
@@ -59,17 +60,8 @@
         self.verseTypeLayout.addWidget(self.insertButton)
         self.verseTypeLayout.addStretch()
         self.dialogLayout.addLayout(self.verseTypeLayout)
-        self.buttonBox = QtGui.QDialogButtonBox(editVerseDialog)
-        self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
-        self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel |
-            QtGui.QDialogButtonBox.Save)
-        self.buttonBox.setObjectName(u'buttonBox')
-        self.dialogLayout.addWidget(self.buttonBox)
+        self.dialogLayout.addWidget(save_cancel_button_box(editVerseDialog))
         self.retranslateUi(editVerseDialog)
-        QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'accepted()'),
-            editVerseDialog.accept)
-        QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'rejected()'),
-            editVerseDialog.reject)
         QtCore.QMetaObject.connectSlotsByName(editVerseDialog)
 
     def retranslateUi(self, editVerseDialog):

=== modified file 'openlp/plugins/songs/forms/songbookdialog.py'
--- openlp/plugins/songs/forms/songbookdialog.py	2011-01-04 21:06:50 +0000
+++ openlp/plugins/songs/forms/songbookdialog.py	2011-02-01 01:07:42 +0000
@@ -26,7 +26,7 @@
 
 from PyQt4 import QtCore, QtGui
 
-from openlp.core.lib import translate
+from openlp.core.lib import translate, save_cancel_button_box
 
 class Ui_SongBookDialog(object):
     def setupUi(self, songBookDialog):
@@ -49,17 +49,9 @@
         self.publisherLabel.setBuddy(self.publisherEdit)
         self.bookLayout.addRow(self.publisherLabel, self.publisherEdit)
         self.dialogLayout.addLayout(self.bookLayout)
-        self.buttonBox = QtGui.QDialogButtonBox(songBookDialog)
-        self.buttonBox.setStandardButtons(
-            QtGui.QDialogButtonBox.Save | QtGui.QDialogButtonBox.Cancel)
-        self.buttonBox.setObjectName(u'buttonBox')
-        self.dialogLayout.addWidget(self.buttonBox)
+        self.dialogLayout.addWidget(save_cancel_button_box(songBookDialog))
         self.retranslateUi(songBookDialog)
         songBookDialog.setMaximumHeight(songBookDialog.sizeHint().height())
-        QtCore.QObject.connect(self.buttonBox,
-            QtCore.SIGNAL(u'accepted()'), songBookDialog.accept)
-        QtCore.QObject.connect(self.buttonBox,
-            QtCore.SIGNAL(u'rejected()'), songBookDialog.reject)
         QtCore.QMetaObject.connectSlotsByName(songBookDialog)
 
     def retranslateUi(self, songBookDialog):

=== modified file 'openlp/plugins/songs/forms/songmaintenanceform.py'
--- openlp/plugins/songs/forms/songmaintenanceform.py	2011-01-27 16:59:15 +0000
+++ openlp/plugins/songs/forms/songmaintenanceform.py	2011-02-01 01:07:42 +0000
@@ -310,12 +310,8 @@
                 'the existing author %s?')) % (author.display_name,
                 temp_display_name, author.display_name),
                 parent=self, question=True) == QtGui.QMessageBox.Yes:
-                Receiver.send_message(u'cursor_busy')
-                Receiver.send_message(u'openlp_process_events')
-                self.mergeAuthors(author)
-                self.resetAuthors()
-                Receiver.send_message(u'songs_load_list')
-                Receiver.send_message(u'cursor_normal')
+                self.__mergeObjects(author, self.mergeAuthors,
+                    self.resetAuthors)
             else:
                 # We restore the author's old first and last name as well as
                 # his display name.
@@ -350,11 +346,7 @@
                 'with topic %s use the existing topic %s?')) % (topic.name,
                 temp_name, topic.name),
                 parent=self, question=True) == QtGui.QMessageBox.Yes:
-                Receiver.send_message(u'cursor_busy')
-                Receiver.send_message(u'openlp_process_events')
-                self.mergeTopics(topic)
-                self.resetTopics()
-                Receiver.send_message(u'cursor_normal')
+                self.__mergeObjects(topic, self.mergeTopics, self.resetTopics)
             else:
                 # We restore the topics's old name.
                 topic.name = temp_name
@@ -392,16 +384,23 @@
                 'with book %s use the existing book %s?')) % (book.name,
                 temp_name, book.name),
                 parent=self, question=True) == QtGui.QMessageBox.Yes:
-                Receiver.send_message(u'cursor_busy')
-                Receiver.send_message(u'openlp_process_events')
-                self.mergeBooks(book)
-                self.resetBooks()
-                Receiver.send_message(u'cursor_normal')
+                self.__mergeObjects(book, self.mergeBooks, self.resetBooks)
             else:
                 # We restore the book's old name and publisher.
                 book.name = temp_name
                 book.publisher = temp_publisher
 
+    def __mergeObjects(self, object, merge, reset):
+        """
+        Utility method to merge two objects to leave one in the database.
+        """
+        Receiver.send_message(u'cursor_busy')
+        Receiver.send_message(u'openlp_process_events')
+        merge(object)
+        reset()
+        Receiver.send_message(u'songs_load_list')
+        Receiver.send_message(u'cursor_normal')
+
     def mergeAuthors(self, old_author):
         """
         Merges two authors into one author.
@@ -508,42 +507,32 @@
 
     def onAuthorsListRowChanged(self, row):
         """
-        Called when the *authorsListWidget* current's row has changed.
-
-        ``row``
-            The current row. If there is no current row, the value is -1
+        Called when the *authorsListWidget*s current row has changed.
         """
-        if row == -1:
-            self.authorsDeleteButton.setEnabled(False)
-            self.authorsEditButton.setEnabled(False)
-        else:
-            self.authorsDeleteButton.setEnabled(True)
-            self.authorsEditButton.setEnabled(True)
+        self.__rowChange(row, self.authorsEditButton, self.authorsDeleteButton)
 
     def onTopicsListRowChanged(self, row):
         """
-        Called when the *booksListWidget* current's row has changed.
-
-        ``row``
-            The current row. If there is no current row, the value is -1.
+        Called when the *topicsListWidget*s current row has changed.
         """
-        if row == -1:
-            self.topicsDeleteButton.setEnabled(False)
-            self.topicsEditButton.setEnabled(False)
-        else:
-            self.topicsDeleteButton.setEnabled(True)
-            self.topicsEditButton.setEnabled(True)
+        self.__rowChange(row, self.topicsEditButton, self.topicsDeleteButton)
 
     def onBooksListRowChanged(self, row):
         """
-        Called when the *booksListWidget* current's row has changed.
+        Called when the *booksListWidget*s current row has changed.
+        """
+        self.__rowChange(row, self.booksEditButton, self.booksDeleteButton)
+
+    def __rowChange(self, row, editButton, deleteButton):
+        """
+        Utility method to toggle if buttons are enabled.
 
         ``row``
             The current row. If there is no current row, the value is -1.
         """
         if row == -1:
-            self.booksDeleteButton.setEnabled(False)
-            self.booksEditButton.setEnabled(False)
+            deleteButton.setEnabled(False)
+            editButton.setEnabled(False)
         else:
-            self.booksDeleteButton.setEnabled(True)
-            self.booksEditButton.setEnabled(True)
+            deleteButton.setEnabled(True)
+            editButton.setEnabled(True)

=== modified file 'openlp/plugins/songs/forms/topicsdialog.py'
--- openlp/plugins/songs/forms/topicsdialog.py	2011-01-04 21:06:50 +0000
+++ openlp/plugins/songs/forms/topicsdialog.py	2011-02-01 01:07:42 +0000
@@ -26,7 +26,7 @@
 
 from PyQt4 import QtCore, QtGui
 
-from openlp.core.lib import translate
+from openlp.core.lib import translate, save_cancel_button_box
 
 class Ui_TopicsDialog(object):
     def setupUi(self, topicsDialog):
@@ -43,17 +43,9 @@
         self.nameLabel.setBuddy(self.nameEdit)
         self.nameLayout.addRow(self.nameLabel, self.nameEdit)
         self.dialogLayout.addLayout(self.nameLayout)
-        self.buttonBox = QtGui.QDialogButtonBox(topicsDialog)
-        self.buttonBox.setStandardButtons(
-            QtGui.QDialogButtonBox.Save | QtGui.QDialogButtonBox.Cancel)
-        self.buttonBox.setObjectName(u'buttonBox')
-        self.dialogLayout.addWidget(self.buttonBox)
+        self.dialogLayout.addWidget(save_cancel_button_box(topicsDialog))
         self.retranslateUi(topicsDialog)
         topicsDialog.setMaximumHeight(topicsDialog.sizeHint().height())
-        QtCore.QObject.connect(self.buttonBox,
-            QtCore.SIGNAL(u'accepted()'), topicsDialog.accept)
-        QtCore.QObject.connect(self.buttonBox,
-            QtCore.SIGNAL(u'rejected()'), topicsDialog.reject)
         QtCore.QMetaObject.connectSlotsByName(topicsDialog)
 
     def retranslateUi(self, topicsDialog):

=== modified file 'openlp/plugins/songs/lib/easislidesimport.py'
--- openlp/plugins/songs/lib/easislidesimport.py	2011-01-26 02:43:16 +0000
+++ openlp/plugins/songs/lib/easislidesimport.py	2011-02-01 01:07:42 +0000
@@ -133,30 +133,38 @@
             pass
 
     def _add_copyright(self, song):
+        """
+        Assign the copyright information from the import to the song being
+        created.
+
+        ``song``
+            The current song being imported.
+        """
         copyright = []
-        try:
-            copyright.append(unicode(song.Copyright).strip())
-        except UnicodeDecodeError:
-            log.exception(u'Unicode decode error while decoding Copyright')
-            self._success = False
-        except AttributeError:
-            pass
-        try:
-            copyright.append(unicode(song.LicenceAdmin1).strip())
-        except UnicodeDecodeError:
-            log.exception(u'Unicode decode error while decoding LicenceAdmin1')
-            self._success = False
-        except AttributeError:
-            pass
-        try:
-            copyright.append(unicode(song.LicenceAdmin2).strip())
-        except UnicodeDecodeError:
-            log.exception(u'Unicode decode error while decoding LicenceAdmin2')
-            self._success = False
-        except AttributeError:
-            pass
+        self.__add_copyright_element(copyright, song.Copyright)
+        self.__add_copyright_element(copyright, song.LicenceAdmin1)
+        self.__add_copyright_element(copyright, song.LicenceAdmin2)
         self.add_copyright(u' '.join(copyright))
 
+    def __add_copyright_element(self, copyright, element):
+        """
+        Add a piece of copyright to the total copyright information for the
+        song.
+
+        ``copyright``
+            The array to add the information to.
+
+        ``element``
+            The imported variable to get the data from.
+        """
+        try:
+            copyright.append(unicode(element).strip())
+        except UnicodeDecodeError:
+            log.exception(u'Unicode error decoding %s' % element)
+            self._success = False
+        except AttributeError:
+            pass
+
     def _parse_and_add_lyrics(self, song):
         try:
             lyrics = unicode(song.Contents).strip()

=== modified file 'openlp/plugins/songs/lib/mediaitem.py'
--- openlp/plugins/songs/lib/mediaitem.py	2011-01-26 18:14:46 +0000
+++ openlp/plugins/songs/lib/mediaitem.py	2011-02-01 01:07:42 +0000
@@ -337,16 +337,7 @@
         author_list = u''
         author_audit = []
         ccli = u''
-        if item is None:
-            if self.remoteTriggered is None:
-                item = self.listView.currentItem()
-                if item is None:
-                    return False
-                item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
-            else:
-                item_id = self.remoteSong
-        else:
-            item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
+        item_id = self._getIdOfItemToGenerate(item, self.remoteSong)
         service_item.add_capability(ItemCapabilities.AllowsEdit)
         service_item.add_capability(ItemCapabilities.AllowsPreview)
         service_item.add_capability(ItemCapabilities.AllowsLoop)


Follow ups