QGIS API Documentation 3.41.0-Master (af5edcb665c)
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 )
66 : QStyledItemDelegate( parent ) {}
67
68 QWidget *createEditor( QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index ) const override;
69 void setEditorData( QWidget *editor, const QModelIndex &index ) const override;
70 void setModelData( QWidget *editor, QAbstractItemModel *model, const QModelIndex &index ) const override;
71};
72
73
74class GUI_EXPORT QgsProcessingTinInputLayersWidget : public QWidget, private Ui::QgsProcessingTinInputLayersWidgetBase
75{
76 Q_OBJECT
77 public:
78 QgsProcessingTinInputLayersWidget( QgsProject *project );
79
80 QVariant value() const;
81 void setValue( const QVariant &value );
82 void setProject( QgsProject *project );
83
84 signals:
85 void changed();
86
87 private slots:
88 void onLayerChanged( QgsMapLayer *layer );
89 void onCurrentLayerAdded();
90 void onLayersRemove();
91
92 private:
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, QgsProcessingGui::WidgetType type = QgsProcessingGui::Standard, QWidget *parent = nullptr );
103
104 QString parameterType() const override;
106
107 protected:
108 QStringList compatibleParameterTypes() const override;
109 QStringList compatibleOutputTypes() const override;
110 QWidget *createWidget() override SIP_FACTORY;
111 void setWidgetValue( const QVariant &value, QgsProcessingContext &context ) override;
112 QVariant widgetValue() const override;
113
114 private:
115 QgsProcessingTinInputLayersWidget *mWidget = nullptr;
116
117 friend class TestProcessingGui;
118};
119
121
122#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.