QGIS API Documentation 3.41.0-Master (af5edcb665c)
Loading...
Searching...
No Matches
qgsfeaturelistview.h
Go to the documentation of this file.
1/***************************************************************************
2 QgsAttributeListView.h
3 --------------------------------------
4 Date : Jan 2012
5 Copyright : (C) 2013 Matthias Kuhn
6 Email : matthias at opengis dot ch
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 QGSFEATURELISTVIEW_H
17#define QGSFEATURELISTVIEW_H
18
19#include <QListView>
20#include "qgis_sip.h"
21#include <qdebug.h>
22
23#include "qgsfeature.h" // For QgsFeatureIds
24#include "qgis_gui.h"
25#include <QTimer>
26
32class QgsVectorLayer;
35class QRect;
36class QgsActionMenu;
37
46class GUI_EXPORT QgsFeatureListView : public QListView
47{
48 Q_OBJECT
49
50 public:
56 explicit QgsFeatureListView( QWidget *parent SIP_TRANSFERTHIS = nullptr );
57
62 QgsVectorLayerCache *layerCache();
63
64#ifdef __clang__
65#pragma clang diagnostic push
66#pragma clang diagnostic ignored "-Woverloaded-virtual"
67#endif
68
74 virtual void setModel( QgsFeatureListModel *featureListModel );
75#ifdef __clang__
76#pragma clang diagnostic pop
77#endif
78
85
94 bool setDisplayExpression( const QString &displayExpression );
95
103 const QString displayExpression() const;
104
110 QString parserErrorString();
111
117 QgsFeatureIds currentEditSelection();
118
124 void setCurrentFeatureEdited( bool state );
125
130 void setFeatureSelectionManager( QgsIFeatureSelectionManager *featureSelectionManager );
131
132 protected:
133 void mouseMoveEvent( QMouseEvent *event ) override;
134 void mousePressEvent( QMouseEvent *event ) override;
135 void mouseReleaseEvent( QMouseEvent *event ) override;
136 void keyPressEvent( QKeyEvent *event ) override;
137 void contextMenuEvent( QContextMenuEvent *event ) override;
138
139 signals:
140
146
153 void currentEditSelectionProgressChanged( int progress, int count );
154
159 void displayExpressionChanged( const QString &expression );
160
163
169 void willShowContextMenu( QgsActionMenu *menu, const QModelIndex &atIndex );
170
171 public slots:
172
178 void setEditSelection( const QgsFeatureIds &fids );
179
186 void setEditSelection( const QModelIndex &index, QItemSelectionModel::SelectionFlags command );
187
191 void selectAll() override;
192
193 void repaintRequested( const QModelIndexList &indexes );
194 void repaintRequested();
195
200 void editFirstFeature() { editOtherFeature( First ); }
201
206 void editNextFeature() { editOtherFeature( Next ); }
207
212 void editPreviousFeature() { editOtherFeature( Previous ); }
213
218 void editLastFeature() { editOtherFeature( Last ); }
219
220
221 private slots:
222 void editSelectionChanged( const QItemSelection &selected, const QItemSelection &deselected );
223
230 void ensureEditSelection( bool inSelection = false );
231
232 private:
233 void selectRow( const QModelIndex &index, bool anchor );
234
235 void updateEditSelection( bool inSelection = false );
236
237 enum PositionInList
238 {
239 First,
240 Next,
241 Previous,
242 Last
243 };
244
245 void editOtherFeature( PositionInList positionInList );
246
247
248 QgsFeatureListModel *mModel = nullptr;
249 QItemSelectionModel *mCurrentEditSelectionModel = nullptr;
250 QgsFeatureSelectionModel *mFeatureSelectionModel = nullptr;
251 QgsIFeatureSelectionManager *mOwnedFeatureSelectionManager = nullptr;
252 QgsIFeatureSelectionManager *mFeatureSelectionManager = nullptr;
253 QgsFeatureListViewDelegate *mItemDelegate = nullptr;
254
255 enum class DragMode
256 {
257 Inactive,
258 ExpandSelection,
259 MoveSelection
260 };
261
262 DragMode mDragMode = DragMode::Inactive;
263
264 int mRowAnchor = 0;
265 QItemSelectionModel::SelectionFlags mCtrlDragSelectionFlag;
266
267 QTimer mUpdateEditSelectionTimerWithSelection;
268 QTimer mUpdateEditSelectionTimerWithoutSelection;
269
270 QgsFeatureId mLastEditSelectionFid;
271
272 friend class QgsDualView;
273};
274
275#endif
This class is a menu that is populated automatically with the actions defined for a given layer.
A model backed by a QgsVectorLayerCache which is able to provide feature/attribute information to a Q...
This widget is used to show the attributes of a set of features of a QgsVectorLayer.
Definition qgsdualview.h:46
Shows a list of features and renders a edit button next to each feature.
void currentEditSelectionProgressChanged(int progress, int count)
Emitted whenever the current edit selection has been changed.
void editNextFeature()
editNextFeature will try to edit next feature of the list
void editLastFeature()
editLastFeature will try to edit the last feature of the list
void editFirstFeature()
editFirstFeature will try to edit the first feature of the list
void displayExpressionChanged(const QString &expression)
Emitted whenever the display expression is successfully changed.
void editPreviousFeature()
editPreviousFeature will try to edit previous feature of the list
void willShowContextMenu(QgsActionMenu *menu, const QModelIndex &atIndex)
Emitted when the context menu is created to add the specific actions to it.
QgsFeatureListModel * featureListModel()
Gets the featureListModel used by this view.
void currentEditSelectionChanged(QgsFeature &feat)
Emitted whenever the current edit selection has been changed.
void aboutToChangeEditSelection(bool &ok)
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.
This class caches features of a given QgsVectorLayer.
Represents a vector layer which manages a vector based data sets.
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53
#define SIP_SKIP
Definition qgis_sip.h:126
QSet< QgsFeatureId > QgsFeatureIds
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features