QGIS API Documentation  3.8.0-Zanzibar (11aff65)
qgsquickfeaturelayerpair.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsquickfeaturelayerpair.cpp
3  ---------------------
4  Date : Nov 2017
5  Copyright : (C) 2017 by Peter Petrik
6  Email : zilolv at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #include "qgsvectorlayer.h"
17 #include "qgsfeature.h"
18 
20 
22 
24  : mLayer( layer )
25  , mFeature( feature )
26 {
27 }
28 
30 {
31  return mLayer;
32 }
33 
35 {
36  return mFeature;
37 }
38 
40 {
41  return mFeature;
42 }
43 
45 {
46  return ( mLayer && mFeature.isValid() && hasValidGeometry() );
47 }
48 
50 {
51  return ( mLayer == other.layer() ) && ( mFeature == other.feature() );
52 }
53 
55 {
56  return ( mLayer != other.layer() ) || ( mFeature != other.feature() );
57 }
58 
59 bool QgsQuickFeatureLayerPair::hasValidGeometry() const
60 {
61  Q_ASSERT( mLayer );
62 
63  if ( !mFeature.hasGeometry() )
64  return false;
65 
66  if ( mFeature.geometry().type() != mLayer->geometryType() )
67  return false;
68 
69  return true;
70 }
bool isValid() const
Returns the validity of this feature.
Definition: qgsfeature.cpp:183
QgsWkbTypes::GeometryType geometryType() const
Returns point, line or polygon.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:55
bool hasGeometry() const
Returns true if the feature has an associated geometry.
Definition: qgsfeature.cpp:197
QgsFeature & featureRef()
Feature that belongs to layer.
QgsFeature feature() const
Feature that belongs to layer.
bool operator!=(const QgsQuickFeatureLayerPair &other) const
bool operator==(const QgsQuickFeatureLayerPair &other) const
QgsFeature feature
Feature that belongs to layer.
QgsVectorLayer * layer() const
Vector layer to which the feature belongs.
QgsQuickFeatureLayerPair()
Constructs invalid feature-layer pair.
QgsVectorLayer layer
Vector layer to which the feature belongs.
QgsWkbTypes::GeometryType type
Definition: qgsgeometry.h:115
QgsGeometry geometry
Definition: qgsfeature.h:67
Pair of QgsFeature and QgsVectorLayer.
Represents a vector layer which manages a vector based data sets.