Skip to content

Commit

Permalink
Rename OrderBys -> OrderBy and OrderBy -> OrderByClause
Browse files Browse the repository at this point in the history
And some sip fixes
  • Loading branch information
m-kuhn committed Dec 22, 2015
1 parent 3f1db6d commit 168c6f7
Show file tree
Hide file tree
Showing 16 changed files with 88 additions and 31 deletions.
16 changes: 14 additions & 2 deletions python/core/qgsfeaturerequest.sip
Expand Up @@ -81,6 +81,18 @@ class QgsFeatureRequest
class OrderBy
{
public:
OrderBy();

OrderBy( const QList<QgsFeatureRequest::OrderByClause>& 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<QgsFeatureRequest::OrderByClause> list() const;

/**
* Serialize to XML
*/
Expand Down Expand Up @@ -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.
Expand Down
12 changes: 12 additions & 0 deletions python/core/symbology-ng/qgsrendererv2.sip
Expand Up @@ -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 );

Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsfeatureiterator.cpp
Expand Up @@ -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++;
}
Expand Down
27 changes: 20 additions & 7 deletions src/core/qgsfeaturerequest.cpp
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -321,6 +321,19 @@ QgsExpression QgsFeatureRequest::OrderByClause::expression() const
return mExpression;
}

QgsFeatureRequest::OrderBy::OrderBy( const QList<QgsFeatureRequest::OrderByClause>& other )
{
Q_FOREACH ( const QgsFeatureRequest::OrderByClause& clause, other )
{
append( clause );
}
}

QList<QgsFeatureRequest::OrderByClause> QgsFeatureRequest::OrderBy::list() const
{
return *this;
}

void QgsFeatureRequest::OrderBy::save( QDomElement& elem ) const
{
QDomDocument doc = elem.ownerDocument();
Expand Down
26 changes: 23 additions & 3 deletions src/core/qgsfeaturerequest.h
Expand Up @@ -175,6 +175,26 @@ class CORE_EXPORT QgsFeatureRequest
class OrderBy : public QList<OrderByClause>
{
public:
/**
* Create a new empty order by
*/
OrderBy()
: QList<OrderByClause>()
{}

/**
* Create a new order by from a list of clauses
*/
OrderBy( const QList<OrderByClause>& 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<OrderByClause> list() const;

/**
* Serialize to XML
*/
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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 )
Expand Down
4 changes: 2 additions & 2 deletions src/core/qgsvectorlayerfeatureiterator.cpp
Expand Up @@ -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 );
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsvectorlayerrenderer.cpp
Expand Up @@ -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 )
Expand Down
2 changes: 1 addition & 1 deletion src/core/symbology-ng/qgsinvertedpolygonrenderer.cpp
Expand Up @@ -344,7 +344,7 @@ QgsInvertedPolygonRenderer* QgsInvertedPolygonRenderer::clone() const
newRenderer = new QgsInvertedPolygonRenderer( mSubRenderer.data() );
}
newRenderer->setPreprocessingEnabled( preprocessingEnabled() );
copyPaintEffect( newRenderer );
copyRendererData( newRenderer );
return newRenderer;
}

Expand Down
2 changes: 1 addition & 1 deletion src/core/symbology-ng/qgspointdisplacementrenderer.cpp
Expand Up @@ -80,7 +80,7 @@ QgsPointDisplacementRenderer* QgsPointDisplacementRenderer::clone() const
{
r->setCenterSymbol( mCenterSymbol->clone() );
}
copyPaintEffect( r );
copyRendererData( r );
return r;
}

Expand Down
6 changes: 3 additions & 3 deletions src/core/symbology-ng/qgsrendererv2.cpp
Expand Up @@ -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 )
Expand Down
4 changes: 2 additions & 2 deletions src/core/symbology-ng/qgsrendererv2.h
Expand Up @@ -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 );
Expand Down
2 changes: 1 addition & 1 deletion src/core/symbology-ng/qgsrulebasedrendererv2.cpp
Expand Up @@ -911,7 +911,7 @@ QgsRuleBasedRendererV2* QgsRuleBasedRendererV2::clone() const
QgsRuleBasedRendererV2* r = new QgsRuleBasedRendererV2( clonedRoot );

r->setUsingSymbolLevels( usingSymbolLevels() );
copyPaintEffect( r );
copyRendererData( r );
return r;
}

Expand Down
8 changes: 4 additions & 4 deletions src/gui/qgsorderbydialog.cpp
Expand Up @@ -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 )
{
Expand All @@ -81,13 +81,13 @@ QgsFeatureRequest::OrderBy QgsOrderByDialog::orderBy()
{
bool asc = static_cast<QCheckBox*>( mOrderByTableWidget->cellWidget( i, 1 ) )->checkState();
bool nullsFirst = static_cast<QCheckBox*>( 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 )
Expand Down
2 changes: 1 addition & 1 deletion src/providers/mssql/qgsmssqlfeatureiterator.cpp
Expand Up @@ -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() ) )
{
Expand Down
2 changes: 1 addition & 1 deletion src/providers/postgres/qgspostgresfeatureiterator.cpp
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/providers/spatialite/qgsspatialitefeatureiterator.cpp
Expand Up @@ -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();
Expand Down

0 comments on commit 168c6f7

Please sign in to comment.