Allow the up and down selection to step over collapsed service items

bzr-revno: 1693
Fixes: https://launchpad.net/bugs/805084
This commit is contained in:
Tim Bentley 2011-07-24 18:47:54 +01:00
commit 0b44825d0c
1 changed files with 14 additions and 37 deletions

View File

@ -781,48 +781,25 @@ class ServiceManager(QtGui.QWidget):
def onMoveSelectionUp(self): def onMoveSelectionUp(self):
""" """
Moves the selection up the window. Called by the up arrow. Moves the cursor selection up the window.
Called by the up arrow.
""" """
serviceIterator = QtGui.QTreeWidgetItemIterator(self.serviceManagerList) item = self.serviceManagerList.currentItem()
tempItem = None itemBefore = self.serviceManagerList.itemAbove(item)
setLastItem = False if itemBefore is None:
while serviceIterator.value(): return
if serviceIterator.value().isSelected() and tempItem is None: self.serviceManagerList.setCurrentItem(itemBefore)
setLastItem = True
serviceIterator.value().setSelected(False)
if serviceIterator.value().isSelected():
# We are on the first record
if tempItem:
tempItem.setSelected(True)
serviceIterator.value().setSelected(False)
else:
tempItem = serviceIterator.value()
lastItem = serviceIterator.value()
serviceIterator += 1
# Top Item was selected so set the last one
if setLastItem:
lastItem.setSelected(True)
def onMoveSelectionDown(self): def onMoveSelectionDown(self):
""" """
Moves the selection down the window. Called by the down arrow. Moves the cursor selection down the window.
Called by the down arrow.
""" """
serviceIterator = QtGui.QTreeWidgetItemIterator(self.serviceManagerList) item = self.serviceManagerList.currentItem()
firstItem = None itemAfter = self.serviceManagerList.itemBelow(item)
setSelected = False if itemAfter is None:
while serviceIterator.value(): return
if not firstItem: self.serviceManagerList.setCurrentItem(itemAfter)
firstItem = serviceIterator.value()
if setSelected:
setSelected = False
serviceIterator.value().setSelected(True)
elif serviceIterator.value() and \
serviceIterator.value().isSelected():
serviceIterator.value().setSelected(False)
setSelected = True
serviceIterator += 1
if setSelected:
firstItem.setSelected(True)
def onCollapseAll(self): def onCollapseAll(self):
""" """