diff --git a/src/pluginitemmodel.cpp b/src/pluginitemmodel.cpp index 7846182e9e..34b7fdbae9 100644 --- a/src/pluginitemmodel.cpp +++ b/src/pluginitemmodel.cpp @@ -121,6 +121,24 @@ QModelIndex PluginItem::modelIndex() const //============================================================================== +bool PluginItem::hasCheckBox() const +{ + // Return whether we have a check box + + return mHasCheckBox; +} + +//============================================================================== + +void PluginItem::setHasCheckBox(bool pHasCheckBox) +{ + // Specify whether we have a check box + + mHasCheckBox = pHasCheckBox; +} + +//============================================================================== + bool PluginItem::isCheckable() const { // Return whether we are checkable @@ -157,6 +175,15 @@ void PluginItem::setCheckState(Qt::CheckState pCheckState) //============================================================================== +QIcon PluginItem::icon() const +{ + // Return our icon + + return mIcon; +} + +//============================================================================== + QString PluginItem::name() const { // Return our name @@ -275,8 +302,22 @@ QVariant PluginItemModel::data(const QModelIndex &pIndex, int pRole) const { // Return the data for the given index - if (pIndex.isValid() && (pRole == Qt::DisplayRole)) { - return static_cast(pIndex.internalPointer())->name(); + if (pIndex.isValid()) { + if (pRole == Qt::DisplayRole) { + return static_cast(pIndex.internalPointer())->name(); + } + + if (pRole == Qt::CheckStateRole) { + PluginItem *item = static_cast(pIndex.internalPointer()); + + if (item->hasCheckBox()) { + return static_cast(pIndex.internalPointer())->checkState(); + } + } + + if (pRole == Qt::DecorationRole) { + return static_cast(pIndex.internalPointer())->icon(); + } } return {}; diff --git a/src/pluginitemmodel.h b/src/pluginitemmodel.h index 95fd94c224..9ef1ae73d2 100644 --- a/src/pluginitemmodel.h +++ b/src/pluginitemmodel.h @@ -57,12 +57,16 @@ class PluginItem QModelIndex modelIndex() const; + bool hasCheckBox() const; + void setHasCheckBox(bool pHasCheckBox); + bool isCheckable() const; void setCheckable(bool pCheckable); Qt::CheckState checkState() const; void setCheckState(Qt::CheckState pCheckState); + QIcon icon() const; QString name() const; void insert(int pIndex, PluginItem *pItem); @@ -74,7 +78,8 @@ class PluginItem PluginItem *mParent = nullptr; QVector mChildren; - bool mCheckable = true; + bool mHasCheckBox = false; + bool mCheckable = false; Qt::CheckState mCheckState; QIcon mIcon; diff --git a/src/pluginsdialog.cpp b/src/pluginsdialog.cpp index 2db06a8c58..11e6f90b9d 100644 --- a/src/pluginsdialog.cpp +++ b/src/pluginsdialog.cpp @@ -154,11 +154,13 @@ PluginsDialog::PluginsDialog(PluginManager *pPluginManager, plugin->name()); // Only selectable plugins and plugins that are of the right type are - // checkable + // checkable though all plugins should have a check box + // Note: the latter is only so that everything gets nicely aligned... PluginInfo *pluginInfo = plugin->info(); if (pluginInfo != nullptr) { + pluginItem->setHasCheckBox(true); pluginItem->setCheckable(pluginInfo->isSelectable()); if (pluginItem->isCheckable()) {