diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2014-10-27 18:06:12 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2014-10-27 18:06:12 +0000 |
| commit | 9731b885956a4d4da2dd420c6017ea3be5da9654 (patch) | |
| tree | 26ee317137798ad0d753c3a717210feab3c20443 /src | |
| parent | b45e369d2b4872ba46446913991b6ae5dd9ad414 (diff) | |
| download | qmmp-9731b885956a4d4da2dd420c6017ea3be5da9654.tar.gz qmmp-9731b885956a4d4da2dd420c6017ea3be5da9654.tar.bz2 qmmp-9731b885956a4d4da2dd420c6017ea3be5da9654.zip | |
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
Diffstat (limited to 'src')
| -rw-r--r-- | src/qmmpui/playlistmodel.cpp | 36 |
1 files changed, 26 insertions, 10 deletions
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(); } } |
