QGIS API Documentation 3.39.0-Master (bca3cdb6021)
Loading...
Searching...
No Matches
qgsprocessingtininputlayerswidget.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsprocessingtininputlayerswidget.h
3 ---------------------
4 Date : August 2020
5 Copyright : (C) 2020 by Vincent Cloarec
6 Email : vcloarec 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 QGSPROCESSINGTININPUTLAYERSWIDGET_H
17#define QGSPROCESSINGTININPUTLAYERSWIDGET_H
18
19#define SIP_NO_FILE
20
21#include <QAbstractTableModel>
22#include <QStyledItemDelegate>
23
26#include "ui_qgsprocessingtinmeshdatawidgetbase.h"
27
29
30class QgsProcessingTinInputLayersModel: public QAbstractTableModel
31{
32 Q_OBJECT
33 public:
34 enum Roles
35 {
36 Type = Qt::UserRole
37 };
38
39 QgsProcessingTinInputLayersModel( QgsProject *project );
40
41 int rowCount( const QModelIndex &parent ) const override;
42 int columnCount( const QModelIndex &parent ) const override;
43 QVariant data( const QModelIndex &index, int role ) const override;
44 bool setData( const QModelIndex &index, const QVariant &value, int role ) override;
45 Qt::ItemFlags flags( const QModelIndex &index ) const override;
46 QVariant headerData( int section, Qt::Orientation orientation, int role ) const override;
47
49 void removeLayer( int index );
50 void clear();
51
52 QList<QgsProcessingParameterTinInputLayers::InputLayer> layers() const;
53
54 void setProject( QgsProject *project );
55
56 private:
57 QList<QgsProcessingParameterTinInputLayers::InputLayer> mInputLayers;
58 QgsProject *mProject = nullptr;
59};
60
61class QgsProcessingTinInputLayersDelegate: public QStyledItemDelegate
62{
63 Q_OBJECT
64 public:
65 QgsProcessingTinInputLayersDelegate( QObject *parent ): QStyledItemDelegate( parent ) {}
66
67 QWidget *createEditor( QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index ) const override;
68 void setEditorData( QWidget *editor, const QModelIndex &index ) const override;
69 void setModelData( QWidget *editor, QAbstractItemModel *model, const QModelIndex &index ) const override;
70};
71
72
73class GUI_EXPORT QgsProcessingTinInputLayersWidget: public QWidget, private Ui::QgsProcessingTinInputLayersWidgetBase
74{
75 Q_OBJECT
76 public:
77 QgsProcessingTinInputLayersWidget( QgsProject *project );
78
79 QVariant value() const;
80 void setValue( const QVariant &value );
81 void setProject( QgsProject *project );
82
83 signals:
84 void changed();
85
86 private slots:
87 void onLayerChanged( QgsMapLayer *layer );
88 void onCurrentLayerAdded();
89 void onLayersRemove();
90
91 private:
92
93 QgsProcessingTinInputLayersModel mInputLayersModel;
94};
95
96
97class GUI_EXPORT QgsProcessingTinInputLayersWidgetWrapper : public QgsAbstractProcessingParameterWidgetWrapper, public QgsProcessingParameterWidgetFactoryInterface
98{
99 Q_OBJECT
100
101 public:
102 QgsProcessingTinInputLayersWidgetWrapper( const QgsProcessingParameterDefinition *parameter = nullptr,
103 QgsProcessingGui::WidgetType type = QgsProcessingGui::Standard, QWidget *parent = nullptr );
104
105 QString parameterType() const override;
107
108 protected:
109 QStringList compatibleParameterTypes() const override;
110 QStringList compatibleOutputTypes() const override;
111 QWidget *createWidget() override SIP_FACTORY;
112 void setWidgetValue( const QVariant &value, QgsProcessingContext &context ) override;
113 QVariant widgetValue() const override;
114
115 private:
116 QgsProcessingTinInputLayersWidget *mWidget = nullptr;
117
118 friend class TestProcessingGui;
119};
120
122
123#endif // QGSPROCESSINGTININPUTLAYERSWIDGET_H
A widget wrapper for Processing parameter value widgets.
Base class for all map layer types.
Definition qgsmaplayer.h:76
Contains information about the context in which a processing algorithm is executed.
WidgetType
Types of dialogs which Processing widgets can be created for.
@ Standard
Standard algorithm dialog.
Base class for the definition of processing parameters.
An interface for Processing widget wrapper factories.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Definition qgsproject.h:107
#define SIP_FACTORY
Definition qgis_sip.h:76
Used to store input layer Id and other associated parameters.