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

Requested reviews:
  OpenLP Core (openlp-core)
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/46936

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/46936
Your team OpenLP Core is requested to review the proposed merge of 
lp:~googol-hush/openlp/fixes into lp:openlp.
=== modified file 'openlp/core/ui/servicemanager.py'
--- openlp/core/ui/servicemanager.py	2011-01-19 04:30:11 +0000
+++ openlp/core/ui/servicemanager.py	2011-01-20 17:01:23 +0000
@@ -801,10 +801,10 @@
         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.
+            The child of the ``serviceItem``, which will be selected. (int)
         """
         # Correct order of items in array
         count = 1
@@ -837,16 +837,21 @@
             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)
                 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
+                if serviceItem == itemcount:
+                    # Preserve expanding status as setCurrentItem sets it to
+                    # True.
                     temp = item[u'expanded']
-                    self.serviceManagerList.setCurrentItem(treewidgetitem1)
+                    if item[u'expanded'] and serviceItemCount == count:
+                        self.serviceManagerList.setCurrentItem(treewidgetitem1)
+                    elif serviceItemCount == -1:
+                        self.serviceManagerList.setCurrentItem(treewidgetitem)
                     item[u'expanded'] = temp
             treewidgetitem.setExpanded(item[u'expanded'])
 
@@ -958,7 +963,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
@@ -1046,11 +1051,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-19 04:30:11 +0000
+++ openlp/core/ui/slidecontroller.py	2011-01-20 17:01:23 +0000
@@ -525,6 +525,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():

_______________________________________________
Mailing list: https://launchpad.net/~openlp-core
Post to     : openlp-core@lists.launchpad.net
Unsubscribe : https://launchpad.net/~openlp-core
More help   : https://help.launchpad.net/ListHelp

Reply via email to