From cc04a82c080ec2a9843e77ed75ad1c68f7062f42 Mon Sep 17 00:00:00 2001 From: Jonathan Stafford Date: Sun, 22 Jan 2012 17:07:59 +0800 Subject: [PATCH] Changed up arrow to jump to last slide of previous service item (when applicable) --- openlp/core/ui/servicemanager.py | 17 ++++++++++++++--- openlp/core/ui/slidecontroller.py | 12 +++++++++--- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index e23e68ef5..5028297dd 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -826,7 +826,7 @@ class ServiceManager(QtGui.QWidget): lookFor = 1 serviceIterator += 1 - def previousItem(self): + def previousItem(self, message): """ Called by the SlideController to select the previous service item. """ @@ -834,20 +834,31 @@ class ServiceManager(QtGui.QWidget): return selected = self.serviceManagerList.selectedItems()[0] prevItem = None + prevItemLastSlide = None serviceIterator = QtGui.QTreeWidgetItemIterator(self.serviceManagerList) while serviceIterator.value(): if serviceIterator.value() == selected: - if prevItem: + if message == 'last slide' and prevItemLastSlide: + pos = prevItem.data(0, QtCore.Qt.UserRole).toInt()[0] + check_expanded = self.serviceItems[pos - 1][u'expanded'] + self.serviceManagerList.setCurrentItem(prevItemLastSlide) + if not check_expanded: + self.serviceManagerList.collapseItem(prevItem) + self.makeLive() + self.serviceManagerList.setCurrentItem(prevItem) + elif prevItem: self.serviceManagerList.setCurrentItem(prevItem) self.makeLive() return if serviceIterator.value().parent() is None: prevItem = serviceIterator.value() + if serviceIterator.value().parent() is prevItem: + prevItemLastSlide = serviceIterator.value() serviceIterator += 1 def onSetItem(self, message): """ - Called by a signal to select a specific item. + Called by a signal to select a specific item.signal """ self.setItem(int(message)) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 30d09050a..41dddb1c9 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -616,8 +616,12 @@ class SlideController(Controller): if len(self.keypress_queue): while len(self.keypress_queue) and not self.keypress_loop: self.keypress_loop = True - if self.keypress_queue.popleft() == u'previous': - Receiver.send_message('servicemanager_previous_item') + keypressCommand = self.keypress_queue.popleft() + if keypressCommand == u'previous': + Receiver.send_message('servicemanager_previous_item', None) + elif keypressCommand == u'previous last slide': + # Go to the last slide of the previous item + Receiver.send_message('servicemanager_previous_item', 'last slide') else: Receiver.send_message('servicemanager_next_item') self.keypress_loop = False @@ -1221,7 +1225,9 @@ class SlideController(Controller): if self.slide_advance == SlideAdvance.Wrap: row = self.previewListWidget.rowCount() - 1 elif self.slide_advance == SlideAdvance.Next: - self.servicePrevious() + # self.servicePrevious() + self.keypress_queue.append(u'previous last slide') + self._process_queue() return else: row = 0