Fix delete key for services

bzr-revno: 1970
This commit is contained in:
Tim Bentley 2012-05-07 18:07:34 +01:00
commit 01ed8e4ed8

View File

@ -64,6 +64,9 @@ class ServiceManagerList(QtGui.QTreeWidget):
elif event.key() == QtCore.Qt.Key_Down: elif event.key() == QtCore.Qt.Key_Down:
self.serviceManager.onMoveSelectionDown() self.serviceManager.onMoveSelectionDown()
event.accept() event.accept()
elif event.key() == QtCore.Qt.Key_Delete:
self.serviceManager.onDeleteFromService()
event.accept()
event.ignore() event.ignore()
else: else:
event.ignore() event.ignore()
@ -218,6 +221,7 @@ class ServiceManager(QtGui.QWidget):
icon=u':/general/general_delete.png', icon=u':/general/general_delete.png',
tooltip=translate('OpenLP.ServiceManager', tooltip=translate('OpenLP.ServiceManager',
'Delete the selected item from the service.'), 'Delete the selected item from the service.'),
shortcuts=[QtCore.Qt.Key_Delete],
triggers=self.onDeleteFromService) triggers=self.onDeleteFromService)
self.orderToolbar.addSeparator() self.orderToolbar.addSeparator()
self.serviceManagerList.expand = self.orderToolbar.addToolbarAction( self.serviceManagerList.expand = self.orderToolbar.addToolbarAction(
@ -1314,15 +1318,15 @@ class ServiceManager(QtGui.QWidget):
def findServiceItem(self): def findServiceItem(self):
""" """
Finds the selected ServiceItem in the list and returns the position of Finds the first selected ServiceItem in the list and returns the
the serviceitem and its selected child item. For example, if the third position of the serviceitem and its selected child item. For example,
child item (in the Slidecontroller known as slide) in the second service if the third child item (in the Slidecontroller known as slide) in the
item is selected this will return:: second service item is selected this will return::
(1, 2) (1, 2)
""" """
items = self.serviceManagerList.selectedItems() items = self.serviceManagerList.selectedItems()
serviceItem = 0 serviceItem = -1
serviceItemChild = -1 serviceItemChild = -1
for item in items: for item in items:
parentitem = item.parent() parentitem = item.parent()
@ -1331,8 +1335,10 @@ class ServiceManager(QtGui.QWidget):
else: else:
serviceItem = parentitem.data(0, QtCore.Qt.UserRole).toInt()[0] serviceItem = parentitem.data(0, QtCore.Qt.UserRole).toInt()[0]
serviceItemChild = item.data(0, QtCore.Qt.UserRole).toInt()[0] serviceItemChild = item.data(0, QtCore.Qt.UserRole).toInt()[0]
# Adjust for zero based arrays. # Adjust for zero based arrays.
serviceItem -= 1 serviceItem -= 1
# Only process the first item on the list for this method.
break
return serviceItem, serviceItemChild return serviceItem, serviceItemChild
def dragEnterEvent(self, event): def dragEnterEvent(self, event):