QGIS API Documentation  2.99.0-Master (5169e0d)
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 <qdebug.h>
21 
22 #include "qgsfeature.h" // For QgsFeatureIds
23 #include "qgis_gui.h"
24 
30 class QgsVectorLayer;
33 class QRect;
34 
42 class GUI_EXPORT QgsFeatureListView : public QListView
43 {
44  Q_OBJECT
45 
46  public:
47 
53  explicit QgsFeatureListView( QWidget *parent = nullptr );
54 
59  QgsVectorLayerCache *layerCache();
60 
66  virtual void setModel( QgsFeatureListModel *featureListModel );
67 
73  QgsFeatureListModel *featureListModel() { return mModel; }
74 
83  bool setDisplayExpression( const QString &displayExpression );
84 
92  const QString displayExpression() const;
93 
99  QString parserErrorString();
100 
106  QgsFeatureIds currentEditSelection();
107 
113  void setCurrentFeatureEdited( bool state );
114 
119  void setFeatureSelectionManager( QgsIFeatureSelectionManager *featureSelectionManager );
120  protected:
121  virtual void mouseMoveEvent( QMouseEvent *event ) override;
122  virtual void mousePressEvent( QMouseEvent *event ) override;
123  virtual void mouseReleaseEvent( QMouseEvent *event ) override;
124  virtual void keyPressEvent( QKeyEvent *event ) override;
125  virtual void contextMenuEvent( QContextMenuEvent *event ) override;
126 
127  signals:
128 
134  void currentEditSelectionChanged( QgsFeature &feat );
135 
140  void displayExpressionChanged( const QString &expression );
141 
143  void aboutToChangeEditSelection( bool &ok );
144 
145  public slots:
146 
152  void setEditSelection( const QgsFeatureIds &fids );
153 
160  void setEditSelection( const QModelIndex &index, QItemSelectionModel::SelectionFlags command );
161 
165  virtual void selectAll() override;
166 
167  void repaintRequested( const QModelIndexList &indexes );
168  void repaintRequested();
169 
170  private slots:
171  void editSelectionChanged( const QItemSelection &deselected, const QItemSelection &selected );
172 
173  private:
174  void selectRow( const QModelIndex &index, bool anchor );
175 
176  QgsFeatureListModel *mModel = nullptr;
177  QItemSelectionModel *mCurrentEditSelectionModel = nullptr;
178  QgsFeatureSelectionModel *mFeatureSelectionModel = nullptr;
179  QgsIFeatureSelectionManager *mFeatureSelectionManager = nullptr;
180  QgsFeatureListViewDelegate *mItemDelegate = nullptr;
181  bool mEditSelectionDrag; // Is set to true when the user initiated a left button click over an edit button and still keeps pressing //!< TODO
182  int mRowAnchor;
183  QItemSelectionModel::SelectionFlags mCtrlDragSelectionFlag;
184 };
185 
186 #endif
static unsigned index
QSet< QgsFeatureId > QgsFeatureIds
Definition: qgsfeature.h:517
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:61
A model backed by a QgsVectorLayerCache which is able to provide feature/attribute information to a Q...
Shows a list of features and renders a edit button next to each feature.
QgsFeatureListModel * featureListModel()
Get the featureListModel used by this view.
This class caches features of a given QgsVectorLayer.
Is an interface class to abstract feature selection handling.
Represents a vector layer which manages a vector based data sets.