QGIS API Documentation  2.99.0-Master (314842d)
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 
22 #include "qgsfeature.h" // For QgsFeatureIds
23 #include "qgis_gui.h"
24 
30 class QgsMapCanvas;
31 class QgsVectorLayer;
33 class QMenu;
34 class QProgressDialog;
36 
45 class GUI_EXPORT QgsAttributeTableView : public QTableView
46 {
47  Q_OBJECT
48 
49  public:
50  QgsAttributeTableView( QWidget *parent = nullptr );
51 
52  virtual void setModel( QgsAttributeTableFilterModel *filterModel );
53 
58  void setFeatureSelectionManager( QgsIFeatureSelectionManager *featureSelectionManager );
59 
70  virtual bool eventFilter( QObject *object, QEvent *event ) override;
71 
77  void setAttributeTableConfig( const QgsAttributeTableConfig &config );
78 
79  protected:
80 
87  void mousePressEvent( QMouseEvent *event ) override;
88 
95  void mouseReleaseEvent( QMouseEvent *event ) override;
96 
103  void mouseMoveEvent( QMouseEvent *event ) override;
104 
111  void keyPressEvent( QKeyEvent *event ) override;
112 
120  void contextMenuEvent( QContextMenuEvent *event ) override;
121 
126  void closeEvent( QCloseEvent *event ) override;
127 
128  signals:
129 
138  void willShowContextMenu( QMenu *menu, const QModelIndex &atIndex );
139 
145  void columnResized( int column, int width );
146 
147  void finished();
148 
149  public slots:
150  void repaintRequested( const QModelIndexList &indexes );
151  void repaintRequested();
152  virtual void selectAll() override;
153  virtual void selectRow( int row );
154  virtual void _q_selectRow( int row );
155 
156  private slots:
157  void modelDeleted();
158  void showHorizontalSortIndicator();
159  void actionTriggered();
160  void columnSizeChanged( int index, int oldWidth, int newWidth );
161  void onActionColumnItemPainted( const QModelIndex &index );
162  void recreateActionWidgets();
163 
164  private:
165  void updateActionImage( QWidget *widget );
166  QWidget *createActionWidget( QgsFeatureId fid );
167 
168  void selectRow( int row, bool anchor );
169  QgsAttributeTableFilterModel *mFilterModel = nullptr;
170  QgsFeatureSelectionModel *mFeatureSelectionModel = nullptr;
171  QgsIFeatureSelectionManager *mFeatureSelectionManager = nullptr;
172  QgsAttributeTableDelegate *mTableDelegate = nullptr;
173  QMenu *mActionPopup = nullptr;
174  int mRowSectionAnchor;
175  QItemSelectionModel::SelectionFlag mCtrlDragSelectionFlag;
176  QMap< QModelIndex, QWidget * > mActionWidgets;
177 };
178 
179 #endif
static unsigned index
Provides a table view of features of a QgsVectorLayer.
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:72
This class caches features of a given QgsVectorLayer.
A delegate item class for QgsAttributeTable (see Qt documentation for QItemDelegate).
qint64 QgsFeatureId
Definition: qgsfeature.h:33
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.