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