Allow drag and drop to open documents
This commit is contained in:
@@ -1111,82 +1111,6 @@ class GuiProjectTree(QTreeView):
|
||||
# self._scrollTimer.stop()
|
||||
return
|
||||
|
||||
##
|
||||
# Events
|
||||
##
|
||||
|
||||
# def startDrag(self, dropAction: Qt.DropAction) -> None:
|
||||
# """Capture the drag and drop handling to pop alerts."""
|
||||
# super().startDrag(dropAction)
|
||||
# if self._popAlert:
|
||||
# SHARED.error(self._popAlert)
|
||||
# self._popAlert = None
|
||||
# return
|
||||
|
||||
# def dragEnterEvent(self, event: QDragEnterEvent) -> None:
|
||||
# """Check that we're only dragging items that are siblings, and
|
||||
# not a root level item.
|
||||
# """
|
||||
# items = self.selectedItems()
|
||||
# if items and (parent := items[0].parent()) and all(x.parent() is parent for x in items):
|
||||
# super().dragEnterEvent(event)
|
||||
# else:
|
||||
# logger.warning("Drag action is not allowed and has been cancelled")
|
||||
# self._popAlert = self.tr(
|
||||
# "Drag and drop is only allowed for single items, non-root "
|
||||
# "items, or multiple items with the same parent."
|
||||
# )
|
||||
# event.mimeData().clear()
|
||||
# event.ignore()
|
||||
# return
|
||||
|
||||
# def dragMoveEvent(self, event: QDragMoveEvent) -> None:
|
||||
# """Capture the drag move event to enable edge auto scroll."""
|
||||
# y = event.pos().y()
|
||||
# if y < self._scrollMargin:
|
||||
# if not self._scrollTimer.isActive():
|
||||
# self._scrollDirection = -1
|
||||
# self._scrollTimer.start()
|
||||
# elif y > self.height() - self._scrollMargin:
|
||||
# if not self._scrollTimer.isActive():
|
||||
# self._scrollDirection = 1
|
||||
# self._scrollTimer.start()
|
||||
# super().dragMoveEvent(event)
|
||||
# return
|
||||
|
||||
# def dropEvent(self, event: QDropEvent) -> None:
|
||||
# """Overload the drop item event to ensure the drag and drop
|
||||
# action is allowed, and update relevant data.
|
||||
# """
|
||||
# tItem = self.itemAt(event.pos())
|
||||
# onItem = self.dropIndicatorPosition() == QAbstractItemView.DropIndicatorPosition.OnItem
|
||||
# onView = self.dropIndicatorPosition() == QAbstractItemView.DropIndicatorPosition.OnViewport
|
||||
# # Make sure nothing can be dropped on invisible root (see #1569)
|
||||
# # Make sure nothing can be dropped on the viewport (see #2108)
|
||||
# if tItem is None or (tItem.parent() is None and not onItem) or onView:
|
||||
# logger.error("Invalid drop location")
|
||||
# event.ignore()
|
||||
# return
|
||||
|
||||
# mItems: dict[str, tuple[QTreeWidgetItem, bool]] = {}
|
||||
# sItems = self.selectedItems()
|
||||
# if sItems and (parent := sItems[0].parent()) and all(x.parent() is parent for x in sItems):
|
||||
# for sItem in sItems:
|
||||
# mHandle = str(sItem.data(self.C_DATA, self.D_HANDLE))
|
||||
# mItems[mHandle] = (sItem, sItem.isExpanded())
|
||||
# self.propagateCount(mHandle, 0)
|
||||
|
||||
# super().dropEvent(event)
|
||||
|
||||
# for mHandle, (sItem, isExpanded) in mItems.items():
|
||||
# self._postItemMove(mHandle)
|
||||
# sItem.setExpanded(isExpanded)
|
||||
# self._alertTreeChange(mHandle, flush=False)
|
||||
|
||||
# self.saveTreeOrder()
|
||||
|
||||
# return
|
||||
|
||||
##
|
||||
# Internal Functions
|
||||
##
|
||||
|
||||
Reference in New Issue
Block a user