QGIS API Documentation 3.99.0-Master (752b475928d)
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:
46 explicit QgsAttributesFormBaseView( QgsVectorLayer *layer, QWidget *parent = nullptr );
47
53 QModelIndex firstSelectedIndex() const;
54
55 // QgsExpressionContextGenerator interface
57
63 const QList<QgsAttributesFormTreeViewIndicator *> indicators( const QModelIndex &index ) const;
64
70 const QList<QgsAttributesFormTreeViewIndicator *> indicators( QgsAttributesFormItem *item ) const;
71
78
85
92
99
100 public slots:
101
107 void selectFirstMatchingItem( const QgsAttributesFormData::AttributesFormItemType &itemType, const QString &itemId );
108
114 void setFilterText( const QString &text );
115
116 protected:
119
121 QHash< QgsAttributesFormItem *, QList< QgsAttributesFormTreeViewIndicator * > > mIndicators;
122};
123
124
133{
134 Q_OBJECT
135
136 public:
142 explicit QgsAttributesAvailableWidgetsView( QgsVectorLayer *layer, QWidget *parent = nullptr );
143
145 void setModel( QAbstractItemModel *model ) override;
146
149};
150
151
160{
161 Q_OBJECT
162
163 public:
169 explicit QgsAttributesFormLayoutView( QgsVectorLayer *layer, QWidget *parent = nullptr );
170
172 void setModel( QAbstractItemModel *model ) override;
173
174 protected:
175 // Drag and drop support (to handle internal moves)
176 void dragEnterEvent( QDragEnterEvent *event ) override;
177 void dragMoveEvent( QDragMoveEvent *event ) override;
178 void dropEvent( QDropEvent *event ) override;
179
180 private slots:
181 void onItemDoubleClicked( const QModelIndex &index );
182 void handleExternalDroppedItem( QModelIndex &index );
183 void handleInternalDroppedItem( QModelIndex &index );
184};
185
186
187#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.