QGIS API Documentation  2.99.0-Master (b058df7)
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  QgsAttributeTableView( QWidget *parent SIP_TRANSFERTHIS = 0 );
53 
54  virtual void setModel( QgsAttributeTableFilterModel *filterModel );
55 
60  void setFeatureSelectionManager( QgsIFeatureSelectionManager *featureSelectionManager SIP_TRANSFER );
61 
72  virtual bool eventFilter( QObject *object, QEvent *event ) override;
73 
79  void setAttributeTableConfig( const QgsAttributeTableConfig &config );
80 
81  protected:
82 
89  void mousePressEvent( QMouseEvent *event ) override;
90 
97  void mouseReleaseEvent( QMouseEvent *event ) override;
98 
105  void mouseMoveEvent( QMouseEvent *event ) override;
106 
113  void keyPressEvent( QKeyEvent *event ) override;
114 
122  void contextMenuEvent( QContextMenuEvent *event ) override;
123 
128  void closeEvent( QCloseEvent *event ) override;
129 
130  signals:
131 
140  void willShowContextMenu( QMenu *menu, const QModelIndex &atIndex );
141 
148  void columnResized( int column, int width );
149 
150  void finished();
151 
152  public slots:
153  void repaintRequested( const QModelIndexList &indexes );
154  void repaintRequested();
155  virtual void selectAll() override;
156  virtual void selectRow( int row );
157  virtual void _q_selectRow( int row );
158 
159  private slots:
160  void modelDeleted();
161  void showHorizontalSortIndicator();
162  void actionTriggered();
163  void columnSizeChanged( int index, int oldWidth, int newWidth );
164  void onActionColumnItemPainted( const QModelIndex &index );
165  void recreateActionWidgets();
166 
167  private:
168  void updateActionImage( QWidget *widget );
169  QWidget *createActionWidget( QgsFeatureId fid );
170 
171  void selectRow( int row, bool anchor );
172  QgsAttributeTableFilterModel *mFilterModel = nullptr;
173  QgsFeatureSelectionModel *mFeatureSelectionModel = nullptr;
174  QgsIFeatureSelectionManager *mFeatureSelectionManager = nullptr;
175  QgsAttributeTableDelegate *mTableDelegate = nullptr;
176  QMenu *mActionPopup = nullptr;
177  int mRowSectionAnchor = 0;
178  QItemSelectionModel::SelectionFlag mCtrlDragSelectionFlag = QItemSelectionModel::Select;
179  QMap< QModelIndex, QWidget * > mActionWidgets;
180 };
181 
182 #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.