← 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)


Initial version of edit songs and custom from service item.
Works fine but unable to hide edit menu item as it messes up all mouse events.  Code commented out till we can understand what I have done wrong.
Rest of the code is code is fine though.
-- 
https://code.launchpad.net/~trb143/openlp/fixes/+merge/14165
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp/core/lib/eventreceiver.py'
--- openlp/core/lib/eventreceiver.py	2009-10-27 08:38:02 +0000
+++ openlp/core/lib/eventreceiver.py	2009-10-29 13:55:18 +0000
@@ -78,6 +78,9 @@
     ``{plugin}_stop``
         Requests a plugin to handle a stop event
 
+    ``{plugin}_edit``
+        Requests a plugin edit a database item with the key as the payload
+
     ``songusage_live``
         Sends live song audit requests to the audit component
 
@@ -93,10 +96,14 @@
     ``preview_song``
         Tells the song plugin the edit has finished and the song can be previewed
         Only available if the edit was triggered by the Preview button.
-        
+
     ``slidecontroller_change``
         Informs the slidecontroller that a slide change has occurred
 
+
+    ``remote_edite_clear``
+        Informs all components that remote edit has been aborted.
+
     """
     global log
     log = logging.getLogger(u'EventReceiver')
@@ -154,4 +161,4 @@
         """
         Get the global ``eventreceiver`` instance.
         """
-        return Receiver.eventreceiver
\ No newline at end of file
+        return Receiver.eventreceiver

=== modified file 'openlp/core/lib/serviceitem.py'
--- openlp/core/lib/serviceitem.py	2009-10-16 23:34:56 +0000
+++ openlp/core/lib/serviceitem.py	2009-10-29 13:55:18 +0000
@@ -70,6 +70,7 @@
         self.theme = None
         self.service_item_path = None
         self.service_item_type = None
+        self.editEnabled = False
         self.service_frames = []
 
     def addIcon(self, icon):

=== modified file 'openlp/core/ui/servicemanager.py'
--- openlp/core/ui/servicemanager.py	2009-10-25 18:07:23 +0000
+++ openlp/core/ui/servicemanager.py	2009-10-29 13:55:18 +0000
@@ -38,6 +38,24 @@
         QtGui.QTreeWidget.__init__(self,parent)
         self.parent = parent
 
+#    def mousePressEvent(self, event):
+#        if event.button() == QtCore.Qt.RightButton:
+#            item = self.itemAt(event.pos())
+#            parentitem = item.parent()
+#            if parentitem is None:
+#                pos = item.data(0, QtCore.Qt.UserRole).toInt()[0]
+#            else:
+#                pos = parentitem.data(0, QtCore.Qt.UserRole).toInt()[0]
+#            serviceItem = self.parent.serviceItems[pos - 1]
+#            if serviceItem[u'data'].editEnabled:
+#                self.parent.editAction.setVisible(True)
+#            else:
+#                self.parent.editAction.setVisible(False)
+#            event.accept()
+#        else:
+#            event.ignore()
+
+
     def keyPressEvent(self, event):
         if type(event) == QtGui.QKeyEvent:
             #here accept the event and do something
@@ -111,6 +129,7 @@
         self.serviceItems = []
         self.serviceName = u''
         self.isNew = True
+        self.remoteEditTriggered = False
         self.Layout = QtGui.QVBoxLayout(self)
         self.Layout.setSpacing(0)
         self.Layout.setMargin(0)
@@ -157,6 +176,12 @@
         # Add a context menu to the service manager list
         self.ServiceManagerList.setContextMenuPolicy(
             QtCore.Qt.ActionsContextMenu)
+        self.editAction = contextMenuAction(
+            self.ServiceManagerList, ':/system/system_live.png',
+            self.trUtf8(u'&Edit Item'), self.remoteEdit)
+        self.ServiceManagerList.addAction(self.editAction)
+        self.ServiceManagerList.addAction(contextMenuSeparator(
+            self.ServiceManagerList))
         self.ServiceManagerList.addAction(contextMenuAction(
             self.ServiceManagerList, ':/system/system_preview.png',
             self.trUtf8(u'&Preview Verse'), self.makePreview))
@@ -205,6 +230,8 @@
            QtCore.SIGNAL(u'itemExpanded(QTreeWidgetItem*)'), self.expanded)
         QtCore.QObject.connect(Receiver.get_receiver(),
             QtCore.SIGNAL(u'update_themes'), self.updateThemeList)
+        QtCore.QObject.connect(Receiver.get_receiver(),
+            QtCore.SIGNAL(u'remote_edit_clear'), self.onRemoteEditClear)
         # Last little bits of setting up
         self.config = PluginConfig(u'ServiceManager')
         self.servicePath = self.config.get_data_path()
@@ -510,14 +537,19 @@
         """
         sitem, count = self.findServiceItem()
         item.render()
