refresh QTableView after deleting songs from library

This commit is contained in:
billypom on debian 2024-06-27 17:06:34 -04:00
parent 3ec08d8446
commit b8e36fc524
3 changed files with 6 additions and 4 deletions

View File

@ -109,13 +109,15 @@ class MusicTable(QTableView):
QMessageBox.Yes,
)
if reply:
model = self.model
selected_filepaths = self.get_selected_songs_filepaths()
selected_indices = self.get_selected_rows()
for file in selected_filepaths:
with DBA.DBAccess() as db:
db.execute("DELETE FROM library WHERE filepath = ?", (file,))
for index in selected_indices:
self.model.removeRow(index)
model.removeRow(index)
self.fetch_library()
def open_directory(self):
"""Opens the currently selected song in the system file manager"""

View File

@ -19,8 +19,8 @@ def add_files_to_library(files):
if any(filepath.lower().endswith(ext) for ext in extensions):
filename = filepath.split("/")[-1]
audio = get_id3_tags(filepath)
print("add_files_to_library audio:")
print(audio)
# print("add_files_to_library audio:")
# print(audio)
# Skip if no title is found (but should never happen
if "TIT2" not in audio:

View File

@ -7,5 +7,5 @@ def id3_timestamp_to_datetime(timestamp: ID3TimeStamp):
if len(timestamp.text) == 4: # If only year is provided
datetime_obj = datetime.datetime.strptime(timestamp.text, '%Y')
else:
datetime_obj = datetime.datetime.strptime(timestamp.text, '%Y-%m-%dT%H:%M:%SZ')
datetime_obj = datetime.datetime.strptime(timestamp.text, '%Y-%m-%d')
return datetime_obj.strftime('%Y-%m-%d')