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/playlistmodel.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/playlistmodel.cpp')
| -rw-r--r-- | src/qmmpui/playlistmodel.cpp | 52 |
1 files changed, 33 insertions, 19 deletions
diff --git a/src/qmmpui/playlistmodel.cpp b/src/qmmpui/playlistmodel.cpp index 7f0b67dd8..ab97fae0c 100644 --- a/src/qmmpui/playlistmodel.cpp +++ b/src/qmmpui/playlistmodel.cpp @@ -39,7 +39,7 @@ #include "tagupdater_p.h" #include "playlistmodel.h" -#define INVALID_ROW -1 +#define INVALID_INDEX -1 PlayListModel::PlayListModel(const QString &name, QObject *parent) : QObject(parent) , m_selection() @@ -128,7 +128,6 @@ void PlayListModel::add(const QString &path) m_loader->loadFile(path); loadPlaylist(path); } - } void PlayListModel::add(const QStringList &paths) @@ -477,33 +476,48 @@ int PlayListModel::totalLength() const void PlayListModel::moveItems(int from, int to) { // Get rid of useless work - /*if (from == to) + if (from == to) return; - QList<int> selected_rows = selectedIndexes(); + QList<int> selected_indexes = selectedIndexes(); + + if(selected_indexes.isEmpty()) + return; - if (!(bottommostInSelection(from) == INVALID_ROW || - from == INVALID_ROW || - topmostInSelection(from) == INVALID_ROW) - ) + foreach(int i, selected_indexes) //do no move groups { - if (from > to) - foreach(int i, selected_rows) + if(!isTrack(i)) + return; + } + + if (bottommostInSelection(from) == INVALID_INDEX || + from == INVALID_INDEX || + topmostInSelection(from) == INVALID_INDEX) + return; + + m_container.move(selected_indexes, from, to); + + /*if (from > to) + foreach(int i, selected_indexes) + { if (i + to - from < 0) break; + else m_items.move(i,i + to - from); - else - for (int i = selected_rows.count() - 1; i >= 0; i--) - if (selected_rows[i] + to -from >= m_items.count()) - break; - else - m_items.move(selected_rows[i],selected_rows[i] + to - from); - - m_current = m_items.indexOf(m_currentItem); + } + else - emit listChanged(); + for (int i = selected_indexes.count() - 1; i >= 0; i--) + { + if (selected_indexes[i] + to -from >= m_items.count()) + break; + else + m_items.move(selected_indexes[i],selected_indexes[i] + to - from); }*/ + + m_current = m_container.indexOf(m_current_track); + emit listChanged(); } int PlayListModel::topmostInSelection(int row) |
