Skip to content

Commit c996c61

Browse files
authored
Merge branch 'master' into dxf_label_layers_v3
2 parents 5c3a755 + 66b9b43 commit c996c61

14 files changed

+89
-582
lines changed

python/core/conversions.sip

+5-541
Large diffs are not rendered by default.

python/core/dxf/qgsdxfexport.sip.in

+19-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,24 @@ class QgsDxfExport
2020
#include "qgsdxfexport.h"
2121
%End
2222
public:
23+
24+
struct DxfLayer
25+
{
26+
DxfLayer( QgsVectorLayer *vl, int layerOutputAttributeIndex = -1 );
27+
28+
QgsVectorLayer *layer() const;
29+
%Docstring
30+
Return the layer
31+
%End
32+
33+
int layerOutputAttributeIndex() const;
34+
%Docstring
35+
Return the attribute index used to split into multiple layers.
36+
The attribute value is used for layer names.
37+
%End
38+
39+
};
40+
2341
enum SymbologyExport
2442
{
2543
NoSymbology,
@@ -64,7 +82,7 @@ Returns the export flags.
6482
.. seealso:: :py:func:`setFlags`
6583
%End
6684

67-
void addLayers( const QList< QPair<QgsVectorLayer *, int > > &layers );
85+
void addLayers( const QList< QgsDxfExport::DxfLayer > &layers );
6886
%Docstring
6987
Add layers to export
7088

python/plugins/processing/ProcessingPlugin.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -211,14 +211,15 @@ def initGui(self):
211211
self.menu.addAction(self.historyAction)
212212
self.toolbox.processingToolbar.addAction(self.historyAction)
213213

214-
self.resultsAction = self.resultsDock.toggleViewAction()
215-
self.resultsAction.setObjectName('resultsAction')
216-
self.resultsAction.setIcon(
217-
QgsApplication.getThemeIcon("/processingResult.svg"))
218-
self.resultsAction.setText(self.tr('&Results Viewer'))
214+
self.resultsAction = QAction(
215+
QgsApplication.getThemeIcon("/processingResult.svg"),
216+
self.tr('&Results Viewer'), self.iface.mainWindow())
217+
self.resultsAction.setCheckable(True)
219218
self.iface.registerMainWindowAction(self.resultsAction, 'Ctrl+Alt+R')
220219
self.menu.addAction(self.resultsAction)
221220
self.toolbox.processingToolbar.addAction(self.resultsAction)
221+
self.resultsDock.visibilityChanged.connect(self.resultsAction.setChecked)
222+
self.resultsAction.toggled.connect(self.resultsDock.setUserVisible)
222223

223224
self.optionsAction = QAction(
224225
QgsApplication.getThemeIcon("/mActionOptions.svg"),

python/plugins/processing/gui/DestinationSelectionPanel.py

+1
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ def setValue(self, value):
271271
self.saveToTemporary()
272272
else:
273273
self.leText.setText(value)
274+
self.use_temporary = False
274275

275276
def getValue(self):
276277
key = None

src/app/main.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -1357,15 +1357,15 @@ int main( int argc, char *argv[] )
13571357
dxfExport.setExtent( dxfExtent );
13581358

13591359
QStringList layerIds;
1360-
QList< QPair<QgsVectorLayer *, int > > layers;
1360+
QList< QgsDxfExport::DxfLayer > layers;
13611361
if ( !dxfMapTheme.isEmpty() )
13621362
{
13631363
Q_FOREACH ( QgsMapLayer *layer, QgsProject::instance()->mapThemeCollection()->mapThemeVisibleLayers( dxfMapTheme ) )
13641364
{
13651365
QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( layer );
13661366
if ( !vl )
13671367
continue;
1368-
layers << qMakePair<QgsVectorLayer *, int>( vl, -1 );
1368+
layers << QgsDxfExport::DxfLayer( vl );
13691369
layerIds << vl->id();
13701370
}
13711371
}
@@ -1376,7 +1376,7 @@ int main( int argc, char *argv[] )
13761376
QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( ml );
13771377
if ( !vl )
13781378
continue;
1379-
layers << qMakePair<QgsVectorLayer *, int>( vl, -1 );
1379+
layers << QgsDxfExport::DxfLayer( vl );
13801380
layerIds << vl->id();
13811381
}
13821382
}

