summaryrefslogtreecommitdiff
path: root/src/libs
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@theqtcompany.com>2015-04-01 16:49:43 +0200
committerEike Ziller <eike.ziller@theqtcompany.com>2015-04-02 09:53:06 +0000
commitfd0b383932452ae20fa83e9224d473014dedc841 (patch)
tree27d5c8c1cb8cc860ea2925475edf5a550bc543f4 /src/libs
parent46fc33d9147c843d122d8384ab9c1465ef716ee1 (diff)
downloadqt-creator-fd0b383932452ae20fa83e9224d473014dedc841.tar.gz
About Plugins: Fix sorting by "Load" column
Change-Id: I705a717ff13e23bafcffb0d41edceab95d3607e6 Task-number: QTCREATORBUG-14107 Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
Diffstat (limited to 'src/libs')
-rw-r--r--src/libs/extensionsystem/pluginview.cpp19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/libs/extensionsystem/pluginview.cpp b/src/libs/extensionsystem/pluginview.cpp
index 97b87f84db..9875a3d5d3 100644
--- a/src/libs/extensionsystem/pluginview.cpp
+++ b/src/libs/extensionsystem/pluginview.cpp
@@ -81,6 +81,8 @@ enum Columns { NameColumn, LoadedColumn, VersionColumn, VendorColumn, };
enum IconIndex { OkIcon, ErrorIcon, NotLoadedIcon };
+static const int SortRole = Qt::UserRole + 1;
+
static const QIcon &icon(int num)
{
static QIcon icons[] = {
@@ -104,7 +106,7 @@ public:
{
switch (column) {
case NameColumn:
- if (role == Qt::DisplayRole)
+ if (role == Qt::DisplayRole || role == SortRole)
return m_spec->name();
if (role == Qt::ToolTipRole)
return QDir::toNativeSeparators(m_spec->filePath());
@@ -119,17 +121,17 @@ public:
case LoadedColumn:
if (!m_spec->isAvailableForHostPlatform()) {
- if (role == Qt::CheckStateRole)
+ if (role == Qt::CheckStateRole || role == SortRole)
return Qt::Unchecked;
if (role == Qt::ToolTipRole)
return PluginView::tr("Plugin is not available on this platform.");
} else if (m_spec->isRequired()) {
- if (role == Qt::CheckStateRole)
+ if (role == Qt::CheckStateRole || role == SortRole)
return Qt::Checked;
if (role == Qt::ToolTipRole)
return PluginView::tr("Plugin is required.");
} else {
- if (role == Qt::CheckStateRole)
+ if (role == Qt::CheckStateRole || role == SortRole)
return m_spec->isEnabledInSettings() ? Qt::Checked : Qt::Unchecked;
if (role == Qt::ToolTipRole)
return PluginView::tr("Load on startup");
@@ -137,12 +139,12 @@ public:
break;
case VersionColumn:
- if (role == Qt::DisplayRole)
+ if (role == Qt::DisplayRole || role == SortRole)
return QString::fromLatin1("%1 (%2)").arg(m_spec->version(), m_spec->compatVersion());
break;
case VendorColumn:
- if (role == Qt::DisplayRole)
+ if (role == Qt::DisplayRole || role == SortRole)
return m_spec->vendor();
break;
}
@@ -207,7 +209,7 @@ public:
QVariant data(int column, int role) const
{
if (column == NameColumn) {
- if (role == Qt::DisplayRole)
+ if (role == Qt::DisplayRole || role == SortRole)
return m_name;
if (role == Qt::DecorationRole) {
foreach (PluginSpec *spec, m_plugins) {
@@ -223,7 +225,7 @@ public:
if (column == LoadedColumn) {
if (role == Qt::ToolTipRole)
return PluginView::tr("Load on Startup");
- if (role == Qt::CheckStateRole) {
+ if (role == Qt::CheckStateRole || role == SortRole) {
int checkedCount = 0;
foreach (PluginSpec *spec, m_plugins) {
if (spec->isEnabledInSettings())
@@ -291,6 +293,7 @@ PluginView::PluginView(QWidget *parent)
m_sortModel = new QSortFilterProxyModel(this);
m_sortModel->setSourceModel(m_model);
+ m_sortModel->setSortRole(SortRole);
m_categoryView->setModel(m_sortModel);
QGridLayout *gridLayout = new QGridLayout(this);