QGIS API Documentation  3.10.0-A Coruña (6c816b4204)
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( const QgsProcessingParameterDefinition *parameter, QWidget *parent = nullptr );
51 
52  ~QgsProcessingMapLayerComboBox() override;
53 
58  void setLayer( QgsMapLayer *layer );
59 
69  QgsMapLayer *currentLayer();
70 
79  QString currentText();
80 
86  void setValue( const QVariant &value, QgsProcessingContext &context );
87 
93  QVariant value() const;
94 
95  signals:
96 
100  void valueChanged();
101 
106  void triggerFileSelection();
107 
108  protected:
109 
110  void dragEnterEvent( QDragEnterEvent *event ) override;
111  void dragLeaveEvent( QDragLeaveEvent *event ) override;
112  void dropEvent( QDropEvent *event ) override;
113 
114  private slots:
115 
116  void onLayerChanged( QgsMapLayer *layer );
117  void selectionChanged( const QgsFeatureIds &selected, const QgsFeatureIds &deselected, bool clearAndSelect );
118 
119  private:
120  std::unique_ptr< QgsProcessingParameterDefinition > mParameter;
121  QgsMapLayerComboBox *mCombo = nullptr;
122  QToolButton *mSelectButton = nullptr;
123  QCheckBox *mUseSelectionCheckBox = nullptr;
124  bool mDragActive = false;
125  QPointer< QgsMapLayer> mPrevLayer;
126  int mBlockChangedSignal = 0;
127  QgsMapLayer *compatibleMapLayerFromMimeData( const QMimeData *data, bool &incompatibleLayerSelected ) const;
128  QString compatibleUriFromMimeData( const QMimeData *data ) const;
129 };
130 
132 #endif // QGSPROCESSINGMAPLAYERCOMBOBOX_H
Base class for all map layer types.
Definition: qgsmaplayer.h:79
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.