src/app/qgsdxfexportdialog.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -276,9 +276,9 @@ bool QgsVectorLayerAndAttributeModel::setData( const QModelIndex &index, const Q
276276
}
277277

278278

279-
QList< QPair<QgsVectorLayer *, int> > QgsVectorLayerAndAttributeModel::layers() const
279+
QList< QgsDxfExport::DxfLayer > QgsVectorLayerAndAttributeModel::layers() const
280280
{
281-
QList< QPair<QgsVectorLayer *, int> > layers;
281+
QList< QgsDxfExport::DxfLayer > layers;
282282
QHash< QString, int > layerIdx;
283283

284284
Q_FOREACH ( const QModelIndex &idx, mCheckedLeafs )
@@ -293,7 +293,7 @@ QList< QPair<QgsVectorLayer *, int> > QgsVectorLayerAndAttributeModel::layers()
293293
if ( !layerIdx.contains( vl->id() ) )
294294
{
295295
layerIdx.insert( vl->id(), layers.size() );
296-
layers << qMakePair<QgsVectorLayer *, int>( vl, mAttributeIdx.value( vl, -1 ) );
296+
layers << QgsDxfExport::DxfLayer( vl, mAttributeIdx.value( vl, -1 ) );
297297
}
298298
}
299299
}
@@ -304,12 +304,12 @@ QList< QPair<QgsVectorLayer *, int> > QgsVectorLayerAndAttributeModel::layers()
304304
if ( !layerIdx.contains( vl->id() ) )
305305
{
306306
layerIdx.insert( vl->id(), layers.size() );
307-
layers << qMakePair<QgsVectorLayer *, int>( vl, mAttributeIdx.value( vl, -1 ) );
307+
layers << QgsDxfExport::DxfLayer( vl, mAttributeIdx.value( vl, -1 ) );
308308
}
309309
}
310310
}
311311

312-
QList< QPair<QgsVectorLayer *, int> > layersInROrder;
312+
QList< QgsDxfExport::DxfLayer > layersInROrder;
313313

314314
QList<QgsMapLayer *> layerOrder = mRootNode->layerOrder();
315315

@@ -549,7 +549,7 @@ void QgsDxfExportDialog::deSelectAll()
549549
}
550550

551551

552-
QList< QPair<QgsVectorLayer *, int> > QgsDxfExportDialog::layers() const
552+
QList< QgsDxfExport::DxfLayer > QgsDxfExportDialog::layers() const
553553
{
554554
const QgsVectorLayerAndAttributeModel *model = dynamic_cast< const QgsVectorLayerAndAttributeModel *>( mTreeView->model() );
555555
Q_ASSERT( model );

src/app/qgsdxfexportdialog.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class QgsVectorLayerAndAttributeModel : public QgsLayerTreeModel
5353
Qt::ItemFlags flags( const QModelIndex &index ) const override;
5454
bool setData( const QModelIndex &index, const QVariant &value, int role = Qt::EditRole ) override;
5555

56-
QList< QPair<QgsVectorLayer *, int> > layers() const;
56+
QList< QgsDxfExport::DxfLayer > layers() const;
5757

5858
QgsVectorLayer *vectorLayer( const QModelIndex &index ) const;
5959
int attributeIndex( const QgsVectorLayer *vl ) const;
@@ -79,7 +79,7 @@ class QgsDxfExportDialog : public QDialog, private Ui::QgsDxfExportDialogBase
7979
QgsDxfExportDialog( QWidget *parent = nullptr, Qt::WindowFlags f = nullptr );
8080
~QgsDxfExportDialog() override;
8181

82-
QList< QPair<QgsVectorLayer *, int> > layers() const;
82+
QList< QgsDxfExport::DxfLayer > layers() const;
8383

8484
double symbologyScale() const;
8585
QgsDxfExport::SymbologyExport symbologyMode() const;

src/core/dxf/qgsdxfexport.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -398,18 +398,18 @@ QgsDxfExport::Flags QgsDxfExport::flags() const
398398
return mFlags;
399399
}
400400

