QGIS API Documentation 3.99.0-Master (2fe06baccd8)
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 "ui_qgsprocessingtinmeshdatawidgetbase.h"
22
25
26#include <QAbstractTableModel>
27#include <QStyledItemDelegate>
28
30
31class QgsProcessingTinInputLayersModel : public QAbstractTableModel
32{
33 Q_OBJECT
34 public:
35 enum Roles
36 {
37 Type = Qt::UserRole
38 };
39
40 QgsProcessingTinInputLayersModel( QgsProject *project );
41
42 int rowCount( const QModelIndex &parent ) const override;
43 int columnCount( const QModelIndex &parent ) const override;
44 QVariant data( const QModelIndex &index, int role ) const override;
45 bool setData( const QModelIndex &index, const QVariant &value, int role ) override;
46 Qt::ItemFlags flags( const QModelIndex &index ) const override;
47 QVariant headerData( int section, Qt::Orientation orientation, int role ) const override;
48
50 void removeLayer( int index );
51 void clear();
52
53 QList<QgsProcessingParameterTinInputLayers::InputLayer> layers() const;
54
55 void setProject( QgsProject *project );
56
57 private:
58 QList<QgsProcessingParameterTinInputLayers::InputLayer> mInputLayers;
59 QgsProject *mProject = nullptr;
60};
61
62class QgsProcessingTinInputLayersDelegate : public QStyledItemDelegate
63{
64 Q_OBJECT
65 public:
66 QgsProcessingTinInputLayersDelegate( QObject *parent )
67 : QStyledItemDelegate( parent ) {}
68
69 QWidget *createEditor( QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index ) const override;
70 void setEditorData( QWidget *editor, const QModelIndex &index ) const override;
71 void setModelData( QWidget *editor, QAbstractItemModel *model, const QModelIndex &index ) const override;
72};
73
74
75class GUI_EXPORT QgsProcessingTinInputLayersWidget : public QWidget, private Ui::QgsProcessingTinInputLayersWidgetBase
76{
77 Q_OBJECT
78 public:
79 QgsProcessingTinInputLayersWidget( QgsProject *project );
80
81 QVariant value() const;
82 void setValue( const QVariant &value );
83 void setProject( QgsProject *project );
84
85 signals:
86 void changed();
87
88 private slots:
89 void onLayerChanged( QgsMapLayer *layer );
90 void onCurrentLayerAdded();
91 void onLayersRemove();
92
93 private:
94 QgsProcessingTinInputLayersModel mInputLayersModel;
95};
96
97
98class GUI_EXPORT QgsProcessingTinInputLayersWidgetWrapper : public QgsAbstractProcessingParameterWidgetWrapper, public QgsProcessingParameterWidgetFactoryInterface
99{
100 Q_OBJECT
101
102 public:
103 QgsProcessingTinInputLayersWidgetWrapper( const QgsProcessingParameterDefinition *parameter = nullptr, Qgis::ProcessingMode type = Qgis::ProcessingMode::Standard, QWidget *parent = nullptr );
104
105 QString parameterType() const override;
106 QgsAbstractProcessingParameterWidgetWrapper *createWidgetWrapper( const QgsProcessingParameterDefinition *parameter, Qgis::ProcessingMode type ) override;
107
108 protected:
109 QWidget *createWidget() override SIP_FACTORY;
110 void setWidgetValue( const QVariant &value, QgsProcessingContext &context ) override;
111 QVariant widgetValue() const override;
112
113 private:
114 QgsProcessingTinInputLayersWidget *mWidget = nullptr;
115
116 friend class TestProcessingGui;
117};
118
120
121#endif // QGSPROCESSINGTININPUTLAYERSWIDGET_H
ProcessingMode
Types of modes which Processing widgets can be created for.
Definition qgis.h:3671
@ Standard
Standard (single-run) algorithm mode.
Definition qgis.h:3672
A widget wrapper for Processing parameter value widgets.
An interface for Processing widget wrapper factories.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Definition qgsproject.h:109
#define SIP_FACTORY
Definition qgis_sip.h:84
Used to store input layer Id and other associated parameters.