QGIS API Documentation  2.99.0-Master (b8fd1fd)
qgsfeaturelistviewdelegate.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsfeaturelistviewdelegate.h
3  ---------------------
4  begin : February 2013
5  copyright : (C) 2013 by 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 #ifndef QGSATTRIBUTELISTVIEWDELEGATE_H
16 #define QGSATTRIBUTELISTVIEWDELEGATE_H
17 
18 #include <QItemDelegate>
19 #include <QItemSelectionModel>
20 #include "qgis_gui.h"
21 
22 class QgsVectorLayer;
25 class QPosition;
26 
30 class GUI_EXPORT QgsFeatureListViewDelegate : public QItemDelegate
31 {
32  Q_OBJECT
33 
34  public:
35  static int const ICON_SIZE = 24;
36 
37  enum Element
38  {
40  SelectionElement
41  };
42 
43  explicit QgsFeatureListViewDelegate( QgsFeatureListModel *listModel, QObject *parent = nullptr );
44 
45  void setEditSelectionModel( QItemSelectionModel *editSelectionModel );
46 
47  Element positionToElement( QPoint pos );
48 
49  void setFeatureSelectionModel( QgsFeatureSelectionModel *featureSelectionModel );
50 
51  void setCurrentFeatureEdited( bool state );
52 
53  signals:
54  void editButtonClicked( QModelIndex &index );
55 
56  protected:
57  virtual QSize sizeHint( const QStyleOptionViewItem &option, const QModelIndex &index ) const override;
58  virtual void paint( QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index ) const override;
59 
60  private:
61  QgsFeatureSelectionModel *mFeatureSelectionModel = nullptr;
62  QItemSelectionModel *mEditSelectionModel = nullptr;
63  QgsFeatureListModel *mListModel = nullptr;
65  bool mCurrentFeatureEdited;
66 };
67 
68 #endif // QGSATTRIBUTELISTVIEWDELEGATE_H
static unsigned index
Represents a vector layer which manages a vector based data sets.