QGIS API Documentation 3.41.0-Master (3440c17df1d)
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 "moc_qgsprocessingfeaturesourceoptionswidget.cpp"
19#include "qgis.h"
20
22
23QgsProcessingFeatureSourceOptionsWidget::QgsProcessingFeatureSourceOptionsWidget( QWidget *parent )
24 : QgsPanelWidget( parent )
25{
26 setupUi( this );
27
28 mFeatureLimitSpinBox->setClearValue( 0, tr( "Not set" ) );
29 mFeatureLimitSpinBox->clear();
30
31 mComboInvalidFeatureFiltering->addItem( tr( "Use Default" ) );
32 mComboInvalidFeatureFiltering->addItem( tr( "Do not Filter (Better Performance)" ), QVariant::fromValue( Qgis::InvalidGeometryCheck::NoCheck ) );
33 mComboInvalidFeatureFiltering->addItem( tr( "Skip (Ignore) Features with Invalid Geometries" ), QVariant::fromValue( Qgis::InvalidGeometryCheck::SkipInvalid ) );
34 mComboInvalidFeatureFiltering->addItem( tr( "Stop Algorithm Execution When a Geometry is Invalid" ), QVariant::fromValue( Qgis::InvalidGeometryCheck::AbortOnInvalid ) );
35
36 connect( mFeatureLimitSpinBox, qOverload<int>( &QSpinBox::valueChanged ), this, &QgsPanelWidget::widgetChanged );
37 connect( mComboInvalidFeatureFiltering, qOverload<int>( &QComboBox::currentIndexChanged ), this, &QgsPanelWidget::widgetChanged );
38 connect( mFilterExpressionWidget, &QgsExpressionLineEdit::expressionChanged, this, &QgsPanelWidget::widgetChanged );
39}
40
41void QgsProcessingFeatureSourceOptionsWidget::setLayer( QgsVectorLayer *layer )
42{
43 mFilterExpressionWidget->setLayer( layer );
44}
45
46void QgsProcessingFeatureSourceOptionsWidget::setGeometryCheckMethod( bool isOverridden, Qgis::InvalidGeometryCheck check )
47{
48 if ( !isOverridden )
49 mComboInvalidFeatureFiltering->setCurrentIndex( mComboInvalidFeatureFiltering->findData( QVariant() ) );
50 else
51 mComboInvalidFeatureFiltering->setCurrentIndex( mComboInvalidFeatureFiltering->findData( QVariant::fromValue( check ) ) );
52}
53
54void QgsProcessingFeatureSourceOptionsWidget::setFeatureLimit( int limit )
55{
56 mFeatureLimitSpinBox->setValue( limit );
57}
58
59void QgsProcessingFeatureSourceOptionsWidget::setFilterExpression( const QString &expression )
60{
61 mFilterExpressionWidget->setExpression( expression );
62}
63
64Qgis::InvalidGeometryCheck QgsProcessingFeatureSourceOptionsWidget::geometryCheckMethod() const
65{
66 return mComboInvalidFeatureFiltering->currentData().isValid() ? mComboInvalidFeatureFiltering->currentData().value< Qgis::InvalidGeometryCheck >() : Qgis::InvalidGeometryCheck::AbortOnInvalid;
67}
68
69bool QgsProcessingFeatureSourceOptionsWidget::isOverridingInvalidGeometryCheck() const
70{
71 return mComboInvalidFeatureFiltering->currentData().isValid();
72}
73
74int QgsProcessingFeatureSourceOptionsWidget::featureLimit() const
75{
76 return mFeatureLimitSpinBox->value() > 0 ? mFeatureLimitSpinBox->value() : -1;
77}
78
79QString QgsProcessingFeatureSourceOptionsWidget::filterExpression() const
80{
81 return mFilterExpressionWidget->expression();
82}
83
The Qgis class provides global constants for use throughout the application.
Definition qgis.h:54
InvalidGeometryCheck
Methods for handling of features with invalid geometries.
Definition qgis.h:2072
@ NoCheck
No invalid geometry checking.
@ AbortOnInvalid
Close iterator on encountering any features with invalid geometry. This requires a slow geometry vali...
@ SkipInvalid
Skip any features with invalid geometry. This requires a slow geometry validity check for every featu...
void expressionChanged(const QString &expression)
Emitted when the expression is changed.
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.