Skip to content
Permalink
Browse files

Merge branch 'master' into dxf_label_layers_v3

  • Loading branch information
mhugent committed Feb 13, 2018
2 parents 5c3a755 + 66b9b43 commit c996c617898985c266a5ef58e883cc31aa5aee0f

Large diffs are not rendered by default.

@@ -20,6 +20,24 @@ class QgsDxfExport
#include "qgsdxfexport.h"
%End
public:

struct DxfLayer
{
DxfLayer( QgsVectorLayer *vl, int layerOutputAttributeIndex = -1 );

QgsVectorLayer *layer() const;
%Docstring
Return the layer
%End

int layerOutputAttributeIndex() const;
%Docstring
Return the attribute index used to split into multiple layers.
The attribute value is used for layer names.
%End

};

enum SymbologyExport
{
NoSymbology,
@@ -64,7 +82,7 @@ Returns the export flags.
.. seealso:: :py:func:`setFlags`
%End

void addLayers( const QList< QPair<QgsVectorLayer *, int > > &layers );
void addLayers( const QList< QgsDxfExport::DxfLayer > &layers );
%Docstring
Add layers to export

@@ -211,14 +211,15 @@ def initGui(self):
self.menu.addAction(self.historyAction)
self.toolbox.processingToolbar.addAction(self.historyAction)

self.resultsAction = self.resultsDock.toggleViewAction()
self.resultsAction.setObjectName('resultsAction')
self.resultsAction.setIcon(
QgsApplication.getThemeIcon("/processingResult.svg"))
self.resultsAction.setText(self.tr('&Results Viewer'))
self.resultsAction = QAction(
QgsApplication.getThemeIcon("/processingResult.svg"),
self.tr('&Results Viewer'), self.iface.mainWindow())
self.resultsAction.setCheckable(True)
self.iface.registerMainWindowAction(self.resultsAction, 'Ctrl+Alt+R')
self.menu.addAction(self.resultsAction)
self.toolbox.processingToolbar.addAction(self.resultsAction)
self.resultsDock.visibilityChanged.connect(self.resultsAction.setChecked)
self.resultsAction.toggled.connect(self.resultsDock.setUserVisible)

self.optionsAction = QAction(
QgsApplication.getThemeIcon("/mActionOptions.svg"),
@@ -271,6 +271,7 @@ def setValue(self, value):
self.saveToTemporary()
else:
self.leText.setText(value)
self.use_temporary = False

def getValue(self):
key = None
@@ -1357,15 +1357,15 @@ int main( int argc, char *argv[] )
dxfExport.setExtent( dxfExtent );

QStringList layerIds;
QList< QPair<QgsVectorLayer *, int > > layers;
QList< QgsDxfExport::DxfLayer > layers;
if ( !dxfMapTheme.isEmpty() )
{
Q_FOREACH ( QgsMapLayer *layer, QgsProject::instance()->mapThemeCollection()->mapThemeVisibleLayers( dxfMapTheme ) )
{
QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( layer );
if ( !vl )
continue;
layers << qMakePair<QgsVectorLayer *, int>( vl, -1 );
layers << QgsDxfExport::DxfLayer( vl );
layerIds << vl->id();
}
}
@@ -1376,7 +1376,7 @@ int main( int argc, char *argv[] )
QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( ml );
if ( !vl )
continue;
layers << qMakePair<QgsVectorLayer *, int>( vl, -1 );
layers << QgsDxfExport::DxfLayer( vl );
layerIds << vl->id();
}
}
@@ -276,9 +276,9 @@ bool QgsVectorLayerAndAttributeModel::setData( const QModelIndex &index, const Q
}


QList< QPair<QgsVectorLayer *, int> > QgsVectorLayerAndAttributeModel::layers() const
QList< QgsDxfExport::DxfLayer > QgsVectorLayerAndAttributeModel::layers() const
{
QList< QPair<QgsVectorLayer *, int> > layers;
QList< QgsDxfExport::DxfLayer > layers;
QHash< QString, int > layerIdx;

Q_FOREACH ( const QModelIndex &idx, mCheckedLeafs )
@@ -293,7 +293,7 @@ QList< QPair<QgsVectorLayer *, int> > QgsVectorLayerAndAttributeModel::layers()
if ( !layerIdx.contains( vl->id() ) )
{
layerIdx.insert( vl->id(), layers.size() );
layers << qMakePair<QgsVectorLayer *, int>( vl, mAttributeIdx.value( vl, -1 ) );
layers << QgsDxfExport::DxfLayer( vl, mAttributeIdx.value( vl, -1 ) );
}
}
}
@@ -304,12 +304,12 @@ QList< QPair<QgsVectorLayer *, int> > QgsVectorLayerAndAttributeModel::layers()
if ( !layerIdx.contains( vl->id() ) )
{
layerIdx.insert( vl->id(), layers.size() );
layers << qMakePair<QgsVectorLayer *, int>( vl, mAttributeIdx.value( vl, -1 ) );
layers << QgsDxfExport::DxfLayer( vl, mAttributeIdx.value( vl, -1 ) );
}
}
}

QList< QPair<QgsVectorLayer *, int> > layersInROrder;
QList< QgsDxfExport::DxfLayer > layersInROrder;

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

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


