From 14ff3ad8079147ef188270eb10631c0c2962435d Mon Sep 17 00:00:00 2001 From: trialuser02 Date: Tue, 13 Aug 2013 16:41:14 +0000 Subject: enabled item moving feature git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@3592 90c681e8-e032-0410-971d-27865f9a5e38 --- src/qmmpui/playlistcontainer.cpp | 49 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'src/qmmpui/playlistcontainer.cpp') 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 tracks) removeTrack(t); } +void PlayListContainer::move(QList 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()) -- cgit v1.2.3-13-gbd6f