Line | Source Code | Coverage |
---|
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | | - |
6 | | - |
7 | | - |
8 | extern QMainWindowLayout *qt_mainwindow_layout(const QMainWindow *window); | - |
9 | | - |
10 | | - |
11 | | - |
12 | | - |
13 | | - |
14 | QToolBarItem::QToolBarItem(QWidget *widget) | - |
15 | : QWidgetItem(widget), action(0), customWidget(false) | - |
16 | { | - |
17 | } executed: } Execution Count:16 | 16 |
18 | | - |
19 | bool QToolBarItem::isEmpty() const | - |
20 | { | - |
21 | return action == 0 || !action->isVisible(); executed: return action == 0 || !action->isVisible(); Execution Count:222 | 222 |
22 | } | - |
23 | | - |
24 | | - |
25 | | - |
26 | | - |
27 | | - |
28 | QToolBarLayout::QToolBarLayout(QWidget *parent) | - |
29 | : QLayout(parent), expanded(false), animating(false), dirty(true), | - |
30 | expanding(false), empty(true), expandFlag(false), popupMenu(0) | - |
31 | { | - |
32 | QToolBar *tb = qobject_cast<QToolBar*>(parent); | - |
33 | if (!tb) partially evaluated: !tb no Evaluation Count:0 | yes Evaluation Count:16 |
| 0-16 |
34 | return; | 0 |
35 | | - |
36 | extension = new QToolBarExtension(tb); | - |
37 | extension->setFocusPolicy(Qt::NoFocus); | - |
38 | extension->hide(); | - |
39 | QObject::connect(tb, "2""orientationChanged(Qt::Orientation)", | - |
40 | extension, "1""setOrientation(Qt::Orientation)"); | - |
41 | | - |
42 | setUsePopupMenu(qobject_cast<QMainWindow*>(tb->parentWidget()) == 0); | - |
43 | } executed: } Execution Count:16 | 16 |
44 | | - |
45 | QToolBarLayout::~QToolBarLayout() | - |
46 | { | - |
47 | while (!items.isEmpty()) { evaluated: !items.isEmpty() yes Evaluation Count:6 | yes Evaluation Count:16 |
| 6-16 |
48 | QToolBarItem *item = items.takeFirst(); | - |
49 | if (QWidgetAction *widgetAction = qobject_cast<QWidgetAction*>(item->action)) { partially evaluated: QWidgetAction *widgetAction = qobject_cast<QWidgetAction*>(item->action) yes Evaluation Count:6 | no Evaluation Count:0 |
| 0-6 |
50 | if (item->customWidget) partially evaluated: item->customWidget yes Evaluation Count:6 | no Evaluation Count:0 |
| 0-6 |
51 | widgetAction->releaseWidget(item->widget()); executed: widgetAction->releaseWidget(item->widget()); Execution Count:6 | 6 |
52 | } executed: } Execution Count:6 | 6 |
53 | delete item; | - |
54 | } executed: } Execution Count:6 | 6 |
55 | } executed: } Execution Count:16 | 16 |
56 | | - |
57 | void QToolBarLayout::updateMarginAndSpacing() | - |
58 | { | - |
59 | QToolBar *tb = qobject_cast<QToolBar*>(parentWidget()); | - |
60 | if (!tb) partially evaluated: !tb no Evaluation Count:0 | yes Evaluation Count:16 |
| 0-16 |
61 | return; | 0 |
62 | QStyle *style = tb->style(); | - |
63 | QStyleOptionToolBar opt; | - |
64 | tb->initStyleOption(&opt); | - |
65 | setMargin(style->pixelMetric(QStyle::PM_ToolBarItemMargin, &opt, tb) | - |
66 | + style->pixelMetric(QStyle::PM_ToolBarFrameWidth, &opt, tb)); | - |
67 | setSpacing(style->pixelMetric(QStyle::PM_ToolBarItemSpacing, &opt, tb)); | - |
68 | } executed: } Execution Count:16 | 16 |
69 | | - |
70 | bool QToolBarLayout::hasExpandFlag() const | - |
71 | { | - |
72 | return expandFlag; never executed: return expandFlag; | 0 |
73 | } | - |
74 | | - |
75 | void QToolBarLayout::setUsePopupMenu(bool set) | - |
76 | { | - |
77 | if (!dirty && ((popupMenu == 0) == set)) evaluated: !dirty yes Evaluation Count:11 | yes Evaluation Count:25 |
evaluated: ((popupMenu == 0) == set) yes Evaluation Count:1 | yes Evaluation Count:10 |
| 1-25 |
78 | invalidate(); executed: invalidate(); Execution Count:1 | 1 |
79 | if (!set) { evaluated: !set yes Evaluation Count:12 | yes Evaluation Count:24 |
| 12-24 |
80 | QObject::connect(extension, "2""clicked(bool)", | - |
81 | this, "1""setExpanded(bool)", Qt::UniqueConnection); | - |
82 | extension->setPopupMode(QToolButton::DelayedPopup); | - |
83 | extension->setMenu(0); | - |
84 | delete popupMenu; | - |
85 | popupMenu = 0; | - |
86 | } else { executed: } Execution Count:12 | 12 |
87 | QObject::disconnect(extension, "2""clicked(bool)", | - |
88 | this, "1""setExpanded(bool)"); | - |
89 | extension->setPopupMode(QToolButton::InstantPopup); | - |
90 | if (!popupMenu) { evaluated: !popupMenu yes Evaluation Count:15 | yes Evaluation Count:9 |
| 9-15 |
91 | popupMenu = new QMenu(extension); | - |
92 | } executed: } Execution Count:15 | 15 |
93 | extension->setMenu(popupMenu); | - |
94 | } executed: } Execution Count:24 | 24 |
95 | } | - |
96 | | - |
97 | void QToolBarLayout::checkUsePopupMenu() | - |
98 | { | - |
99 | QToolBar *tb = static_cast<QToolBar *>(parent()); | - |
100 | QMainWindow *mw = qobject_cast<QMainWindow *>(tb->parent()); | - |
101 | Qt::Orientation o = tb->orientation(); | - |
102 | setUsePopupMenu(!mw || tb->isFloating() || perp(o, expandedSize(mw->size())) >= perp(o, mw->size())); | - |
103 | } executed: } Execution Count:20 | 20 |
104 | | - |
105 | void QToolBarLayout::addItem(QLayoutItem*) | - |
106 | { | - |
107 | QMessageLogger("widgets/qtoolbarlayout.cpp", 160, __PRETTY_FUNCTION__).warning() << "QToolBarLayout::addItem(): please use addAction() instead"; | - |
108 | return; | 0 |
109 | } | - |
110 | | - |
111 | QLayoutItem *QToolBarLayout::itemAt(int index) const | - |
112 | { | - |
113 | if (index < 0 || index >= items.count()) partially evaluated: index < 0 no Evaluation Count:0 | yes Evaluation Count:71 |
evaluated: index >= items.count() yes Evaluation Count:43 | yes Evaluation Count:28 |
| 0-71 |
114 | return 0; executed: return 0; Execution Count:43 | 43 |
115 | return items.at(index); executed: return items.at(index); Execution Count:28 | 28 |
116 | } | - |
117 | | - |
118 | QLayoutItem *QToolBarLayout::takeAt(int index) | - |
119 | { | - |
120 | if (index < 0 || index >= items.count()) partially evaluated: index < 0 no Evaluation Count:0 | yes Evaluation Count:10 |
partially evaluated: index >= items.count() no Evaluation Count:0 | yes Evaluation Count:10 |
| 0-10 |
121 | return 0; never executed: return 0; | 0 |
122 | QToolBarItem *item = items.takeAt(index); | - |
123 | | - |
124 | if (popupMenu) evaluated: popupMenu yes Evaluation Count:9 | yes Evaluation Count:1 |
| 1-9 |
125 | popupMenu->removeAction(item->action); executed: popupMenu->removeAction(item->action); Execution Count:9 | 9 |
126 | | - |
127 | QWidgetAction *widgetAction = qobject_cast<QWidgetAction*>(item->action); | - |
128 | if (widgetAction != 0 && item->customWidget) { evaluated: widgetAction != 0 yes Evaluation Count:8 | yes Evaluation Count:2 |
evaluated: item->customWidget yes Evaluation Count:7 | yes Evaluation Count:1 |
| 1-8 |
129 | widgetAction->releaseWidget(item->widget()); | - |
130 | } else { executed: } Execution Count:7 | 7 |
131 | | - |
132 | item->widget()->hide(); | - |
133 | item->widget()->deleteLater(); | - |
134 | } executed: } Execution Count:3 | 3 |
135 | | - |
136 | invalidate(); | - |
137 | return item; executed: return item; Execution Count:10 | 10 |
138 | } | - |
139 | | - |
140 | void QToolBarLayout::insertAction(int index, QAction *action) | - |
141 | { | - |
142 | index = qMax(0, index); | - |
143 | index = qMin(items.count(), index); | - |
144 | | - |
145 | QToolBarItem *item = createItem(action); | - |
146 | if (item) { partially evaluated: item yes Evaluation Count:16 | no Evaluation Count:0 |
| 0-16 |
147 | items.insert(index, item); | - |
148 | invalidate(); | - |
149 | } executed: } Execution Count:16 | 16 |
150 | } executed: } Execution Count:16 | 16 |
151 | | - |
152 | int QToolBarLayout::indexOf(QAction *action) const | - |
153 | { | - |
154 | for (int i = 0; i < items.count(); ++i) { evaluated: i < items.count() yes Evaluation Count:7 | yes Evaluation Count:3 |
| 3-7 |
155 | if (items.at(i)->action == action) partially evaluated: items.at(i)->action == action yes Evaluation Count:7 | no Evaluation Count:0 |
| 0-7 |
156 | return i; executed: return i; Execution Count:7 | 7 |
157 | } | 0 |
158 | return -1; executed: return -1; Execution Count:3 | 3 |
159 | } | - |
160 | | - |
161 | int QToolBarLayout::count() const | - |
162 | { | - |
163 | return items.count(); executed: return items.count(); Execution Count:16 | 16 |
164 | } | - |
165 | | - |
166 | bool QToolBarLayout::isEmpty() const | - |
167 | { | - |
168 | if (dirty) | 0 |
169 | updateGeomArray(); never executed: updateGeomArray(); | 0 |
170 | return empty; never executed: return empty; | 0 |
171 | } | - |
172 | | - |
173 | void QToolBarLayout::invalidate() | - |
174 | { | - |
175 | dirty = true; | - |
176 | QLayout::invalidate(); | - |
177 | } executed: } Execution Count:218 | 218 |
178 | | - |
179 | Qt::Orientations QToolBarLayout::expandingDirections() const | - |
180 | { | - |
181 | if (dirty) partially evaluated: dirty no Evaluation Count:0 | yes Evaluation Count:9 |
| 0-9 |
182 | updateGeomArray(); never executed: updateGeomArray(); | 0 |
183 | QToolBar *tb = qobject_cast<QToolBar*>(parentWidget()); | - |
184 | if (!tb) partially evaluated: !tb no Evaluation Count:0 | yes Evaluation Count:9 |
| 0-9 |
185 | return Qt::Orientations(0); never executed: return Qt::Orientations(0); | 0 |
186 | Qt::Orientation o = tb->orientation(); | - |
187 | return expanding ? Qt::Orientations(o) : Qt::Orientations(0); executed: return expanding ? Qt::Orientations(o) : Qt::Orientations(0); Execution Count:9 | 9 |
188 | } | - |
189 | | - |
190 | bool QToolBarLayout::movable() const | - |
191 | { | - |
192 | QToolBar *tb = qobject_cast<QToolBar*>(parentWidget()); | - |
193 | if (!tb) partially evaluated: !tb no Evaluation Count:0 | yes Evaluation Count:250 |
| 0-250 |
194 | return false; never executed: return false; | 0 |
195 | QMainWindow *win = qobject_cast<QMainWindow*>(tb->parentWidget()); | - |
196 | return tb->isMovable() && win != 0; executed: return tb->isMovable() && win != 0; Execution Count:250 | 250 |
197 | } | - |
198 | | - |
199 | void QToolBarLayout::updateGeomArray() const | - |
200 | { | - |
201 | if (!dirty) partially evaluated: !dirty no Evaluation Count:0 | yes Evaluation Count:38 |
| 0-38 |
202 | return; | 0 |
203 | | - |
204 | QToolBarLayout *that = const_cast<QToolBarLayout*>(this); | - |
205 | | - |
206 | QToolBar *tb = qobject_cast<QToolBar*>(parentWidget()); | - |
207 | if (!tb) partially evaluated: !tb no Evaluation Count:0 | yes Evaluation Count:38 |
| 0-38 |
208 | return; | 0 |
209 | QStyle *style = tb->style(); | - |
210 | QStyleOptionToolBar opt; | - |
211 | tb->initStyleOption(&opt); | - |
212 | const int handleExtent = movable() evaluated: movable() yes Evaluation Count:7 | yes Evaluation Count:31 |
| 7-31 |
213 | ? style->pixelMetric(QStyle::PM_ToolBarHandleExtent, &opt, tb) : 0; | - |
214 | const int margin = this->margin(); | - |
215 | const int spacing = this->spacing(); | - |
216 | const int extensionExtent = style->pixelMetric(QStyle::PM_ToolBarExtensionExtent, &opt, tb); | - |
217 | Qt::Orientation o = tb->orientation(); | - |
218 | | - |
219 | that->minSize = QSize(0, 0); | - |
220 | that->hint = QSize(0, 0); | - |
221 | rperp(o, that->minSize) = style->pixelMetric(QStyle::PM_ToolBarHandleExtent, &opt, tb); | - |
222 | rperp(o, that->hint) = style->pixelMetric(QStyle::PM_ToolBarHandleExtent, &opt, tb); | - |
223 | | - |
224 | that->expanding = false; | - |
225 | that->empty = false; | - |
226 | | - |
227 | QVector<QLayoutStruct> a(items.count() + 1); | - |
228 | | - |
229 | int count = 0; | - |
230 | for (int i = 0; i < items.count(); ++i) { evaluated: i < items.count() yes Evaluation Count:31 | yes Evaluation Count:38 |
| 31-38 |
231 | QToolBarItem *item = items.at(i); | - |
232 | | - |
233 | QSize max = item->maximumSize(); | - |
234 | QSize min = item->minimumSize(); | - |
235 | QSize hint = item->sizeHint(); | - |
236 | Qt::Orientations exp = item->expandingDirections(); | - |
237 | bool empty = item->isEmpty(); | - |
238 | | - |
239 | that->expanding = expanding || exp & o; partially evaluated: expanding no Evaluation Count:0 | yes Evaluation Count:31 |
evaluated: exp & o yes Evaluation Count:3 | yes Evaluation Count:28 |
| 0-31 |
240 | | - |
241 | | - |
242 | if (item->widget()) { partially evaluated: item->widget() yes Evaluation Count:31 | no Evaluation Count:0 |
| 0-31 |
243 | if ((item->widget()->sizePolicy().horizontalPolicy() & QSizePolicy::ExpandFlag)) { evaluated: (item->widget()->sizePolicy().horizontalPolicy() & QSizePolicy::ExpandFlag) yes Evaluation Count:3 | yes Evaluation Count:28 |
| 3-28 |
244 | that->expandFlag = true; | - |
245 | } executed: } Execution Count:3 | 3 |
246 | } executed: } Execution Count:31 | 31 |
247 | | - |
248 | if (!empty) { evaluated: !empty yes Evaluation Count:29 | yes Evaluation Count:2 |
| 2-29 |
249 | if (count == 0) partially evaluated: count == 0 yes Evaluation Count:29 | no Evaluation Count:0 |
| 0-29 |
250 | rpick(o, that->minSize) += pick(o, min); executed: rpick(o, that->minSize) += pick(o, min); Execution Count:29 | 29 |
251 | int s = perp(o, minSize); | - |
252 | rperp(o, that->minSize) = qMax(s, perp(o, min)); | - |
253 | | - |
254 | | - |
255 | rpick(o, that->hint) += (count == 0 ? 0 : spacing) + pick(o, hint); partially evaluated: count == 0 yes Evaluation Count:29 | no Evaluation Count:0 |
| 0-29 |
256 | s = perp(o, that->hint); | - |
257 | rperp(o, that->hint) = qMax(s, perp(o, hint)); | - |
258 | ++count; | - |
259 | } executed: } Execution Count:29 | 29 |
260 | | - |
261 | a[i].sizeHint = pick(o, hint); | - |
262 | a[i].maximumSize = pick(o, max); | - |
263 | a[i].minimumSize = pick(o, min); | - |
264 | a[i].expansive = exp & o; | - |
265 | if (o == Qt::Horizontal) partially evaluated: o == Qt::Horizontal yes Evaluation Count:31 | no Evaluation Count:0 |
| 0-31 |
266 | a[i].stretch = item->widget()->sizePolicy().horizontalStretch(); executed: a[i].stretch = item->widget()->sizePolicy().horizontalStretch(); Execution Count:31 | 31 |
267 | else | - |
268 | a[i].stretch = item->widget()->sizePolicy().verticalStretch(); never executed: a[i].stretch = item->widget()->sizePolicy().verticalStretch(); | 0 |
269 | a[i].empty = empty; | - |
270 | } executed: } Execution Count:31 | 31 |
271 | | - |
272 | that->geomArray = a; | - |
273 | that->empty = count == 0; | - |
274 | | - |
275 | rpick(o, that->minSize) += handleExtent; | - |
276 | that->minSize += QSize(2*margin, 2*margin); | - |
277 | if (items.count() > 1) partially evaluated: items.count() > 1 no Evaluation Count:0 | yes Evaluation Count:38 |
| 0-38 |
278 | rpick(o, that->minSize) += spacing + extensionExtent; never executed: rpick(o, that->minSize) += spacing + extensionExtent; | 0 |
279 | | - |
280 | rpick(o, that->hint) += handleExtent; | - |
281 | that->hint += QSize(2*margin, 2*margin); | - |
282 | that->dirty = false; | - |
283 | that->dirty = false; | - |
284 | } executed: } Execution Count:38 | 38 |
285 | | - |
286 | static bool defaultWidgetAction(QToolBarItem *item) | - |
287 | { | - |
288 | QWidgetAction *a = qobject_cast<QWidgetAction*>(item->action); | - |
289 | return a != 0 && a->defaultWidget() == item->widget(); never executed: return a != 0 && a->defaultWidget() == item->widget(); | 0 |
290 | } | - |
291 | | - |
292 | void QToolBarLayout::setGeometry(const QRect &rect) | - |
293 | { | - |
294 | QToolBar *tb = qobject_cast<QToolBar*>(parentWidget()); | - |
295 | if (!tb) partially evaluated: !tb no Evaluation Count:0 | yes Evaluation Count:43 |
| 0-43 |
296 | return; | 0 |
297 | QStyle *style = tb->style(); | - |
298 | QStyleOptionToolBar opt; | - |
299 | tb->initStyleOption(&opt); | - |
300 | const int margin = this->margin(); | - |
301 | const int extensionExtent = style->pixelMetric(QStyle::PM_ToolBarExtensionExtent, &opt, tb); | - |
302 | Qt::Orientation o = tb->orientation(); | - |
303 | | - |
304 | QLayout::setGeometry(rect); | - |
305 | | - |
306 | bool ranOutOfSpace = false; | - |
307 | if (!animating) partially evaluated: !animating yes Evaluation Count:43 | no Evaluation Count:0 |
| 0-43 |
308 | ranOutOfSpace = layoutActions(rect.size()); executed: ranOutOfSpace = layoutActions(rect.size()); Execution Count:43 | 43 |
309 | | - |
310 | if (expanded || animating || ranOutOfSpace) { partially evaluated: expanded no Evaluation Count:0 | yes Evaluation Count:43 |
partially evaluated: animating no Evaluation Count:0 | yes Evaluation Count:43 |
partially evaluated: ranOutOfSpace no Evaluation Count:0 | yes Evaluation Count:43 |
| 0-43 |
311 | Qt::ToolBarArea area = Qt::TopToolBarArea; | - |
312 | if (QMainWindow *win = qobject_cast<QMainWindow*>(tb->parentWidget())) never evaluated: QMainWindow *win = qobject_cast<QMainWindow*>(tb->parentWidget()) | 0 |
313 | area = win->toolBarArea(tb); never executed: area = win->toolBarArea(tb); | 0 |
314 | QSize hint = sizeHint(); | - |
315 | | - |
316 | QPoint pos; | - |
317 | rpick(o, pos) = pick(o, rect.bottomRight()) - margin - extensionExtent + 2; | - |
318 | if (area == Qt::LeftToolBarArea || area == Qt::TopToolBarArea) never evaluated: area == Qt::LeftToolBarArea never evaluated: area == Qt::TopToolBarArea | 0 |
319 | rperp(o, pos) = perp(o, rect.topLeft()) + margin; never executed: rperp(o, pos) = perp(o, rect.topLeft()) + margin; | 0 |
320 | else | - |
321 | rperp(o, pos) = perp(o, rect.bottomRight()) - margin - (perp(o, hint) - 2*margin) + 1; never executed: rperp(o, pos) = perp(o, rect.bottomRight()) - margin - (perp(o, hint) - 2*margin) + 1; | 0 |
322 | QSize size; | - |
323 | rpick(o, size) = extensionExtent; | - |
324 | rperp(o, size) = perp(o, hint) - 2*margin; | - |
325 | QRect r(pos, size); | - |
326 | | - |
327 | if (o == Qt::Horizontal) never evaluated: o == Qt::Horizontal | 0 |
328 | r = QStyle::visualRect(parentWidget()->layoutDirection(), rect, r); never executed: r = QStyle::visualRect(parentWidget()->layoutDirection(), rect, r); | 0 |
329 | | - |
330 | extension->setGeometry(r); | - |
331 | | - |
332 | if (extension->isHidden()) never evaluated: extension->isHidden() | 0 |
333 | extension->show(); never executed: extension->show(); | 0 |
334 | } else { | 0 |
335 | if (!extension->isHidden()) partially evaluated: !extension->isHidden() no Evaluation Count:0 | yes Evaluation Count:43 |
| 0-43 |
336 | extension->hide(); never executed: extension->hide(); | 0 |
337 | } executed: } Execution Count:43 | 43 |
338 | } | - |
339 | | - |
340 | bool QToolBarLayout::layoutActions(const QSize &size) | - |
341 | { | - |
342 | if (dirty) evaluated: dirty yes Evaluation Count:6 | yes Evaluation Count:37 |
| 6-37 |
343 | updateGeomArray(); executed: updateGeomArray(); Execution Count:6 | 6 |
344 | | - |
345 | QRect rect(0, 0, size.width(), size.height()); | - |
346 | | - |
347 | QList<QWidget*> showWidgets, hideWidgets; | - |
348 | | - |
349 | QToolBar *tb = qobject_cast<QToolBar*>(parentWidget()); | - |
350 | if (!tb) partially evaluated: !tb no Evaluation Count:0 | yes Evaluation Count:43 |
| 0-43 |
351 | return false; never executed: return false; | 0 |
352 | QStyle *style = tb->style(); | - |
353 | QStyleOptionToolBar opt; | - |
354 | tb->initStyleOption(&opt); | - |
355 | const int handleExtent = movable() evaluated: movable() yes Evaluation Count:4 | yes Evaluation Count:39 |
| 4-39 |
356 | ? style->pixelMetric(QStyle::PM_ToolBarHandleExtent, &opt, tb) : 0; | - |
357 | const int margin = this->margin(); | - |
358 | const int spacing = this->spacing(); | - |
359 | const int extensionExtent = style->pixelMetric(QStyle::PM_ToolBarExtensionExtent, &opt, tb); | - |
360 | Qt::Orientation o = tb->orientation(); | - |
361 | bool extensionMenuContainsOnlyWidgetActions = true; | - |
362 | | - |
363 | int space = pick(o, rect.size()) - 2*margin - handleExtent; | - |
364 | if (space <= 0) evaluated: space <= 0 yes Evaluation Count:6 | yes Evaluation Count:37 |
| 6-37 |
365 | return false; executed: return false; Execution Count:6 | 6 |
366 | | - |
367 | if(popupMenu) evaluated: popupMenu yes Evaluation Count:33 | yes Evaluation Count:4 |
| 4-33 |
368 | popupMenu->clear(); executed: popupMenu->clear(); Execution Count:33 | 33 |
369 | | - |
370 | bool ranOutOfSpace = false; | - |
371 | int rows = 0; | - |
372 | int rowPos = perp(o, rect.topLeft()) + margin; | - |
373 | int i = 0; | - |
374 | while (i < items.count()) { evaluated: i < items.count() yes Evaluation Count:31 | yes Evaluation Count:6 |
| 6-31 |
375 | QVector<QLayoutStruct> a = geomArray; | - |
376 | | - |
377 | int start = i; | - |
378 | int size = 0; | - |
379 | int prev = -1; | - |
380 | int rowHeight = 0; | - |
381 | int count = 0; | - |
382 | int maximumSize = 0; | - |
383 | bool expansiveRow = false; | - |
384 | for (; i < items.count(); ++i) { evaluated: i < items.count() yes Evaluation Count:31 | yes Evaluation Count:31 |
| 31 |
385 | if (a[i].empty) evaluated: a[i].empty yes Evaluation Count:4 | yes Evaluation Count:27 |
| 4-27 |
386 | continue; executed: continue; Execution Count:4 | 4 |
387 | | - |
388 | int newSize = size + (count == 0 ? 0 : spacing) + a[i].minimumSize; partially evaluated: count == 0 yes Evaluation Count:27 | no Evaluation Count:0 |
| 0-27 |
389 | if (prev != -1 && newSize > space) { partially evaluated: prev != -1 no Evaluation Count:0 | yes Evaluation Count:27 |
never evaluated: newSize > space | 0-27 |
390 | if (rows == 0) never evaluated: rows == 0 | 0 |
391 | ranOutOfSpace = true; never executed: ranOutOfSpace = true; | 0 |
392 | | - |
393 | | - |
394 | if (count > 1 && size + spacing + extensionExtent > space) never evaluated: count > 1 never evaluated: size + spacing + extensionExtent > space | 0 |
395 | i = prev; never executed: i = prev; | 0 |
396 | break; | 0 |
397 | } | - |
398 | | - |
399 | if (expanded) partially evaluated: expanded no Evaluation Count:0 | yes Evaluation Count:27 |
| 0-27 |
400 | rowHeight = qMax(rowHeight, perp(o, items.at(i)->sizeHint())); never executed: rowHeight = qMax(rowHeight, perp(o, items.at(i)->sizeHint())); | 0 |
401 | expansiveRow = expansiveRow || a[i].expansive; partially evaluated: expansiveRow no Evaluation Count:0 | yes Evaluation Count:27 |
evaluated: a[i].expansive yes Evaluation Count:2 | yes Evaluation Count:25 |
| 0-27 |
402 | size = newSize; | - |
403 | maximumSize += spacing + (a[i].expansive ? a[i].maximumSize : a[i].smartSizeHint()); evaluated: a[i].expansive yes Evaluation Count:2 | yes Evaluation Count:25 |
| 2-25 |
404 | prev = i; | - |
405 | ++count; | - |
406 | } executed: } Execution Count:27 | 27 |
407 | | - |
408 | | - |
409 | a[i].sizeHint = 0; | - |
410 | a[i].maximumSize = ((1<<24)-1); | - |
411 | a[i].minimumSize = 0; | - |
412 | a[i].expansive = true; | - |
413 | a[i].stretch = 0; | - |
414 | a[i].empty = true; | - |
415 | | - |
416 | if (expansiveRow && maximumSize < space) { evaluated: expansiveRow yes Evaluation Count:2 | yes Evaluation Count:29 |
partially evaluated: maximumSize < space no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-29 |
417 | expansiveRow = false; | - |
418 | a[i].maximumSize = space - maximumSize; | - |
419 | } | 0 |
420 | | - |
421 | qGeomCalc(a, start, i - start + (expansiveRow ? 0 : 1), 0, | - |
422 | space - (ranOutOfSpace ? (extensionExtent + spacing) : 0), | - |
423 | spacing); | - |
424 | | - |
425 | for (int j = start; j < i; ++j) { evaluated: j < i yes Evaluation Count:31 | yes Evaluation Count:31 |
| 31 |
426 | QToolBarItem *item = items.at(j); | - |
427 | | - |
428 | if (a[j].empty) { evaluated: a[j].empty yes Evaluation Count:4 | yes Evaluation Count:27 |
| 4-27 |
429 | if (!item->widget()->isHidden()) evaluated: !item->widget()->isHidden() yes Evaluation Count:1 | yes Evaluation Count:3 |
| 1-3 |
430 | hideWidgets << item->widget(); executed: hideWidgets << item->widget(); Execution Count:1 | 1 |
431 | continue; executed: continue; Execution Count:4 | 4 |
432 | } | - |
433 | | - |
434 | QPoint pos; | - |
435 | rpick(o, pos) = margin + handleExtent + a[j].pos; | - |
436 | rperp(o, pos) = rowPos; | - |
437 | QSize size; | - |
438 | rpick(o, size) = a[j].size; | - |
439 | if (expanded) partially evaluated: expanded no Evaluation Count:0 | yes Evaluation Count:27 |
| 0-27 |
440 | rperp(o, size) = rowHeight; never executed: rperp(o, size) = rowHeight; | 0 |
441 | else | - |
442 | rperp(o, size) = perp(o, rect.size()) - 2*margin; executed: rperp(o, size) = perp(o, rect.size()) - 2*margin; Execution Count:27 | 27 |
443 | QRect r(pos, size); | - |
444 | | - |
445 | if (o == Qt::Horizontal) partially evaluated: o == Qt::Horizontal yes Evaluation Count:27 | no Evaluation Count:0 |
| 0-27 |
446 | r = QStyle::visualRect(parentWidget()->layoutDirection(), rect, r); executed: r = QStyle::visualRect(parentWidget()->layoutDirection(), rect, r); Execution Count:27 | 27 |
447 | | - |
448 | item->setGeometry(r); | - |
449 | | - |
450 | if (item->widget()->isHidden()) evaluated: item->widget()->isHidden() yes Evaluation Count:9 | yes Evaluation Count:18 |
| 9-18 |
451 | showWidgets << item->widget(); executed: showWidgets << item->widget(); Execution Count:9 | 9 |
452 | } executed: } Execution Count:27 | 27 |
453 | | - |
454 | if (!expanded) { partially evaluated: !expanded yes Evaluation Count:31 | no Evaluation Count:0 |
| 0-31 |
455 | for (int j = i; j < items.count(); ++j) { partially evaluated: j < items.count() no Evaluation Count:0 | yes Evaluation Count:31 |
| 0-31 |
456 | QToolBarItem *item = items.at(j); | - |
457 | if (!item->widget()->isHidden()) never evaluated: !item->widget()->isHidden() | 0 |
458 | hideWidgets << item->widget(); never executed: hideWidgets << item->widget(); | 0 |
459 | if (popupMenu) { never evaluated: popupMenu | 0 |
460 | if (!defaultWidgetAction(item)) { never evaluated: !defaultWidgetAction(item) | 0 |
461 | popupMenu->addAction(item->action); | - |
462 | extensionMenuContainsOnlyWidgetActions = false; | - |
463 | } | 0 |
464 | } | 0 |
465 | } | 0 |
466 | break; executed: break; Execution Count:31 | 31 |
467 | } | - |
468 | | - |
469 | rowPos += rowHeight + spacing; | - |
470 | ++rows; | - |
471 | } | 0 |
472 | | - |
473 | | - |
474 | | - |
475 | | - |
476 | | - |
477 | extension->setEnabled(popupMenu == 0 || !extensionMenuContainsOnlyWidgetActions); | - |
478 | | - |
479 | | - |
480 | for (int i = 0; i < showWidgets.count(); ++i) evaluated: i < showWidgets.count() yes Evaluation Count:9 | yes Evaluation Count:37 |
| 9-37 |
481 | showWidgets.at(i)->show(); executed: showWidgets.at(i)->show(); Execution Count:9 | 9 |
482 | for (int i = 0; i < hideWidgets.count(); ++i) evaluated: i < hideWidgets.count() yes Evaluation Count:1 | yes Evaluation Count:37 |
| 1-37 |
483 | hideWidgets.at(i)->hide(); executed: hideWidgets.at(i)->hide(); Execution Count:1 | 1 |
484 | | - |
485 | return ranOutOfSpace; executed: return ranOutOfSpace; Execution Count:37 | 37 |
486 | } | - |
487 | | - |
488 | QSize QToolBarLayout::expandedSize(const QSize &size) const | - |
489 | { | - |
490 | if (dirty) evaluated: dirty yes Evaluation Count:1 | yes Evaluation Count:10 |
| 1-10 |
491 | updateGeomArray(); executed: updateGeomArray(); Execution Count:1 | 1 |
492 | | - |
493 | QToolBar *tb = qobject_cast<QToolBar*>(parentWidget()); | - |
494 | if (!tb) partially evaluated: !tb no Evaluation Count:0 | yes Evaluation Count:11 |
| 0-11 |
495 | return QSize(0, 0); never executed: return QSize(0, 0); | 0 |
496 | QMainWindow *win = qobject_cast<QMainWindow*>(tb->parentWidget()); | - |
497 | Qt::Orientation o = tb->orientation(); | - |
498 | QStyle *style = tb->style(); | - |
499 | QStyleOptionToolBar opt; | - |
500 | tb->initStyleOption(&opt); | - |
501 | const int handleExtent = movable() partially evaluated: movable() yes Evaluation Count:11 | no Evaluation Count:0 |
| 0-11 |
502 | ? style->pixelMetric(QStyle::PM_ToolBarHandleExtent, &opt, tb) : 0; | - |
503 | const int margin = this->margin(); | - |
504 | const int spacing = this->spacing(); | - |
505 | const int extensionExtent = style->pixelMetric(QStyle::PM_ToolBarExtensionExtent, &opt, tb); | - |
506 | | - |
507 | int total_w = 0; | - |
508 | int count = 0; | - |
509 | for (int x = 0; x < items.count(); ++x) { evaluated: x < items.count() yes Evaluation Count:11 | yes Evaluation Count:11 |
| 11 |
510 | if (!geomArray[x].empty) { partially evaluated: !geomArray[x].empty yes Evaluation Count:11 | no Evaluation Count:0 |
| 0-11 |
511 | total_w += (count == 0 ? 0 : spacing) + geomArray[x].minimumSize; partially evaluated: count == 0 yes Evaluation Count:11 | no Evaluation Count:0 |
| 0-11 |
512 | ++count; | - |
513 | } executed: } Execution Count:11 | 11 |
514 | } executed: } Execution Count:11 | 11 |
515 | if (count == 0) partially evaluated: count == 0 no Evaluation Count:0 | yes Evaluation Count:11 |
| 0-11 |
516 | return QSize(0, 0); never executed: return QSize(0, 0); | 0 |
517 | | - |
518 | int min_w = pick(o, size); | - |
519 | int rows = (int)qSqrt(qreal(count)); | - |
520 | if (rows == 1) partially evaluated: rows == 1 yes Evaluation Count:11 | no Evaluation Count:0 |
| 0-11 |
521 | ++rows; executed: ++rows; Execution Count:11 | 11 |
522 | int space = total_w/rows + spacing + extensionExtent; | - |
523 | space = qMax(space, min_w - 2*margin - handleExtent); | - |
524 | if (win != 0) partially evaluated: win != 0 yes Evaluation Count:11 | no Evaluation Count:0 |
| 0-11 |
525 | space = qMin(space, pick(o, win->size()) - 2*margin - handleExtent); executed: space = qMin(space, pick(o, win->size()) - 2*margin - handleExtent); Execution Count:11 | 11 |
526 | | - |
527 | int w = 0; | - |
528 | int h = 0; | - |
529 | int i = 0; | - |
530 | while (i < items.count()) { evaluated: i < items.count() yes Evaluation Count:11 | yes Evaluation Count:11 |
| 11 |
531 | int count = 0; | - |
532 | int size = 0; | - |
533 | int prev = -1; | - |
534 | int rowHeight = 0; | - |
535 | for (; i < items.count(); ++i) { evaluated: i < items.count() yes Evaluation Count:11 | yes Evaluation Count:11 |
| 11 |
536 | if (geomArray[i].empty) partially evaluated: geomArray[i].empty no Evaluation Count:0 | yes Evaluation Count:11 |
| 0-11 |
537 | continue; never executed: continue; | 0 |
538 | | - |
539 | int newSize = size + (count == 0 ? 0 : spacing) + geomArray[i].minimumSize; partially evaluated: count == 0 yes Evaluation Count:11 | no Evaluation Count:0 |
| 0-11 |
540 | rowHeight = qMax(rowHeight, perp(o, items.at(i)->sizeHint())); | - |
541 | if (prev != -1 && newSize > space) { partially evaluated: prev != -1 no Evaluation Count:0 | yes Evaluation Count:11 |
never evaluated: newSize > space | 0-11 |
542 | if (count > 1 && size + spacing + extensionExtent > space) { never evaluated: count > 1 never evaluated: size + spacing + extensionExtent > space | 0 |
543 | size -= spacing + geomArray[prev].minimumSize; | - |
544 | i = prev; | - |
545 | } | 0 |
546 | break; | 0 |
547 | } | - |
548 | | - |
549 | size = newSize; | - |
550 | prev = i; | - |
551 | ++count; | - |
552 | } executed: } Execution Count:11 | 11 |
553 | | - |
554 | w = qMax(size, w); | - |
555 | h += rowHeight + spacing; | - |
556 | } executed: } Execution Count:11 | 11 |
557 | | - |
558 | w += 2*margin + handleExtent + spacing + extensionExtent; | - |
559 | w = qMax(w, min_w); | - |
560 | if (win != 0) partially evaluated: win != 0 yes Evaluation Count:11 | no Evaluation Count:0 |
| 0-11 |
561 | w = qMin(w, pick(o, win->size())); executed: w = qMin(w, pick(o, win->size())); Execution Count:11 | 11 |
562 | h += 2*margin - spacing; | - |
563 | | - |
564 | QSize result; | - |
565 | rpick(o, result) = w; | - |
566 | rperp(o, result) = h; | - |
567 | return result; executed: return result; Execution Count:11 | 11 |
568 | } | - |
569 | | - |
570 | void QToolBarLayout::setExpanded(bool exp) | - |
571 | { | - |
572 | QWidget *tb = qobject_cast<QToolBar*>(parentWidget()); | - |
573 | if (!tb) | 0 |
574 | return; | 0 |
575 | if (exp == expanded && !tb->isWindow()) never evaluated: exp == expanded never evaluated: !tb->isWindow() | 0 |
576 | return; | 0 |
577 | | - |
578 | expanded = exp; | - |
579 | extension->setChecked(expanded); | - |
580 | | - |
581 | if (QMainWindow *win = qobject_cast<QMainWindow*>(tb->parentWidget())) { never evaluated: QMainWindow *win = qobject_cast<QMainWindow*>(tb->parentWidget()) | 0 |
582 | | - |
583 | | - |
584 | | - |
585 | animating = !tb->isWindow() && win->isAnimated(); never evaluated: !tb->isWindow() never evaluated: win->isAnimated() | 0 |
586 | | - |
587 | QMainWindowLayout *layout = qt_mainwindow_layout(win); | - |
588 | if (expanded) { never evaluated: expanded | 0 |
589 | tb->raise(); | - |
590 | } else { | 0 |
591 | QList<int> path = layout->layoutState.indexOf(tb); | - |
592 | if (!path.isEmpty()) { never evaluated: !path.isEmpty() | 0 |
593 | QRect rect = layout->layoutState.itemRect(path); | - |
594 | layoutActions(rect.size()); | - |
595 | } | 0 |
596 | } | 0 |
597 | layout->layoutState.toolBarAreaLayout.apply(animating); | - |
598 | } | 0 |
599 | } | 0 |
600 | | - |
601 | QSize QToolBarLayout::minimumSize() const | - |
602 | { | - |
603 | if (dirty) evaluated: dirty yes Evaluation Count:27 | yes Evaluation Count:56 |
| 27-56 |
604 | updateGeomArray(); executed: updateGeomArray(); Execution Count:27 | 27 |
605 | return minSize; executed: return minSize; Execution Count:83 | 83 |
606 | } | - |
607 | | - |
608 | QSize QToolBarLayout::sizeHint() const | - |
609 | { | - |
610 | if (dirty) evaluated: dirty yes Evaluation Count:4 | yes Evaluation Count:63 |
| 4-63 |
611 | updateGeomArray(); executed: updateGeomArray(); Execution Count:4 | 4 |
612 | return hint; executed: return hint; Execution Count:67 | 67 |
613 | } | - |
614 | | - |
615 | QToolBarItem *QToolBarLayout::createItem(QAction *action) | - |
616 | { | - |
617 | bool customWidget = false; | - |
618 | bool standardButtonWidget = false; | - |
619 | QWidget *widget = 0; | - |
620 | QToolBar *tb = qobject_cast<QToolBar*>(parentWidget()); | - |
621 | if (!tb) partially evaluated: !tb no Evaluation Count:0 | yes Evaluation Count:16 |
| 0-16 |
622 | return (QToolBarItem *)0; never executed: return (QToolBarItem *)0; | 0 |
623 | | - |
624 | if (QWidgetAction *widgetAction = qobject_cast<QWidgetAction *>(action)) { evaluated: QWidgetAction *widgetAction = qobject_cast<QWidgetAction *>(action) yes Evaluation Count:15 | yes Evaluation Count:1 |
| 1-15 |
625 | widget = widgetAction->requestWidget(tb); | - |
626 | if (widget != 0) { evaluated: widget != 0 yes Evaluation Count:13 | yes Evaluation Count:2 |
| 2-13 |
627 | widget->setAttribute(Qt::WA_LayoutUsesWidgetRect); | - |
628 | customWidget = true; | - |
629 | } executed: } Execution Count:13 | 13 |
630 | } else if (action->isSeparator()) { executed: } Execution Count:15 partially evaluated: action->isSeparator() no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-15 |
631 | QToolBarSeparator *sep = new QToolBarSeparator(tb); | - |
632 | connect(tb, "2""orientationChanged(Qt::Orientation)", | - |
633 | sep, "1""setOrientation(Qt::Orientation)"); | - |
634 | widget = sep; | - |
635 | } | 0 |
636 | | - |
637 | if (!widget) { evaluated: !widget yes Evaluation Count:3 | yes Evaluation Count:13 |
| 3-13 |
638 | QToolButton *button = new QToolButton(tb); | - |
639 | button->setAutoRaise(true); | - |
640 | button->setFocusPolicy(Qt::NoFocus); | - |
641 | button->setIconSize(tb->iconSize()); | - |
642 | button->setToolButtonStyle(tb->toolButtonStyle()); | - |
643 | QObject::connect(tb, "2""iconSizeChanged(QSize)", | - |
644 | button, "1""setIconSize(QSize)"); | - |
645 | QObject::connect(tb, "2""toolButtonStyleChanged(Qt::ToolButtonStyle)", | - |
646 | button, "1""setToolButtonStyle(Qt::ToolButtonStyle)"); | - |
647 | button->setDefaultAction(action); | - |
648 | QObject::connect(button, "2""triggered(QAction*)", tb, "2""actionTriggered(QAction*)"); | - |
649 | widget = button; | - |
650 | standardButtonWidget = true; | - |
651 | } executed: } Execution Count:3 | 3 |
652 | | - |
653 | widget->hide(); | - |
654 | QToolBarItem *result = new QToolBarItem(widget); | - |
655 | if (standardButtonWidget) evaluated: standardButtonWidget yes Evaluation Count:3 | yes Evaluation Count:13 |
| 3-13 |
656 | result->setAlignment(Qt::AlignJustify); executed: result->setAlignment(Qt::AlignJustify); Execution Count:3 | 3 |
657 | result->customWidget = customWidget; | - |
658 | result->action = action; | - |
659 | return result; executed: return result; Execution Count:16 | 16 |
660 | } | - |
661 | | - |
662 | | - |
663 | | - |
| | |