Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qquickstyleitemtreeindicator.cpp
Go to the documentation of this file.
1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
6
8
9void QQuickStyleItemTreeIndicator::connectToControl() const
10{
11 QQuickStyleItem::connectToControl();
12 auto delegate = control<QQuickTreeViewDelegate>();
13 connect(delegate, &QQuickTreeViewDelegate::expandedChanged, this, &QQuickStyleItem::markImageDirty);
14}
15
16StyleItemGeometry QQuickStyleItemTreeIndicator::calculateGeometry()
17{
18 QStyleOptionViewItem styleOption;
19 initStyleOption(styleOption);
20 StyleItemGeometry geometry;
21
22 geometry.minimumSize = QSize(20, 20);
23 geometry.implicitSize = geometry.minimumSize;
24 styleOption.rect = QRect(QPoint(0, 0), geometry.implicitSize);
25
26 return geometry;
27}
28
29void QQuickStyleItemTreeIndicator::paintEvent(QPainter *painter) const
30{
31 QStyleOptionViewItem styleOption;
32 initStyleOption(styleOption);
33 style()->drawPrimitive(QStyle::PE_IndicatorBranch, &styleOption, painter);
34}
35
36void QQuickStyleItemTreeIndicator::initStyleOption(QStyleOptionViewItem &styleOption) const
37{
38 initStyleOptionBase(styleOption);
39 auto delegate = control<QQuickTreeViewDelegate>();
40
41 styleOption.state |= QStyle::State_Children;
42
43 if (delegate->expanded())
44 styleOption.state |= QStyle::State_Open;
45}
46
47QT_END_NAMESPACE
48
49#include "moc_qquickstyleitemtreeindicator.cpp"