QGIS API Documentation  3.14.0-Pi (9f7028fd23)
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:71
QgsQuickFeatureLayerPair::QgsQuickFeatureLayerPair
QgsQuickFeatureLayerPair()
Constructs invalid feature-layer pair.
QgsQuickFeatureLayerPair::layer
QgsVectorLayer layer
Vector layer to which the feature belongs.
Definition: qgsquickfeaturelayerpair.h:49
QgsFeature::isValid
bool isValid() const
Returns the validity of this feature.
Definition: qgsfeature.cpp:183
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
Definition: qgsvectorlayer.h:385
QgsFeature::hasGeometry
bool hasGeometry() const
Returns true if the feature has an associated geometry.
Definition: qgsfeature.cpp:197
QgsQuickFeatureLayerPair
Definition: qgsquickfeaturelayerpair.h:40
QgsFeature
Definition: qgsfeature.h:55
QgsQuickFeatureLayerPair::isValid
bool isValid() const
Whether.
Definition: qgsquickfeaturelayerpair.cpp:44
QgsGeometry::type
QgsWkbTypes::GeometryType type
Definition: qgsgeometry.h:126
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