QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
qgsprocessingmaplayercombobox.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsprocessingmaplayercombobox.h
3  -----------------------------
4  begin : June 2019
5  copyright : (C) 2019 by Nyall Dawson
6  email : nyall dot dawson 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 #ifndef QGSPROCESSINGMAPLAYERCOMBOBOX_H
17 #define QGSPROCESSINGMAPLAYERCOMBOBOX_H
18 
19 #include "qgis.h"
20 #include "qgis_gui.h"
21 #include <QTreeView>
23 #include "qgsfeatureid.h"
24 #include "qgsmimedatautils.h"
25 #include "qgsprocessingcontext.h"
26 #include "qgsprocessinggui.h"
27 
29 class QToolButton;
30 class QCheckBox;
32 class QgsBrowserGuiModel;
34 
36 
43 class GUI_EXPORT QgsProcessingMapLayerComboBox : public QWidget
44 {
45  Q_OBJECT
46 
47  public:
48 
52  QgsProcessingMapLayerComboBox( const QgsProcessingParameterDefinition *parameter, QgsProcessingGui::WidgetType type = QgsProcessingGui::Standard, QWidget *parent = nullptr );
53 
54  ~QgsProcessingMapLayerComboBox() override;
55 
60  void setLayer( QgsMapLayer *layer );
61 
71  QgsMapLayer *currentLayer();
72 
81  QString currentText();
82 
88  void setValue( const QVariant &value, QgsProcessingContext &context );
89 
95  QVariant value() const;
96 
101  void setWidgetContext( const QgsProcessingParameterWidgetContext &context );
102 
109  void setEditable( bool editable );
110 
117  bool isEditable() const;
118 
119  signals:
120 
124  void valueChanged();
125 
126  protected:
127 
128  void dragEnterEvent( QDragEnterEvent *event ) override;
129  void dragLeaveEvent( QDragLeaveEvent *event ) override;
130  void dropEvent( QDropEvent *event ) override;
131 
132  private slots:
133 
134  void onLayerChanged( QgsMapLayer *layer );
135  void selectionChanged( const QgsFeatureIds &selected, const QgsFeatureIds &deselected, bool clearAndSelect );
136  void showSourceOptions();
137  void selectFromFile();
138  void browseForLayer();
139 
140  private:
141  std::unique_ptr< QgsProcessingParameterDefinition > mParameter;
142  QgsMapLayerComboBox *mCombo = nullptr;
143  QToolButton *mSelectButton = nullptr;
144  QToolButton *mIterateButton = nullptr;
145  QToolButton *mSettingsButton = nullptr;
146  QCheckBox *mUseSelectionCheckBox = nullptr;
147  bool mDragActive = false;
148  long long mFeatureLimit = -1;
149  bool mIsOverridingDefaultGeometryCheck = false;
151  QPointer< QgsMapLayer> mPrevLayer;
152  int mBlockChangedSignal = 0;
153 
154  QgsBrowserGuiModel *mBrowserModel = nullptr;
155 
156  QMenu *mFeatureSourceMenu = nullptr;
157  QgsMapLayer *compatibleMapLayerFromMimeData( const QMimeData *data, bool &incompatibleLayerSelected ) const;
158  QString compatibleUriFromMimeData( const QMimeData *data ) const;
159 };
160 
162 #endif // QGSPROCESSINGMAPLAYERCOMBOBOX_H
QgsProcessingParameterWidgetContext
Contains settings which reflect the context in which a Processing parameter widget is shown,...
Definition: qgsprocessingwidgetwrapper.h:100
qgsprocessingtoolboxmodel.h
QgsFeatureRequest::GeometryAbortOnInvalid
@ GeometryAbortOnInvalid
Close iterator on encountering any features with invalid geometry. This requires a slow geometry vali...
Definition: qgsfeaturerequest.h:103
qgis.h
QgsProcessingParameterDefinition
Base class for the definition of processing parameters.
Definition: qgsprocessingparameters.h:331
qgsfeatureid.h
qgsmimedatautils.h
QgsFeatureRequest::InvalidGeometryCheck
InvalidGeometryCheck
Handling of features with invalid geometries.
Definition: qgsfeaturerequest.h:100
QgsProcessingGui::Standard
@ Standard
Standard algorithm dialog.
Definition: qgsprocessinggui.h:40
QgsProcessingContext
Contains information about the context in which a processing algorithm is executed.
Definition: qgsprocessingcontext.h:44
qgsprocessinggui.h
QgsFeatureIds
QSet< QgsFeatureId > QgsFeatureIds
Definition: qgsfeatureid.h:37
QgsMapLayerComboBox
The QgsMapLayerComboBox class is a combo box which displays the list of layers.
Definition: qgsmaplayercombobox.h:35
QgsProcessingGui::WidgetType
WidgetType
Types of dialogs which Processing widgets can be created for.
Definition: qgsprocessinggui.h:39
QgsMapLayer
Base class for all map layer types.
Definition: qgsmaplayer.h:83
qgsprocessingcontext.h
QgsBrowserGuiModel
A model for showing available data sources and other items in a structured tree.
Definition: qgsbrowserguimodel.h:38