[PyQt] how to implement flags based on drop type
danny
shevitz at lanl.gov
Wed Oct 27 22:38:47 BST 2010
Howdy,
I am at a complete loss as to how I would implement the following functionality.
If anyone has any ideas, I would appreciate hearing them.
The idea is that in my app I have an editable custom model with two different
kinds of nodes: branch nodes and leaf nodes. Branch nodes are like folders,
leaf nodes are like files.
I have reimplimented a drag type of Qt.CopyAction to act like an insert
operation and a drag type of Qt.Move action to append as a child (this
is standard).
The problem is that you can always insert (Qt.CopyAction), but you can only
append to Branch nodes. In PyQt speak, the flags function needs to take the
drag type into account.
I would like to implement something like this:
def flags(modelIndex, dragtype):
defaultFlags = ...
if dragType==Qt.CopyAction:
return defaultFlags | Qt.ItemIsDropEnabled
item = self.getItem(index)
if dragType==Qt.MoveAction and item.isBranch:
return defaultFlags | Qt.ItemIsDropEnabled
return defaultFlags
The problem is that the signature of flags is:
flags(modelIndex).
I am completely stumped.
Does anyone have any ideas?
thanks,
Danny
More information about the PyQt
mailing list