From 201f91b8672b2c26d458d4e719a8b3d796d8f00e Mon Sep 17 00:00:00 2001 From: Cristian Adam Date: Tue, 1 Feb 2022 10:25:42 +0100 Subject: [PATCH] CMakePM: Mark as changed only the changed values in "Batch Edit..." Previously all values coming from "Batch Edit..." would be considered as user changed values and be displayed with bold font. This means that if I had -DMY_VAR:BOOL=ON and do a Copy and paste in "Batch Edit..." I would have it displayed as user changed and it would be passed to CMake as changed value. Also it should be possible to start with -DMY_VAR:BOOL=ON, click the check box to make it OFF and then do a "Batch Edit..." with -DMY_VAR:BOOL=ON to set the value back to original value. Change-Id: I5f6cb915b32a3288c1339135dabfd182ca16feda Reviewed-by: Alessandro Portale --- src/plugins/cmakeprojectmanager/configmodel.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/plugins/cmakeprojectmanager/configmodel.cpp b/src/plugins/cmakeprojectmanager/configmodel.cpp index 9a3f6c4e286..4933c158f85 100644 --- a/src/plugins/cmakeprojectmanager/configmodel.cpp +++ b/src/plugins/cmakeprojectmanager/configmodel.cpp @@ -288,11 +288,15 @@ void ConfigModel::setBatchEditConfiguration(const CMakeConfig &config) auto existing = std::find(m_configuration.begin(), m_configuration.end(), di); if (existing != m_configuration.end()) { existing->isUnset = c.isUnset; - if (!c.isUnset) { - existing->isUserChanged = true; + const QString newValue = QString::fromUtf8(c.value); + // Allow a different value when the user didn't change anything (don't mark the same value as new) + // But allow the same value (going back) when the user did a change + const bool canSetValue = (existing->value != newValue && !existing->isUserChanged) + || existing->isUserChanged; + if (!c.isUnset && canSetValue) { + existing->isUserChanged = existing->value != newValue; existing->setType(c.type); - existing->value = QString::fromUtf8(c.value); - existing->newValue = existing->value; + existing->newValue = newValue; } } else if (!c.isUnset) { InternalDataItem i(di);