QGIS API Documentation 4.5.0-Master (c9e0ddc514d)
Loading...
Searching...
No Matches
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
35
36#include "qgsproxystyle.h"
37#include <QStyledItemDelegate>
38
42class QgsLayerTreeViewProxyStyle : public QgsProxyStyle
43{
44 Q_OBJECT
45
46 public:
47 explicit QgsLayerTreeViewProxyStyle( QgsLayerTreeView *treeView );
48
49 QRect subElementRect( SubElement element, const QStyleOption *option, const QWidget *widget ) const override;
50
51 void drawPrimitive( QStyle::PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = nullptr ) const override;
52
53 static const auto SE_LayerTreeItemIndicator = SE_CustomBase + 1;
54
55 private:
56 QgsLayerTreeView *mLayerTreeView;
57};
58
59
63class QgsLayerTreeViewItemDelegate : public QStyledItemDelegate
64{
65 Q_OBJECT
66 public:
67 explicit QgsLayerTreeViewItemDelegate( QgsLayerTreeView *parent );
68
69 void paint( QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index ) const override;
70
71 bool helpEvent( QHelpEvent *event, QAbstractItemView *view, const QStyleOptionViewItem &option, const QModelIndex &index ) override;
72
73 private slots:
74 void onClicked( const QModelIndex &index );
75
76 private:
77 QgsLayerTreeView *mLayerTreeView;
78};
79
81
82#endif // QGSLAYERTREEVIEWITEMDELEGATE_H
Extends QTreeView and provides additional functionality when working with a layer tree.
A QProxyStyle subclass which correctly sets the base style to match the QGIS application style,...
#define SIP_NO_FILE