QGIS API Documentation  3.8.0-Zanzibar (11aff65)
qgsattributetableview.h
Go to the documentation of this file.
1 /***************************************************************************
2  QgsAttributeTableView.h
3  --------------------------------------
4  Date : Feb 2009
5  Copyright : (C) 2009 Vita Cizek
6  Email : weetya (at) gmail.com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #ifndef QGSATTRIBUTETABLEVIEW_H
17 #define QGSATTRIBUTETABLEVIEW_H
18 
19 #include <QTableView>
20 #include <QAction>
21 #include "qgsfeatureid.h"
22 
23 #include "qgis_gui.h"
25 
31 class QgsMapCanvas;
32 class QgsVectorLayer;
34 class QMenu;
35 class QProgressDialog;
37 class QgsFeature;
38 
48 class GUI_EXPORT QgsAttributeTableView : public QTableView
49 {
50  Q_OBJECT
51 
52  public:
53 
55  QgsAttributeTableView( QWidget *parent SIP_TRANSFERTHIS = nullptr );
56 
57  virtual void setModel( QgsAttributeTableFilterModel *filterModel );
58 
63  void setFeatureSelectionManager( QgsIFeatureSelectionManager *featureSelectionManager SIP_TRANSFER );
64 
75  bool eventFilter( QObject *object, QEvent *event ) override;
76 
82  void setAttributeTableConfig( const QgsAttributeTableConfig &config );
83 
89  QList<QgsFeatureId> selectedFeaturesIds() const;
90 
91  protected:
92 
99  void mousePressEvent( QMouseEvent *event ) override;
100 
107  void mouseReleaseEvent( QMouseEvent *event ) override;
108 
115  void mouseMoveEvent( QMouseEvent *event ) override;
116 
123  void keyPressEvent( QKeyEvent *event ) override;
124 
132  void contextMenuEvent( QContextMenuEvent *event ) override;
133 
138  void closeEvent( QCloseEvent *event ) override;
139 
140  signals:
141 
150  void willShowContextMenu( QMenu *menu, const QModelIndex &atIndex );
151 
158  void columnResized( int column, int width );
159 
160  void finished();
161 
162  public slots:
163  void repaintRequested( const QModelIndexList &indexes );
164  void repaintRequested();
165  void selectAll() override;
166  virtual void selectRow( int row );
167  virtual void _q_selectRow( int row );
168 
169  private slots:
170  void modelDeleted();
171  void showHorizontalSortIndicator();
172  void actionTriggered();
173  void columnSizeChanged( int index, int oldWidth, int newWidth );
174  void onActionColumnItemPainted( const QModelIndex &index );
175  void recreateActionWidgets();
176 
177  private:
178  void updateActionImage( QWidget *widget );
179  QWidget *createActionWidget( QgsFeatureId fid );
180 
181  void selectRow( int row, bool anchor );
182  QgsAttributeTableFilterModel *mFilterModel = nullptr;
183  QgsFeatureSelectionModel *mFeatureSelectionModel = nullptr;
184  QgsIFeatureSelectionManager *mFeatureSelectionManager = nullptr;
185  QgsAttributeTableDelegate *mTableDelegate = nullptr;
186  QMenu *mActionPopup = nullptr;
187  int mRowSectionAnchor = 0;
188  QItemSelectionModel::SelectionFlag mCtrlDragSelectionFlag = QItemSelectionModel::Select;
189  QMap< QModelIndex, QWidget * > mActionWidgets;
190  QgsAttributeTableConfig mConfig;
191 };
192 
193 #endif
Provides a table view of features of a QgsVectorLayer.
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:46
qint64 QgsFeatureId
Definition: qgsfeatureid.h:25
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:55
A model backed by a QgsVectorLayerCache which is able to provide feature/attribute information to a Q...
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:73
#define SIP_TRANSFER
Definition: qgis_sip.h:36
This class caches features of a given QgsVectorLayer.
A delegate item class for QgsAttributeTable (see Qt documentation for QItemDelegate).
This is a container for configuration of the attribute table.
Is an interface class to abstract feature selection handling.
Represents a vector layer which manages a vector based data sets.