QGIS API Documentation  3.20.0-Odense (decaadbb31)
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 
22 QgsProcessingFeatureSourceOptionsWidget::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 }
38 
39 void QgsProcessingFeatureSourceOptionsWidget::setGeometryCheckMethod( bool isOverridden, QgsFeatureRequest::InvalidGeometryCheck check )
40 {
41  if ( !isOverridden )
42  mComboInvalidFeatureFiltering->setCurrentIndex( mComboInvalidFeatureFiltering->findData( QVariant() ) );
43  else
44  mComboInvalidFeatureFiltering->setCurrentIndex( mComboInvalidFeatureFiltering->findData( check ) );
45 }
46 
47 void QgsProcessingFeatureSourceOptionsWidget::setFeatureLimit( int limit )
48 {
49  mFeatureLimitSpinBox->setValue( limit );
50 }
51 
52 QgsFeatureRequest::InvalidGeometryCheck QgsProcessingFeatureSourceOptionsWidget::geometryCheckMethod() const
53 {
54  return mComboInvalidFeatureFiltering->currentData().isValid() ? static_cast< QgsFeatureRequest::InvalidGeometryCheck >( mComboInvalidFeatureFiltering->currentData().toInt() ) : QgsFeatureRequest::GeometryAbortOnInvalid;
55 }
56 
57 bool QgsProcessingFeatureSourceOptionsWidget::isOverridingInvalidGeometryCheck() const
58 {
59  return mComboInvalidFeatureFiltering->currentData().isValid();
60 }
61 
62 int QgsProcessingFeatureSourceOptionsWidget::featureLimit() const
63 {
64  return mFeatureLimitSpinBox->value() > 0 ? mFeatureLimitSpinBox->value() : -1;
65 }
66 
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.