qtoolbarlayout.cpp

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

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