Commit fd0b3839 authored by Eike Ziller's avatar Eike Ziller

About Plugins: Fix sorting by "Load" column

Change-Id: I705a717ff13e23bafcffb0d41edceab95d3607e6
Task-number: QTCREATORBUG-14107
Reviewed-by: default avatarEike Ziller <eike.ziller@theqtcompany.com>
parent 46fc33d9
......@@ -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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment