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/playlistmodel.cpp | 52 ++++++++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 19 deletions(-) (limited to 'src/qmmpui/playlistmodel.cpp') 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 selected_rows = selectedIndexes(); + QList 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) -- cgit v1.2.3-13-gbd6f