File drops from the file manager insert at the drop position
The table already computed and emitted the drop row for external URL drops, but PlaylistView._on_files_dropped threw it away, so imported files always appended. Thread it through: playlist_view.files_dropped gains a row slot (None = append), MainWindow.import_files and file_importer.import_paths take an optional position and hand it to add_tracks_to_playlist, which already supported positional insert. Files already in the library dedup to the existing track and insert at the drop position without duplicating the library entry.
This commit is contained in:
@@ -314,16 +314,18 @@ class MainWindow(QMainWindow):
|
||||
if paths:
|
||||
self.import_files([Path(p) for p in paths])
|
||||
|
||||
def import_files(self, paths, playlist_pid: str = ""):
|
||||
def import_files(self, paths, playlist_pid: str = "",
|
||||
position: int | None = None):
|
||||
self.statusBar().showMessage(f"Importing {len(paths)} item(s)…")
|
||||
imported = file_importer.import_paths(
|
||||
paths, self._music_import_dir(), self._manager, playlist_pid)
|
||||
paths, self._music_import_dir(), self._manager, playlist_pid,
|
||||
position)
|
||||
self.statusBar().showMessage(f"Imported {len(imported)} track(s)", 5000)
|
||||
if imported:
|
||||
self._library_view.reload()
|
||||
|
||||
def _import_files_to_playlist(self, paths, pid):
|
||||
self.import_files([Path(p) for p in paths], pid)
|
||||
def _import_files_to_playlist(self, paths, pid, position=None):
|
||||
self.import_files([Path(p) for p in paths], pid, position)
|
||||
|
||||
# ---- album art download ----
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ from lintunes.gui.playlist_ops import add_tracks_with_dup_check
|
||||
class PlaylistView(TableSettingsMixin, QWidget):
|
||||
play_requested = pyqtSignal(list, int)
|
||||
info_requested = pyqtSignal(list)
|
||||
files_dropped = pyqtSignal(list, str) # paths, playlist pid
|
||||
files_dropped = pyqtSignal(list, str, object) # paths, pid, row or None
|
||||
show_in_playlist_requested = pyqtSignal(int, str) # track_id, playlist pid
|
||||
|
||||
def __init__(self, manager, parent=None):
|
||||
@@ -124,7 +124,8 @@ class PlaylistView(TableSettingsMixin, QWidget):
|
||||
|
||||
def _on_files_dropped(self, paths, drop_row):
|
||||
if self._editable():
|
||||
self.files_dropped.emit(paths, self._playlist.persistent_id)
|
||||
self.files_dropped.emit(
|
||||
paths, self._playlist.persistent_id, drop_row)
|
||||
|
||||
def _on_remove(self, rows):
|
||||
if self._editable():
|
||||
|
||||
Reference in New Issue
Block a user