QGIS API Documentation 3.34.0-Prizren (ffbdd678812)
Loading...
Searching...
No Matches
qgsprocessingfeaturesourceoptionswidget.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsprocessingfeaturesourceoptionswidget.cpp
3 ------------------------------------
4 Date : March 2020
5 Copyright : (C) 2020 Nyall Dawson
6 Email : nyall dot dawson at gmail dot com
7
8 ***************************************************************************
9 * *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 ***************************************************************************/
16
18#include "qgis.h"
19
21
22QgsProcessingFeatureSourceOptionsWidget::QgsProcessingFeatureSourceOptionsWidget( QWidget *parent )
23 : QgsPanelWidget( parent )
24{
25 setupUi( this );
26
27 mFeatureLimitSpinBox->setClearValue( 0, tr( "Not set" ) );
28 mFeatureLimitSpinBox->clear();
29
30 mComboInvalidFeatureFiltering->addItem( tr( "Use Default" ) );
31 mComboInvalidFeatureFiltering->addItem( tr( "Do not Filter (Better Performance)" ), QgsFeatureRequest::GeometryNoCheck );
32 mComboInvalidFeatureFiltering->addItem( tr( "Skip (Ignore) Features with Invalid Geometries" ), QgsFeatureRequest::GeometrySkipInvalid );
33 mComboInvalidFeatureFiltering->addItem( tr( "Stop Algorithm Execution When a Geometry is Invalid" ), QgsFeatureRequest::GeometryAbortOnInvalid );
34
35 connect( mFeatureLimitSpinBox, qOverload<int>( &QSpinBox::valueChanged ), this, &QgsPanelWidget::widgetChanged );
36 connect( mComboInvalidFeatureFiltering, qOverload<int>( &QComboBox::currentIndexChanged ), this, &QgsPanelWidget::widgetChanged );
37 connect( mFilterExpressionWidget, &QgsExpressionLineEdit::expressionChanged, this, &QgsPanelWidget::widgetChanged );
38}
39
40void QgsProcessingFeatureSourceOptionsWidget::setLayer( QgsVectorLayer *layer )
41{
42 mFilterExpressionWidget->setLayer( layer );
43}
44
45void QgsProcessingFeatureSourceOptionsWidget::setGeometryCheckMethod( bool isOverridden, QgsFeatureRequest::InvalidGeometryCheck check )
46{
47 if ( !isOverridden )
48 mComboInvalidFeatureFiltering->setCurrentIndex( mComboInvalidFeatureFiltering->findData( QVariant() ) );
49 else
50 mComboInvalidFeatureFiltering->setCurrentIndex( mComboInvalidFeatureFiltering->findData( check ) );
51}
52
53void QgsProcessingFeatureSourceOptionsWidget::setFeatureLimit( int limit )
54{
55 mFeatureLimitSpinBox->setValue( limit );
56}
57
58void QgsProcessingFeatureSourceOptionsWidget::setFilterExpression( const QString &expression )
59{
60 mFilterExpressionWidget->setExpression( expression );
61}
62
63QgsFeatureRequest::InvalidGeometryCheck QgsProcessingFeatureSourceOptionsWidget::geometryCheckMethod() const
64{
65 return mComboInvalidFeatureFiltering->currentData().isValid() ? static_cast< QgsFeatureRequest::InvalidGeometryCheck >( mComboInvalidFeatureFiltering->currentData().toInt() ) : QgsFeatureRequest::GeometryAbortOnInvalid;
66}
67
68bool QgsProcessingFeatureSourceOptionsWidget::isOverridingInvalidGeometryCheck() const
69{
70 return mComboInvalidFeatureFiltering->currentData().isValid();
71}
72
73int QgsProcessingFeatureSourceOptionsWidget::featureLimit() const
74{
75 return mFeatureLimitSpinBox->value() > 0 ? mFeatureLimitSpinBox->value() : -1;
76}
77
78QString QgsProcessingFeatureSourceOptionsWidget::filterExpression() const
79{
80 return mFilterExpressionWidget->expression();
81}
82
void expressionChanged(const QString &expression)
Emitted when the expression is changed.
This class wraps a request for features to a vector layer (or directly its vector data provider).
InvalidGeometryCheck
Handling of features with invalid geometries.
@ GeometryNoCheck
No invalid geometry checking.
@ GeometryAbortOnInvalid
Close iterator on encountering any features with invalid geometry. This requires a slow geometry vali...
@ GeometrySkipInvalid
Skip any features with invalid geometry. This requires a slow geometry validity check for every featu...
Base class for any widget that can be shown as a inline panel.
void widgetChanged()
Emitted when the widget state changes.
Represents a vector layer which manages a vector based data sets.