QGIS API Documentation 3.37.0-Master (fdefdf9c27f)
qgsattributetableconfig.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsattributetableconfig.h - QgsAttributeTableConfig
3
4 ---------------------
5 begin : 27.4.2016
6 copyright : (C) 2016 by Matthias Kuhn
8 ***************************************************************************
9 * *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 ***************************************************************************/
16#ifndef QGSATTRIBUTETABLECONFIG_H
17#define QGSATTRIBUTETABLECONFIG_H
18
19#include <QString>
20#include <QVector>
21#include <QDomNode>
22#include <QVariant>
23
24#include "qgis_sip.h"
25#include "qgis_core.h"
26
27class QgsFields;
28
35class CORE_EXPORT QgsAttributeTableConfig
36{
37 public:
38
42 enum Type
43 {
45 Action
46 };
47
52 {
54 ColumnConfig() = default;
55
56 // TODO c++20 - replace with = default
58
61
63 QString name;
64
66 bool hidden = false;
67
69 int width = -1;
70 };
71
76 {
78 DropDown
79 };
80
85
90 QVector<QgsAttributeTableConfig::ColumnConfig> columns() const;
91
97 bool isEmpty() const;
98
104 int size() const;
105
106#ifdef SIP_RUN
107 int __len__() const;
108 % MethodCode
109 sipRes = sipCpp->size();
110 % End
111#endif
112
118 int mapVisibleColumnToIndex( int visibleColumn ) const;
119
124 void setColumns( const QVector<QgsAttributeTableConfig::ColumnConfig> &columns );
125
132 void update( const QgsFields &fields );
133
137 bool actionWidgetVisible() const;
138
142 void setActionWidgetVisible( bool visible );
143
147 ActionWidgetStyle actionWidgetStyle() const;
148
152 void setActionWidgetStyle( ActionWidgetStyle actionWidgetStyle );
153
157 void writeXml( QDomNode &node ) const;
158
162 void readXml( const QDomNode &node );
163
167 QString sortExpression() const;
168
172 void setSortExpression( const QString &sortExpression );
173
174#ifndef SIP_RUN
175
181 int columnWidth( int column ) const;
182#else
183
190 int columnWidth( int column ) const;
191 % MethodCode
192 {
193 if ( a0 < 0 || a0 >= sipCpp->size() )
194 {
195 PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
196 sipIsErr = 1;
197 }
198 else
199 {
200 return PyLong_FromLong( sipCpp->columnWidth( a0 ) );
201 }
202 }
203 % End
204#endif
205
206#ifndef SIP_RUN
207
214 void setColumnWidth( int column, int width );
215#else
216
224 void setColumnWidth( int column, int width );
225 % MethodCode
226 if ( a0 < 0 || a0 >= sipCpp->size() )
227 {
228 PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
229 sipIsErr = 1;
230 }
231 else
232 {
233 sipCpp->setColumnWidth( a0, a1 );
234 }
235 % End
236#endif
237
238#ifndef SIP_RUN
239
245 bool columnHidden( int column ) const;
246#else
247
254 bool columnHidden( int column ) const;
255 % MethodCode
256 {
257 if ( a0 < 0 || a0 >= sipCpp->size() )
258 {
259 PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
260 sipIsErr = 1;
261 }
262 else
263 {
264 return PyBool_FromLong( sipCpp->columnHidden( a0 ) );
265 }
266 }
267 % End
268#endif
269
270#ifndef SIP_RUN
271
278 void setColumnHidden( int column, bool hidden );
279#else
280
288 void setColumnHidden( int column, bool hidden );
289 % MethodCode
290 if ( a0 < 0 || a0 >= sipCpp->size() )
291 {
292 PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
293 sipIsErr = 1;
294 }
295 else
296 {
297 sipCpp->setColumnHidden( a0, a1 );
298 }
299 % End
300#endif
301
305 Qt::SortOrder sortOrder() const;
306
310 void setSortOrder( Qt::SortOrder sortOrder );
311
316 bool hasSameColumns( const QgsAttributeTableConfig &other ) const;
317
321 bool operator!= ( const QgsAttributeTableConfig &other ) const;
322
323 private:
324 QVector<ColumnConfig> mColumns;
325 ActionWidgetStyle mActionWidgetStyle = DropDown;
326 QString mSortExpression;
327 Qt::SortOrder mSortOrder = Qt::AscendingOrder;
328};
329
331
332#endif // QGSATTRIBUTETABLECONFIG_H
This is a container for configuration of the attribute table.
Type
The type of an attribute table column.
@ Field
This column represents a field.
ActionWidgetStyle
The style of the action widget in the attribute table.
@ ButtonList
A list of buttons.
QgsAttributeTableConfig()=default
Constructor for QgsAttributeTableConfig.
Container of fields for a vector layer.
Definition: qgsfields.h:45
#define SIP_SKIP
Definition: qgis_sip.h:126
Q_DECLARE_METATYPE(QgsDatabaseQueryLogEntry)
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
bool operator!=(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
Defines the configuration of a column in the attribute table.
ColumnConfig()=default
Constructor for ColumnConfig.
QString name
The name of the attribute if this column represents a field.