QGIS API Documentation  2.17.0-Master (3a3b9ab7)
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 
29 class QgsMapCanvas;
30 class QgsVectorLayer;
32 class QMenu;
33 class QProgressDialog;
35 
44 class GUI_EXPORT QgsAttributeTableView : public QTableView
45 {
46  Q_OBJECT
47 
48  public:
49  QgsAttributeTableView( QWidget* parent = nullptr );
50 
51  virtual void setModel( QgsAttributeTableFilterModel* filterModel );
52 
57  void setFeatureSelectionManager( QgsIFeatureSelectionManager* featureSelectionManager );
58 
69  virtual bool eventFilter( QObject* object, QEvent* event ) override;
70 
76  void setAttributeTableConfig( const QgsAttributeTableConfig& config );
77 
78  protected:
85  void mousePressEvent( QMouseEvent *event ) override;
86 
93  void mouseReleaseEvent( QMouseEvent *event ) override;
94 
101  void mouseMoveEvent( QMouseEvent *event ) override;
102 
109  void keyPressEvent( QKeyEvent *event ) override;
110 
118  void contextMenuEvent( QContextMenuEvent* event ) override;
119 
124  void closeEvent( QCloseEvent *event ) override;
125 
126  signals:
135  void willShowContextMenu( QMenu* menu, const QModelIndex& atIndex );
136 
142  void columnResized( int column, int width );
143 
144  void finished();
145 
146  public slots:
147  void repaintRequested( const QModelIndexList& indexes );
148  void repaintRequested();
149  virtual void selectAll() override;
150  virtual void selectRow( int row );
151  virtual void _q_selectRow( int row );
152 
153  private slots:
154  void modelDeleted();
155  void showHorizontalSortIndicator();
156  void actionTriggered();
157  void columnSizeChanged( int index, int oldWidth, int newWidth );
158  void onActionColumnItemPainted( const QModelIndex& index );
159  void recreateActionWidgets();
160 
161  private:
162  void updateActionImage( QWidget* widget );
163  QWidget* createActionWidget( QgsFeatureId fid );
164 
165  void selectRow( int row, bool anchor );
166  QgsAttributeTableFilterModel* mFilterModel;
167  QgsFeatureSelectionModel* mFeatureSelectionModel;
168  QgsIFeatureSelectionManager* mFeatureSelectionManager;
169  QgsAttributeTableDelegate* mTableDelegate;
170  QMenu *mActionPopup;
171  int mRowSectionAnchor;
172  QItemSelectionModel::SelectionFlag mCtrlDragSelectionFlag;
173  QMap< QModelIndex, QWidget* > mActionWidgets;
174 };
175 
176 #endif
static unsigned index
Provides a table view of features of a QgsVectorLayer.
void columnResized(int column, int oldWidth, int newWidth)
A model backed by a QgsVectorLayerCache which is able to provide feature/attribute information to a Q...
virtual void mouseReleaseEvent(QMouseEvent *event)
virtual void contextMenuEvent(QContextMenuEvent *e)
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:109
virtual void setModel(QAbstractItemModel *model)
virtual bool eventFilter(QObject *watched, QEvent *event)
This class caches features of a given QgsVectorLayer.
virtual void mouseMoveEvent(QMouseEvent *event)
virtual void selectAll()
virtual void mousePressEvent(QMouseEvent *event)
A delegate item class for QgsAttributeTable (see Qt documentation for QItemDelegate).
qint64 QgsFeatureId
Definition: qgsfeature.h:31
virtual void keyPressEvent(QKeyEvent *event)
virtual void closeEvent(QCloseEvent *event)
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.
void selectRow(int row)