diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2013-08-13 16:41:14 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2013-08-13 16:41:14 +0000 |
| commit | 14ff3ad8079147ef188270eb10631c0c2962435d (patch) | |
| tree | be428491ac41b06c8c8c85df8c5ddaefb761e76c /src/qmmpui/playlistcontainer.cpp | |
| parent | 48a0ee1fcdac69def507f6d3a31ff6ee32b19480 (diff) | |
| download | qmmp-14ff3ad8079147ef188270eb10631c0c2962435d.tar.gz qmmp-14ff3ad8079147ef188270eb10631c0c2962435d.tar.bz2 qmmp-14ff3ad8079147ef188270eb10631c0c2962435d.zip | |
enabled item moving feature
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@3592 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/qmmpui/playlistcontainer.cpp')
| -rw-r--r-- | src/qmmpui/playlistcontainer.cpp | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/qmmpui/playlistcontainer.cpp b/src/qmmpui/playlistcontainer.cpp index 4cde4d195..6f0297061 100644 --- a/src/qmmpui/playlistcontainer.cpp +++ b/src/qmmpui/playlistcontainer.cpp @@ -197,6 +197,55 @@ void PlayListContainer::removeTracks(QList<PlayListTrack *> tracks) removeTrack(t); } +void PlayListContainer::move(QList<int> indexes, int from, int to) +{ + PlayListGroup *group = 0; + + foreach (PlayListGroup *g, m_groups) + { + if(from > g->firstIndex && from <= g->lastIndex && + to > g->firstIndex && to <= g->lastIndex) + { + group = g; + break; + } + } + + if(!group) + return; + + foreach (int i, indexes) + { + if(i <= group->firstIndex || i > group->lastIndex) + return; + } + + if (from > to) + foreach(int i, indexes) + { + if (i + to - from < 0) + break; + else + { + m_items.move(i,i + to - from); + group->move(i - group->firstIndex - 1, + i + to - from - group->firstIndex - 1); + } + } + else + for (int i = indexes.count() - 1; i >= 0; i--) + { + if (indexes[i] + to - from >= m_items.count()) + break; + else + { + m_items.move(indexes[i], indexes[i] + to - from); + group->move(indexes[i] - group->firstIndex - 1, + indexes[i] + to - from - group->firstIndex - 1); + } + } +} + void PlayListContainer::clear() { while(!m_groups.isEmpty()) |
