QGIS API Documentation 3.41.0-Master (3440c17df1d)
Loading...
Searching...
No Matches
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
51 struct CORE_EXPORT ColumnConfig
52 {
53 ColumnConfig() = default;
54
55 // TODO c++20 - replace with = default
57
60
62 QString name;
63
65 bool hidden = false;
66
68 int width = -1;
69 };
70
75 {
77 DropDown
78 };
79
81
86 QVector<QgsAttributeTableConfig::ColumnConfig> columns() const;
87
93 bool isEmpty() const;
94
100 int size() const;
101
102#ifdef SIP_RUN
103 int __len__() const;
104 % MethodCode
105 sipRes = sipCpp->size();
106 % End
107#endif
108
114 int mapVisibleColumnToIndex( int visibleColumn ) const;
115
120 void setColumns( const QVector<QgsAttributeTableConfig::ColumnConfig> &columns );
121
128 void update( const QgsFields &fields );
129
133 bool actionWidgetVisible() const;
134
138 void setActionWidgetVisible( bool visible );
139
143 ActionWidgetStyle actionWidgetStyle() const;
144
148 void setActionWidgetStyle( ActionWidgetStyle actionWidgetStyle );
149
153 void writeXml( QDomNode &node ) const;
154
158 void readXml( const QDomNode &node );
159
163 QString sortExpression() const;
164
168 void setSortExpression( const QString &sortExpression );
169
170#ifndef SIP_RUN
171
177 int columnWidth( int column ) const;
178#else
179
186 int columnWidth( int column ) const;
187 % MethodCode
188 {
189 if ( a0 < 0 || a0 >= sipCpp->size() )
190 {
191 PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
192 sipIsErr = 1;
193 }
194 else
195 {
196 return PyLong_FromLong( sipCpp->columnWidth( a0 ) );
197 }
198 }
199 % End
200#endif
201
202#ifndef SIP_RUN
203
210 void setColumnWidth( int column, int width );
211#else
212
220 void setColumnWidth( int column, int width );
221 % MethodCode
222 if ( a0 < 0 || a0 >= sipCpp->size() )
223 {
224 PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
225 sipIsErr = 1;
226 }
227 else
228 {
229 sipCpp->setColumnWidth( a0, a1 );
230 }
231 % End
232#endif
233
234#ifndef SIP_RUN
235
241 bool columnHidden( int column ) const;
242#else
243
250 bool columnHidden( int column ) const;
251 % MethodCode
252 {
253 if ( a0 < 0 || a0 >= sipCpp->size() )
254 {
255 PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
256 sipIsErr = 1;
257 }
258 else
259 {
260 return PyBool_FromLong( sipCpp->columnHidden( a0 ) );
261 }
262 }
263 % End
264#endif
265
266#ifndef SIP_RUN
267
274 void setColumnHidden( int column, bool hidden );
275#else
276
284 void setColumnHidden( int column, bool hidden );
285 % MethodCode
286 if ( a0 < 0 || a0 >= sipCpp->size() )
287 {
288 PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
289 sipIsErr = 1;
290 }
291 else
292 {
293 sipCpp->setColumnHidden( a0, a1 );
294 }
295 % End
296#endif
297
301 Qt::SortOrder sortOrder() const;
302
306 void setSortOrder( Qt::SortOrder sortOrder );
307
312 bool hasSameColumns( const QgsAttributeTableConfig &other ) const;
313
314 bool operator!= ( const QgsAttributeTableConfig &other ) const;
315
316 private:
317 QVector<ColumnConfig> mColumns;
318 ActionWidgetStyle mActionWidgetStyle = DropDown;
319 QString mSortExpression;
320 Qt::SortOrder mSortOrder = Qt::AscendingOrder;
321};
322
324
325#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.
QgsAttributeTableConfig()=default
Container of fields for a vector layer.
Definition qgsfields.h:46
#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.
QString name
The name of the attribute if this column represents a field.