QGIS API Documentation  3.20.0-Odense (decaadbb31)
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
7  email : [email protected]
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 
27 class QgsFields;
28 
36 class CORE_EXPORT QgsAttributeTableConfig
37 {
38  public:
39 
43  enum Type
44  {
46  Action
47  };
48 
52  struct ColumnConfig
53  {
55  ColumnConfig() = default;
56 
58 
60  QString name;
61  bool hidden = false;
62  int width = -1;
63  };
64 
69  {
71  DropDown
72  };
73 
78 
83  QVector<QgsAttributeTableConfig::ColumnConfig> columns() const;
84 
88  bool isEmpty() const;
89 
95  int mapVisibleColumnToIndex( int visibleColumn ) const;
96 
101  void setColumns( const QVector<QgsAttributeTableConfig::ColumnConfig> &columns );
102 
109  void update( const QgsFields &fields );
110 
114  bool actionWidgetVisible() const;
115 
119  void setActionWidgetVisible( bool visible );
120 
124  ActionWidgetStyle actionWidgetStyle() const;
125 
129  void setActionWidgetStyle( ActionWidgetStyle actionWidgetStyle );
130 
134  void writeXml( QDomNode &node ) const;
135 
139  void readXml( const QDomNode &node );
140 
144  QString sortExpression() const;
145 
149  void setSortExpression( const QString &sortExpression );
150 
156  int columnWidth( int column ) const;
157 
164  void setColumnWidth( int column, int width );
165 
171  bool columnHidden( int column ) const;
172 
179  void setColumnHidden( int column, bool hidden );
180 
185  Qt::SortOrder sortOrder() const;
186 
191  void setSortOrder( Qt::SortOrder sortOrder );
192 
197  bool hasSameColumns( const QgsAttributeTableConfig &other ) const;
198 
202  bool operator!= ( const QgsAttributeTableConfig &other ) const;
203 
204  private:
205  QVector<ColumnConfig> mColumns;
206  ActionWidgetStyle mActionWidgetStyle = DropDown;
207  QString mSortExpression;
208  Qt::SortOrder mSortOrder = Qt::AscendingOrder;
209 };
210 
212 
213 #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
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
bool operator!=(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
Q_DECLARE_METATYPE(QgsMeshTimeSettings)
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.