qgraphicslayout.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/widgets/graphicsview/qgraphicslayout.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6QGraphicsLayout::QGraphicsLayout(QGraphicsLayoutItem *parent)-
7 : QGraphicsLayoutItem(*new QGraphicsLayoutPrivate)-
8{-
9 setParentLayoutItem(parent);-
10 if (parent
parentDescription
TRUEnever evaluated
FALSEnever evaluated
&& !parent->isLayout()
!parent->isLayout()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
11-
12 QGraphicsItem *itemParent = parent->graphicsItem();-
13 if (itemParent
itemParentDescription
TRUEnever evaluated
FALSEnever evaluated
&& itemParent->isWidget()
itemParent->isWidget()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
14 static_cast<QGraphicsWidget *>(itemParent)->d_func()->setLayout_helper(this);-
15 }
never executed: end of block
else {
0
16 QMessageLogger(__FILE__, 169, __PRETTY_FUNCTION__).warning("QGraphicsLayout::QGraphicsLayout: Attempt to create a layout with a parent that is"-
17 " neither a QGraphicsWidget nor QGraphicsLayout");-
18 }
never executed: end of block
0
19 }-
20 d_func()->sizePolicy = QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding, QSizePolicy::DefaultType);-
21 setOwnedByLayout(true);-
22}
never executed: end of block
0
23-
24-
25-
26-
27QGraphicsLayout::QGraphicsLayout(QGraphicsLayoutPrivate &dd, QGraphicsLayoutItem *parent)-
28 : QGraphicsLayoutItem(dd)-
29{-
30 setParentLayoutItem(parent);-
31 if (parent
parentDescription
TRUEnever evaluated
FALSEnever evaluated
&& !parent->isLayout()
!parent->isLayout()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
32-
33 QGraphicsItem *itemParent = parent->graphicsItem();-
34 if (itemParent
itemParentDescription
TRUEnever evaluated
FALSEnever evaluated
&& itemParent->isWidget()
itemParent->isWidget()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
35 static_cast<QGraphicsWidget *>(itemParent)->d_func()->setLayout_helper(this);-
36 }
never executed: end of block
else {
0
37 QMessageLogger(__FILE__, 190, __PRETTY_FUNCTION__).warning("QGraphicsLayout::QGraphicsLayout: Attempt to create a layout with a parent that is"-
38 " neither a QGraphicsWidget nor QGraphicsLayout");-
39 }
never executed: end of block
0
40 }-
41 d_func()->sizePolicy = QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding, QSizePolicy::DefaultType);-
42 setOwnedByLayout(true);-
43}
never executed: end of block
0
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->left == leftDescription
TRUEnever evaluated
FALSEnever evaluated
&& d->top == top
d->top == topDescription
TRUEnever evaluated
FALSEnever evaluated
&& d->right == right
d->right == rightDescription
TRUEnever evaluated
FALSEnever evaluated
&& d->bottom == bottom
d->bottom == bottomDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
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}
never executed: end of block
0
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}
never executed: end of block
0
74void QGraphicsLayout::activate()-
75{-
76 QGraphicsLayoutPrivate * const d = d_func();-
77 if (d->activated
d->activatedDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
78 return;
never executed: return;
0
79-
80 d->activateRecursive(this);-
81-
82-
83-
84 QGraphicsLayoutItem *parentItem = this;-
85 while (parentItem
parentItemDescription
TRUEnever evaluated
FALSEnever evaluated
&& parentItem->isLayout()
parentItem->isLayout()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
86 parentItem = parentItem->parentLayoutItem();
never executed: parentItem = parentItem->parentLayoutItem();
0
87 if (!parentItem
!parentItemDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
88 return;
never executed: return;
0
89 ((!(!parentItem->isLayout())) ? qt_assert("!parentItem->isLayout()",__FILE__,273) : qt_noop());-
90-
91 if (QGraphicsLayout::instantInvalidatePropagation()
QGraphicsLayou...ePropagation()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
92 QGraphicsWidget *parentWidget = static_cast<QGraphicsWidget*>(parentItem);-
93 if (!parentWidget->parentLayoutItem()
!parentWidget-...ntLayoutItem()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
94-
95 bool wasResized = parentWidget->testAttribute(Qt::WA_Resized);-
96 parentWidget->resize(parentWidget->size());-
97 parentWidget->setAttribute(Qt::WA_Resized, wasResized);-
98 }
never executed: end of block
0
99-
100 setGeometry(parentItem->contentsRect());-
101 }
never executed: end of block
else {
0
102 setGeometry(parentItem->contentsRect());-
103 parentLayoutItem()->updateGeometry();-
104 }
never executed: end of block
0
105}-
106bool QGraphicsLayout::isActivated() const-
107{-
108 const QGraphicsLayoutPrivate * const d = d_func();-
109 return
never executed: return d->activated;
d->activated;
never executed: return d->activated;
0
110}-
111void QGraphicsLayout::invalidate()-
112{-
113 if (QGraphicsLayout::instantInvalidatePropagation()
QGraphicsLayou...ePropagation()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
114 updateGeometry();-
115 }
never executed: end of block
else {
0
116-
117 QGraphicsLayoutItem *layoutItem = this;-
118 while (layoutItem
layoutItemDescription
TRUEnever evaluated
FALSEnever evaluated
&& layoutItem->isLayout()
layoutItem->isLayout()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
119-
120-
121-
122 layoutItem->d_func()->sizeHintCacheDirty = true;-
123 layoutItem->d_func()->sizeHintWithConstraintCacheDirty = true;-
124 layoutItem = layoutItem->parentLayoutItem();-
125 }
never executed: end of block
0
126 if (layoutItem
layoutItemDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
127 layoutItem->d_func()->sizeHintCacheDirty = true;-
128 layoutItem->d_func()->sizeHintWithConstraintCacheDirty = true;-
129 }
never executed: end of block
0
130-
131 bool postIt = layoutItem
layoutItemDescription
TRUEnever evaluated
FALSEnever evaluated
? !layoutItem->isLayout() : false;
0
132 if (postIt
postItDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
133 layoutItem = this;-
134 while (layoutItem
layoutItemDescription
TRUEnever evaluated
FALSEnever evaluated
&& layoutItem->isLayout()
layoutItem->isLayout()Description
TRUEnever evaluated
FALSEnever evaluated
0
135 && static_cast<
static_cast<QG...c()->activatedDescription
TRUEnever evaluated
FALSEnever evaluated
QGraphicsLayout*>(layoutItem)->d_func()->activated
static_cast<QG...c()->activatedDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
136 static_cast<QGraphicsLayout*>(layoutItem)->d_func()->activated = false;-
137 layoutItem = layoutItem->parentLayoutItem();-
138 }
never executed: end of block
0
139 if (layoutItem
layoutItemDescription
TRUEnever evaluated
FALSEnever evaluated
&& !layoutItem->isLayout()
!layoutItem->isLayout()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
140-
141 QApplication::postEvent(static_cast<QGraphicsWidget *>(layoutItem), new QEvent(QEvent::LayoutRequest));-
142 }
never executed: end of block
0
143 }
never executed: end of block
0
144 }
never executed: end of block
0
145}-
146-
147-
148-
149-
150void QGraphicsLayout::updateGeometry()-
151{-
152 QGraphicsLayoutPrivate * const d = d_func();-
153 if (QGraphicsLayout::instantInvalidatePropagation()
QGraphicsLayou...ePropagation()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
154 d->activated = false;-
155 QGraphicsLayoutItem::updateGeometry();-
156-
157 QGraphicsLayoutItem *parentItem = parentLayoutItem();-
158 if (!parentItem
!parentItemDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
159 return;
never executed: return;
0
160-
161 if (parentItem->isLayout()
parentItem->isLayout()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
162 static_cast<
never executed: static_cast<QGraphicsLayout *>(parentItem)->invalidate();
QGraphicsLayout *>(parentItem)->invalidate();
never executed: static_cast<QGraphicsLayout *>(parentItem)->invalidate();
0
163 else-
164 parentItem->updateGeometry();
never executed: parentItem->updateGeometry();
0
165 } else {-
166 QGraphicsLayoutItem::updateGeometry();-
167 if (QGraphicsLayoutItem *parentItem = parentLayoutItem()
QGraphicsLayou...ntLayoutItem()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
168 if (parentItem->isLayout()
parentItem->isLayout()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
169 parentItem->updateGeometry();-
170 }
never executed: end of block
else {
0
171 invalidate();-
172 }
never executed: end of block
0
173 }-
174 }
never executed: end of block
0
175}-
176void QGraphicsLayout::widgetEvent(QEvent *e)-
177{-
178 switch (e->type()) {-
179 case
never executed: case QEvent::GraphicsSceneResize:
QEvent::GraphicsSceneResize:
never executed: case QEvent::GraphicsSceneResize:
0
180 if (isActivated()
isActivated()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
181 setGeometry(parentLayoutItem()->contentsRect());-
182 }
never executed: end of block
else {
0
183 activate();-
184 }
never executed: end of block
0
185 break;
never executed: break;
0
186 case
never executed: case QEvent::LayoutRequest:
QEvent::LayoutRequest:
never executed: case QEvent::LayoutRequest:
0
187 activate();-
188 break;
never executed: break;
0
189 case
never executed: case QEvent::LayoutDirectionChange:
QEvent::LayoutDirectionChange:
never executed: case QEvent::LayoutDirectionChange:
0
190 invalidate();-
191 break;
never executed: break;
0
192 default
never executed: default:
:
never executed: default:
0
193 break;
never executed: break;
0
194 }-
195}-
196void QGraphicsLayout::addChildLayoutItem(QGraphicsLayoutItem *layoutItem)-
197{-
198 QGraphicsLayoutPrivate * const d = d_func();-
199 d->addChildLayoutItem(layoutItem);-
200}
never executed: end of block
0
201-
202static bool g_instantInvalidatePropagation = false;-
203void QGraphicsLayout::setInstantInvalidatePropagation(bool enable)-
204{-
205 g_instantInvalidatePropagation = enable;-
206}
never executed: end of block
0
207bool QGraphicsLayout::instantInvalidatePropagation()-
208{-
209 return
never executed: return g_instantInvalidatePropagation;
g_instantInvalidatePropagation;
never executed: return g_instantInvalidatePropagation;
0
210}-
211-
212-
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9