Added item flags so it is impossible to put other tracks into tracks.

This commit is contained in:
The Wobbler 2024-12-29 14:49:19 +01:00
parent da27963884
commit 5d6f67603a

View file

@ -1,6 +1,7 @@
#!/usr/bin/python3 #!/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 player.playlist import Playlist
from ui.library_dock import LibraryDock from ui.library_dock import LibraryDock
from ui.playlist import PlaylistView from ui.playlist import PlaylistView
@ -34,9 +35,17 @@ class Library:
def create_playlist_view(self, playlist: Playlist): def create_playlist_view(self, playlist: Playlist):
view = PlaylistView() view = PlaylistView()
view.setDragDropMode(QAbstractItemView.DragDropMode.InternalMove)
for track in playlist.tracks: for track in playlist.tracks:
track_item = QTreeWidgetItem(view) track_item = QTreeWidgetItem(view)
track_item.setFlags(
Qt.ItemFlag.ItemIsEnabled |
Qt.ItemFlag.ItemIsSelectable |
Qt.ItemFlag.ItemIsDragEnabled
)
track_item.track = track track_item.track = track
track_item.setText(1, track.tags.title) track_item.setText(1, track.tags.title)
track_item.setText(2, track.tags.artist) track_item.setText(2, track.tags.artist)