401-
void QgsDxfExport::addLayers( const QList< QPair< QgsVectorLayer *, int > > &layers )
401+
void QgsDxfExport::addLayers( const QList<DxfLayer> &layers )
402402
{
403403
QList<QgsMapLayer *> layerList;
404404

405405
mLayerNameAttribute.clear();
406406

407-
QList< QPair< QgsVectorLayer *, int > >::const_iterator layerIt = layers.constBegin();
407+
QList< DxfLayer >::const_iterator layerIt = layers.constBegin();
408408
for ( ; layerIt != layers.constEnd(); ++layerIt )
409409
{
410-
layerList << layerIt->first;
411-
if ( layerIt->second >= 0 )
412-
mLayerNameAttribute.insert( layerIt->first->id(), layerIt->second );
410+
layerList << layerIt->layer();
411+
if ( layerIt->layerOutputAttributeIndex() >= 0 )
412+
mLayerNameAttribute.insert( layerIt->layer()->id(), layerIt->layerOutputAttributeIndex() );
413413
}
414414

415415
mMapSettings.setLayers( layerList );

src/core/dxf/qgsdxfexport.h

+27-1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,32 @@ namespace pal SIP_SKIP
5151
class CORE_EXPORT QgsDxfExport
5252
{
5353
public:
54+
55+
/**
56+
* Layers and optional attribute index to split
57+
* into multiple layers using attribute value as layer name.
58+
*/
59+
struct DxfLayer
60+
{
61+
DxfLayer( QgsVectorLayer *vl, int layerOutputAttributeIndex = -1 )
62+
: mLayer( vl )
63+
, mLayerOutputAttributeIndex( layerOutputAttributeIndex )
64+
{}
65+
66+
//! Return the layer
67+
QgsVectorLayer *layer() const {return mLayer;}
68+
69+
/**
70+
* Return the attribute index used to split into multiple layers.
71+
* The attribute value is used for layer names.
72+
*/
73+
int layerOutputAttributeIndex() const {return mLayerOutputAttributeIndex;}
74+
75+
private:
76+
QgsVectorLayer *mLayer = nullptr;
77+
int mLayerOutputAttributeIndex = -1;
78+
};
79+
5480
enum SymbologyExport
5581
{
5682
NoSymbology = 0, //!< Export only data
@@ -97,7 +123,7 @@ class CORE_EXPORT QgsDxfExport
97123
* \param layers list of layers and corresponding attribute indexes that determine the layer name (-1 for original layer name or title)
98124
* \see setLayerTitleAsName
99125
*/
100-
void addLayers( const QList< QPair<QgsVectorLayer *, int > > &layers );
126+
void addLayers( const QList< QgsDxfExport::DxfLayer > &layers );
101127

102128
/**
103129
* Export to a dxf file in the given encoding

src/core/qgsvectordataprovider.h

-3
Original file line numberDiff line numberDiff line change
@@ -595,9 +595,6 @@ class CORE_EXPORT QgsVectorDataProvider : public QgsDataProvider, public QgsFeat
595595
//! The names of the providers native types
596596
QList< NativeType > mNativeTypes;
597597

598-
//! Old notation *
599-
QMap<QString, QVariant::Type> mOldTypeList;
600-
601598
//! List of errors
602599
mutable QStringList mErrors;
603600

src/gui/qgscollapsiblegroupbox.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,17 @@ void QgsCollapsibleGroupBoxBasic::init()
5858
mExpandIcon = QgsApplication::getThemeIcon( QStringLiteral( "/mIconExpand.svg" ) );
5959

6060
// collapse button
61-
mCollapseButton = qgis::make_unique<QgsGroupBoxCollapseButton>( nullptr );
61+
mCollapseButton = new QgsGroupBoxCollapseButton( this );
6262
mCollapseButton->setObjectName( QStringLiteral( "collapseButton" ) );
6363
mCollapseButton->setAutoRaise( true );
6464
mCollapseButton->setFixedSize( 16, 16 );
6565
// TODO set size (as well as margins) depending on theme, in updateStyle()
6666
mCollapseButton->setIconSize( QSize( 12, 12 ) );
6767
mCollapseButton->setIcon( mCollapseIcon );
68-
setFocusProxy( mCollapseButton.get() );
68+
setFocusProxy( mCollapseButton );
6969
setFocusPolicy( Qt::StrongFocus );
7070

71-
connect( mCollapseButton.get(), &QAbstractButton::clicked, this, &QgsCollapsibleGroupBoxBasic::toggleCollapsed );
71+
connect( mCollapseButton, &QAbstractButton::clicked, this, &QgsCollapsibleGroupBoxBasic::toggleCollapsed );
7272
connect( this, &QGroupBox::toggled, this, &QgsCollapsibleGroupBoxBasic::checkToggled );
7373
connect( this, &QGroupBox::clicked, this, &QgsCollapsibleGroupBoxBasic::checkClicked );
7474
}
@@ -221,7 +221,7 @@ void QgsCollapsibleGroupBoxBasic::toggleCollapsed()
221221
{
222222
// verify if sender is this group box's collapse button
223223
QgsGroupBoxCollapseButton *collBtn = qobject_cast<QgsGroupBoxCollapseButton *>( QObject::sender() );
224-
bool senderCollBtn = ( collBtn && collBtn == mCollapseButton.get() );
224+
bool senderCollBtn = ( collBtn && collBtn == mCollapseButton );
225225

226226
mAltDown = ( mAltDown || mCollapseButton->altDown() );
227227
mShiftDown = ( mShiftDown || mCollapseButton->shiftDown() );
@@ -426,7 +426,7 @@ void QgsCollapsibleGroupBoxBasic::setCollapsed( bool collapse )
426426
mParentScrollArea->ensureWidgetVisible( this );
427427
//and then make sure the top of the widget is visible - otherwise tall group boxes
428428
//scroll to their centres, which is disorienting for users
429-
mParentScrollArea->ensureWidgetVisible( mCollapseButton.get(), 0, 5 );
429+
mParentScrollArea->ensureWidgetVisible( mCollapseButton, 0, 5 );
430430
mParentScrollArea->setUpdatesEnabled( true );
431431
}
432432
// emit signal for connections using collapsed state
@@ -444,7 +444,7 @@ void QgsCollapsibleGroupBoxBasic::collapseExpandFixes()
444444
Q_FOREACH ( QObject *child, children() )
445445
{
446446
QWidget *w = qobject_cast<QWidget *>( child );
447-
if ( w && w != mCollapseButton.get() )
447+
if ( w && w != mCollapseButton )
448448
{
449449
w->setProperty( hideKey, true );
450450
w->hide();
@@ -456,7 +456,7 @@ void QgsCollapsibleGroupBoxBasic::collapseExpandFixes()
456456
Q_FOREACH ( QObject *child, children() )
457457
{
458458
QWidget *w = qobject_cast<QWidget *>( child );
459-
if ( w && w != mCollapseButton.get() )
459+
if ( w && w != mCollapseButton )
460460
{
461461
if ( w->property( hideKey ).toBool() )
462462
w->show();

src/gui/qgscollapsiblegroupbox.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ class GUI_EXPORT QgsCollapsibleGroupBoxBasic : public QGroupBox
157157
bool mScrollOnExpand;
158158
bool mShown;
159159
QScrollArea *mParentScrollArea = nullptr;
160-
std::unique_ptr<QgsGroupBoxCollapseButton> mCollapseButton;
160+
QgsGroupBoxCollapseButton *mCollapseButton = nullptr;
161161
QWidget *mSyncParent = nullptr;
162162
QString mSyncGroup;
163163
bool mAltDown;

src/server/services/wms/qgswmsrenderer.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,7 @@ namespace QgsWms
767767
QStringList wfsLayerIds = QgsServerProjectUtils::wfsLayerIds( *mProject );
768768

769769
// get dxf layers
770-
QList< QPair<QgsVectorLayer *, int > > dxfLayers;
770+
QList< QgsDxfExport::DxfLayer > dxfLayers;
771771
int layerIdx = -1;
772772
Q_FOREACH ( QgsMapLayer *layer, layers )
773773
{
@@ -801,7 +801,7 @@ namespace QgsWms
801801
layerAttribute = vlayer->fields().indexFromName( layerAttributes.at( layerIdx ) );
802802
}
803803

804-
dxfLayers.append( qMakePair( vlayer, layerAttribute ) );
804+
dxfLayers.append( QgsDxfExport::DxfLayer( vlayer, layerAttribute ) );
805805
}
806806

807807
// add layers to dxf

tests/src/core/testqgsdxfexport.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ void TestQgsDxfExport::cleanup()
102102
void TestQgsDxfExport::testPoints()
103103
{
104104
QgsDxfExport d;
105-
d.addLayers( QList< QPair< QgsVectorLayer *, int > >() << qMakePair( mPointLayer, -1 ) );
105+
d.addLayers( QList< QgsDxfExport::DxfLayer >() << QgsDxfExport::DxfLayer( mPointLayer ) );
106106

107107
QgsMapSettings mapSettings;
108108
QSize size( 640, 480 );
@@ -130,7 +130,7 @@ void TestQgsDxfExport::testPoints()
130130
void TestQgsDxfExport::testLines()
131131
{
132132
QgsDxfExport d;
133-
d.addLayers( QList< QPair< QgsVectorLayer *, int > >() << qMakePair( mLineLayer, -1 ) );
133+
d.addLayers( QList< QgsDxfExport::DxfLayer >() << QgsDxfExport::DxfLayer( mLineLayer ) );
134134

135135
QgsMapSettings mapSettings;
136136
QSize size( 640, 480 );
@@ -158,7 +158,7 @@ void TestQgsDxfExport::testLines()
158158
void TestQgsDxfExport::testPolygons()
159159
{
160160
QgsDxfExport d;
161-
d.addLayers( QList< QPair< QgsVectorLayer *, int > >() << qMakePair( mPolygonLayer, -1 ) );
161+
d.addLayers( QList< QgsDxfExport::DxfLayer >() << QgsDxfExport::DxfLayer( mPolygonLayer ) );
162162

163163
QgsMapSettings mapSettings;
164164
QSize size( 640, 480 );
@@ -207,7 +207,7 @@ void TestQgsDxfExport::testText()
207207
mPointLayer->setLabelsEnabled( true );
208208

209209
QgsDxfExport d;
210-
d.addLayers( QList< QPair< QgsVectorLayer *, int > >() << qMakePair( mPointLayer, -1 ) );
210+
d.addLayers( QList< QgsDxfExport::DxfLayer >() << QgsDxfExport::DxfLayer( mPointLayer ) );
211211

212212
QgsMapSettings mapSettings;
213213
QSize size( 640, 480 );
@@ -274,7 +274,7 @@ bool TestQgsDxfExport::testMtext( QgsVectorLayer *vlayer, const QString &tempFil
274274
vlayer->setLabelsEnabled( true );
275275

276276
QgsDxfExport d;
277-
d.addLayers( QList< QPair< QgsVectorLayer *, int > >() << qMakePair( vlayer, -1 ) );
277+
d.addLayers( QList< QgsDxfExport::DxfLayer >() << QgsDxfExport::DxfLayer( vlayer ) );
278278

279279
QgsMapSettings mapSettings;
280280
QSize size( 640, 480 );

0 commit comments

Comments
 (0)