Line | Source | Count |
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | | - |
6 | | - |
7 | | - |
8 | | - |
9 | | - |
10 | | - |
11 | | - |
12 | | - |
13 | | - |
14 | | - |
15 | | - |
16 | | - |
17 | | - |
18 | | - |
19 | | - |
20 | | - |
21 | | - |
22 | | - |
23 | | - |
24 | | - |
25 | | - |
26 | | - |
27 | | - |
28 | | - |
29 | | - |
30 | | - |
31 | | - |
32 | | - |
33 | | - |
34 | | - |
35 | | - |
36 | | - |
37 | | - |
38 | | - |
39 | | - |
40 | #include "qglobal.h" | - |
41 | | - |
42 | #ifndef QT_NO_GRAPHICSVIEW | - |
43 | | - |
44 | #include "qgraphicslayout_p.h" | - |
45 | #include "qgraphicslayout.h" | - |
46 | #include "qgraphicswidget.h" | - |
47 | #include "qapplication.h" | - |
48 | | - |
49 | QT_BEGIN_NAMESPACE | - |
50 | | - |
51 | | - |
52 | | - |
53 | | - |
54 | | - |
55 | | - |
56 | void QGraphicsLayoutPrivate::reparentChildItems(QGraphicsItem *newParent) | - |
57 | { | - |
58 | Q_Q(QGraphicsLayout); | - |
59 | int n = q->count(); | - |
60 | | - |
61 | for (int i = 0; i < n; ++i) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
62 | QGraphicsLayoutItem *layoutChild = q->itemAt(i); | - |
63 | if (!layoutChild) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
64 | | - |
65 | continue; never executed: continue; | 0 |
66 | } | - |
67 | if (layoutChild->isLayout()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
68 | QGraphicsLayout *l = static_cast<QGraphicsLayout*>(layoutChild); | - |
69 | l->d_func()->reparentChildItems(newParent); | - |
70 | } else if (QGraphicsItem *itemChild = layoutChild->graphicsItem()){ never executed: end of block TRUE | never evaluated | FALSE | never evaluated |
| 0 |
71 | QGraphicsItem *childParent = itemChild->parentItem(); | - |
72 | #ifdef QT_DEBUG | - |
73 | if (childParent && childParent != newParent && itemChild->isWidget() && qt_graphicsLayoutDebug()) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
74 | QGraphicsWidget *w = static_cast<QGraphicsWidget*>(layoutChild); | - |
75 | qWarning("QGraphicsLayout::addChildLayout: widget %s \"%s\" in wrong parent; moved to correct parent", | - |
76 | w->metaObject()->className(), w->objectName().toLocal8Bit().constData()); | - |
77 | } never executed: end of block | 0 |
78 | #endif | - |
79 | if (childParent != newParent)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
80 | itemChild->setParentItem(newParent); never executed: itemChild->setParentItem(newParent); | 0 |
81 | } never executed: end of block | 0 |
82 | } never executed: end of block | 0 |
83 | } never executed: end of block | 0 |
84 | | - |
85 | void QGraphicsLayoutPrivate::getMargin(qreal *result, qreal userMargin, QStyle::PixelMetric pm) const | - |
86 | { | - |
87 | if (!result)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
88 | return; never executed: return; | 0 |
89 | Q_Q(const QGraphicsLayout); | - |
90 | | - |
91 | QGraphicsLayoutItem *parent = q->parentLayoutItem(); | - |
92 | if (userMargin >= 0.0) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
93 | *result = userMargin; | - |
94 | } else if (!parent) { never executed: end of block TRUE | never evaluated | FALSE | never evaluated |
| 0 |
95 | *result = 0.0; | - |
96 | } else if (parent->isLayout()) { never executed: end of block TRUE | never evaluated | FALSE | never evaluated |
| 0 |
97 | *result = 0.0; | - |
98 | } else { never executed: end of block | 0 |
99 | *result = 0.0; | - |
100 | if (QGraphicsItem *layoutParentItem = parentItem()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
101 | if (layoutParentItem->isWidget())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
102 | *result = (qreal)static_cast<QGraphicsWidget*>(layoutParentItem)->style()->pixelMetric(pm, 0); never executed: *result = (qreal)static_cast<QGraphicsWidget*>(layoutParentItem)->style()->pixelMetric(pm, 0); | 0 |
103 | } never executed: end of block | 0 |
104 | } never executed: end of block | 0 |
105 | } | - |
106 | | - |
107 | Qt::LayoutDirection QGraphicsLayoutPrivate::visualDirection() const | - |
108 | { | - |
109 | if (QGraphicsItem *maybeWidget = parentItem()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
110 | if (maybeWidget->isWidget())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
111 | return static_cast<QGraphicsWidget*>(maybeWidget)->layoutDirection(); never executed: return static_cast<QGraphicsWidget*>(maybeWidget)->layoutDirection(); | 0 |
112 | } never executed: end of block | 0 |
113 | return QApplication::layoutDirection(); never executed: return QApplication::layoutDirection(); | 0 |
114 | } | - |
115 | | - |
116 | static bool removeLayoutItemFromLayout(QGraphicsLayout *lay, QGraphicsLayoutItem *layoutItem) | - |
117 | { | - |
118 | if (!lay)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
119 | return false; never executed: return false; | 0 |
120 | | - |
121 | for (int i = lay->count() - 1; i >= 0; --i) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
122 | QGraphicsLayoutItem *child = lay->itemAt(i); | - |
123 | if (child && child->isLayout()) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
124 | if (removeLayoutItemFromLayout(static_cast<QGraphicsLayout*>(child), layoutItem))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
125 | return true; never executed: return true; | 0 |
126 | } else if (child == layoutItem) { never executed: end of block TRUE | never evaluated | FALSE | never evaluated |
| 0 |
127 | lay->removeAt(i); | - |
128 | return true; never executed: return true; | 0 |
129 | } | - |
130 | } never executed: end of block | 0 |
131 | return false; never executed: return false; | 0 |
132 | } | - |
133 | | - |
134 | | - |
135 | | - |
136 | | - |
137 | | - |
138 | | - |
139 | | - |
140 | | - |
141 | | - |
142 | | - |
143 | | - |
144 | | - |
145 | void QGraphicsLayoutPrivate::addChildLayoutItem(QGraphicsLayoutItem *layoutItem) | - |
146 | { | - |
147 | Q_Q(QGraphicsLayout); | - |
148 | if (QGraphicsLayoutItem *maybeLayout = layoutItem->parentLayoutItem()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
149 | if (maybeLayout->isLayout())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
150 | removeLayoutItemFromLayout(static_cast<QGraphicsLayout*>(maybeLayout), layoutItem); never executed: removeLayoutItemFromLayout(static_cast<QGraphicsLayout*>(maybeLayout), layoutItem); | 0 |
151 | } never executed: end of block | 0 |
152 | layoutItem->setParentLayoutItem(q); | - |
153 | if (layoutItem->isLayout()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
154 | if (QGraphicsItem *parItem = parentItem()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
155 | static_cast<QGraphicsLayout*>(layoutItem)->d_func()->reparentChildItems(parItem); | - |
156 | } never executed: end of block | 0 |
157 | } else { never executed: end of block | 0 |
158 | if (QGraphicsItem *item = layoutItem->graphicsItem()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
159 | QGraphicsItem *newParent = parentItem(); | - |
160 | QGraphicsItem *oldParent = item->parentItem(); | - |
161 | if (oldParent == newParent || !newParent)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
162 | return; never executed: return; | 0 |
163 | | - |
164 | #ifdef QT_DEBUG | - |
165 | if (oldParent && item->isWidget()) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
166 | QGraphicsWidget *w = static_cast<QGraphicsWidget*>(item); | - |
167 | qWarning("QGraphicsLayout::addChildLayoutItem: %s \"%s\" in wrong parent; moved to correct parent", | - |
168 | w->metaObject()->className(), w->objectName().toLocal8Bit().constData()); | - |
169 | } never executed: end of block | 0 |
170 | #endif | - |
171 | | - |
172 | item->setParentItem(newParent); | - |
173 | } never executed: end of block | 0 |
174 | } never executed: end of block | 0 |
175 | } | - |
176 | | - |
177 | void QGraphicsLayoutPrivate::activateRecursive(QGraphicsLayoutItem *item) | - |
178 | { | - |
179 | if (item->isLayout()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
180 | QGraphicsLayout *layout = static_cast<QGraphicsLayout *>(item); | - |
181 | if (layout->d_func()->activated) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
182 | if (QGraphicsLayout::instantInvalidatePropagation()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
183 | return; never executed: return; | 0 |
184 | } else { | - |
185 | layout->invalidate(); | - |
186 | } never executed: end of block | 0 |
187 | } | - |
188 | | - |
189 | for (int i = layout->count() - 1; i >= 0; --i) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
190 | QGraphicsLayoutItem *childItem = layout->itemAt(i); | - |
191 | if (childItem)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
192 | activateRecursive(childItem); never executed: activateRecursive(childItem); | 0 |
193 | } never executed: end of block | 0 |
194 | layout->d_func()->activated = true; | - |
195 | } never executed: end of block | 0 |
196 | } never executed: end of block | 0 |
197 | | - |
198 | | - |
199 | QT_END_NAMESPACE | - |
200 | | - |
201 | #endif //QT_NO_GRAPHICSVIEW | - |
| | |