Split artist and song into separate columns in history table
This commit is contained in:
1 parent
eb61051c7c
commit
43e93c5abc
1 file changed
+15
-7
+15
-7
@@ -642,8 +642,8 @@ class MainWindow(QMainWindow):
|
|||||||
layout = QVBoxLayout()
|
layout = QVBoxLayout()
|
||||||
|
|
||||||
table = QTableWidget()
|
table = QTableWidget()
|
||||||
table.setColumnCount(3)
|
table.setColumnCount(4)
|
||||||
table.setHorizontalHeaderLabels(["Date", "Type", "Song"])
|
table.setHorizontalHeaderLabels(["Date", "Type", "Artist", "Song"])
|
||||||
table.horizontalHeader().setStretchLastSection(True)
|
table.horizontalHeader().setStretchLastSection(True)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -666,7 +666,13 @@ class MainWindow(QMainWindow):
|
|||||||
try:
|
try:
|
||||||
added_songs = json.loads(added_songs_json)
|
added_songs = json.loads(added_songs_json)
|
||||||
for song in added_songs:
|
for song in added_songs:
|
||||||
entries.append((date_str, "Added", song))
|
# Format is "Title by Artist"
|
||||||
|
if " by " in song:
|
||||||
|
title, artist = song.split(" by ", 1)
|
||||||
|
else:
|
||||||
|
title = song
|
||||||
|
artist = "Unknown"
|
||||||
|
entries.append((date_str, "Added", artist, title))
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@@ -674,16 +680,18 @@ class MainWindow(QMainWindow):
|
|||||||
try:
|
try:
|
||||||
missing_songs = json.loads(missing_songs_json)
|
missing_songs = json.loads(missing_songs_json)
|
||||||
for song in missing_songs:
|
for song in missing_songs:
|
||||||
song_text = f"{song['artist']} - {song['title']}"
|
artist = song.get('artist', 'Unknown')
|
||||||
entries.append((date_str, "Missing", song_text))
|
title = song.get('title', 'Unknown')
|
||||||
|
entries.append((date_str, "Missing", artist, title))
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
table.setRowCount(len(entries))
|
table.setRowCount(len(entries))
|
||||||
for row_idx, (date_str, type_str, song) in enumerate(entries):
|
for row_idx, (date_str, type_str, artist, song) in enumerate(entries):
|
||||||
table.setItem(row_idx, 0, QTableWidgetItem(date_str))
|
table.setItem(row_idx, 0, QTableWidgetItem(date_str))
|
||||||
table.setItem(row_idx, 1, QTableWidgetItem(type_str))
|
table.setItem(row_idx, 1, QTableWidgetItem(type_str))
|
||||||
table.setItem(row_idx, 2, QTableWidgetItem(song))
|
table.setItem(row_idx, 2, QTableWidgetItem(artist))
|
||||||
|
table.setItem(row_idx, 3, QTableWidgetItem(song))
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
table.setRowCount(1)
|
table.setRowCount(1)
|
||||||
|
|||||||
Reference in new issue
Block a user