QGIS API Documentation  3.14.0-Pi (9f7028fd23)
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 
92  protected:
93 
100  void mousePressEvent( QMouseEvent *event ) override;
101 
108  void mouseReleaseEvent( QMouseEvent *event ) override;
109 
116  void mouseMoveEvent( QMouseEvent *event ) override;
117 
124  void keyPressEvent( QKeyEvent *event ) override;
125 
133  void contextMenuEvent( QContextMenuEvent *event ) override;
134 
139  void closeEvent( QCloseEvent *event ) override;
140 
141  signals:
142 
151  void willShowContextMenu( QMenu *menu, const QModelIndex &atIndex );
152 
159  void columnResized( int column, int width );
160 
161  void finished();
162 
163  public slots:
164  void repaintRequested( const QModelIndexList &indexes );
165  void repaintRequested();
166  void selectAll() override;
167  virtual void selectRow( int row );
168  virtual void _q_selectRow( int row );
169 
170  private slots:
171  void modelDeleted();
172  void showHorizontalSortIndicator();
173  void actionTriggered();
174  void columnSizeChanged( int index, int oldWidth, int newWidth );
175  void onActionColumnItemPainted( const QModelIndex &index );
176  void recreateActionWidgets();
177 
178  private:
179  void updateActionImage( QWidget *widget );
180  QWidget *createActionWidget( QgsFeatureId fid );
181 
182  void selectRow( int row, bool anchor );
183  QgsAttributeTableFilterModel *mFilterModel = nullptr;
184  QgsFeatureSelectionModel *mFeatureSelectionModel = nullptr;
185  QgsIFeatureSelectionManager *mOwnedFeatureSelectionManager = nullptr;
186  QgsIFeatureSelectionManager *mFeatureSelectionManager = nullptr;
187  QgsAttributeTableDelegate *mTableDelegate = nullptr;
188  QMenu *mActionPopup = nullptr;
189  int mRowSectionAnchor = 0;
190  QItemSelectionModel::SelectionFlag mCtrlDragSelectionFlag = QItemSelectionModel::Select;
191  QMap< QModelIndex, QWidget * > mActionWidgets;
192  QgsAttributeTableConfig mConfig;
193 };
194 
195 #endif
QgsVectorLayerCache
The cached features can be indexed by QgsAbstractCacheIndex.
Definition: qgsvectorlayercache.h:45
QgsFeatureSelectionModel
Definition: qgsfeatureselectionmodel.h:31
QgsMapCanvas
Definition: qgsmapcanvas.h:83
qgsfeatureid.h
QgsAttributeTableConfig
Definition: qgsattributetableconfig.h:36
QgsAttributeTableModel
Is able to generate editor widgets for its QModelIndexes as well. Is mostly referred to as "master mo...
Definition: qgsattributetablemodel.h:49
QgsAttributeTableFilterModel
Definition: qgsattributetablefiltermodel.h:35
QgsAttributeTableDelegate
Definition: qgsattributetabledelegate.h:35
QgsVectorLayer
Definition: qgsvectorlayer.h:385
qgsattributetableconfig.h
QgsFeature
Definition: qgsfeature.h:55
QgsIFeatureSelectionManager
Definition: qgsifeatureselectionmanager.h:31
QgsAttributeTableView
Provides a table view of features of a QgsVectorLayer.
Definition: qgsattributetableview.h:48
SIP_TRANSFERTHIS
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
QgsFeatureId
qint64 QgsFeatureId
Definition: qgsfeatureid.h:25