-        if sitem == -1:
-            self.serviceItems.append({u'data': item,
-                u'order': len(self.serviceItems) + 1, u'expanded':True})
-            self.repaintServiceList(len(self.serviceItems) + 1, 0)
-        else:
-            self.serviceItems.insert(sitem + 1, {u'data': item,
-                u'order': len(self.serviceItems)+1, u'expanded':True})
+        if self.remoteEditTriggered:
+            self.serviceItems[sitem][u'data'] = item
+            self.remoteEditTriggered = False
             self.repaintServiceList(sitem + 1, 0)
+        else:
+            if sitem == -1:
+                self.serviceItems.append({u'data': item,
+                    u'order': len(self.serviceItems) + 1, u'expanded':True})
+                self.repaintServiceList(len(self.serviceItems) + 1, 0)
+            else:
+                self.serviceItems.insert(sitem + 1, {u'data': item,
+                    u'order': len(self.serviceItems)+1, u'expanded':True})
+                self.repaintServiceList(sitem + 1, 0)
         self.parent.serviceChanged(False, self.serviceName)
 
     def makePreview(self):
@@ -536,6 +568,19 @@
         self.parent.LiveController.addServiceManagerItem(
             self.serviceItems[item][u'data'], count)
 
+    def remoteEdit(self):
+        """
+        Posts a remote edit message to a plugin to allow item to be edited.
+        """
+        item, count = self.findServiceItem()
+        if self.serviceItems[item][u'data'].editEnabled:
+            self.remoteEditTriggered = True
+            Receiver().send_message(u'%s_edit' % self.serviceItems[item][u'data'].name,
+                self.serviceItems[item][u'data'].editId )
+
+    def onRemoteEditClear(self):
+        self.remoteEditTriggered = False
+
     def findServiceItem(self):
         """
         Finds a ServiceItem in the list

=== modified file 'openlp/core/ui/thememanager.py'
--- openlp/core/ui/thememanager.py	2009-10-29 13:19:31 +0000
+++ openlp/core/ui/thememanager.py	2009-10-29 13:55:19 +0000
@@ -266,7 +266,20 @@
         try:
             xml = file_to_xml(xml_file)
         except:
+<<<<<<< TREE
             xml = baseTheme()
+=======
+            newtheme = ThemeXML()
+            newtheme.new_document(unicode(self.trUtf8(u'New Theme')))
+            newtheme.add_background_solid(unicode(u'#000000'))
+            newtheme.add_font(unicode(QtGui.QFont().family()),
+                unicode(u'#FFFFFF'), unicode(30), u'False')
+            newtheme.add_font(unicode(QtGui.QFont().family()),
+                unicode(u'#FFFFFF'), unicode(12), u'False', u'footer')
+            newtheme.add_display(u'False', unicode(u'#FFFFFF'), u'False',
+                unicode(u'#FFFFFF'), unicode(0), unicode(0), unicode(0))
+            xml = newtheme.extract_xml()
+>>>>>>> MERGE-SOURCE
         theme = ThemeXML()
         theme.parse(xml)
         self.cleanTheme(theme)

=== modified file 'openlp/plugins/custom/customplugin.py'
--- openlp/plugins/custom/customplugin.py	2009-10-10 13:39:32 +0000
+++ openlp/plugins/custom/customplugin.py	2009-10-29 13:55:19 +0000
@@ -69,4 +69,4 @@
         self.remove_toolbox_item()
 
     def about(self):
-        return u'<b>Custom Plugin</b> <br>This plugin allows slides to be displayed on the screen in the same way songs are. The difference between this plugin and songs is this plugin provides greater freedom.<br><br>This is a core plugin and cannot be made inactive</b>'
+        return u'<b>Custom Plugin</b> <br>This plugin allows slides to be displayed on the screen in the same way songs are. The difference between this plugin and songs is this plugin provides greater freedom.<br>'

=== modified file 'openlp/plugins/custom/forms/editcustomdialog.py'
--- openlp/plugins/custom/forms/editcustomdialog.py	2009-10-24 16:40:36 +0000
+++ openlp/plugins/custom/forms/editcustomdialog.py	2009-10-29 13:55:19 +0000
@@ -54,7 +54,8 @@
         self.UpButton.setIcon(icon1)
         self.UpButton.setObjectName(u'UpButton')
         self.verticalLayout.addWidget(self.UpButton)
-        spacerItem = QtGui.QSpacerItem(20, 128, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
+        spacerItem = QtGui.QSpacerItem(20, 128,
+            QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
         self.verticalLayout.addItem(spacerItem)
         self.DownButton = QtGui.QPushButton(customEditDialog)
         icon2 = buildIcon(u':/services/service_down.png')
@@ -94,7 +95,8 @@
         self.ClearButton = QtGui.QPushButton(self.ButtonWidge)
         self.ClearButton.setObjectName(u'ClearButton')
         self.verticalLayout_2.addWidget(self.ClearButton)
-        spacerItem1 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
+        spacerItem1 = QtGui.QSpacerItem(20, 40,
+            QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
         self.verticalLayout_2.addItem(spacerItem1)
         self.EditLayout_3.addWidget(self.ButtonWidge)
         self.gridLayout.addWidget(self.EditWidget, 2, 0, 1, 1)
@@ -117,11 +119,16 @@
         self.horizontalLayout_2.addWidget(self.CreditEdit)
         self.gridLayout.addLayout(self.horizontalLayout_2, 4, 0, 1, 1)
         self.buttonBox = QtGui.QDialogButtonBox(customEditDialog)
-        self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok)
+        self.buttonBox.setStandardButtons(
+            QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok)
         self.buttonBox.setObjectName(u'buttonBox')
         self.gridLayout.addWidget(self.buttonBox, 5, 0, 1, 1)
 
         self.retranslateUi(customEditDialog)
+        QtCore.QObject.connect(self.buttonBox,
+            QtCore.SIGNAL(u'rejected()'), customEditDialog.closePressed)
+        QtCore.QObject.connect(self.buttonBox,
+            QtCore.SIGNAL(u'accepted()'), customEditDialog.accept)
         QtCore.QMetaObject.connectSlotsByName(customEditDialog)
         customEditDialog.setTabOrder(self.TitleEdit, self.VerseTextEdit)
         customEditDialog.setTabOrder(self.VerseTextEdit, self.AddButton)

=== modified file 'openlp/plugins/custom/forms/editcustomform.py'
--- openlp/plugins/custom/forms/editcustomform.py	2009-10-24 16:40:36 +0000
+++ openlp/plugins/custom/forms/editcustomform.py	2009-10-29 13:55:19 +0000
@@ -40,10 +40,6 @@
         #self.parent = parent
         self.setupUi(self)
         # Connecting signals and slots
-        QtCore.QObject.connect(self.buttonBox,
-            QtCore.SIGNAL(u'rejected()'), self.rejected)
-        QtCore.QObject.connect(self.buttonBox,
-            QtCore.SIGNAL(u'accepted()'), self.accept)
         QtCore.QObject.connect(self.AddButton,
             QtCore.SIGNAL(u'pressed()'), self.onAddButtonPressed)
         QtCore.QObject.connect(self.EditButton,
@@ -113,6 +109,10 @@
         else:
             self.ThemeComboBox.setCurrentIndex(0)
 
+    def closePressed(self):
+        Receiver().send_message(u'remote_edit_clear')
+        self.close()
+
     def accept(self):
         valid, message = self._validate()
         if not valid:
@@ -132,9 +132,7 @@
         self.customSlide.credits = unicode(self.CreditEdit.displayText())
         self.customSlide.theme_name = unicode(self.ThemeComboBox.currentText())
         self.custommanager.save_slide(self.customSlide)
-        self.close()
-
-    def rejected(self):
+        Receiver().send_message(u'load_custom_list')
         self.close()
 
     def onUpButtonPressed(self):

=== modified file 'openlp/plugins/custom/lib/mediaitem.py'
--- openlp/plugins/custom/lib/mediaitem.py	2009-09-28 20:45:04 +0000
+++ openlp/plugins/custom/lib/mediaitem.py	2009-10-29 13:55:19 +0000
@@ -26,7 +26,7 @@
 
 from PyQt4 import QtCore, QtGui
 
-from openlp.core.lib import MediaManagerItem, SongXMLParser, BaseListWithDnD
+from openlp.core.lib import MediaManagerItem, SongXMLParser, BaseListWithDnD, Receiver
 
 class CustomListView(BaseListWithDnD):
     def __init__(self, parent=None):
@@ -53,6 +53,15 @@
         self.servicePath = None
         MediaManagerItem.__init__(self, parent, icon, title)
         self.parent = parent
+        self.fromServiceManager = -1
+
+    def addEndHeaderBar(self):
+        QtCore.QObject.connect(Receiver.get_receiver(),
+            QtCore.SIGNAL(u'%s_edit' % self.parent.name), self.onRemoteEdit)
+        QtCore.QObject.connect(Receiver.get_receiver(),
+            QtCore.SIGNAL(u'remote_edit_clear' ), self.onRemoteEditClear)
+        QtCore.QObject.connect(Receiver.get_receiver(),
+            QtCore.SIGNAL(u'load_custom_list'), self.initialise)
 
     def requiredIcons(self):
         MediaManagerItem.requiredIcons(self)
@@ -68,12 +77,24 @@
             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)
         self.parent.edit_custom_form.exec_()
         self.initialise()
 
+    def onRemoteEditClear(self):
+        self.fromServiceManager = -1
+
+    def onRemoteEdit(self, item_id):
+        valid = self.parent.custommanager.get_custom(item_id)
+        if valid is not None:
+            self.fromServiceManager = item_id
+            self.parent.edit_custom_form.loadCustom(item_id)
+            self.parent.edit_custom_form.exec_()
+
     def onEditClick(self):
         item = self.ListView.currentItem()
         if item is not None:
@@ -95,13 +116,19 @@
         raw_footer = []
         slide = None
         theme = None
-        item = self.ListView.currentItem()
-        if item is None:
-            return False
-        item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
+        if self.fromServiceManager == -1:
+            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
         customSlide = self.parent.custommanager.get_custom(item_id)
         title = customSlide.title
         credit = customSlide.credits
+        service_item.editEnabled = True
+        service_item.editId = item_id
         theme = customSlide.theme_name
         if len(theme) is not 0 :
             service_item.theme = theme

=== modified file 'openlp/plugins/songs/forms/editsongdialog.py'
--- openlp/plugins/songs/forms/editsongdialog.py	2009-10-25 18:07:23 +0000
+++ openlp/plugins/songs/forms/editsongdialog.py	2009-10-29 13:55:19 +0000
@@ -383,7 +383,7 @@
 
         self.retranslateUi(EditSongDialog)
         QtCore.QObject.connect(self.ButtonBox,
-            QtCore.SIGNAL(u'rejected()'), EditSongDialog.close)
+            QtCore.SIGNAL(u'rejected()'), EditSongDialog.closePressed)
         QtCore.QObject.connect(self.ButtonBox,
             QtCore.SIGNAL(u'accepted()'), EditSongDialog.accept)
         QtCore.QMetaObject.connectSlotsByName(EditSongDialog)

=== modified file 'openlp/plugins/songs/forms/editsongform.py'
--- openlp/plugins/songs/forms/editsongform.py	2009-10-27 07:20:01 +0000
+++ openlp/plugins/songs/forms/editsongform.py	2009-10-29 13:55:19 +0000
@@ -400,15 +400,18 @@
 
     def onPreview(self, button):
         log.debug(u'onPreview')
-        if button.text() == self.trUtf8(u'Save & Preview') and self.saveSong():
+        if button.text() == unicode(self.trUtf8(u'Save && Preview')) \
+            and self.saveSong():
             Receiver().send_message(u'preview_song')
 
+    def closePressed(self):
+        Receiver().send_message(u'remote_edit_clear')
+        self.close()
+
     def accept(self):
         log.debug(u'accept')
         if self.saveSong():
-            if self.title_change:
-                Receiver().send_message(u'load_song_list')
-            Receiver().send_message(u'preview_song')
+            Receiver().send_message(u'load_song_list')
             self.close()
 
     def saveSong(self):

=== modified file 'openlp/plugins/songs/lib/mediaitem.py'
--- openlp/plugins/songs/lib/mediaitem.py	2009-10-25 08:09:41 +0000
+++ openlp/plugins/songs/lib/mediaitem.py	2009-10-29 13:55:19 +0000
@@ -55,7 +55,8 @@
         self.edit_song_form = EditSongForm(self.parent.songmanager, self)
         self.song_maintenance_form = SongMaintenanceForm(
             self.parent.songmanager, self)
-        self.fromPreview = None
+        self.fromPreview = -1
+        self.fromServiceManager = -1
 
     def requiredIcons(self):
         MediaManagerItem.requiredIcons(self)
@@ -126,6 +127,10 @@
             QtCore.SIGNAL(u'edit_song'), self.onEventEditSong)
         QtCore.QObject.connect(Receiver.get_receiver(),
             QtCore.SIGNAL(u'preview_song'), self.onPreviewClick)
+        QtCore.QObject.connect(Receiver.get_receiver(),
+            QtCore.SIGNAL(u'%s_edit' % self.parent.name), self.onRemoteEdit)
+        QtCore.QObject.connect(Receiver.get_receiver(),
+            QtCore.SIGNAL(u'remote_edit_clear' ), self.onRemoteEditClear)
 
     def configUpdated(self):
         self.searchAsYouType = str_to_bool(
@@ -179,8 +184,11 @@
             song_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(song.id))
             self.ListView.addItem(song_name)
             if song.id == self.fromPreview:
-                self.fromPreview = 0
                 self.ListView.setCurrentItem(song_name)
+                self.onPreviewClick()
+                self.fromPreview = -1
+            if song.id == self.fromServiceManager:
+                self.onAddClick()
 
     def displayResultsAuthor(self, searchresults):
         log.debug(u'display results Author')
@@ -226,11 +234,21 @@
     def onSongMaintenanceClick(self):
         self.song_maintenance_form.exec_()
 
+    def onRemoteEditClear(self):
+        self.fromServiceManager = -1
+
+    def onRemoteEdit(self, songid):
+        valid = self.parent.songmanager.get_song(songid)
+        if valid is not None:
+            self.fromServiceManager = songid
+            self.edit_song_form.loadSong(songid)
+            self.edit_song_form.exec_()
+
     def onEditClick(self, preview=False):
         item = self.ListView.currentItem()
         if item is not None:
             item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
-            self.fromPreview = 0
+            self.fromPreview = -1
             if preview:
                 self.fromPreview = item_id
             self.edit_song_form.loadSong(item_id)
@@ -253,12 +271,18 @@
         author_list = u''
         author_audit = []
         ccl = u''
-        item = self.ListView.currentItem()
-        if item is None:
-            return False
-        item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
+        if self.fromServiceManager == -1:
+            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
         song = self.parent.songmanager.get_song(item_id)
         service_item.theme = song.theme_name
+        service_item.editEnabled = True
+        service_item.editId = item_id
         if song.lyrics.startswith(u'<?xml version='):
             songXML=SongXMLParser(song.lyrics)
             verseList = songXML.get_verses()

=== modified file 'openlp/plugins/songs/songsplugin.py'
--- openlp/plugins/songs/songsplugin.py	2009-10-24 16:40:36 +0000
+++ openlp/plugins/songs/songsplugin.py	2009-10-29 13:55:19 +0000
@@ -180,4 +180,4 @@
         self.opensong_export_form.show()
 
     def about(self):
-        return u'<b>Song Plugin</b> <br>This plugin allows Songs to be managed and displayed.<br><br>This is a core plugin and cannot be made inactive</b>'
+        return u'<b>Song Plugin</b> <br>This plugin allows Songs to be managed and displayed.<br>'


Follow ups