Skip to content

Commit

Permalink
Adjust docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Jun 4, 2018
1 parent 2b9ffa1 commit b5b16df
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 13 deletions.
1 change: 1 addition & 0 deletions python/core/auto_generated/qgsfeaturesource.sip.in
Expand Up @@ -22,6 +22,7 @@ An interface for objects which provide features via a getFeatures method.
#include "qgsfeaturesource.h"
%End
public:

enum FeatureAvailability
{
NoFeaturesAvailable,
Expand Down
11 changes: 5 additions & 6 deletions python/core/auto_generated/qgsvectorlayer.sip.in
Expand Up @@ -946,13 +946,12 @@ Determines if this vector layer has features.

.. warning::

A layer is considered empty if neither the data provider nor
the edit buffer have features in them.
This means the returned value may be inaccurate for layers with unsaved changes,
i.e. in the case of all features from the data provider having been
deleted within the edit buffer.
when a layer is editable and some features
have been deleted, this will return
QgsFeatureSource.FeatureAvailability.FeaturesMayBeAvailable
to avoid a potentially expensive call to the dataprovider.

.. versionadded:: 3.2
.. versionadded:: 3.4
%End

void setDataSource( const QString &dataSource, const QString &baseName, const QString &provider, bool loadDefaultStyleFlag = false ) /Deprecated/;
Expand Down
10 changes: 10 additions & 0 deletions src/core/qgsfeaturesource.h
Expand Up @@ -37,6 +37,16 @@ class QgsFeedback;
class CORE_EXPORT QgsFeatureSource
{
public:

/**
* Return value for hasFeatures() to determine if a source is empty.
* It is implemented as a three-value logic, so it can return if
* there are features available for sure, if there are no features
* available for sure or if there might be features available but
* there is no guarantee for this.
*
* \since QGIS 3.4
*/
enum FeatureAvailability
{
NoFeaturesAvailable, //!< There are certainly no features available in this source
Expand Down
11 changes: 5 additions & 6 deletions src/core/qgsvectorlayer.h
Expand Up @@ -932,13 +932,12 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
/**
* Determines if this vector layer has features.
*
* \warning A layer is considered empty if neither the data provider nor
* the edit buffer have features in them.
* This means the returned value may be inaccurate for layers with unsaved changes,
* i.e. in the case of all features from the data provider having been
* deleted within the edit buffer.
* \warning when a layer is editable and some features
* have been deleted, this will return
* QgsFeatureSource::FeatureAvailability::FeaturesMayBeAvailable
* to avoid a potentially expensive call to the dataprovider.
*
* \since QGIS 3.2
* \since QGIS 3.4
*/
FeatureAvailability hasFeatures() const override;

Expand Down
2 changes: 1 addition & 1 deletion src/providers/postgres/qgspostgresprovider.h
Expand Up @@ -115,7 +115,7 @@ class QgsPostgresProvider : public QgsVectorDataProvider
* \note In contrast to the featureCount() method, this method is not
* affected by estimated metadata.
*
* \since QGIS 3.2
* \since QGIS 3.4
*/
bool empty() const override;

Expand Down

0 comments on commit b5b16df

Please sign in to comment.