QGIS API Documentation  2.99.0-Master (8ec3eaf)
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 
29 class QgsVectorLayer;
32 class QRect;
33 
42 class GUI_EXPORT QgsFeatureListView : public QListView
43 {
44  Q_OBJECT
45 
46  public:
47 
53  explicit QgsFeatureListView( QWidget* parent = nullptr );
54 
58  virtual ~QgsFeatureListView() {}
59 
64  QgsVectorLayerCache* layerCache();
65 
71  virtual void setModel( QgsFeatureListModel* featureListModel );
72 
78  QgsFeatureListModel* featureListModel() { return mModel; }
79 
88  bool setDisplayExpression( const QString& displayExpression );
89 
97  const QString displayExpression() const;
98 
104  QString parserErrorString();
105 
111  QgsFeatureIds currentEditSelection();
112 
118  void setCurrentFeatureEdited( bool state );
119 
124  void setFeatureSelectionManager( QgsIFeatureSelectionManager* featureSelectionManager );
125  protected:
126  virtual void mouseMoveEvent( QMouseEvent *event ) override;
127  virtual void mousePressEvent( QMouseEvent *event ) override;
128  virtual void mouseReleaseEvent( QMouseEvent *event ) override;
129  virtual void keyPressEvent( QKeyEvent *event ) override;
130  virtual void contextMenuEvent( QContextMenuEvent *event ) override;
131 
132  signals:
133 
139  void currentEditSelectionChanged( QgsFeature &feat );
140 
145  void displayExpressionChanged( const QString& expression );
146 
148  void aboutToChangeEditSelection( bool& ok );
149 
150  public slots:
151 
157  void setEditSelection( const QgsFeatureIds &fids );
158 
165  void setEditSelection( const QModelIndex& index, QItemSelectionModel::SelectionFlags command );
166 
170  virtual void selectAll() override;
171 
172  void repaintRequested( const QModelIndexList& indexes );
173  void repaintRequested();
174 
175  private slots:
176  void editSelectionChanged( const QItemSelection& deselected, const QItemSelection& selected );
177 
178  private:
179  void selectRow( const QModelIndex &index, bool anchor );
180 
181  QgsFeatureListModel *mModel;
182  QItemSelectionModel* mCurrentEditSelectionModel;
183  QgsFeatureSelectionModel* mFeatureSelectionModel;
184  QgsIFeatureSelectionManager* mFeatureSelectionManager;
185  QgsFeatureListViewDelegate* mItemDelegate;
186  bool mEditSelectionDrag; // Is set to true when the user initiated a left button click over an edit button and still keeps pressing //!< TODO
187  int mRowAnchor;
188  QItemSelectionModel::SelectionFlags mCtrlDragSelectionFlag;
189 };
190 
191 #endif
static unsigned index
QSet< QgsFeatureId > QgsFeatureIds
Definition: qgsfeature.h:355
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:135
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.
virtual ~QgsFeatureListView()
Destructor.
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.