QGIS API Documentation  2.99.0-Master (f1c3692)
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 "qgis_sip.h"
21 #include "qgis.h"
22 #include <qdebug.h>
23 
24 #include "qgsfeature.h" // For QgsFeatureIds
25 #include "qgis_gui.h"
26 
32 class QgsVectorLayer;
35 class QRect;
36 
45 class GUI_EXPORT QgsFeatureListView : public QListView
46 {
47  Q_OBJECT
48 
49  public:
50 
56  explicit QgsFeatureListView( QWidget *parent SIP_TRANSFERTHIS = 0 );
57 
62  QgsVectorLayerCache *layerCache();
63 
69  virtual void setModel( QgsFeatureListModel *featureListModel );
70 
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 SIP_TRANSFER );
123 
124  protected:
125  virtual void mouseMoveEvent( QMouseEvent *event ) override;
126  virtual void mousePressEvent( QMouseEvent *event ) override;
127  virtual void mouseReleaseEvent( QMouseEvent *event ) override;
128  virtual void keyPressEvent( QKeyEvent *event ) override;
129  virtual void contextMenuEvent( QContextMenuEvent *event ) override;
130 
131  signals:
132 
138  void currentEditSelectionChanged( QgsFeature &feat );
139 
144  void displayExpressionChanged( const QString &expression );
145 
147  void aboutToChangeEditSelection( bool &ok ) SIP_SKIP;
148 
149  public slots:
150 
156  void setEditSelection( const QgsFeatureIds &fids );
157 
164  void setEditSelection( const QModelIndex &index, QItemSelectionModel::SelectionFlags command );
165 
169  virtual void selectAll() override;
170 
171  void repaintRequested( const QModelIndexList &indexes );
172  void repaintRequested();
173 
174  private slots:
175  void editSelectionChanged( const QItemSelection &deselected, const QItemSelection &selected );
176 
177  private:
178  void selectRow( const QModelIndex &index, bool anchor );
179 
180  QgsFeatureListModel *mModel = nullptr;
181  QItemSelectionModel *mCurrentEditSelectionModel = nullptr;
182  QgsFeatureSelectionModel *mFeatureSelectionModel = nullptr;
183  QgsIFeatureSelectionManager *mFeatureSelectionManager = nullptr;
184  QgsFeatureListViewDelegate *mItemDelegate = nullptr;
185  bool mEditSelectionDrag = false; // Is set to true when the user initiated a left button click over an edit button and still keeps pressing //!< TODO
186  int mRowAnchor = 0;
187  QItemSelectionModel::SelectionFlags mCtrlDragSelectionFlag;
188 };
189 
190 #endif
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:46
QSet< QgsFeatureId > QgsFeatureIds
Definition: qgsfeature.h:544
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:62
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.
#define SIP_SKIP
Definition: qgis_sip.h:119
#define SIP_TRANSFER
Definition: qgis_sip.h:36
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.