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