diff --git a/python/core/qgsfeaturerequest.sip b/python/core/qgsfeaturerequest.sip index 49720b0828f..398ddae52da 100644 --- a/python/core/qgsfeaturerequest.sip +++ b/python/core/qgsfeaturerequest.sip @@ -81,6 +81,18 @@ class QgsFeatureRequest class OrderBy { public: + OrderBy(); + + OrderBy( const QList& other ); + + /** + * Get a copy as a list of OrderByClauses + * + * This is only required in python where the inheritance + * is not properly propagated and this makes it usable. + */ + QList list() const; + /** * Serialize to XML */ @@ -199,12 +211,12 @@ class QgsFeatureRequest /** * Return a list of order by clauses specified for this feature request. */ - QgsFeatureRequest::OrderBy orderBys() const; + QgsFeatureRequest::OrderBy orderBy() const; /** * Set a list of order by clauses. */ - QgsFeatureRequest& setOrderBys(const QgsFeatureRequest::OrderBy& orderBys ); + QgsFeatureRequest& setOrderBy(const QgsFeatureRequest::OrderBy& orderBy ); /** Set the maximum number of features to request. * @param limit maximum number of features, or -1 to request all features. diff --git a/python/core/symbology-ng/qgsrendererv2.sip b/python/core/symbology-ng/qgsrendererv2.sip index efa8a563bfc..92e1beb693e 100644 --- a/python/core/symbology-ng/qgsrendererv2.sip +++ b/python/core/symbology-ng/qgsrendererv2.sip @@ -312,6 +312,18 @@ class QgsFeatureRendererV2 */ void setForceRasterRender( bool forceRaster ); + /** + * Get the order in which features shall be processed by this renderer. + * @note added in QGIS 2.14 + */ + QgsFeatureRequest::OrderBy orderBy() const; + + /** + * Define the order in which features shall be processed by this renderer. + * @note added in QGIS 2.14 + */ + void setOrderBy( const QgsFeatureRequest::OrderBy& orderBy ); + protected: QgsFeatureRendererV2( const QString& type ); diff --git a/src/core/qgsfeatureiterator.cpp b/src/core/qgsfeatureiterator.cpp index f6348a249d2..2059a7b7131 100644 --- a/src/core/qgsfeatureiterator.cpp +++ b/src/core/qgsfeatureiterator.cpp @@ -220,7 +220,7 @@ void QgsAbstractFeatureIterator::ref() prepareSimplification( mRequest.simplifyMethod() ); // Should be called as last preparation step since it possibly will already fetch all features - setupOrderBy( mRequest.orderBys() ); + setupOrderBy( mRequest.orderBy() ); } refs++; } diff --git a/src/core/qgsfeaturerequest.cpp b/src/core/qgsfeaturerequest.cpp index c9afc31b79b..8cc6cded92d 100644 --- a/src/core/qgsfeaturerequest.cpp +++ b/src/core/qgsfeaturerequest.cpp @@ -84,7 +84,7 @@ QgsFeatureRequest& QgsFeatureRequest::operator=( const QgsFeatureRequest & rh ) mAttrs = rh.mAttrs; mSimplifyMethod = rh.mSimplifyMethod; mLimit = rh.mLimit; - mOrderBys = rh.mOrderBys; + mOrderBy = rh.mOrderBy; return *this; } @@ -144,24 +144,24 @@ QgsFeatureRequest &QgsFeatureRequest::setExpressionContext( const QgsExpressionC QgsFeatureRequest& QgsFeatureRequest::addOrderBy( const QString& expression, bool ascending ) { - mOrderBys.append( OrderByClause( expression, ascending ) ); + mOrderBy.append( OrderByClause( expression, ascending ) ); return *this; } QgsFeatureRequest& QgsFeatureRequest::addOrderBy( const QString& expression, bool ascending, bool nullsfirst ) { - mOrderBys.append( OrderByClause( expression, ascending, nullsfirst ) ); + mOrderBy.append( OrderByClause( expression, ascending, nullsfirst ) ); return *this; } -QgsFeatureRequest::OrderBy QgsFeatureRequest::orderBys() const +QgsFeatureRequest::OrderBy QgsFeatureRequest::orderBy() const { - return mOrderBys; + return mOrderBy; } -QgsFeatureRequest& QgsFeatureRequest::setOrderBys( const QgsFeatureRequest::OrderBy& orderBys ) +QgsFeatureRequest& QgsFeatureRequest::setOrderBy( const QgsFeatureRequest::OrderBy& orderBy ) { - mOrderBys = orderBys; + mOrderBy = orderBy; return *this; } @@ -321,6 +321,19 @@ QgsExpression QgsFeatureRequest::OrderByClause::expression() const return mExpression; } +QgsFeatureRequest::OrderBy::OrderBy( const QList& other ) +{ + Q_FOREACH ( const QgsFeatureRequest::OrderByClause& clause, other ) + { + append( clause ); + } +} + +QList QgsFeatureRequest::OrderBy::list() const +{ + return *this; +} + void QgsFeatureRequest::OrderBy::save( QDomElement& elem ) const { QDomDocument doc = elem.ownerDocument(); diff --git a/src/core/qgsfeaturerequest.h b/src/core/qgsfeaturerequest.h index 1a0b4842459..ed15ee7297b 100644 --- a/src/core/qgsfeaturerequest.h +++ b/src/core/qgsfeaturerequest.h @@ -175,6 +175,26 @@ class CORE_EXPORT QgsFeatureRequest class OrderBy : public QList { public: + /** + * Create a new empty order by + */ + OrderBy() + : QList() + {} + + /** + * Create a new order by from a list of clauses + */ + OrderBy( const QList& other ); + + /** + * Get a copy as a list of OrderByClauses + * + * This is only required in python where the inheritance + * is not properly propagated and this makes it usable. + */ + QList list() const; + /** * Serialize to XML */ @@ -315,14 +335,14 @@ class CORE_EXPORT QgsFeatureRequest * * @note added in 2.14 */ - OrderBy orderBys() const; + OrderBy orderBy() const; /** * Set a list of order by clauses. * * @note added in 2.14 */ - QgsFeatureRequest& setOrderBys( const OrderBy& orderBys ); + QgsFeatureRequest& setOrderBy( const OrderBy& orderBy ); /** Set the maximum number of features to request. * @param limit maximum number of features, or -1 to request all features. @@ -385,7 +405,7 @@ class CORE_EXPORT QgsFeatureRequest QgsAttributeList mAttrs; QgsSimplifyMethod mSimplifyMethod; long mLimit; - OrderBy mOrderBys; + OrderBy mOrderBy; }; Q_DECLARE_OPERATORS_FOR_FLAGS( QgsFeatureRequest::Flags ) diff --git a/src/core/qgsvectorlayerfeatureiterator.cpp b/src/core/qgsvectorlayerfeatureiterator.cpp index 1dc2341c31c..e3fbeec5c89 100644 --- a/src/core/qgsvectorlayerfeatureiterator.cpp +++ b/src/core/qgsvectorlayerfeatureiterator.cpp @@ -120,9 +120,9 @@ QgsVectorLayerFeatureIterator::QgsVectorLayerFeatureIterator( QgsVectorLayerFeat // TODO: // It would be nicer to first check if we can compile the order by // and only modify the subset if we cannot. - if ( !mProviderRequest.orderBys().isEmpty() ) + if ( !mProviderRequest.orderBy().isEmpty() ) { - Q_FOREACH ( const QString& attr, mProviderRequest.orderBys().usedAttributes() ) + Q_FOREACH ( const QString& attr, mProviderRequest.orderBy().usedAttributes() ) { providerSubset << mSource->mFields.fieldNameIndex( attr ); } diff --git a/src/core/qgsvectorlayerrenderer.cpp b/src/core/qgsvectorlayerrenderer.cpp index 80468a4c3ec..4145d2b9423 100644 --- a/src/core/qgsvectorlayerrenderer.cpp +++ b/src/core/qgsvectorlayerrenderer.cpp @@ -156,7 +156,7 @@ bool QgsVectorLayerRenderer::render() .setFilterRect( requestExtent ) .setSubsetOfAttributes( mAttrNames, mFields ) .setExpressionContext( mContext.expressionContext() ) - .setOrderBys( orderBy ); + .setOrderBy( orderBy ); const QgsFeatureFilterProvider* featureFilterProvider = mContext.featureFilterProvider(); if ( featureFilterProvider ) diff --git a/src/core/symbology-ng/qgsinvertedpolygonrenderer.cpp b/src/core/symbology-ng/qgsinvertedpolygonrenderer.cpp index 2323185de20..9615605ab24 100644 --- a/src/core/symbology-ng/qgsinvertedpolygonrenderer.cpp +++ b/src/core/symbology-ng/qgsinvertedpolygonrenderer.cpp @@ -344,7 +344,7 @@ QgsInvertedPolygonRenderer* QgsInvertedPolygonRenderer::clone() const newRenderer = new QgsInvertedPolygonRenderer( mSubRenderer.data() ); } newRenderer->setPreprocessingEnabled( preprocessingEnabled() ); - copyPaintEffect( newRenderer ); + copyRendererData( newRenderer ); return newRenderer; } diff --git a/src/core/symbology-ng/qgspointdisplacementrenderer.cpp b/src/core/symbology-ng/qgspointdisplacementrenderer.cpp index ac9f5923210..56a7694825b 100644 --- a/src/core/symbology-ng/qgspointdisplacementrenderer.cpp +++ b/src/core/symbology-ng/qgspointdisplacementrenderer.cpp @@ -80,7 +80,7 @@ QgsPointDisplacementRenderer* QgsPointDisplacementRenderer::clone() const { r->setCenterSymbol( mCenterSymbol->clone() ); } - copyPaintEffect( r ); + copyRendererData( r ); return r; } diff --git a/src/core/symbology-ng/qgsrendererv2.cpp b/src/core/symbology-ng/qgsrendererv2.cpp index 2eb455a14b4..a9051834382 100644 --- a/src/core/symbology-ng/qgsrendererv2.cpp +++ b/src/core/symbology-ng/qgsrendererv2.cpp @@ -616,14 +616,14 @@ void QgsFeatureRendererV2::setPaintEffect( QgsPaintEffect *effect ) mPaintEffect = effect; } -QgsFeatureRequest::OrderBy QgsFeatureRendererV2::orderBy() +QgsFeatureRequest::OrderBy QgsFeatureRendererV2::orderBy() const { return mOrderBy; } -void QgsFeatureRendererV2::setOrderBy( const QgsFeatureRequest::OrderBy& orderBys ) +void QgsFeatureRendererV2::setOrderBy( const QgsFeatureRequest::OrderBy& orderBy ) { - mOrderBy = orderBys; + mOrderBy = orderBy; } void QgsFeatureRendererV2::convertSymbolSizeScale( QgsSymbolV2 * symbol, QgsSymbolV2::ScaleMethod method, const QString & field ) diff --git a/src/core/symbology-ng/qgsrendererv2.h b/src/core/symbology-ng/qgsrendererv2.h index e0314b6b5c3..b14ba7ef5b2 100644 --- a/src/core/symbology-ng/qgsrendererv2.h +++ b/src/core/symbology-ng/qgsrendererv2.h @@ -348,13 +348,13 @@ class CORE_EXPORT QgsFeatureRendererV2 * Get the order in which features shall be processed by this renderer. * @note added in QGIS 2.14 */ - QgsFeatureRequest::OrderBy orderBy(); + QgsFeatureRequest::OrderBy orderBy() const; /** * Define the order in which features shall be processed by this renderer. * @note added in QGIS 2.14 */ - void setOrderBy( const QgsFeatureRequest::OrderBy& orderBys ); + void setOrderBy( const QgsFeatureRequest::OrderBy& orderBy ); protected: QgsFeatureRendererV2( const QString& type ); diff --git a/src/core/symbology-ng/qgsrulebasedrendererv2.cpp b/src/core/symbology-ng/qgsrulebasedrendererv2.cpp index a3c1525d790..ec0562b1860 100644 --- a/src/core/symbology-ng/qgsrulebasedrendererv2.cpp +++ b/src/core/symbology-ng/qgsrulebasedrendererv2.cpp @@ -911,7 +911,7 @@ QgsRuleBasedRendererV2* QgsRuleBasedRendererV2::clone() const QgsRuleBasedRendererV2* r = new QgsRuleBasedRendererV2( clonedRoot ); r->setUsingSymbolLevels( usingSymbolLevels() ); - copyPaintEffect( r ); + copyRendererData( r ); return r; } diff --git a/src/gui/qgsorderbydialog.cpp b/src/gui/qgsorderbydialog.cpp index 05878070143..2b702c415b9 100644 --- a/src/gui/qgsorderbydialog.cpp +++ b/src/gui/qgsorderbydialog.cpp @@ -71,7 +71,7 @@ void QgsOrderByDialog::setOrderBy( const QgsFeatureRequest::OrderBy& orderBy ) QgsFeatureRequest::OrderBy QgsOrderByDialog::orderBy() { - QgsFeatureRequest::OrderBy orderBys; + QgsFeatureRequest::OrderBy orderBy; for ( int i = 0; i < mOrderByTableWidget->rowCount(); ++i ) { @@ -81,13 +81,13 @@ QgsFeatureRequest::OrderBy QgsOrderByDialog::orderBy() { bool asc = static_cast( mOrderByTableWidget->cellWidget( i, 1 ) )->checkState(); bool nullsFirst = static_cast( mOrderByTableWidget->cellWidget( i, 2 ) )->checkState(); - QgsFeatureRequest::OrderByClause orderBy( expressionText, asc, nullsFirst ); + QgsFeatureRequest::OrderByClause orderByClause( expressionText, asc, nullsFirst ); - orderBys << orderBy; + orderBy << orderByClause; } } - return orderBys; + return orderBy; } void QgsOrderByDialog::onCellDoubleClicked( int row, int column ) diff --git a/src/providers/mssql/qgsmssqlfeatureiterator.cpp b/src/providers/mssql/qgsmssqlfeatureiterator.cpp index 791f01173ff..ac6ed8c7cbd 100644 --- a/src/providers/mssql/qgsmssqlfeatureiterator.cpp +++ b/src/providers/mssql/qgsmssqlfeatureiterator.cpp @@ -197,7 +197,7 @@ void QgsMssqlFeatureIterator::BuildStatement( const QgsFeatureRequest& request ) if ( QSettings().value( "/qgis/compileExpressions", true ).toBool() ) { - Q_FOREACH ( const QgsFeatureRequest::OrderByClause& clause, request.orderBys() ) + Q_FOREACH ( const QgsFeatureRequest::OrderByClause& clause, request.orderBy() ) { if (( clause.ascending() && !clause.nullsFirst() ) || ( !clause.ascending() && clause.nullsFirst() ) ) { diff --git a/src/providers/postgres/qgspostgresfeatureiterator.cpp b/src/providers/postgres/qgspostgresfeatureiterator.cpp index 592b5cc04ed..33dad7140ef 100644 --- a/src/providers/postgres/qgspostgresfeatureiterator.cpp +++ b/src/providers/postgres/qgspostgresfeatureiterator.cpp @@ -118,7 +118,7 @@ QgsPostgresFeatureIterator::QgsPostgresFeatureIterator( QgsPostgresFeatureSource if ( QSettings().value( "/qgis/compileExpressions", true ).toBool() ) { - Q_FOREACH ( const QgsFeatureRequest::OrderByClause& clause, request.orderBys() ) + Q_FOREACH ( const QgsFeatureRequest::OrderByClause& clause, request.orderBy() ) { QgsPostgresExpressionCompiler compiler = QgsPostgresExpressionCompiler( source ); QgsExpression expression = clause.expression(); diff --git a/src/providers/spatialite/qgsspatialitefeatureiterator.cpp b/src/providers/spatialite/qgsspatialitefeatureiterator.cpp index cf8246efeb0..a429eb34ddf 100644 --- a/src/providers/spatialite/qgsspatialitefeatureiterator.cpp +++ b/src/providers/spatialite/qgsspatialitefeatureiterator.cpp @@ -123,7 +123,7 @@ QgsSpatiaLiteFeatureIterator::QgsSpatiaLiteFeatureIterator( QgsSpatiaLiteFeature if ( QSettings().value( "/qgis/compileExpressions", true ).toBool() ) { - Q_FOREACH ( const QgsFeatureRequest::OrderByClause& clause, request.orderBys() ) + Q_FOREACH ( const QgsFeatureRequest::OrderByClause& clause, request.orderBy() ) { QgsSpatiaLiteExpressionCompiler compiler = QgsSpatiaLiteExpressionCompiler( source ); QgsExpression expression = clause.expression();