QGIS API Documentation  2.99.0-Master (53aba61)
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 
44 class GUI_EXPORT QgsFeatureListView : public QListView
45 {
46  Q_OBJECT
47 
48  public:
49 
55  explicit QgsFeatureListView( QWidget *parent SIP_TRANSFERTHIS = 0 );
56 
61  QgsVectorLayerCache *layerCache();
62 
68  virtual void setModel( QgsFeatureListModel *featureListModel );
69 
75  QgsFeatureListModel *featureListModel() { return mModel; }
76 
85  bool setDisplayExpression( const QString &displayExpression );
86 
94  const QString displayExpression() const;
95 
101  QString parserErrorString();
102 
108  QgsFeatureIds currentEditSelection();
109 
115  void setCurrentFeatureEdited( bool state );
116 
121  void setFeatureSelectionManager( QgsIFeatureSelectionManager *featureSelectionManager SIP_TRANSFER );
122 
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:
131 
137  void currentEditSelectionChanged( QgsFeature &feat );
138 
143  void displayExpressionChanged( const QString &expression );
144 
146  void aboutToChangeEditSelection( bool &ok ) SIP_SKIP;
147 
148  public slots:
149 
155  void setEditSelection( const QgsFeatureIds &fids );
156 
163  void setEditSelection( const QModelIndex &index, QItemSelectionModel::SelectionFlags command );
164 
168  virtual void selectAll() override;
169 
170  void repaintRequested( const QModelIndexList &indexes );
171  void repaintRequested();
172 
173  private slots:
174  void editSelectionChanged( const QItemSelection &deselected, const QItemSelection &selected );
175 
176  private:
177  void selectRow( const QModelIndex &index, bool anchor );
178 
179  QgsFeatureListModel *mModel = nullptr;
180  QItemSelectionModel *mCurrentEditSelectionModel = nullptr;
181  QgsFeatureSelectionModel *mFeatureSelectionModel = nullptr;
182  QgsIFeatureSelectionManager *mFeatureSelectionManager = nullptr;
183  QgsFeatureListViewDelegate *mItemDelegate = nullptr;
184  bool mEditSelectionDrag; // Is set to true when the user initiated a left button click over an edit button and still keeps pressing //!< TODO
185  int mRowAnchor;
186  QItemSelectionModel::SelectionFlags mCtrlDragSelectionFlag;
187 };
188 
189 #endif
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:46
QSet< QgsFeatureId > QgsFeatureIds
Definition: qgsfeature.h:519
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.
#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.