QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
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 
23 #include "qgsfield.h"
24 
31 class CORE_EXPORT QgsAttributeTableConfig
32 {
33  public:
37  enum Type
38  {
40  Action
41  };
42 
46  struct ColumnConfig
47  {
50  : type( Field )
51  , hidden( false )
52  , width( -1 )
53  {}
54 
55  bool operator== ( const ColumnConfig& other ) const;
56 
59  bool hidden;
60  int width;
61  };
62 
67  {
69  DropDown
70  };
71 
73 
78  QVector<ColumnConfig> columns() const;
79 
82  bool isEmpty() const;
83 
88  int mapVisibleColumnToIndex( int visibleColumn ) const;
89 
94  void setColumns( const QVector<ColumnConfig>& columns );
95 
102  void update( const QgsFields& fields );
103 
107  bool actionWidgetVisible() const;
108 
112  void setActionWidgetVisible( bool visible );
113 
117  ActionWidgetStyle actionWidgetStyle() const;
118 
122  void setActionWidgetStyle( const ActionWidgetStyle& actionWidgetStyle );
123 
127  void writeXml( QDomNode& node ) const;
128 
132  void readXml( const QDomNode& node );
133 
137  QString sortExpression() const;
138 
142  void setSortExpression( const QString& sortExpression );
143 
148  int columnWidth( int column ) const;
149 
155  void setColumnWidth( int column, int width );
156 
161  bool columnHidden( int column ) const;
162 
168  void setColumnHidden( int column, bool hidden );
169 
174  Qt::SortOrder sortOrder() const;
175 
180  void setSortOrder( const Qt::SortOrder& sortOrder );
181 
185  bool operator!= ( const QgsAttributeTableConfig& other ) const;
186 
187  private:
188  QVector<ColumnConfig> mColumns;
189  ActionWidgetStyle mActionWidgetStyle;
190  QString mSortExpression;
191  Qt::SortOrder mSortOrder;
192 };
193 
195 
196 #endif // QGSATTRIBUTETABLECONFIG_H
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
bool operator!=(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
Q_DECLARE_METATYPE(QgsMimeDataUtils::UriList)
Container of fields for a vector layer.
Definition: qgsfield.h:252
ActionWidgetStyle
The style of the action widget in the attribute table.
bool hidden
Flag that controls if the column is hidden.
QString name
The name of the attribute if this column represents a field.
int width
Width of column, or -1 for default width.
Type
The type of an attribute table column.
This column represents a field.
Defines the configuration of a column in the attribute table.
This is a container for configuration of the attribute table.
ColumnConfig()
Constructor for ColumnConfig.