Added display of track genres.
This commit is contained in:
parent
9e20e21e6f
commit
209335b005
4 changed files with 18 additions and 9 deletions
|
@ -284,7 +284,7 @@ class Playlist:
|
|||
|
||||
def save(self):
|
||||
first_view = list(self.views.values())[0]
|
||||
first_view.sortItems(4, Qt.SortOrder.AscendingOrder)
|
||||
first_view.sortItems(5, Qt.SortOrder.AscendingOrder) # sort by custom sorting
|
||||
self.sync(first_view)
|
||||
|
||||
wbzm3u = WobuzzM3U(self.path)
|
||||
|
@ -299,7 +299,7 @@ class Playlist:
|
|||
wbz_data += wbzm3u.assemble_line(WBZM3UData.TrackMetadata.TrackTitle(track.metadata.title))
|
||||
wbz_data += wbzm3u.assemble_line(WBZM3UData.TrackMetadata.TrackArtist(track.metadata.artist))
|
||||
wbz_data += wbzm3u.assemble_line(WBZM3UData.TrackMetadata.TrackAlbum(track.metadata.album))
|
||||
# wbz_data += wbzm3u.assemble_line(WBZM3UData.TrackMetadata.TrackGenre(track.metadata.genre))
|
||||
wbz_data += wbzm3u.assemble_line(WBZM3UData.TrackMetadata.TrackGenre(track.metadata.genre))
|
||||
|
||||
wbz_data += wbzm3u.assemble_line(WBZM3UData.Path(track.path))
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ class TrackMetadata:
|
|||
title: str | None=None
|
||||
artist: str | None=None
|
||||
album: str | None=None
|
||||
genre: str | None=None
|
||||
images: TTImages | None=None # tinytag images
|
||||
|
||||
def add_missing(self):
|
||||
|
@ -26,15 +27,19 @@ class TrackMetadata:
|
|||
if self.album == "None":
|
||||
self.album = ""
|
||||
|
||||
if self.genre == "None":
|
||||
self.genre = ""
|
||||
|
||||
if self.path is None: # can't add missing information without a path
|
||||
return
|
||||
|
||||
if self.title is None or self.artist is None or self.album is None:
|
||||
if self.title is None or self.artist is None or self.album is None or self.genre is None:
|
||||
tags = TinyTag.get(self.path, ignore_errors=True, duration=False)
|
||||
|
||||
self.title = tags.title
|
||||
self.artist = tags.artist
|
||||
self.album = tags.album
|
||||
self.genre = tags.genre
|
||||
|
||||
|
||||
class Track:
|
||||
|
|
|
@ -30,13 +30,14 @@ class PlaylistView(QTreeWidget):
|
|||
|
||||
self.setSelectionMode(QAbstractItemView.SelectionMode.ExtendedSelection)
|
||||
|
||||
self.setColumnCount(4)
|
||||
self.setColumnCount(5)
|
||||
|
||||
headers = [
|
||||
"#",
|
||||
"Title",
|
||||
"Artist",
|
||||
"Album",
|
||||
"Genre",
|
||||
"# Custom Sorting"
|
||||
]
|
||||
|
||||
|
@ -98,7 +99,7 @@ class PlaylistView(QTreeWidget):
|
|||
track.setText(0, str(i)) # 0 = index
|
||||
|
||||
if user_sort:
|
||||
track.setText(4, str(i)) # 4 = user sort index
|
||||
track.setText(5, str(i)) # 5 = user sort index
|
||||
|
||||
if user_sort:
|
||||
# set last sort to user sort
|
||||
|
@ -107,7 +108,7 @@ class PlaylistView(QTreeWidget):
|
|||
|
||||
self.playlist.sorting.append(WBZM3UData.SortOrder(WBZM3UData.SortOrder.custom_sorting, True))
|
||||
|
||||
self.header.setSortIndicator(4, Qt.SortOrder.AscendingOrder)
|
||||
self.header.setSortIndicator(5, Qt.SortOrder.AscendingOrder)
|
||||
|
||||
self.playlist.sync(self, user_sort) # sync playlist to this view
|
||||
|
||||
|
|
|
@ -41,26 +41,29 @@ class TrackItem(QTreeWidgetItem):
|
|||
self.setText(1, track.metadata.title)
|
||||
self.setText(2, track.metadata.artist)
|
||||
self.setText(3, track.metadata.album)
|
||||
self.setText(4, str(self.index_user_sort + 1))
|
||||
self.setText(4, track.metadata.genre)
|
||||
self.setText(5, str(self.index_user_sort + 1))
|
||||
|
||||
def mark(self):
|
||||
self.setIcon(0, self.playing_mark)
|
||||
self.setFont(1, self.bold_font)
|
||||
self.setFont(2, self.bold_font)
|
||||
self.setFont(3, self.normal_font)
|
||||
self.setFont(3, self.bold_font)
|
||||
self.setFont(4, self.bold_font)
|
||||
|
||||
def unmark(self):
|
||||
self.setIcon(0, QIcon(None))
|
||||
self.setFont(1, self.normal_font)
|
||||
self.setFont(2, self.normal_font)
|
||||
self.setFont(3, self.normal_font)
|
||||
self.setFont(4, self.normal_font)
|
||||
|
||||
def __lt__(self, other):
|
||||
# make numeric strings get sorted the right way
|
||||
|
||||
column = self.parent.sortColumn()
|
||||
|
||||
if column == 0 or column == 4:
|
||||
if column == 0 or column == 5:
|
||||
return int(self.text(column)) < int(other.text(column))
|
||||
|
||||
else:
|
||||
|
|
Loading…
Add table
Reference in a new issue