Added "Custom Sorting" to playlist view.
This commit is contained in:
parent
5d6f67603a
commit
44854af42f
3 changed files with 15 additions and 3 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
Loading…
Reference in a new issue