From ebfeb2fbf95df4a2246ff2ef1cd6b48f373b70f3 Mon Sep 17 00:00:00 2001 From: Tannin Date: Sun, 14 Dec 2014 18:25:26 +0100 Subject: - mod-list can now be re-ordered with drag&drop while grouping is active - drag&drop is not disabled when ordering by other columns than priority. MO will notify using messagedialog that it's impossible instead. --- src/mainwindow.cpp | 4 ++-- src/modlistsortproxy.cpp | 12 +++++++++--- src/qtgroupingproxy.cpp | 17 +++++++++++++++++ src/qtgroupingproxy.h | 2 ++ 4 files changed, 30 insertions(+), 5 deletions(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 74690f19..0bdf4160 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -2537,7 +2537,6 @@ static HRESULT CreateShortcut(LPCWSTR targetFileName, LPCWSTR arguments, qCritical("failed to create IShellLink instance"); return result; } - if (!SUCCEEDED(result)) return result; result = shellLink->SetPath(targetFileName); if (!SUCCEEDED(result)) { @@ -2545,6 +2544,7 @@ static HRESULT CreateShortcut(LPCWSTR targetFileName, LPCWSTR arguments, shellLink->Release(); return result; } + result = shellLink->SetArguments(arguments); if (!SUCCEEDED(result)) { qCritical("failed to set arguments: %ls", arguments); @@ -2570,7 +2570,7 @@ static HRESULT CreateShortcut(LPCWSTR targetFileName, LPCWSTR arguments, } } - IPersistFile* persistFile; + IPersistFile *persistFile; result = shellLink->QueryInterface(IID_IPersistFile, (LPVOID*)&persistFile); if (SUCCEEDED(result)) { wchar_t linkFileNameW[MAX_PATH]; diff --git a/src/modlistsortproxy.cpp b/src/modlistsortproxy.cpp index 887ef758..0f6ce33a 100644 --- a/src/modlistsortproxy.cpp +++ b/src/modlistsortproxy.cpp @@ -21,10 +21,12 @@ along with Mod Organizer. If not, see . #include "modinfo.h" #include "profile.h" #include "modlist.h" +#include "messagedialog.h" #include #include #include -#include +#include +#include ModListSortProxy::ModListSortProxy(Profile* profile, QObject *parent) @@ -65,9 +67,9 @@ void ModListSortProxy::setCategoryFilter(const std::vector &categories) Qt::ItemFlags ModListSortProxy::flags(const QModelIndex &modelIndex) const { Qt::ItemFlags flags = sourceModel()->flags(mapToSource(modelIndex)); - if (sortColumn() != ModList::COL_PRIORITY) { +/* if (sortColumn() != ModList::COL_PRIORITY) { flags &= ~Qt::ItemIsDragEnabled; - } + }*/ return flags; } @@ -321,6 +323,10 @@ bool ModListSortProxy::filterAcceptsRow(int row, const QModelIndex &parent) cons bool ModListSortProxy::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) { + if (sortColumn() != ModList::COL_PRIORITY) { + MessageDialog::showMessage(tr("Drag&Drop is only supported when sorting by priority"), qApp->activeWindow()); + return false; + } if ((row == -1) && (column == -1)) { return this->sourceModel()->dropMimeData(data, action, -1, -1, mapToSource(parent)); } diff --git a/src/qtgroupingproxy.cpp b/src/qtgroupingproxy.cpp index 45ff192b..64ca5241 100644 --- a/src/qtgroupingproxy.cpp +++ b/src/qtgroupingproxy.cpp @@ -866,6 +866,23 @@ QtGroupingProxy::hasChildren( const QModelIndex &parent ) const return sourceModel()->hasChildren( mapToSource( parent ) ); } +bool +QtGroupingProxy::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) +{ + QModelIndex idx = index(row, column, parent); + if (isGroup(idx)) { + QList childRows = m_groupHash.value(idx.row()); + int max = *std::max_element(childRows.begin(), childRows.end()); + + QModelIndex newIdx = mapToSource(index(max, column, idx)); + return sourceModel()->dropMimeData(data, action, max, column, newIdx); + } else { + QModelIndex idx = mapToSource(index(row, column, parent)); + + return sourceModel()->dropMimeData(data, action, idx.row(), idx.column(), idx.parent()); + } +} + void QtGroupingProxy::modelRowsAboutToBeInserted( const QModelIndex &parent, int start, int end ) { diff --git a/src/qtgroupingproxy.h b/src/qtgroupingproxy.h index 7df069f7..6567cb0e 100644 --- a/src/qtgroupingproxy.h +++ b/src/qtgroupingproxy.h @@ -73,6 +73,7 @@ public: virtual bool canFetchMore( const QModelIndex &parent ) const; virtual void fetchMore( const QModelIndex &parent ); virtual bool hasChildren( const QModelIndex &parent = QModelIndex() ) const; + virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent); /* QtGroupingProxy methods */ virtual QModelIndex addEmptyGroup( const RowData &data ); @@ -162,6 +163,7 @@ private: int m_groupedRole; int m_aggregateRole; + }; #endif //GROUPINGPROXY_H -- cgit v1.3.1