QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
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 #include "qgsfeatureid.h"
22 
23 #include "qgis_gui.h"
25 
31 class QgsMapCanvas;
32 class QgsVectorLayer;
34 class QMenu;
35 class QProgressDialog;
37 class QgsFeature;
38 
48 class GUI_EXPORT QgsAttributeTableView : public QTableView
49 {
50  Q_OBJECT
51 
52  public:
53 
55  QgsAttributeTableView( QWidget *parent SIP_TRANSFERTHIS = nullptr );
56 
57  virtual void setModel( QgsAttributeTableFilterModel *filterModel );
58 
63  void setFeatureSelectionManager( QgsIFeatureSelectionManager *featureSelectionManager );
64 
75  bool eventFilter( QObject *object, QEvent *event ) override;
76 
82  void setAttributeTableConfig( const QgsAttributeTableConfig &config );
83 
89  QList<QgsFeatureId> selectedFeaturesIds() const;
90 
91 
99  void scrollToFeature( const QgsFeatureId &fid, int column = -1 );
100 
101 
102  protected:
103 
110  void mousePressEvent( QMouseEvent *event ) override;
111 
118  void mouseReleaseEvent( QMouseEvent *event ) override;
119 
126  void mouseMoveEvent( QMouseEvent *event ) override;
127 
134  void keyPressEvent( QKeyEvent *event ) override;
135 
143  void contextMenuEvent( QContextMenuEvent *event ) override;
144 
149  void closeEvent( QCloseEvent *event ) override;
150 
151  signals:
152 
161  void willShowContextMenu( QMenu *menu, const QModelIndex &atIndex );
162 
169  void columnResized( int column, int width );
170 
171  void finished();
172 
173  public slots:
174  void repaintRequested( const QModelIndexList &indexes );
175  void repaintRequested();
176  void selectAll() override;
177  virtual void selectRow( int row );
178  virtual void _q_selectRow( int row );
179 
180  private slots:
181  void modelDeleted();
182  void showHorizontalSortIndicator();
183  void actionTriggered();
184  void columnSizeChanged( int index, int oldWidth, int newWidth );
185  void onActionColumnItemPainted( const QModelIndex &index );
186  void recreateActionWidgets();
187 
188  private:
189  void updateActionImage( QWidget *widget );
190  QWidget *createActionWidget( QgsFeatureId fid );
191 
192  void selectRow( int row, bool anchor );
193  QgsAttributeTableFilterModel *mFilterModel = nullptr;
194  QgsFeatureSelectionModel *mFeatureSelectionModel = nullptr;
195  QgsIFeatureSelectionManager *mOwnedFeatureSelectionManager = nullptr;
196  QgsIFeatureSelectionManager *mFeatureSelectionManager = nullptr;
197  QgsAttributeTableDelegate *mTableDelegate = nullptr;
198  QMenu *mActionPopup = nullptr;
199  int mRowSectionAnchor = 0;
200  QItemSelectionModel::SelectionFlag mCtrlDragSelectionFlag = QItemSelectionModel::Select;
201  QMap< QModelIndex, QWidget * > mActionWidgets;
202  QgsAttributeTableConfig mConfig;
203 };
204 
205 #endif
QgsVectorLayerCache
This class caches features of a given QgsVectorLayer.
Definition: qgsvectorlayercache.h:46
QgsFeatureSelectionModel
Definition: qgsfeatureselectionmodel.h:32
QgsAttributeTableView::finished
void finished()
QgsMapCanvas
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:85
qgsfeatureid.h
QgsAttributeTableConfig
This is a container for configuration of the attribute table.
Definition: qgsattributetableconfig.h:37
QgsAttributeTableModel
A model backed by a QgsVectorLayerCache which is able to provide feature/attribute information to a Q...
Definition: qgsattributetablemodel.h:50
QgsAttributeTableFilterModel
Definition: qgsattributetablefiltermodel.h:36
QgsAttributeTableDelegate
A delegate item class for QgsAttributeTable (see Qt documentation for QItemDelegate).
Definition: qgsattributetabledelegate.h:36
QgsVectorLayer
Represents a vector layer which manages a vector based data sets.
Definition: qgsvectorlayer.h:387
qgsattributetableconfig.h
QgsFeature
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:56
QgsAttributeTableView::willShowContextMenu
void willShowContextMenu(QMenu *menu, const QModelIndex &atIndex)
Emitted in order to provide a hook to add additional* menu entries to the context menu.
QgsIFeatureSelectionManager
Is an interface class to abstract feature selection handling.
Definition: qgsifeatureselectionmanager.h:32
QgsAttributeTableView
Provides a table view of features of a QgsVectorLayer.
Definition: qgsattributetableview.h:49
SIP_TRANSFERTHIS
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
QgsAttributeTableView::columnResized
void columnResized(int column, int width)
Emitted when a column in the view has been resized.
QgsFeatureId
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features
Definition: qgsfeatureid.h:28