QGIS API Documentation  3.0.2-Girona (307d082)
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 #include "qgsactionmenu.h"
24 
25 #include "qgsfeature.h" // For QgsFeatureIds
26 #include "qgis_gui.h"
27 
33 class QgsVectorLayer;
36 class QRect;
37 
46 class GUI_EXPORT QgsFeatureListView : public QListView
47 {
48  Q_OBJECT
49 
50  public:
51 
57  explicit QgsFeatureListView( QWidget *parent SIP_TRANSFERTHIS = nullptr );
58 
63  QgsVectorLayerCache *layerCache();
64 
70  virtual void setModel( QgsFeatureListModel *featureListModel );
71 
77  QgsFeatureListModel *featureListModel() { return mModel; }
78 
87  bool setDisplayExpression( const QString &displayExpression );
88 
96  const QString displayExpression() const;
97 
103  QString parserErrorString();
104 
110  QgsFeatureIds currentEditSelection();
111 
117  void setCurrentFeatureEdited( bool state );
118 
123  void setFeatureSelectionManager( QgsIFeatureSelectionManager *featureSelectionManager SIP_TRANSFER );
124 
125  protected:
126  void mouseMoveEvent( QMouseEvent *event ) override;
127  void mousePressEvent( QMouseEvent *event ) override;
128  void mouseReleaseEvent( QMouseEvent *event ) override;
129  void keyPressEvent( QKeyEvent *event ) override;
130  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 ) SIP_SKIP;
149 
155  void willShowContextMenu( QgsActionMenu *menu, const QModelIndex &atIndex );
156 
157  public slots:
158 
164  void setEditSelection( const QgsFeatureIds &fids );
165 
172  void setEditSelection( const QModelIndex &index, QItemSelectionModel::SelectionFlags command );
173 
177  void selectAll() override;
178 
179  void repaintRequested( const QModelIndexList &indexes );
180  void repaintRequested();
181 
182  private slots:
183  void editSelectionChanged( const QItemSelection &deselected, const QItemSelection &selected );
184 
188  void ensureEditSelection();
189 
190  private:
191  void selectRow( const QModelIndex &index, bool anchor );
192 
193 
194  QgsFeatureListModel *mModel = nullptr;
195  QItemSelectionModel *mCurrentEditSelectionModel = nullptr;
196  QgsFeatureSelectionModel *mFeatureSelectionModel = nullptr;
197  QgsIFeatureSelectionManager *mFeatureSelectionManager = nullptr;
198  QgsFeatureListViewDelegate *mItemDelegate = nullptr;
199  bool mEditSelectionDrag = false; // Is set to true when the user initiated a left button click over an edit button and still keeps pressing //!< TODO
200  int mRowAnchor = 0;
201  QItemSelectionModel::SelectionFlags mCtrlDragSelectionFlag;
202 
203 };
204 
205 #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
This class is a menu that is populated automatically with the actions defined for a given layer...
Definition: qgsactionmenu.h:38
#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.