From 88817c7f3b259550741c5e203fb28f7f705ce30c Mon Sep 17 00:00:00 2001 From: Tannin Date: Sat, 20 Dec 2014 14:44:40 +0100 Subject: - drag&drop in the plugin list now also prompts a message instead of being impossible --- src/pluginlistsortproxy.cpp | 53 +++++++++++---------------------------------- 1 file changed, 13 insertions(+), 40 deletions(-) (limited to 'src/pluginlistsortproxy.cpp') diff --git a/src/pluginlistsortproxy.cpp b/src/pluginlistsortproxy.cpp index 02d99b36..4f840f52 100644 --- a/src/pluginlistsortproxy.cpp +++ b/src/pluginlistsortproxy.cpp @@ -19,9 +19,12 @@ along with Mod Organizer. If not, see . #include "pluginlistsortproxy.h" #include "pluginlist.h" +#include "messagedialog.h" #include #include +#include #include +#include PluginListSortProxy::PluginListSortProxy(QObject *parent) @@ -35,16 +38,7 @@ PluginListSortProxy::PluginListSortProxy(QObject *parent) } -unsigned int PluginListSortProxy::getEnabledColumns() const -{ - unsigned int result = 0; - for (int i = 0; i <= PluginList::COL_LASTCOLUMN; ++i) { - if (m_EnabledColumns.test(i)) { - result |= 1 << i; - } - } - return result; -} + void PluginListSortProxy::setEnabledColumns(unsigned int columns) @@ -60,42 +54,14 @@ void PluginListSortProxy::setEnabledColumns(unsigned int columns) Qt::ItemFlags PluginListSortProxy::flags(const QModelIndex &modelIndex) const { Qt::ItemFlags flags = sourceModel()->flags(mapToSource(modelIndex)); - if (sortColumn() == PluginList::COL_NAME) { +/* if (sortColumn() == PluginList::COL_NAME) { flags &= ~Qt::ItemIsDragEnabled; - } + }*/ return flags; } -void PluginListSortProxy::displayColumnSelection(const QPoint &pos) -{ - QMenu menu; - - for (int i = 0; i <= PluginList::COL_LASTCOLUMN; ++i) { - QCheckBox *checkBox = new QCheckBox(&menu); - checkBox->setText(PluginList::getColumnName(i)); - checkBox->setChecked(m_EnabledColumns.test(i) ? Qt::Checked : Qt::Unchecked); - QWidgetAction *checkableAction = new QWidgetAction(&menu); - checkableAction->setDefaultWidget(checkBox); - menu.addAction(checkableAction); - } - menu.exec(pos); - int i = 0; - emit layoutAboutToBeChanged(); - m_EnabledColumns.reset(); - foreach (const QAction *action, menu.actions()) { - const QWidgetAction *widgetAction = qobject_cast(action); - if (widgetAction != NULL) { - const QCheckBox *checkBox = qobject_cast(widgetAction->defaultWidget()); - if (checkBox != NULL) { - m_EnabledColumns.set(i, checkBox->checkState() == Qt::Checked); - } - } - ++i; - } - emit layoutChanged(); -} void PluginListSortProxy::updateFilter(const QString &filter) @@ -134,6 +100,13 @@ bool PluginListSortProxy::lessThan(const QModelIndex &left, bool PluginListSortProxy::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) { + if ((sortColumn() != PluginList::COL_PRIORITY) + && (sortColumn() != PluginList::COL_MODINDEX)) { + QWidget *wid = qApp->activeWindow()->findChild("espList"); + MessageDialog::showMessage(tr("Drag&Drop is only supported when sorting by priority or mod index"), wid); + return false; + } + if ((row == -1) && (column == -1)) { return this->sourceModel()->dropMimeData(data, action, -1, -1, mapToSource(parent)); } -- cgit v1.3.1