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 <alessandro.portale@qt.io>
This commit is contained in:
Cristian Adam
2022-02-01 10:25:42 +01:00
committed by Alessandro Portale
parent 577ad6fa3e
commit 201f91b867

View File

@@ -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);