Commit cacb6b17 authored by Tobias Hunger's avatar Tobias Hunger

CMake: Group entries in project configuration

Change-Id: I6aa797f5ff49a5cc33dfbdf0b25dcd78abbff66e
Reviewed-by: default avatarhjk <hjk@qt.io>
parent 8e96bc91
......@@ -139,21 +139,23 @@ CMakeBuildSettingsWidget::CMakeBuildSettingsWidget(CMakeBuildConfiguration *bc)
connect(tree, &Utils::TreeView::activated,
tree, [tree](const QModelIndex &idx) { tree->edit(idx); });
m_configView = tree;
m_configFilterModel->setSourceModel(m_configModel);
m_configFilterModel->setFilterKeyColumn(2);
m_configFilterModel->setFilterFixedString(QLatin1String("0"));
m_configFilterModel->setFilterKeyColumn(0);
m_configFilterModel->setFilterRole(ConfigModel::ItemIsAdvancedRole);
m_configFilterModel->setFilterFixedString("0");
m_configTextFilterModel->setSourceModel(m_configFilterModel);
m_configTextFilterModel->setFilterKeyColumn(-1);
m_configTextFilterModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
m_configView->setModel(m_configTextFilterModel);
m_configView->setMinimumHeight(300);
m_configView->setRootIsDecorated(false);
m_configView->setUniformRowHeights(true);
auto stretcher = new Utils::HeaderViewStretcher(m_configView->header(), 1);
m_configView->setSelectionMode(QAbstractItemView::SingleSelection);
m_configView->setSelectionBehavior(QAbstractItemView::SelectItems);
m_configView->setFrameShape(QFrame::NoFrame);
m_configView->hideColumn(2); // Hide isAdvanced column
m_configView->setItemDelegate(new ConfigModelItemDelegate(m_configView));
QFrame *findWrapper = Core::ItemViewFind::createSearchableWrapper(m_configView, Core::ItemViewFind::LightColored);
findWrapper->setFrameStyle(QFrame::StyledPanel);
......@@ -311,8 +313,10 @@ void CMakeBuildSettingsWidget::updateButtonState()
void CMakeBuildSettingsWidget::updateAdvancedCheckBox()
{
// Switch between Qt::DisplayRole (everything is "0") and Qt::EditRole (advanced is "1").
m_configFilterModel->setFilterRole(m_showAdvancedCheckBox->isChecked() ? Qt::EditRole : Qt::DisplayRole);
if (m_showAdvancedCheckBox->isChecked())
m_configTextFilterModel->setSourceModel(m_configModel);
else
m_configTextFilterModel->setSourceModel(m_configFilterModel);
}
void CMakeBuildSettingsWidget::updateFromKit()
......
......@@ -26,17 +26,21 @@
#pragma once
#include <QAbstractTableModel>
#include <utils/treemodel.h>
namespace CMakeProjectManager {
class ConfigModel : public QAbstractTableModel
namespace Internal { class ConfigModelTreeItem; }
class ConfigModel : public Utils::TreeModel<>
{
Q_OBJECT
public:
enum Roles {
ItemTypeRole = Qt::UserRole,
ItemValuesRole
ItemValuesRole,
ItemIsAdvancedRole
};
class DataItem {
......@@ -54,14 +58,9 @@ public:
};
explicit ConfigModel(QObject *parent = nullptr);
~ConfigModel() override;
// QAbstractItemModel interface
int rowCount(const QModelIndex &parent) const override;
int columnCount(const QModelIndex &parent) const override;
Qt::ItemFlags flags(const QModelIndex &index) const override;
QVariant data(const QModelIndex &index, int role) const override;
bool setData(const QModelIndex &index, const QVariant &value, int role) override;
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
QVariant data(const QModelIndex &idx, int role) const final;
void appendConfiguration(const QString &key,
const QString &value = QString(),
......@@ -92,12 +91,35 @@ private:
bool isUserNew = false;
bool isCMakeChanged = false;
QString newValue;
QString kitValue;
};
InternalDataItem &itemAtRow(int row);
const InternalDataItem &itemAtRow(int row) const;
void setConfiguration(const QList<InternalDataItem> &config);
void generateTree();
QList<InternalDataItem> m_configuration;
QHash<QString, QString> m_kitConfiguartion;
QHash<QString, QString> m_kitConfiguration;
friend class Internal::ConfigModelTreeItem;
};
namespace Internal {
class ConfigModelTreeItem : public Utils::TreeItem
{
public:
ConfigModelTreeItem(ConfigModel::InternalDataItem *di = nullptr) : dataItem(di) {}
virtual ~ConfigModelTreeItem() override;
QVariant data(int column, int role) const final;
bool setData(int column, const QVariant &data, int role) final;
Qt::ItemFlags flags(int column) const final;
QString toolTip() const;
QString currentValue() const;
ConfigModel::InternalDataItem *dataItem;
};
} // namespace Internal
} // namespace CMakeProjectManager
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