Skip to content

Commit

Permalink
fix windows build and some warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Dec 24, 2015
1 parent 13a5167 commit 8f29f28
Show file tree
Hide file tree
Showing 18 changed files with 138 additions and 56 deletions.
91 changes: 80 additions & 11 deletions python/core/qgsfeaturerequest.sip
Expand Up @@ -15,17 +15,39 @@ class QgsFeatureRequest
};
typedef QFlags<QgsFeatureRequest::Flag> Flags;

/**
* Types of filters.
*/
enum FilterType
{
FilterNone, //!< No filter is applied
FilterRect, //!< Filter using a rectangle, no need to set NoGeometry
FilterRect, //!< Obsolete, will be ignored. If a filterRect is set it will be used anyway. Filter using a rectangle, no need to set NoGeometry. Instead check for request.filterRect().isNull()
FilterFid, //!< Filter using feature ID
FilterExpression, //!< Filter using expression
FilterFids //!< Filter using feature IDs
};

/**
* @brief The OrderByClause class represents an order by clause for a QgsFeatureRequest
* The OrderByClause class represents an order by clause for a QgsFeatureRequest.
*
* It can be a simple field or an expression. Multiple order by clauses can be added to
* a QgsFeatureRequest to fine tune the behavior if a single field or expression is not
* enough to completely specify the required behavior.
*
* If expression compilation is activated in the settings and the expression can be
* translated for the provider in question, it will be evaluated on provider side.
* If one of these two premises does not apply, the ordering will take place locally
* which results in increased memory and CPU usage.
*
* If the ordering is done on strings, the order depends on the system's locale if the
* local fallback implementation is used. The order depends on the server system's locale
* and implementation if ordering is done on the server.
*
* In case the fallback code needs to be used, a limit set on the request will be respected
* for the features returned by the iterator but internally all features will be requested
* from the provider.
*
* @note added in QGIS 2.14
*/
class OrderByClause
{
Expand All @@ -35,8 +57,8 @@ class QgsFeatureRequest
*
* @param expression The expression to use for ordering
* @param ascending If the order should be ascending (1,2,3) or descending (3,2,1)
* If thr order is ascending, by default nulls are last
* If thr order is descending, by default nulls are first
* If the order is ascending, by default nulls are last
* If the order is descending, by default nulls are first
*/
OrderByClause( const QString &expression, bool ascending = true );
/**
Expand Down Expand Up @@ -76,13 +98,29 @@ class QgsFeatureRequest
*/
void setNullsFirst( bool nullsFirst );

/**
* Dumps the content to an SQL equivalent
*/
QString dump() const;
};

