QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
qgsattributetabledelegate.h
Go to the documentation of this file.
1 /***************************************************************************
2  QgsAttributeTableDelegate.h
3  --------------------------------------
4  Date : Feb 2009
5  Copyright : (C) 2009 Vita Cizek
6  Email : weetya (at) gmail.com
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 QGSATTRIBUTETABLEDELEGATE_H
17 #define QGSATTRIBUTETABLEDELEGATE_H
18 
19 #include <QItemDelegate>
20 #include "qgsfeature.h"
21 
23 class QPainter;
24 class QgsVectorLayer;
26 class QToolButton;
27 
33 class GUI_EXPORT QgsAttributeTableDelegate : public QItemDelegate
34 {
35  Q_OBJECT
36 
37  static QgsVectorLayer* layer( const QAbstractItemModel* model );
38  static const QgsAttributeTableModel* masterModel( const QAbstractItemModel* model );
39 
40  public:
45  QgsAttributeTableDelegate( QObject* parent = nullptr )
46  : QItemDelegate( parent )
47  , mLayer( nullptr )
48  , mFeatureSelectionModel( nullptr )
49  {
50  }
51 
56  QWidget * createEditor( QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index ) const override;
57 
61  void paint( QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const override;
62 
69  void setModelData( QWidget *editor, QAbstractItemModel *model, const QModelIndex &index ) const override;
70 
76  void setEditorData( QWidget *editor, const QModelIndex &index ) const override;
77 
78  void setFeatureSelectionModel( QgsFeatureSelectionModel* featureSelectionModel );
79 
80  signals:
89  void actionColumnItemPainted( const QModelIndex& index ) const;
90 
91  private:
92  QgsVectorLayer* mLayer;
93  QgsFeatureSelectionModel* mFeatureSelectionModel;
94 };
95 
96 #endif //QGSATTRIBUTETABLEDELEGATE_H
static unsigned index
virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
A model backed by a QgsVectorLayerCache which is able to provide feature/attribute information to a Q...
virtual void setEditorData(QWidget *editor, const QModelIndex &index) const
virtual QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
virtual void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
QgsAttributeTableDelegate(QObject *parent=nullptr)
Constructor.
A delegate item class for QgsAttributeTable (see Qt documentation for QItemDelegate).
Represents a vector layer which manages a vector based data sets.