added removeDuplicateSongs() function to playlist.cpp and added this action to the playlist-menu
Fixes issue #21
This commit is contained in:
parent
887cc0c2c8
commit
dcab14e5fe
|
@ -1906,6 +1906,25 @@ void Playlist::RemoveDeletedSongs() {
|
|||
removeRows(rows_to_remove);
|
||||
}
|
||||
|
||||
void Playlist::RemoveDuplicateSongs() {
|
||||
QList<int> rows_to_remove;
|
||||
QSet<QUrl> filenames;
|
||||
|
||||
for (int row = 0; row < items_.count(); ++row) {
|
||||
PlaylistItemPtr item = items_[row];
|
||||
Song song = item->Metadata();
|
||||
|
||||
if (filenames.contains(song.url())) {
|
||||
rows_to_remove.append(row);
|
||||
} else {
|
||||
filenames.insert(song.url());
|
||||
}
|
||||
}
|
||||
|
||||
removeRows(rows_to_remove);
|
||||
}
|
||||
|
||||
|
||||
bool Playlist::ApplyValidityOnCurrentSong(const QUrl& url, bool valid) {
|
||||
PlaylistItemPtr current = current_item();
|
||||
|
||||
|
|
|
@ -280,6 +280,7 @@ class Playlist : public QAbstractListModel {
|
|||
void UpdateItems(const SongList& songs);
|
||||
|
||||
void Clear();
|
||||
void RemoveDuplicateSongs();
|
||||
void Shuffle();
|
||||
|
||||
void ShuffleModeChanged(PlaylistSequence::ShuffleMode mode);
|
||||
|
|
|
@ -257,6 +257,10 @@ void PlaylistManager::ShuffleCurrent() {
|
|||
current()->Shuffle();
|
||||
}
|
||||
|
||||
void PlaylistManager::RemoveDuplicatesCurrent() {
|
||||
current()->RemoveDuplicateSongs();
|
||||
}
|
||||
|
||||
void PlaylistManager::SetActivePlaying() {
|
||||
active()->Playing();
|
||||
}
|
||||
|
|
|
@ -96,6 +96,7 @@ public slots:
|
|||
// Convenience slots that defer to either current() or active()
|
||||
virtual void ClearCurrent() = 0;
|
||||
virtual void ShuffleCurrent() = 0;
|
||||
virtual void RemoveDuplicatesCurrent() = 0;
|
||||
virtual void SetActivePlaying() = 0;
|
||||
virtual void SetActivePaused() = 0;
|
||||
virtual void SetActiveStopped() = 0;
|
||||
|
@ -191,6 +192,7 @@ public slots:
|
|||
// Convenience slots that defer to either current() or active()
|
||||
void ClearCurrent();
|
||||
void ShuffleCurrent();
|
||||
void RemoveDuplicatesCurrent();
|
||||
void SetActiveStreamMetadata(const QUrl& url, const Song& song);
|
||||
// Rate current song using 0.0 - 1.0 scale.
|
||||
void RateCurrentSong(double rating);
|
||||
|
|
|
@ -318,6 +318,7 @@ MainWindow::MainWindow(Application* app,
|
|||
connect(ui_->action_toggle_scrobbling, SIGNAL(triggered()), InternetModel::Service<LastFMService>(), SLOT(ToggleScrobbling()));
|
||||
#endif
|
||||
connect(ui_->action_clear_playlist, SIGNAL(triggered()), app_->playlist_manager(), SLOT(ClearCurrent()));
|
||||
connect(ui_->action_remove_duplicates, SIGNAL(triggered()), app_->playlist_manager(), SLOT(RemoveDuplicatesCurrent()));
|
||||
connect(ui_->action_remove_from_playlist, SIGNAL(triggered()), SLOT(PlaylistRemoveCurrent()));
|
||||
connect(ui_->action_edit_track, SIGNAL(triggered()), SLOT(EditTracks()));
|
||||
connect(ui_->action_renumber_tracks, SIGNAL(triggered()), SLOT(RenumberTracks()));
|
||||
|
@ -491,6 +492,7 @@ MainWindow::MainWindow(Application* app,
|
|||
playlist_open_in_browser_ = playlist_menu_->addAction(IconLoader::Load("document-open-folder"), tr("Show in file browser..."), this, SLOT(PlaylistOpenInBrowser()));
|
||||
playlist_menu_->addSeparator();
|
||||
playlist_menu_->addAction(ui_->action_clear_playlist);
|
||||
playlist_menu_->addAction(ui_->action_remove_duplicates);
|
||||
playlist_menu_->addAction(ui_->action_shuffle);
|
||||
|
||||
#ifdef Q_OS_DARWIN
|
||||
|
|
|
@ -457,6 +457,7 @@
|
|||
<addaction name="action_clear_playlist"/>
|
||||
<addaction name="action_shuffle"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="action_remove_duplicates"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menu_help">
|
||||
<property name="title">
|
||||
|
@ -848,6 +849,11 @@
|
|||
<string>Add podcast...</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="action_remove_duplicates">
|
||||
<property name="text">
|
||||
<string>Remove duplicates</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<customwidgets>
|
||||
|
|
Loading…
Reference in New Issue