From 9731b885956a4d4da2dd420c6017ea3be5da9654 Mon Sep 17 00:00:00 2001 From: trialuser02 Date: Mon, 27 Oct 2014 18:06:12 +0000 Subject: reduced time of duplicates search git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@4598 90c681e8-e032-0410-971d-27865f9a5e38 --- src/qmmpui/playlistmodel.cpp | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/qmmpui/playlistmodel.cpp b/src/qmmpui/playlistmodel.cpp index 951d52dfa..c41bd11c1 100644 --- a/src/qmmpui/playlistmodel.cpp +++ b/src/qmmpui/playlistmodel.cpp @@ -876,20 +876,36 @@ void PlayListModel::removeInvalidTracks() void PlayListModel::removeDuplicates() { + QStringList urls; + bool modified = false; + PlayListTrack *prev_current = m_current_track; + for(int i = 0; i < m_container->count(); ++i) { if(!isTrack(i)) continue; - int j = m_container->count() - 1; - while(j > i) - { - if(j < m_container->count() && isTrack(j)) - { - if(track(i)->url() == track(j)->url()) - removeTrack(j); - } - j--; - } + + if(urls.contains(track(i)->url())) + { + blockSignals(true); + removeTrack(i); + blockSignals(false); + modified = true; + i--; + } + else + { + urls.append(track(i)->url()); + } + } + + if(modified) + { + if(m_current_track != prev_current) + emit currentChanged(); + + emit listChanged(); + emit countChanged(); } } -- cgit v1.2.3-13-gbd6f