Disable drag and drop (todo: fix in qt6)

This commit is contained in:
Keith Edmunds 2023-04-13 14:45:29 +01:00
parent a8ffa6f231
commit 32cc0468e8

View File

@ -189,13 +189,13 @@ class PlaylistTab(QTableWidget):
self.resizeRowsToContents) self.resizeRowsToContents)
# Drag and drop setup # Drag and drop setup
self.setAcceptDrops(True) # TODO: fix drag and drop for qt6
self.setAcceptDrops(False)
self.viewport().setAcceptDrops(True) self.viewport().setAcceptDrops(True)
self.setDragDropOverwriteMode(False) self.setDragDropOverwriteMode(False)
self.setDropIndicatorShown(True) self.setDropIndicatorShown(True)
self.setDragDropMode(QAbstractItemView.DragDropMode.InternalMove) self.setDragDropMode(QAbstractItemView.DragDropMode.InternalMove)
self.setDragEnabled(False) self.setDragEnabled(False)
# This property defines how the widget shows a context menu # This property defines how the widget shows a context menu
self.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) self.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu)
# This signal is emitted when the widget's contextMenuPolicy is # This signal is emitted when the widget's contextMenuPolicy is
@ -291,7 +291,8 @@ class PlaylistTab(QTableWidget):
""" """
if self.selectedItems(): if self.selectedItems():
self.setDragEnabled(True) # TODO: fix drag and drop
self.setDragEnabled(False)
else: else:
self.setDragEnabled(False) self.setDragEnabled(False)
super().mouseReleaseEvent(event) super().mouseReleaseEvent(event)
@ -1156,11 +1157,12 @@ class PlaylistTab(QTableWidget):
https://stackoverflow.com/questions/26227885/drag-and-drop-rows-within-qtablewidget https://stackoverflow.com/questions/26227885/drag-and-drop-rows-within-qtablewidget
""" """
index = self.indexAt(event.pos()) position = event.position().toPoint()
index = self.indexAt(position)
if not index.isValid(): if not index.isValid():
return self.rowCount() return self.rowCount()
return (index.row() + 1 if self._is_below(event.pos(), index) return (index.row() + 1 if self._is_below(position, index)
else index.row()) else index.row())
def _find_next_track_row(self, session: scoped_session, def _find_next_track_row(self, session: scoped_session,