only allow drag if an item is selected

This commit is contained in:
Andreas Preikschat 2011-05-12 17:50:20 +02:00
parent 4778bfd781
commit 4e870ed705
2 changed files with 6 additions and 0 deletions

View File

@ -49,6 +49,9 @@ class ListWidgetWithDnD(QtGui.QListWidget):
if event.buttons() != QtCore.Qt.LeftButton:
event.ignore()
return
if not self.selectedItems():
event.ignore()
return
drag = QtGui.QDrag(self)
mimeData = QtCore.QMimeData()
drag.setMimeData(mimeData)

View File

@ -73,6 +73,9 @@ class ServiceManagerList(QtGui.QTreeWidget):
if event.buttons() != QtCore.Qt.LeftButton:
event.ignore()
return
if not self.selectedItems():
event.ignore()
return
drag = QtGui.QDrag(self)
mimeData = QtCore.QMimeData()
drag.setMimeData(mimeData)