manuskript/manuskript/ui/views/dndView.py

20 lines
660 B
Python
Raw Normal View History

2015-06-09 22:32:43 +12:00
#!/usr/bin/env python
2016-02-07 00:34:22 +13:00
# --!-- coding: utf8 --!--
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QAbstractItemView
2015-06-09 22:32:43 +12:00
class dndView(QAbstractItemView):
def __init__(self, parent=None):
2016-02-07 00:34:22 +13:00
# QAbstractItemView.__init__(self, parent)
2015-06-09 22:32:43 +12:00
self.setDragDropMode(self.DragDrop)
self.setDefaultDropAction(Qt.MoveAction)
self.setSelectionMode(self.ExtendedSelection)
2016-02-07 00:34:22 +13:00
2015-06-09 22:32:43 +12:00
def dragMoveEvent(self, event):
2016-02-07 00:34:22 +13:00
# return QAbstractItemView.dragMoveEvent(self, event)
2015-06-09 22:32:43 +12:00
if event.keyboardModifiers() & Qt.ControlModifier:
event.setDropAction(Qt.CopyAction)
else:
2016-02-07 00:34:22 +13:00
event.setDropAction(Qt.MoveAction)