QGIS API Documentation  3.21.0-Master (3191652dc5)
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 
57  // TODO c++20 - replace with = default
59 
62 
64  QString name;
65 
67  bool hidden = false;
68 
70  int width = -1;
71  };
72 
77  {
79  DropDown
80  };
81 
86 
91  QVector<QgsAttributeTableConfig::ColumnConfig> columns() const;
92 
96  bool isEmpty() const;
97 
103  int mapVisibleColumnToIndex( int visibleColumn ) const;
104 
109  void setColumns( const QVector<QgsAttributeTableConfig::ColumnConfig> &columns );
110 
117  void update( const QgsFields &fields );
118 
122  bool actionWidgetVisible() const;
123 
127  void setActionWidgetVisible( bool visible );
128 
132  ActionWidgetStyle actionWidgetStyle() const;
133 
137  void setActionWidgetStyle( ActionWidgetStyle actionWidgetStyle );
138 
142  void writeXml( QDomNode &node ) const;
143 
147  void readXml( const QDomNode &node );
148 
152  QString sortExpression() const;
153 
157  void setSortExpression( const QString &sortExpression );
158 
164  int columnWidth( int column ) const;
165 
172  void setColumnWidth( int column, int width );
173 
179  bool columnHidden( int column ) const;
180 
187  void setColumnHidden( int column, bool hidden );
188 
193  Qt::SortOrder sortOrder() const;
194 
199  void setSortOrder( Qt::SortOrder sortOrder );
200 
205  bool hasSameColumns( const QgsAttributeTableConfig &other ) const;
206 
210  bool operator!= ( const QgsAttributeTableConfig &other ) const;
211 
212  private:
213  QVector<ColumnConfig> mColumns;
214  ActionWidgetStyle mActionWidgetStyle = DropDown;
215  QString mSortExpression;
216  Qt::SortOrder mSortOrder = Qt::AscendingOrder;
217 };
218 
220 
221 #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.