QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
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 }
qgsquickfeaturelayerpair.h
QgsQuickFeatureLayerPair::operator!=
bool operator!=(const QgsQuickFeatureLayerPair &other) const
Definition: qgsquickfeaturelayerpair.cpp:54
qgsfeature.h
QgsFeature::geometry
QgsGeometry geometry
Definition: qgsfeature.h:67
QgsQuickFeatureLayerPair::QgsQuickFeatureLayerPair
QgsQuickFeatureLayerPair()
Constructs invalid feature-layer pair.
QgsFeature::isValid
bool isValid() const
Returns the validity of this feature.
Definition: qgsfeature.cpp:185
QgsQuickFeatureLayerPair::layer
Q_GADGET QgsVectorLayer * layer
Vector layer to which the feature belongs.
Definition: qgsquickfeaturelayerpair.h:49
QgsQuickFeatureLayerPair::operator==
bool operator==(const QgsQuickFeatureLayerPair &other) const
Definition: qgsquickfeaturelayerpair.cpp:49
QgsQuickFeatureLayerPair::feature
QgsFeature feature
Feature that belongs to layer.
Definition: qgsquickfeaturelayerpair.h:56
qgsvectorlayer.h
QgsVectorLayer
Represents a vector layer which manages a vector based data sets.
Definition: qgsvectorlayer.h:387
QgsFeature::hasGeometry
bool hasGeometry() const
Returns true if the feature has an associated geometry.
Definition: qgsfeature.cpp:199
QgsQuickFeatureLayerPair
Pair of QgsFeature and QgsVectorLayer.
Definition: qgsquickfeaturelayerpair.h:41
QgsFeature
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:56
QgsQuickFeatureLayerPair::isValid
bool isValid() const
Whether.
Definition: qgsquickfeaturelayerpair.cpp:44
QgsGeometry::type
QgsWkbTypes::GeometryType type
Definition: qgsgeometry.h:127
QgsVectorLayer::geometryType
Q_INVOKABLE QgsWkbTypes::GeometryType geometryType() const
Returns point, line or polygon.
Definition: qgsvectorlayer.cpp:659
QgsQuickFeatureLayerPair::featureRef
QgsFeature & featureRef()
Feature that belongs to layer.
Definition: qgsquickfeaturelayerpair.cpp:39