qtoolbararealayout.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Contact: https://www.qt.io/licensing/-
5**-
6** This file is part of the QtWidgets module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see https://www.qt.io/terms-conditions. For further-
15** information use the contact form at https://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 3 as published by the Free Software-
20** Foundation and appearing in the file LICENSE.LGPL3 included in the-
21** packaging of this file. Please review the following information to-
22** ensure the GNU Lesser General Public License version 3 requirements-
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
24**-
25** GNU General Public License Usage-
26** Alternatively, this file may be used under the terms of the GNU-
27** General Public License version 2.0 or (at your option) the GNU General-
28** Public license version 3 or any later version approved by the KDE Free-
29** Qt Foundation. The licenses are as published by the Free Software-
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
31** included in the packaging of this file. Please review the following-
32** information to ensure the GNU General Public License requirements will-
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
34** https://www.gnu.org/licenses/gpl-3.0.html.-
35**-
36** $QT_END_LICENSE$-
37**-
38****************************************************************************/-
39-
40#include <QWidgetItem>-
41#include <QToolBar>-
42#include <QStyleOption>-
43#include <QApplication>-
44#include <qdebug.h>-
45-
46#include "qtoolbararealayout_p.h"-
47#include "qmainwindowlayout_p.h"-
48#include "qwidgetanimator_p.h"-
49#include "qtoolbarlayout_p.h"-
50#include "qtoolbar_p.h"-
51-
52/******************************************************************************-
53** QToolBarAreaLayoutItem-
54*/-
55-
56#ifndef QT_NO_TOOLBAR-
57-
58QT_BEGIN_NAMESPACE-
59-
60// qmainwindow.cpp-
61extern QMainWindowLayout *qt_mainwindow_layout(const QMainWindow *mainWindow);-
62-
63QSize QToolBarAreaLayoutItem::minimumSize() const-
64{-
65 if (skip())
skip()Description
TRUEnever evaluated
FALSEnever evaluated
0
66 return QSize(0, 0);
never executed: return QSize(0, 0);
0
67 return qSmartMinSize(static_cast<QWidgetItem*>(widgetItem));
never executed: return qSmartMinSize(static_cast<QWidgetItem*>(widgetItem));
0
68}-
69-
70QSize QToolBarAreaLayoutItem::sizeHint() const-
71{-
72 if (skip())
skip()Description
TRUEnever evaluated
FALSEnever evaluated
0
73 return QSize(0, 0);
never executed: return QSize(0, 0);
0
74-
75 return realSizeHint();
never executed: return realSizeHint();
0
76}-
77-
78//returns the real size hint not taking into account the visibility of the widget-
79QSize QToolBarAreaLayoutItem::realSizeHint() const-
80{-
81 QWidget *wid = widgetItem->widget();-
82 QSize s = wid->sizeHint().expandedTo(wid->minimumSizeHint());-
83 if (wid->sizePolicy().horizontalPolicy() == QSizePolicy::Ignored)
wid->sizePolic...olicy::IgnoredDescription
TRUEnever evaluated
FALSEnever evaluated
0
84 s.setWidth(0);
never executed: s.setWidth(0);
0
85 if (wid->sizePolicy().verticalPolicy() == QSizePolicy::Ignored)
wid->sizePolic...olicy::IgnoredDescription
TRUEnever evaluated
FALSEnever evaluated
0
86 s.setHeight(0);
never executed: s.setHeight(0);
0
87 s = s.boundedTo(wid->maximumSize())-
88 .expandedTo(wid->minimumSize());-
89 return s;
never executed: return s;
0
90}-
91-
92bool QToolBarAreaLayoutItem::skip() const-
93{-
94 if (gap)
gapDescription
TRUEnever evaluated
FALSEnever evaluated
0
95 return false;
never executed: return false;
0
96 return widgetItem == 0 || widgetItem->isEmpty();
never executed: return widgetItem == 0 || widgetItem->isEmpty();
0
97}-
98-
99/******************************************************************************-
100** QToolBarAreaLayoutLine-
101*/-
102-
103QToolBarAreaLayoutLine::QToolBarAreaLayoutLine(Qt::Orientation orientation)-
104 : o(orientation)-
105{-
106}
never executed: end of block
0
107-
108QSize QToolBarAreaLayoutLine::sizeHint() const-
109{-
110 int a = 0, b = 0;-
111 for (int i = 0; i < toolBarItems.count(); ++i) {
i < toolBarItems.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
112 const QToolBarAreaLayoutItem &item = toolBarItems.at(i);-
113 if (item.skip())
item.skip()Description
TRUEnever evaluated
FALSEnever evaluated
0
114 continue;
never executed: continue;
0
115-
116 QSize sh = item.sizeHint();-
117 a += item.preferredSize > 0 ? item.preferredSize : pick(o, sh);
item.preferredSize > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
118 b = qMax(b, perp(o, sh));-
119 }
never executed: end of block
0
120-
121 QSize result;-
122 rpick(o, result) = a;-
123 rperp(o, result) = b;-
124-
125 return result;
never executed: return result;
0
126}-
127-
128QSize QToolBarAreaLayoutLine::minimumSize() const-
129{-
130 int a = 0, b = 0;-
131 for (int i = 0; i < toolBarItems.count(); ++i) {
i < toolBarItems.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
132 const QToolBarAreaLayoutItem &item = toolBarItems[i];-
133 if (item.skip())
item.skip()Description
TRUEnever evaluated
FALSEnever evaluated
0
134 continue;
never executed: continue;
0
135-
136 QSize ms = item.minimumSize();-
137 a += pick(o, ms);-
138 b = qMax(b, perp(o, ms));-
139 }
never executed: end of block
0
140-
141 QSize result;-
142 rpick(o, result) = a;-
143 rperp(o, result) = b;-
144-
145 return result;
never executed: return result;
0
146}-
147-
148void QToolBarAreaLayoutLine::fitLayout()-
149{-
150 int last = -1;-
151 int min = pick(o, minimumSize());-
152 int space = pick(o, rect.size());-
153 int extra = qMax(0, space - min);-
154-
155 for (int i = 0; i < toolBarItems.count(); ++i) {
i < toolBarItems.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
156 QToolBarAreaLayoutItem &item = toolBarItems[i];-
157 if (item.skip())
item.skip()Description
TRUEnever evaluated
FALSEnever evaluated
0
158 continue;
never executed: continue;
0
159-
160 if (QToolBarLayout *tblayout = qobject_cast<QToolBarLayout*>(item.widgetItem->widget()->layout()))
QToolBarLayout...t()->layout())Description
TRUEnever evaluated
FALSEnever evaluated
0
161 tblayout->checkUsePopupMenu();
never executed: tblayout->checkUsePopupMenu();
0
162-
163 const int itemMin = pick(o, item.minimumSize());-
164 //preferredSize is the default if it is set, otherwise, we take the sizehint-
165 item.size = item.preferredSize > 0 ? item.preferredSize : pick(o, item.sizeHint());
item.preferredSize > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
166-
167 //the extraspace is the space above the item minimum sizehint-
168 const int extraSpace = qMin(item.size - itemMin, extra);-
169 item.size = itemMin + extraSpace; //that is the real size-
170-
171 extra -= extraSpace;-
172-
173 last = i;-
174 }
never executed: end of block
0
175-
176 // calculate the positions from the sizes-
177 int pos = 0;-
178 for (int i = 0; i < toolBarItems.count(); ++i) {
i < toolBarItems.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
179 QToolBarAreaLayoutItem &item = toolBarItems[i];-
180 if (item.skip())
item.skip()Description
TRUEnever evaluated
FALSEnever evaluated
0
181 continue;
never executed: continue;
0
182-
183 item.pos = pos;-
184 if (i == last) // stretch the last item to the end of the line
i == lastDescription
TRUEnever evaluated
FALSEnever evaluated
0
185 item.size = qMax(0, pick(o, rect.size()) - item.pos);
never executed: item.size = qMax(0, pick(o, rect.size()) - item.pos);
0
186 pos += item.size;-
187 }
never executed: end of block
0
188}
never executed: end of block
0
189-
190bool QToolBarAreaLayoutLine::skip() const-
191{-
192 for (int i = 0; i < toolBarItems.count(); ++i) {
i < toolBarItems.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
193 if (!toolBarItems.at(i).skip())
!toolBarItems.at(i).skip()Description
TRUEnever evaluated
FALSEnever evaluated
0
194 return false;
never executed: return false;
0
195 }
never executed: end of block
0
196 return true;
never executed: return true;
0
197}-
198-
199/******************************************************************************-
200** QToolBarAreaLayoutInfo-
201*/-
202-
203QToolBarAreaLayoutInfo::QToolBarAreaLayoutInfo(QInternal::DockPosition pos)-
204 : dockPos(pos), dirty(false)-
205{-
206 switch (pos) {-
207 case QInternal::LeftDock:
never executed: case QInternal::LeftDock:
0
208 case QInternal::RightDock:
never executed: case QInternal::RightDock:
0
209 o = Qt::Vertical;-
210 break;
never executed: break;
0
211 case QInternal::TopDock:
never executed: case QInternal::TopDock:
0
212 case QInternal::BottomDock:
never executed: case QInternal::BottomDock:
0
213 o = Qt::Horizontal;-
214 break;
never executed: break;
0
215 default:
never executed: default:
0
216 o = Qt::Horizontal;-
217 break;
never executed: break;
0
218 }-
219}-
220-
221QSize QToolBarAreaLayoutInfo::sizeHint() const-
222{-
223 int a = 0, b = 0;-
224 for (int i = 0; i < lines.count(); ++i) {
i < lines.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
225 const QToolBarAreaLayoutLine &l = lines.at(i);-
226 if (l.skip())
l.skip()Description
TRUEnever evaluated
FALSEnever evaluated
0
227 continue;
never executed: continue;
0
228-
229 QSize hint = l.sizeHint();-
230 a = qMax(a, pick(o, hint));-
231 b += perp(o, hint);-
232 }
never executed: end of block
0
233-
234 QSize result;-
235 rpick(o, result) = a;-
236 rperp(o, result) = b;-
237-
238 return result;
never executed: return result;
0
239}-
240-
241QSize QToolBarAreaLayoutInfo::minimumSize() const-
242{-
243 int a = 0, b = 0;-
244 for (int i = 0; i < lines.count(); ++i) {
i < lines.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
245 const QToolBarAreaLayoutLine &l = lines.at(i);-
246 if (l.skip())
l.skip()Description
TRUEnever evaluated
FALSEnever evaluated
0
247 continue;
never executed: continue;
0
248-
249 QSize m = l.minimumSize();-
250 a = qMax(a, pick(o, m));-
251 b += perp(o, m);-
252 }
never executed: end of block
0
253-
254 QSize result;-
255 rpick(o, result) = a;-
256 rperp(o, result) = b;-
257-
258 return result;
never executed: return result;
0
259}-
260-
261void QToolBarAreaLayoutInfo::fitLayout()-
262{-
263 dirty = false;-
264-
265 int b = 0;-
266-
267 bool reverse = dockPos == QInternal::RightDock || dockPos == QInternal::BottomDock;
dockPos == QIn...nal::RightDockDescription
TRUEnever evaluated
FALSEnever evaluated
dockPos == QIn...al::BottomDockDescription
TRUEnever evaluated
FALSEnever evaluated
0
268-
269 int i = reverse ? lines.count() - 1 : 0;
reverseDescription
TRUEnever evaluated
FALSEnever evaluated
0
270 for (;;) {-
271 if ((reverse && i < 0) || (!reverse && i == lines.count()))
reverseDescription
TRUEnever evaluated
FALSEnever evaluated
i < 0Description
TRUEnever evaluated
FALSEnever evaluated
!reverseDescription
TRUEnever evaluated
FALSEnever evaluated
i == lines.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
272 break;
never executed: break;
0
273-
274 QToolBarAreaLayoutLine &l = lines[i];-
275 if (!l.skip()) {
!l.skip()Description
TRUEnever evaluated
FALSEnever evaluated
0
276 if (o == Qt::Horizontal) {
o == Qt::HorizontalDescription
TRUEnever evaluated
FALSEnever evaluated
0
277 l.rect.setLeft(rect.left());-
278 l.rect.setRight(rect.right());-
279 l.rect.setTop(b + rect.top());-
280 b += l.sizeHint().height();-
281 l.rect.setBottom(b - 1 + rect.top());-
282 } else {
never executed: end of block
0
283 l.rect.setTop(rect.top());-
284 l.rect.setBottom(rect.bottom());-
285 l.rect.setLeft(b + rect.left());-
286 b += l.sizeHint().width();-
287 l.rect.setRight(b - 1 + rect.left());-
288 }
never executed: end of block
0
289-
290 l.fitLayout();-
291 }
never executed: end of block
0
292-
293 i += reverse ? -1 : 1;
reverseDescription
TRUEnever evaluated
FALSEnever evaluated
0
294 }
never executed: end of block
0
295}
never executed: end of block
0
296-
297QLayoutItem *QToolBarAreaLayoutInfo::insertToolBar(QToolBar *before, QToolBar *toolBar)-
298{-
299 toolBar->setOrientation(o);-
300 QLayoutItem *item = new QWidgetItemV2(toolBar);-
301 insertItem(before, item);-
302 return item;
never executed: return item;
0
303}-
304-
305void QToolBarAreaLayoutInfo::insertItem(QToolBar *before, QLayoutItem *item)-
306{-
307 if (before == 0) {
before == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
308 if (lines.isEmpty())
lines.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
309 lines.append(QToolBarAreaLayoutLine(o));
never executed: lines.append(QToolBarAreaLayoutLine(o));
0
310 lines.last().toolBarItems.append(item);-
311 return;
never executed: return;
0
312 }-
313-
314 for (int j = 0; j < lines.count(); ++j) {
j < lines.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
315 QToolBarAreaLayoutLine &line = lines[j];-
316-
317 for (int k = 0; k < line.toolBarItems.count(); ++k) {
k < line.toolBarItems.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
318 if (line.toolBarItems.at(k).widgetItem->widget() == before) {
line.toolBarIt...et() == beforeDescription
TRUEnever evaluated
FALSEnever evaluated
0
319 line.toolBarItems.insert(k, item);-
320 return;
never executed: return;
0
321 }-
322 }
never executed: end of block
0
323 }
never executed: end of block
0
324}
never executed: end of block
0
325-
326void QToolBarAreaLayoutInfo::removeToolBar(QToolBar *toolBar)-
327{-
328 for (int j = 0; j < lines.count(); ++j) {
j < lines.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
329 QToolBarAreaLayoutLine &line = lines[j];-
330-
331 for (int k = 0; k < line.toolBarItems.count(); ++k) {
k < line.toolBarItems.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
332 QToolBarAreaLayoutItem &item = line.toolBarItems[k];-
333 if (item.widgetItem->widget() == toolBar) {
item.widgetIte...t() == toolBarDescription
TRUEnever evaluated
FALSEnever evaluated
0
334 delete item.widgetItem;-
335 item.widgetItem = 0;-
336 line.toolBarItems.removeAt(k);-
337-
338 if (line.toolBarItems.isEmpty() && j < lines.count() - 1)
line.toolBarItems.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
j < lines.count() - 1Description
TRUEnever evaluated
FALSEnever evaluated
0
339 lines.removeAt(j);
never executed: lines.removeAt(j);
0
340-
341 return;
never executed: return;
0
342 }-
343 }
never executed: end of block
0
344 }
never executed: end of block
0
345}
never executed: end of block
0
346-
347void QToolBarAreaLayoutInfo::insertToolBarBreak(QToolBar *before)-
348{-
349 if (before == 0) {
before == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
350 if (!lines.isEmpty() && lines.constLast().toolBarItems.isEmpty())
!lines.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
lines.constLas...tems.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
351 return;
never executed: return;
0
352 lines.append(QToolBarAreaLayoutLine(o));-
353 return;
never executed: return;
0
354 }-
355-
356 for (int j = 0; j < lines.count(); ++j) {
j < lines.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
357 QToolBarAreaLayoutLine &line = lines[j];-
358-
359 for (int k = 0; k < line.toolBarItems.count(); ++k) {
k < line.toolBarItems.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
360 if (line.toolBarItems.at(k).widgetItem->widget() == before) {
line.toolBarIt...et() == beforeDescription
TRUEnever evaluated
FALSEnever evaluated
0
361 if (k == 0)
k == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
362 return;
never executed: return;
0
363-
364 QToolBarAreaLayoutLine newLine(o);-
365 newLine.toolBarItems = line.toolBarItems.mid(k);-
366 line.toolBarItems = line.toolBarItems.mid(0, k);-
367 lines.insert(j + 1, newLine);-
368-
369 return;
never executed: return;
0
370 }-
371 }
never executed: end of block
0
372 }
never executed: end of block
0
373}
never executed: end of block
0
374-
375void QToolBarAreaLayoutInfo::removeToolBarBreak(QToolBar *before)-
376{-
377 for (int j = 0; j < lines.count(); ++j) {
j < lines.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
378 const QToolBarAreaLayoutLine &line = lines.at(j);-
379-
380 for (int k = 0; k < line.toolBarItems.count(); ++k) {
k < line.toolBarItems.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
381 if (line.toolBarItems.at(k).widgetItem->widget() == before) {
line.toolBarIt...et() == beforeDescription
TRUEnever evaluated
FALSEnever evaluated
0
382 if (k != 0)
k != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
383 return;
never executed: return;
0
384 if (j == 0)
j == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
385 return;
never executed: return;
0
386-
387 lines[j - 1].toolBarItems += lines[j].toolBarItems;-
388 lines.removeAt(j);-
389-
390 return;
never executed: return;
0
391 }-
392 }
never executed: end of block
0
393 }
never executed: end of block
0
394}
never executed: end of block
0
395-
396void QToolBarAreaLayoutInfo::moveToolBar(QToolBar *toolbar, int pos)-
397{-
398 if (dirty)
dirtyDescription
TRUEnever evaluated
FALSEnever evaluated
0
399 fitLayout();
never executed: fitLayout();
0
400-
401 dirty = true;-
402-
403 if (o == Qt::Vertical)
o == Qt::VerticalDescription
TRUEnever evaluated
FALSEnever evaluated
0
404 pos -= rect.top();
never executed: pos -= rect.top();
0
405-
406 //here we actually update the preferredSize for the line containing the toolbar so that we move it-
407 for (int j = 0; j < lines.count(); ++j) {
j < lines.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
408 QToolBarAreaLayoutLine &line = lines[j];-
409-
410 int previousIndex = -1;-
411 int minPos = 0;-
412 for (int k = 0; k < line.toolBarItems.count(); ++k) {
k < line.toolBarItems.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
413 QToolBarAreaLayoutItem &current = line.toolBarItems[k];-
414 if (current.widgetItem->widget() == toolbar) {
current.widget...t() == toolbarDescription
TRUEnever evaluated
FALSEnever evaluated
0
415 int newPos = current.pos;-
416-
417 if (previousIndex >= 0) {
previousIndex >= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
418 QToolBarAreaLayoutItem &previous = line.toolBarItems[previousIndex];-
419 if (pos < current.pos) {
pos < current.posDescription
TRUEnever evaluated
FALSEnever evaluated
0
420 newPos = qMax(pos, minPos);-
421 } else {
never executed: end of block
0
422 //we check the max value for the position (until everything at the right is "compressed")-
423 int maxPos = pick(o, rect.size());-
424 for(int l = k; l < line.toolBarItems.count(); ++l) {
l < line.toolBarItems.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
425 const QToolBarAreaLayoutItem &item = line.toolBarItems.at(l);-
426 if (!item.skip()) {
!item.skip()Description
TRUEnever evaluated
FALSEnever evaluated
0
427 maxPos -= pick(o, item.minimumSize());-
428 }
never executed: end of block
0
429 }
never executed: end of block
0
430 newPos = qMin(pos, maxPos);-
431 }
never executed: end of block
0
432-
433 //extra is the number of pixels to add to the previous toolbar-
434 int extra = newPos - current.pos;-
435-
436 //we check if the previous is near its size hint-
437 //in which case we try to stick to it-
438 const int diff = pick(o, previous.sizeHint()) - (previous.size + extra);-
439 if (qAbs(diff) < QApplication::startDragDistance()) {
qAbs(diff) < Q...DragDistance()Description
TRUEnever evaluated
FALSEnever evaluated
0
440 //we stick to the default place and size-
441 extra += diff;-
442 }
never executed: end of block
0
443-
444 //update for the current item-
445 current.extendSize(line.o, -extra);-
446-
447 if (extra >= 0) {
extra >= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
448 previous.extendSize(line.o, extra);-
449 } else {
never executed: end of block
0
450 //we need to push the toolbars on the left starting with previous-
451 extra = -extra; // we just need to know the number of pixels-
452 ///at this point we need to get extra pixels from the toolbars at the left-
453 for(int l = previousIndex; l >=0; --l) {
l >=0Description
TRUEnever evaluated
FALSEnever evaluated
0
454 QToolBarAreaLayoutItem &item = line.toolBarItems[l];-
455 if (!item.skip()) {
!item.skip()Description
TRUEnever evaluated
FALSEnever evaluated
0
456 const int minPreferredSize = pick(o, item.minimumSize());-
457 const int margin = item.size - minPreferredSize;-
458 if (margin < extra) {
margin < extraDescription
TRUEnever evaluated
FALSEnever evaluated
0
459 item.resize(line.o, minPreferredSize);-
460 extra -= margin;-
461 } else {
never executed: end of block
0
462 item.extendSize(line.o, -extra);-
463 extra = 0;-
464 }
never executed: end of block
0
465 }-
466 }
never executed: end of block
0
467 Q_ASSERT(extra == 0);-
468 }
never executed: end of block
0
469 } else {-
470 //the item is the first one, it should be at position 0-
471 }
never executed: end of block
0
472-
473 return;
never executed: return;
0
474-
475 } else if (!current.skip()) {
!current.skip()Description
TRUEnever evaluated
FALSEnever evaluated
0
476 previousIndex = k;-
477 minPos += pick(o, current.minimumSize());-
478 }
never executed: end of block
0
479 }
never executed: end of block
0
480 }
never executed: end of block
0
481}
never executed: end of block
0
482-
483-
484QList<int> QToolBarAreaLayoutInfo::gapIndex(const QPoint &pos, int *minDistance) const-
485{-
486 if (rect.contains(pos)) {
rect.contains(pos)Description
TRUEnever evaluated
FALSEnever evaluated
0
487 // <pos> is in QToolBarAreaLayout coordinates.-
488 // <item.pos> is in local dockarea coordinates (see ~20 lines below)-
489 // Since we're comparing p with item.pos, we put them in the same coordinate system.-
490 const int p = pick(o, pos - rect.topLeft());-
491-
492 for (int j = 0; j < lines.count(); ++j) {
j < lines.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
493 const QToolBarAreaLayoutLine &line = lines.at(j);-
494 if (line.skip())
line.skip()Description
TRUEnever evaluated
FALSEnever evaluated
0
495 continue;
never executed: continue;
0
496 if (!line.rect.contains(pos))
!line.rect.contains(pos)Description
TRUEnever evaluated
FALSEnever evaluated
0
497 continue;
never executed: continue;
0
498-
499 int k = 0;-
500 for (; k < line.toolBarItems.count(); ++k) {
k < line.toolBarItems.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
501 const QToolBarAreaLayoutItem &item = line.toolBarItems.at(k);-
502 if (item.skip())
item.skip()Description
TRUEnever evaluated
FALSEnever evaluated
0
503 continue;
never executed: continue;
0
504-
505 int size = qMin(item.size, pick(o, item.sizeHint()));-
506-
507 if (p > item.pos + size)
p > item.pos + sizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
508 continue;
never executed: continue;
0
509 if (p > item.pos + size/2)
p > item.pos + size/2Description
TRUEnever evaluated
FALSEnever evaluated
0
510 ++k;
never executed: ++k;
0
511 break;
never executed: break;
0
512 }-
513-
514 QList<int> result;-
515 result << j << k;-
516 *minDistance = 0; //we found a perfect match-
517 return result;
never executed: return result;
0
518 }-
519 } else {
never executed: end of block
0
520 const int dist = distance(pos);-
521 //it will only return a path if the minDistance is higher than the current distance-
522 if (dist >= 0 && *minDistance > dist) {
dist >= 0Description
TRUEnever evaluated
FALSEnever evaluated
*minDistance > distDescription
TRUEnever evaluated
FALSEnever evaluated
0
523 *minDistance = dist;-
524-
525 QList<int> result;-
526 result << lines.count() << 0;-
527 return result;
never executed: return result;
0
528 }-
529 }
never executed: end of block
0
530-
531 return QList<int>();
never executed: return QList<int>();
0
532}-
533-
534bool QToolBarAreaLayoutInfo::insertGap(const QList<int> &path, QLayoutItem *item)-
535{-
536 Q_ASSERT(path.count() == 2);-
537 int j = path.first();-
538 if (j == lines.count())
j == lines.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
539 lines.append(QToolBarAreaLayoutLine(o));
never executed: lines.append(QToolBarAreaLayoutLine(o));
0
540-
541 QToolBarAreaLayoutLine &line = lines[j];-
542 const int k = path.at(1);-
543-
544 QToolBarAreaLayoutItem gap_item;-
545 gap_item.gap = true;-
546 gap_item.widgetItem = item;-
547-
548 //update the previous item's preferred size-
549 for(int p = k - 1 ; p >= 0; --p) {
p >= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
550 QToolBarAreaLayoutItem &previous = line.toolBarItems[p];-
551 if (!previous.skip()) {
!previous.skip()Description
TRUEnever evaluated
FALSEnever evaluated
0
552 //we found the previous one-
553 int previousSizeHint = pick(line.o, previous.sizeHint());-
554 int previousExtraSpace = previous.size - previousSizeHint;-
555-
556 if (previousExtraSpace > 0) {
previousExtraSpace > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
557 //in this case we reset the space-
558 previous.preferredSize = -1;-
559 previous.size = previousSizeHint;-
560-
561 gap_item.resize(o, previousExtraSpace);-
562 }
never executed: end of block
0
563-
564 break;
never executed: break;
0
565 }-
566 }
never executed: end of block
0
567-
568 line.toolBarItems.insert(k, gap_item);-
569 return true;
never executed: return true;
0
570-
571}-
572-
573void QToolBarAreaLayoutInfo::clear()-
574{-
575 lines.clear();-
576 rect = QRect();-
577}
never executed: end of block
0
578-
579QRect QToolBarAreaLayoutInfo::itemRect(const QList<int> &path) const-
580{-
581 Q_ASSERT(path.count() == 2);-
582 int j = path.at(0);-
583 int k = path.at(1);-
584-
585 const QToolBarAreaLayoutLine &line = lines.at(j);-
586 const QToolBarAreaLayoutItem &item = line.toolBarItems.at(k);-
587-
588 QRect result = line.rect;-
589-
590 if (o == Qt::Horizontal) {
o == Qt::HorizontalDescription
TRUEnever evaluated
FALSEnever evaluated
0
591 result.setLeft(item.pos + line.rect.left());-
592 result.setWidth(item.size);-
593 } else {
never executed: end of block
0
594 result.setTop(item.pos + line.rect.top());-
595 result.setHeight(item.size);-
596 }
never executed: end of block
0
597-
598 return result;
never executed: return result;
0
599}-
600-
601int QToolBarAreaLayoutInfo::distance(const QPoint &pos) const-
602{-
603 switch (dockPos) {-
604 case QInternal::LeftDock:
never executed: case QInternal::LeftDock:
0
605 if (pos.y() < rect.bottom())
pos.y() < rect.bottom()Description
TRUEnever evaluated
FALSEnever evaluated
0
606 return pos.x() - rect.right();
never executed: return pos.x() - rect.right();
0
607 break;
never executed: break;
0
608 case QInternal::RightDock:
never executed: case QInternal::RightDock:
0
609 if (pos.y() < rect.bottom())
pos.y() < rect.bottom()Description
TRUEnever evaluated
FALSEnever evaluated
0
610 return rect.left() - pos.x();
never executed: return rect.left() - pos.x();
0
611 break;
never executed: break;
0
612 case QInternal::TopDock:
never executed: case QInternal::TopDock:
0
613 if (pos.x() < rect.right())
pos.x() < rect.right()Description
TRUEnever evaluated
FALSEnever evaluated
0
614 return pos.y() - rect.bottom();
never executed: return pos.y() - rect.bottom();
0
615 break;
never executed: break;
0
616 case QInternal::BottomDock:
never executed: case QInternal::BottomDock:
0
617 if (pos.x() < rect.right())
pos.x() < rect.right()Description
TRUEnever evaluated
FALSEnever evaluated
0
618 return rect.top() - pos.y();
never executed: return rect.top() - pos.y();
0
619 break;
never executed: break;
0
620-
621 case QInternal::DockCount:
never executed: case QInternal::DockCount:
0
622 break;
never executed: break;
0
623 }-
624 return -1;
never executed: return -1;
0
625}-
626-
627/******************************************************************************-
628** QToolBarAreaLayout-
629*/-
630-
631QToolBarAreaLayout::QToolBarAreaLayout(const QMainWindow *win) : mainWindow(win), visible(true)-
632{-
633 for (int i = 0; i < QInternal::DockCount; ++i) {
i < QInternal::DockCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
634 QInternal::DockPosition pos = static_cast<QInternal::DockPosition>(i);-
635 docks[i] = QToolBarAreaLayoutInfo(pos);-
636 }
never executed: end of block
0
637}
never executed: end of block
0
638-
639QRect QToolBarAreaLayout::fitLayout()-
640{-
641 if (!visible)
!visibleDescription
TRUEnever evaluated
FALSEnever evaluated
0
642 return rect;
never executed: return rect;
0
643-
644 QSize left_hint = docks[QInternal::LeftDock].sizeHint();-
645 QSize right_hint = docks[QInternal::RightDock].sizeHint();-
646 QSize top_hint = docks[QInternal::TopDock].sizeHint();-
647 QSize bottom_hint = docks[QInternal::BottomDock].sizeHint();-
648-
649 QRect center = rect.adjusted(left_hint.width(), top_hint.height(),-
650 -right_hint.width(), -bottom_hint.height());-
651-
652 docks[QInternal::TopDock].rect = QRect(rect.left(), rect.top(),-
653 rect.width(), top_hint.height());-
654 docks[QInternal::LeftDock].rect = QRect(rect.left(), center.top(),-
655 left_hint.width(), center.height());-
656 docks[QInternal::RightDock].rect = QRect(center.right() + 1, center.top(),-
657 right_hint.width(), center.height());-
658 docks[QInternal::BottomDock].rect = QRect(rect.left(), center.bottom() + 1,-
659 rect.width(), bottom_hint.height());-
660-
661 docks[QInternal::TopDock].fitLayout();-
662 docks[QInternal::LeftDock].fitLayout();-
663 docks[QInternal::RightDock].fitLayout();-
664 docks[QInternal::BottomDock].fitLayout();-
665-
666 return center;
never executed: return center;
0
667}-
668-
669QSize QToolBarAreaLayout::minimumSize(const QSize &centerMin) const-
670{-
671 if (!visible)
!visibleDescription
TRUEnever evaluated
FALSEnever evaluated
0
672 return centerMin;
never executed: return centerMin;
0
673-
674 QSize result = centerMin;-
675-
676 QSize left_min = docks[QInternal::LeftDock].minimumSize();-
677 QSize right_min = docks[QInternal::RightDock].minimumSize();-
678 QSize top_min = docks[QInternal::TopDock].minimumSize();-
679 QSize bottom_min = docks[QInternal::BottomDock].minimumSize();-
680-
681 result.setWidth(qMax(top_min.width(), result.width()));-
682 result.setWidth(qMax(bottom_min.width(), result.width()));-
683 result.setHeight(qMax(left_min.height(), result.height()));-
684 result.setHeight(qMax(right_min.height(), result.height()));-
685-
686 result.rwidth() += left_min.width() + right_min.width();-
687 result.rheight() += top_min.height() + bottom_min.height();-
688-
689 return result;
never executed: return result;
0
690}-
691-
692QSize QToolBarAreaLayout::sizeHint(const QSize &centerHint) const-
693{-
694 if (!visible)
!visibleDescription
TRUEnever evaluated
FALSEnever evaluated
0
695 return centerHint;
never executed: return centerHint;
0
696-
697 QSize result = centerHint;-
698-
699 QSize left_hint = docks[QInternal::LeftDock].sizeHint();-
700 QSize right_hint = docks[QInternal::RightDock].sizeHint();-
701 QSize top_hint = docks[QInternal::TopDock].sizeHint();-
702 QSize bottom_hint = docks[QInternal::BottomDock].sizeHint();-
703-
704 result.setWidth(qMax(top_hint.width(), result.width()));-
705 result.setWidth(qMax(bottom_hint.width(), result.width()));-
706 result.setHeight(qMax(left_hint.height(), result.height()));-
707 result.setHeight(qMax(right_hint.height(), result.height()));-
708-
709 result.rwidth() += left_hint.width() + right_hint.width();-
710 result.rheight() += top_hint.height() + bottom_hint.height();-
711-
712 return result;
never executed: return result;
0
713}-
714-
715QRect QToolBarAreaLayout::rectHint(const QRect &r) const-
716{-
717 int coef = visible ? 1 : -1;
visibleDescription
TRUEnever evaluated
FALSEnever evaluated
0
718-
719 QRect result = r;-
720-
721 QSize left_hint = docks[QInternal::LeftDock].sizeHint();-
722 QSize right_hint = docks[QInternal::RightDock].sizeHint();-
723 QSize top_hint = docks[QInternal::TopDock].sizeHint();-
724 QSize bottom_hint = docks[QInternal::BottomDock].sizeHint();-
725-
726 result.adjust(-left_hint.width()*coef, -top_hint.height()*coef,-
727 right_hint.width()*coef, bottom_hint.height()*coef);-
728-
729 return result;
never executed: return result;
0
730}-
731-
732QLayoutItem *QToolBarAreaLayout::itemAt(int *x, int index) const-
733{-
734 Q_ASSERT(x != 0);-
735-
736 for (int i = 0; i < QInternal::DockCount; ++i) {
i < QInternal::DockCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
737 const QToolBarAreaLayoutInfo &dock = docks[i];-
738-
739 for (int j = 0; j < dock.lines.count(); ++j) {
j < dock.lines.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
740 const QToolBarAreaLayoutLine &line = dock.lines.at(j);-
741-
742 for (int k = 0; k < line.toolBarItems.count(); ++k) {
k < line.toolBarItems.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
743 if ((*x)++ == index)
(*x)++ == indexDescription
TRUEnever evaluated
FALSEnever evaluated
0
744 return line.toolBarItems.at(k).widgetItem;
never executed: return line.toolBarItems.at(k).widgetItem;
0
745 }
never executed: end of block
0
746 }
never executed: end of block
0
747 }
never executed: end of block
0
748-
749 return 0;
never executed: return 0;
0
750}-
751-
752QLayoutItem *QToolBarAreaLayout::takeAt(int *x, int index)-
753{-
754 Q_ASSERT(x != 0);-
755-
756 for (int i = 0; i < QInternal::DockCount; ++i) {
i < QInternal::DockCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
757 QToolBarAreaLayoutInfo &dock = docks[i];-
758-
759 for (int j = 0; j < dock.lines.count(); ++j) {
j < dock.lines.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
760 QToolBarAreaLayoutLine &line = dock.lines[j];-
761-
762 for (int k = 0; k < line.toolBarItems.count(); ++k) {
k < line.toolBarItems.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
763 if ((*x)++ == index) {
(*x)++ == indexDescription
TRUEnever evaluated
FALSEnever evaluated
0
764 QLayoutItem *result = line.toolBarItems.takeAt(k).widgetItem;-
765 if (line.toolBarItems.isEmpty())
line.toolBarItems.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
766 dock.lines.removeAt(j);
never executed: dock.lines.removeAt(j);
0
767 return result;
never executed: return result;
0
768 }-
769 }
never executed: end of block
0
770 }
never executed: end of block
0
771 }
never executed: end of block
0
772-
773 return 0;
never executed: return 0;
0
774}-
775-
776void QToolBarAreaLayout::deleteAllLayoutItems()-
777{-
778 for (int i = 0; i < QInternal::DockCount; ++i) {
i < QInternal::DockCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
779 QToolBarAreaLayoutInfo &dock = docks[i];-
780-
781 for (int j = 0; j < dock.lines.count(); ++j) {
j < dock.lines.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
782 QToolBarAreaLayoutLine &line = dock.lines[j];-
783-
784 for (int k = 0; k < line.toolBarItems.count(); ++k) {
k < line.toolBarItems.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
785 QToolBarAreaLayoutItem &item = line.toolBarItems[k];-
786 if (!item.gap)
!item.gapDescription
TRUEnever evaluated
FALSEnever evaluated
0
787 delete item.widgetItem;
never executed: delete item.widgetItem;
0
788 item.widgetItem = 0;-
789 }
never executed: end of block
0
790 }
never executed: end of block
0
791 }
never executed: end of block
0
792}
never executed: end of block
0
793-
794QInternal::DockPosition QToolBarAreaLayout::findToolBar(QToolBar *toolBar) const-
795{-
796 for (int i = 0; i < QInternal::DockCount; ++i) {
i < QInternal::DockCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
797 const QToolBarAreaLayoutInfo &dock = docks[i];-
798-
799 for (int j = 0; j < dock.lines.count(); ++j) {
j < dock.lines.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
800 const QToolBarAreaLayoutLine &line = dock.lines.at(j);-
801-
802 for (int k = 0; k < line.toolBarItems.count(); ++k) {
k < line.toolBarItems.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
803 if (line.toolBarItems.at(k).widgetItem->widget() == toolBar)
line.toolBarIt...t() == toolBarDescription
TRUEnever evaluated
FALSEnever evaluated
0
804 return static_cast<QInternal::DockPosition>(i);
never executed: return static_cast<QInternal::DockPosition>(i);
0
805 }
never executed: end of block
0
806 }
never executed: end of block
0
807 }
never executed: end of block
0
808-
809 return QInternal::DockCount;
never executed: return QInternal::DockCount;
0
810}-
811-
812QLayoutItem *QToolBarAreaLayout::insertToolBar(QToolBar *before, QToolBar *toolBar)-
813{-
814 QInternal::DockPosition pos = findToolBar(before);-
815 if (pos == QInternal::DockCount)
pos == QInternal::DockCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
816 return 0;
never executed: return 0;
0
817-
818 return docks[pos].insertToolBar(before, toolBar);
never executed: return docks[pos].insertToolBar(before, toolBar);
0
819}-
820-
821void QToolBarAreaLayout::removeToolBar(QToolBar *toolBar)-
822{-
823 QInternal::DockPosition pos = findToolBar(toolBar);-
824 if (pos == QInternal::DockCount)
pos == QInternal::DockCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
825 return;
never executed: return;
0
826 docks[pos].removeToolBar(toolBar);-
827}
never executed: end of block
0
828-
829QLayoutItem *QToolBarAreaLayout::addToolBar(QInternal::DockPosition pos, QToolBar *toolBar)-
830{-
831 return docks[pos].insertToolBar(0, toolBar);
never executed: return docks[pos].insertToolBar(0, toolBar);
0
832}-
833-
834void QToolBarAreaLayout::insertToolBarBreak(QToolBar *before)-
835{-
836 QInternal::DockPosition pos = findToolBar(before);-
837 if (pos == QInternal::DockCount)
pos == QInternal::DockCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
838 return;
never executed: return;
0
839 docks[pos].insertToolBarBreak(before);-
840}
never executed: end of block
0
841-
842void QToolBarAreaLayout::removeToolBarBreak(QToolBar *before)-
843{-
844 QInternal::DockPosition pos = findToolBar(before);-
845 if (pos == QInternal::DockCount)
pos == QInternal::DockCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
846 return;
never executed: return;
0
847 docks[pos].removeToolBarBreak(before);-
848}
never executed: end of block
0
849-
850void QToolBarAreaLayout::addToolBarBreak(QInternal::DockPosition pos)-
851{-
852 docks[pos].insertToolBarBreak(0);-
853}
never executed: end of block
0
854-
855void QToolBarAreaLayout::moveToolBar(QToolBar *toolbar, int p)-
856{-
857 QInternal::DockPosition pos = findToolBar(toolbar);-
858 if (pos == QInternal::DockCount)
pos == QInternal::DockCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
859 return;
never executed: return;
0
860 docks[pos].moveToolBar(toolbar, p);-
861}
never executed: end of block
0
862-
863-
864void QToolBarAreaLayout::insertItem(QInternal::DockPosition pos, QLayoutItem *item)-
865{-
866 if (docks[pos].lines.isEmpty())
docks[pos].lines.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
867 docks[pos].lines.append(QToolBarAreaLayoutLine(docks[pos].o));
never executed: docks[pos].lines.append(QToolBarAreaLayoutLine(docks[pos].o));
0
868 docks[pos].lines.last().toolBarItems.append(item);-
869}
never executed: end of block
0
870-
871void QToolBarAreaLayout::insertItem(QToolBar *before, QLayoutItem *item)-
872{-
873 QInternal::DockPosition pos = findToolBar(before);-
874 if (pos == QInternal::DockCount)
pos == QInternal::DockCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
875 return;
never executed: return;
0
876-
877 docks[pos].insertItem(before, item);-
878}
never executed: end of block
0
879-
880void QToolBarAreaLayout::apply(bool animate)-
881{-
882 QMainWindowLayout *layout = qt_mainwindow_layout(mainWindow);-
883 Q_ASSERT(layout != 0);-
884-
885 Qt::LayoutDirection dir = mainWindow->layoutDirection();-
886-
887 for (int i = 0; i < QInternal::DockCount; ++i) {
i < QInternal::DockCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
888 const QToolBarAreaLayoutInfo &dock = docks[i];-
889-
890 for (int j = 0; j < dock.lines.count(); ++j) {
j < dock.lines.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
891 const QToolBarAreaLayoutLine &line = dock.lines.at(j);-
892 if (line.skip())
line.skip()Description
TRUEnever evaluated
FALSEnever evaluated
0
893 continue;
never executed: continue;
0
894-
895 for (int k = 0; k < line.toolBarItems.count(); ++k) {
k < line.toolBarItems.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
896 const QToolBarAreaLayoutItem &item = line.toolBarItems.at(k);-
897 if (item.skip() || item.gap)
item.skip()Description
TRUEnever evaluated
FALSEnever evaluated
item.gapDescription
TRUEnever evaluated
FALSEnever evaluated
0
898 continue;
never executed: continue;
0
899-
900 QRect geo;-
901 if (visible) {
visibleDescription
TRUEnever evaluated
FALSEnever evaluated
0
902 if (line.o == Qt::Horizontal) {
line.o == Qt::HorizontalDescription
TRUEnever evaluated
FALSEnever evaluated
0
903 geo.setTop(line.rect.top());-
904 geo.setBottom(line.rect.bottom());-
905 geo.setLeft(line.rect.left() + item.pos);-
906 geo.setRight(line.rect.left() + item.pos + item.size - 1);-
907 } else {
never executed: end of block
0
908 geo.setLeft(line.rect.left());-
909 geo.setRight(line.rect.right());-
910 geo.setTop(line.rect.top() + item.pos);-
911 geo.setBottom(line.rect.top() + item.pos + item.size - 1);-
912 }
never executed: end of block
0
913 }-
914-
915 QWidget *widget = item.widgetItem->widget();-
916 if (QToolBar *toolBar = qobject_cast<QToolBar*>(widget)) {
QToolBar *tool...lBar*>(widget)Description
TRUEnever evaluated
FALSEnever evaluated
0
917 QToolBarLayout *tbl = qobject_cast<QToolBarLayout*>(toolBar->layout());-
918 if (tbl->expanded) {
tbl->expandedDescription
TRUEnever evaluated
FALSEnever evaluated
0
919 QPoint tr = geo.topRight();-
920 QSize size = tbl->expandedSize(geo.size());-
921 geo.setSize(size);-
922 geo.moveTopRight(tr);-
923 if (geo.bottom() > rect.bottom())
geo.bottom() > rect.bottom()Description
TRUEnever evaluated
FALSEnever evaluated
0
924 geo.moveBottom(rect.bottom());
never executed: geo.moveBottom(rect.bottom());
0
925 if (geo.right() > rect.right())
geo.right() > rect.right()Description
TRUEnever evaluated
FALSEnever evaluated
0
926 geo.moveRight(rect.right());
never executed: geo.moveRight(rect.right());
0
927 if (geo.left() < 0)
geo.left() < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
928 geo.moveLeft(0);
never executed: geo.moveLeft(0);
0
929 if (geo.top() < 0)
geo.top() < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
930 geo.moveTop(0);
never executed: geo.moveTop(0);
0
931 }
never executed: end of block
0
932 }
never executed: end of block
0
933-
934 if (visible && dock.o == Qt::Horizontal)
visibleDescription
TRUEnever evaluated
FALSEnever evaluated
dock.o == Qt::HorizontalDescription
TRUEnever evaluated
FALSEnever evaluated
0
935 geo = QStyle::visualRect(dir, line.rect, geo);
never executed: geo = QStyle::visualRect(dir, line.rect, geo);
0
936-
937 layout->widgetAnimator.animate(widget, geo, animate);-
938 }
never executed: end of block
0
939 }
never executed: end of block
0
940 }
never executed: end of block
0
941}
never executed: end of block
0
942-
943bool QToolBarAreaLayout::toolBarBreak(QToolBar *toolBar) const-
944{-
945 for (int i = 0; i < QInternal::DockCount; ++i) {
i < QInternal::DockCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
946 const QToolBarAreaLayoutInfo &dock = docks[i];-
947-
948 for (int j = 0; j < dock.lines.count(); ++j) {
j < dock.lines.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
949 const QToolBarAreaLayoutLine &line = dock.lines.at(j);-
950-
951 for (int k = 0; k < line.toolBarItems.count(); ++k) {
k < line.toolBarItems.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
952 if (line.toolBarItems.at(k).widgetItem->widget() == toolBar)
line.toolBarIt...t() == toolBarDescription
TRUEnever evaluated
FALSEnever evaluated
0
953 return j > 0 && k == 0;
never executed: return j > 0 && k == 0;
0
954 }
never executed: end of block
0
955 }
never executed: end of block
0
956 }
never executed: end of block
0
957-
958 return false;
never executed: return false;
0
959}-
960-
961void QToolBarAreaLayout::getStyleOptionInfo(QStyleOptionToolBar *option, QToolBar *toolBar) const-
962{-
963 for (int i = 0; i < QInternal::DockCount; ++i) {
i < QInternal::DockCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
964 const QToolBarAreaLayoutInfo &dock = docks[i];-
965-
966 for (int j = 0; j < dock.lines.count(); ++j) {
j < dock.lines.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
967 const QToolBarAreaLayoutLine &line = dock.lines.at(j);-
968-
969 for (int k = 0; k < line.toolBarItems.count(); ++k) {
k < line.toolBarItems.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
970 if (line.toolBarItems.at(k).widgetItem->widget() == toolBar) {
line.toolBarIt...t() == toolBarDescription
TRUEnever evaluated
FALSEnever evaluated
0
971 if (line.toolBarItems.count() == 1)
line.toolBarItems.count() == 1Description
TRUEnever evaluated
FALSEnever evaluated
0
972 option->positionWithinLine = QStyleOptionToolBar::OnlyOne;
never executed: option->positionWithinLine = QStyleOptionToolBar::OnlyOne;
0
973 else if (k == 0)
k == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
974 option->positionWithinLine = QStyleOptionToolBar::Beginning;
never executed: option->positionWithinLine = QStyleOptionToolBar::Beginning;
0
975 else if (k == line.toolBarItems.count() - 1)
k == line.tool...ms.count() - 1Description
TRUEnever evaluated
FALSEnever evaluated
0
976 option->positionWithinLine = QStyleOptionToolBar::End;
never executed: option->positionWithinLine = QStyleOptionToolBar::End;
0
977 else-
978 option->positionWithinLine = QStyleOptionToolBar::Middle;
never executed: option->positionWithinLine = QStyleOptionToolBar::Middle;
0
979-
980 if (dock.lines.count() == 1)
dock.lines.count() == 1Description
TRUEnever evaluated
FALSEnever evaluated
0
981 option->positionOfLine = QStyleOptionToolBar::OnlyOne;
never executed: option->positionOfLine = QStyleOptionToolBar::OnlyOne;
0
982 else if (j == 0)
j == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
983 option->positionOfLine = QStyleOptionToolBar::Beginning;
never executed: option->positionOfLine = QStyleOptionToolBar::Beginning;
0
984 else if (j == dock.lines.count() - 1)
j == dock.lines.count() - 1Description
TRUEnever evaluated
FALSEnever evaluated
0
985 option->positionOfLine = QStyleOptionToolBar::End;
never executed: option->positionOfLine = QStyleOptionToolBar::End;
0
986 else-
987 option->positionOfLine = QStyleOptionToolBar::Middle;
never executed: option->positionOfLine = QStyleOptionToolBar::Middle;
0
988-
989 return;
never executed: return;
0
990 }-
991 }
never executed: end of block
0
992 }
never executed: end of block
0
993 }
never executed: end of block
0
994}
never executed: end of block
0
995-
996QList<int> QToolBarAreaLayout::indexOf(QWidget *toolBar) const-
997{-
998 QList<int> result;-
999-
1000 bool found = false;-
1001-
1002 for (int i = 0; i < QInternal::DockCount; ++i) {
i < QInternal::DockCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
1003 const QToolBarAreaLayoutInfo &dock = docks[i];-
1004-
1005 for (int j = 0; j < dock.lines.count(); ++j) {
j < dock.lines.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
1006 const QToolBarAreaLayoutLine &line = dock.lines.at(j);-
1007-
1008 for (int k = 0; k < line.toolBarItems.count(); ++k) {
k < line.toolBarItems.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
1009 const QToolBarAreaLayoutItem &item = line.toolBarItems.at(k);-
1010 if (!item.gap && item.widgetItem->widget() == toolBar) {
!item.gapDescription
TRUEnever evaluated
FALSEnever evaluated
item.widgetIte...t() == toolBarDescription
TRUEnever evaluated
FALSEnever evaluated
0
1011 found = true;-
1012 result.prepend(k);-
1013 break;
never executed: break;
0
1014 }-
1015 }
never executed: end of block
0
1016-
1017 if (found) {
foundDescription
TRUEnever evaluated
FALSEnever evaluated
0
1018 result.prepend(j);-
1019 break;
never executed: break;
0
1020 }-
1021 }
never executed: end of block
0
1022-
1023 if (found) {
foundDescription
TRUEnever evaluated
FALSEnever evaluated
0
1024 result.prepend(i);-
1025 break;
never executed: break;
0
1026 }-
1027 }
never executed: end of block
0
1028-
1029 return result;
never executed: return result;
0
1030}-
1031-
1032//this functions returns the path to the possible gapindex for the position pos-
1033QList<int> QToolBarAreaLayout::gapIndex(const QPoint &pos) const-
1034{-
1035 Qt::LayoutDirection dir = mainWindow->layoutDirection();-
1036 int minDistance = 80; // when a dock area is empty, how "wide" is it?-
1037 QList<int> ret; //return value-
1038 for (int i = 0; i < QInternal::DockCount; ++i) {
i < QInternal::DockCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
1039 QPoint p = pos;-
1040 if (docks[i].o == Qt::Horizontal)
docks[i].o == Qt::HorizontalDescription
TRUEnever evaluated
FALSEnever evaluated
0
1041 p = QStyle::visualPos(dir, docks[i].rect, p);
never executed: p = QStyle::visualPos(dir, docks[i].rect, p);
0
1042 QList<int> result = docks[i].gapIndex(p, &minDistance);-
1043 if (!result.isEmpty()) {
!result.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1044 result.prepend(i);-
1045 ret = result;-
1046 }
never executed: end of block
0
1047 }
never executed: end of block
0
1048-
1049 return ret;
never executed: return ret;
0
1050}-
1051-
1052QList<int> QToolBarAreaLayout::currentGapIndex() const-
1053{-
1054 for (int i = 0; i < QInternal::DockCount; ++i) {
i < QInternal::DockCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
1055 const QToolBarAreaLayoutInfo &dock = docks[i];-
1056-
1057 for (int j = 0; j < dock.lines.count(); ++j) {
j < dock.lines.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
1058 const QToolBarAreaLayoutLine &line = dock.lines[j];-
1059-
1060 for (int k = 0; k < line.toolBarItems.count(); k++) {
k < line.toolBarItems.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
1061 if (line.toolBarItems[k].gap) {
line.toolBarItems[k].gapDescription
TRUEnever evaluated
FALSEnever evaluated
0
1062 QList<int> result;-
1063 result << i << j << k;-
1064 return result;
never executed: return result;
0
1065 }-
1066 }
never executed: end of block
0
1067 }
never executed: end of block
0
1068 }
never executed: end of block
0
1069 return QList<int>();
never executed: return QList<int>();
0
1070}-
1071-
1072bool QToolBarAreaLayout::insertGap(const QList<int> &path, QLayoutItem *item)-
1073{-
1074 Q_ASSERT(path.count() == 3);-
1075 const int i = path.first();-
1076 Q_ASSERT(i >= 0 && i < QInternal::DockCount);-
1077 return docks[i].insertGap(path.mid(1), item);
never executed: return docks[i].insertGap(path.mid(1), item);
0
1078}-
1079-
1080void QToolBarAreaLayout::remove(const QList<int> &path)-
1081{-
1082 Q_ASSERT(path.count() == 3);-
1083 docks[path.at(0)].lines[path.at(1)].toolBarItems.removeAt(path.at(2));-
1084}
never executed: end of block
0
1085-
1086void QToolBarAreaLayout::remove(QLayoutItem *item)-
1087{-
1088 for (int i = 0; i < QInternal::DockCount; ++i) {
i < QInternal::DockCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
1089 QToolBarAreaLayoutInfo &dock = docks[i];-
1090-
1091 for (int j = 0; j < dock.lines.count(); ++j) {
j < dock.lines.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
1092 QToolBarAreaLayoutLine &line = dock.lines[j];-
1093-
1094 for (int k = 0; k < line.toolBarItems.count(); k++) {
k < line.toolBarItems.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
1095 if (line.toolBarItems[k].widgetItem == item) {
line.toolBarIt...etItem == itemDescription
TRUEnever evaluated
FALSEnever evaluated
0
1096 line.toolBarItems.removeAt(k);-
1097 if (line.toolBarItems.isEmpty())
line.toolBarItems.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1098 dock.lines.removeAt(j);
never executed: dock.lines.removeAt(j);
0
1099 return;
never executed: return;
0
1100 }-
1101 }
never executed: end of block
0
1102 }
never executed: end of block
0
1103 }
never executed: end of block
0
1104}
never executed: end of block
0
1105-
1106void QToolBarAreaLayout::clear()-
1107{-
1108 for (int i = 0; i < QInternal::DockCount; ++i)
i < QInternal::DockCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
1109 docks[i].clear();
never executed: docks[i].clear();
0
1110 rect = QRect();-
1111}
never executed: end of block
0
1112-
1113QToolBarAreaLayoutItem *QToolBarAreaLayout::item(const QList<int> &path)-
1114{-
1115 Q_ASSERT(path.count() == 3);-
1116-
1117 if (path.at(0) < 0 || path.at(0) >= QInternal::DockCount)
path.at(0) < 0Description
TRUEnever evaluated
FALSEnever evaluated
path.at(0) >= ...nal::DockCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
1118 return 0;
never executed: return 0;
0
1119 QToolBarAreaLayoutInfo &info = docks[path.at(0)];-
1120 if (path.at(1) < 0 || path.at(1) >= info.lines.count())
path.at(1) < 0Description
TRUEnever evaluated
FALSEnever evaluated
path.at(1) >= ....lines.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
1121 return 0;
never executed: return 0;
0
1122 QToolBarAreaLayoutLine &line = info.lines[path.at(1)];-
1123 if (path.at(2) < 0 || path.at(2) >= line.toolBarItems.count())
path.at(2) < 0Description
TRUEnever evaluated
FALSEnever evaluated
path.at(2) >= ...rItems.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
1124 return 0;
never executed: return 0;
0
1125 return &(line.toolBarItems[path.at(2)]);
never executed: return &(line.toolBarItems[path.at(2)]);
0
1126}-
1127-
1128QRect QToolBarAreaLayout::itemRect(const QList<int> &path) const-
1129{-
1130 const int i = path.first();-
1131-
1132 QRect r = docks[i].itemRect(path.mid(1));-
1133 if (docks[i].o == Qt::Horizontal)
docks[i].o == Qt::HorizontalDescription
TRUEnever evaluated
FALSEnever evaluated
0
1134 r = QStyle::visualRect(mainWindow->layoutDirection(),
never executed: r = QStyle::visualRect(mainWindow->layoutDirection(), docks[i].rect, r);
0
1135 docks[i].rect, r);
never executed: r = QStyle::visualRect(mainWindow->layoutDirection(), docks[i].rect, r);
0
1136 return r;
never executed: return r;
0
1137}-
1138-
1139QLayoutItem *QToolBarAreaLayout::plug(const QList<int> &path)-
1140{-
1141 QToolBarAreaLayoutItem *item = this->item(path);-
1142 if (Q_UNLIKELY(!item)) {
__builtin_expe...!item), false)Description
TRUEnever evaluated
FALSEnever evaluated
0
1143 qWarning() << "No item at" << path;-
1144 return 0;
never executed: return 0;
0
1145 }-
1146 Q_ASSERT(item->gap);-
1147 Q_ASSERT(item->widgetItem != 0);-
1148 item->gap = false;-
1149 return item->widgetItem;
never executed: return item->widgetItem;
0
1150}-
1151-
1152QLayoutItem *QToolBarAreaLayout::unplug(const QList<int> &path, QToolBarAreaLayout *other)-
1153{-
1154 //other needs to be update as well-
1155 Q_ASSERT(path.count() == 3);-
1156 QToolBarAreaLayoutItem *item = this->item(path);-
1157 Q_ASSERT(item);-
1158-
1159 //update the leading space here-
1160 QToolBarAreaLayoutInfo &info = docks[path.at(0)];-
1161 QToolBarAreaLayoutLine &line = info.lines[path.at(1)];-
1162 if (item->size != pick(line.o, item->realSizeHint())) {
item->size != ...ealSizeHint())Description
TRUEnever evaluated
FALSEnever evaluated
0
1163 //the item doesn't have its default size-
1164 //so we'll give this to the next item-
1165 int newExtraSpace = 0;-
1166 //let's iterate over the siblings of the current item that pare placed before it-
1167 //we need to find just the one before-
1168 for (int i = path.at(2) - 1; i >= 0; --i) {
i >= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1169 QToolBarAreaLayoutItem &previous = line.toolBarItems[i];-
1170 if (!previous.skip()) {
!previous.skip()Description
TRUEnever evaluated
FALSEnever evaluated
0
1171 //we need to check if it has a previous element and a next one-
1172 //the previous will get its size changed-
1173 for (int j = path.at(2) + 1; j < line.toolBarItems.count(); ++j) {
j < line.toolBarItems.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
1174 const QToolBarAreaLayoutItem &next = line.toolBarItems.at(j);-
1175 if (!next.skip()) {
!next.skip()Description
TRUEnever evaluated
FALSEnever evaluated
0
1176 newExtraSpace = next.pos - previous.pos - pick(line.o, previous.sizeHint());-
1177 previous.resize(line.o, next.pos - previous.pos);-
1178 break;
never executed: break;
0
1179 }-
1180 }
never executed: end of block
0
1181 break;
never executed: break;
0
1182 }-
1183 }
never executed: end of block
0
1184-
1185 if (other) {
otherDescription
TRUEnever evaluated
FALSEnever evaluated
0
1186 QToolBarAreaLayoutInfo &info = other->docks[path.at(0)];-
1187 QToolBarAreaLayoutLine &line = info.lines[path.at(1)];-
1188 for (int i = path.at(2) - 1; i >= 0; --i) {
i >= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1189 QToolBarAreaLayoutItem &previous = line.toolBarItems[i];-
1190 if (!previous.skip()) {
!previous.skip()Description
TRUEnever evaluated
FALSEnever evaluated
0
1191 previous.resize(line.o, pick(line.o, previous.sizeHint()) + newExtraSpace);-
1192 break;
never executed: break;
0
1193 }-
1194 }
never executed: end of block
0
1195-
1196 }
never executed: end of block
0
1197 }
never executed: end of block
0
1198-
1199 Q_ASSERT(!item->gap);-
1200 item->gap = true;-
1201 return item->widgetItem;
never executed: return item->widgetItem;
0
1202}-
1203-
1204static QRect unpackRect(uint geom0, uint geom1, bool *floating)-
1205{-
1206 *floating = geom0 & 1;-
1207 if (!*floating)
!*floatingDescription
TRUEnever evaluated
FALSEnever evaluated
0
1208 return QRect();
never executed: return QRect();
0
1209-
1210 geom0 >>= 1;-
1211-
1212 int x = (int)(geom0 & 0x0000ffff) - 0x7FFF;-
1213 int y = (int)(geom1 & 0x0000ffff) - 0x7FFF;-
1214-
1215 geom0 >>= 16;-
1216 geom1 >>= 16;-
1217-
1218 int w = geom0 & 0x0000ffff;-
1219 int h = geom1 & 0x0000ffff;-
1220-
1221 return QRect(x, y, w, h);
never executed: return QRect(x, y, w, h);
0
1222}-
1223-
1224static void packRect(uint *geom0, uint *geom1, const QRect &rect, bool floating)-
1225{-
1226 *geom0 = 0;-
1227 *geom1 = 0;-
1228-
1229 if (!floating)
!floatingDescription
TRUEnever evaluated
FALSEnever evaluated
0
1230 return;
never executed: return;
0
1231-
1232 // The 0x7FFF is half of 0xFFFF. We add it so we can handle negative coordinates on-
1233 // dual monitors. It's subtracted when unpacking.-
1234-
1235 *geom0 |= qMax(0, rect.width()) & 0x0000ffff;-
1236 *geom1 |= qMax(0, rect.height()) & 0x0000ffff;-
1237-
1238 *geom0 <<= 16;-
1239 *geom1 <<= 16;-
1240-
1241 *geom0 |= qMax(0, rect.x() + 0x7FFF) & 0x0000ffff;-
1242 *geom1 |= qMax(0, rect.y() + 0x7FFF) & 0x0000ffff;-
1243-
1244 // yeah, we chop one bit off the width, but it still has a range up to 32512-
1245-
1246 *geom0 <<= 1;-
1247 *geom0 |= 1;-
1248}
never executed: end of block
0
1249-
1250-
1251void QToolBarAreaLayout::saveState(QDataStream &stream) const-
1252{-
1253 // save toolbar state-
1254 stream << (uchar) ToolBarStateMarkerEx;-
1255-
1256 int lineCount = 0;-
1257 for (int i = 0; i < QInternal::DockCount; ++i)
i < QInternal::DockCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
1258 lineCount += docks[i].lines.count();
never executed: lineCount += docks[i].lines.count();
0
1259-
1260 stream << lineCount;-
1261-
1262 for (int i = 0; i < QInternal::DockCount; ++i) {
i < QInternal::DockCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
1263 const QToolBarAreaLayoutInfo &dock = docks[i];-
1264-
1265 for (int j = 0; j < dock.lines.count(); ++j) {
j < dock.lines.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
1266 const QToolBarAreaLayoutLine &line = dock.lines.at(j);-
1267-
1268 stream << i << line.toolBarItems.count();-
1269-
1270 for (int k = 0; k < line.toolBarItems.count(); ++k) {
k < line.toolBarItems.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
1271 const QToolBarAreaLayoutItem &item = line.toolBarItems.at(k);-
1272 QWidget *widget = const_cast<QLayoutItem*>(item.widgetItem)->widget();-
1273 QString objectName = widget->objectName();-
1274 if (Q_UNLIKELY(objectName.isEmpty())) {
__builtin_expe...pty()), false)Description
TRUEnever evaluated
FALSEnever evaluated
0
1275 qWarning("QMainWindow::saveState(): 'objectName' not set for QToolBar %p '%s'",-
1276 widget, widget->windowTitle().toLocal8Bit().constData());-
1277 }
never executed: end of block
0
1278 stream << objectName;-
1279 // we store information as:-
1280 // 1st bit: 1 if shown-
1281 // 2nd bit: 1 if orientation is vertical (default is horizontal)-
1282 uchar shownOrientation = (uchar)!widget->isHidden();-
1283 if (QToolBar * tb= qobject_cast<QToolBar*>(widget)) {
QToolBar * tb=...lBar*>(widget)Description
TRUEnever evaluated
FALSEnever evaluated
0
1284 if (tb->orientation() == Qt::Vertical)
tb->orientatio...= Qt::VerticalDescription
TRUEnever evaluated
FALSEnever evaluated
0
1285 shownOrientation |= 2;
never executed: shownOrientation |= 2;
0
1286 }
never executed: end of block
0
1287 stream << shownOrientation;-
1288 stream << item.pos;-
1289 //we store the preferred size. If the use rdidn't resize the toolbars it will be -1-
1290 stream << item.preferredSize;-
1291-
1292 uint geom0, geom1;-
1293 packRect(&geom0, &geom1, widget->geometry(), widget->isWindow());-
1294 stream << geom0 << geom1;-
1295 }
never executed: end of block
0
1296 }
never executed: end of block
0
1297 }
never executed: end of block
0
1298}
never executed: end of block
0
1299-
1300static inline int getInt(QDataStream &stream)-
1301{-
1302 int x;-
1303 stream >> x;-
1304 return x;
never executed: return x;
0
1305}-
1306-
1307-
1308bool QToolBarAreaLayout::restoreState(QDataStream &stream, const QList<QToolBar*> &_toolBars, uchar tmarker, bool testing)-
1309{-
1310 QList<QToolBar*> toolBars = _toolBars;-
1311 int lines;-
1312 stream >> lines;-
1313-
1314 for (int j = 0; j < lines; ++j) {
j < linesDescription
TRUEnever evaluated
FALSEnever evaluated
0
1315 int pos;-
1316 stream >> pos;-
1317 if (pos < 0 || pos >= QInternal::DockCount)
pos < 0Description
TRUEnever evaluated
FALSEnever evaluated
pos >= QInternal::DockCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
1318 return false;
never executed: return false;
0
1319 int cnt;-
1320 stream >> cnt;-
1321-
1322 QToolBarAreaLayoutInfo &dock = docks[pos];-
1323 const bool applyingLayout = !testing;-
1324 QToolBarAreaLayoutLine line(dock.o);-
1325-
1326 for (int k = 0; k < cnt; ++k) {
k < cntDescription
TRUEnever evaluated
FALSEnever evaluated
0
1327 QToolBarAreaLayoutItem item;-
1328-
1329 QString objectName;-
1330 stream >> objectName;-
1331 uchar shown;-
1332 stream >> shown;-
1333 item.pos = getInt(stream);-
1334 item.size = getInt(stream);-
1335-
1336 /*-
1337 4.3.0 added floating toolbars, but failed to add the ability to restore them.-
1338 We need to store there geometry (four ints). We cannot change the format in a-
1339 patch release (4.3.1) by adding ToolBarStateMarkerEx2 to signal extra data. So-
1340 for now we'll pack it in the two legacy ints we no longer used in Qt4.3.0.-
1341 In 4.4, we should add ToolBarStateMarkerEx2 and fix this properly.-
1342 */-
1343-
1344 QRect rect;-
1345 bool floating = false;-
1346 uint geom0, geom1;-
1347 geom0 = getInt(stream);-
1348 if (tmarker == ToolBarStateMarkerEx) {
tmarker == Too...rStateMarkerExDescription
TRUEnever evaluated
FALSEnever evaluated
0
1349 geom1 = getInt(stream);-
1350 rect = unpackRect(geom0, geom1, &floating);-
1351 }
never executed: end of block
0
1352-
1353 QToolBar *toolBar = 0;-
1354 for (int x = 0; x < toolBars.count(); ++x) {
x < toolBars.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
1355 if (toolBars.at(x)->objectName() == objectName) {
toolBars.at(x)... == objectNameDescription
TRUEnever evaluated
FALSEnever evaluated
0
1356 toolBar = toolBars.takeAt(x);-
1357 break;
never executed: break;
0
1358 }-
1359 }
never executed: end of block
0
1360 if (toolBar == 0) {
toolBar == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1361 continue;
never executed: continue;
0
1362 }-
1363-
1364 if (applyingLayout) {
applyingLayoutDescription
TRUEnever evaluated
FALSEnever evaluated
0
1365 item.widgetItem = new QWidgetItemV2(toolBar);-
1366 toolBar->setOrientation(floating ? ((shown & 2) ? Qt::Vertical : Qt::Horizontal) : dock.o);-
1367 toolBar->setVisible(shown & 1);-
1368 toolBar->d_func()->setWindowState(floating, true, rect);-
1369-
1370 item.preferredSize = item.size;-
1371 line.toolBarItems.append(item);-
1372 }
never executed: end of block
0
1373 }
never executed: end of block
0
1374-
1375 if (applyingLayout) {
applyingLayoutDescription
TRUEnever evaluated
FALSEnever evaluated
0
1376 dock.lines.append(line);-
1377 }
never executed: end of block
0
1378 }
never executed: end of block
0
1379-
1380-
1381 return stream.status() == QDataStream::Ok;
never executed: return stream.status() == QDataStream::Ok;
0
1382}-
1383-
1384bool QToolBarAreaLayout::isEmpty() const-
1385{-
1386 for (int i = 0; i < QInternal::DockCount; ++i) {
i < QInternal::DockCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
1387 if (!docks[i].lines.isEmpty())
!docks[i].lines.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1388 return false;
never executed: return false;
0
1389 }
never executed: end of block
0
1390 return true;
never executed: return true;
0
1391}-
1392-
1393QT_END_NAMESPACE-
1394-
1395#endif // QT_NO_TOOLBAR-
Source codeSwitch to Preprocessed file

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