forked from qt-creator/qt-creator
CMake: Improve delegates for CMake configuration
Change-Id: Ib1d2bfca1b2faafd36c53f24c6649e73ee0af190 Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
@@ -33,6 +33,7 @@
|
||||
#include <QCoreApplication>
|
||||
#include <QFont>
|
||||
#include <QString>
|
||||
#include <QSortFilterProxyModel>
|
||||
|
||||
namespace CMakeProjectManager {
|
||||
|
||||
@@ -154,6 +155,37 @@ void ConfigModel::forceToString(const QModelIndex &idx)
|
||||
emit dataChanged(valueIdx, valueIdx);
|
||||
}
|
||||
|
||||
ConfigModel::DataItem ConfigModel::dataItemFromIndex(const QModelIndex &idx)
|
||||
{
|
||||
const QAbstractItemModel *m = idx.model();
|
||||
QModelIndex mIdx = idx;
|
||||
while (auto sfpm = qobject_cast<const QSortFilterProxyModel *>(m)) {
|
||||
m = sfpm->sourceModel();
|
||||
mIdx = sfpm->mapToSource(mIdx);
|
||||
}
|
||||
auto model = qobject_cast<const ConfigModel *>(m);
|
||||
QTC_ASSERT(model, return DataItem());
|
||||
const QModelIndex modelIdx = mIdx;
|
||||
|
||||
Utils::TreeItem *item = model->itemForIndex(modelIdx);
|
||||
auto cmti = dynamic_cast<Internal::ConfigModelTreeItem *>(item);
|
||||
|
||||
if (cmti && cmti->dataItem) {
|
||||
DataItem di;
|
||||
di.key = cmti->dataItem->key;
|
||||
di.type = cmti->dataItem->type;
|
||||
di.isHidden = cmti->dataItem->isHidden;
|
||||
di.isAdvanced = cmti->dataItem->isAdvanced;
|
||||
di.inCMakeCache = cmti->dataItem->inCMakeCache;
|
||||
di.value = cmti->dataItem->currentValue();
|
||||
di.description = cmti->dataItem->description;
|
||||
di.values = cmti->dataItem->values;
|
||||
|
||||
return di;
|
||||
}
|
||||
return DataItem();
|
||||
}
|
||||
|
||||
QList<ConfigModel::DataItem> ConfigModel::configurationChanges() const
|
||||
{
|
||||
const QList<InternalDataItem> tmp
|
||||
@@ -303,10 +335,6 @@ QVariant ConfigModelTreeItem::data(int column, int role) const
|
||||
}
|
||||
|
||||
// Leaf node:
|
||||
if (role == ConfigModel::ItemTypeRole)
|
||||
return dataItem->type;
|
||||
if (role == ConfigModel::ItemValuesRole)
|
||||
return dataItem->values;
|
||||
if (role == ConfigModel::ItemIsAdvancedRole)
|
||||
return dataItem->isAdvanced ? "1" : "0";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user