QGIS API Documentation 3.99.0-Master (26c88405ac0)
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 "qgis_gui.h"
20#include "qgis_sip.h"
21#include "qgsfeature.h"
22
23#include <QListView>
24#include <QTimer>
25#include <qdebug.h>
26
32class QgsVectorLayer;
35class QRect;
36class QgsActionMenu;
37
46class GUI_EXPORT QgsFeatureListView : public QListView
47{
48 Q_OBJECT
49
50 public:
51
57 explicit QgsFeatureListView( QWidget *parent SIP_TRANSFERTHIS = nullptr );
58
64
65#ifdef __clang__
66#pragma clang diagnostic push
67#pragma clang diagnostic ignored "-Woverloaded-virtual"
68#endif
69
76#ifdef __clang__
77#pragma clang diagnostic pop
78#endif
79
86
95 bool setDisplayExpression( const QString &displayExpression );
96
104 const QString displayExpression() const;
105
111 QString parserErrorString();
112
118 QgsFeatureIds currentEditSelection();
119
125 void setCurrentFeatureEdited( bool state );
126
131 void setFeatureSelectionManager( QgsIFeatureSelectionManager *featureSelectionManager );
132
133 protected:
134 void mouseMoveEvent( QMouseEvent *event ) override;
135 void mousePressEvent( QMouseEvent *event ) override;
136 void mouseReleaseEvent( QMouseEvent *event ) override;
137 void keyPressEvent( QKeyEvent *event ) override;
138 void contextMenuEvent( QContextMenuEvent *event ) override;
139
140 signals:
141
147
154 void currentEditSelectionProgressChanged( int progress, int count );
155
160 void displayExpressionChanged( const QString &expression );
161
164
170 void willShowContextMenu( QgsActionMenu *menu, const QModelIndex &atIndex );
171
172 public slots:
173
179 void setEditSelection( const QgsFeatureIds &fids );
180
187 void setEditSelection( const QModelIndex &index, QItemSelectionModel::SelectionFlags command );
188
192 void selectAll() override;
193
194 void repaintRequested( const QModelIndexList &indexes );
195 void repaintRequested();
196
201 void editFirstFeature() { editOtherFeature( First ); }
202
207 void editNextFeature() { editOtherFeature( Next ); }
208
213 void editPreviousFeature() { editOtherFeature( Previous ); }
214
219 void editLastFeature() { editOtherFeature( Last ); }
220
221
222 private slots:
223 void editSelectionChanged( const QItemSelection &selected, const QItemSelection &deselected );
224
231 void ensureEditSelection( bool inSelection = false );
232
233 private:
234 void selectRow( const QModelIndex &index, bool anchor );
235
236 void updateEditSelection( bool inSelection = false );
237
238 enum PositionInList
239 {
240 First,
241 Next,
242 Previous,
243 Last
244 };
245
246 void editOtherFeature( PositionInList positionInList );
247
248
249 QgsFeatureListModel *mModel = nullptr;
250 QItemSelectionModel *mCurrentEditSelectionModel = nullptr;
251 QgsFeatureSelectionModel *mFeatureSelectionModel = nullptr;
252 QgsIFeatureSelectionManager *mOwnedFeatureSelectionManager = nullptr;
253 QgsIFeatureSelectionManager *mFeatureSelectionManager = nullptr;
254 QgsFeatureListViewDelegate *mItemDelegate = nullptr;
255
256 enum class DragMode
257 {
258 Inactive,
259 ExpandSelection,
260 MoveSelection
261 };
262
263 DragMode mDragMode = DragMode::Inactive;
264
265 int mRowAnchor = 0;
266 QItemSelectionModel::SelectionFlags mCtrlDragSelectionFlag;
267
268 QTimer mUpdateEditSelectionTimerWithSelection;
269 QTimer mUpdateEditSelectionTimerWithoutSelection;
270
271 QgsFeatureId mLastEditSelectionFid;
272
273 friend class QgsDualView;
274};
275
276#endif
A menu that is populated automatically with the actions defined for a given layer.
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...
A proxy model for feature lists.
Custom item delegate for feature list views.
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 repaintRequested(const QModelIndexList &indexes)
void setEditSelection(const QgsFeatureIds &fids)
Set the feature(s) to be edited.
void selectAll() override
Select all currently visible features.
void editPreviousFeature()
editPreviousFeature will try to edit previous feature of the list
QgsVectorLayerCache * layerCache()
Returns the layer cache.
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.
QgsFeatureListView(QWidget *parent=nullptr)
Creates a feature list view.
virtual void setModel(QgsFeatureListModel *featureListModel)
Set the QgsFeatureListModel which is used to retrieve information.
void currentEditSelectionChanged(QgsFeature &feat)
Emitted whenever the current edit selection has been changed.
void aboutToChangeEditSelection(bool &ok)
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.
Caches features for a given QgsVectorLayer.
Represents a vector layer which manages a vector based dataset.
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53
#define SIP_SKIP
Definition qgis_sip.h:134
QSet< QgsFeatureId > QgsFeatureIds
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features