QGIS API Documentation 4.1.0-Master (5bf3c20f3c9)
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
71 QWidget *createEditor( QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index ) const override;
72 void setEditorData( QWidget *editor, const QModelIndex &index ) const override;
73 void setModelData( QWidget *editor, QAbstractItemModel *model, const QModelIndex &index ) const override;
74};
75
76
77class GUI_EXPORT QgsProcessingTinInputLayersWidget : public QWidget, private Ui::QgsProcessingTinInputLayersWidgetBase
78{
79 Q_OBJECT
80 public:
81 QgsProcessingTinInputLayersWidget( QgsProject *project );
82
83 QVariant value() const;
84 void setValue( const QVariant &value );
85 void setProject( QgsProject *project );
86
87 signals:
88 void changed();
89
90 private slots:
91 void onLayerChanged( QgsMapLayer *layer );
92 void onCurrentLayerAdded();
93 void onLayersRemove();
94
95 private:
96 QgsProcessingTinInputLayersModel mInputLayersModel;
97};
98
99
100class GUI_EXPORT QgsProcessingTinInputLayersWidgetWrapper : public QgsAbstractProcessingParameterWidgetWrapper, public QgsProcessingParameterWidgetFactoryInterface
101{
102 Q_OBJECT
103
104 public:
105 QgsProcessingTinInputLayersWidgetWrapper( const QgsProcessingParameterDefinition *parameter = nullptr, Qgis::ProcessingMode type = Qgis::ProcessingMode::Standard, QWidget *parent = nullptr );
106
107 QString parameterType() const override;
108 QgsAbstractProcessingParameterWidgetWrapper *createWidgetWrapper( const QgsProcessingParameterDefinition *parameter, Qgis::ProcessingMode type ) override;
109
110 protected:
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
ProcessingMode
Types of modes which Processing widgets can be created for.
Definition qgis.h:3786
@ Standard
Standard (single-run) algorithm mode.
Definition qgis.h:3787
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.