From ff2ac445f06214be828595767be466eeb6c09e9b Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 20 Jan 2011 17:12:07 +0100 Subject: [PATCH 1/3] fix for Bug #598393 --- openlp/core/ui/servicemanager.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 1acf8b8a0..f9adca9d7 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -801,10 +801,10 @@ class ServiceManager(QtGui.QWidget): 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,6 +837,7 @@ class ServiceManager(QtGui.QWidget): 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' ') @@ -844,9 +845,13 @@ class ServiceManager(QtGui.QWidget): treewidgetitem1.setData(0, QtCore.Qt.UserRole, QtCore.QVariant(count)) if serviceItem == itemcount and serviceItemCount == count: - #preserve expanding status as setCurrentItem sets it to True + # Preserve expanding status as setCurrentItem sets it to + # True. temp = item[u'expanded'] - self.serviceManagerList.setCurrentItem(treewidgetitem1) + if item[u'expanded']: + self.serviceManagerList.setCurrentItem(treewidgetitem1) + else: + self.serviceManagerList.setCurrentItem(treewidgetitem) item[u'expanded'] = temp treewidgetitem.setExpanded(item[u'expanded']) @@ -958,7 +963,7 @@ class ServiceManager(QtGui.QWidget): 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,7 +1051,12 @@ class ServiceManager(QtGui.QWidget): 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 From 7e57fa2f954df0783b6bfed5042978be75be69b6 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 20 Jan 2011 17:43:29 +0100 Subject: [PATCH 2/3] Don't select the child item if not selected --- openlp/core/ui/servicemanager.py | 8 ++++---- openlp/core/ui/slidecontroller.py | 3 +++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index f9adca9d7..3bdda5516 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -844,13 +844,13 @@ class ServiceManager(QtGui.QWidget): treewidgetitem1.setText(0, text[:40]) treewidgetitem1.setData(0, QtCore.Qt.UserRole, QtCore.QVariant(count)) - if serviceItem == itemcount and serviceItemCount == count: + if serviceItem == itemcount: # Preserve expanding status as setCurrentItem sets it to # True. temp = item[u'expanded'] - if item[u'expanded']: + if item[u'expanded'] and serviceItemCount == count: self.serviceManagerList.setCurrentItem(treewidgetitem1) - else: + elif serviceItemCount == -1: self.serviceManagerList.setCurrentItem(treewidgetitem) item[u'expanded'] = temp treewidgetitem.setExpanded(item[u'expanded']) @@ -1060,7 +1060,7 @@ class ServiceManager(QtGui.QWidget): """ items = self.serviceManagerList.selectedItems() pos = 0 - count = 0 + count = -1 for item in items: parentitem = item.parent() if parentitem is None: diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 28b419616..3e3438100 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -525,6 +525,9 @@ class SlideController(QtGui.QWidget): 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(): From 4263182290d90c00c905ba8aa5a22cea093e247a Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 22 Jan 2011 08:31:32 +0100 Subject: [PATCH 3/3] name change --- openlp/core/ui/servicemanager.py | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 3bdda5516..738849599 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -794,7 +794,7 @@ class ServiceManager(QtGui.QWidget): 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, @@ -803,7 +803,7 @@ class ServiceManager(QtGui.QWidget): ``serviceItem`` The item which changed. (int) - ``serviceItemCount`` + ``serviceItemChild`` The child of the ``serviceItem``, which will be selected. (int) """ # Correct order of items in array @@ -839,20 +839,15 @@ class ServiceManager(QtGui.QWidget): 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)) + child.setText(0, text[:40]) + child.setData(0, QtCore.Qt.UserRole, QtCore.QVariant(count)) if serviceItem == itemcount: - # Preserve expanding status as setCurrentItem sets it to - # True. - temp = item[u'expanded'] - if item[u'expanded'] and serviceItemCount == count: - self.serviceManagerList.setCurrentItem(treewidgetitem1) - elif serviceItemCount == -1: + if item[u'expanded'] and serviceItemChild == count: + self.serviceManagerList.setCurrentItem(child) + elif serviceItemChild == -1: self.serviceManagerList.setCurrentItem(treewidgetitem) - item[u'expanded'] = temp treewidgetitem.setExpanded(item[u'expanded']) def validateItem(self, serviceItem):