Fix Reuse last entered value tool and QGIS's reuseLastValue support
Support for QGIS's native reuseLastValue option and refactoring of RememberAttributesController to store attribute values persistently in QSettings instead of in-memory, making them survive reinstantiation on each new form open. This adds project-specific storage with ActiveProject integration. On project deletion, stored settings from RememberAttributesController are cleared.
Fix #3784
Pull Request Test Coverage Report for Build 16373656904
Details
- 0 of 0 changed or added relevant lines in 0 files are covered.
- 188 unchanged lines in 5 files lost coverage.
- Overall coverage increased (+0.1%) to 59.69%
| Files with Coverage Reduction | New Missed Lines | % |
|---|---|---|
| input/core/merginapi.cpp | 7 | 75.31% |
| input/app/attributes/rememberattributescontroller.cpp | 13 | 80.3% |
| input/core/localprojectsmanager.cpp | 17 | 76.34% |
| input/core/coreutils.cpp | 19 | 86.29% |
| input/app/attributes/attributecontroller.cpp | 132 | 76.62% |
| <!-- | Total: | 188 |
| Totals | |
|---|---|
| Change from base Build 16364671362: | 0.1% |
| Covered Lines: | 8267 |
| Relevant Lines: | 13850 |
💛 - Coveralls
Testing looks good to me. The only scenario to confirm, that is set this way now: if we have a project with QGIS's reuseLastValue set for a field and our tool on in Settings, then open the form, we encounter the checkbox for that field unchecked, although this field with QGIS's reuseLastValue set works just fine when our tool is off. If this behavior is intentional, then everything is okay from my side.
Hi @uclaros - is this one ready for review please?
Should be ready for review.
The remember last value feature can be enabled in QGIS and in Mergin Maps independently:
- QGIS off, MM off : Don't show checkboxes, don't store/recall values
- QGIS on, MM off: Don't show checkboxes, store/recall values based on QGIS setting
- QGIS on, MM on: Show checkboxes, initial check state based on QGIS setting until overwritten, store/recall values of checked fields
- QGIS off, MM on: Show checkboxes, initially unchecked, store/recall values of checked fields
The idea is that we store last used values in QSettings per project, per layer, per field. The value stored for a field signifies the following states:
- No entry in QSettings: remember last value is disabled in both Mergin Maps and QGIS. We won't store nor recall values
- invalid QVariant(): remember last value is enabled in Mergin Maps, but checkbox is unchecked for this field. We won't store nor recall values
- valid value: checkbox for this field is checked or enabled in QGIS. This is the previously used value. We will recall this value on next feature and replace it with the new value
- empty QString(): checkbox for this field is checked or enabled in QGIS, but we don't have a last value yet (no feature saved yet, or empty value in last feature). We will store next value
This is the updated logic diagram. Relevant methods:
-
shouldRememberValue()is used to set the check state of the checkbox in the gui -
setShouldRememberValue()is called when checkbox is checked/unchecked -
rememberedValue()reads the previously used value. Returns true if value was stored -
storeFeature()is called when the feature is stored and potentially saves the last value to the settings
Tests should be extended to cover the QGIS on/off - MM on/off combos
Let's consider this as a starting point for the next development