← Back to team overview

openlp-core team mailing list archive

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

 

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

Requested reviews:
  OpenLP Core (openlp-core)


Fix bug in presentations where items can be added with no active controllers
Add "addtoExisting" to service manager drag and drop
-- 
https://code.launchpad.net/~trb143/openlp/working/+merge/24550
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp/core/lib/mediamanageritem.py'
--- openlp/core/lib/mediamanageritem.py	2010-04-30 22:38:15 +0000
+++ openlp/core/lib/mediamanageritem.py	2010-05-01 13:09:19 +0000
@@ -429,7 +429,7 @@
                 service_item = self.buildServiceItem()
                 if service_item:
                     service_item.from_plugin = False
-                    self.parent.service_manager.addServiceItem(service_item, 
+                    self.parent.service_manager.addServiceItem(service_item,
                         replace=self.remoteTriggered)
             else:
                 items = self.ListView.selectedIndexes()
@@ -454,7 +454,7 @@
                         'You must select an existing service item to add to.'))
             elif self.title.lower() == service_item.name.lower():
                 self.generateSlideData(service_item)
-                self.parent.service_manager.addServiceItem(service_item, 
+                self.parent.service_manager.addServiceItem(service_item,
                     replace=True)
             else:
                 #Turn off the remote edit update message indicator

=== modified file 'openlp/core/lib/plugin.py'
--- openlp/core/lib/plugin.py	2010-04-30 22:38:15 +0000
+++ openlp/core/lib/plugin.py	2010-05-01 13:09:19 +0000
@@ -215,13 +215,16 @@
         """
         pass
 
-    def process_add_service_event(self):
+    def process_add_service_event(self, replace=False):
         """
         Generic Drag and drop handler triggered from service_manager.
         """
         log.debug(u'process_add_service_event event called for plugin %s' %
             self.name)
-        self.media_item.onAddClick()
+        if replace:
+            self.media_item.onAddEditClick()
+        else:
+            self.media_item.onAddClick()
 
     def about(self):
         """

=== modified file 'openlp/core/lib/serviceitem.py'
--- openlp/core/lib/serviceitem.py	2010-04-29 20:56:27 +0000
+++ openlp/core/lib/serviceitem.py	2010-05-01 13:09:19 +0000
@@ -48,6 +48,7 @@
    AllowsMaintain = 3
    RequiresMedia = 4
    AllowsLoop = 5
+   AllowsAdditions = 6
 
 class ServiceItem(object):
     """

=== modified file 'openlp/core/ui/servicemanager.py'
--- openlp/core/ui/servicemanager.py	2010-05-01 08:46:06 +0000
+++ openlp/core/ui/servicemanager.py	2010-05-01 13:09:19 +0000
@@ -200,12 +200,18 @@
             self.parent.serviceSettingsSection + u'/service theme',
             QtCore.QVariant(u'')).toString())
         self.servicePath = AppLocation.get_section_data_path(u'servicemanager')
+        #build the drag and drop context menu
+        self.dndMenu = QtGui.QMenu()
+        self.newAction = self.dndMenu.addAction(self.trUtf8('&Add New Item'))
+        self.newAction.setIcon(build_icon(u':/general/general_edit.png'))
+        self.addToAction = self.dndMenu.addAction(self.trUtf8('&Add to Selected Item'))
+        self.addToAction.setIcon(build_icon(u':/general/general_edit.png'))
         #build the context menu
         self.menu = QtGui.QMenu()
         self.editAction = self.menu.addAction(self.trUtf8('&Edit Item'))
         self.editAction.setIcon(build_icon(u':/general/general_edit.png'))
         self.maintainAction = self.menu.addAction(self.trUtf8('&Maintain Item'))
-        self.editAction.setIcon(build_icon(u':/general/general_edit.png'))
+        self.maintainAction.setIcon(build_icon(u':/general/general_edit.png'))
         self.notesAction = self.menu.addAction(self.trUtf8('&Notes'))
         self.notesAction.setIcon(build_icon(u':/services/service_notes.png'))
         self.deleteAction = self.menu.addAction(
@@ -836,6 +842,7 @@
         if link.hasText():
             plugin = event.mimeData().text()
             item = self.ServiceManagerList.itemAt(event.pos())
+            #ServiceManager started the drag and drop
             if plugin == u'ServiceManager':
                 startpos, startCount = self.findServiceItem()
                 if item is None:
@@ -851,11 +858,28 @@
                 self.serviceItems.insert(newpos, serviceItem)
                 self.repaintServiceList(endpos, startCount)
             else:
+                #we are not over anything so drop
+                replace = False
                 if item == None:
                     self.droppos = len(self.serviceItems)
                 else:
-                    self.droppos = self._getParentItemData(item)
-                Receiver.send_message(u'%s_add_service_item' % plugin)
+                    #we are over somthing so lets investigate
+                    pos = self._getParentItemData(item) - 1
+                    serviceItem = self.serviceItems[pos]
+                    if plugin == serviceItem[u'service_item'].name \
+                        and serviceItem[u'service_item'].is_capable(ItemCapabilities.AllowsAdditions):
+                            action = self.dndMenu.exec_(QtGui.QCursor.pos())
+                            #New action required
+                            if action == self.newAction:
+                                self.droppos = self._getParentItemData(item)
+                            #Append to existing action
+                            if action == self.addToAction:
+                                self.droppos = self._getParentItemData(item)
+                                item.setSelected(True)
+                                replace = True
+                    else:
+                        self.droppos = self._getParentItemData(item)
+                Receiver.send_message(u'%s_add_service_item' % plugin, replace)
 
     def updateThemeList(self, theme_list):
         """

=== modified file 'openlp/plugins/bibles/lib/mediaitem.py'
--- openlp/plugins/bibles/lib/mediaitem.py	2010-04-30 22:38:15 +0000
+++ openlp/plugins/bibles/lib/mediaitem.py	2010-05-01 13:09:19 +0000
@@ -449,6 +449,7 @@
         bible_text = u''
         service_item.add_capability(ItemCapabilities.AllowsPreview)
         service_item.add_capability(ItemCapabilities.AllowsLoop)
+        service_item.add_capability(ItemCapabilities.AllowsAdditions)
         #If we want to use a 2nd translation / version
         bible2 = u''
         if self.SearchTabWidget.currentIndex() == 0:

=== modified file 'openlp/plugins/images/lib/mediaitem.py'
--- openlp/plugins/images/lib/mediaitem.py	2010-04-30 22:38:15 +0000
+++ openlp/plugins/images/lib/mediaitem.py	2010-05-01 13:09:19 +0000
@@ -147,6 +147,7 @@
             service_item.add_capability(ItemCapabilities.AllowsMaintain)
             service_item.add_capability(ItemCapabilities.AllowsPreview)
             service_item.add_capability(ItemCapabilities.AllowsLoop)
+            service_item.add_capability(ItemCapabilities.AllowsAdditions)
             for item in items:
                 bitem = self.ListView.item(item.row())
                 filename = unicode((bitem.data(QtCore.Qt.UserRole)).toString())

=== modified file 'openlp/plugins/presentations/lib/mediaitem.py'
--- openlp/plugins/presentations/lib/mediaitem.py	2010-04-30 22:38:15 +0000
+++ openlp/plugins/presentations/lib/mediaitem.py	2010-05-01 13:09:19 +0000
@@ -187,26 +187,29 @@
         service_item.title = unicode(self.DisplayTypeComboBox.currentText())
         service_item.shortname = unicode(self.DisplayTypeComboBox.currentText())
         shortname = service_item.shortname
-        for item in items:
-            bitem = self.ListView.item(item.row())
-            filename = unicode((bitem.data(QtCore.Qt.UserRole)).toString())
-            if shortname == self.Automatic:
-                service_item.shortname = self.findControllerByType(filename)
-                if not service_item.shortname:
-                    return False
-            controller = self.controllers[service_item.shortname]
-            (path, name) = os.path.split(filename)
-            doc = controller.add_doc(filename)
-            if doc.get_slide_preview_file(1) is None:
-                doc.load_presentation()
-            i = 1
-            img = doc.get_slide_preview_file(i)
-            while img:
-                service_item.add_from_command(path, name, img)
-                i = i + 1
+        if shortname:
+            for item in items:
+                bitem = self.ListView.item(item.row())
+                filename = unicode((bitem.data(QtCore.Qt.UserRole)).toString())
+                if shortname == self.Automatic:
+                    service_item.shortname = self.findControllerByType(filename)
+                    if not service_item.shortname:
+                        return False
+                controller = self.controllers[service_item.shortname]
+                (path, name) = os.path.split(filename)
+                doc = controller.add_doc(filename)
+                if doc.get_slide_preview_file(1) is None:
+                    doc.load_presentation()
+                i = 1
                 img = doc.get_slide_preview_file(i)
-            doc.close_presentation()
-        return True
+                while img:
+                    service_item.add_from_command(path, name, img)
+                    i = i + 1
+                    img = doc.get_slide_preview_file(i)
+                doc.close_presentation()
+            return True
+        else:
+            return False
 
     def findControllerByType(self, filename):
         filetype = os.path.splitext(filename)[1]


Follow ups