From 5d6f67603a4fa11a1cb4806ada6e4d49532d80fc Mon Sep 17 00:00:00 2001 From: wobbl Date: Sun, 29 Dec 2024 14:49:19 +0100 Subject: [PATCH] Added item flags so it is impossible to put other tracks into tracks. --- wobuzz/library/library.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/wobuzz/library/library.py b/wobuzz/library/library.py index 1ec3d6f..cddfd17 100644 --- a/wobuzz/library/library.py +++ b/wobuzz/library/library.py @@ -1,6 +1,7 @@ #!/usr/bin/python3 -from PyQt6.QtWidgets import QTabWidget, QTreeWidgetItem +from PyQt6.QtCore import Qt +from PyQt6.QtWidgets import QTabWidget, QTreeWidgetItem, QAbstractItemView from player.playlist import Playlist from ui.library_dock import LibraryDock from ui.playlist import PlaylistView @@ -34,9 +35,17 @@ class Library: def create_playlist_view(self, playlist: Playlist): view = PlaylistView() + view.setDragDropMode(QAbstractItemView.DragDropMode.InternalMove) for track in playlist.tracks: track_item = QTreeWidgetItem(view) + + track_item.setFlags( + Qt.ItemFlag.ItemIsEnabled | + Qt.ItemFlag.ItemIsSelectable | + Qt.ItemFlag.ItemIsDragEnabled + ) + track_item.track = track track_item.setText(1, track.tags.title) track_item.setText(2, track.tags.artist)