Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Export layers to dxf in drawing order
  • Loading branch information
mhugent committed Nov 29, 2013
1 parent bcad16d commit 14de6e6
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 87 deletions.
8 changes: 7 additions & 1 deletion src/app/qgisapp.cpp
Expand Up @@ -3802,7 +3802,13 @@ void QgisApp::fileSaveAs()

void QgisApp::dxfExport()
{
QgsDxfExportDialog d( QgsMapLayerRegistry::instance()->mapLayers().keys() );
QgsLegend* mapLegend = legend();
if ( !mapLegend )
{
return;
}

QgsDxfExportDialog d( mapLegend->layers() );
if ( d.exec() == QDialog::Accepted )
{
QgsDxfExport dxfExport;
Expand Down
10 changes: 5 additions & 5 deletions src/app/qgsdxfexportdialog.cpp
Expand Up @@ -6,22 +6,22 @@
#include <QPushButton>
#include <QSettings>

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

QList<QString>::const_iterator layerIt = layerKeys.constBegin();
QList<QgsMapLayer*>::const_iterator layerIt = layerKeys.constBegin();
for ( ; layerIt != layerKeys.constEnd(); ++layerIt )
{
QgsMapLayer* layer = QgsMapLayerRegistry::instance()->mapLayer( *layerIt );
QgsMapLayer* layer = *layerIt;
if ( layer )
{
if ( layer->type() == QgsMapLayer::VectorLayer )
{
QListWidgetItem* layerItem = new QListWidgetItem( layer->name() );
layerItem->setData( Qt::UserRole, *layerIt );
layerItem->setData( Qt::UserRole, layer->id() );
layerItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsUserCheckable );
layerItem->setCheckState( Qt::Checked );
mLayersListWidget->addItem( layerItem );
Expand Down Expand Up @@ -52,7 +52,7 @@ QList<QString> QgsDxfExportDialog::layers() const
QListWidgetItem* currentItem = mLayersListWidget->item( i );
if ( currentItem->checkState() == Qt::Checked )
{
layerKeyList.append( currentItem->data( Qt::UserRole ).toString() );
layerKeyList.prepend( currentItem->data( Qt::UserRole ).toString() );
}
}
return layerKeyList;
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsdxfexportdialog.h
Expand Up @@ -8,7 +8,7 @@ class QgsDxfExportDialog: public QDialog, private Ui::QgsDxfExportDialogBase
{
Q_OBJECT
public:
QgsDxfExportDialog( const QList<QString>& layerKeys, QWidget * parent = 0, Qt::WindowFlags f = 0 );
QgsDxfExportDialog( const QList<QgsMapLayer*>& layerKeys, QWidget * parent = 0, Qt::WindowFlags f = 0 );
~QgsDxfExportDialog();

QList<QString> layers() const;
Expand Down
148 changes: 68 additions & 80 deletions src/ui/qgsdxfexportdialogbase.ui
Expand Up @@ -6,97 +6,85 @@
<rect>
<x>0</x>
<y>0</y>
<width>373</width>
<height>288</height>
<width>377</width>
<height>292</height>
</rect>
</property>
<property name="windowTitle">
<string>DXF export</string>
</property>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="geometry">
<rect>
<x>20</x>
<y>260</y>
<width>341</width>
<height>32</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>361</width>
<height>247</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="1">
<widget class="QLineEdit" name="mFileLineEdit"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="mSymbologyModeLabel">
<property name="text">
<string>Symbology mode</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="mSymbologyScaleLabel">
<property name="text">
<string>Symbology scale</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="mSaveAsLabel">
<property name="text">
<string>Save as</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QToolButton" name="mFileSelectionButton">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="1" column="1" colspan="2">
<widget class="QComboBox" name="mSymbologyModeComboBox">
<item>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="1">
<widget class="QLineEdit" name="mFileLineEdit"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="mSymbologyModeLabel">
<property name="text">
<string>Symbology mode</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="mSymbologyScaleLabel">
<property name="text">
<string>No symbology</string>
<string>Symbology scale</string>
</property>
</item>
<item>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="mSaveAsLabel">
<property name="text">
<string>Feature symbology</string>
<string>Save as</string>
</property>
</item>
<item>
</widget>
</item>
<item row="0" column="2">
<widget class="QToolButton" name="mFileSelectionButton">
<property name="text">
<string>Symbol layer symbology</string>
<string>...</string>
</property>
</item>
</widget>
</item>
<item row="2" column="1" colspan="2">
<widget class="QLineEdit" name="mSymbologyScaleLineEdit"/>
</item>
<item row="3" column="0" colspan="3">
<widget class="QListWidget" name="mLayersListWidget"/>
</item>
</layout>
</widget>
</widget>
</item>
<item row="1" column="1" colspan="2">
<widget class="QComboBox" name="mSymbologyModeComboBox">
<item>
<property name="text">
<string>No symbology</string>
</property>
</item>
<item>
<property name="text">
<string>Feature symbology</string>
</property>
</item>
<item>
<property name="text">
<string>Symbol layer symbology</string>
</property>
</item>
</widget>
</item>
<item row="2" column="1" colspan="2">
<widget class="QLineEdit" name="mSymbologyScaleLineEdit"/>
</item>
<item row="3" column="0" colspan="3">
<widget class="QListWidget" name="mLayersListWidget"/>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
Expand Down

0 comments on commit 14de6e6

Please sign in to comment.