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,
|
QMessageBox.Yes,
|
||||||
)
|
)
|
||||||
if reply:
|
if reply:
|
||||||
|
model = self.model
|
||||||
selected_filepaths = self.get_selected_songs_filepaths()
|
selected_filepaths = self.get_selected_songs_filepaths()
|
||||||
selected_indices = self.get_selected_rows()
|
selected_indices = self.get_selected_rows()
|
||||||
for file in selected_filepaths:
|
for file in selected_filepaths:
|
||||||
with DBA.DBAccess() as db:
|
with DBA.DBAccess() as db:
|
||||||
db.execute("DELETE FROM library WHERE filepath = ?", (file,))
|
db.execute("DELETE FROM library WHERE filepath = ?", (file,))
|
||||||
for index in selected_indices:
|
for index in selected_indices:
|
||||||
self.model.removeRow(index)
|
model.removeRow(index)
|
||||||
|
self.fetch_library()
|
||||||
|
|
||||||
def open_directory(self):
|
def open_directory(self):
|
||||||
"""Opens the currently selected song in the system file manager"""
|
"""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):
|
if any(filepath.lower().endswith(ext) for ext in extensions):
|
||||||
filename = filepath.split("/")[-1]
|
filename = filepath.split("/")[-1]
|
||||||
audio = get_id3_tags(filepath)
|
audio = get_id3_tags(filepath)
|
||||||
print("add_files_to_library audio:")
|
# print("add_files_to_library audio:")
|
||||||
print(audio)
|
# print(audio)
|
||||||
|
|
||||||
# Skip if no title is found (but should never happen
|
# Skip if no title is found (but should never happen
|
||||||
if "TIT2" not in audio:
|
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
|
if len(timestamp.text) == 4: # If only year is provided
|
||||||
datetime_obj = datetime.datetime.strptime(timestamp.text, '%Y')
|
datetime_obj = datetime.datetime.strptime(timestamp.text, '%Y')
|
||||||
else:
|
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')
|
return datetime_obj.strftime('%Y-%m-%d')
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user