QGIS API Documentation 3.38.0-Grenoble (exported)
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)" ), QVariant::fromValue( Qgis::InvalidGeometryCheck::NoCheck ) );
32 mComboInvalidFeatureFiltering->addItem( tr( "Skip (Ignore) Features with Invalid Geometries" ), QVariant::fromValue( Qgis::InvalidGeometryCheck::SkipInvalid ) );
33 mComboInvalidFeatureFiltering->addItem( tr( "Stop Algorithm Execution When a Geometry is Invalid" ), QVariant::fromValue( Qgis::InvalidGeometryCheck::AbortOnInvalid ) );
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, Qgis::InvalidGeometryCheck check )
46{
47 if ( !isOverridden )
48 mComboInvalidFeatureFiltering->setCurrentIndex( mComboInvalidFeatureFiltering->findData( QVariant() ) );
49 else
50 mComboInvalidFeatureFiltering->setCurrentIndex( mComboInvalidFeatureFiltering->findData( QVariant::fromValue( 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
63Qgis::InvalidGeometryCheck QgsProcessingFeatureSourceOptionsWidget::geometryCheckMethod() const
64{
65 return mComboInvalidFeatureFiltering->currentData().isValid() ? mComboInvalidFeatureFiltering->currentData().value< Qgis::InvalidGeometryCheck >() : Qgis::InvalidGeometryCheck::AbortOnInvalid;
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
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:1872
@ 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.