Skip to content

Commit a3b8432

Browse files
committed
For projects saved with QGIS < 4.0, restore old always-on remember pin behavior
1 parent cb103fe commit a3b8432

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

src/core/attributeformmodelbase.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ void AttributeFormModelBase::buildForm( QgsAttributeEditorContainer *container,
554554
item->setData( !mLayer->editFormConfig().readOnly( fieldIndex ) && setup.type() != QStringLiteral( "Binary" ), AttributeFormModel::AttributeEditable );
555555
item->setData( setup.type(), AttributeFormModel::EditorWidget );
556556
item->setData( setup.config(), AttributeFormModel::EditorWidgetConfig );
557-
const bool canRemember = mLayer->editFormConfig().reuseLastValuePolicy( fieldIndex ) != Qgis::AttributeFormReuseLastValuePolicy::NotAllowed;
557+
const bool canRemember = mLayer->editFormConfig().reuseLastValuePolicy( fieldIndex ) != Qgis::AttributeFormReuseLastValuePolicy::NotAllowed || QgsProject::instance()->lastSaveVersion().majorVersion() < 4;
558558
item->setData( canRemember, AttributeFormModel::CanRememberValue );
559559
if ( canRemember )
560560
{

src/core/featuremodel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ bool FeatureModel::setData( const QModelIndex &index, const QVariant &value, int
466466
( *sRememberings )[mLayer].rememberedAttributes[index.row()] = value.toBool();
467467

468468
QgsEditFormConfig config = mLayer->editFormConfig();
469-
if ( config.reuseLastValuePolicy( index.row() ) == Qgis::AttributeFormReuseLastValuePolicy::NotAllowed )
469+
if ( config.reuseLastValuePolicy( index.row() ) == Qgis::AttributeFormReuseLastValuePolicy::NotAllowed && mProject->lastSaveVersion().majorVersion() >= 4 )
470470
{
471471
return false;
472472
}

src/core/projectinfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ void ProjectInfo::restoreSettings( QString &projectFilePath, QgsProject *project
569569
const QStringList fieldNames = rememberedFields.keys();
570570
for ( const QString &fieldName : fieldNames )
571571
{
572-
if ( config.reuseLastValuePolicy( vlayer->fields().indexFromName( fieldName ) ) != Qgis::AttributeFormReuseLastValuePolicy::NotAllowed )
572+
if ( config.reuseLastValuePolicy( vlayer->fields().indexFromName( fieldName ) ) != Qgis::AttributeFormReuseLastValuePolicy::NotAllowed || project->lastSaveVersion().majorVersion() < 4 )
573573
{
574574
config.setReuseLastValuePolicy( vlayer->fields().indexFromName( fieldName ), rememberedFields[fieldName].toBool() ? Qgis::AttributeFormReuseLastValuePolicy::AllowedDefaultOn : Qgis::AttributeFormReuseLastValuePolicy::AllowedDefaultOff );
575575
}

0 commit comments

Comments
 (0)