| 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 | |
| 11 | QT_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 | |
| 24 | class QTextOption; |
| 25 | |
| 26 | namespace QQC2 { |
| 27 | |
| 28 | class QCommonStylePrivate : public QStylePrivate |
| 29 | { |
| 30 | Q_DECLARE_PUBLIC(QCommonStyle) |
| 31 | public: |
| 32 | |
| 33 | #if QT_CONFIG(quick_itemview) |
| 34 | ~QCommonStylePrivate() |
| 35 | { |
| 36 | delete cachedOption; |
| 37 | } |
| 38 | #endif // QT_CONFIG(quick_itemview) |
| 39 | |
| 40 | QString calculateElidedText(const QString &text, const QTextOption &textOption, |
| 41 | const QFont &font, const QRect &textRect, const Qt::Alignment valign, |
| 42 | Qt::TextElideMode textElideMode, int flags, |
| 43 | bool lastVisibleLineShouldBeElided, QPointF *paintStartPosition) const; |
| 44 | #if QT_CONFIG(quick_itemview) |
| 45 | void viewItemDrawText(QPainter *p, const QStyleOptionViewItem *option, const QRect &rect) const; |
| 46 | void viewItemLayout(const QStyleOptionViewItem *opt, QRect *checkRect, |
| 47 | QRect *pixmapRect, QRect *textRect, bool sizehint) const; |
| 48 | QSize viewItemSize(const QStyleOptionViewItem *option, int role) const; |
| 49 | |
| 50 | mutable QRect decorationRect, displayRect, checkRect; |
| 51 | mutable QStyleOptionViewItem *cachedOption = nullptr; |
| 52 | bool isViewItemCached(const QStyleOptionViewItem &option) const { |
| 53 | return cachedOption |
| 54 | && option.index == cachedOption->index |
| 55 | && option.state == cachedOption->state |
| 56 | && option.rect == cachedOption->rect |
| 57 | && option.text == cachedOption->text |
| 58 | && option.direction == cachedOption->direction |
| 59 | && option.displayAlignment == cachedOption->displayAlignment |
| 60 | && option.decorationAlignment == cachedOption->decorationAlignment |
| 61 | && option.decorationPosition == cachedOption->decorationPosition |
| 62 | && option.decorationSize == cachedOption->decorationSize |
| 63 | && option.features == cachedOption->features |
| 64 | && option.icon.isNull() == cachedOption->icon.isNull() |
| 65 | && option.font == cachedOption->font |
| 66 | && option.viewItemPosition == cachedOption->viewItemPosition; |
| 67 | } |
| 68 | #endif // QT_CONFIG(quick_itemview) |
| 69 | QString toolButtonElideText(const QStyleOptionToolButton *toolbutton, |
| 70 | const QRect &textRect, int flags) const; |
| 71 | |
| 72 | mutable QIcon tabBarcloseButtonIcon; |
| 73 | virtual void tabLayout(const QStyleOptionTab *opt, QRect *textRect, QRect *pixmapRect) const; |
| 74 | }; |
| 75 | |
| 76 | } // namespace QQC2 |
| 77 | |
| 78 | QT_END_NAMESPACE |
| 79 | |
| 80 | #endif //QCOMMONSTYLE_P_H |
| 81 | |