1
0
mirror of https://github.com/clementine-player/Clementine synced 2024-12-17 03:45:56 +01:00

Remove unavailable items from playlist

This commit is contained in:
ppkt 2014-08-24 10:44:27 +02:00
parent 13cda62c5c
commit 43a6740b48
6 changed files with 31 additions and 0 deletions

View File

@ -2109,6 +2109,21 @@ void Playlist::RemoveDuplicateSongs() {
removeRows(rows_to_remove);
}
void Playlist::RemoveUnavailableSongs() {
QList<int> rows_to_remove;
for (int row = 0; row < items_.count(); ++row) {
PlaylistItemPtr item = items_[row];
const Song& song = item->Metadata();
// check only local files
if (song.url().isLocalFile() && !QFile::exists(song.url().toLocalFile())) {
rows_to_remove.append(row);
}
}
removeRows(rows_to_remove);
}
bool Playlist::ApplyValidityOnCurrentSong(const QUrl& url, bool valid) {
PlaylistItemPtr current = current_item();

View File

@ -314,6 +314,7 @@ class Playlist : public QAbstractListModel {
void Clear();
void RemoveDuplicateSongs();
void RemoveUnavailableSongs();
void Shuffle();
void ShuffleModeChanged(PlaylistSequence::ShuffleMode mode);

View File

@ -336,6 +336,10 @@ void PlaylistManager::RemoveDuplicatesCurrent() {
current()->RemoveDuplicateSongs();
}
void PlaylistManager::RemoveUnavailableCurrent() {
current()->RemoveUnavailableSongs();
}
void PlaylistManager::SetActivePlaying() { active()->Playing(); }
void PlaylistManager::SetActivePaused() { active()->Paused(); }

View File

@ -95,6 +95,7 @@ class PlaylistManagerInterface : public QObject {
virtual void ClearCurrent() = 0;
virtual void ShuffleCurrent() = 0;
virtual void RemoveDuplicatesCurrent() = 0;
virtual void RemoveUnavailableCurrent() = 0;
virtual void SetActivePlaying() = 0;
virtual void SetActivePaused() = 0;
virtual void SetActiveStopped() = 0;
@ -204,6 +205,7 @@ class PlaylistManager : public PlaylistManagerInterface {
void ClearCurrent();
void ShuffleCurrent();
void RemoveDuplicatesCurrent();
void RemoveUnavailableCurrent();
void SetActiveStreamMetadata(const QUrl& url, const Song& song);
// Rate current song using 0.0 - 1.0 scale.
void RateCurrentSong(double rating);

View File

@ -368,6 +368,8 @@ MainWindow::MainWindow(Application* app, SystemTrayIcon* tray_icon, OSD* osd,
app_->playlist_manager(), SLOT(ClearCurrent()));
connect(ui_->action_remove_duplicates, SIGNAL(triggered()),
app_->playlist_manager(), SLOT(RemoveDuplicatesCurrent()));
connect(ui_->action_remove_unavailable, SIGNAL(triggered()),
app_->playlist_manager(), SLOT(RemoveUnavailableCurrent()));
connect(ui_->action_remove_from_playlist, SIGNAL(triggered()),
SLOT(PlaylistRemoveCurrent()));
connect(ui_->action_edit_track, SIGNAL(triggered()), SLOT(EditTracks()));
@ -626,6 +628,7 @@ MainWindow::MainWindow(Application* app, SystemTrayIcon* tray_icon, OSD* osd,
playlist_menu_->addAction(ui_->action_clear_playlist);
playlist_menu_->addAction(ui_->action_shuffle);
playlist_menu_->addAction(ui_->action_remove_duplicates);
playlist_menu_->addAction(ui_->action_remove_unavailable);
#ifdef Q_OS_DARWIN
ui_->action_shuffle->setShortcut(QKeySequence());

View File

@ -444,6 +444,7 @@
<addaction name="action_clear_playlist"/>
<addaction name="action_shuffle"/>
<addaction name="action_remove_duplicates"/>
<addaction name="action_remove_unavailable"/>
</widget>
<widget class="QMenu" name="menu_help">
<property name="title">
@ -849,6 +850,11 @@
<string>Rip audio CD...</string>
</property>
</action>
<action name="action_remove_unavailable">
<property name="text">
<string>Remove unavailable tracks from playlist</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>