From 6255ab496d51625320b5e50caf999f6d3c8c6489 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germ=C3=A1n=20Carrillo?= Date: Wed, 3 Apr 2024 21:06:44 +0200 Subject: [PATCH] [dxf] Remember settings for DadaDefinedBlocks in DXF Export (app) dialog --- src/app/qgsdxfexportdialog.cpp | 44 ++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-) diff --git a/src/app/qgsdxfexportdialog.cpp b/src/app/qgsdxfexportdialog.cpp index 4e84f2b377fe..577e8575fbf2 100644 --- a/src/app/qgsdxfexportdialog.cpp +++ b/src/app/qgsdxfexportdialog.cpp @@ -583,15 +583,35 @@ void QgsVectorLayerAndAttributeModel::loadLayersOutputAttribute( QgsLayerTreeNod QgsVectorLayer *vl = qobject_cast< QgsVectorLayer * >( QgsLayerTree::toLayer( child )->layer() ); if ( vl ) { + QModelIndex idx = node2index( child ); + const int attributeIndex = vl->fields().lookupField( vl->customProperty( QStringLiteral( "lastDxfOutputAttribute" ), -1 ).toString() ); if ( attributeIndex > -1 ) { mAttributeIdx[vl] = attributeIndex; - - QModelIndex idx = node2index( child ); - idx = index( idx.row(), 1, idx.parent() ); + idx = index( idx.row(), OUTPUT_LAYER_ATTRIBUTE_COL, idx.parent() ); emit dataChanged( idx, idx, QVector() << Qt::EditRole ); } + + if ( vl->geometryType() == Qgis::GeometryType::Point ) + { + const bool allowDataDefinedBlocks = vl->customProperty( QStringLiteral( "lastAllowDataDefinedBlocks" ), false ).toBool(); + + if ( allowDataDefinedBlocks ) // Since False is the default value + { + mCreateDDBlockInfo[vl] = allowDataDefinedBlocks; + idx = index( idx.row(), ALLOW_DD_SYMBOL_BLOCKS_COL, idx.parent() ); + emit dataChanged( idx, idx, QVector() << Qt::CheckStateRole ); + } + + const int maximumNumberOfBlocks = vl->customProperty( QStringLiteral( "lastMaximumNumberOfBlocks" ), -1 ).toInt(); + if ( maximumNumberOfBlocks > -1 ) + { + mDDBlocksMaxNumberOfClasses[vl] = maximumNumberOfBlocks; + idx = index( idx.row(), MAXIMUM_DD_SYMBOL_BLOCKS_COL, idx.parent() ); + emit dataChanged( idx, idx, QVector() << Qt::EditRole ); + } + } } } else if ( QgsLayerTree::isGroup( child ) ) @@ -612,7 +632,7 @@ void QgsVectorLayerAndAttributeModel::saveLayersOutputAttribute( QgsLayerTreeNod if ( vl ) { QModelIndex idx = node2index( child ); - const int attributeIndex = data( index( idx.row(), 1, idx.parent() ), Qt::EditRole ).toInt(); + const int attributeIndex = data( index( idx.row(), OUTPUT_LAYER_ATTRIBUTE_COL, idx.parent() ), Qt::EditRole ).toInt(); const QgsFields fields = vl->fields(); if ( attributeIndex > -1 && attributeIndex < fields.count() ) { @@ -622,6 +642,22 @@ void QgsVectorLayerAndAttributeModel::saveLayersOutputAttribute( QgsLayerTreeNod { vl->removeCustomProperty( QStringLiteral( "lastDxfOutputAttribute" ) ); } + + if ( vl->geometryType() == Qgis::GeometryType::Point ) + { + const bool allowDataDefinedBlocks = data( index( idx.row(), ALLOW_DD_SYMBOL_BLOCKS_COL, idx.parent() ), Qt::CheckStateRole ).toBool(); + vl->setCustomProperty( QStringLiteral( "lastAllowDataDefinedBlocks" ), allowDataDefinedBlocks ); + + const int maximumNumberOfBlocks = data( index( idx.row(), MAXIMUM_DD_SYMBOL_BLOCKS_COL, idx.parent() ), Qt::DisplayRole ).toInt(); + if ( maximumNumberOfBlocks > -1 ) + { + vl->setCustomProperty( QStringLiteral( "lastMaximumNumberOfBlocks" ), maximumNumberOfBlocks ); + } + else + { + vl->removeCustomProperty( QStringLiteral( "lastMaximumNumberOfBlocks" ) ); + } + } } } else if ( QgsLayerTree::isGroup( child ) )