QGIS API Documentation  3.2.0-Bonn (bc43194)
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 
47 class GUI_EXPORT QgsAttributeTableView : public QTableView
48 {
49  Q_OBJECT
50 
51  public:
52 
54  QgsAttributeTableView( QWidget *parent SIP_TRANSFERTHIS = nullptr );
55 
56  virtual void setModel( QgsAttributeTableFilterModel *filterModel );
57 
62  void setFeatureSelectionManager( QgsIFeatureSelectionManager *featureSelectionManager SIP_TRANSFER );
63 
74  bool eventFilter( QObject *object, QEvent *event ) override;
75 
81  void setAttributeTableConfig( const QgsAttributeTableConfig &config );
82 
83  protected:
84 
91  void mousePressEvent( QMouseEvent *event ) override;
92 
99  void mouseReleaseEvent( QMouseEvent *event ) override;
100 
107  void mouseMoveEvent( QMouseEvent *event ) override;
108 
115  void keyPressEvent( QKeyEvent *event ) override;
116 
124  void contextMenuEvent( QContextMenuEvent *event ) override;
125 
130  void closeEvent( QCloseEvent *event ) override;
131 
132  signals:
133 
142  void willShowContextMenu( QMenu *menu, const QModelIndex &atIndex );
143 
150  void columnResized( int column, int width );
151 
152  void finished();
153 
154  public slots:
155  void repaintRequested( const QModelIndexList &indexes );
156  void repaintRequested();
157  void selectAll() override;
158  virtual void selectRow( int row );
159  virtual void _q_selectRow( int row );
160 
161  private slots:
162  void modelDeleted();
163  void showHorizontalSortIndicator();
164  void actionTriggered();
165  void columnSizeChanged( int index, int oldWidth, int newWidth );
166  void onActionColumnItemPainted( const QModelIndex &index );
167  void recreateActionWidgets();
168 
169  private:
170  void updateActionImage( QWidget *widget );
171  QWidget *createActionWidget( QgsFeatureId fid );
172 
173  void selectRow( int row, bool anchor );
174  QgsAttributeTableFilterModel *mFilterModel = nullptr;
175  QgsFeatureSelectionModel *mFeatureSelectionModel = nullptr;
176  QgsIFeatureSelectionManager *mFeatureSelectionManager = nullptr;
177  QgsAttributeTableDelegate *mTableDelegate = nullptr;
178  QMenu *mActionPopup = nullptr;
179  int mRowSectionAnchor = 0;
180  QItemSelectionModel::SelectionFlag mCtrlDragSelectionFlag = QItemSelectionModel::Select;
181  QMap< QModelIndex, QWidget * > mActionWidgets;
182 };
183 
184 #endif
Provides a table view of features of a QgsVectorLayer.
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:46
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:74
#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).
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.