Commit 8e552821 authored by Tobias Hunger's avatar Tobias Hunger

CMake: Only enable edit button for CMake configuration when useful

Only enable the button when items are actually editable.

Change-Id: I54fd5430772a6db61c85b59d5c655d3bd4ebf8d7
Reviewed-by: default avatarhjk <hjk@qt.io>
parent d1799b9a
......@@ -197,6 +197,9 @@ CMakeBuildSettingsWidget::CMakeBuildSettingsWidget(CMakeBuildConfiguration *bc)
mainLayout->addLayout(buttonLayout, row, 2);
connect(m_configView->selectionModel(), &QItemSelectionModel::currentChanged,
this, &CMakeBuildSettingsWidget::updateSelection);
++row;
m_reconfigureButton = new QPushButton(tr("Apply Configuration Changes"));
m_reconfigureButton->setEnabled(false);
......@@ -331,5 +334,24 @@ void CMakeBuildSettingsWidget::updateFromKit()
m_configModel->setKitConfiguration(configHash);
}
static QModelIndex mapToSource(const QAbstractItemView *view, const QModelIndex &idx)
{
QAbstractItemModel *model = view->model();
QModelIndex result = idx;
while (QSortFilterProxyModel *proxy = qobject_cast<QSortFilterProxyModel *>(model)) {
result = proxy->mapToSource(result);
model = proxy->sourceModel();
}
return result;
}
void CMakeBuildSettingsWidget::updateSelection(const QModelIndex &current, const QModelIndex &previous)
{
Q_UNUSED(previous);
const QModelIndex currentModelIndex = mapToSource(m_configView, current);
if (currentModelIndex.isValid())
m_editButton->setEnabled(currentModelIndex.flags().testFlag(Qt::ItemIsEditable));
}
} // namespace Internal
} // namespace CMakeProjectManager
......@@ -64,6 +64,8 @@ private:
void updateAdvancedCheckBox();
void updateFromKit();
void updateSelection(const QModelIndex &current, const QModelIndex &previous);
CMakeBuildConfiguration *m_buildConfiguration;
QTreeView *m_configView;
ConfigModel *m_configModel;
......
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