← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~googol-hush/openlp/fixes into lp:openlp

 

Andreas Preikschat has proposed merging lp:~googol-hush/openlp/fixes into lp:openlp.

Requested reviews:
  Tim Bentley (trb143)
  Jon Tibble (meths)
Related bugs:
  #598393 After adding a new image to a selected (image) item in the service manager it is not selected anymore
  https://bugs.launchpad.net/bugs/598393

For more details, see:
https://code.launchpad.net/~googol-hush/openlp/fixes/+merge/47146

Hello

I fixed bug #598393.

The selected service item will stay selected, if you perform an action on it (only those actions, which call "repaintServiceList"). In the case that the item will stay selected, it does not matter which "part" of the item is selected (if you selected the second slide (child) of the item and move the item up, the second slide (child) will stay selected). It is required to return -1 for child number if no child is selected (findServiceItem) to distinguish if the first child (-> 0) or no child (-> -1) is selected). This again, required a small change to "addServiceManagerItem".

Cheers
-- 
https://code.launchpad.net/~googol-hush/openlp/fixes/+merge/47146
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp/core/ui/servicemanager.py'
--- openlp/core/ui/servicemanager.py	2011-01-21 18:32:42 +0000
+++ openlp/core/ui/servicemanager.py	2011-01-22 07:38:53 +0000
@@ -808,17 +808,17 @@
             self.repaintServiceList(0, 0)
         self.setModified(True)
 
-    def repaintServiceList(self, serviceItem, serviceItemCount):
+    def repaintServiceList(self, serviceItem, serviceItemChild):
         """
         Clear the existing service list and prepaint all the items. This is
         used when moving items as the move takes place in a supporting list,
         and when regenerating all the items due to theme changes.
 
         ``serviceItem``
-            The item which changed.
+            The item which changed. (int)
 
-        ``serviceItemCount``
-            The number of items in the service.
+        ``serviceItemChild``
+            The child of the ``serviceItem``, which will be selected. (int)
         """
         # Correct order of items in array
         count = 1
@@ -851,17 +851,17 @@
             treewidgetitem.setToolTip(0, serviceitem.notes)
             treewidgetitem.setData(0, QtCore.Qt.UserRole,
                 QtCore.QVariant(item[u'order']))
+            # Add the children to their parent treewidgetitem.
             for count, frame in enumerate(serviceitem.get_frames()):
-                treewidgetitem1 = QtGui.QTreeWidgetItem(treewidgetitem)
+                child = QtGui.QTreeWidgetItem(treewidgetitem)
                 text = frame[u'title'].replace(u'\n', u' ')
-                treewidgetitem1.setText(0, text[:40])
-                treewidgetitem1.setData(0, QtCore.Qt.UserRole,
-                    QtCore.QVariant(count))
-                if serviceItem == itemcount and serviceItemCount == count:
-                    #preserve expanding status as setCurrentItem sets it to True
-                    temp = item[u'expanded']
-                    self.serviceManagerList.setCurrentItem(treewidgetitem1)
-                    item[u'expanded'] = temp
+                child.setText(0, text[:40])
+                child.setData(0, QtCore.Qt.UserRole, QtCore.QVariant(count))
+                if serviceItem == itemcount:
+                    if item[u'expanded'] and serviceItemChild == count:
+                        self.serviceManagerList.setCurrentItem(child)
+                    elif serviceItemChild == -1:
+                        self.serviceManagerList.setCurrentItem(treewidgetitem)
             treewidgetitem.setExpanded(item[u'expanded'])
 
     def validateItem(self, serviceItem):
@@ -972,7 +972,7 @@
         if replace:
             item.merge(self.serviceItems[sitem][u'service_item'])
             self.serviceItems[sitem][u'service_item'] = item
-            self.repaintServiceList(sitem + 1, 0)
+            self.repaintServiceList(sitem, 0)
             self.mainwindow.liveController.replaceServiceManagerItem(item)
         else:
             # nothing selected for dnd
@@ -1060,11 +1060,16 @@
 
     def findServiceItem(self):
         """
-        Finds a ServiceItem in the list
+        Finds a ServiceItem in the list and returns the position of the
+        serviceitem and its selected child item. For example, if the third child
+        item (in the Slidecontroller known as slide) in the second service item
+        is selected this will return::
+
+            (1, 2)
         """
         items = self.serviceManagerList.selectedItems()
         pos = 0
-        count = 0
+        count = -1
         for item in items:
             parentitem = item.parent()
             if parentitem is None:

=== modified file 'openlp/core/ui/slidecontroller.py'
--- openlp/core/ui/slidecontroller.py	2011-01-21 19:09:56 +0000
+++ openlp/core/ui/slidecontroller.py	2011-01-22 07:38:53 +0000
@@ -576,6 +576,9 @@
         Called by ServiceManager
         """
         log.debug(u'addServiceManagerItem live = %s' % self.isLive)
+        # If no valid slide number is specified we take the first one.
+        if slideno == -1:
+            slideno = 0
         # If service item is the same as the current on only change slide
         if item.__eq__(self.serviceItem):
             if slideno + 1 < self.PreviewListWidget.rowCount():


Follow ups