Skip to content

Commit

Permalink
Merge branch 'master' into dxf_label_layers_v3
Browse files Browse the repository at this point in the history
  • Loading branch information
mhugent committed Feb 13, 2018
2 parents 5c3a755 + 66b9b43 commit c996c61
Show file tree
Hide file tree
Showing 14 changed files with 89 additions and 582 deletions.
546 changes: 5 additions & 541 deletions python/core/conversions.sip

Large diffs are not rendered by default.

20 changes: 19 additions & 1 deletion python/core/dxf/qgsdxfexport.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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

Expand Down
11 changes: 6 additions & 5 deletions python/plugins/processing/ProcessingPlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
1 change: 1 addition & 0 deletions python/plugins/processing/gui/DestinationSelectionPanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ def setValue(self, value):
self.saveToTemporary()
else:
self.leText.setText(value)
self.use_temporary = False

def getValue(self):
key = None
Expand Down
6 changes: 3 additions & 3 deletions src/app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Expand All @@ -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();
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/app/qgsdxfexportdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand All @@ -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 ) );
}
}
}
Expand All @@ -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();

Expand Down Expand Up @@ -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 );
Expand Down
4 changes: 2 additions & 2 deletions src/app/qgsdxfexportdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
10 changes: 5 additions & 5 deletions src/core/dxf/qgsdxfexport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
28 changes: 27 additions & 1 deletion src/core/dxf/qgsdxfexport.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions src/core/qgsvectordataprovider.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
14 changes: 7 additions & 7 deletions src/gui/qgscollapsiblegroupbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
Expand Down Expand Up @@ -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() );
Expand Down Expand Up @@ -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
Expand All @@ -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();
Expand All @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/gui/qgscollapsiblegroupbox.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/server/services/wms/qgswmsrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
{
Expand Down Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions tests/src/core/testqgsdxfexport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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 );
Expand Down

0 comments on commit c996c61

Please sign in to comment.