graphicsview/qgraphicslayout.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4 -
5 -
6QGraphicsLayout::QGraphicsLayout(QGraphicsLayoutItem *parent) -
7 : QGraphicsLayoutItem(*new QGraphicsLayoutPrivate) -
8{ -
9 setParentLayoutItem(parent); -
10 if (parent && !parent->isLayout()) {
evaluated: parent
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:5
partially evaluated: !parent->isLayout()
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-5
11 -
12 QGraphicsItem *itemParent = parent->graphicsItem(); -
13 if (itemParent && itemParent->isWidget()) {
partially evaluated: itemParent
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
partially evaluated: itemParent->isWidget()
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
14 static_cast<QGraphicsWidget *>(itemParent)->d_func()->setLayout_helper(this); -
15 } else {
executed: }
Execution Count:1
1
16 QMessageLogger("graphicsview/qgraphicslayout.cpp", 171, __PRETTY_FUNCTION__).warning("QGraphicsLayout::QGraphicsLayout: Attempt to create a layout with a parent that is" -
17 " neither a QGraphicsWidget nor QGraphicsLayout"); -
18 }
never executed: }
0
19 } -
20 d_func()->sizePolicy = QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding, QSizePolicy::DefaultType); -
21 setOwnedByLayout(true); -
22}
executed: }
Execution Count:6
6
23 -
24 -
25 -
26 -
27QGraphicsLayout::QGraphicsLayout(QGraphicsLayoutPrivate &dd, QGraphicsLayoutItem *parent) -
28 : QGraphicsLayoutItem(dd) -
29{ -
30 setParentLayoutItem(parent); -
31 if (parent && !parent->isLayout()) {
evaluated: parent
TRUEFALSE
yes
Evaluation Count:26
yes
Evaluation Count:638
partially evaluated: !parent->isLayout()
TRUEFALSE
yes
Evaluation Count:26
no
Evaluation Count:0
0-638
32 -
33 QGraphicsItem *itemParent = parent->graphicsItem(); -
34 if (itemParent && itemParent->isWidget()) {
partially evaluated: itemParent
TRUEFALSE
yes
Evaluation Count:26
no
Evaluation Count:0
partially evaluated: itemParent->isWidget()
TRUEFALSE
yes
Evaluation Count:26
no
Evaluation Count:0
0-26
35 static_cast<QGraphicsWidget *>(itemParent)->d_func()->setLayout_helper(this); -
36 } else {
executed: }
Execution Count:26
26
37 QMessageLogger("graphicsview/qgraphicslayout.cpp", 192, __PRETTY_FUNCTION__).warning("QGraphicsLayout::QGraphicsLayout: Attempt to create a layout with a parent that is" -
38 " neither a QGraphicsWidget nor QGraphicsLayout"); -
39 }
never executed: }
0
40 } -
41 d_func()->sizePolicy = QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding, QSizePolicy::DefaultType); -
42 setOwnedByLayout(true); -
43}
executed: }
Execution Count:664
664
44 -
45 -
46 -
47 -
48QGraphicsLayout::~QGraphicsLayout() -
49{ -
50} -
51void QGraphicsLayout::setContentsMargins(qreal left, qreal top, qreal right, qreal bottom) -
52{ -
53 QGraphicsLayoutPrivate * const d = d_func(); -
54 if (d->left == left && d->top == top && d->right == right && d->bottom == bottom)
partially evaluated: d->left == left
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:241
never evaluated: d->top == top
never evaluated: d->right == right
never evaluated: d->bottom == bottom
0-241
55 return;
never executed: return;
0
56 d->left = left; -
57 d->right = right; -
58 d->top = top; -
59 d->bottom = bottom; -
60 invalidate(); -
61}
executed: }
Execution Count:241
241
62 -
63 -
64 -
65 -
66void QGraphicsLayout::getContentsMargins(qreal *left, qreal *top, qreal *right, qreal *bottom) const -
67{ -
68 const QGraphicsLayoutPrivate * const d = d_func(); -
69 d->getMargin(left, d->left, QStyle::PM_LayoutLeftMargin); -
70 d->getMargin(top, d->top, QStyle::PM_LayoutTopMargin); -
71 d->getMargin(right, d->right, QStyle::PM_LayoutRightMargin); -
72 d->getMargin(bottom, d->bottom, QStyle::PM_LayoutBottomMargin); -
73}
executed: }
Execution Count:2031
2031
74void QGraphicsLayout::activate() -
75{ -
76 QGraphicsLayoutPrivate * const d = d_func(); -
77 if (d->activated)
evaluated: d->activated
TRUEFALSE
yes
Evaluation Count:204
yes
Evaluation Count:252
204-252
78 return;
executed: return;
Execution Count:204
204
79 -
80 d->activateRecursive(this); -
81 -
82 -
83 -
84 QGraphicsLayoutItem *parentItem = this; -
85 while (parentItem && parentItem->isLayout())
partially evaluated: parentItem
TRUEFALSE
yes
Evaluation Count:504
no
Evaluation Count:0
evaluated: parentItem->isLayout()
TRUEFALSE
yes
Evaluation Count:252
yes
Evaluation Count:252
0-504
86 parentItem = parentItem->parentLayoutItem();
executed: parentItem = parentItem->parentLayoutItem();
Execution Count:252
252
87 if (!parentItem)
partially evaluated: !parentItem
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:252
0-252
88 return;
never executed: return;
0
89 qt_noop(); -
90 -
91 if (QGraphicsLayout::instantInvalidatePropagation()) {
evaluated: QGraphicsLayout::instantInvalidatePropagation()
TRUEFALSE
yes
Evaluation Count:18
yes
Evaluation Count:234
18-234
92 QGraphicsWidget *parentWidget = static_cast<QGraphicsWidget*>(parentItem); -
93 if (!parentWidget->parentLayoutItem()) {
evaluated: !parentWidget->parentLayoutItem()
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:10
8-10
94 -
95 bool wasResized = parentWidget->testAttribute(Qt::WA_Resized); -
96 parentWidget->resize(parentWidget->size()); -
97 parentWidget->setAttribute(Qt::WA_Resized, wasResized); -
98 }
executed: }
Execution Count:8
8
99 -
100 setGeometry(parentItem->contentsRect()); -
101 } else {
executed: }
Execution Count:18
18
102 setGeometry(parentItem->contentsRect()); -
103 parentLayoutItem()->updateGeometry(); -
104 }
executed: }
Execution Count:234
234
105} -
106bool QGraphicsLayout::isActivated() const -
107{ -
108 const QGraphicsLayoutPrivate * const d = d_func(); -
109 return d->activated;
executed: return d->activated;
Execution Count:332
332
110} -
111void QGraphicsLayout::invalidate() -
112{ -
113 if (QGraphicsLayout::instantInvalidatePropagation()) {
evaluated: QGraphicsLayout::instantInvalidatePropagation()
TRUEFALSE
yes
Evaluation Count:39
yes
Evaluation Count:3802
39-3802
114 updateGeometry(); -
115 } else {
executed: }
Execution Count:39
39
116 -
117 QGraphicsLayoutItem *layoutItem = this; -
118 while (layoutItem && layoutItem->isLayout()) {
evaluated: layoutItem
TRUEFALSE
yes
Evaluation Count:6491
yes
Evaluation Count:1189
evaluated: layoutItem->isLayout()
TRUEFALSE
yes
Evaluation Count:3878
yes
Evaluation Count:2613
1189-6491
119 -
120 -
121 -
122 layoutItem->d_func()->sizeHintCacheDirty = true; -
123 layoutItem->d_func()->sizeHintWithConstraintCacheDirty = true; -
124 layoutItem = layoutItem->parentLayoutItem(); -
125 }
executed: }
Execution Count:3878
3878
126 if (layoutItem) {
evaluated: layoutItem
TRUEFALSE
yes
Evaluation Count:2613
yes
Evaluation Count:1189
1189-2613
127 layoutItem->d_func()->sizeHintCacheDirty = true; -
128 layoutItem->d_func()->sizeHintWithConstraintCacheDirty = true; -
129 }
executed: }
Execution Count:2613
2613
130 -
131 bool postIt = layoutItem ? !layoutItem->isLayout() : false;
evaluated: layoutItem
TRUEFALSE
yes
Evaluation Count:2613
yes
Evaluation Count:1189
1189-2613
132 if (postIt) {
evaluated: postIt
TRUEFALSE
yes
Evaluation Count:2613
yes
Evaluation Count:1189
1189-2613
133 layoutItem = this; -
134 while (layoutItem && layoutItem->isLayout()
partially evaluated: layoutItem
TRUEFALSE
yes
Evaluation Count:3102
no
Evaluation Count:0
evaluated: layoutItem->isLayout()
TRUEFALSE
yes
Evaluation Count:2685
yes
Evaluation Count:417
0-3102
135 && static_cast<QGraphicsLayout*>(layoutItem)->d_func()->activated) {
evaluated: static_cast<QGraphicsLayout*>(layoutItem)->d_func()->activated
TRUEFALSE
yes
Evaluation Count:489
yes
Evaluation Count:2196
489-2196
136 static_cast<QGraphicsLayout*>(layoutItem)->d_func()->activated = false; -
137 layoutItem = layoutItem->parentLayoutItem(); -
138 }
executed: }
Execution Count:489
489
139 if (layoutItem && !layoutItem->isLayout()) {
partially evaluated: layoutItem
TRUEFALSE
yes
Evaluation Count:2613
no
Evaluation Count:0
evaluated: !layoutItem->isLayout()
TRUEFALSE
yes
Evaluation Count:417
yes
Evaluation Count:2196
0-2613
140 -
141 QApplication::postEvent(static_cast<QGraphicsWidget *>(layoutItem), new QEvent(QEvent::LayoutRequest)); -
142 }
executed: }
Execution Count:417
417
143 }
executed: }
Execution Count:2613
2613
144 }
executed: }
Execution Count:3802
3802
145} -
146 -
147 -
148 -
149 -
150void QGraphicsLayout::updateGeometry() -
151{ -
152 QGraphicsLayoutPrivate * const d = d_func(); -
153 if (QGraphicsLayout::instantInvalidatePropagation()) {
evaluated: QGraphicsLayout::instantInvalidatePropagation()
TRUEFALSE
yes
Evaluation Count:39
yes
Evaluation Count:300
39-300
154 d->activated = false; -
155 QGraphicsLayoutItem::updateGeometry(); -
156 -
157 QGraphicsLayoutItem *parentItem = parentLayoutItem(); -
158 if (!parentItem)
partially evaluated: !parentItem
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:39
0-39
159 return;
never executed: return;
0
160 -
161 if (parentItem->isLayout())
partially evaluated: parentItem->isLayout()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:39
0-39
162 static_cast<QGraphicsLayout *>(parentItem)->invalidate();
never executed: static_cast<QGraphicsLayout *>(parentItem)->invalidate();
0
163 else -
164 parentItem->updateGeometry();
executed: parentItem->updateGeometry();
Execution Count:39
39
165 } else { -
166 QGraphicsLayoutItem::updateGeometry(); -
167 if (QGraphicsLayoutItem *parentItem = parentLayoutItem()) {
evaluated: QGraphicsLayoutItem *parentItem = parentLayoutItem()
TRUEFALSE
yes
Evaluation Count:193
yes
Evaluation Count:107
107-193
168 if (parentItem->isLayout()) {
evaluated: parentItem->isLayout()
TRUEFALSE
yes
Evaluation Count:15
yes
Evaluation Count:178
15-178
169 parentItem->updateGeometry(); -
170 } else {
executed: }
Execution Count:15
15
171 invalidate(); -
172 }
executed: }
Execution Count:178
178
173 } -
174 }
executed: }
Execution Count:300
300
175} -
176void QGraphicsLayout::widgetEvent(QEvent *e) -
177{ -
178 switch (e->type()) { -
179 case QEvent::GraphicsSceneResize: -
180 if (isActivated()) {
evaluated: isActivated()
TRUEFALSE
yes
Evaluation Count:116
yes
Evaluation Count:142
116-142
181 setGeometry(parentLayoutItem()->contentsRect()); -
182 } else {
executed: }
Execution Count:116
116
183 activate(); -
184 }
executed: }
Execution Count:142
142
185 break;
executed: break;
Execution Count:258
258
186 case QEvent::LayoutRequest: -
187 activate(); -
188 break;
executed: break;
Execution Count:201
201
189 case QEvent::LayoutDirectionChange: -
190 invalidate(); -
191 break;
executed: break;
Execution Count:3
3
192 default: -
193 break;
executed: break;
Execution Count:318
318
194 } -
195}
executed: }
Execution Count:780
780
196void QGraphicsLayout::addChildLayoutItem(QGraphicsLayoutItem *layoutItem) -
197{ -
198 QGraphicsLayoutPrivate * const d = d_func(); -
199 d->addChildLayoutItem(layoutItem); -
200}
never executed: }
0
201 -
202static bool g_instantInvalidatePropagation = false; -
203void QGraphicsLayout::setInstantInvalidatePropagation(bool enable) -
204{ -
205 g_instantInvalidatePropagation = enable; -
206}
executed: }
Execution Count:2
2
207bool QGraphicsLayout::instantInvalidatePropagation() -
208{ -
209 return g_instantInvalidatePropagation;
executed: return g_instantInvalidatePropagation;
Execution Count:16885
16885
210} -
211 -
212 -
213 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial