Actually add tracks chosen from query

This commit is contained in:
Keith Edmunds 2025-03-13 10:41:56 +00:00
parent c9ff1aa668
commit 1749f0a0b8
2 changed files with 24 additions and 7 deletions

View File

@ -5,7 +5,7 @@ from dataclasses import dataclass
from enum import auto, Enum from enum import auto, Enum
import functools import functools
import threading import threading
from typing import NamedTuple, Optional from typing import NamedTuple
# Third party imports # Third party imports
@ -97,10 +97,7 @@ class MusicMusterSignals(QObject):
""" """
Class for all MusicMuster signals. See: Class for all MusicMuster signals. See:
- https://zetcode.com/gui/pyqt5/eventssignals/ - https://zetcode.com/gui/pyqt5/eventssignals/
- https://stackoverflow.com/questions/62654525/ - https://stackoverflow.com/questions/62654525/emit-a-signal-from-another-class-to-main-class
emit-a-signal-from-another-class-to-main-class
and Singleton class at
https://refactoring.guru/design-patterns/singleton/python/example#example-0
""" """
begin_reset_model_signal = pyqtSignal(int) begin_reset_model_signal = pyqtSignal(int)

View File

@ -72,7 +72,7 @@ from classes import (
from config import Config from config import Config
from dialogs import TrackSelectDialog from dialogs import TrackSelectDialog
from file_importer import FileImporter from file_importer import FileImporter
from helpers import file_is_unreadable, get_name from helpers import ask_yes_no, file_is_unreadable, get_name
from log import log from log import log
from models import db, Playdates, PlaylistRows, Playlists, Queries, Settings, Tracks from models import db, Playdates, PlaylistRows, Playlists, Queries, Settings, Tracks
from music_manager import RowAndTrack, track_sequence from music_manager import RowAndTrack, track_sequence
@ -1431,7 +1431,27 @@ class Window(QMainWindow):
# Keep a reference else it will be gc'd # Keep a reference else it will be gc'd
self.query_dialog = QueryDialog(session, query_id) self.query_dialog = QueryDialog(session, query_id)
self.query_dialog.exec() if self.query_dialog.exec():
new_row_number = self.current_row_or_end()
base_model = self.current.base_model
for track_id in self.query_dialog.selected_tracks:
# Check whether track is already in playlist
move_existing = False
existing_prd = base_model.is_track_in_playlist(track_id)
if existing_prd is not None:
if ask_yes_no(
"Duplicate row",
"Track already in playlist. " "Move to new location?",
default_yes=True,
):
move_existing = True
if move_existing and existing_prd:
base_model.move_track_add_note(new_row_number, existing_prd, note="")
else:
base_model.insert_row(new_row_number, track_id)
new_row_number += 1
# # # # # # # # # # Playlist management functions # # # # # # # # # # # # # # # # # # # # Playlist management functions # # # # # # # # # #