| Line | Source Code | Coverage |
|---|
| 1 | /**************************************************************************** | - |
| 2 | ** | - |
| 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). | - |
| 4 | ** Contact: http://www.qt-project.org/legal | - |
| 5 | ** | - |
| 6 | ** This file is part of the QtGui module of the Qt Toolkit. | - |
| 7 | ** | - |
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ | - |
| 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 Digia. For licensing terms and | - |
| 14 | ** conditions see http://qt.digia.com/licensing. For further information | - |
| 15 | ** use the contact form at http://qt.digia.com/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 as published by the Free Software | - |
| 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the | - |
| 21 | ** packaging of this file. Please review the following information to | - |
| 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements | - |
| 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - |
| 24 | ** | - |
| 25 | ** In addition, as a special exception, Digia gives you certain additional | - |
| 26 | ** rights. These rights are described in the Digia Qt LGPL Exception | - |
| 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - |
| 28 | ** | - |
| 29 | ** GNU General Public License Usage | - |
| 30 | ** Alternatively, this file may be used under the terms of the GNU | - |
| 31 | ** General Public License version 3.0 as published by the Free Software | - |
| 32 | ** Foundation and appearing in the file LICENSE.GPL included in the | - |
| 33 | ** packaging of this file. Please review the following information to | - |
| 34 | ** ensure the GNU General Public License version 3.0 requirements will be | - |
| 35 | ** met: http://www.gnu.org/copyleft/gpl.html. | - |
| 36 | ** | - |
| 37 | ** | - |
| 38 | ** $QT_END_LICENSE$ | - |
| 39 | ** | - |
| 40 | ****************************************************************************/ | - |
| 41 | | - |
| 42 | #include "qglobal.h" | - |
| 43 | | - |
| 44 | #ifndef QT_NO_GRAPHICSVIEW | - |
| 45 | | - |
| 46 | #include "qgraphicslayout_p.h" | - |
| 47 | #include "qgraphicslayout.h" | - |
| 48 | #include "qgraphicswidget.h" | - |
| 49 | #include "qapplication.h" | - |
| 50 | | - |
| 51 | QT_BEGIN_NAMESPACE | - |
| 52 | | - |
| 53 | /*! | - |
| 54 | \internal | - |
| 55 | | - |
| 56 | \a mw is the new parent. all items in the layout will be a child of \a mw. | - |
| 57 | */ | - |
| 58 | void QGraphicsLayoutPrivate::reparentChildItems(QGraphicsItem *newParent) | - |
| 59 | { | - |
| 60 | Q_Q(QGraphicsLayout); executed (the execution status of this line is deduced): QGraphicsLayout * const q = q_func(); | - |
| 61 | int n = q->count(); executed (the execution status of this line is deduced): int n = q->count(); | - |
| 62 | //bool mwVisible = mw && mw->isVisible(); | - |
| 63 | for (int i = 0; i < n; ++i) { evaluated: i < n| yes Evaluation Count:150 | yes Evaluation Count:261 |
| 150-261 |
| 64 | QGraphicsLayoutItem *layoutChild = q->itemAt(i); executed (the execution status of this line is deduced): QGraphicsLayoutItem *layoutChild = q->itemAt(i); | - |
| 65 | if (!layoutChild) { partially evaluated: !layoutChild| no Evaluation Count:0 | yes Evaluation Count:150 |
| 0-150 |
| 66 | // Skip stretch items | - |
| 67 | continue; never executed: continue; | 0 |
| 68 | } | - |
| 69 | if (layoutChild->isLayout()) { evaluated: layoutChild->isLayout()| yes Evaluation Count:32 | yes Evaluation Count:118 |
| 32-118 |
| 70 | QGraphicsLayout *l = static_cast<QGraphicsLayout*>(layoutChild); executed (the execution status of this line is deduced): QGraphicsLayout *l = static_cast<QGraphicsLayout*>(layoutChild); | - |
| 71 | l->d_func()->reparentChildItems(newParent); executed (the execution status of this line is deduced): l->d_func()->reparentChildItems(newParent); | - |
| 72 | } else if (QGraphicsItem *itemChild = layoutChild->graphicsItem()){ executed: }Execution Count:32 partially evaluated: QGraphicsItem *itemChild = layoutChild->graphicsItem()| yes Evaluation Count:118 | no Evaluation Count:0 |
| 0-118 |
| 73 | QGraphicsItem *childParent = itemChild->parentItem(); executed (the execution status of this line is deduced): QGraphicsItem *childParent = itemChild->parentItem(); | - |
| 74 | #ifdef QT_DEBUG | - |
| 75 | if (childParent && childParent != newParent && itemChild->isWidget() && qt_graphicsLayoutDebug()) { | - |
| 76 | QGraphicsWidget *w = static_cast<QGraphicsWidget*>(layoutChild); | - |
| 77 | qWarning("QGraphicsLayout::addChildLayout: widget %s \"%s\" in wrong parent; moved to correct parent", | - |
| 78 | w->metaObject()->className(), w->objectName().toLocal8Bit().constData()); | - |
| 79 | } | - |
| 80 | #endif | - |
| 81 | if (childParent != newParent) evaluated: childParent != newParent| yes Evaluation Count:82 | yes Evaluation Count:36 |
| 36-82 |
| 82 | itemChild->setParentItem(newParent); executed: itemChild->setParentItem(newParent);Execution Count:82 | 82 |
| 83 | } executed: }Execution Count:118 | 118 |
| 84 | } | - |
| 85 | } executed: }Execution Count:261 | 261 |
| 86 | | - |
| 87 | void QGraphicsLayoutPrivate::getMargin(qreal *result, qreal userMargin, QStyle::PixelMetric pm) const | - |
| 88 | { | - |
| 89 | if (!result) partially evaluated: !result| no Evaluation Count:0 | yes Evaluation Count:8124 |
| 0-8124 |
| 90 | return; | 0 |
| 91 | Q_Q(const QGraphicsLayout); executed (the execution status of this line is deduced): const QGraphicsLayout * const q = q_func(); | - |
| 92 | | - |
| 93 | QGraphicsLayoutItem *parent = q->parentLayoutItem(); executed (the execution status of this line is deduced): QGraphicsLayoutItem *parent = q->parentLayoutItem(); | - |
| 94 | if (userMargin >= 0.0) { evaluated: userMargin >= 0.0| yes Evaluation Count:5128 | yes Evaluation Count:2996 |
| 2996-5128 |
| 95 | *result = userMargin; executed (the execution status of this line is deduced): *result = userMargin; | - |
| 96 | } else if (!parent) { executed: }Execution Count:5128 evaluated: !parent| yes Evaluation Count:528 | yes Evaluation Count:2468 |
| 528-5128 |
| 97 | *result = 0.0; executed (the execution status of this line is deduced): *result = 0.0; | - |
| 98 | } else if (parent->isLayout()) { // sublayouts have 0 margin by default executed: }Execution Count:528 evaluated: parent->isLayout()| yes Evaluation Count:1684 | yes Evaluation Count:784 |
| 528-1684 |
| 99 | *result = 0.0; executed (the execution status of this line is deduced): *result = 0.0; | - |
| 100 | } else { executed: }Execution Count:1684 | 1684 |
| 101 | *result = 0.0; executed (the execution status of this line is deduced): *result = 0.0; | - |
| 102 | if (QGraphicsItem *layoutParentItem = parentItem()) { partially evaluated: QGraphicsItem *layoutParentItem = parentItem()| yes Evaluation Count:784 | no Evaluation Count:0 |
| 0-784 |
| 103 | if (layoutParentItem->isWidget()) partially evaluated: layoutParentItem->isWidget()| yes Evaluation Count:784 | no Evaluation Count:0 |
| 0-784 |
| 104 | *result = (qreal)static_cast<QGraphicsWidget*>(layoutParentItem)->style()->pixelMetric(pm, 0); executed: *result = (qreal)static_cast<QGraphicsWidget*>(layoutParentItem)->style()->pixelMetric(pm, 0);Execution Count:784 | 784 |
| 105 | } executed: }Execution Count:784 | 784 |
| 106 | } executed: }Execution Count:784 | 784 |
| 107 | } | - |
| 108 | | - |
| 109 | Qt::LayoutDirection QGraphicsLayoutPrivate::visualDirection() const | - |
| 110 | { | - |
| 111 | if (QGraphicsItem *maybeWidget = parentItem()) { evaluated: QGraphicsItem *maybeWidget = parentItem()| yes Evaluation Count:494 | yes Evaluation Count:3 |
| 3-494 |
| 112 | if (maybeWidget->isWidget()) partially evaluated: maybeWidget->isWidget()| yes Evaluation Count:494 | no Evaluation Count:0 |
| 0-494 |
| 113 | return static_cast<QGraphicsWidget*>(maybeWidget)->layoutDirection(); executed: return static_cast<QGraphicsWidget*>(maybeWidget)->layoutDirection();Execution Count:494 | 494 |
| 114 | } | 0 |
| 115 | return QApplication::layoutDirection(); executed: return QApplication::layoutDirection();Execution Count:3 | 3 |
| 116 | } | - |
| 117 | | - |
| 118 | static bool removeLayoutItemFromLayout(QGraphicsLayout *lay, QGraphicsLayoutItem *layoutItem) | - |
| 119 | { | - |
| 120 | if (!lay) partially evaluated: !lay| no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-3 |
| 121 | return false; never executed: return false; | 0 |
| 122 | | - |
| 123 | for (int i = lay->count() - 1; i >= 0; --i) { partially evaluated: i >= 0| yes Evaluation Count:4 | no Evaluation Count:0 |
| 0-4 |
| 124 | QGraphicsLayoutItem *child = lay->itemAt(i); executed (the execution status of this line is deduced): QGraphicsLayoutItem *child = lay->itemAt(i); | - |
| 125 | if (child && child->isLayout()) { partially evaluated: child| yes Evaluation Count:4 | no Evaluation Count:0 |
partially evaluated: child->isLayout()| no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
| 126 | if (removeLayoutItemFromLayout(static_cast<QGraphicsLayout*>(child), layoutItem)) never evaluated: removeLayoutItemFromLayout(static_cast<QGraphicsLayout*>(child), layoutItem) | 0 |
| 127 | return true; never executed: return true; | 0 |
| 128 | } else if (child == layoutItem) { never executed: } evaluated: child == layoutItem| yes Evaluation Count:3 | yes Evaluation Count:1 |
| 0-3 |
| 129 | lay->removeAt(i); executed (the execution status of this line is deduced): lay->removeAt(i); | - |
| 130 | return true; executed: return true;Execution Count:3 | 3 |
| 131 | } | - |
| 132 | } | - |
| 133 | return false; never executed: return false; | 0 |
| 134 | } | - |
| 135 | | - |
| 136 | /*! | - |
| 137 | \internal | - |
| 138 | | - |
| 139 | This function is called from subclasses to add a layout item \a layoutItem | - |
| 140 | to a layout. | - |
| 141 | | - |
| 142 | It takes care of automatically reparenting graphics items, if needed. | - |
| 143 | | - |
| 144 | If \a layoutItem is a is already in a layout, it will remove it from that layout. | - |
| 145 | | - |
| 146 | */ | - |
| 147 | void QGraphicsLayoutPrivate::addChildLayoutItem(QGraphicsLayoutItem *layoutItem) | - |
| 148 | { | - |
| 149 | Q_Q(QGraphicsLayout); executed (the execution status of this line is deduced): QGraphicsLayout * const q = q_func(); | - |
| 150 | if (QGraphicsLayoutItem *maybeLayout = layoutItem->parentLayoutItem()) { evaluated: QGraphicsLayoutItem *maybeLayout = layoutItem->parentLayoutItem()| yes Evaluation Count:3 | yes Evaluation Count:1339 |
| 3-1339 |
| 151 | if (maybeLayout->isLayout()) partially evaluated: maybeLayout->isLayout()| yes Evaluation Count:3 | no Evaluation Count:0 |
| 0-3 |
| 152 | removeLayoutItemFromLayout(static_cast<QGraphicsLayout*>(maybeLayout), layoutItem); executed: removeLayoutItemFromLayout(static_cast<QGraphicsLayout*>(maybeLayout), layoutItem);Execution Count:3 | 3 |
| 153 | } executed: }Execution Count:3 | 3 |
| 154 | layoutItem->setParentLayoutItem(q); executed (the execution status of this line is deduced): layoutItem->setParentLayoutItem(q); | - |
| 155 | if (layoutItem->isLayout()) { evaluated: layoutItem->isLayout()| yes Evaluation Count:219 | yes Evaluation Count:1123 |
| 219-1123 |
| 156 | if (QGraphicsItem *parItem = parentItem()) { evaluated: QGraphicsItem *parItem = parentItem()| yes Evaluation Count:42 | yes Evaluation Count:177 |
| 42-177 |
| 157 | static_cast<QGraphicsLayout*>(layoutItem)->d_func()->reparentChildItems(parItem); executed (the execution status of this line is deduced): static_cast<QGraphicsLayout*>(layoutItem)->d_func()->reparentChildItems(parItem); | - |
| 158 | } executed: }Execution Count:42 | 42 |
| 159 | } else { executed: }Execution Count:219 | 219 |
| 160 | if (QGraphicsItem *item = layoutItem->graphicsItem()) { evaluated: QGraphicsItem *item = layoutItem->graphicsItem()| yes Evaluation Count:1120 | yes Evaluation Count:3 |
| 3-1120 |
| 161 | QGraphicsItem *newParent = parentItem(); executed (the execution status of this line is deduced): QGraphicsItem *newParent = parentItem(); | - |
| 162 | QGraphicsItem *oldParent = item->parentItem(); executed (the execution status of this line is deduced): QGraphicsItem *oldParent = item->parentItem(); | - |
| 163 | if (oldParent == newParent || !newParent) evaluated: oldParent == newParent| yes Evaluation Count:697 | yes Evaluation Count:423 |
evaluated: !newParent| yes Evaluation Count:38 | yes Evaluation Count:385 |
| 38-697 |
| 164 | return; executed: return;Execution Count:735 | 735 |
| 165 | | - |
| 166 | #ifdef QT_DEBUG | - |
| 167 | if (oldParent && item->isWidget()) { | - |
| 168 | QGraphicsWidget *w = static_cast<QGraphicsWidget*>(item); | - |
| 169 | qWarning("QGraphicsLayout::addChildLayoutItem: %s \"%s\" in wrong parent; moved to correct parent", | - |
| 170 | w->metaObject()->className(), w->objectName().toLocal8Bit().constData()); | - |
| 171 | } | - |
| 172 | #endif | - |
| 173 | | - |
| 174 | item->setParentItem(newParent); executed (the execution status of this line is deduced): item->setParentItem(newParent); | - |
| 175 | } executed: }Execution Count:385 | 385 |
| 176 | } executed: }Execution Count:388 | 388 |
| 177 | } | - |
| 178 | | - |
| 179 | void QGraphicsLayoutPrivate::activateRecursive(QGraphicsLayoutItem *item) | - |
| 180 | { | - |
| 181 | if (item->isLayout()) { evaluated: item->isLayout()| yes Evaluation Count:323 | yes Evaluation Count:852 |
| 323-852 |
| 182 | QGraphicsLayout *layout = static_cast<QGraphicsLayout *>(item); executed (the execution status of this line is deduced): QGraphicsLayout *layout = static_cast<QGraphicsLayout *>(item); | - |
| 183 | if (layout->d_func()->activated) { evaluated: layout->d_func()->activated| yes Evaluation Count:71 | yes Evaluation Count:252 |
| 71-252 |
| 184 | if (QGraphicsLayout::instantInvalidatePropagation()) { partially evaluated: QGraphicsLayout::instantInvalidatePropagation()| no Evaluation Count:0 | yes Evaluation Count:71 |
| 0-71 |
| 185 | return; | 0 |
| 186 | } else { | - |
| 187 | layout->invalidate(); // ### LOOKS SUSPICIOUSLY WRONG!!??? executed (the execution status of this line is deduced): layout->invalidate(); | - |
| 188 | } executed: }Execution Count:71 | 71 |
| 189 | } | - |
| 190 | | - |
| 191 | for (int i = layout->count() - 1; i >= 0; --i) { evaluated: i >= 0| yes Evaluation Count:923 | yes Evaluation Count:323 |
| 323-923 |
| 192 | QGraphicsLayoutItem *childItem = layout->itemAt(i); executed (the execution status of this line is deduced): QGraphicsLayoutItem *childItem = layout->itemAt(i); | - |
| 193 | if (childItem) partially evaluated: childItem| yes Evaluation Count:923 | no Evaluation Count:0 |
| 0-923 |
| 194 | activateRecursive(childItem); executed: activateRecursive(childItem);Execution Count:923 | 923 |
| 195 | } executed: }Execution Count:923 | 923 |
| 196 | layout->d_func()->activated = true; executed (the execution status of this line is deduced): layout->d_func()->activated = true; | - |
| 197 | } executed: }Execution Count:323 | 323 |
| 198 | } executed: }Execution Count:1175 | 1175 |
| 199 | | - |
| 200 | | - |
| 201 | QT_END_NAMESPACE | - |
| 202 | | - |
| 203 | #endif //QT_NO_GRAPHICSVIEW | - |
| 204 | | - |
| | |