QGIS API Documentation  3.8.0-Zanzibar (11aff65)
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 
27 
29 class QToolButton;
30 class QCheckBox;
32 
34 
41 class GUI_EXPORT QgsProcessingMapLayerComboBox : public QWidget
42 {
43  Q_OBJECT
44 
45  public:
46 
50  QgsProcessingMapLayerComboBox( QgsProcessingParameterDefinition *parameter, QWidget *parent = nullptr );
51 
56  void setLayer( QgsMapLayer *layer );
57 
67  QgsMapLayer *currentLayer();
68 
77  QString currentText();
78 
84  void setValue( const QVariant &value, QgsProcessingContext &context );
85 
91  QVariant value() const;
92 
93  signals:
94 
98  void valueChanged();
99 
104  void triggerFileSelection();
105 
106  protected:
107 
108  void dragEnterEvent( QDragEnterEvent *event ) override;
109  void dragLeaveEvent( QDragLeaveEvent *event ) override;
110  void dropEvent( QDropEvent *event ) override;
111 
112  private slots:
113 
114  void onLayerChanged( QgsMapLayer *layer );
115  void selectionChanged( const QgsFeatureIds &selected, const QgsFeatureIds &deselected, bool clearAndSelect );
116 
117  private:
118  QgsProcessingParameterDefinition *mParameter = nullptr;
119  QgsMapLayerComboBox *mCombo = nullptr;
120  QToolButton *mSelectButton = nullptr;
121  QCheckBox *mUseSelectionCheckBox = nullptr;
122  bool mDragActive = false;
123  QPointer< QgsMapLayer> mPrevLayer;
124  int mBlockChangedSignal = 0;
125  QgsMapLayer *compatibleMapLayerFromMimeData( const QMimeData *data, bool &incompatibleLayerSelected ) const;
126  QString compatibleUriFromMimeData( const QMimeData *data ) const;
127 };
128 
130 #endif // QGSPROCESSINGMAPLAYERCOMBOBOX_H
Base class for all map layer types.
Definition: qgsmaplayer.h:78
QSet< QgsFeatureId > QgsFeatureIds
Definition: qgsfeatureid.h:34
The QgsMapLayerComboBox class is a combo box which displays the list of layers.
Base class for the definition of processing parameters.
Contains information about the context in which a processing algorithm is executed.