← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~trb143/openlp/fixes into lp:openlp

 

Tim Bentley has proposed merging lp:~trb143/openlp/fixes into lp:openlp.

    Requested reviews:
    OpenLP Core (openlp-core)


Clean ups to get Custom Remote Editing working
Fixed theme errors discovered
-- 
https://code.launchpad.net/~trb143/openlp/fixes/+merge/14560
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp/core/lib/serviceitem.py'
--- openlp/core/lib/serviceitem.py	2009-11-04 18:21:08 +0000
+++ openlp/core/lib/serviceitem.py	2009-11-06 18:55:19 +0000
@@ -256,3 +256,26 @@
                 self.add_from_command(path, text_image)
         elif self.service_item_type == ServiceItemType.Video:
             pass
+
+    def merge(self, other):
+        """
+        Updates the uuid with the value from the original one
+        The uuid is unique for a give service item but this allows one to
+        replace an original version.
+        """
+        self.uuid = other.uuid
+
+    def __eq__(self, other):
+        """
+        Confirms the service items are for the same instance
+        """
+        if not other:
+            return False
+        return self.uuid == other.uuid
+
+    def __ne__(self, other):
+        """
+        Confirms the service items are not for the same instance
+        """
+        return self.uuid != other.uuid
+

=== modified file 'openlp/core/ui/servicemanager.py'
--- openlp/core/ui/servicemanager.py	2009-11-03 19:21:58 +0000
+++ openlp/core/ui/servicemanager.py	2009-11-06 18:55:19 +0000
@@ -544,7 +544,7 @@
         sitem, count = self.findServiceItem()
         item.render()
         if self.remoteEditTriggered:
-            item.uuid = self.serviceItems[sitem][u'data'].uuid
+            item.merge(self.serviceItems[sitem][u'data'])
             self.serviceItems[sitem][u'data'] = item
             self.remoteEditTriggered = False
             self.repaintServiceList(sitem + 1, 0)

=== modified file 'openlp/core/ui/slidecontroller.py'
--- openlp/core/ui/slidecontroller.py	2009-11-04 01:16:15 +0000
+++ openlp/core/ui/slidecontroller.py	2009-11-06 18:55:19 +0000
@@ -361,8 +361,7 @@
         """
         Replacement item following a remote edit
         """
-        if self.commandItem and \
-            item.uuid == self.commandItem.uuid:
+        if item.__eq__(self.commandItem):
             self.addServiceManagerItem(item, self.PreviewListWidget.currentRow())
 
     def addServiceManagerItem(self, item, slideno):

=== modified file 'openlp/core/ui/thememanager.py'
--- openlp/core/ui/thememanager.py	2009-11-06 02:12:56 +0000
+++ openlp/core/ui/thememanager.py	2009-11-06 18:55:19 +0000
@@ -276,7 +276,7 @@
         xml = file_to_xml(xml_file)
         if not xml:
             xml = self.baseTheme()
-        return createThemeFromXml(xml, self.path)
+        return self.createThemeFromXml(xml, self.path)
 
     def checkThemesExists(self, dir):
         log.debug(u'check themes')

=== modified file 'openlp/plugins/custom/forms/editcustomform.py'
--- openlp/plugins/custom/forms/editcustomform.py	2009-10-31 20:38:57 +0000
+++ openlp/plugins/custom/forms/editcustomform.py	2009-11-06 18:55:19 +0000
@@ -21,6 +21,7 @@
 # with this program; if not, write to the Free Software Foundation, Inc., 59  #
 # Temple Place, Suite 330, Boston, MA 02111-1307 USA                          #
 ###############################################################################
+import logging
 
 from PyQt4 import QtCore, QtGui
 
@@ -32,6 +33,9 @@
     """
     Class documentation goes here.
     """
