QGIS API Documentation  2.15.0-Master (5f66276)
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 
21 #include "qgsfeature.h"
22 
23 class QgsVectorLayer;
26 class QPosition;
27 
28 class GUI_EXPORT QgsFeatureListViewDelegate : public QItemDelegate
29 {
30  Q_OBJECT
31 
32  public:
33  static int const sIconSize = 24;
34 
35  enum Element
36  {
38  SelectionElement
39  };
40 
41  explicit QgsFeatureListViewDelegate( QgsFeatureListModel* listModel, QObject *parent = nullptr );
42 
43  void setEditSelectionModel( QItemSelectionModel* editSelectionModel );
44 
45  Element positionToElement( QPoint pos );
46 
47  void setFeatureSelectionModel( QgsFeatureSelectionModel* featureSelectionModel );
48 
49  void setCurrentFeatureEdited( bool state );
50 
51  signals:
52  void editButtonClicked( QModelIndex& index );
53 
54  protected:
55  virtual QSize sizeHint( const QStyleOptionViewItem& option, const QModelIndex& index ) const override;
56  virtual void paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const override;
57 
58  private:
59  QgsFeatureSelectionModel* mFeatureSelectionModel;
60  QItemSelectionModel* mEditSelectionModel;
61  QgsFeatureListModel* mListModel;
63  bool mCurrentFeatureEdited;
64 };
65 
66 #endif // QGSATTRIBUTELISTVIEWDELEGATE_H
static unsigned index
virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
virtual QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
Represents a vector layer which manages a vector based data sets.