QList< QPair<QgsVectorLayer *, int> > QgsDxfExportDialog::layers() const
QList< QgsDxfExport::DxfLayer > QgsDxfExportDialog::layers() const
{
const QgsVectorLayerAndAttributeModel *model = dynamic_cast< const QgsVectorLayerAndAttributeModel *>( mTreeView->model() );
Q_ASSERT( model );
@@ -53,7 +53,7 @@ class QgsVectorLayerAndAttributeModel : public QgsLayerTreeModel
Qt::ItemFlags flags( const QModelIndex &index ) const override;
bool setData( const QModelIndex &index, const QVariant &value, int role = Qt::EditRole ) override;

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

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

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

double symbologyScale() const;
QgsDxfExport::SymbologyExport symbologyMode() const;
@@ -398,18 +398,18 @@ QgsDxfExport::Flags QgsDxfExport::flags() const
return mFlags;
}

void QgsDxfExport::addLayers( const QList< QPair< QgsVectorLayer *, int > > &layers )
void QgsDxfExport::addLayers( const QList<DxfLayer> &layers )
{
QList<QgsMapLayer *> layerList;

mLayerNameAttribute.clear();

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

mMapSettings.setLayers( layerList );
@@ -51,6 +51,32 @@ namespace pal SIP_SKIP
class CORE_EXPORT QgsDxfExport
{
public:

/**
* Layers and optional attribute index to split
* into multiple layers using attribute value as layer name.
*/
struct DxfLayer
{
DxfLayer( QgsVectorLayer *vl, int layerOutputAttributeIndex = -1 )
: mLayer( vl )
, mLayerOutputAttributeIndex( layerOutputAttributeIndex )
{}

//! Return the layer
QgsVectorLayer *layer() const {return mLayer;}

/**
* Return the attribute index used to split into multiple layers.
* The attribute value is used for layer names.
*/
int layerOutputAttributeIndex() const {return mLayerOutputAttributeIndex;}

private:
QgsVectorLayer *mLayer = nullptr;
int mLayerOutputAttributeIndex = -1;
};

enum SymbologyExport
{
NoSymbology = 0, //!< Export only data
@@ -97,7 +123,7 @@ class CORE_EXPORT QgsDxfExport
* \param layers list of layers and corresponding attribute indexes that determine the layer name (-1 for original layer name or title)
* \see setLayerTitleAsName
*/
void addLayers( const QList< QPair<QgsVectorLayer *, int > > &layers );
void addLayers( const QList< QgsDxfExport::DxfLayer > &layers );

/**
* Export to a dxf file in the given encoding
@@ -595,9 +595,6 @@ class CORE_EXPORT QgsVectorDataProvider : public QgsDataProvider, public QgsFeat
//! The names of the providers native types
QList< NativeType > mNativeTypes;

//! Old notation *
QMap<QString, QVariant::Type> mOldTypeList;

//! List of errors
mutable QStringList mErrors;

@@ -58,17 +58,17 @@ void QgsCollapsibleGroupBoxBasic::init()
mExpandIcon = QgsApplication::getThemeIcon( QStringLiteral( "/mIconExpand.svg" ) );

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

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

mAltDown = ( mAltDown || mCollapseButton->altDown() );
mShiftDown = ( mShiftDown || mCollapseButton->shiftDown() );
@@ -426,7 +426,7 @@ void QgsCollapsibleGroupBoxBasic::setCollapsed( bool collapse )
mParentScrollArea->ensureWidgetVisible( this );
//and then make sure the top of the widget is visible - otherwise tall group boxes
//scroll to their centres, which is disorienting for users
mParentScrollArea->ensureWidgetVisible( mCollapseButton.get(), 0, 5 );
mParentScrollArea->ensureWidgetVisible( mCollapseButton, 0, 5 );
mParentScrollArea->setUpdatesEnabled( true );
}
// emit signal for connections using collapsed state
@@ -444,7 +444,7 @@ void QgsCollapsibleGroupBoxBasic::collapseExpandFixes()
Q_FOREACH ( QObject *child, children() )
{
QWidget *w = qobject_cast<QWidget *>( child );
if ( w && w != mCollapseButton.get() )
if ( w && w != mCollapseButton )
{
w->setProperty( hideKey, true );
w->hide();
@@ -456,7 +456,7 @@ void QgsCollapsibleGroupBoxBasic::collapseExpandFixes()
Q_FOREACH ( QObject *child, children() )
{
QWidget *w = qobject_cast<QWidget *>( child );
if ( w && w != mCollapseButton.get() )
if ( w && w != mCollapseButton )
{
if ( w->property( hideKey ).toBool() )
w->show();
@@ -157,7 +157,7 @@ class GUI_EXPORT QgsCollapsibleGroupBoxBasic : public QGroupBox
bool mScrollOnExpand;
bool mShown;
QScrollArea *mParentScrollArea = nullptr;
std::unique_ptr<QgsGroupBoxCollapseButton> mCollapseButton;
QgsGroupBoxCollapseButton *mCollapseButton = nullptr;
QWidget *mSyncParent = nullptr;
QString mSyncGroup;
bool mAltDown;
@@ -767,7 +767,7 @@ namespace QgsWms
QStringList wfsLayerIds = QgsServerProjectUtils::wfsLayerIds( *mProject );

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

dxfLayers.append( qMakePair( vlayer, layerAttribute ) );
dxfLayers.append( QgsDxfExport::DxfLayer( vlayer, layerAttribute ) );
}

// add layers to dxf
@@ -102,7 +102,7 @@ void TestQgsDxfExport::cleanup()
void TestQgsDxfExport::testPoints()
{
QgsDxfExport d;
d.addLayers( QList< QPair< QgsVectorLayer *, int > >() << qMakePair( mPointLayer, -1 ) );
d.addLayers( QList< QgsDxfExport::DxfLayer >() << QgsDxfExport::DxfLayer( mPointLayer ) );

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

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

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

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

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

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

QgsMapSettings mapSettings;
QSize size( 640, 480 );

0 comments on commit c996c61

Please sign in to comment.
You can’t perform that action at this time.