forked from qt-creator/qt-creator
CMake: Only enable edit button for CMake configuration when useful
Only enable the button when items are actually editable. Change-Id: I54fd5430772a6db61c85b59d5c655d3bd4ebf8d7 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -197,6 +197,9 @@ CMakeBuildSettingsWidget::CMakeBuildSettingsWidget(CMakeBuildConfiguration *bc)
|
|||||||
|
|
||||||
mainLayout->addLayout(buttonLayout, row, 2);
|
mainLayout->addLayout(buttonLayout, row, 2);
|
||||||
|
|
||||||
|
connect(m_configView->selectionModel(), &QItemSelectionModel::currentChanged,
|
||||||
|
this, &CMakeBuildSettingsWidget::updateSelection);
|
||||||
|
|
||||||
++row;
|
++row;
|
||||||
m_reconfigureButton = new QPushButton(tr("Apply Configuration Changes"));
|
m_reconfigureButton = new QPushButton(tr("Apply Configuration Changes"));
|
||||||
m_reconfigureButton->setEnabled(false);
|
m_reconfigureButton->setEnabled(false);
|
||||||
@@ -331,5 +334,24 @@ void CMakeBuildSettingsWidget::updateFromKit()
|
|||||||
m_configModel->setKitConfiguration(configHash);
|
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 ¤t, 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 Internal
|
||||||
} // namespace CMakeProjectManager
|
} // namespace CMakeProjectManager
|
||||||
|
@@ -64,6 +64,8 @@ private:
|
|||||||
void updateAdvancedCheckBox();
|
void updateAdvancedCheckBox();
|
||||||
void updateFromKit();
|
void updateFromKit();
|
||||||
|
|
||||||
|
void updateSelection(const QModelIndex ¤t, const QModelIndex &previous);
|
||||||
|
|
||||||
CMakeBuildConfiguration *m_buildConfiguration;
|
CMakeBuildConfiguration *m_buildConfiguration;
|
||||||
QTreeView *m_configView;
|
QTreeView *m_configView;
|
||||||
ConfigModel *m_configModel;
|
ConfigModel *m_configModel;
|
||||||
|
Reference in New Issue
Block a user