| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/widgets/graphicsview/qgraphicslayoutstyleinfo.cpp |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | /**************************************************************************** | - | ||||||||||||
| 2 | ** | - | ||||||||||||
| 3 | ** Copyright (C) 2015 The Qt Company Ltd. | - | ||||||||||||
| 4 | ** Contact: http://www.qt.io/licensing/ | - | ||||||||||||
| 5 | ** | - | ||||||||||||
| 6 | ** This file is part of the QtWidgets module of the Qt Toolkit. | - | ||||||||||||
| 7 | ** | - | ||||||||||||
| 8 | ** $QT_BEGIN_LICENSE:LGPL21$ | - | ||||||||||||
| 9 | ** Commercial License Usage | - | ||||||||||||
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||
| 11 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||
| 12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||
| 13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||
| 14 | ** and conditions see http://www.qt.io/terms-conditions. For further | - | ||||||||||||
| 15 | ** information use the contact form at http://www.qt.io/contact-us. | - | ||||||||||||
| 16 | ** | - | ||||||||||||
| 17 | ** GNU Lesser General Public License Usage | - | ||||||||||||
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||||||||
| 19 | ** General Public License version 2.1 or version 3 as published by the Free | - | ||||||||||||
| 20 | ** Software Foundation and appearing in the file LICENSE.LGPLv21 and | - | ||||||||||||
| 21 | ** LICENSE.LGPLv3 included in the packaging of this file. Please review the | - | ||||||||||||
| 22 | ** following information to ensure the GNU Lesser General Public License | - | ||||||||||||
| 23 | ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and | - | ||||||||||||
| 24 | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - | ||||||||||||
| 25 | ** | - | ||||||||||||
| 26 | ** As a special exception, The Qt Company gives you certain additional | - | ||||||||||||
| 27 | ** rights. These rights are described in The Qt Company LGPL Exception | - | ||||||||||||
| 28 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - | ||||||||||||
| 29 | ** | - | ||||||||||||
| 30 | ** $QT_END_LICENSE$ | - | ||||||||||||
| 31 | ** | - | ||||||||||||
| 32 | ****************************************************************************/ | - | ||||||||||||
| 33 | - | |||||||||||||
| 34 | #include "qgraphicslayoutstyleinfo_p.h" | - | ||||||||||||
| 35 | - | |||||||||||||
| 36 | #ifndef QT_NO_GRAPHICSVIEW | - | ||||||||||||
| 37 | - | |||||||||||||
| 38 | #include "qgraphicslayout_p.h" | - | ||||||||||||
| 39 | #include "qgraphicswidget.h" | - | ||||||||||||
| 40 | #include <QtWidgets/qstyle.h> | - | ||||||||||||
| 41 | #include <QtWidgets/qwidget.h> | - | ||||||||||||
| 42 | #include <QtWidgets/qapplication.h> | - | ||||||||||||
| 43 | - | |||||||||||||
| 44 | QT_BEGIN_NAMESPACE | - | ||||||||||||
| 45 | - | |||||||||||||
| 46 | QGraphicsLayoutStyleInfo::QGraphicsLayoutStyleInfo(const QGraphicsLayoutPrivate *layout) | - | ||||||||||||
| 47 | : m_layout(layout), m_style(0) | - | ||||||||||||
| 48 | { | - | ||||||||||||
| 49 | m_widget = new QWidget; // pixelMetric might need a widget ptr | - | ||||||||||||
| 50 | if (m_widget)
| 0 | ||||||||||||
| 51 | m_styleOption.initFrom(m_widget); never executed: m_styleOption.initFrom(m_widget); | 0 | ||||||||||||
| 52 | m_isWindow = m_styleOption.state & QStyle::State_Window; | - | ||||||||||||
| 53 | } never executed: end of block | 0 | ||||||||||||
| 54 | - | |||||||||||||
| 55 | QGraphicsLayoutStyleInfo::~QGraphicsLayoutStyleInfo() | - | ||||||||||||
| 56 | { | - | ||||||||||||
| 57 | delete m_widget; | - | ||||||||||||
| 58 | } never executed: end of block | 0 | ||||||||||||
| 59 | - | |||||||||||||
| 60 | qreal QGraphicsLayoutStyleInfo::combinedLayoutSpacing(QLayoutPolicy::ControlTypes controls1, | - | ||||||||||||
| 61 | QLayoutPolicy::ControlTypes controls2, | - | ||||||||||||
| 62 | Qt::Orientation orientation) const | - | ||||||||||||
| 63 | { | - | ||||||||||||
| 64 | Q_ASSERT(style()); | - | ||||||||||||
| 65 | return style()->combinedLayoutSpacing(QSizePolicy::ControlTypes(int(controls1)), QSizePolicy::ControlTypes(int(controls2)), never executed: return style()->combinedLayoutSpacing(QSizePolicy::ControlTypes(int(controls1)), QSizePolicy::ControlTypes(int(controls2)), orientation, const_cast<QStyleOption*>(&m_styleOption), widget()); | 0 | ||||||||||||
| 66 | orientation, const_cast<QStyleOption*>(&m_styleOption), widget()); never executed: return style()->combinedLayoutSpacing(QSizePolicy::ControlTypes(int(controls1)), QSizePolicy::ControlTypes(int(controls2)), orientation, const_cast<QStyleOption*>(&m_styleOption), widget()); | 0 | ||||||||||||
| 67 | } | - | ||||||||||||
| 68 | - | |||||||||||||
| 69 | qreal QGraphicsLayoutStyleInfo::perItemSpacing(QLayoutPolicy::ControlType control1, | - | ||||||||||||
| 70 | QLayoutPolicy::ControlType control2, | - | ||||||||||||
| 71 | Qt::Orientation orientation) const | - | ||||||||||||
| 72 | { | - | ||||||||||||
| 73 | Q_ASSERT(style()); | - | ||||||||||||
| 74 | return style()->layoutSpacing(QSizePolicy::ControlType(control1), QSizePolicy::ControlType(control2), never executed: return style()->layoutSpacing(QSizePolicy::ControlType(control1), QSizePolicy::ControlType(control2), orientation, const_cast<QStyleOption*>(&m_styleOption), widget()); | 0 | ||||||||||||
| 75 | orientation, const_cast<QStyleOption*>(&m_styleOption), widget()); never executed: return style()->layoutSpacing(QSizePolicy::ControlType(control1), QSizePolicy::ControlType(control2), orientation, const_cast<QStyleOption*>(&m_styleOption), widget()); | 0 | ||||||||||||
| 76 | } | - | ||||||||||||
| 77 | - | |||||||||||||
| 78 | qreal QGraphicsLayoutStyleInfo::spacing(Qt::Orientation orientation) const | - | ||||||||||||
| 79 | { | - | ||||||||||||
| 80 | Q_ASSERT(style()); | - | ||||||||||||
| 81 | return style()->pixelMetric(orientation == Qt::Horizontal ? QStyle::PM_LayoutHorizontalSpacing : QStyle::PM_LayoutVerticalSpacing); never executed: return style()->pixelMetric(orientation == Qt::Horizontal ? QStyle::PM_LayoutHorizontalSpacing : QStyle::PM_LayoutVerticalSpacing); | 0 | ||||||||||||
| 82 | } | - | ||||||||||||
| 83 | - | |||||||||||||
| 84 | qreal QGraphicsLayoutStyleInfo::windowMargin(Qt::Orientation orientation) const | - | ||||||||||||
| 85 | { | - | ||||||||||||
| 86 | return style()->pixelMetric(orientation == Qt::Vertical never executed: return style()->pixelMetric(orientation == Qt::Vertical ? QStyle::PM_LayoutBottomMargin : QStyle::PM_LayoutRightMargin, const_cast<QStyleOption*>(&m_styleOption), widget()); | 0 | ||||||||||||
| 87 | ? QStyle::PM_LayoutBottomMargin never executed: return style()->pixelMetric(orientation == Qt::Vertical ? QStyle::PM_LayoutBottomMargin : QStyle::PM_LayoutRightMargin, const_cast<QStyleOption*>(&m_styleOption), widget()); | 0 | ||||||||||||
| 88 | : QStyle::PM_LayoutRightMargin, never executed: return style()->pixelMetric(orientation == Qt::Vertical ? QStyle::PM_LayoutBottomMargin : QStyle::PM_LayoutRightMargin, const_cast<QStyleOption*>(&m_styleOption), widget()); | 0 | ||||||||||||
| 89 | const_cast<QStyleOption*>(&m_styleOption), widget()); never executed: return style()->pixelMetric(orientation == Qt::Vertical ? QStyle::PM_LayoutBottomMargin : QStyle::PM_LayoutRightMargin, const_cast<QStyleOption*>(&m_styleOption), widget()); | 0 | ||||||||||||
| 90 | } | - | ||||||||||||
| 91 | - | |||||||||||||
| 92 | QWidget *QGraphicsLayoutStyleInfo::widget() const { return m_widget; } never executed: return m_widget; | 0 | ||||||||||||
| 93 | - | |||||||||||||
| 94 | QStyle *QGraphicsLayoutStyleInfo::style() const | - | ||||||||||||
| 95 | { | - | ||||||||||||
| 96 | if (!m_style) {
| 0 | ||||||||||||
| 97 | Q_ASSERT(m_layout); | - | ||||||||||||
| 98 | QGraphicsItem *item = m_layout->parentItem(); | - | ||||||||||||
| 99 | m_style = (item && item->isWidget()) ? static_cast<QGraphicsWidget*>(item)->style() : QApplication::style();
| 0 | ||||||||||||
| 100 | } never executed: end of block | 0 | ||||||||||||
| 101 | return m_style; never executed: return m_style; | 0 | ||||||||||||
| 102 | } | - | ||||||||||||
| 103 | - | |||||||||||||
| 104 | QT_END_NAMESPACE | - | ||||||||||||
| 105 | - | |||||||||||||
| 106 | #endif // QT_NO_GRAPHICSVIEW | - | ||||||||||||
| Source code | Switch to Preprocessed file |