QGIS API Documentation  3.4.15-Madeira (e83d02e274)
qgslayertreeviewitemdelegate.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgslayertreeviewitemdelegate.h
3  --------------------------------------
4  Date : January 2018
5  Copyright : (C) 2018 by Martin Dobias
6  Email : wonder dot sk at gmail dot 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 QGSLAYERTREEVIEWITEMDELEGATE_H
17 #define QGSLAYERTREEVIEWITEMDELEGATE_H
18 
19 #include "qgis_sip.h"
20 
22 
24 
25 //
26 // W A R N I N G
27 // -------------
28 //
29 // This file is not part of the QGIS API. It exists purely as an
30 // implementation detail. This header file may change from version to
31 // version without notice, or even be removed.
32 //
33 
34 class QgsLayerTreeView;
35 
36 #include "qgsproxystyle.h"
37 #include <QStyledItemDelegate>
38 
42 class QgsLayerTreeViewProxyStyle : public QgsProxyStyle
43 {
44  public:
45  explicit QgsLayerTreeViewProxyStyle( QgsLayerTreeView *treeView );
46 
47  QRect subElementRect( SubElement element, const QStyleOption *option, const QWidget *widget ) const override;
48 
49  static const unsigned long SE_LayerTreeItemIndicator = SE_CustomBase + 1;
50 
51  private:
52  QgsLayerTreeView *mLayerTreeView;
53 };
54 
55 
59 class QgsLayerTreeViewItemDelegate : public QStyledItemDelegate
60 {
61  Q_OBJECT
62  public:
63  explicit QgsLayerTreeViewItemDelegate( QgsLayerTreeView *parent );
64 
65  void paint( QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index ) const override;
66 
67  bool helpEvent( QHelpEvent *event, QAbstractItemView *view, const QStyleOptionViewItem &option, const QModelIndex &index ) override;
68 
69  private slots:
70  void onClicked( const QModelIndex &index );
71 
72  private:
73  QgsLayerTreeView *mLayerTreeView;
74 };
75 
77 
78 #endif // QGSLAYERTREEVIEWITEMDELEGATE_H
The QgsLayerTreeView class extends QTreeView and provides some additional functionality when working ...
A QProxyStyle subclass which correctly sets the base style to match the QGIS application style...
Definition: qgsproxystyle.h:30
#define SIP_NO_FILE
Definition: qgis_sip.h:23