Skip to content

Commit 14de6e6

Browse files
committed
Export layers to dxf in drawing order
1 parent bcad16d commit 14de6e6

File tree

4 files changed

+81
-87
lines changed

4 files changed

+81
-87
lines changed

src/app/qgisapp.cpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -3802,7 +3802,13 @@ void QgisApp::fileSaveAs()
38023802

38033803
void QgisApp::dxfExport()
38043804
{
3805-
QgsDxfExportDialog d( QgsMapLayerRegistry::instance()->mapLayers().keys() );
3805+
QgsLegend* mapLegend = legend();
3806+
if ( !mapLegend )
3807+
{
3808+
return;
3809+
}
3810+
3811+
QgsDxfExportDialog d( mapLegend->layers() );
38063812
if ( d.exec() == QDialog::Accepted )
38073813
{
38083814
QgsDxfExport dxfExport;

src/app/qgsdxfexportdialog.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,22 @@
66
#include <QPushButton>
77
#include <QSettings>
88

9-
QgsDxfExportDialog::QgsDxfExportDialog( const QList<QString>& layerKeys, QWidget* parent, Qt::WindowFlags f ): QDialog( parent, f )
9+
QgsDxfExportDialog::QgsDxfExportDialog( const QList<QgsMapLayer*>& layerKeys, QWidget* parent, Qt::WindowFlags f ): QDialog( parent, f )
1010
{
1111
setupUi( this );
1212
connect( mFileLineEdit, SIGNAL( textChanged( const QString& ) ), this, SLOT( setOkEnabled() ) );
1313
connect( this, SIGNAL( accepted() ), this, SLOT( saveSettings() ) );
1414

15-
QList<QString>::const_iterator layerIt = layerKeys.constBegin();
15+
QList<QgsMapLayer*>::const_iterator layerIt = layerKeys.constBegin();
1616
for ( ; layerIt != layerKeys.constEnd(); ++layerIt )
1717
{
18-
QgsMapLayer* layer = QgsMapLayerRegistry::instance()->mapLayer( *layerIt );
18+
QgsMapLayer* layer = *layerIt;
1919
if ( layer )
2020
{
2121
if ( layer->type() == QgsMapLayer::VectorLayer )
2222
{
2323
QListWidgetItem* layerItem = new QListWidgetItem( layer->name() );
24-
layerItem->setData( Qt::UserRole, *layerIt );
24+
layerItem->setData( Qt::UserRole, layer->id() );
2525
layerItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsUserCheckable );
2626
layerItem->setCheckState( Qt::Checked );
2727
mLayersListWidget->addItem( layerItem );
@@ -52,7 +52,7 @@ QList<QString> QgsDxfExportDialog::layers() const
5252
QListWidgetItem* currentItem = mLayersListWidget->item( i );
5353
if ( currentItem->checkState() == Qt::Checked )
5454
{
55-
layerKeyList.append( currentItem->data( Qt::UserRole ).toString() );
55+
layerKeyList.prepend( currentItem->data( Qt::UserRole ).toString() );
5656
}
5757
}
5858
return layerKeyList;

src/app/qgsdxfexportdialog.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class QgsDxfExportDialog: public QDialog, private Ui::QgsDxfExportDialogBase
88
{
99
Q_OBJECT
1010
public:
11-
QgsDxfExportDialog( const QList<QString>& layerKeys, QWidget * parent = 0, Qt::WindowFlags f = 0 );
11+
QgsDxfExportDialog( const QList<QgsMapLayer*>& layerKeys, QWidget * parent = 0, Qt::WindowFlags f = 0 );
1212
~QgsDxfExportDialog();
1313

1414
QList<QString> layers() const;

src/ui/qgsdxfexportdialogbase.ui

+68-80
Original file line numberDiff line numberDiff line change
@@ -6,97 +6,85 @@
66
<rect>
77
<x>0</x>
88
<y>0</y>
9-
<width>373</width>
10-
<height>288</height>
9+
<width>377</width>
10+
<height>292</height>
1111
</rect>
1212
</property>
1313
<property name="windowTitle">
1414
<string>DXF export</string>
1515
</property>
16-
<widget class="QDialogButtonBox" name="buttonBox">
17-
<property name="geometry">
18-
<rect>
19-
<x>20</x>
20-
<y>260</y>
21-
<width>341</width>
22-
<height>32</height>
23-
</rect>
24-
</property>
25-
<property name="orientation">
26-
<enum>Qt::Horizontal</enum>
27-
</property>
28-
<property name="standardButtons">
29-
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
30-
</property>
31-
</widget>
32-
<widget class="QWidget" name="layoutWidget">
33-
<property name="geometry">
34-
<rect>
35-
<x>10</x>
36-
<y>10</y>
37-
<width>361</width>
38-
<height>247</height>
39-
</rect>
40-
</property>
41-
<layout class="QGridLayout" name="gridLayout">
42-
<item row="0" column="1">
43-
<widget class="QLineEdit" name="mFileLineEdit"/>
44-
</item>
45-
<item row="1" column="0">
46-
<widget class="QLabel" name="mSymbologyModeLabel">
47-
<property name="text">
48-
<string>Symbology mode</string>
49-
</property>
50-
</widget>
51-
</item>
52-
<item row="2" column="0">
53-
<widget class="QLabel" name="mSymbologyScaleLabel">
54-
<property name="text">
55-
<string>Symbology scale</string>
56-
</property>
57-
</widget>
58-
</item>
59-
<item row="0" column="0">
60-
<widget class="QLabel" name="mSaveAsLabel">
61-
<property name="text">
62-
<string>Save as</string>
63-
</property>
64-
</widget>
65-
</item>
66-
<item row="0" column="2">
67-
<widget class="QToolButton" name="mFileSelectionButton">
68-
<property name="text">
69-
<string>...</string>
70-
</property>
71-
</widget>
72-
</item>
73-
<item row="1" column="1" colspan="2">
74-
<widget class="QComboBox" name="mSymbologyModeComboBox">
75-
<item>
16+
<layout class="QGridLayout" name="gridLayout_2">
17+
<item row="0" column="0">
18+
<layout class="QGridLayout" name="gridLayout">
19+
<item row="0" column="1">
20+
<widget class="QLineEdit" name="mFileLineEdit"/>
21+
</item>
22+
<item row="1" column="0">
23+
<widget class="QLabel" name="mSymbologyModeLabel">
24+
<property name="text">
25+
<string>Symbology mode</string>
26+
</property>
27+
</widget>
28+
</item>
29+
<item row="2" column="0">
30+
<widget class="QLabel" name="mSymbologyScaleLabel">
7631
<property name="text">
77-
<string>No symbology</string>
32+
<string>Symbology scale</string>
7833
</property>
79-
</item>
80-
<item>
34+
</widget>
35+
</item>
36+
<item row="0" column="0">
37+
<widget class="QLabel" name="mSaveAsLabel">
8138
<property name="text">
82-
<string>Feature symbology</string>
39+
<string>Save as</string>
8340
</property>
84-
</item>
85-
<item>
41+
</widget>
42+
</item>
43+
<item row="0" column="2">
44+
<widget class="QToolButton" name="mFileSelectionButton">
8645
<property name="text">
87-
<string>Symbol layer symbology</string>
46+
<string>...</string>
8847
</property>
89-
</item>
90-
</widget>
91-
</item>
92-
<item row="2" column="1" colspan="2">
93-
<widget class="QLineEdit" name="mSymbologyScaleLineEdit"/>
94-
</item>
95-
<item row="3" column="0" colspan="3">
96-
<widget class="QListWidget" name="mLayersListWidget"/>
97-
</item>
98-
</layout>
99-
</widget>
48+
</widget>
49+
</item>
50+
<item row="1" column="1" colspan="2">
51+
<widget class="QComboBox" name="mSymbologyModeComboBox">
52+
<item>
53+
<property name="text">
54+
<string>No symbology</string>
55+
</property>
56+
</item>
57+
<item>
58+
<property name="text">
59+
<string>Feature symbology</string>
60+
</property>
61+
</item>
62+
<item>
63+
<property name="text">
64+
<string>Symbol layer symbology</string>
65+
</property>
66+
</item>
67+
</widget>
68+
</item>
69+
<item row="2" column="1" colspan="2">
70+
<widget class="QLineEdit" name="mSymbologyScaleLineEdit"/>
71+
</item>
72+
<item row="3" column="0" colspan="3">
73+
<widget class="QListWidget" name="mLayersListWidget"/>
74+
</item>
75+
</layout>
76+
</item>
77+
<item row="1" column="0">
78+
<widget class="QDialogButtonBox" name="buttonBox">
79+
<property name="orientation">
80+
<enum>Qt::Horizontal</enum>
81+
</property>
82+
<property name="standardButtons">
83+
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
84+
</property>
85+
</widget>
86+
</item>
87+
</layout>
10088
</widget>
10189
<resources/>
10290
<connections>

0 commit comments

Comments
 (0)