/**
* Represents a list of OrderByClauses, with the most important first and the least
* important last.
*
* @note added in QGIS 2.14
*/
class OrderBy
{
public:
/**
* Create a new empty order by
*/
OrderBy();

/**
* Create a new order by from a list of clauses
*/
OrderBy( const QList<QgsFeatureRequest::OrderByClause>& other );

/**
Expand Down Expand Up @@ -127,20 +165,36 @@ class QgsFeatureRequest
explicit QgsFeatureRequest( const QgsRectangle& rect );
//! construct a request with a filter expression
explicit QgsFeatureRequest( const QgsExpression& expr, const QgsExpressionContext& context = QgsExpressionContext() );
//! copy constructor
QgsFeatureRequest( const QgsFeatureRequest& rh );

~QgsFeatureRequest();

/**
* Return the filter type which is currently set on this request
*
* @return Filter type
*/
FilterType filterType() const;

//! Set rectangle from which features will be taken. Empty rectangle removes the filter.
//!
/**
* Set rectangle from which features will be taken. Empty rectangle removes the filter.
*/
QgsFeatureRequest& setFilterRect( const QgsRectangle& rect );

/**
* Get the rectangle from which features will be taken.
*/
const QgsRectangle& filterRect() const;

//! Set feature ID that should be fetched.
QgsFeatureRequest& setFilterFid( qint64 fid );
//! Get the feature ID that should be fetched.
qint64 filterFid() const;

//! Set feature ID that should be fetched.
//! Set feature IDs that should be fetched.
QgsFeatureRequest& setFilterFids( const QgsFeatureIds& fids );
//! Get feature IDs that should be fetched.
const QgsFeatureIds& filterFids() const;

/** Set the filter expression. {@see QgsExpression}
Expand All @@ -166,12 +220,14 @@ class QgsFeatureRequest
/** Returns the expression context used to evaluate filter expressions.
* @note added in QGIS 2.12
* @see setExpressionContext
* @see filterExpression
*/
QgsExpressionContext* expressionContext();

/** Sets the expression context used to evaluate filter expressions.
* @note added in QGIS 2.12
* @see expressionContext
* @see setFilterExpression
*/
QgsFeatureRequest& setExpressionContext( const QgsExpressionContext& context );

Expand All @@ -186,14 +242,14 @@ class QgsFeatureRequest
QgsFeatureRequest& disableFilter();

/**
* Adds a new OrderByClause
* Adds a new OrderByClause, appending it as the least important one.
*
* @param expression The expression to use for ordering
* @param ascending If the order should be ascending (1,2,3) or descending (3,2,1)
* If the order is ascending, by default nulls are last
* If the order is descending, by default nulls are first
*
* @added in QGIS 2.14
* @note added in QGIS 2.14
*/

QgsFeatureRequest& addOrderBy( const QString &expression, bool ascending = true );
Expand All @@ -204,19 +260,23 @@ class QgsFeatureRequest
* @param ascending If the order should be ascending (1,2,3) or descending (3,2,1)
* @param nullsfirst If true, NULLS are at the beginning, if false, NULLS are at the end
*
* @added in QGIS 2.14
* @note added in QGIS 2.14
*/
QgsFeatureRequest& addOrderBy( const QString &expression, bool ascending, bool nullsfirst );

/**
* Return a list of order by clauses specified for this feature request.
*
* @note added in 2.14
*/
QgsFeatureRequest::OrderBy orderBy() const;

/**
* Set a list of order by clauses.
*
* @note added in 2.14
*/
QgsFeatureRequest& setOrderBy(const QgsFeatureRequest::OrderBy& orderBy );
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 All @@ -238,6 +298,10 @@ class QgsFeatureRequest
//! Set a subset of attributes that will be fetched. Empty list means that all attributes are used.
//! To disable fetching attributes, reset the FetchAttributes flag (which is set by default)
QgsFeatureRequest& setSubsetOfAttributes( const QgsAttributeList& attrs );
/**
* Return the subset of attributes which at least need to be fetched
* @return A list of attributes to be fetched
*/
const QgsAttributeList& subsetOfAttributes() const;

//! Set a subset of attributes by names that will be fetched
Expand Down Expand Up @@ -275,6 +339,11 @@ class QgsAbstractFeatureSource
public:
virtual ~QgsAbstractFeatureSource();

/**
* Get an iterator for features matching the specified request
* @param request The request
* @return A feature iterator
*/
virtual QgsFeatureIterator getFeatures( const QgsFeatureRequest& request ) = 0;

protected:
Expand Down
12 changes: 11 additions & 1 deletion src/analysis/CMakeLists.txt
Expand Up @@ -62,10 +62,20 @@ ADD_FLEX_FILES_PREFIX(QGIS_ANALYSIS_SRCS raster raster/qgsrastercalclexer.ll)

ADD_BISON_FILES_PREFIX(QGIS_ANALYSIS_SRCS raster raster/qgsrastercalcparser.yy)

SET_SOURCE_FILES_PROPERTIES(
IF(NOT MSVC)
SET_SOURCE_FILES_PROPERTIES(
${CMAKE_BINARY_DIR}/src/analysis/qgsrastercalcparser.cpp
PROPERTIES COMPILE_FLAGS "-w"
)
ELSE(NOT MSVC)
IF(PEDANTIC)
# 4702 unreachable code
SET_SOURCE_FILES_PROPERTIES(
${CMAKE_BINARY_DIR}/src/analysis/qgsrastercalcparser.cpp
PROPERTIES COMPILE_FLAGS "-wd4702"
)
ENDIF(PEDANTIC)
ENDIF(NOT MSVC)

IF (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
SET_SOURCE_FILES_PROPERTIES(
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsstatusbarcoordinateswidget.cpp
Expand Up @@ -140,7 +140,7 @@ void QgsStatusBarCoordinatesWidget::validateCoordinates()

bool xOk = false;
bool yOk = false;
double x, y;
double x = 0., y = 0.;
QString coordText = mLineEdit->text();
coordText.replace( QRegExp( " {2,}" ), " " );

Expand Down
3 changes: 2 additions & 1 deletion src/app/qgsvectorlayerproperties.cpp
Expand Up @@ -1052,6 +1052,7 @@ void QgsVectorLayerProperties::showListOfStylesFromDatabase()
QMessageBox::warning( this, tr( "Error occured retrieving styles from database" ), errorMsg );
return;
}
Q_NOWARN_DEPRECATED_PUSH
if ( layer->applyNamedStyle( qmlStyle, errorMsg ) )
{
syncToLayer();
Expand All @@ -1062,7 +1063,7 @@ void QgsVectorLayerProperties::showListOfStylesFromDatabase()
tr( "The retrieved style is not a valid named style. Error message: %1" )
.arg( errorMsg ) );
}

Q_NOWARN_DEPRECATED_POP
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/astyle/CMakeLists.txt
@@ -1,5 +1,7 @@
SET(ASTYLE_SRCS astyle_main.cpp ASBeautifier.cpp ASFormatter.cpp ASEnhancer.cpp ASResource.cpp)
# No warnings for astyle build
SET_SOURCE_FILES_PROPERTIES( ${ASTYLE_SRCS} PROPERTIES COMPILE_FLAGS -w )
IF(NOT MSVC)
SET_SOURCE_FILES_PROPERTIES(${ASTYLE_SRCS} PROPERTIES COMPILE_FLAGS -w)
ENDIF(NOT MSVC)
ADD_EXECUTABLE(qgisstyle ${ASTYLE_SRCS})
SET_TARGET_PROPERTIES(qgisstyle PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/scripts)
8 changes: 6 additions & 2 deletions src/core/CMakeLists.txt
Expand Up @@ -403,10 +403,14 @@ IF (QT_MOBILITY_LOCATION_FOUND OR Qt5Positioning_FOUND)
ENDIF (QT_MOBILITY_LOCATION_FOUND OR Qt5Positioning_FOUND)

ADD_FLEX_FILES(QGIS_CORE_SRCS qgsexpressionlexer.ll)

ADD_BISON_FILES(QGIS_CORE_SRCS qgsexpressionparser.yy)

SET_SOURCE_FILES_PROPERTIES( qgsexpressionparser.cpp PROPERTIES COMPILE_FLAGS -w )
IF(NOT MSVC)
SET_SOURCE_FILES_PROPERTIES(qgsexpressionparser.cpp PROPERTIES COMPILE_FLAGS -w)
ELSE(NOT MSVC)
# -wd4702 unreachable code
SET_SOURCE_FILES_PROPERTIES(geometry/qgsgeos.cpp PROPERTIES COMPILE_FLAGS -wd4702)
ENDIF(NOT MSVC)

SET(QGIS_CORE_MOC_HDRS
qgsapplication.h
Expand Down
5 changes: 4 additions & 1 deletion src/core/qgsexpression.cpp
Expand Up @@ -4478,4 +4478,7 @@ QVariant QgsExpression::StaticFunction::func( const QVariantList &values, const
Q_NOWARN_DEPRECATED_POP
}

const QgsExpression::Node* QgsExpression::rootNode() const { return d->mRootNode; }
const QgsExpression::Node* QgsExpression::rootNode() const
{
return d->mRootNode;
}
2 changes: 1 addition & 1 deletion src/core/qgsfeatureiterator.h
Expand Up @@ -262,7 +262,7 @@ inline bool QgsFeatureIterator::isClosed() const

inline bool operator== ( const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2 )
{
return ( fi1.mIter == fi2.mIter );
return fi1.mIter == fi2.mIter;
}

inline bool operator!= ( const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2 )
Expand Down
3 changes: 2 additions & 1 deletion src/core/qgsfeaturerequest.cpp
Expand Up @@ -381,7 +381,8 @@ QSet<QString> QgsFeatureRequest::OrderBy::usedAttributes() const

return usedAttributes;
}
QString QgsFeatureRequest::OrderBy::dump() const

QString QgsFeatureRequest::OrderBy::dump( void ) const
{
QStringList results;

Expand Down
18 changes: 10 additions & 8 deletions src/core/qgsfeaturerequest.h
Expand Up @@ -16,14 +16,14 @@
#define QGSFEATUREREQUEST_H

#include <QFlags>
#include <QList>

#include "qgsfeature.h"
#include "qgsrectangle.h"
#include "qgsexpression.h"
#include "qgsexpressioncontext.h"
#include "qgssimplifymethod.h"

#include <QList>
typedef QList<int> QgsAttributeList;

/**
Expand Down Expand Up @@ -160,6 +160,8 @@ class CORE_EXPORT QgsFeatureRequest
*/
QString dump() const;

// friend inline int qHash(const OrderByClause &a) { return qHash(a.mExpression.expression()) ^ qHash(a.mAscending) ^ qHash( a.mNullsFirst); }

private:
QgsExpression mExpression;
bool mAscending;
Expand All @@ -178,42 +180,42 @@ class CORE_EXPORT QgsFeatureRequest
/**
* Create a new empty order by
*/
OrderBy()
CORE_EXPORT OrderBy()
: QList<OrderByClause>()
{}

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

/**
* Serialize to XML
*/
void save( QDomElement& elem ) const;
void CORE_EXPORT save( QDomElement& elem ) const;

/**
* Deserialize from XML
*/
void load( const QDomElement& elem );
void CORE_EXPORT load( const QDomElement& elem );

/**
* Returns a set of used attributes
*/
QSet<QString> usedAttributes() const;
QSet<QString> CORE_EXPORT usedAttributes() const;

/**
* Dumps the content to an SQL equivalent syntax
*/
QString dump() const;
QString CORE_EXPORT dump() const;
};

/**
Expand Down
2 changes: 2 additions & 0 deletions src/core/qgsvectorlayer.cpp
Expand Up @@ -3878,7 +3878,9 @@ QString QgsVectorLayer::loadNamedStyle( const QString &theURI, bool &theResultFl
qml = loadStyleExternalMethod( mDataSource, errorMsg );
if ( !qml.isEmpty() )
{
Q_NOWARN_DEPRECATED_PUSH
theResultFlag = applyNamedStyle( qml, errorMsg );
Q_NOWARN_DEPRECATED_POP
return QObject::tr( "Loaded from Provider" );
}
}
Expand Down

0 comments on commit 8f29f28

Please sign in to comment.