QGIS API Documentation  3.14.0-Pi (9f7028fd23)
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 <qdebug.h>
22 #include "qgsactionmenu.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 = nullptr );
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 );
123 
124  protected:
125  void mouseMoveEvent( QMouseEvent *event ) override;
126  void mousePressEvent( QMouseEvent *event ) override;
127  void mouseReleaseEvent( QMouseEvent *event ) override;
128  void keyPressEvent( QKeyEvent *event ) override;
129  void contextMenuEvent( QContextMenuEvent *event ) override;
130 
131  signals:
132 
137  void currentEditSelectionChanged( QgsFeature &feat );
138 
145  void currentEditSelectionProgressChanged( int progress, int count );
146 
151  void displayExpressionChanged( const QString &expression );
152 
154  void aboutToChangeEditSelection( bool &ok ) SIP_SKIP;
155 
161  void willShowContextMenu( QgsActionMenu *menu, const QModelIndex &atIndex );
162 
163  public slots:
164 
170  void setEditSelection( const QgsFeatureIds &fids );
171 
178  void setEditSelection( const QModelIndex &index, QItemSelectionModel::SelectionFlags command );
179 
183  void selectAll() override;
184 
185  void repaintRequested( const QModelIndexList &indexes );
186  void repaintRequested();
187 
192  void editFirstFeature() {editOtherFeature( First );}
193 
198  void editNextFeature() {editOtherFeature( Next );}
199 
204  void editPreviousFeature() {editOtherFeature( Previous );}
205 
210  void editLastFeature() {editOtherFeature( Last );}
211 
212 
213 
214  private slots:
215  void editSelectionChanged( const QItemSelection &deselected, const QItemSelection &selected );
216 
220  void updateEditSelectionDependencies();
221 
228  void ensureEditSelection( bool inSelection = false );
229 
230  private:
231  void selectRow( const QModelIndex &index, bool anchor );
232 
233  enum PositionInList
234  {
235  First,
236  Next,
237  Previous,
238  Last
239  };
240 
241  void editOtherFeature( PositionInList positionInList );
242 
243 
244  QgsFeatureListModel *mModel = nullptr;
245  QItemSelectionModel *mCurrentEditSelectionModel = nullptr;
246  QgsFeatureSelectionModel *mFeatureSelectionModel = nullptr;
247  QgsIFeatureSelectionManager *mOwnedFeatureSelectionManager = nullptr;
248  QgsIFeatureSelectionManager *mFeatureSelectionManager = nullptr;
249  QgsFeatureListViewDelegate *mItemDelegate = nullptr;
250  bool mEditSelectionDrag = false; // Is set to true when the user initiated a left button click over an edit button and still keeps pressing //!< TODO
251  int mRowAnchor = 0;
252  QItemSelectionModel::SelectionFlags mCtrlDragSelectionFlag;
253 
254  QTimer mUpdateEditSelectionTimer;
255 
256  friend class QgsDualView;
257 };
258 
259 #endif
QgsFeatureListView::editPreviousFeature
void editPreviousFeature()
editPreviousFeature will try to edit previous feature of the list
Definition: qgsfeaturelistview.h:204
QgsVectorLayerCache
The cached features can be indexed by QgsAbstractCacheIndex.
Definition: qgsvectorlayercache.h:45
QgsFeatureSelectionModel
Definition: qgsfeatureselectionmodel.h:31
qgsfeature.h
QgsFeatureListView
Definition: qgsfeaturelistview.h:45
QgsDualView
Definition: qgsdualview.h:41
QgsFeatureListView::editLastFeature
void editLastFeature()
editLastFeature will try to edit the last feature of the list
Definition: qgsfeaturelistview.h:210
SIP_SKIP
#define SIP_SKIP
Definition: qgis_sip.h:126
QgsAttributeTableModel
Is able to generate editor widgets for its QModelIndexes as well. Is mostly referred to as "master mo...
Definition: qgsattributetablemodel.h:49
qgis_sip.h
QgsActionMenu
Definition: qgsactionmenu.h:37
QgsFeatureListView::featureListModel
QgsFeatureListModel * featureListModel()
Gets the featureListModel used by this view.
Definition: qgsfeaturelistview.h:76
QgsFeatureIds
QSet< QgsFeatureId > QgsFeatureIds
Definition: qgsfeatureid.h:34
qgsactionmenu.h
QgsAttributeTableFilterModel
Definition: qgsattributetablefiltermodel.h:35
QgsFeatureListModel
Definition: qgsfeaturelistmodel.h:38
QgsVectorLayer
Definition: qgsvectorlayer.h:385
QgsFeature
Definition: qgsfeature.h:55
QgsFeatureListView::editFirstFeature
void editFirstFeature()
editFirstFeature will try to edit the first feature of the list
Definition: qgsfeaturelistview.h:192
QgsIFeatureSelectionManager
Definition: qgsifeatureselectionmanager.h:31
QgsFeatureListViewDelegate
Definition: qgsfeaturelistviewdelegate.h:31
SIP_TRANSFERTHIS
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
QgsFeatureListView::editNextFeature
void editNextFeature()
editNextFeature will try to edit next feature of the list
Definition: qgsfeaturelistview.h:198