QGIS API Documentation  3.14.0-Pi (9f7028fd23)
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 
77  QgsAttributeTableConfig() = default;
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
operator==
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
Definition: qgsfeatureiterator.h:399
QgsAttributeTableConfig::ActionWidgetStyle
ActionWidgetStyle
The style of the action widget in the attribute table.
Definition: qgsattributetableconfig.h:68
QgsFields
Definition: qgsfields.h:44
QgsAttributeTableConfig::ColumnConfig
Defines the configuration of a column in the attribute table.
Definition: qgsattributetableconfig.h:52
QgsAttributeTableConfig::ButtonList
@ ButtonList
A list of buttons.
Definition: qgsattributetableconfig.h:70
operator!=
bool operator!=(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
Definition: qgsfeatureiterator.h:404
QgsAttributeTableConfig::Field
@ Field
This column represents a field.
Definition: qgsattributetableconfig.h:45
Q_DECLARE_METATYPE
Q_DECLARE_METATYPE(QgsMeshTimeSettings)
QgsAttributeTableConfig
Definition: qgsattributetableconfig.h:36
SIP_SKIP
#define SIP_SKIP
Definition: qgis_sip.h:126
qgis_sip.h
QgsAttributeTableConfig::Type
Type
The type of an attribute table column.
Definition: qgsattributetableconfig.h:43
QgsAttributeTableConfig::ColumnConfig::name
QString name
The name of the attribute if this column represents a field.
Definition: qgsattributetableconfig.h:60