QGIS API Documentation  2.17.0-Master (973e4b0)
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 
31 class GUI_EXPORT QgsFeatureListViewDelegate : public QItemDelegate
32 {
33  Q_OBJECT
34 
35  public:
36  static int const sIconSize = 24;
37 
38  enum Element
39  {
41  SelectionElement
42  };
43 
44  explicit QgsFeatureListViewDelegate( QgsFeatureListModel* listModel, QObject *parent = nullptr );
45 
46  void setEditSelectionModel( QItemSelectionModel* editSelectionModel );
47 
48  Element positionToElement( QPoint pos );
49 
50  void setFeatureSelectionModel( QgsFeatureSelectionModel* featureSelectionModel );
51 
52  void setCurrentFeatureEdited( bool state );
53 
54  signals:
55  void editButtonClicked( QModelIndex& index );
56 
57  protected:
58  virtual QSize sizeHint( const QStyleOptionViewItem& option, const QModelIndex& index ) const override;
59  virtual void paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const override;
60 
61  private:
62  QgsFeatureSelectionModel* mFeatureSelectionModel;
63  QItemSelectionModel* mEditSelectionModel;
64  QgsFeatureListModel* mListModel;
66  bool mCurrentFeatureEdited;
67 };
68 
69 #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.