QGIS API Documentation  2.99.0-Master (5753576)
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 
43 class GUI_EXPORT QgsFeatureListView : public QListView
44 {
45  Q_OBJECT
46 
47  public:
48 
54  explicit QgsFeatureListView( QWidget* parent = nullptr );
55 
60  QgsVectorLayerCache* layerCache();
61 
67  virtual void setModel( QgsFeatureListModel* featureListModel );
68 
74  QgsFeatureListModel* featureListModel() { return mModel; }
75 
84  bool setDisplayExpression( const QString& displayExpression );
85 
93  const QString displayExpression() const;
94 
100  QString parserErrorString();
101 
107  QgsFeatureIds currentEditSelection();
108 
114  void setCurrentFeatureEdited( bool state );
115 
120  void setFeatureSelectionManager( QgsIFeatureSelectionManager* featureSelectionManager );
121  protected:
122  virtual void mouseMoveEvent( QMouseEvent *event ) override;
123  virtual void mousePressEvent( QMouseEvent *event ) override;
124  virtual void mouseReleaseEvent( QMouseEvent *event ) override;
125  virtual void keyPressEvent( QKeyEvent *event ) override;
126  virtual void contextMenuEvent( QContextMenuEvent *event ) override;
127 
128  signals:
129 
135  void currentEditSelectionChanged( QgsFeature &feat );
136 
141  void displayExpressionChanged( const QString& expression );
142 
144  void aboutToChangeEditSelection( bool& ok );
145 
146  public slots:
147 
153  void setEditSelection( const QgsFeatureIds &fids );
154 
161  void setEditSelection( const QModelIndex& index, QItemSelectionModel::SelectionFlags command );
162 
166  virtual void selectAll() override;
167 
168  void repaintRequested( const QModelIndexList& indexes );
169  void repaintRequested();
170 
171  private slots:
172  void editSelectionChanged( const QItemSelection& deselected, const QItemSelection& selected );
173 
174  private:
175  void selectRow( const QModelIndex &index, bool anchor );
176 
177  QgsFeatureListModel *mModel;
178  QItemSelectionModel* mCurrentEditSelectionModel;
179  QgsFeatureSelectionModel* mFeatureSelectionModel;
180  QgsIFeatureSelectionManager* mFeatureSelectionManager;
181  QgsFeatureListViewDelegate* mItemDelegate;
182  bool mEditSelectionDrag; // Is set to true when the user initiated a left button click over an edit button and still keeps pressing //!< TODO
183  int mRowAnchor;
184  QItemSelectionModel::SelectionFlags mCtrlDragSelectionFlag;
185 };
186 
187 #endif
static unsigned index
QSet< QgsFeatureId > QgsFeatureIds
Definition: qgsfeature.h:348
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:136
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.