QGIS API Documentation 3.99.0-Master (21b3aa880ba)
Loading...
Searching...
No Matches
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 "qgis_gui.h"
21#include "qgsfeatureid.h"
22#include "qgstableview.h"
23
24#include <QAction>
25
31class QgsMapCanvas;
32class QgsVectorLayer;
34class QMenu;
35class QProgressDialog;
37class QgsFeature;
38
47
48class GUI_EXPORT QgsAttributeTableView : public QgsTableView
49{
50 Q_OBJECT
51
52 public:
54 QgsAttributeTableView( QWidget *parent SIP_TRANSFERTHIS = nullptr );
55
56#ifdef __clang__
57#pragma clang diagnostic push
58#pragma clang diagnostic ignored "-Woverloaded-virtual"
59#endif
60 virtual void setModel( QgsAttributeTableFilterModel *filterModel );
61#ifdef __clang__
62#pragma clang diagnostic pop
63#endif
64
69 void setFeatureSelectionManager( QgsIFeatureSelectionManager *featureSelectionManager );
70
81 bool eventFilter( QObject *object, QEvent *event ) override;
82
88
94 QList<QgsFeatureId> selectedFeaturesIds() const;
95
103 void scrollToFeature( const QgsFeatureId &fid, int column = -1 );
104
110 void closeCurrentEditor();
111
112 protected:
113
120 void mousePressEvent( QMouseEvent *event ) override;
121
128 void mouseReleaseEvent( QMouseEvent *event ) override;
129
136 void mouseMoveEvent( QMouseEvent *event ) override;
137
144 void keyPressEvent( QKeyEvent *event ) override;
145
153 void contextMenuEvent( QContextMenuEvent *event ) override;
154
159 void closeEvent( QCloseEvent *event ) override;
160
161 signals:
162
170 void willShowContextMenu( QMenu *menu, const QModelIndex &atIndex );
171
177 void columnResized( int column, int width );
178
182 Q_DECL_DEPRECATED void finished() SIP_DEPRECATED;
183
190
191 public slots:
192 void repaintRequested( const QModelIndexList &indexes );
193 void repaintRequested();
194 void selectAll() override;
195 virtual void selectRow( int row );
196 virtual void _q_selectRow( int row );
197
198 private slots:
199 void modelDeleted();
200 void showHorizontalSortIndicator();
201 void actionTriggered();
202 void columnSizeChanged( int index, int oldWidth, int newWidth );
203 void onActionColumnItemPainted( const QModelIndex &index );
204 void recreateActionWidgets();
205
206 private:
207 void updateActionImage( QWidget *widget );
208 QWidget *createActionWidget( QgsFeatureId fid );
209
210 void selectRow( int row, bool anchor );
211 QgsAttributeTableFilterModel *mFilterModel = nullptr;
212 QgsFeatureSelectionModel *mFeatureSelectionModel = nullptr;
213 QgsIFeatureSelectionManager *mOwnedFeatureSelectionManager = nullptr;
214 QgsIFeatureSelectionManager *mFeatureSelectionManager = nullptr;
215 QgsAttributeTableDelegate *mTableDelegate = nullptr;
216 QMenu *mActionPopup = nullptr;
217 int mRowSectionAnchor = 0;
218 QItemSelectionModel::SelectionFlag mCtrlDragSelectionFlag = QItemSelectionModel::Select;
219 QMap<QModelIndex, QWidget *> mActionWidgets;
221 QString mSortExpression;
222};
223
224#endif
A container for configuration of the attribute table.
A delegate item class for QgsAttributeTable (see Qt documentation for QItemDelegate).
A proxy model for filtering an attribute table model.
A model backed by a QgsVectorLayerCache which is able to provide feature/attribute information to a Q...
void willShowContextMenu(QMenu *menu, const QModelIndex &atIndex)
Emitted in order to provide a hook to add additional* menu entries to the context menu.
QList< QgsFeatureId > selectedFeaturesIds() const
Returns the selected features in the attribute table in table sorted order.
Q_DECL_DEPRECATED void finished()
void setFeatureSelectionManager(QgsIFeatureSelectionManager *featureSelectionManager)
setFeatureSelectionManager
void mouseMoveEvent(QMouseEvent *event) override
Called for mouse move events on a table cell.
virtual void selectRow(int row)
QgsAttributeTableView(QWidget *parent=nullptr)
Constructor for QgsAttributeTableView.
void rowHeaderDoubleClicked(QgsFeatureId fid)
Emitted when a row header is double-clicked.
void scrollToFeature(const QgsFeatureId &fid, int column=-1)
Scroll to a feature with a given fid.
void mouseReleaseEvent(QMouseEvent *event) override
Called for mouse release events on a table cell.
void contextMenuEvent(QContextMenuEvent *event) override
Is called when the context menu will be shown.
virtual void _q_selectRow(int row)
void closeEvent(QCloseEvent *event) override
Saves geometry to the settings on close.
void mousePressEvent(QMouseEvent *event) override
Called for mouse press events on a table cell.
void closeCurrentEditor()
Closes the editor delegate for the current item, committing its changes to the model.
void keyPressEvent(QKeyEvent *event) override
Called for key press events Disables selection change by only pressing an arrow key.
void setAttributeTableConfig(const QgsAttributeTableConfig &config)
Set the attribute table config which should be used to control the appearance of the attribute table.
void columnResized(int column, int width)
Emitted when a column in the view has been resized.
void repaintRequested(const QModelIndexList &indexes)
bool eventFilter(QObject *object, QEvent *event) override
This event filter is installed on the verticalHeader to intercept mouse press and release events.
virtual void setModel(QgsAttributeTableFilterModel *filterModel)
Item selection model for selecting features.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition qgsfeature.h:58
Is an interface class to abstract feature selection handling.
Map canvas is a class for displaying all GIS data types on a canvas.
QgsTableView(QWidget *parent=nullptr)
Constructor for QgsTableView.
Caches features for a given QgsVectorLayer.
Represents a vector layer which manages a vector based dataset.
#define SIP_DEPRECATED
Definition qgis_sip.h:114
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features