diff --git a/wobuzz/library/library.py b/wobuzz/library/library.py index cddfd17..18bd2f1 100644 --- a/wobuzz/library/library.py +++ b/wobuzz/library/library.py @@ -37,7 +37,13 @@ class Library: view = PlaylistView() view.setDragDropMode(QAbstractItemView.DragDropMode.InternalMove) - for track in playlist.tracks: + num_tracks = len(playlist.tracks) + + i = 0 + + while i < num_tracks: + track = playlist.tracks[i] + track_item = QTreeWidgetItem(view) track_item.setFlags( @@ -50,6 +56,9 @@ class Library: track_item.setText(1, track.tags.title) track_item.setText(2, track.tags.artist) track_item.setText(3, track.tags.album) + track_item.setText(4, str(i + 1)) + + i += 1 return view diff --git a/wobuzz/player/playlist.py b/wobuzz/player/playlist.py index ac52382..7bf4556 100644 --- a/wobuzz/player/playlist.py +++ b/wobuzz/player/playlist.py @@ -1,6 +1,7 @@ #!/usr/bin/python3 import os +from PyQt6.QtCore import Qt from .track import Track @@ -8,6 +9,7 @@ class Playlist: def __init__(self, app, title: str): self.app = app self.title = title # playlist title + self.sorting: list[Qt.SortOrder] | None = None # Custom sort order if None self.tracks: list[Track] = [] self.current_track_index = 0 self.current_track: Track | None = None diff --git a/wobuzz/ui/playlist.py b/wobuzz/ui/playlist.py index 066a3b7..4ca1999 100644 --- a/wobuzz/ui/playlist.py +++ b/wobuzz/ui/playlist.py @@ -7,13 +7,14 @@ class PlaylistView(QTreeWidget): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) - self.setColumnCount(4) + self.setColumnCount(3) headers = [ "#", "Title", "Artist", - "Album" + "Album", + "# Custom Sorting" ] self.setHeaderLabels(headers) \ No newline at end of file