QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
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:
52  explicit QgsFeatureListView( QWidget* parent = nullptr );
53 
57  virtual ~QgsFeatureListView() {}
58 
63  QgsVectorLayerCache* layerCache();
64 
70  virtual void setModel( QgsFeatureListModel* featureListModel );
76  QgsFeatureListModel* featureListModel() { return mModel; }
77 
86  bool setDisplayExpression( const QString& displayExpression );
87 
95  const QString displayExpression() const;
96 
102  QString parserErrorString();
103 
109  QgsFeatureIds currentEditSelection();
110 
116  void setCurrentFeatureEdited( bool state );
117 
122  void setFeatureSelectionManager( QgsIFeatureSelectionManager* featureSelectionManager );
123  protected:
124  virtual void mouseMoveEvent( QMouseEvent *event ) override;
125  virtual void mousePressEvent( QMouseEvent *event ) override;
126  virtual void mouseReleaseEvent( QMouseEvent *event ) override;
127  virtual void keyPressEvent( QKeyEvent *event ) override;
128  virtual void contextMenuEvent( QContextMenuEvent *event ) override;
129 
130  signals:
136  void currentEditSelectionChanged( QgsFeature &feat );
137 
142  void displayExpressionChanged( const QString& expression );
143 
145  void aboutToChangeEditSelection( bool& ok );
146 
147  public slots:
153  void setEditSelection( const QgsFeatureIds &fids );
154 
161  void setEditSelection( const QModelIndex& index, const 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
virtual void setModel(QAbstractItemModel *model)
virtual void mouseReleaseEvent(QMouseEvent *e)
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:187
A model backed by a QgsVectorLayerCache which is able to provide feature/attribute information to a Q...
virtual void contextMenuEvent(QContextMenuEvent *e)
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.
virtual void mouseMoveEvent(QMouseEvent *e)
virtual void selectAll()
virtual void mousePressEvent(QMouseEvent *event)
virtual void keyPressEvent(QKeyEvent *event)
Is an interface class to abstract feature selection handling.
Represents a vector layer which manages a vector based data sets.