Skip to content

Commit

Permalink
hide tracks: optionally remove from playlists
Browse files Browse the repository at this point in the history
  • Loading branch information
ronso0 committed Jan 14, 2025
1 parent 6214901 commit 253cd60
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions src/library/trackcollection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,28 +287,30 @@ bool TrackCollection::hideTracks(const QList<TrackId>& trackIds) {
}
}

// TODO show list with checkboxes for playlists to leave unchanged
// use QListWidget, see WTrackMenu::slotRemoveFromDisk()
bool removeFromplaylists = false;
if (!allPlaylistIds.isEmpty()) {
QStringList playlistNames;
playlistNames.reserve(allPlaylistIds.count());
for (const auto& playlistId: allPlaylistIds) {
playlistNames.append(m_playlistDao.getPlaylistName(playlistId));
}

QString playlistNamesSection =
"\n\n\"" %
const QString playlistNamesSection =
"\n\n\"" % // prepend linebreak
playlistNames.join("\"\n\"") %
"\"\n\n";
"\"\n\n"; // append linebreak

if (QMessageBox::question(
nullptr,
QMessageBox::StandardButton btn = QMessageBox::question(nullptr,
tr("Hiding tracks"),
tr("The selected tracks are in the following playlists:"
"%1"
"Hiding them will remove them from these playlists. Continue?")
"%1"
"Do you want to remove them from these playlists. Continue?")
.arg(playlistNamesSection),
QMessageBox::Ok | QMessageBox::Cancel) != QMessageBox::Ok) {
return false;
}
QMessageBox::Yes | QMessageBox::No,
QMessageBox::No);
removeFromplaylists = btn == QMessageBox::Yes;
}

// Transactional
Expand All @@ -323,7 +325,9 @@ bool TrackCollection::hideTracks(const QList<TrackId>& trackIds) {
return false;
}

m_playlistDao.removeTracksFromPlaylists(trackIds);
if (removeFromplaylists) {
m_playlistDao.removeTracksFromPlaylists(trackIds);
}

// Post-processing
// TODO(XXX): Move signals from TrackDAO to TrackCollection
Expand Down

0 comments on commit 253cd60

Please sign in to comment.