1// Copyright (C) 2020 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
4#ifndef QCOMMONSTYLE_P_H
5#define QCOMMONSTYLE_P_H
6
7#include "qquickcommonstyle.h"
8#include "qquickstyle_p.h"
9#include "qquickstyleoption.h"
10
11QT_BEGIN_NAMESPACE
12
13//
14// W A R N I N G
15// -------------
16//
17// This file is not part of the Qt API. It exists for the convenience
18// of qapplication_*.cpp, qwidget*.cpp and qfiledialog.cpp. This header
19// file may change from version to version without notice, or even be removed.
20//
21// We mean it.
22//
23
24class QTextOption;
25
26namespace QQC2 {
27
28class QCommonStylePrivate : public QStylePrivate
29{
30 Q_DECLARE_PUBLIC(QCommonStyle)
31public:
32
33 ~QCommonStylePrivate()
34 {
35 delete cachedOption;
36 }
37
38 QString calculateElidedText(const QString &text, const QTextOption &textOption,
39 const QFont &font, const QRect &textRect, const Qt::Alignment valign,
40 Qt::TextElideMode textElideMode, int flags,
41 bool lastVisibleLineShouldBeElided, QPointF *paintStartPosition) const;
42 void viewItemDrawText(QPainter *p, const QStyleOptionViewItem *option, const QRect &rect) const;
43 void viewItemLayout(const QStyleOptionViewItem *opt, QRect *checkRect,
44 QRect *pixmapRect, QRect *textRect, bool sizehint) const;
45 QSize viewItemSize(const QStyleOptionViewItem *option, int role) const;
46
47 mutable QRect decorationRect, displayRect, checkRect;
48 mutable QStyleOptionViewItem *cachedOption = nullptr;
49 bool isViewItemCached(const QStyleOptionViewItem &option) const {
50 return cachedOption
51 && option.index == cachedOption->index
52 && option.state == cachedOption->state
53 && option.rect == cachedOption->rect
54 && option.text == cachedOption->text
55 && option.direction == cachedOption->direction
56 && option.displayAlignment == cachedOption->displayAlignment
57 && option.decorationAlignment == cachedOption->decorationAlignment
58 && option.decorationPosition == cachedOption->decorationPosition
59 && option.decorationSize == cachedOption->decorationSize
60 && option.features == cachedOption->features
61 && option.icon.isNull() == cachedOption->icon.isNull()
62 && option.font == cachedOption->font
63 && option.viewItemPosition == cachedOption->viewItemPosition;
64 }
65 QString toolButtonElideText(const QStyleOptionToolButton *toolbutton,
66 const QRect &textRect, int flags) const;
67
68 mutable QIcon tabBarcloseButtonIcon;
69 virtual void tabLayout(const QStyleOptionTab *opt, QRect *textRect, QRect *pixmapRect) const;
70};
71
72} // namespace QQC2
73
74QT_END_NAMESPACE
75
76#endif //QCOMMONSTYLE_P_H
77

source code of qtdeclarative/src/quicknativestyle/qstyle/qquickcommonstyle_p.h