refresh QTableView after deleting songs from library
This commit is contained in:
parent
3ec08d8446
commit
b8e36fc524
@ -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"""
|
||||
|
||||
@ -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:
|
||||
|
||||
@ -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')
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user