Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable dd blocks by default and remove global setting #57036

Merged
merged 1 commit into from Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion python/PyQt6/core/auto_generated/dxf/qgsdxfexport.sip.in
Expand Up @@ -27,7 +27,7 @@ Exports QGIS layers to the DXF format.

struct DxfLayer
{
DxfLayer( QgsVectorLayer *vl, int layerOutputAttributeIndex = -1, bool buildDDBlocks = false, int ddBlocksMaxNumberOfClasses = -1 );
DxfLayer( QgsVectorLayer *vl, int layerOutputAttributeIndex = -1, bool buildDDBlocks = true, int ddBlocksMaxNumberOfClasses = -1 );

QgsVectorLayer *layer() const;
%Docstring
Expand Down
2 changes: 1 addition & 1 deletion python/core/auto_generated/dxf/qgsdxfexport.sip.in
Expand Up @@ -27,7 +27,7 @@ Exports QGIS layers to the DXF format.

struct DxfLayer
{
DxfLayer( QgsVectorLayer *vl, int layerOutputAttributeIndex = -1, bool buildDDBlocks = false, int ddBlocksMaxNumberOfClasses = -1 );
DxfLayer( QgsVectorLayer *vl, int layerOutputAttributeIndex = -1, bool buildDDBlocks = true, int ddBlocksMaxNumberOfClasses = -1 );

QgsVectorLayer *layer() const;
%Docstring
Expand Down
8 changes: 4 additions & 4 deletions src/app/qgsdxfexportdialog.cpp
Expand Up @@ -150,7 +150,7 @@ QgsVectorLayerAndAttributeModel::QgsVectorLayerAndAttributeModel( QgsLayerTree *
const QgsVectorLayer *vLayer = qobject_cast< const QgsVectorLayer *>( QgsProject::instance()->mapLayer( id ) );
if ( vLayer )
{
mCreateDDBlockInfo[vLayer] = QgsDxfExportDialog::settingsDxfEnableDDBlocks->value();
mCreateDDBlockInfo[vLayer] = true;
m-kuhn marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be really handy to have a constant that can be used across all DXF Export classes to access this default value.

Just saying because I'm preparing another PR (see my local PR in the meantime), where I actually need the default value to improve code readability and maintenance (namely here to have something like if ( allowDataDefinedBlocks != DEFAULT_DXF_DATA_DEFINED_BLOCKS)).

Without such constant, it would be too easy for someone to break something in the future regarding this default value.

I guess it could live in the dxfexport.h or in the qgis.cpp.

Would that make sense for you @mhugent?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, sounds good to have it in dxfexport.h

mDDBlocksMaxNumberOfClasses[vLayer] = -1;
}
}
Expand Down Expand Up @@ -287,7 +287,7 @@ QVariant QgsVectorLayerAndAttributeModel::data( const QModelIndex &idx, int role
return QVariant();
}

bool checked = mCreateDDBlockInfo.contains( vl ) ? mCreateDDBlockInfo[vl] : false;
bool checked = mCreateDDBlockInfo.contains( vl ) ? mCreateDDBlockInfo[vl] : true;
if ( role == Qt::CheckStateRole )
{
return checked ? Qt::Checked : Qt::Unchecked;
Expand Down Expand Up @@ -423,7 +423,7 @@ QList< QgsDxfExport::DxfLayer > QgsVectorLayerAndAttributeModel::layers() const
if ( !layerIdx.contains( vl->id() ) )
{
layerIdx.insert( vl->id(), layers.size() );
layers << QgsDxfExport::DxfLayer( vl, mAttributeIdx.value( vl, -1 ), mCreateDDBlockInfo.value( vl, false ), mDDBlocksMaxNumberOfClasses.value( vl, -1 ) );
layers << QgsDxfExport::DxfLayer( vl, mAttributeIdx.value( vl, -1 ), mCreateDDBlockInfo.value( vl, true ), mDDBlocksMaxNumberOfClasses.value( vl, -1 ) );
}
}
}
Expand All @@ -434,7 +434,7 @@ QList< QgsDxfExport::DxfLayer > QgsVectorLayerAndAttributeModel::layers() const
if ( !layerIdx.contains( vl->id() ) )
{
layerIdx.insert( vl->id(), layers.size() );
layers << QgsDxfExport::DxfLayer( vl, mAttributeIdx.value( vl, -1 ), mCreateDDBlockInfo.value( vl, false ), mDDBlocksMaxNumberOfClasses.value( vl, -1 ) );
layers << QgsDxfExport::DxfLayer( vl, mAttributeIdx.value( vl, -1 ), mCreateDDBlockInfo.value( vl, true ), mDDBlocksMaxNumberOfClasses.value( vl, -1 ) );
}
}
}
Expand Down
1 change: 0 additions & 1 deletion src/app/qgsdxfexportdialog.h
Expand Up @@ -103,7 +103,6 @@ class QgsDxfExportDialog : public QDialog, private Ui::QgsDxfExportDialogBase
Q_OBJECT
public:
static inline QgsSettingsTreeNode *sTreeAppDdxf = QgsSettingsTree::sTreeApp->createChildNode( QStringLiteral( "dxf" ) );
static const inline QgsSettingsEntryBool *settingsDxfEnableDDBlocks = new QgsSettingsEntryBool( QStringLiteral( "enable-datadefined-blocks" ), sTreeAppDdxf, false );
static const inline QgsSettingsEntryString *settingsDxfLastSettingsDir = new QgsSettingsEntryString( QStringLiteral( "last-settings-dir" ), sTreeAppDdxf, QDir::homePath() );

QgsDxfExportDialog( QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags() );
Expand Down
2 changes: 1 addition & 1 deletion src/core/dxf/qgsdxfexport.h
Expand Up @@ -73,7 +73,7 @@ class CORE_EXPORT QgsDxfExport : public QgsLabelSink
*/
struct CORE_EXPORT DxfLayer
{
DxfLayer( QgsVectorLayer *vl, int layerOutputAttributeIndex = -1, bool buildDDBlocks = false, int ddBlocksMaxNumberOfClasses = -1 )
DxfLayer( QgsVectorLayer *vl, int layerOutputAttributeIndex = -1, bool buildDDBlocks = true, int ddBlocksMaxNumberOfClasses = -1 )
: mLayer( vl )
, mLayerOutputAttributeIndex( layerOutputAttributeIndex )
, mBuildDDBlocks( buildDDBlocks )
Expand Down