QGIS API Documentation 3.99.0-Master (21b3aa880ba)
Loading...
Searching...
No Matches
qgsattributesformview.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsattributesformview.h
3 ---------------------
4 begin : June 2025
5 copyright : (C) 2025 by Germán Carrillo
6 email : german at opengis dot ch
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 QGSATTRIBUTESFORMVIEW_H
17#define QGSATTRIBUTESFORMVIEW_H
18
19// We don't want to expose this in the public API
20#define SIP_NO_FILE
21
22#include "qgis_gui.h"
24
25#include <QTreeView>
26
28
36class GUI_EXPORT QgsAttributesFormBaseView : public QTreeView, protected QgsExpressionContextGenerator
37{
38 Q_OBJECT
39
40 public:
41
47 explicit QgsAttributesFormBaseView( QgsVectorLayer *layer, QWidget *parent = nullptr );
48
54 QModelIndex firstSelectedIndex() const;
55
56 // QgsExpressionContextGenerator interface
58
64 const QList<QgsAttributesFormTreeViewIndicator *> indicators( const QModelIndex &index ) const;
65
71 const QList<QgsAttributesFormTreeViewIndicator *> indicators( QgsAttributesFormItem *item ) const;
72
79
86
93
100
101 public slots:
102
108 void selectFirstMatchingItem( const QgsAttributesFormData::AttributesFormItemType &itemType, const QString &itemId );
109
115 void setFilterText( const QString &text );
116
117 protected:
120
122 QHash< QgsAttributesFormItem *, QList< QgsAttributesFormTreeViewIndicator * > > mIndicators;
123};
124
125
134{
135 Q_OBJECT
136
137 public:
138
144 explicit QgsAttributesAvailableWidgetsView( QgsVectorLayer *layer, QWidget *parent = nullptr );
145
147 void setModel( QAbstractItemModel *model ) override;
148
151};
152
153
162{
163 Q_OBJECT
164
165 public:
166
172 explicit QgsAttributesFormLayoutView( QgsVectorLayer *layer, QWidget *parent = nullptr );
173
175 void setModel( QAbstractItemModel *model ) override;
176
177 protected:
178 // Drag and drop support (to handle internal moves)
179 void dragEnterEvent( QDragEnterEvent *event ) override;
180 void dragMoveEvent( QDragMoveEvent *event ) override;
181 void dropEvent( QDropEvent *event ) override;
182
183 private slots:
184 void onItemDoubleClicked( const QModelIndex &index );
185 void handleExternalDroppedItem( QModelIndex &index );
186 void handleInternalDroppedItem( QModelIndex &index );
187};
188
189
190#endif // QGSATTRIBUTESFORMVIEW_H
Manages available widgets when configuring attributes forms.
void setModel(QAbstractItemModel *model) override
Overridden setModel() from base class. Only QgsAttributesFormProxyModel is an acceptable model.
QgsAttributesAvailableWidgetsView(QgsVectorLayer *layer, QWidget *parent=nullptr)
Constructor for QgsAttributesAvailableWidgetsView, with the given parent.
QgsAttributesAvailableWidgetsModel * availableWidgetsModel() const
Access the underlying QgsAttributesAvailableWidgetsModel source model.
void setFilterText(const QString &text)
Sets the filter text to the underlying proxy model.
QgsAttributesFormProxyModel * mModel
QgsAttributesFormModel * sourceModel() const
Returns the underlying QgsAttributesFormModel model where the view gets data from.
void addIndicator(QgsAttributesFormItem *item, QgsAttributesFormTreeViewIndicator *indicator)
Adds the indicator to the given item.
QHash< QgsAttributesFormItem *, QList< QgsAttributesFormTreeViewIndicator * > > mIndicators
Storage of indicators used with the tree view.
void removeIndicator(QgsAttributesFormItem *item, QgsAttributesFormTreeViewIndicator *indicator)
Removes the indicator from the given item.
void removeAllIndicators()
Removes all indicators in the current view.
QgsAttributesFormBaseView(QgsVectorLayer *layer, QWidget *parent=nullptr)
Constructor for QgsAttributesFormBaseView, with the given parent.
const QList< QgsAttributesFormTreeViewIndicator * > indicators(const QModelIndex &index) const
Returns the list of indicators associated with a given index.
void selectFirstMatchingItem(const QgsAttributesFormData::AttributesFormItemType &itemType, const QString &itemId)
Selects the first item that matches a itemType and a itemId.
QModelIndex firstSelectedIndex() const
Returns the source model index corresponding to the first selected row.
AttributesFormItemType
Custom item types.
Holds parent-child relations as well as item data contained in a QgsAttributesFormModel.
void dropEvent(QDropEvent *event) override
void dragEnterEvent(QDragEnterEvent *event) override
QgsAttributesFormLayoutView(QgsVectorLayer *layer, QWidget *parent=nullptr)
Constructor for QgsAttributesFormLayoutView, with the given parent.
void setModel(QAbstractItemModel *model) override
Overridden setModel() from base class. Only QgsAttributesFormProxyModel is an acceptable model.
void dragMoveEvent(QDragMoveEvent *event) override
Is called when mouse is moved over attributes tree before a drop event.
Abstract class for tree models allowing for configuration of attributes forms.
Proxy model to filter items in the tree views of the drag and drop designer.
Indicator that can be used in an Attributes Form tree view to display icons next to field items.
Abstract interface for generating an expression context.
virtual QgsExpressionContext createExpressionContext() const =0
This method needs to be reimplemented in all classes which implement this interface and return an exp...
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Represents a vector layer which manages a vector based dataset.