+    global log
+    log = logging.getLogger(u'EditCustomForm')
+    log.info(u'Custom Editor loaded')
     def __init__(self, custommanager, parent = None):
         """
         Constructor
@@ -40,6 +44,12 @@
         #self.parent = parent
         self.setupUi(self)
         # Connecting signals and slots
+        self.previewButton = QtGui.QPushButton()
+        self.previewButton.setText(self.trUtf8(u'Save && Preview'))
+        self.buttonBox.addButton(
+            self.previewButton, QtGui.QDialogButtonBox.ActionRole)
+        QtCore.QObject.connect(self.buttonBox,
+            QtCore.SIGNAL(u'clicked(QAbstractButton*)'), self.onPreview)
         QtCore.QObject.connect(self.AddButton,
             QtCore.SIGNAL(u'pressed()'), self.onAddButtonPressed)
         QtCore.QObject.connect(self.EditButton,
@@ -68,6 +78,12 @@
         self.custommanager = custommanager
         self.initialise()
 
+    def onPreview(self, button):
+        log.debug(u'onPreview')
+        if button.text() == unicode(self.trUtf8(u'Save && Preview')) \
+            and self.saveCustom():
+            Receiver().send_message(u'preview_custom')
+
     def initialise(self):
         self.editAll = False
         self.DeleteButton.setEnabled(False)
@@ -89,7 +105,7 @@
         for themename in themelist:
             self.ThemeComboBox.addItem(themename)
 
-    def loadCustom(self, id):
+    def loadCustom(self, id, preview):
         self.customSlide = CustomSlide()
         self.initialise()
         if id != 0:
@@ -108,17 +124,27 @@
             self.ThemeComboBox.setCurrentIndex(id)
         else:
             self.ThemeComboBox.setCurrentIndex(0)
+        #if not preview hide the preview button
+        self.previewButton.setVisible(False)
+        if preview:
+            self.previewButton.setVisible(True)
 
     def closePressed(self):
         Receiver().send_message(u'remote_edit_clear')
         self.close()
 
     def accept(self):
+        log.debug(u'accept')
+        if self.saveCustom():
+            Receiver().send_message(u'load_custom_list')
+            self.close()
+
+    def saveCustom(self):
         valid, message = self._validate()
         if not valid:
             QtGui.QMessageBox.critical(self, self.trUtf8(u'Error'), message,
                 QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok))
-            return
+            return False
         sxml = SongXMLBuilder()
         sxml.new_document()
         sxml.add_lyrics_to_song()
@@ -132,8 +158,7 @@
         self.customSlide.credits = unicode(self.CreditEdit.displayText())
         self.customSlide.theme_name = unicode(self.ThemeComboBox.currentText())
         self.custommanager.save_slide(self.customSlide)
-        Receiver().send_message(u'load_custom_list')
-        self.close()
+        return True
 
     def onUpButtonPressed(self):
         selectedRow = self.VerseListView.currentRow()

=== modified file 'openlp/plugins/custom/lib/mediaitem.py'
--- openlp/plugins/custom/lib/mediaitem.py	2009-11-03 19:01:53 +0000
+++ openlp/plugins/custom/lib/mediaitem.py	2009-11-06 18:55:19 +0000
@@ -50,7 +50,9 @@
         self.ListViewWithDnD_class = CustomListView
         self.servicePath = None
         MediaManagerItem.__init__(self, parent, icon, title)
-        self.fromServiceManager = -1
+        # Holds information about whether the edit is remotly triggered and
+        # which Custom is required.
+        self.remoteCustom = -1
 
     def addEndHeaderBar(self):
         QtCore.QObject.connect(Receiver.get_receiver(),
@@ -59,6 +61,8 @@
             QtCore.SIGNAL(u'remote_edit_clear' ), self.onRemoteEditClear)
         QtCore.QObject.connect(Receiver.get_receiver(),
             QtCore.SIGNAL(u'load_custom_list'), self.initialise)
+        QtCore.QObject.connect(Receiver.get_receiver(),
+            QtCore.SIGNAL(u'preview_custom'), self.onPreviewClick)
 
     def initPluginNameVisible(self):
         self.PluginNameVisible = self.trUtf8(u'Custom')
@@ -69,6 +73,14 @@
 
     def initialise(self):
         self.loadCustomListView(self.parent.custommanager.get_all_slides())
+        #Called to redisplay the song list screen edith from a search
+        #or from the exit of the Song edit dialog.  If remote editing is active
+        #Trigger it and clean up so it will not update again.
+        if self.remoteTriggered == u'L':
+            self.onAddClick()
+        if self.remoteTriggered == u'P':
+            self.onPreviewClick()
+        self.onRemoteEditClear()
 
     def loadCustomListView(self, list):
         self.ListView.clear()
@@ -77,8 +89,6 @@
             custom_name.setData(
                 QtCore.Qt.UserRole, QtCore.QVariant(CustomSlide.id))
             self.ListView.addItem(custom_name)
-            if CustomSlide.id == self.fromServiceManager:
-                self.onAddClick()
 
     def onNewClick(self):
         self.parent.edit_custom_form.loadCustom(0)
@@ -86,20 +96,29 @@
         self.initialise()
 
     def onRemoteEditClear(self):
-        self.fromServiceManager = -1
+        self.remoteTriggered = None
+        self.remoteCustom = -1
 
-    def onRemoteEdit(self, item_id):
-        valid = self.parent.custommanager.get_custom(item_id)
+    def onRemoteEdit(self, customid):
+        """
+        Called by ServiceManager or SlideController by event passing
+        the Song Id in the payload along with an indicator to say which
+        type of display is required.
+        """
+        fields = customid.split(u':')
+        valid = self.parent.custommanager.get_custom(fields[1])
         if valid:
-            self.fromServiceManager = item_id
-            self.parent.edit_custom_form.loadCustom(item_id)
+            self.remoteCustom = fields[1]
+            self.remoteTriggered = fields[0]
+            self.parent.edit_custom_form.loadCustom(fields[1],
+                (fields[0] == u'P'))
             self.parent.edit_custom_form.exec_()
 
     def onEditClick(self):
         item = self.ListView.currentItem()
         if item:
             item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
-            self.parent.edit_custom_form.loadCustom(item_id)
+            self.parent.edit_custom_form.loadCustom(item_id, False)
             self.parent.edit_custom_form.exec_()
             self.initialise()
 
@@ -116,14 +135,13 @@
         raw_footer = []
         slide = None
         theme = None
-        if self.fromServiceManager == -1:
+        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.fromServiceManager
-            self.fromServiceManager = -1
+            item_id = self.remoteCustom
         customSlide = self.parent.custommanager.get_custom(item_id)
         title = customSlide.title
         credit = customSlide.credits
@@ -137,9 +155,8 @@
         for verse in verseList:
             raw_slides.append(verse[1])
         raw_footer.append(title + u' '+ credit)
-        if theme:
-            service_item.title = title
-            for slide in raw_slides:
-                service_item.add_from_text(slide[:30], slide)
-            service_item.raw_footer = raw_footer
+        service_item.title = title
+        for slide in raw_slides:
+            service_item.add_from_text(slide[:30], slide)
+        service_item.raw_footer = raw_footer
         return True

=== modified file 'openlp/plugins/songs/forms/editsongform.py'
--- openlp/plugins/songs/forms/editsongform.py	2009-11-04 01:16:15 +0000
+++ openlp/plugins/songs/forms/editsongform.py	2009-11-06 18:55:19 +0000
@@ -462,7 +462,7 @@
             text = text.replace(u'}', u'')
             text = text.replace(u'?', u'')
             self.song.search_lyrics = unicode(text)
-            self.song.lyrics = unicode(sxml.extract_xml())
+            self.song.lyrics = unicode(sxml.extract_xml(), u'utf-8')
         except:
             log.exception(u'Problem processing song Lyrics \n%s',
                 sxml.dump_xml())


Follow ups