qmainwindowlayout.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/widgets/widgets/qmainwindowlayout.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Copyright (C) 2015 Olivier Goffart <ogoffart@woboq.com>-
5** Contact: https://www.qt.io/licensing/-
6**-
7** This file is part of the QtWidgets module of the Qt Toolkit.-
8**-
9** $QT_BEGIN_LICENSE:LGPL$-
10** Commercial License Usage-
11** Licensees holding valid commercial Qt licenses may use this file in-
12** accordance with the commercial license agreement provided with the-
13** Software or, alternatively, in accordance with the terms contained in-
14** a written agreement between you and The Qt Company. For licensing terms-
15** and conditions see https://www.qt.io/terms-conditions. For further-
16** information use the contact form at https://www.qt.io/contact-us.-
17**-
18** GNU Lesser General Public License Usage-
19** Alternatively, this file may be used under the terms of the GNU Lesser-
20** General Public License version 3 as published by the Free Software-
21** Foundation and appearing in the file LICENSE.LGPL3 included in the-
22** packaging of this file. Please review the following information to-
23** ensure the GNU Lesser General Public License version 3 requirements-
24** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
25**-
26** GNU General Public License Usage-
27** Alternatively, this file may be used under the terms of the GNU-
28** General Public License version 2.0 or (at your option) the GNU General-
29** Public license version 3 or any later version approved by the KDE Free-
30** Qt Foundation. The licenses are as published by the Free Software-
31** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
32** included in the packaging of this file. Please review the following-
33** information to ensure the GNU General Public License requirements will-
34** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
35** https://www.gnu.org/licenses/gpl-3.0.html.-
36**-
37** $QT_END_LICENSE$-
38**-
39****************************************************************************/-
40-
41#include "qmainwindowlayout_p.h"-
42#include "qdockarealayout_p.h"-
43-
44#ifndef QT_NO_MAINWINDOW-
45#include "qdockwidget.h"-
46#include "qdockwidget_p.h"-
47#include "qtoolbar_p.h"-
48#include "qmainwindow.h"-
49#include "qtoolbar.h"-
50#include "qtoolbarlayout_p.h"-
51#include "qwidgetanimator_p.h"-
52#include "qrubberband.h"-
53#include "qtabbar_p.h"-
54-
55#include <qapplication.h>-
56#include <qstatusbar.h>-
57#include <qstring.h>-
58#include <qstyle.h>-
59#include <qstylepainter.h>-
60#include <qvarlengtharray.h>-
61#include <qstack.h>-
62#include <qmap.h>-
63#include <qtimer.h>-
64-
65#ifndef QT_NO_DEBUG_STREAM-
66# include <qdebug.h>-
67# include <qtextstream.h>-
68#endif-
69-
70#include <private/qapplication_p.h>-
71#include <private/qlayoutengine_p.h>-
72#include <private/qwidgetresizehandler_p.h>-
73#ifdef Q_DEAD_CODE_FROM_QT4_MAC-
74# include <private/qcore_mac_p.h>-
75# include <private/qt_cocoa_helpers_mac_p.h>-
76#endif-
77-
78QT_BEGIN_NAMESPACE-
79-
80extern QMainWindowLayout *qt_mainwindow_layout(const QMainWindow *window);-
81-
82/******************************************************************************-
83** debug-
84*/-
85-
86#if !defined(QT_NO_DOCKWIDGET) && !defined(QT_NO_DEBUG_STREAM)-
87-
88static void dumpLayout(QTextStream &qout, const QDockAreaLayoutInfo &layout, QString indent);-
89-
90static void dumpLayout(QTextStream &qout, const QDockAreaLayoutItem &item, QString indent)-
91{-
92 qout << indent << "QDockAreaLayoutItem: "-
93 << "pos: " << item.pos << " size:" << item.size-
94 << " gap:" << (item.flags & QDockAreaLayoutItem::GapItem)-
95 << " keepSize:" << (item.flags & QDockAreaLayoutItem::KeepSize) << '\n';-
96 indent += QLatin1String(" ");-
97 if (item.widgetItem != 0) {
item.widgetItem != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
98 qout << indent << "widget: "-
99 << item.widgetItem->widget()->metaObject()->className()-
100 << " \"" << item.widgetItem->widget()->windowTitle() << "\"\n";-
101 } else if (item.subinfo != 0) {
never executed: end of block
item.subinfo != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
102 qout << indent << "subinfo:\n";-
103 dumpLayout(qout, *item.subinfo, indent + QLatin1String(" "));-
104 } else if (item.placeHolderItem != 0) {
never executed: end of block
item.placeHolderItem != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
105 QRect r = item.placeHolderItem->topLevelRect;-
106 qout << indent << "placeHolder: "-
107 << "pos: " << item.pos << " size:" << item.size-
108 << " gap:" << (item.flags & QDockAreaLayoutItem::GapItem)-
109 << " keepSize:" << (item.flags & QDockAreaLayoutItem::KeepSize)-
110 << " objectName:" << item.placeHolderItem->objectName-
111 << " hidden:" << item.placeHolderItem->hidden-
112 << " window:" << item.placeHolderItem->window-
113 << " rect:" << r.x() << ',' << r.y() << ' '-
114 << r.width() << 'x' << r.height() << '\n';-
115 }
never executed: end of block
0
116}
never executed: end of block
0
117-
118static void dumpLayout(QTextStream &qout, const QDockAreaLayoutInfo &layout, QString indent)-
119{-
120 const QSize minSize = layout.minimumSize();-
121 qout << indent << "QDockAreaLayoutInfo: "-
122 << layout.rect.left() << ','-
123 << layout.rect.top() << ' '-
124 << layout.rect.width() << 'x'-
125 << layout.rect.height()-
126 << " min size: " << minSize.width() << ',' << minSize.height()-
127 << " orient:" << layout.o-
128 << " tabbed:" << layout.tabbed-
129 << " tbshape:" << layout.tabBarShape << '\n';-
130-
131 indent += QLatin1String(" ");-
132-
133 for (int i = 0; i < layout.item_list.count(); ++i) {
i < layout.item_list.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
134 qout << indent << "Item: " << i << '\n';-
135 dumpLayout(qout, layout.item_list.at(i), indent + QLatin1String(" "));-
136 }
never executed: end of block
0
137}
never executed: end of block
0
138-
139static void dumpLayout(QTextStream &qout, const QDockAreaLayout &layout)-
140{-
141 qout << "QDockAreaLayout: "-
142 << layout.rect.left() << ','-
143 << layout.rect.top() << ' '-
144 << layout.rect.width() << 'x'-
145 << layout.rect.height() << '\n';-
146-
147 qout << "TopDockArea:\n";-
148 dumpLayout(qout, layout.docks[QInternal::TopDock], QLatin1String(" "));-
149 qout << "LeftDockArea:\n";-
150 dumpLayout(qout, layout.docks[QInternal::LeftDock], QLatin1String(" "));-
151 qout << "RightDockArea:\n";-
152 dumpLayout(qout, layout.docks[QInternal::RightDock], QLatin1String(" "));-
153 qout << "BottomDockArea:\n";-
154 dumpLayout(qout, layout.docks[QInternal::BottomDock], QLatin1String(" "));-
155}
never executed: end of block
0
156-
157QDebug operator<<(QDebug debug, const QDockAreaLayout &layout)-
158{-
159 QString s;-
160 QTextStream str(&s);-
161 dumpLayout(str, layout);-
162 debug << s;-
163 return debug;
never executed: return debug;
0
164}-
165-
166QDebug operator<<(QDebug debug, const QMainWindowLayout *layout)-
167{-
168 debug << layout->layoutState.dockAreaLayout;-
169 return debug;
never executed: return debug;
0
170}-
171-
172#endif // !defined(QT_NO_DOCKWIDGET) && !defined(QT_NO_DEBUG)-
173-
174/******************************************************************************-
175 ** QDockWidgetGroupWindow-
176 */-
177// QDockWidgetGroupWindow is the floating window containing the tabbed dockwidgets in case several-
178// dockwidgets are dragged together (QMainWindow::GroupedDragging feature).-
179// QDockWidgetGroupLayout is the layout of that window and use a QDockAreaLayoutInfo to layout-
180// the tabs inside it.-
181#ifndef QT_NO_DOCKWIDGET-
182class QDockWidgetGroupLayout : public QLayout {-
183 QDockAreaLayoutInfo info;-
184 QWidgetResizeHandler *resizer;-
185public:-
186 QDockWidgetGroupLayout(QWidget* parent) : QLayout(parent) {-
187 setSizeConstraint(QLayout::SetMinAndMaxSize);-
188 resizer = new QWidgetResizeHandler(parent);-
189 resizer->setMovingEnabled(false);-
190 }
never executed: end of block
0
191 ~QDockWidgetGroupLayout() {-
192 info.deleteAllLayoutItems();-
193 }
never executed: end of block
0
194-
195 void addItem(QLayoutItem*) Q_DECL_OVERRIDE { Q_UNREACHABLE(); }
never executed: end of block
0
196 int count() const Q_DECL_OVERRIDE { return 0; }
never executed: return 0;
0
197 QLayoutItem* itemAt(int index) const Q_DECL_OVERRIDE-
198 {-
199 int x = 0;-
200 return info.itemAt(&x, index);
never executed: return info.itemAt(&x, index);
0
201 }-
202 QLayoutItem* takeAt(int index) Q_DECL_OVERRIDE-
203 {-
204 int x = 0;-
205 return info.takeAt(&x, index);
never executed: return info.takeAt(&x, index);
0
206 }-
207 QSize sizeHint() const Q_DECL_OVERRIDE-
208 {-
209 int fw = frameWidth();-
210 return info.sizeHint() + QSize(fw, fw);
never executed: return info.sizeHint() + QSize(fw, fw);
0
211 }-
212 QSize minimumSize() const Q_DECL_OVERRIDE-
213 {-
214 int fw = frameWidth();-
215 return info.minimumSize() + QSize(fw, fw);
never executed: return info.minimumSize() + QSize(fw, fw);
0
216 }-
217 QSize maximumSize() const Q_DECL_OVERRIDE-
218 {-
219 int fw = frameWidth();-
220 return info.maximumSize() + QSize(fw, fw);
never executed: return info.maximumSize() + QSize(fw, fw);
0
221 }-
222 void setGeometry(const QRect&r) Q_DECL_OVERRIDE-
223 {-
224 static_cast<QDockWidgetGroupWindow *>(parent())->destroyOrHideIfEmpty();-
225 QDockAreaLayoutInfo *li = layoutInfo();-
226 if (li->isEmpty())
li->isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
227 return;
never executed: return;
0
228 int fw = frameWidth();-
229 li->reparentWidgets(parentWidget());-
230 li->rect = r.adjusted(fw, fw, -fw, -fw);-
231 li->fitItems();-
232 li->apply(false);-
233 resizer->setActive(QWidgetResizeHandler::Resize, !nativeWindowDeco());-
234 }
never executed: end of block
0
235-
236 QDockAreaLayoutInfo *layoutInfo() {-
237 return &info;
never executed: return &info;
0
238 }-
239-
240 bool nativeWindowDeco() const-
241 {-
242 return QDockWidgetLayout::wmSupportsNativeWindowDeco();
never executed: return QDockWidgetLayout::wmSupportsNativeWindowDeco();
0
243 }-
244-
245 int frameWidth() const-
246 {-
247 return nativeWindowDeco() ? 0 :
never executed: return nativeWindowDeco() ? 0 : parentWidget()->style()->pixelMetric(QStyle::PM_DockWidgetFrameWidth, 0, parentWidget());
0
248 parentWidget()->style()->pixelMetric(QStyle::PM_DockWidgetFrameWidth, 0, parentWidget());
never executed: return nativeWindowDeco() ? 0 : parentWidget()->style()->pixelMetric(QStyle::PM_DockWidgetFrameWidth, 0, parentWidget());
0
249 }-
250};-
251-
252bool QDockWidgetGroupWindow::event(QEvent *e)-
253{-
254 switch (e->type()) {-
255 case QEvent::Close:
never executed: case QEvent::Close:
0
256 // Forward the close to the QDockWidget just as if its close button was pressed-
257 if (QDockWidget *dw = topDockWidget()) {
QDockWidget *d...opDockWidget()Description
TRUEnever evaluated
FALSEnever evaluated
0
258 e->ignore();-
259 dw->close();-
260 adjustFlags();-
261 }
never executed: end of block
0
262 return true;
never executed: return true;
0
263 case QEvent::Move:
never executed: case QEvent::Move:
0
264 // Let QDockWidgetPrivate::moseEvent handle the dragging-
265 if (QDockWidget *dw = topDockWidget())
QDockWidget *d...opDockWidget()Description
TRUEnever evaluated
FALSEnever evaluated
0
266 static_cast<QDockWidgetPrivate *>(QObjectPrivate::get(dw))->moveEvent(static_cast<QMoveEvent*>(e));
never executed: static_cast<QDockWidgetPrivate *>(QObjectPrivate::get(dw))->moveEvent(static_cast<QMoveEvent*>(e));
0
267 return true;
never executed: return true;
0
268 case QEvent::NonClientAreaMouseMove:
never executed: case QEvent::NonClientAreaMouseMove:
0
269 case QEvent::NonClientAreaMouseButtonPress:
never executed: case QEvent::NonClientAreaMouseButtonPress:
0
270 case QEvent::NonClientAreaMouseButtonRelease:
never executed: case QEvent::NonClientAreaMouseButtonRelease:
0
271 case QEvent::NonClientAreaMouseButtonDblClick:
never executed: case QEvent::NonClientAreaMouseButtonDblClick:
0
272 // Let the QDockWidgetPrivate of the currently visible dock widget handle the drag and drop-
273 if (QDockWidget *dw = topDockWidget())
QDockWidget *d...opDockWidget()Description
TRUEnever evaluated
FALSEnever evaluated
0
274 static_cast<QDockWidgetPrivate *>(QObjectPrivate::get(dw))->nonClientAreaMouseEvent(static_cast<QMouseEvent*>(e));
never executed: static_cast<QDockWidgetPrivate *>(QObjectPrivate::get(dw))->nonClientAreaMouseEvent(static_cast<QMouseEvent*>(e));
0
275 return true;
never executed: return true;
0
276 case QEvent::ChildAdded:
never executed: case QEvent::ChildAdded:
0
277 if (qobject_cast<QDockWidget *>(static_cast<QChildEvent*>(e)->child()))
qobject_cast<Q...>(e)->child())Description
TRUEnever evaluated
FALSEnever evaluated
0
278 adjustFlags();
never executed: adjustFlags();
0
279 break;
never executed: break;
0
280 case QEvent::LayoutRequest:
never executed: case QEvent::LayoutRequest:
0
281 // We might need to show the widget again-
282 destroyOrHideIfEmpty();-
283 break;
never executed: break;
0
284 default:
never executed: default:
0
285 break;
never executed: break;
0
286 }-
287 return QWidget::event(e);
never executed: return QWidget::event(e);
0
288}-
289-
290void QDockWidgetGroupWindow::paintEvent(QPaintEvent *)-
291{-
292 QDockWidgetGroupLayout *lay = static_cast<QDockWidgetGroupLayout *>(layout());-
293 bool nativeDeco = lay->nativeWindowDeco();-
294-
295 if (!nativeDeco) {
!nativeDecoDescription
TRUEnever evaluated
FALSEnever evaluated
0
296 QStyleOptionFrame framOpt;-
297 framOpt.init(this);-
298 QStylePainter p(this);-
299 p.drawPrimitive(QStyle::PE_FrameDockWidget, framOpt);-
300 }
never executed: end of block
0
301}
never executed: end of block
0
302-
303QDockAreaLayoutInfo *QDockWidgetGroupWindow::layoutInfo() const-
304{-
305 return static_cast<QDockWidgetGroupLayout*>(layout())->layoutInfo();
never executed: return static_cast<QDockWidgetGroupLayout*>(layout())->layoutInfo();
0
306}-
307-
308/*! \internal-
309 Returns the currently active QDockWidget.-
310 */-
311QDockWidget *QDockWidgetGroupWindow::topDockWidget() const-
312{-
313 QDockAreaLayoutInfo *info = layoutInfo();-
314 QDockWidget *dw = 0;-
315 if (info->tabBar && info->tabBar->currentIndex() >= 0) {
info->tabBarDescription
TRUEnever evaluated
FALSEnever evaluated
info->tabBar->...ntIndex() >= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
316 int i = info->tabIndexToListIndex(info->tabBar->currentIndex());-
317 if (i >= 0) {
i >= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
318 const QDockAreaLayoutItem &item = info->item_list.at(i);-
319 if (item.widgetItem)
item.widgetItemDescription
TRUEnever evaluated
FALSEnever evaluated
0
320 dw = qobject_cast<QDockWidget *>(item.widgetItem->widget());
never executed: dw = qobject_cast<QDockWidget *>(item.widgetItem->widget());
0
321 }
never executed: end of block
0
322 }
never executed: end of block
0
323 if (!dw) {
!dwDescription
TRUEnever evaluated
FALSEnever evaluated
0
324 for (int i = 0; !dw && i < info->item_list.count(); ++i) {
!dwDescription
TRUEnever evaluated
FALSEnever evaluated
i < info->item_list.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
325 const QDockAreaLayoutItem &item = info->item_list.at(i);-
326 if (item.skip())
item.skip()Description
TRUEnever evaluated
FALSEnever evaluated
0
327 continue;
never executed: continue;
0
328 if (!item.widgetItem)
!item.widgetItemDescription
TRUEnever evaluated
FALSEnever evaluated
0
329 continue;
never executed: continue;
0
330 dw = qobject_cast<QDockWidget *>(item.widgetItem->widget());-
331 }
never executed: end of block
0
332 }
never executed: end of block
0
333 return dw;
never executed: return dw;
0
334}-
335-
336/*! \internal-
337 Destroy or hide this window if there is no more QDockWidget in it.-
338 Otherwise make sure it is shown.-
339 */-
340void QDockWidgetGroupWindow::destroyOrHideIfEmpty()-
341{-
342 if (!layoutInfo()->isEmpty()) {
!layoutInfo()->isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
343 show(); // It might have been hidden,-
344 return;
never executed: return;
0
345 }-
346 // There might still be placeholders-
347 if (!layoutInfo()->item_list.isEmpty()) {
!layoutInfo()-...list.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
348 hide();-
349 return;
never executed: return;
0
350 }-
351-
352 // Make sure to reparent the possibly floating or hidden QDockWidgets to the parent-
353 foreach (QDockWidget *dw, findChildren<QDockWidget *>(QString(), Qt::FindDirectChildrenOnly)) {-
354 bool wasFloating = dw->isFloating();-
355 bool wasHidden = dw->isHidden();-
356 dw->setParent(parentWidget());-
357 if (wasFloating) {
wasFloatingDescription
TRUEnever evaluated
FALSEnever evaluated
0
358 dw->setFloating(true);-
359 } else {
never executed: end of block
0
360 // maybe it was hidden, we still have to put it back in the main layout.-
361 QMainWindowLayout *ml =-
362 qt_mainwindow_layout(static_cast<QMainWindow *>(parentWidget()));-
363 Qt::DockWidgetArea area = ml->dockWidgetArea(this);-
364 if (area == Qt::NoDockWidgetArea)
area == Qt::NoDockWidgetAreaDescription
TRUEnever evaluated
FALSEnever evaluated
0
365 area = Qt::LeftDockWidgetArea;
never executed: area = Qt::LeftDockWidgetArea;
0
366 static_cast<QMainWindow *>(parentWidget())->addDockWidget(area, dw);-
367 }
never executed: end of block
0
368 if (!wasHidden)
!wasHiddenDescription
TRUEnever evaluated
FALSEnever evaluated
0
369 dw->show();
never executed: dw->show();
0
370 }
never executed: end of block
0
371 foreach (QTabBar *tb, findChildren<QTabBar *>(QString(), Qt::FindDirectChildrenOnly))-
372 tb->setParent(parentWidget());
never executed: tb->setParent(parentWidget());
0
373 deleteLater();-
374}
never executed: end of block
0
375-
376/*! \internal-
377 Sets the flags of this window in accordence to the capabilities of the dock widgets-
378 */-
379void QDockWidgetGroupWindow::adjustFlags()-
380{-
381 QDockWidget *top = topDockWidget();-
382 if (!top)
!topDescription
TRUEnever evaluated
FALSEnever evaluated
0
383 return;
never executed: return;
0
384 const bool nativeDeco = static_cast<QDockWidgetGroupLayout *>(layout())->nativeWindowDeco();-
385-
386 Qt::WindowFlags oldFlags = windowFlags();-
387 Qt::WindowFlags flags = oldFlags;-
388 if (nativeDeco) {
nativeDecoDescription
TRUEnever evaluated
FALSEnever evaluated
0
389 flags |= Qt::CustomizeWindowHint | Qt::WindowTitleHint;-
390 flags.setFlag(Qt::WindowCloseButtonHint, top->features() & QDockWidget::DockWidgetClosable);-
391 flags &= ~Qt::FramelessWindowHint;-
392 } else {
never executed: end of block
0
393 flags |= Qt::FramelessWindowHint;-
394 }
never executed: end of block
0
395 if (oldFlags != flags) {
oldFlags != flagsDescription
TRUEnever evaluated
FALSEnever evaluated
0
396 setWindowFlags(flags);-
397 show(); // setWindowFlags hides the window-
398 }
never executed: end of block
0
399-
400 setWindowTitle(top->windowTitle());-
401 setWindowIcon(top->windowIcon());-
402}
never executed: end of block
0
403#endif-
404-
405/******************************************************************************-
406** QMainWindowLayoutState-
407*/-
408-
409// we deal with all the #ifndefferry here so QMainWindowLayout code is clean-
410-
411QMainWindowLayoutState::QMainWindowLayoutState(QMainWindow *win)-
412 :-
413#ifndef QT_NO_TOOLBAR-
414 toolBarAreaLayout(win),-
415#endif-
416#ifndef QT_NO_DOCKWIDGET-
417 dockAreaLayout(win)-
418#else-
419 centralWidgetItem(0)-
420#endif-
421-
422{-
423 mainWindow = win;-
424}
never executed: end of block
0
425-
426QSize QMainWindowLayoutState::sizeHint() const-
427{-
428-
429 QSize result(0, 0);-
430-
431#ifndef QT_NO_DOCKWIDGET-
432 result = dockAreaLayout.sizeHint();-
433#else-
434 if (centralWidgetItem != 0)-
435 result = centralWidgetItem->sizeHint();-
436#endif-
437-
438#ifndef QT_NO_TOOLBAR-
439 result = toolBarAreaLayout.sizeHint(result);-
440#endif // QT_NO_TOOLBAR-
441-
442 return result;
never executed: return result;
0
443}-
444-
445QSize QMainWindowLayoutState::minimumSize() const-
446{-
447 QSize result(0, 0);-
448-
449#ifndef QT_NO_DOCKWIDGET-
450 result = dockAreaLayout.minimumSize();-
451#else-
452 if (centralWidgetItem != 0)-
453 result = centralWidgetItem->minimumSize();-
454#endif-
455-
456#ifndef QT_NO_TOOLBAR-
457 result = toolBarAreaLayout.minimumSize(result);-
458#endif // QT_NO_TOOLBAR-
459-
460 return result;
never executed: return result;
0
461}-
462-
463void QMainWindowLayoutState::apply(bool animated)-
464{-
465#ifndef QT_NO_TOOLBAR-
466 toolBarAreaLayout.apply(animated);-
467#endif-
468-
469#ifndef QT_NO_DOCKWIDGET-
470// dumpLayout(dockAreaLayout, QString());-
471 dockAreaLayout.apply(animated);-
472#else-
473 if (centralWidgetItem != 0) {-
474 QMainWindowLayout *layout = qt_mainwindow_layout(mainWindow);-
475 Q_ASSERT(layout != 0);-
476 layout->widgetAnimator.animate(centralWidgetItem->widget(), centralWidgetRect, animated);-
477 }-
478#endif-
479}
never executed: end of block
0
480-
481void QMainWindowLayoutState::fitLayout()-
482{-
483 QRect r;-
484#ifdef QT_NO_TOOLBAR-
485 r = rect;-
486#else-
487 toolBarAreaLayout.rect = rect;-
488 r = toolBarAreaLayout.fitLayout();-
489#endif // QT_NO_TOOLBAR-
490-
491#ifndef QT_NO_DOCKWIDGET-
492 dockAreaLayout.rect = r;-
493 dockAreaLayout.fitLayout();-
494#else-
495 centralWidgetRect = r;-
496#endif-
497}
never executed: end of block
0
498-
499void QMainWindowLayoutState::deleteAllLayoutItems()-
500{-
501#ifndef QT_NO_TOOLBAR-
502 toolBarAreaLayout.deleteAllLayoutItems();-
503#endif-
504-
505#ifndef QT_NO_DOCKWIDGET-
506 dockAreaLayout.deleteAllLayoutItems();-
507#endif-
508}
never executed: end of block
0
509-
510void QMainWindowLayoutState::deleteCentralWidgetItem()-
511{-
512#ifndef QT_NO_DOCKWIDGET-
513 delete dockAreaLayout.centralWidgetItem;-
514 dockAreaLayout.centralWidgetItem = 0;-
515#else-
516 delete centralWidgetItem;-
517 centralWidgetItem = 0;-
518#endif-
519}
never executed: end of block
0
520-
521QLayoutItem *QMainWindowLayoutState::itemAt(int index, int *x) const-
522{-
523#ifndef QT_NO_TOOLBAR-
524 if (QLayoutItem *ret = toolBarAreaLayout.itemAt(x, index))
QLayoutItem *r...emAt(x, index)Description
TRUEnever evaluated
FALSEnever evaluated
0
525 return ret;
never executed: return ret;
0
526#endif-
527-
528#ifndef QT_NO_DOCKWIDGET-
529 if (QLayoutItem *ret = dockAreaLayout.itemAt(x, index))
QLayoutItem *r...emAt(x, index)Description
TRUEnever evaluated
FALSEnever evaluated
0
530 return ret;
never executed: return ret;
0
531#else-
532 if (centralWidgetItem != 0 && (*x)++ == index)-
533 return centralWidgetItem;-
534#endif-
535-
536 return 0;
never executed: return 0;
0
537}-
538-
539QLayoutItem *QMainWindowLayoutState::takeAt(int index, int *x)-
540{-
541#ifndef QT_NO_TOOLBAR-
542 if (QLayoutItem *ret = toolBarAreaLayout.takeAt(x, index))
QLayoutItem *r...keAt(x, index)Description
TRUEnever evaluated
FALSEnever evaluated
0
543 return ret;
never executed: return ret;
0
544#endif-
545-
546#ifndef QT_NO_DOCKWIDGET-
547 if (QLayoutItem *ret = dockAreaLayout.takeAt(x, index))
QLayoutItem *r...keAt(x, index)Description
TRUEnever evaluated
FALSEnever evaluated
0
548 return ret;
never executed: return ret;
0
549#else-
550 if (centralWidgetItem != 0 && (*x)++ == index) {-
551 QLayoutItem *ret = centralWidgetItem;-
552 centralWidgetItem = 0;-
553 return ret;-
554 }-
555#endif-
556-
557 return 0;
never executed: return 0;
0
558}-
559-
560QList<int> QMainWindowLayoutState::indexOf(QWidget *widget) const-
561{-
562 QList<int> result;-
563-
564#ifndef QT_NO_TOOLBAR-
565 // is it a toolbar?-
566 if (QToolBar *toolBar = qobject_cast<QToolBar*>(widget)) {
QToolBar *tool...lBar*>(widget)Description
TRUEnever evaluated
FALSEnever evaluated
0
567 result = toolBarAreaLayout.indexOf(toolBar);-
568 if (!result.isEmpty())
!result.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
569 result.prepend(0);
never executed: result.prepend(0);
0
570 return result;
never executed: return result;
0
571 }-
572#endif-
573-
574#ifndef QT_NO_DOCKWIDGET-
575 // is it a dock widget?-
576 if (qobject_cast<QDockWidget *>(widget) || qobject_cast<QDockWidgetGroupWindow *>(widget)) {
qobject_cast<Q...get *>(widget)Description
TRUEnever evaluated
FALSEnever evaluated
qobject_cast<Q...dow *>(widget)Description
TRUEnever evaluated
FALSEnever evaluated
0
577 result = dockAreaLayout.indexOf(widget);-
578 if (!result.isEmpty())
!result.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
579 result.prepend(1);
never executed: result.prepend(1);
0
580 return result;
never executed: return result;
0
581 }-
582#endif //QT_NO_DOCKWIDGET-
583-
584 return result;
never executed: return result;
0
585}-
586-
587bool QMainWindowLayoutState::contains(QWidget *widget) const-
588{-
589#ifndef QT_NO_DOCKWIDGET-
590 if (dockAreaLayout.centralWidgetItem != 0 && dockAreaLayout.centralWidgetItem->widget() == widget)
dockAreaLayout...idgetItem != 0Description
TRUEnever evaluated
FALSEnever evaluated
dockAreaLayout...et() == widgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
591 return true;
never executed: return true;
0
592 if (!dockAreaLayout.indexOf(widget).isEmpty())
!dockAreaLayou...get).isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
593 return true;
never executed: return true;
0
594#else-
595 if (centralWidgetItem != 0 && centralWidgetItem->widget() == widget)-
596 return true;-
597#endif-
598-
599#ifndef QT_NO_TOOLBAR-
600 if (!toolBarAreaLayout.indexOf(widget).isEmpty())
!toolBarAreaLa...get).isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
601 return true;
never executed: return true;
0
602#endif-
603 return false;
never executed: return false;
0
604}-
605-
606void QMainWindowLayoutState::setCentralWidget(QWidget *widget)-
607{-
608 QLayoutItem *item = 0;-
609 //make sure we remove the widget-
610 deleteCentralWidgetItem();-
611-
612 if (widget != 0)
widget != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
613 item = new QWidgetItemV2(widget);
never executed: item = new QWidgetItemV2(widget);
0
614-
615#ifndef QT_NO_DOCKWIDGET-
616 dockAreaLayout.centralWidgetItem = item;-
617#else-
618 centralWidgetItem = item;-
619#endif-
620}
never executed: end of block
0
621-
622QWidget *QMainWindowLayoutState::centralWidget() const-
623{-
624 QLayoutItem *item = 0;-
625-
626#ifndef QT_NO_DOCKWIDGET-
627 item = dockAreaLayout.centralWidgetItem;-
628#else-
629 item = centralWidgetItem;-
630#endif-
631-
632 if (item != 0)
item != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
633 return item->widget();
never executed: return item->widget();
0
634 return 0;
never executed: return 0;
0
635}-
636-
637QList<int> QMainWindowLayoutState::gapIndex(QWidget *widget,-
638 const QPoint &pos) const-
639{-
640 QList<int> result;-
641-
642#ifndef QT_NO_TOOLBAR-
643 // is it a toolbar?-
644 if (qobject_cast<QToolBar*>(widget) != 0) {
qobject_cast<Q...>(widget) != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
645 result = toolBarAreaLayout.gapIndex(pos);-
646 if (!result.isEmpty())
!result.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
647 result.prepend(0);
never executed: result.prepend(0);
0
648 return result;
never executed: return result;
0
649 }-
650#endif-
651-
652#ifndef QT_NO_DOCKWIDGET-
653 // is it a dock widget?-
654 if (qobject_cast<QDockWidget *>(widget) != 0
qobject_cast<Q...>(widget) != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
655 || qobject_cast<QDockWidgetGroupWindow *>(widget)) {
qobject_cast<Q...dow *>(widget)Description
TRUEnever evaluated
FALSEnever evaluated
0
656 result = dockAreaLayout.gapIndex(pos);-
657 if (!result.isEmpty())
!result.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
658 result.prepend(1);
never executed: result.prepend(1);
0
659 return result;
never executed: return result;
0
660 }-
661#endif //QT_NO_DOCKWIDGET-
662-
663 return result;
never executed: return result;
0
664}-
665-
666bool QMainWindowLayoutState::insertGap(const QList<int> &path, QLayoutItem *item)-
667{-
668 if (path.isEmpty())
path.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
669 return false;
never executed: return false;
0
670-
671 int i = path.first();-
672-
673#ifndef QT_NO_TOOLBAR-
674 if (i == 0) {
i == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
675 Q_ASSERT(qobject_cast<QToolBar*>(item->widget()) != 0);-
676 return toolBarAreaLayout.insertGap(path.mid(1), item);
never executed: return toolBarAreaLayout.insertGap(path.mid(1), item);
0
677 }-
678#endif-
679-
680#ifndef QT_NO_DOCKWIDGET-
681 if (i == 1) {
i == 1Description
TRUEnever evaluated
FALSEnever evaluated
0
682 Q_ASSERT(qobject_cast<QDockWidget*>(item->widget()) || qobject_cast<QDockWidgetGroupWindow*>(item->widget()));-
683 return dockAreaLayout.insertGap(path.mid(1), item);
never executed: return dockAreaLayout.insertGap(path.mid(1), item);
0
684 }-
685#endif //QT_NO_DOCKWIDGET-
686-
687 return false;
never executed: return false;
0
688}-
689-
690void QMainWindowLayoutState::remove(const QList<int> &path)-
691{-
692 int i = path.first();-
693-
694#ifndef QT_NO_TOOLBAR-
695 if (i == 0)
i == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
696 toolBarAreaLayout.remove(path.mid(1));
never executed: toolBarAreaLayout.remove(path.mid(1));
0
697#endif-
698-
699#ifndef QT_NO_DOCKWIDGET-
700 if (i == 1)
i == 1Description
TRUEnever evaluated
FALSEnever evaluated
0
701 dockAreaLayout.remove(path.mid(1));
never executed: dockAreaLayout.remove(path.mid(1));
0
702#endif //QT_NO_DOCKWIDGET-
703}
never executed: end of block
0
704-
705void QMainWindowLayoutState::remove(QLayoutItem *item)-
706{-
707#ifndef QT_NO_TOOLBAR-
708 toolBarAreaLayout.remove(item);-
709#endif-
710-
711#ifndef QT_NO_DOCKWIDGET-
712 // is it a dock widget?-
713 if (QDockWidget *dockWidget = qobject_cast<QDockWidget *>(item->widget())) {
QDockWidget *d...tem->widget())Description
TRUEnever evaluated
FALSEnever evaluated
0
714 QList<int> path = dockAreaLayout.indexOf(dockWidget);-
715 if (!path.isEmpty())
!path.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
716 dockAreaLayout.remove(path);
never executed: dockAreaLayout.remove(path);
0
717 }
never executed: end of block
0
718#endif //QT_NO_DOCKWIDGET-
719}
never executed: end of block
0
720-
721void QMainWindowLayoutState::clear()-
722{-
723#ifndef QT_NO_TOOLBAR-
724 toolBarAreaLayout.clear();-
725#endif-
726-
727#ifndef QT_NO_DOCKWIDGET-
728 dockAreaLayout.clear();-
729#else-
730 centralWidgetRect = QRect();-
731#endif-
732-
733 rect = QRect();-
734}
never executed: end of block
0
735-
736bool QMainWindowLayoutState::isValid() const-
737{-
738 return rect.isValid();
never executed: return rect.isValid();
0
739}-
740-
741QLayoutItem *QMainWindowLayoutState::item(const QList<int> &path)-
742{-
743 int i = path.first();-
744-
745#ifndef QT_NO_TOOLBAR-
746 if (i == 0) {
i == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
747 const QToolBarAreaLayoutItem *tbItem = toolBarAreaLayout.item(path.mid(1));-
748 Q_ASSERT(tbItem);-
749 return tbItem->widgetItem;
never executed: return tbItem->widgetItem;
0
750 }-
751#endif-
752-
753#ifndef QT_NO_DOCKWIDGET-
754 if (i == 1)
i == 1Description
TRUEnever evaluated
FALSEnever evaluated
0
755 return dockAreaLayout.item(path.mid(1)).widgetItem;
never executed: return dockAreaLayout.item(path.mid(1)).widgetItem;
0
756#endif //QT_NO_DOCKWIDGET-
757-
758 return 0;
never executed: return 0;
0
759}-
760-
761QRect QMainWindowLayoutState::itemRect(const QList<int> &path) const-
762{-
763 int i = path.first();-
764-
765#ifndef QT_NO_TOOLBAR-
766 if (i == 0)
i == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
767 return toolBarAreaLayout.itemRect(path.mid(1));
never executed: return toolBarAreaLayout.itemRect(path.mid(1));
0
768#endif-
769-
770#ifndef QT_NO_DOCKWIDGET-
771 if (i == 1)
i == 1Description
TRUEnever evaluated
FALSEnever evaluated
0
772 return dockAreaLayout.itemRect(path.mid(1));
never executed: return dockAreaLayout.itemRect(path.mid(1));
0
773#endif //QT_NO_DOCKWIDGET-
774-
775 return QRect();
never executed: return QRect();
0
776}-
777-
778QRect QMainWindowLayoutState::gapRect(const QList<int> &path) const-
779{-
780 int i = path.first();-
781-
782#ifndef QT_NO_TOOLBAR-
783 if (i == 0)
i == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
784 return toolBarAreaLayout.itemRect(path.mid(1));
never executed: return toolBarAreaLayout.itemRect(path.mid(1));
0
785#endif-
786-
787#ifndef QT_NO_DOCKWIDGET-
788 if (i == 1)
i == 1Description
TRUEnever evaluated
FALSEnever evaluated
0
789 return dockAreaLayout.gapRect(path.mid(1));
never executed: return dockAreaLayout.gapRect(path.mid(1));
0
790#endif //QT_NO_DOCKWIDGET-
791-
792 return QRect();
never executed: return QRect();
0
793}-
794-
795QLayoutItem *QMainWindowLayoutState::plug(const QList<int> &path)-
796{-
797 int i = path.first();-
798-
799#ifndef QT_NO_TOOLBAR-
800 if (i == 0)
i == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
801 return toolBarAreaLayout.plug(path.mid(1));
never executed: return toolBarAreaLayout.plug(path.mid(1));
0
802#endif-
803-
804#ifndef QT_NO_DOCKWIDGET-
805 if (i == 1)
i == 1Description
TRUEnever evaluated
FALSEnever evaluated
0
806 return dockAreaLayout.plug(path.mid(1));
never executed: return dockAreaLayout.plug(path.mid(1));
0
807#endif //QT_NO_DOCKWIDGET-
808-
809 return 0;
never executed: return 0;
0
810}-
811-
812QLayoutItem *QMainWindowLayoutState::unplug(const QList<int> &path, QMainWindowLayoutState *other)-
813{-
814 int i = path.first();-
815-
816#ifdef QT_NO_TOOLBAR-
817 Q_UNUSED(other);-
818#else-
819 if (i == 0)
i == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
820 return toolBarAreaLayout.unplug(path.mid(1), other ? &other->toolBarAreaLayout : 0);
never executed: return toolBarAreaLayout.unplug(path.mid(1), other ? &other->toolBarAreaLayout : 0);
0
821#endif-
822-
823#ifndef QT_NO_DOCKWIDGET-
824 if (i == 1)
i == 1Description
TRUEnever evaluated
FALSEnever evaluated
0
825 return dockAreaLayout.unplug(path.mid(1));
never executed: return dockAreaLayout.unplug(path.mid(1));
0
826#endif //QT_NO_DOCKWIDGET-
827-
828 return 0;
never executed: return 0;
0
829}-
830-
831void QMainWindowLayoutState::saveState(QDataStream &stream) const-
832{-
833#ifndef QT_NO_DOCKWIDGET-
834 dockAreaLayout.saveState(stream);-
835#ifndef QT_NO_TABBAR-
836 QList<QDockWidgetGroupWindow *> floatingTabs =-
837 mainWindow->findChildren<QDockWidgetGroupWindow *>(QString(), Qt::FindDirectChildrenOnly);-
838-
839 foreach (QDockWidgetGroupWindow *floating, floatingTabs) {-
840 if (floating->layoutInfo()->isEmpty())
floating->layo...o()->isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
841 continue;
never executed: continue;
0
842 stream << uchar(QDockAreaLayout::FloatingDockWidgetTabMarker) << floating->geometry();-
843 floating->layoutInfo()->saveState(stream);-
844 }
never executed: end of block
0
845#endif-
846#endif-
847#ifndef QT_NO_TOOLBAR-
848 toolBarAreaLayout.saveState(stream);-
849#endif-
850}
never executed: end of block
0
851-
852template <typename T>-
853static QList<T> findChildrenHelper(const QObject *o)-
854{-
855 const QObjectList &list = o->children();-
856 QList<T> result;-
857-
858 for (int i=0; i < list.size(); ++i) {
i < list.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
859 if (T t = qobject_cast<T>(list[i])) {
T t = qobject_cast<T>(list[i])Description
TRUEnever evaluated
FALSEnever evaluated
0
860 result.append(t);-
861 }
never executed: end of block
0
862 }
never executed: end of block
0
863-
864 return result;
never executed: return result;
0
865}-
866-
867#ifndef QT_NO_DOCKWIDGET-
868static QList<QDockWidget*> allMyDockWidgets(const QWidget *mainWindow)-
869{-
870 QList<QDockWidget*> result;-
871 for (QObject *c : mainWindow->children()) {-
872 if (auto *dw = qobject_cast<QDockWidget*>(c)) {
auto *dw = qob...ockWidget*>(c)Description
TRUEnever evaluated
FALSEnever evaluated
0
873 result.append(dw);-
874 } else if (auto *gw = qobject_cast<QDockWidgetGroupWindow*>(c)) {
never executed: end of block
auto *gw = qob...oupWindow*>(c)Description
TRUEnever evaluated
FALSEnever evaluated
0
875 for (QObject *c : gw->children()) {-
876 if (auto *dw = qobject_cast<QDockWidget*>(c))
auto *dw = qob...ockWidget*>(c)Description
TRUEnever evaluated
FALSEnever evaluated
0
877 result.append(dw);
never executed: result.append(dw);
0
878 }
never executed: end of block
0
879 }
never executed: end of block
0
880 }
never executed: end of block
0
881-
882 return result;
never executed: return result;
0
883}-
884#endif // QT_NO_DOCKWIDGET-
885-
886//pre4.3 tests the format that was used before 4.3-
887bool QMainWindowLayoutState::checkFormat(QDataStream &stream)-
888{-
889 while (!stream.atEnd()) {
!stream.atEnd()Description
TRUEnever evaluated
FALSEnever evaluated
0
890 uchar marker;-
891 stream >> marker;-
892 switch(marker)-
893 {-
894#ifndef QT_NO_TOOLBAR-
895 case QToolBarAreaLayout::ToolBarStateMarker:
never executed: case QToolBarAreaLayout::ToolBarStateMarker:
0
896 case QToolBarAreaLayout::ToolBarStateMarkerEx:
never executed: case QToolBarAreaLayout::ToolBarStateMarkerEx:
0
897 {-
898 QList<QToolBar *> toolBars = findChildrenHelper<QToolBar*>(mainWindow);-
899 if (!toolBarAreaLayout.restoreState(stream, toolBars, marker, true /*testing*/)) {
!toolBarAreaLa...marker, true )Description
TRUEnever evaluated
FALSEnever evaluated
0
900 return false;
never executed: return false;
0
901 }-
902 }-
903 break;
never executed: break;
0
904#endif // QT_NO_TOOLBAR-
905-
906#ifndef QT_NO_DOCKWIDGET-
907 case QDockAreaLayout::DockWidgetStateMarker:
never executed: case QDockAreaLayout::DockWidgetStateMarker:
0
908 {-
909 const auto dockWidgets = allMyDockWidgets(mainWindow);-
910 if (!dockAreaLayout.restoreState(stream, dockWidgets, true /*testing*/)) {
!dockAreaLayou...idgets, true )Description
TRUEnever evaluated
FALSEnever evaluated
0
911 return false;
never executed: return false;
0
912 }-
913 }-
914 break;
never executed: break;
0
915#ifndef QT_NO_TABBAR-
916 case QDockAreaLayout::FloatingDockWidgetTabMarker:
never executed: case QDockAreaLayout::FloatingDockWidgetTabMarker:
0
917 {-
918 QRect geom;-
919 stream >> geom;-
920 QDockAreaLayoutInfo info;-
921 auto dockWidgets = allMyDockWidgets(mainWindow);-
922 if (!info.restoreState(stream, dockWidgets, true /* testing*/))
!info.restoreS...idgets, true )Description
TRUEnever evaluated
FALSEnever evaluated
0
923 return false;
never executed: return false;
0
924 }-
925 break;
never executed: break;
0
926#endif // QT_NO_TABBAR-
927#endif // QT_NO_DOCKWIDGET-
928 default:
never executed: default:
0
929 //there was an error during the parsing-
930 return false;
never executed: return false;
0
931 }// switch-
932 } //while-
933-
934 //everything went fine: it must be a pre-4.3 saved state-
935 return true;
never executed: return true;
0
936}-
937-
938bool QMainWindowLayoutState::restoreState(QDataStream &_stream,-
939 const QMainWindowLayoutState &oldState)-
940{-
941 //make a copy of the data so that we can read it more than once-
942 QByteArray copy;-
943 while(!_stream.atEnd()) {
!_stream.atEnd()Description
TRUEnever evaluated
FALSEnever evaluated
0
944 int length = 1024;-
945 QByteArray ba(length, '\0');-
946 length = _stream.readRawData(ba.data(), ba.size());-
947 ba.resize(length);-
948 copy += ba;-
949 }
never executed: end of block
0
950-
951 QDataStream ds(copy);-
952 if (!checkFormat(ds))
!checkFormat(ds)Description
TRUEnever evaluated
FALSEnever evaluated
0
953 return false;
never executed: return false;
0
954-
955 QDataStream stream(copy);-
956-
957 while (!stream.atEnd()) {
!stream.atEnd()Description
TRUEnever evaluated
FALSEnever evaluated
0
958 uchar marker;-
959 stream >> marker;-
960 switch(marker)-
961 {-
962#ifndef QT_NO_DOCKWIDGET-
963 case QDockAreaLayout::DockWidgetStateMarker:
never executed: case QDockAreaLayout::DockWidgetStateMarker:
0
964 {-
965 const auto dockWidgets = allMyDockWidgets(mainWindow);-
966 if (!dockAreaLayout.restoreState(stream, dockWidgets))
!dockAreaLayou..., dockWidgets)Description
TRUEnever evaluated
FALSEnever evaluated
0
967 return false;
never executed: return false;
0
968-
969 for (int i = 0; i < dockWidgets.size(); ++i) {
i < dockWidgets.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
970 QDockWidget *w = dockWidgets.at(i);-
971 QList<int> path = dockAreaLayout.indexOf(w);-
972 if (path.isEmpty()) {
path.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
973 QList<int> oldPath = oldState.dockAreaLayout.indexOf(w);-
974 if (oldPath.isEmpty()) {
oldPath.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
975 continue;
never executed: continue;
0
976 }-
977 QDockAreaLayoutInfo *info = dockAreaLayout.info(oldPath);-
978 if (info == 0) {
info == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
979 continue;
never executed: continue;
0
980 }-
981 info->item_list.append(QDockAreaLayoutItem(new QDockWidgetItem(w)));-
982 }
never executed: end of block
0
983 }
never executed: end of block
0
984 }-
985 break;
never executed: break;
0
986#ifndef QT_NO_TABBAR-
987 case QDockAreaLayout::FloatingDockWidgetTabMarker:
never executed: case QDockAreaLayout::FloatingDockWidgetTabMarker:
0
988 {-
989 auto dockWidgets = allMyDockWidgets(mainWindow);-
990 QDockWidgetGroupWindow* floatingTab = qt_mainwindow_layout(mainWindow)->createTabbedDockWindow();-
991 *floatingTab->layoutInfo() = QDockAreaLayoutInfo(&dockAreaLayout.sep, QInternal::LeftDock,-
992 Qt::Horizontal, QTabBar::RoundedSouth, mainWindow);-
993 QRect geometry;-
994 stream >> geometry;-
995 if (!floatingTab->layoutInfo()->restoreState(stream, dockWidgets, false))
!floatingTab->...idgets, false)Description
TRUEnever evaluated
FALSEnever evaluated
0
996 return false;
never executed: return false;
0
997 geometry = QDockAreaLayout::constrainedRect(geometry, floatingTab);-
998 floatingTab->move(geometry.topLeft());-
999 floatingTab->resize(geometry.size());-
1000 floatingTab->show();-
1001 }-
1002 break;
never executed: break;
0
1003#endif // QT_NO_TABBAR-
1004#endif // QT_NO_DOCKWIDGET-
1005-
1006#ifndef QT_NO_TOOLBAR-
1007 case QToolBarAreaLayout::ToolBarStateMarker:
never executed: case QToolBarAreaLayout::ToolBarStateMarker:
0
1008 case QToolBarAreaLayout::ToolBarStateMarkerEx:
never executed: case QToolBarAreaLayout::ToolBarStateMarkerEx:
0
1009 {-
1010 QList<QToolBar *> toolBars = findChildrenHelper<QToolBar*>(mainWindow);-
1011 if (!toolBarAreaLayout.restoreState(stream, toolBars, marker))
!toolBarAreaLa...lBars, marker)Description
TRUEnever evaluated
FALSEnever evaluated
0
1012 return false;
never executed: return false;
0
1013-
1014 for (int i = 0; i < toolBars.size(); ++i) {
i < toolBars.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
1015 QToolBar *w = toolBars.at(i);-
1016 QList<int> path = toolBarAreaLayout.indexOf(w);-
1017 if (path.isEmpty()) {
path.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1018 QList<int> oldPath = oldState.toolBarAreaLayout.indexOf(w);-
1019 if (oldPath.isEmpty()) {
oldPath.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1020 continue;
never executed: continue;
0
1021 }-
1022 toolBarAreaLayout.docks[oldPath.at(0)].insertToolBar(0, w);-
1023 }
never executed: end of block
0
1024 }
never executed: end of block
0
1025 }-
1026 break;
never executed: break;
0
1027#endif //QT_NO_TOOLBAR-
1028 default:
never executed: default:
0
1029 return false;
never executed: return false;
0
1030 }// switch-
1031 } //while-
1032-
1033-
1034 return true;
never executed: return true;
0
1035}-
1036-
1037/******************************************************************************-
1038** QMainWindowLayoutState - toolbars-
1039*/-
1040-
1041#ifndef QT_NO_TOOLBAR-
1042-
1043static inline void validateToolBarArea(Qt::ToolBarArea &area)-
1044{-
1045 switch (area) {-
1046 case Qt::LeftToolBarArea:
never executed: case Qt::LeftToolBarArea:
0
1047 case Qt::RightToolBarArea:
never executed: case Qt::RightToolBarArea:
0
1048 case Qt::TopToolBarArea:
never executed: case Qt::TopToolBarArea:
0
1049 case Qt::BottomToolBarArea:
never executed: case Qt::BottomToolBarArea:
0
1050 break;
never executed: break;
0
1051 default:
never executed: default:
0
1052 area = Qt::TopToolBarArea;-
1053 }
never executed: end of block
0
1054}-
1055-
1056static QInternal::DockPosition toDockPos(Qt::ToolBarArea area)-
1057{-
1058 switch (area) {-
1059 case Qt::LeftToolBarArea: return QInternal::LeftDock;
never executed: return QInternal::LeftDock;
never executed: case Qt::LeftToolBarArea:
0
1060 case Qt::RightToolBarArea: return QInternal::RightDock;
never executed: return QInternal::RightDock;
never executed: case Qt::RightToolBarArea:
0
1061 case Qt::TopToolBarArea: return QInternal::TopDock;
never executed: return QInternal::TopDock;
never executed: case Qt::TopToolBarArea:
0
1062 case Qt::BottomToolBarArea: return QInternal::BottomDock;
never executed: return QInternal::BottomDock;
never executed: case Qt::BottomToolBarArea:
0
1063 default:
never executed: default:
0
1064 break;
never executed: break;
0
1065 }-
1066-
1067 return QInternal::DockCount;
never executed: return QInternal::DockCount;
0
1068}-
1069-
1070static Qt::ToolBarArea toToolBarArea(QInternal::DockPosition pos)-
1071{-
1072 switch (pos) {-
1073 case QInternal::LeftDock: return Qt::LeftToolBarArea;
never executed: return Qt::LeftToolBarArea;
never executed: case QInternal::LeftDock:
0
1074 case QInternal::RightDock: return Qt::RightToolBarArea;
never executed: return Qt::RightToolBarArea;
never executed: case QInternal::RightDock:
0
1075 case QInternal::TopDock: return Qt::TopToolBarArea;
never executed: return Qt::TopToolBarArea;
never executed: case QInternal::TopDock:
0
1076 case QInternal::BottomDock: return Qt::BottomToolBarArea;
never executed: return Qt::BottomToolBarArea;
never executed: case QInternal::BottomDock:
0
1077 default: break;
never executed: break;
never executed: default:
0
1078 }-
1079 return Qt::NoToolBarArea;
never executed: return Qt::NoToolBarArea;
0
1080}-
1081-
1082static inline Qt::ToolBarArea toToolBarArea(int pos)-
1083{-
1084 return toToolBarArea(static_cast<QInternal::DockPosition>(pos));
never executed: return toToolBarArea(static_cast<QInternal::DockPosition>(pos));
0
1085}-
1086-
1087void QMainWindowLayout::addToolBarBreak(Qt::ToolBarArea area)-
1088{-
1089 validateToolBarArea(area);-
1090-
1091 layoutState.toolBarAreaLayout.addToolBarBreak(toDockPos(area));-
1092 if (savedState.isValid())
savedState.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1093 savedState.toolBarAreaLayout.addToolBarBreak(toDockPos(area));
never executed: savedState.toolBarAreaLayout.addToolBarBreak(toDockPos(area));
0
1094-
1095 invalidate();-
1096}
never executed: end of block
0
1097-
1098void QMainWindowLayout::insertToolBarBreak(QToolBar *before)-
1099{-
1100 layoutState.toolBarAreaLayout.insertToolBarBreak(before);-
1101 if (savedState.isValid())
savedState.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1102 savedState.toolBarAreaLayout.insertToolBarBreak(before);
never executed: savedState.toolBarAreaLayout.insertToolBarBreak(before);
0
1103 invalidate();-
1104}
never executed: end of block
0
1105-
1106void QMainWindowLayout::removeToolBarBreak(QToolBar *before)-
1107{-
1108 layoutState.toolBarAreaLayout.removeToolBarBreak(before);-
1109 if (savedState.isValid())
savedState.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1110 savedState.toolBarAreaLayout.removeToolBarBreak(before);
never executed: savedState.toolBarAreaLayout.removeToolBarBreak(before);
0
1111 invalidate();-
1112}
never executed: end of block
0
1113-
1114void QMainWindowLayout::moveToolBar(QToolBar *toolbar, int pos)-
1115{-
1116 layoutState.toolBarAreaLayout.moveToolBar(toolbar, pos);-
1117 if (savedState.isValid())
savedState.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1118 savedState.toolBarAreaLayout.moveToolBar(toolbar, pos);
never executed: savedState.toolBarAreaLayout.moveToolBar(toolbar, pos);
0
1119 invalidate();-
1120}
never executed: end of block
0
1121-
1122/* Removes the toolbar from the mainwindow so that it can be added again. Does not-
1123 explicitly hide the toolbar. */-
1124void QMainWindowLayout::removeToolBar(QToolBar *toolbar)-
1125{-
1126 if (toolbar) {
toolbarDescription
TRUEnever evaluated
FALSEnever evaluated
0
1127 QObject::disconnect(parentWidget(), SIGNAL(iconSizeChanged(QSize)),-
1128 toolbar, SLOT(_q_updateIconSize(QSize)));-
1129 QObject::disconnect(parentWidget(), SIGNAL(toolButtonStyleChanged(Qt::ToolButtonStyle)),-
1130 toolbar, SLOT(_q_updateToolButtonStyle(Qt::ToolButtonStyle)));-
1131-
1132#ifdef Q_DEAD_CODE_FROM_QT4_MAC-
1133 if (usesHIToolBar(toolbar)) {-
1134 removeFromMacToolbar(toolbar);-
1135 } else-
1136#endif // Q_DEAD_CODE_FROM_QT4_MAC-
1137 {-
1138 removeWidget(toolbar);-
1139 }-
1140 }
never executed: end of block
0
1141}
never executed: end of block
0
1142-
1143/*!-
1144 Adds \a toolbar to \a area, continuing the current line.-
1145*/-
1146void QMainWindowLayout::addToolBar(Qt::ToolBarArea area,-
1147 QToolBar *toolbar,-
1148 bool)-
1149{-
1150 validateToolBarArea(area);-
1151#ifdef Q_DEAD_CODE_FROM_QT4_MAC-
1152 if ((area == Qt::TopToolBarArea)-
1153 && layoutState.mainWindow->unifiedTitleAndToolBarOnMac()) {-
1154 insertIntoMacToolbar(0, toolbar);-
1155 } else-
1156#endif-
1157 {-
1158 //let's add the toolbar to the layout-
1159 addChildWidget(toolbar);-
1160 QLayoutItem * item = layoutState.toolBarAreaLayout.addToolBar(toDockPos(area), toolbar);-
1161 if (savedState.isValid() && item) {
savedState.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
itemDescription
TRUEnever evaluated
FALSEnever evaluated
0
1162 // copy the toolbar also in the saved state-
1163 savedState.toolBarAreaLayout.insertItem(toDockPos(area), item);-
1164 }
never executed: end of block
0
1165 invalidate();-
1166-
1167 //this ensures that the toolbar has the right window flags (not floating any more)-
1168 toolbar->d_func()->updateWindowFlags(false /*floating*/);-
1169 }-
1170}
never executed: end of block
0
1171-
1172/*!-
1173 Adds \a toolbar before \a before-
1174*/-
1175void QMainWindowLayout::insertToolBar(QToolBar *before, QToolBar *toolbar)-
1176{-
1177#ifdef Q_DEAD_CODE_FROM_QT4_MAC-
1178 if (usesHIToolBar(before)) {-
1179 insertIntoMacToolbar(before, toolbar);-
1180 } else-
1181#endif // Q_DEAD_CODE_FROM_QT4_MAC-
1182 {-
1183 addChildWidget(toolbar);-
1184 QLayoutItem * item = layoutState.toolBarAreaLayout.insertToolBar(before, toolbar);-
1185 if (savedState.isValid() && item) {
savedState.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
itemDescription
TRUEnever evaluated
FALSEnever evaluated
0
1186 // copy the toolbar also in the saved state-
1187 savedState.toolBarAreaLayout.insertItem(before, item);-
1188 }
never executed: end of block
0
1189 if (!currentGapPos.isEmpty() && currentGapPos.constFirst() == 0) {
!currentGapPos.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
currentGapPos....stFirst() == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1190 currentGapPos = layoutState.toolBarAreaLayout.currentGapIndex();-
1191 if (!currentGapPos.isEmpty()) {
!currentGapPos.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1192 currentGapPos.prepend(0);-
1193 currentGapRect = layoutState.itemRect(currentGapPos);-
1194 }
never executed: end of block
0
1195 }
never executed: end of block
0
1196 invalidate();-
1197 }-
1198}
never executed: end of block
0
1199-
1200Qt::ToolBarArea QMainWindowLayout::toolBarArea(QToolBar *toolbar) const-
1201{-
1202 QInternal::DockPosition pos = layoutState.toolBarAreaLayout.findToolBar(toolbar);-
1203 switch (pos) {-
1204 case QInternal::LeftDock: return Qt::LeftToolBarArea;
never executed: return Qt::LeftToolBarArea;
never executed: case QInternal::LeftDock:
0
1205 case QInternal::RightDock: return Qt::RightToolBarArea;
never executed: return Qt::RightToolBarArea;
never executed: case QInternal::RightDock:
0
1206 case QInternal::TopDock: return Qt::TopToolBarArea;
never executed: return Qt::TopToolBarArea;
never executed: case QInternal::TopDock:
0
1207 case QInternal::BottomDock: return Qt::BottomToolBarArea;
never executed: return Qt::BottomToolBarArea;
never executed: case QInternal::BottomDock:
0
1208 default: break;
never executed: break;
never executed: default:
0
1209 }-
1210#ifdef Q_DEAD_CODE_FROM_QT4_MAC-
1211 if (pos == QInternal::DockCount) {-
1212 if (qtoolbarsInUnifiedToolbarList.contains(toolbar))-
1213 return Qt::TopToolBarArea;-
1214 }-
1215#endif-
1216 return Qt::NoToolBarArea;
never executed: return Qt::NoToolBarArea;
0
1217}-
1218-
1219bool QMainWindowLayout::toolBarBreak(QToolBar *toolBar) const-
1220{-
1221 return layoutState.toolBarAreaLayout.toolBarBreak(toolBar);
never executed: return layoutState.toolBarAreaLayout.toolBarBreak(toolBar);
0
1222}-
1223-
1224void QMainWindowLayout::getStyleOptionInfo(QStyleOptionToolBar *option, QToolBar *toolBar) const-
1225{-
1226 option->toolBarArea = toolBarArea(toolBar);-
1227 layoutState.toolBarAreaLayout.getStyleOptionInfo(option, toolBar);-
1228}
never executed: end of block
0
1229-
1230void QMainWindowLayout::toggleToolBarsVisible()-
1231{-
1232 bool updateNonUnifiedParts = true;-
1233#ifdef Q_DEAD_CODE_FROM_QT4_MAC-
1234 if (layoutState.mainWindow->unifiedTitleAndToolBarOnMac()) {-
1235 // If we hit this case, someone has pressed the "toolbar button" which will-
1236 // toggle the unified toolbar visibility, because that's what the user wants.-
1237 // We might be in a situation where someone has hidden all the toolbars-
1238 // beforehand (maybe in construction), but now they've hit this button and-
1239 // and are expecting the items to show. What do we do?-
1240 // 1) Check the visibility of all the toolbars, if one is visible, do nothing, this-
1241 // preserves what people would expect (these toolbars were visible when I clicked last time).-
1242 // 2) If NONE are visible, then show them all. Again, this preserves the user expectation-
1243 // of, "I want to see the toolbars." The user may get more toolbars than expected, but this-
1244 // is better seeing nothing.-
1245 // Don't worry about any of this if we are going invisible. This does mean we may get-
1246 // into issues when switching into and out of fullscreen mode, but this is probably minor.-
1247 // If we ever need to do hiding, that would have to be taken care of after the unified toolbar-
1248 // has finished hiding.-
1249 // People can of course handle the QEvent::ToolBarChange event themselves and do-
1250 // WHATEVER they want if they don't like what we are doing (though the unified toolbar-
1251 // will fire regardless).-
1252-
1253 // Check if we REALLY need to update the geometry below. If we only have items in the-
1254 // unified toolbar, all the docks will be empty, so there's very little point-
1255 // in doing the geometry as Apple will do it (we also avoid flicker in Cocoa as well).-
1256 // FWIW, layoutState.toolBarAreaLayout.visible and the state of the unified toolbar-
1257 // visibility can get out of sync. I really don't think it's a big issue. It is kept-
1258 // to a minimum because we only change the visibility if we absolutely must.-
1259 // update the "non unified parts."-
1260 updateNonUnifiedParts = !layoutState.toolBarAreaLayout.isEmpty();-
1261-
1262 // We get this function before the unified toolbar does its thing.-
1263 // So, the value will be opposite of what we expect.-
1264 bool goingVisible = !macWindowToolbarIsVisible(qt_mac_window_for(layoutState.mainWindow));-
1265 if (goingVisible) {-
1266 const int ToolBarCount = qtoolbarsInUnifiedToolbarList.size();-
1267 bool needAllVisible = true;-
1268 for (int i = 0; i < ToolBarCount; ++i) {-
1269 if (!qtoolbarsInUnifiedToolbarList.at(i)->isHidden()) {-
1270 needAllVisible = false;-
1271 break;-
1272 }-
1273 }-
1274 if (needAllVisible) {-
1275 QBoolBlocker blocker(blockVisiblityCheck); // Disable the visibilty check because-
1276 // the toggle has already happened.-
1277 for (int i = 0; i < ToolBarCount; ++i)-
1278 qtoolbarsInUnifiedToolbarList.at(i)->setVisible(true);-
1279 }-
1280 }-
1281 if (!updateNonUnifiedParts)-
1282 layoutState.toolBarAreaLayout.visible = goingVisible;-
1283 }-
1284#endif-
1285 if (updateNonUnifiedParts) {
updateNonUnifiedPartsDescription
TRUEnever evaluated
FALSEnever evaluated
0
1286 layoutState.toolBarAreaLayout.visible = !layoutState.toolBarAreaLayout.visible;-
1287 if (!layoutState.mainWindow->isMaximized()) {
!layoutState.m...>isMaximized()Description
TRUEnever evaluated
FALSEnever evaluated
0
1288 QPoint topLeft = parentWidget()->geometry().topLeft();-
1289 QRect r = parentWidget()->geometry();-
1290 r = layoutState.toolBarAreaLayout.rectHint(r);-
1291 r.moveTo(topLeft);-
1292 parentWidget()->setGeometry(r);-
1293 } else {
never executed: end of block
0
1294 update();-
1295 }
never executed: end of block
0
1296 }-
1297}
never executed: end of block
0
1298-
1299#endif // QT_NO_TOOLBAR-
1300-
1301/******************************************************************************-
1302** QMainWindowLayoutState - dock areas-
1303*/-
1304-
1305#ifndef QT_NO_DOCKWIDGET-
1306-
1307static QInternal::DockPosition toDockPos(Qt::DockWidgetArea area)-
1308{-
1309 switch (area) {-
1310 case Qt::LeftDockWidgetArea: return QInternal::LeftDock;
never executed: return QInternal::LeftDock;
never executed: case Qt::LeftDockWidgetArea:
0
1311 case Qt::RightDockWidgetArea: return QInternal::RightDock;
never executed: return QInternal::RightDock;
never executed: case Qt::RightDockWidgetArea:
0
1312 case Qt::TopDockWidgetArea: return QInternal::TopDock;
never executed: return QInternal::TopDock;
never executed: case Qt::TopDockWidgetArea:
0
1313 case Qt::BottomDockWidgetArea: return QInternal::BottomDock;
never executed: return QInternal::BottomDock;
never executed: case Qt::BottomDockWidgetArea:
0
1314 default:
never executed: default:
0
1315 break;
never executed: break;
0
1316 }-
1317-
1318 return QInternal::DockCount;
never executed: return QInternal::DockCount;
0
1319}-
1320-
1321static Qt::DockWidgetArea toDockWidgetArea(QInternal::DockPosition pos)-
1322{-
1323 switch (pos) {-
1324 case QInternal::LeftDock : return Qt::LeftDockWidgetArea;
never executed: return Qt::LeftDockWidgetArea;
never executed: case QInternal::LeftDock :
0
1325 case QInternal::RightDock : return Qt::RightDockWidgetArea;
never executed: return Qt::RightDockWidgetArea;
never executed: case QInternal::RightDock :
0
1326 case QInternal::TopDock : return Qt::TopDockWidgetArea;
never executed: return Qt::TopDockWidgetArea;
never executed: case QInternal::TopDock :
0
1327 case QInternal::BottomDock : return Qt::BottomDockWidgetArea;
never executed: return Qt::BottomDockWidgetArea;
never executed: case QInternal::BottomDock :
0
1328 default:
never executed: default:
0
1329 break;
never executed: break;
0
1330 }-
1331-
1332 return Qt::NoDockWidgetArea;
never executed: return Qt::NoDockWidgetArea;
0
1333}-
1334-
1335inline static Qt::DockWidgetArea toDockWidgetArea(int pos)-
1336{-
1337 return toDockWidgetArea(static_cast<QInternal::DockPosition>(pos));
never executed: return toDockWidgetArea(static_cast<QInternal::DockPosition>(pos));
0
1338}-
1339-
1340void QMainWindowLayout::setCorner(Qt::Corner corner, Qt::DockWidgetArea area)-
1341{-
1342 if (layoutState.dockAreaLayout.corners[corner] == area)
layoutState.do...orner] == areaDescription
TRUEnever evaluated
FALSEnever evaluated
0
1343 return;
never executed: return;
0
1344 layoutState.dockAreaLayout.corners[corner] = area;-
1345 if (savedState.isValid())
savedState.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1346 savedState.dockAreaLayout.corners[corner] = area;
never executed: savedState.dockAreaLayout.corners[corner] = area;
0
1347 invalidate();-
1348}
never executed: end of block
0
1349-
1350Qt::DockWidgetArea QMainWindowLayout::corner(Qt::Corner corner) const-
1351{-
1352 return layoutState.dockAreaLayout.corners[corner];
never executed: return layoutState.dockAreaLayout.corners[corner];
0
1353}-
1354-
1355void QMainWindowLayout::addDockWidget(Qt::DockWidgetArea area,-
1356 QDockWidget *dockwidget,-
1357 Qt::Orientation orientation)-
1358{-
1359 addChildWidget(dockwidget);-
1360-
1361 // If we are currently moving a separator, then we need to abort the move, since each-
1362 // time we move the mouse layoutState is replaced by savedState modified by the move.-
1363 if (!movingSeparator.isEmpty())
!movingSeparator.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1364 endSeparatorMove(movingSeparatorPos);
never executed: endSeparatorMove(movingSeparatorPos);
0
1365-
1366 layoutState.dockAreaLayout.addDockWidget(toDockPos(area), dockwidget, orientation);-
1367 emit dockwidget->dockLocationChanged(area);-
1368 invalidate();-
1369}
never executed: end of block
0
1370-
1371void QMainWindowLayout::tabifyDockWidget(QDockWidget *first, QDockWidget *second)-
1372{-
1373 addChildWidget(second);-
1374 layoutState.dockAreaLayout.tabifyDockWidget(first, second);-
1375 emit second->dockLocationChanged(dockWidgetArea(first));-
1376 invalidate();-
1377}
never executed: end of block
0
1378-
1379bool QMainWindowLayout::restoreDockWidget(QDockWidget *dockwidget)-
1380{-
1381 addChildWidget(dockwidget);-
1382 if (!layoutState.dockAreaLayout.restoreDockWidget(dockwidget))
!layoutState.d...et(dockwidget)Description
TRUEnever evaluated
FALSEnever evaluated
0
1383 return false;
never executed: return false;
0
1384 emit dockwidget->dockLocationChanged(dockWidgetArea(dockwidget));-
1385 invalidate();-
1386 return true;
never executed: return true;
0
1387}-
1388-
1389#ifndef QT_NO_TABBAR-
1390bool QMainWindowLayout::documentMode() const-
1391{-
1392 return _documentMode;
never executed: return _documentMode;
0
1393}-
1394-
1395void QMainWindowLayout::setDocumentMode(bool enabled)-
1396{-
1397 if (_documentMode == enabled)
_documentMode == enabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
1398 return;
never executed: return;
0
1399-
1400 _documentMode = enabled;-
1401-
1402 // Update the document mode for all tab bars-
1403 foreach (QTabBar *bar, usedTabBars)-
1404 bar->setDocumentMode(_documentMode);
never executed: bar->setDocumentMode(_documentMode);
0
1405 foreach (QTabBar *bar, unusedTabBars)-
1406 bar->setDocumentMode(_documentMode);
never executed: bar->setDocumentMode(_documentMode);
0
1407}
never executed: end of block
0
1408#endif // QT_NO_TABBAR-
1409-
1410void QMainWindowLayout::setVerticalTabsEnabled(bool enabled)-
1411{-
1412#ifdef QT_NO_TABBAR-
1413 Q_UNUSED(enabled);-
1414#else-
1415 if (verticalTabsEnabled == enabled)
verticalTabsEnabled == enabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
1416 return;
never executed: return;
0
1417-
1418 verticalTabsEnabled = enabled;-
1419-
1420 updateTabBarShapes();-
1421#endif // QT_NO_TABBAR-
1422}
never executed: end of block
0
1423-
1424#ifndef QT_NO_TABWIDGET-
1425QTabWidget::TabShape QMainWindowLayout::tabShape() const-
1426{-
1427 return _tabShape;
never executed: return _tabShape;
0
1428}-
1429-
1430void QMainWindowLayout::setTabShape(QTabWidget::TabShape tabShape)-
1431{-
1432 if (_tabShape == tabShape)
_tabShape == tabShapeDescription
TRUEnever evaluated
FALSEnever evaluated
0
1433 return;
never executed: return;
0
1434-
1435 _tabShape = tabShape;-
1436-
1437 updateTabBarShapes();-
1438}
never executed: end of block
0
1439-
1440QTabWidget::TabPosition QMainWindowLayout::tabPosition(Qt::DockWidgetArea area) const-
1441{-
1442 return tabPositions[toDockPos(area)];
never executed: return tabPositions[toDockPos(area)];
0
1443}-
1444-
1445void QMainWindowLayout::setTabPosition(Qt::DockWidgetAreas areas, QTabWidget::TabPosition tabPosition)-
1446{-
1447 const Qt::DockWidgetArea dockWidgetAreas[] = {-
1448 Qt::TopDockWidgetArea,-
1449 Qt::LeftDockWidgetArea,-
1450 Qt::BottomDockWidgetArea,-
1451 Qt::RightDockWidgetArea-
1452 };-
1453 const QInternal::DockPosition dockPositions[] = {-
1454 QInternal::TopDock,-
1455 QInternal::LeftDock,-
1456 QInternal::BottomDock,-
1457 QInternal::RightDock-
1458 };-
1459-
1460 for (int i = 0; i < QInternal::DockCount; ++i)
i < QInternal::DockCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
1461 if (areas & dockWidgetAreas[i])
areas & dockWidgetAreas[i]Description
TRUEnever evaluated
FALSEnever evaluated
0
1462 tabPositions[dockPositions[i]] = tabPosition;
never executed: tabPositions[dockPositions[i]] = tabPosition;
0
1463-
1464 updateTabBarShapes();-
1465}
never executed: end of block
0
1466-
1467static inline QTabBar::Shape tabBarShapeFrom(QTabWidget::TabShape shape, QTabWidget::TabPosition position)-
1468{-
1469 const bool rounded = (shape == QTabWidget::Rounded);-
1470 if (position == QTabWidget::North)
position == QTabWidget::NorthDescription
TRUEnever evaluated
FALSEnever evaluated
0
1471 return rounded ? QTabBar::RoundedNorth : QTabBar::TriangularNorth;
never executed: return rounded ? QTabBar::RoundedNorth : QTabBar::TriangularNorth;
0
1472 if (position == QTabWidget::South)
position == QTabWidget::SouthDescription
TRUEnever evaluated
FALSEnever evaluated
0
1473 return rounded ? QTabBar::RoundedSouth : QTabBar::TriangularSouth;
never executed: return rounded ? QTabBar::RoundedSouth : QTabBar::TriangularSouth;
0
1474 if (position == QTabWidget::East)
position == QTabWidget::EastDescription
TRUEnever evaluated
FALSEnever evaluated
0
1475 return rounded ? QTabBar::RoundedEast : QTabBar::TriangularEast;
never executed: return rounded ? QTabBar::RoundedEast : QTabBar::TriangularEast;
0
1476 if (position == QTabWidget::West)
position == QTabWidget::WestDescription
TRUEnever evaluated
FALSEnever evaluated
0
1477 return rounded ? QTabBar::RoundedWest : QTabBar::TriangularWest;
never executed: return rounded ? QTabBar::RoundedWest : QTabBar::TriangularWest;
0
1478 return QTabBar::RoundedNorth;
never executed: return QTabBar::RoundedNorth;
0
1479}-
1480#endif // QT_NO_TABWIDGET-
1481-
1482#ifndef QT_NO_TABBAR-
1483void QMainWindowLayout::updateTabBarShapes()-
1484{-
1485#ifndef QT_NO_TABWIDGET-
1486 const QTabWidget::TabPosition vertical[] = {-
1487 QTabWidget::West,-
1488 QTabWidget::East,-
1489 QTabWidget::North,-
1490 QTabWidget::South-
1491 };-
1492#else-
1493 const QTabBar::Shape vertical[] = {-
1494 QTabBar::RoundedWest,-
1495 QTabBar::RoundedEast,-
1496 QTabBar::RoundedNorth,-
1497 QTabBar::RoundedSouth-
1498 };-
1499#endif-
1500-
1501 QDockAreaLayout &layout = layoutState.dockAreaLayout;-
1502-
1503 for (int i = 0; i < QInternal::DockCount; ++i) {
i < QInternal::DockCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
1504#ifndef QT_NO_TABWIDGET-
1505 QTabWidget::TabPosition pos = verticalTabsEnabled ? vertical[i] : tabPositions[i];
verticalTabsEnabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
1506 QTabBar::Shape shape = tabBarShapeFrom(_tabShape, pos);-
1507#else-
1508 QTabBar::Shape shape = verticalTabsEnabled ? vertical[i] : QTabBar::RoundedSouth;-
1509#endif-
1510 layout.docks[i].setTabBarShape(shape);-
1511 }
never executed: end of block
0
1512}
never executed: end of block
0
1513#endif // QT_NO_TABBAR-
1514-
1515void QMainWindowLayout::splitDockWidget(QDockWidget *after,-
1516 QDockWidget *dockwidget,-
1517 Qt::Orientation orientation)-
1518{-
1519 addChildWidget(dockwidget);-
1520 layoutState.dockAreaLayout.splitDockWidget(after, dockwidget, orientation);-
1521 emit dockwidget->dockLocationChanged(dockWidgetArea(after));-
1522 invalidate();-
1523}
never executed: end of block
0
1524-
1525Qt::DockWidgetArea QMainWindowLayout::dockWidgetArea(QWidget *widget) const-
1526{-
1527 const QList<int> pathToWidget = layoutState.dockAreaLayout.indexOf(widget);-
1528 if (pathToWidget.isEmpty())
pathToWidget.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1529 return Qt::NoDockWidgetArea;
never executed: return Qt::NoDockWidgetArea;
0
1530 return toDockWidgetArea(pathToWidget.first());
never executed: return toDockWidgetArea(pathToWidget.first());
0
1531}-
1532-
1533void QMainWindowLayout::keepSize(QDockWidget *w)-
1534{-
1535 layoutState.dockAreaLayout.keepSize(w);-
1536}
never executed: end of block
0
1537-
1538#ifndef QT_NO_TABBAR-
1539-
1540// Handle custom tooltip, and allow to drag tabs away.-
1541class QMainWindowTabBar : public QTabBar-
1542{-
1543 QMainWindow *mainWindow;-
1544 QDockWidget *draggingDock; // Currently dragging (detached) dock widget-
1545public:-
1546 QMainWindowTabBar(QMainWindow *parent);-
1547protected:-
1548 bool event(QEvent *e) Q_DECL_OVERRIDE;-
1549 void mouseReleaseEvent(QMouseEvent*) Q_DECL_OVERRIDE;-
1550 void mouseMoveEvent(QMouseEvent*) Q_DECL_OVERRIDE;-
1551-
1552};-
1553-
1554QMainWindowTabBar::QMainWindowTabBar(QMainWindow *parent)-
1555 : QTabBar(parent), mainWindow(parent), draggingDock(0)-
1556{-
1557 setExpanding(false);-
1558}
never executed: end of block
0
1559-
1560void QMainWindowTabBar::mouseMoveEvent(QMouseEvent *e)-
1561{-
1562 // The QTabBar handles the moving (reordering) of tabs.-
1563 // When QTabBarPrivate::dragInProgress is true, and that the mouse is outside of a region-
1564 // around the QTabBar, we will consider the user wants to drag that QDockWidget away from this-
1565 // tab area.-
1566-
1567 QTabBarPrivate *d = static_cast<QTabBarPrivate*>(d_ptr.data());-
1568 if (!draggingDock && (mainWindow->dockOptions() & QMainWindow::GroupedDragging)) {
!draggingDockDescription
TRUEnever evaluated
FALSEnever evaluated
(mainWindow->d...oupedDragging)Description
TRUEnever evaluated
FALSEnever evaluated
0
1569 int offset = QApplication::startDragDistance() + 1;-
1570 offset *= 3;-
1571 QRect r = rect().adjusted(-offset, -offset, offset, offset);-
1572 if (d->dragInProgress && !r.contains(e->pos()) && d->validIndex(d->pressedIndex)) {
d->dragInProgressDescription
TRUEnever evaluated
FALSEnever evaluated
!r.contains(e->pos())Description
TRUEnever evaluated
FALSEnever evaluated
d->validIndex(d->pressedIndex)Description
TRUEnever evaluated
FALSEnever evaluated
0
1573 QMainWindowLayout* mlayout = qt_mainwindow_layout(mainWindow);-
1574 QDockAreaLayoutInfo *info = mlayout->dockInfo(this);-
1575 Q_ASSERT(info);-
1576 int idx = info->tabIndexToListIndex(d->pressedIndex);-
1577 const QDockAreaLayoutItem &item = info->item_list.at(idx);-
1578 if (item.widgetItem
item.widgetItemDescription
TRUEnever evaluated
FALSEnever evaluated
0
1579 && (draggingDock = qobject_cast<QDockWidget *>(item.widgetItem->widget()))) {
(draggingDock ...em->widget()))Description
TRUEnever evaluated
FALSEnever evaluated
0
1580 // We should drag this QDockWidget away by unpluging it.-
1581 // First cancel the QTabBar's internal move-
1582 d->moveTabFinished(d->pressedIndex);-
1583 d->pressedIndex = -1;-
1584 if (d->movingTab)
d->movingTabDescription
TRUEnever evaluated
FALSEnever evaluated
0
1585 d->movingTab->setVisible(false);
never executed: d->movingTab->setVisible(false);
0
1586 d->dragStartPosition = QPoint();-
1587-
1588 // Then starts the drag using QDockWidgetPrivate's API-
1589 QDockWidgetPrivate *dockPriv = static_cast<QDockWidgetPrivate *>(QObjectPrivate::get(draggingDock));-
1590 QDockWidgetLayout *dwlayout = static_cast<QDockWidgetLayout *>(draggingDock->layout());-
1591 dockPriv->initDrag(dwlayout->titleArea().center(), true);-
1592 dockPriv->startDrag(false);-
1593 if (dockPriv->state)
dockPriv->stateDescription
TRUEnever evaluated
FALSEnever evaluated
0
1594 dockPriv->state->ctrlDrag = e->modifiers() & Qt::ControlModifier;
never executed: dockPriv->state->ctrlDrag = e->modifiers() & Qt::ControlModifier;
0
1595 }
never executed: end of block
0
1596 }
never executed: end of block
0
1597 }
never executed: end of block
0
1598-
1599 if (draggingDock) {
draggingDockDescription
TRUEnever evaluated
FALSEnever evaluated
0
1600 QDockWidgetPrivate *dockPriv = static_cast<QDockWidgetPrivate *>(QObjectPrivate::get(draggingDock));-
1601 if (dockPriv->state && dockPriv->state->dragging) {
dockPriv->stateDescription
TRUEnever evaluated
FALSEnever evaluated
dockPriv->state->draggingDescription
TRUEnever evaluated
FALSEnever evaluated
0
1602 QPoint pos = e->globalPos() - dockPriv->state->pressPos;-
1603 draggingDock->move(pos);-
1604 // move will call QMainWindowLayout::hover-
1605 }
never executed: end of block
0
1606 }
never executed: end of block
0
1607 QTabBar::mouseMoveEvent(e);-
1608}
never executed: end of block
0
1609-
1610void QMainWindowTabBar::mouseReleaseEvent(QMouseEvent *e)-
1611{-
1612 if (draggingDock && e->button() == Qt::LeftButton) {
draggingDockDescription
TRUEnever evaluated
FALSEnever evaluated
e->button() == Qt::LeftButtonDescription
TRUEnever evaluated
FALSEnever evaluated
0
1613 QDockWidgetPrivate *dockPriv = static_cast<QDockWidgetPrivate *>(QObjectPrivate::get(draggingDock));-
1614 if (dockPriv->state && dockPriv->state->dragging) {
dockPriv->stateDescription
TRUEnever evaluated
FALSEnever evaluated
dockPriv->state->draggingDescription
TRUEnever evaluated
FALSEnever evaluated
0
1615 dockPriv->endDrag();-
1616 }
never executed: end of block
0
1617 draggingDock = 0;-
1618 }
never executed: end of block
0
1619 QTabBar::mouseReleaseEvent(e);-
1620}
never executed: end of block
0
1621-
1622bool QMainWindowTabBar::event(QEvent *e)-
1623{-
1624 // show the tooltip if tab is too small to fit label-
1625-
1626 if (e->type() != QEvent::ToolTip)
e->type() != QEvent::ToolTipDescription
TRUEnever evaluated
FALSEnever evaluated
0
1627 return QTabBar::event(e);
never executed: return QTabBar::event(e);
0
1628 QSize size = this->size();-
1629 QSize hint = sizeHint();-
1630 if (shape() == QTabBar::RoundedWest || shape() == QTabBar::RoundedEast) {
shape() == QTa...r::RoundedWestDescription
TRUEnever evaluated
FALSEnever evaluated
shape() == QTa...r::RoundedEastDescription
TRUEnever evaluated
FALSEnever evaluated
0
1631 size = size.transposed();-
1632 hint = hint.transposed();-
1633 }
never executed: end of block
0
1634 if (size.width() < hint.width())
size.width() < hint.width()Description
TRUEnever evaluated
FALSEnever evaluated
0
1635 return QTabBar::event(e);
never executed: return QTabBar::event(e);
0
1636 e->accept();-
1637 return true;
never executed: return true;
0
1638}-
1639-
1640QTabBar *QMainWindowLayout::getTabBar()-
1641{-
1642 QTabBar *result = 0;-
1643 if (!unusedTabBars.isEmpty()) {
!unusedTabBars.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1644 result = unusedTabBars.takeLast();-
1645 } else {
never executed: end of block
0
1646 result = new QMainWindowTabBar(static_cast<QMainWindow *>(parentWidget()));-
1647 result->setDrawBase(true);-
1648 result->setElideMode(Qt::ElideRight);-
1649 result->setDocumentMode(_documentMode);-
1650 result->setMovable(true);-
1651 connect(result, SIGNAL(currentChanged(int)), this, SLOT(tabChanged()));-
1652 connect(result, &QTabBar::tabMoved, this, &QMainWindowLayout::tabMoved);-
1653 }
never executed: end of block
0
1654-
1655 usedTabBars.insert(result);-
1656 return result;
never executed: return result;
0
1657}-
1658-
1659// Allocates a new separator widget if needed-
1660QWidget *QMainWindowLayout::getSeparatorWidget()-
1661{-
1662 QWidget *result = 0;-
1663 if (!unusedSeparatorWidgets.isEmpty()) {
!unusedSeparat...gets.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1664 result = unusedSeparatorWidgets.takeLast();-
1665 } else {
never executed: end of block
0
1666 result = new QWidget(parentWidget());-
1667 result->setAttribute(Qt::WA_MouseNoMask, true);-
1668 result->setAutoFillBackground(false);-
1669 result->setObjectName(QLatin1String("qt_qmainwindow_extended_splitter"));-
1670 }
never executed: end of block
0
1671 usedSeparatorWidgets.insert(result);-
1672 return result;
never executed: return result;
0
1673}-
1674-
1675/*! \internal-
1676 Returns a pointer QDockAreaLayoutInfo which contains this \a widget directly-
1677 (in its internal list)-
1678 */-
1679QDockAreaLayoutInfo *QMainWindowLayout::dockInfo(QWidget *widget)-
1680{-
1681 QDockAreaLayoutInfo *info = layoutState.dockAreaLayout.info(widget);-
1682 if (info)
infoDescription
TRUEnever evaluated
FALSEnever evaluated
0
1683 return info;
never executed: return info;
0
1684 foreach (QDockWidgetGroupWindow *dwgw,-
1685 parent()->findChildren<QDockWidgetGroupWindow*>(QString(), Qt::FindDirectChildrenOnly)) {-
1686 info = dwgw->layoutInfo()->info(widget);-
1687 if (info)
infoDescription
TRUEnever evaluated
FALSEnever evaluated
0
1688 return info;
never executed: return info;
0
1689 }
never executed: end of block
0
1690 return 0;
never executed: return 0;
0
1691}-
1692-
1693void QMainWindowLayout::tabChanged()-
1694{-
1695 QTabBar *tb = qobject_cast<QTabBar*>(sender());-
1696 if (tb == 0)
tb == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1697 return;
never executed: return;
0
1698 QDockAreaLayoutInfo *info = dockInfo(tb);-
1699 if (info == 0)
info == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1700 return;
never executed: return;
0
1701 info->apply(false);-
1702-
1703 if (QWidget *w = centralWidget())
QWidget *w = centralWidget()Description
TRUEnever evaluated
FALSEnever evaluated
0
1704 w->raise();
never executed: w->raise();
0
1705}
never executed: end of block
0
1706-
1707void QMainWindowLayout::tabMoved(int from, int to)-
1708{-
1709 QTabBar *tb = qobject_cast<QTabBar*>(sender());-
1710 Q_ASSERT(tb);-
1711 QDockAreaLayoutInfo *info = dockInfo(tb);-
1712 Q_ASSERT(info);-
1713-
1714 info->moveTab(from, to);-
1715}
never executed: end of block
0
1716#endif // QT_NO_TABBAR-
1717-
1718bool QMainWindowLayout::startSeparatorMove(const QPoint &pos)-
1719{-
1720 movingSeparator = layoutState.dockAreaLayout.findSeparator(pos);-
1721-
1722 if (movingSeparator.isEmpty())
movingSeparator.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1723 return false;
never executed: return false;
0
1724-
1725 layoutState.dockAreaLayout.fallbackToSizeHints = false;-
1726-
1727 savedState = layoutState;-
1728 movingSeparatorPos = movingSeparatorOrigin = pos;-
1729-
1730 return true;
never executed: return true;
0
1731}-
1732-
1733bool QMainWindowLayout::separatorMove(const QPoint &pos)-
1734{-
1735 if (movingSeparator.isEmpty())
movingSeparator.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1736 return false;
never executed: return false;
0
1737 movingSeparatorPos = pos;-
1738 separatorMoveTimer.start(0, this);-
1739 return true;
never executed: return true;
0
1740}-
1741-
1742bool QMainWindowLayout::endSeparatorMove(const QPoint&)-
1743{-
1744 if (movingSeparator.isEmpty())
movingSeparator.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1745 return false;
never executed: return false;
0
1746 movingSeparator.clear();-
1747 savedState.clear();-
1748 return true;
never executed: return true;
0
1749}-
1750-
1751void QMainWindowLayout::raise(QDockWidget *widget)-
1752{-
1753 QDockAreaLayoutInfo *info = dockInfo(widget);-
1754 if (info == 0)
info == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1755 return;
never executed: return;
0
1756#ifndef QT_NO_TABBAR-
1757 if (!info->tabbed)
!info->tabbedDescription
TRUEnever evaluated
FALSEnever evaluated
0
1758 return;
never executed: return;
0
1759 info->setCurrentTab(widget);-
1760#endif-
1761}
never executed: end of block
0
1762-
1763#endif // QT_NO_DOCKWIDGET-
1764-
1765-
1766/******************************************************************************-
1767** QMainWindowLayoutState - layout interface-
1768*/-
1769-
1770int QMainWindowLayout::count() const-
1771{-
1772 qWarning("QMainWindowLayout::count: ?");-
1773 return 0; //#################################################
never executed: return 0;
0
1774}-
1775-
1776QLayoutItem *QMainWindowLayout::itemAt(int index) const-
1777{-
1778 int x = 0;-
1779-
1780 if (QLayoutItem *ret = layoutState.itemAt(index, &x))
QLayoutItem *r...mAt(index, &x)Description
TRUEnever evaluated
FALSEnever evaluated
0
1781 return ret;
never executed: return ret;
0
1782-
1783 if (statusbar && x++ == index)
statusbarDescription
TRUEnever evaluated
FALSEnever evaluated
x++ == indexDescription
TRUEnever evaluated
FALSEnever evaluated
0
1784 return statusbar;
never executed: return statusbar;
0
1785-
1786 return 0;
never executed: return 0;
0
1787}-
1788-
1789QLayoutItem *QMainWindowLayout::takeAt(int index)-
1790{-
1791 int x = 0;-
1792-
1793 if (QLayoutItem *ret = layoutState.takeAt(index, &x)) {
QLayoutItem *r...eAt(index, &x)Description
TRUEnever evaluated
FALSEnever evaluated
0
1794 // the widget might in fact have been destroyed by now-
1795 if (QWidget *w = ret->widget()) {
QWidget *w = ret->widget()Description
TRUEnever evaluated
FALSEnever evaluated
0
1796 widgetAnimator.abort(w);-
1797 if (w == pluggingWidget)
w == pluggingWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
1798 pluggingWidget = 0;
never executed: pluggingWidget = 0;
0
1799 }
never executed: end of block
0
1800-
1801 if (savedState.isValid() ) {
savedState.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1802 //we need to remove the item also from the saved state to prevent crash-
1803 savedState.remove(ret);-
1804 //Also, the item may be contained several times as a gap item.-
1805 layoutState.remove(ret);-
1806 }
never executed: end of block
0
1807-
1808#ifndef QT_NO_TOOLBAR-
1809 if (!currentGapPos.isEmpty() && currentGapPos.constFirst() == 0) {
!currentGapPos.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
currentGapPos....stFirst() == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1810 currentGapPos = layoutState.toolBarAreaLayout.currentGapIndex();-
1811 if (!currentGapPos.isEmpty()) {
!currentGapPos.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1812 currentGapPos.prepend(0);-
1813 currentGapRect = layoutState.itemRect(currentGapPos);-
1814 }
never executed: end of block
0
1815 }
never executed: end of block
0
1816#endif-
1817-
1818 return ret;
never executed: return ret;
0
1819 }-
1820-
1821 if (statusbar && x++ == index) {
statusbarDescription
TRUEnever evaluated
FALSEnever evaluated
x++ == indexDescription
TRUEnever evaluated
FALSEnever evaluated
0
1822 QLayoutItem *ret = statusbar;-
1823 statusbar = 0;-
1824 return ret;
never executed: return ret;
0
1825 }-
1826-
1827 return 0;
never executed: return 0;
0
1828}-
1829-
1830void QMainWindowLayout::setGeometry(const QRect &_r)-
1831{-
1832 if (savedState.isValid())
savedState.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1833 return;
never executed: return;
0
1834-
1835 QRect r = _r;-
1836-
1837 QLayout::setGeometry(r);-
1838-
1839 if (statusbar) {
statusbarDescription
TRUEnever evaluated
FALSEnever evaluated
0
1840 QRect sbr(QPoint(r.left(), 0),-
1841 QSize(r.width(), statusbar->heightForWidth(r.width()))-
1842 .expandedTo(statusbar->minimumSize()));-
1843 sbr.moveBottom(r.bottom());-
1844 QRect vr = QStyle::visualRect(parentWidget()->layoutDirection(), _r, sbr);-
1845 statusbar->setGeometry(vr);-
1846 r.setBottom(sbr.top() - 1);-
1847 }
never executed: end of block
0
1848-
1849 layoutState.rect = r;-
1850 layoutState.fitLayout();-
1851 applyState(layoutState, false);-
1852}
never executed: end of block
0
1853-
1854void QMainWindowLayout::addItem(QLayoutItem *)-
1855{
never executed: end of block
qWarning("QMainWindowLayout::addItem: Please use the public QMainWindow API instead"); }
never executed: end of block
0
1856-
1857QSize QMainWindowLayout::sizeHint() const-
1858{-
1859 if (!szHint.isValid()) {
!szHint.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1860 szHint = layoutState.sizeHint();-
1861 const QSize sbHint = statusbar ? statusbar->sizeHint() : QSize(0, 0);
statusbarDescription
TRUEnever evaluated
FALSEnever evaluated
0
1862 szHint = QSize(qMax(sbHint.width(), szHint.width()),-
1863 sbHint.height() + szHint.height());-
1864 }
never executed: end of block
0
1865 return szHint;
never executed: return szHint;
0
1866}-
1867-
1868QSize QMainWindowLayout::minimumSize() const-
1869{-
1870 if (!minSize.isValid()) {
!minSize.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1871 minSize = layoutState.minimumSize();-
1872 const QSize sbMin = statusbar ? statusbar->minimumSize() : QSize(0, 0);
statusbarDescription
TRUEnever evaluated
FALSEnever evaluated
0
1873 minSize = QSize(qMax(sbMin.width(), minSize.width()),-
1874 sbMin.height() + minSize.height());-
1875#ifdef Q_DEAD_CODE_FROM_QT4_MAC-
1876 const QSize storedSize = minSize;-
1877 int minWidth = 0;-
1878 foreach (QToolBar *toolbar, qtoolbarsInUnifiedToolbarList) {-
1879 minWidth += toolbar->sizeHint().width() + 20;-
1880 }-
1881 minSize = QSize(qMax(minWidth, storedSize.width()), storedSize.height());-
1882#endif-
1883 }
never executed: end of block
0
1884 return minSize;
never executed: return minSize;
0
1885}-
1886-
1887void QMainWindowLayout::invalidate()-
1888{-
1889 QLayout::invalidate();-
1890 minSize = szHint = QSize();-
1891}
never executed: end of block
0
1892-
1893/******************************************************************************-
1894** QMainWindowLayout - remaining stuff-
1895*/-
1896-
1897static void fixToolBarOrientation(QLayoutItem *item, int dockPos)-
1898{-
1899#ifndef QT_NO_TOOLBAR-
1900 QToolBar *toolBar = qobject_cast<QToolBar*>(item->widget());-
1901 if (toolBar == 0)
toolBar == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1902 return;
never executed: return;
0
1903-
1904 QRect oldGeo = toolBar->geometry();-
1905-
1906 QInternal::DockPosition pos-
1907 = static_cast<QInternal::DockPosition>(dockPos);-
1908 Qt::Orientation o = pos == QInternal::TopDock || pos == QInternal::BottomDock
pos == QInternal::TopDockDescription
TRUEnever evaluated
FALSEnever evaluated
pos == QInternal::BottomDockDescription
TRUEnever evaluated
FALSEnever evaluated
0
1909 ? Qt::Horizontal : Qt::Vertical;-
1910 if (o != toolBar->orientation())
o != toolBar->orientation()Description
TRUEnever evaluated
FALSEnever evaluated
0
1911 toolBar->setOrientation(o);
never executed: toolBar->setOrientation(o);
0
1912-
1913 QSize hint = toolBar->sizeHint().boundedTo(toolBar->maximumSize())-
1914 .expandedTo(toolBar->minimumSize());-
1915-
1916 if (toolBar->size() != hint) {
toolBar->size() != hintDescription
TRUEnever evaluated
FALSEnever evaluated
0
1917 QRect newGeo(oldGeo.topLeft(), hint);-
1918 if (toolBar->layoutDirection() == Qt::RightToLeft)
toolBar->layou...t::RightToLeftDescription
TRUEnever evaluated
FALSEnever evaluated
0
1919 newGeo.moveRight(oldGeo.right());
never executed: newGeo.moveRight(oldGeo.right());
0
1920 toolBar->setGeometry(newGeo);-
1921 }
never executed: end of block
0
1922-
1923#else-
1924 Q_UNUSED(item);-
1925 Q_UNUSED(dockPos);-
1926#endif-
1927}
never executed: end of block
0
1928-
1929void QMainWindowLayout::revert(QLayoutItem *widgetItem)-
1930{-
1931 if (!savedState.isValid())
!savedState.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1932 return;
never executed: return;
0
1933-
1934 QWidget *widget = widgetItem->widget();-
1935 layoutState = savedState;-
1936 currentGapPos = layoutState.indexOf(widget);-
1937 if (currentGapPos.isEmpty())
currentGapPos.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1938 return;
never executed: return;
0
1939 fixToolBarOrientation(widgetItem, currentGapPos.at(1));-
1940 layoutState.unplug(currentGapPos);-
1941 layoutState.fitLayout();-
1942 currentGapRect = layoutState.itemRect(currentGapPos);-
1943-
1944 plug(widgetItem);-
1945}
never executed: end of block
0
1946-
1947bool QMainWindowLayout::plug(QLayoutItem *widgetItem)-
1948{-
1949#ifndef QT_NO_DOCKWIDGET-
1950 if (currentHoveredFloat) {
currentHoveredFloatDescription
TRUEnever evaluated
FALSEnever evaluated
0
1951 QWidget *widget = widgetItem->widget();-
1952 QList<int> previousPath = layoutState.indexOf(widget);-
1953 if (!previousPath.isEmpty())
!previousPath.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1954 layoutState.remove(previousPath);
never executed: layoutState.remove(previousPath);
0
1955 // Let's remove the widget from any possible group window-
1956 foreach (QDockWidgetGroupWindow *dwgw,-
1957 parent()->findChildren<QDockWidgetGroupWindow*>(QString(), Qt::FindDirectChildrenOnly)) {-
1958 QList<int> path = dwgw->layoutInfo()->indexOf(widget);-
1959 if (!path.isEmpty())
!path.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1960 dwgw->layoutInfo()->remove(path);
never executed: dwgw->layoutInfo()->remove(path);
0
1961 }
never executed: end of block
0
1962 currentGapRect = QRect();-
1963-
1964 if (QDockWidget *dropTo = qobject_cast<QDockWidget*>(currentHoveredFloat)) {
QDockWidget *d...tHoveredFloat)Description
TRUEnever evaluated
FALSEnever evaluated
0
1965 //dropping to a normal widget, we mutate it in a QDockWidgetGroupWindow with two tabs-
1966 QDockWidgetGroupWindow *floatingTabs = createTabbedDockWindow();-
1967 floatingTabs->setGeometry(dropTo->geometry());-
1968 QDockAreaLayoutInfo *info = floatingTabs->layoutInfo();-
1969 *info = QDockAreaLayoutInfo(&layoutState.dockAreaLayout.sep, QInternal::LeftDock,-
1970 Qt::Horizontal, QTabBar::RoundedSouth,-
1971 static_cast<QMainWindow*>(parentWidget()));-
1972 info->tabbed = true;-
1973 QLayout *parentLayout = currentHoveredFloat->parentWidget()->layout();-
1974 info->item_list.append(QDockAreaLayoutItem(parentLayout->takeAt(parentLayout->indexOf(currentHoveredFloat))));-
1975-
1976 dropTo->setParent(floatingTabs);-
1977 dropTo->show();-
1978 dropTo->d_func()->plug(QRect());-
1979 currentHoveredFloat = floatingTabs;-
1980 }
never executed: end of block
0
1981-
1982 QDockWidgetGroupWindow *dwgw = qobject_cast<QDockWidgetGroupWindow *>(currentHoveredFloat);-
1983 Q_ASSERT(dwgw);-
1984 Q_ASSERT(dwgw->layoutInfo()->tabbed); // because floating group should always be tabbed-
1985 previousPath = dwgw->layoutInfo()->indexOf(widget);-
1986 if (!previousPath.isEmpty())
!previousPath.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1987 dwgw->layoutInfo()->remove(previousPath);
never executed: dwgw->layoutInfo()->remove(previousPath);
0
1988 dwgw->layoutInfo()->tab(0, widgetItem);-
1989 QRect globalRect = dwgw->layoutInfo()->tabContentRect();-
1990 globalRect.moveTopLeft(dwgw->mapToGlobal(globalRect.topLeft()));-
1991 pluggingWidget = widget;-
1992 widgetAnimator.animate(widget, globalRect, dockOptions & QMainWindow::AnimatedDocks);-
1993 return true;
never executed: return true;
0
1994 }-
1995#endif-
1996-
1997 if (!parentWidget()->isVisible() || parentWidget()->isMinimized() || currentGapPos.isEmpty())
!parentWidget()->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
parentWidget()->isMinimized()Description
TRUEnever evaluated
FALSEnever evaluated
currentGapPos.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1998 return false;
never executed: return false;
0
1999-
2000 fixToolBarOrientation(widgetItem, currentGapPos.at(1));-
2001-
2002 QWidget *widget = widgetItem->widget();-
2003-
2004#ifndef QT_NO_DOCKWIDGET-
2005 // Let's remove the widget from any possible group window-
2006 foreach (QDockWidgetGroupWindow *dwgw,-
2007 parent()->findChildren<QDockWidgetGroupWindow*>(QString(), Qt::FindDirectChildrenOnly)) {-
2008 QList<int> path = dwgw->layoutInfo()->indexOf(widget);-
2009 if (!path.isEmpty())
!path.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
2010 dwgw->layoutInfo()->remove(path);
never executed: dwgw->layoutInfo()->remove(path);
0
2011 }
never executed: end of block
0
2012#endif-
2013-
2014 QList<int> previousPath = layoutState.indexOf(widget);-
2015-
2016 const QLayoutItem *it = layoutState.plug(currentGapPos);-
2017 if (!it)
!itDescription
TRUEnever evaluated
FALSEnever evaluated
0
2018 return false;
never executed: return false;
0
2019 Q_ASSERT(it == widgetItem);-
2020 if (!previousPath.isEmpty())
!previousPath.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
2021 layoutState.remove(previousPath);
never executed: layoutState.remove(previousPath);
0
2022-
2023 pluggingWidget = widget;-
2024 QRect globalRect = currentGapRect;-
2025 globalRect.moveTopLeft(parentWidget()->mapToGlobal(globalRect.topLeft()));-
2026#ifndef QT_NO_DOCKWIDGET-
2027 if (qobject_cast<QDockWidget*>(widget) != 0) {
qobject_cast<Q...>(widget) != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2028 QDockWidgetLayout *layout = qobject_cast<QDockWidgetLayout*>(widget->layout());-
2029 if (layout->nativeWindowDeco()) {
layout->nativeWindowDeco()Description
TRUEnever evaluated
FALSEnever evaluated
0
2030 globalRect.adjust(0, layout->titleHeight(), 0, 0);-
2031 } else {
never executed: end of block
0
2032 int fw = widget->style()->pixelMetric(QStyle::PM_DockWidgetFrameWidth, 0, widget);-
2033 globalRect.adjust(-fw, -fw, fw, fw);-
2034 }
never executed: end of block
0
2035 }-
2036#endif-
2037 widgetAnimator.animate(widget, globalRect, dockOptions & QMainWindow::AnimatedDocks);-
2038-
2039 return true;
never executed: return true;
0
2040}-
2041-
2042void QMainWindowLayout::animationFinished(QWidget *widget)-
2043{-
2044 //this function is called from within the Widget Animator whenever an animation is finished-
2045 //on a certain widget-
2046#ifndef QT_NO_TOOLBAR-
2047 if (QToolBar *tb = qobject_cast<QToolBar*>(widget)) {
QToolBar *tb =...lBar*>(widget)Description
TRUEnever evaluated
FALSEnever evaluated
0
2048 QToolBarLayout *tbl = qobject_cast<QToolBarLayout*>(tb->layout());-
2049 if (tbl->animating) {
tbl->animatingDescription
TRUEnever evaluated
FALSEnever evaluated
0
2050 tbl->animating = false;-
2051 if (tbl->expanded)
tbl->expandedDescription
TRUEnever evaluated
FALSEnever evaluated
0
2052 tbl->layoutActions(tb->size());
never executed: tbl->layoutActions(tb->size());
0
2053 tb->update();-
2054 }
never executed: end of block
0
2055 }
never executed: end of block
0
2056#endif-
2057-
2058 if (widget == pluggingWidget) {
widget == pluggingWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
2059-
2060#ifndef QT_NO_DOCKWIDGET-
2061 if (QDockWidgetGroupWindow *dwgw = qobject_cast<QDockWidgetGroupWindow *>(widget)) {
QDockWidgetGro...dow *>(widget)Description
TRUEnever evaluated
FALSEnever evaluated
0
2062 // When the animated widget was a QDockWidgetGroupWindow, it means each of the-
2063 // embedded QDockWidget needs to be plugged back into the QMainWindow layout.-
2064 savedState.clear();-
2065 QDockAreaLayoutInfo* info = dwgw->layoutInfo();-
2066 QDockAreaLayoutInfo* parentInfo;-
2067 QList<int> path;-
2068-
2069 if (QDockWidgetGroupWindow *dropTo = qobject_cast<QDockWidgetGroupWindow *>(currentHoveredFloat)) {
QDockWidgetGro...tHoveredFloat)Description
TRUEnever evaluated
FALSEnever evaluated
0
2070 parentInfo = dropTo->layoutInfo();-
2071 Q_ASSERT(parentInfo->tabbed);-
2072 path = parentInfo->indexOf(widget);-
2073 Q_ASSERT(path.size() == 1);-
2074 } else {
never executed: end of block
0
2075 path = layoutState.dockAreaLayout.indexOf(widget);-
2076 Q_ASSERT(path.size() >= 2);-
2077 parentInfo = layoutState.dockAreaLayout.info(path);-
2078 Q_ASSERT(parentInfo);-
2079 }
never executed: end of block
0
2080-
2081 if (parentInfo->tabbed) {
parentInfo->tabbedDescription
TRUEnever evaluated
FALSEnever evaluated
0
2082 // merge the two tab widgets-
2083 int idx = path.constLast();-
2084 Q_ASSERT(parentInfo->item_list[idx].widgetItem->widget() == dwgw);-
2085 delete parentInfo->item_list[idx].widgetItem;-
2086 parentInfo->item_list.removeAt(idx);-
2087 std::copy(info->item_list.cbegin(), info->item_list.cend(),-
2088 std::inserter(parentInfo->item_list, parentInfo->item_list.begin() + idx));-
2089 quintptr currentId = info->currentTabId();-
2090 *info = QDockAreaLayoutInfo();-
2091 parentInfo->reparentWidgets(currentHoveredFloat ? currentHoveredFloat.data() : parentWidget());-
2092 parentInfo->updateTabBar();-
2093 parentInfo->setCurrentTabId(currentId);-
2094 } else {
never executed: end of block
0
2095 QDockAreaLayoutItem &item = layoutState.dockAreaLayout.item(path);-
2096 Q_ASSERT(item.widgetItem->widget() == dwgw);-
2097 delete item.widgetItem;-
2098 item.widgetItem = 0;-
2099 item.subinfo = new QDockAreaLayoutInfo(qMove(*info));-
2100 *info = QDockAreaLayoutInfo();-
2101 item.subinfo->reparentWidgets(parentWidget());-
2102 item.subinfo->setTabBarShape(parentInfo->tabBarShape);-
2103 }
never executed: end of block
0
2104 dwgw->destroyOrHideIfEmpty();-
2105 }
never executed: end of block
0
2106-
2107 if (QDockWidget *dw = qobject_cast<QDockWidget*>(widget)) {
QDockWidget *d...dget*>(widget)Description
TRUEnever evaluated
FALSEnever evaluated
0
2108 if (currentHoveredFloat) {
currentHoveredFloatDescription
TRUEnever evaluated
FALSEnever evaluated
0
2109 dw->setParent(currentHoveredFloat);-
2110 dw->show();-
2111 }
never executed: end of block
0
2112 dw->d_func()->plug(currentGapRect);-
2113 }
never executed: end of block
0
2114#endif-
2115#ifndef QT_NO_TOOLBAR-
2116 if (QToolBar *tb = qobject_cast<QToolBar*>(widget))
QToolBar *tb =...lBar*>(widget)Description
TRUEnever evaluated
FALSEnever evaluated
0
2117 tb->d_func()->plug(currentGapRect);
never executed: tb->d_func()->plug(currentGapRect);
0
2118#endif-
2119-
2120 savedState.clear();-
2121 currentGapPos.clear();-
2122 pluggingWidget = 0;-
2123 currentHoveredFloat = Q_NULLPTR;-
2124 //applying the state will make sure that the currentGap is updated correctly-
2125 //and all the geometries (especially the one from the central widget) is correct-
2126 layoutState.apply(false);-
2127-
2128#ifndef QT_NO_DOCKWIDGET-
2129#ifndef QT_NO_TABBAR-
2130 if (qobject_cast<QDockWidget*>(widget) != 0) {
qobject_cast<Q...>(widget) != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2131 // info() might return null if the widget is destroyed while-
2132 // animating but before the animationFinished signal is received.-
2133 if (QDockAreaLayoutInfo *info = dockInfo(widget))
QDockAreaLayou...ckInfo(widget)Description
TRUEnever evaluated
FALSEnever evaluated
0
2134 info->setCurrentTab(widget);
never executed: info->setCurrentTab(widget);
0
2135 }
never executed: end of block
0
2136#endif-
2137#endif-
2138 }
never executed: end of block
0
2139-
2140 if (!widgetAnimator.animating()) {
!widgetAnimator.animating()Description
TRUEnever evaluated
FALSEnever evaluated
0
2141 //all animations are finished-
2142#ifndef QT_NO_DOCKWIDGET-
2143 parentWidget()->update(layoutState.dockAreaLayout.separatorRegion());-
2144#ifndef QT_NO_TABBAR-
2145 foreach (QTabBar *tab_bar, usedTabBars)-
2146 tab_bar->show();
never executed: tab_bar->show();
0
2147#endif // QT_NO_TABBAR-
2148#endif // QT_NO_DOCKWIDGET-
2149 }
never executed: end of block
0
2150-
2151 updateGapIndicator();-
2152}
never executed: end of block
0
2153-
2154void QMainWindowLayout::restore(bool keepSavedState)-
2155{-
2156 if (!savedState.isValid())
!savedState.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
2157 return;
never executed: return;
0
2158-
2159 layoutState = savedState;-
2160 applyState(layoutState);-
2161 if (!keepSavedState)
!keepSavedStateDescription
TRUEnever evaluated
FALSEnever evaluated
0
2162 savedState.clear();
never executed: savedState.clear();
0
2163 currentGapPos.clear();-
2164 pluggingWidget = 0;-
2165 updateGapIndicator();-
2166}
never executed: end of block
0
2167-
2168QMainWindowLayout::QMainWindowLayout(QMainWindow *mainwindow, QLayout *parentLayout)-
2169 : QLayout(parentLayout ? static_cast<QWidget *>(0) : mainwindow)-
2170 , layoutState(mainwindow)-
2171 , savedState(mainwindow)-
2172 , dockOptions(QMainWindow::AnimatedDocks | QMainWindow::AllowTabbedDocks)-
2173 , statusbar(0)-
2174#ifndef QT_NO_DOCKWIDGET-
2175#ifndef QT_NO_TABBAR-
2176 , _documentMode(false)-
2177 , verticalTabsEnabled(false)-
2178#ifndef QT_NO_TABWIDGET-
2179 , _tabShape(QTabWidget::Rounded)-
2180#endif-
2181#endif-
2182#endif // QT_NO_DOCKWIDGET-
2183 , widgetAnimator(this)-
2184 , pluggingWidget(0)-
2185#ifdef Q_DEAD_CODE_FROM_QT4_MAC-
2186 , blockVisiblityCheck(false)-
2187#endif-
2188{-
2189 if (parentLayout)
parentLayoutDescription
TRUEnever evaluated
FALSEnever evaluated
0
2190 setParent(parentLayout);
never executed: setParent(parentLayout);
0
2191-
2192#ifndef QT_NO_DOCKWIDGET-
2193#ifndef QT_NO_TABBAR-
2194 sep = mainwindow->style()->pixelMetric(QStyle::PM_DockWidgetSeparatorExtent, 0, mainwindow);-
2195#endif-
2196-
2197#ifndef QT_NO_TABWIDGET-
2198 for (int i = 0; i < QInternal::DockCount; ++i)
i < QInternal::DockCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
2199 tabPositions[i] = QTabWidget::South;
never executed: tabPositions[i] = QTabWidget::South;
0
2200#endif-
2201#endif // QT_NO_DOCKWIDGET-
2202 pluggingWidget = 0;-
2203-
2204 setObjectName(mainwindow->objectName() + QLatin1String("_layout"));-
2205}
never executed: end of block
0
2206-
2207QMainWindowLayout::~QMainWindowLayout()-
2208{-
2209 layoutState.deleteAllLayoutItems();-
2210 layoutState.deleteCentralWidgetItem();-
2211-
2212#ifdef Q_DEAD_CODE_FROM_QT4_MAC-
2213 cleanUpMacToolbarItems();-
2214#endif-
2215-
2216 delete statusbar;-
2217}
never executed: end of block
0
2218-
2219void QMainWindowLayout::setDockOptions(QMainWindow::DockOptions opts)-
2220{-
2221 if (opts == dockOptions)
opts == dockOptionsDescription
TRUEnever evaluated
FALSEnever evaluated
0
2222 return;
never executed: return;
0
2223-
2224 dockOptions = opts;-
2225-
2226#ifndef QT_NO_DOCKWIDGET-
2227 setVerticalTabsEnabled(opts & QMainWindow::VerticalTabs);-
2228#endif-
2229-
2230 invalidate();-
2231}
never executed: end of block
0
2232-
2233#ifndef QT_NO_STATUSBAR-
2234QStatusBar *QMainWindowLayout::statusBar() const-
2235{
never executed: return statusbar ? qobject_cast<QStatusBar *>(statusbar->widget()) : 0;
return statusbar ? qobject_cast<QStatusBar *>(statusbar->widget()) : 0; }
never executed: return statusbar ? qobject_cast<QStatusBar *>(statusbar->widget()) : 0;
0
2236-
2237void QMainWindowLayout::setStatusBar(QStatusBar *sb)-
2238{-
2239 if (sb)
sbDescription
TRUEnever evaluated
FALSEnever evaluated
0
2240 addChildWidget(sb);
never executed: addChildWidget(sb);
0
2241 delete statusbar;-
2242 statusbar = sb ? new QWidgetItemV2(sb) : 0;
sbDescription
TRUEnever evaluated
FALSEnever evaluated
0
2243 invalidate();-
2244}
never executed: end of block
0
2245#endif // QT_NO_STATUSBAR-
2246-
2247QWidget *QMainWindowLayout::centralWidget() const-
2248{-
2249 return layoutState.centralWidget();
never executed: return layoutState.centralWidget();
0
2250}-
2251-
2252void QMainWindowLayout::setCentralWidget(QWidget *widget)-
2253{-
2254 if (widget != 0)
widget != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2255 addChildWidget(widget);
never executed: addChildWidget(widget);
0
2256 layoutState.setCentralWidget(widget);-
2257 if (savedState.isValid()) {
savedState.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
2258#ifndef QT_NO_DOCKWIDGET-
2259 savedState.dockAreaLayout.centralWidgetItem = layoutState.dockAreaLayout.centralWidgetItem;-
2260 savedState.dockAreaLayout.fallbackToSizeHints = true;-
2261#else-
2262 savedState.centralWidgetItem = layoutState.centralWidgetItem;-
2263#endif-
2264 }
never executed: end of block
0
2265 invalidate();-
2266}
never executed: end of block
0
2267-
2268/*! \internal-
2269 Unplug \a widget (QDockWidget or QToolBar) from it's parent container.-
2270-
2271 If \a group is true we might actually unplug the group of tabs this-
2272 widget is part if QMainWindow::GroupedDragging is set. When \a group-
2273 is false, the widget itself is always unplugged alone-
2274-
2275 Returns the QLayoutItem of the dragged element.-
2276 The layout item is kept in the layout but set as a gap item.-
2277 */-
2278QLayoutItem *QMainWindowLayout::unplug(QWidget *widget, bool group)-
2279{-
2280#if !defined(QT_NO_DOCKWIDGET) && !defined(QT_NO_TABBAR)-
2281 if (!widget->isWindow() && qobject_cast<const QDockWidgetGroupWindow *>(widget->parentWidget())) {
!widget->isWindow()Description
TRUEnever evaluated
FALSEnever evaluated
qobject_cast<c...arentWidget())Description
TRUEnever evaluated
FALSEnever evaluated
0
2282 if (group) {
groupDescription
TRUEnever evaluated
FALSEnever evaluated
0
2283 // We are just dragging a floating window as it, not need to do anything, we just have to-
2284 // look up the corresponding QWidgetItem* if it exists-
2285 QList<int> tabbedWindowPath = layoutState.indexOf(widget->parentWidget());-
2286 return tabbedWindowPath.isEmpty() ? 0 : layoutState.item(tabbedWindowPath);
never executed: return tabbedWindowPath.isEmpty() ? 0 : layoutState.item(tabbedWindowPath);
0
2287 } else {-
2288 // We are unplugging a dock widget from a floating window.-
2289 if (QDockWidget *dw = qobject_cast<QDockWidget*>(widget)) {
QDockWidget *d...dget*>(widget)Description
TRUEnever evaluated
FALSEnever evaluated
0
2290 dw->d_func()->unplug(widget->geometry());-
2291 return 0;
never executed: return 0;
0
2292 }-
2293 }
never executed: end of block
0
2294 }-
2295#endif-
2296 QList<int> path = layoutState.indexOf(widget);-
2297 if (path.isEmpty())
path.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
2298 return 0;
never executed: return 0;
0
2299-
2300 QLayoutItem *item = layoutState.item(path);-
2301 if (widget->isWindow())
widget->isWindow()Description
TRUEnever evaluated
FALSEnever evaluated
0
2302 return item;
never executed: return item;
0
2303-
2304 QRect r = layoutState.itemRect(path);-
2305 savedState = layoutState;-
2306-
2307#ifndef QT_NO_DOCKWIDGET-
2308 if (QDockWidget *dw = qobject_cast<QDockWidget*>(widget)) {
QDockWidget *d...dget*>(widget)Description
TRUEnever evaluated
FALSEnever evaluated
0
2309 Q_ASSERT(path.constFirst() == 1);-
2310 bool actualGroup = false;-
2311#ifndef QT_NO_TABBAR-
2312 if (group && (dockOptions & QMainWindow::GroupedDragging) && path.size() > 3) {
groupDescription
TRUEnever evaluated
FALSEnever evaluated
(dockOptions &...oupedDragging)Description
TRUEnever evaluated
FALSEnever evaluated
path.size() > 3Description
TRUEnever evaluated
FALSEnever evaluated
0
2313 QDockAreaLayoutItem &parentItem = layoutState.dockAreaLayout.item(path.mid(1, path.size() - 2));-
2314 if (parentItem.subinfo && parentItem.subinfo->tabbed) {
parentItem.subinfoDescription
TRUEnever evaluated
FALSEnever evaluated
parentItem.subinfo->tabbedDescription
TRUEnever evaluated
FALSEnever evaluated
0
2315 // The QDockWidget is part of a group of tab and we need to unplug them all.-
2316 actualGroup = true;-
2317 path.removeLast();-
2318-
2319 QDockWidgetGroupWindow* floatingTabs = createTabbedDockWindow();-
2320 QDockAreaLayoutInfo* info = floatingTabs->layoutInfo();-
2321 *info = qMove(*parentItem.subinfo);-
2322 delete parentItem.subinfo;-
2323 parentItem.subinfo = 0;-
2324 floatingTabs->setGeometry(info->rect.translated(parentWidget()->pos()));-
2325 floatingTabs->show();-
2326 floatingTabs->raise();-
2327 item = new QDockWidgetGroupWindowItem(floatingTabs);-
2328 parentItem.widgetItem = item;-
2329 savedState = layoutState;-
2330 }
never executed: end of block
0
2331 }
never executed: end of block
0
2332#endif // QT_NO_TABBAR-
2333 if (!actualGroup) {
!actualGroupDescription
TRUEnever evaluated
FALSEnever evaluated
0
2334 dw->d_func()->unplug(r);-
2335 }
never executed: end of block
0
2336 }
never executed: end of block
0
2337#endif // QT_NO_DOCKWIDGET-
2338#ifndef QT_NO_TOOLBAR-
2339 if (QToolBar *tb = qobject_cast<QToolBar*>(widget)) {
QToolBar *tb =...lBar*>(widget)Description
TRUEnever evaluated
FALSEnever evaluated
0
2340 tb->d_func()->unplug(r);-
2341 }
never executed: end of block
0
2342#endif-
2343-
2344-
2345 layoutState.unplug(path ,&savedState);-
2346 savedState.fitLayout();-
2347 currentGapPos = path;-
2348 currentGapRect = r;-
2349 updateGapIndicator();-
2350-
2351 fixToolBarOrientation(item, currentGapPos.at(1));-
2352-
2353 return item;
never executed: return item;
0
2354}-
2355-
2356void QMainWindowLayout::updateGapIndicator()-
2357{-
2358#ifndef QT_NO_RUBBERBAND-
2359 if ((!widgetAnimator.animating() && !currentGapPos.isEmpty()) || currentHoveredFloat) {
!widgetAnimator.animating()Description
TRUEnever evaluated
FALSEnever evaluated
!currentGapPos.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
currentHoveredFloatDescription
TRUEnever evaluated
FALSEnever evaluated
0
2360 QWidget *expectedParent = currentHoveredFloat ? currentHoveredFloat.data() : parentWidget();
currentHoveredFloatDescription
TRUEnever evaluated
FALSEnever evaluated
0
2361 if (!gapIndicator) {
!gapIndicatorDescription
TRUEnever evaluated
FALSEnever evaluated
0
2362 gapIndicator = new QRubberBand(QRubberBand::Rectangle, expectedParent);-
2363 // For accessibility to identify this special widget.-
2364 gapIndicator->setObjectName(QLatin1String("qt_rubberband"));-
2365 } else if (gapIndicator->parent() != expectedParent) {
never executed: end of block
gapIndicator->...expectedParentDescription
TRUEnever evaluated
FALSEnever evaluated
0
2366 gapIndicator->setParent(expectedParent);-
2367 }
never executed: end of block
0
2368 gapIndicator->setGeometry(currentHoveredFloat ? currentHoveredFloat->rect() : currentGapRect);-
2369 gapIndicator->show();-
2370 gapIndicator->raise();-
2371 } else if (gapIndicator) {
never executed: end of block
gapIndicatorDescription
TRUEnever evaluated
FALSEnever evaluated
0
2372 gapIndicator->hide();-
2373 }
never executed: end of block
0
2374#endif //QT_NO_RUBBERBAND-
2375}
never executed: end of block
0
2376-
2377void QMainWindowLayout::hover(QLayoutItem *widgetItem, const QPoint &mousePos)-
2378{-
2379 if (!parentWidget()->isVisible() || parentWidget()->isMinimized()
!parentWidget()->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
parentWidget()->isMinimized()Description
TRUEnever evaluated
FALSEnever evaluated
0
2380 || pluggingWidget != 0 || widgetItem == 0)
pluggingWidget != 0Description
TRUEnever evaluated
FALSEnever evaluated
widgetItem == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2381 return;
never executed: return;
0
2382-
2383 QWidget *widget = widgetItem->widget();-
2384-
2385#ifndef QT_NO_DOCKWIDGET-
2386 if ((dockOptions & QMainWindow::GroupedDragging) && (qobject_cast<QDockWidget*>(widget)
(dockOptions &...oupedDragging)Description
TRUEnever evaluated
FALSEnever evaluated
qobject_cast<Q...dget*>(widget)Description
TRUEnever evaluated
FALSEnever evaluated
0
2387 || qobject_cast<QDockWidgetGroupWindow *>(widget))) {
qobject_cast<Q...dow *>(widget)Description
TRUEnever evaluated
FALSEnever evaluated
0
2388-
2389 // Check if we are over another floating dock widget-
2390 QVarLengthArray<QWidget *, 10> candidates;-
2391 foreach (QObject *c, parentWidget()->children()) {-
2392 QWidget *w = qobject_cast<QWidget*>(c);-
2393 if (!w)
!wDescription
TRUEnever evaluated
FALSEnever evaluated
0
2394 continue;
never executed: continue;
0
2395 if (!qobject_cast<QDockWidget*>(w) && !qobject_cast<QDockWidgetGroupWindow *>(w))
!qobject_cast<QDockWidget*>(w)Description
TRUEnever evaluated
FALSEnever evaluated
!qobject_cast<...upWindow *>(w)Description
TRUEnever evaluated
FALSEnever evaluated
0
2396 continue;
never executed: continue;
0
2397 if (w != widget && w->isTopLevel() && w->isVisible() && !w->isMinimized())
w != widgetDescription
TRUEnever evaluated
FALSEnever evaluated
w->isTopLevel()Description
TRUEnever evaluated
FALSEnever evaluated
w->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
!w->isMinimized()Description
TRUEnever evaluated
FALSEnever evaluated
0
2398 candidates << w;
never executed: candidates << w;
0
2399 if (QDockWidgetGroupWindow *group = qobject_cast<QDockWidgetGroupWindow *>(w)) {
QDockWidgetGro...upWindow *>(w)Description
TRUEnever evaluated
FALSEnever evaluated
0
2400 // Sometimes, there are floating QDockWidget that have a QDockWidgetGroupWindow as a parent.-
2401 foreach (QObject *c, group->children()) {-
2402 if (QDockWidget *dw = qobject_cast<QDockWidget*>(c)) {
QDockWidget *d...ockWidget*>(c)Description
TRUEnever evaluated
FALSEnever evaluated
0
2403 if (dw != widget && dw->isFloating() && dw->isVisible() && !dw->isMinimized())
dw != widgetDescription
TRUEnever evaluated
FALSEnever evaluated
dw->isFloating()Description
TRUEnever evaluated
FALSEnever evaluated
dw->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
!dw->isMinimized()Description
TRUEnever evaluated
FALSEnever evaluated
0
2404 candidates << dw;
never executed: candidates << dw;
0
2405 }
never executed: end of block
0
2406 }
never executed: end of block
0
2407 }
never executed: end of block
0
2408 }
never executed: end of block
0
2409 for (QWidget *w : candidates) {-
2410 QWindow *handle1 = widget->windowHandle();-
2411 QWindow *handle2 = w->windowHandle();-
2412 if (handle1 && handle2 && handle1->screen() != handle2->screen())
handle1Description
TRUEnever evaluated
FALSEnever evaluated
handle2Description
TRUEnever evaluated
FALSEnever evaluated
handle1->scree...dle2->screen()Description
TRUEnever evaluated
FALSEnever evaluated
0
2413 continue;
never executed: continue;
0
2414 if (!w->geometry().contains(mousePos))
!w->geometry()...ains(mousePos)Description
TRUEnever evaluated
FALSEnever evaluated
0
2415 continue;
never executed: continue;
0
2416-
2417 currentHoveredFloat = w;-
2418 restore(true);-
2419 return;
never executed: return;
0
2420 }-
2421 }
never executed: end of block
0
2422 currentHoveredFloat = Q_NULLPTR;-
2423#endif //QT_NO_DOCKWIDGET-
2424-
2425 QPoint pos = parentWidget()->mapFromGlobal(mousePos);-
2426-
2427 if (!savedState.isValid())
!savedState.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
2428 savedState = layoutState;
never executed: savedState = layoutState;
0
2429-
2430 QList<int> path = savedState.gapIndex(widget, pos);-
2431-
2432 if (!path.isEmpty()) {
!path.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
2433 bool allowed = false;-
2434-
2435#ifndef QT_NO_DOCKWIDGET-
2436 if (QDockWidget *dw = qobject_cast<QDockWidget*>(widget))
QDockWidget *d...dget*>(widget)Description
TRUEnever evaluated
FALSEnever evaluated
0
2437 allowed = dw->isAreaAllowed(toDockWidgetArea(path.at(1)));
never executed: allowed = dw->isAreaAllowed(toDockWidgetArea(path.at(1)));
0
2438-
2439 if (qobject_cast<QDockWidgetGroupWindow *>(widget))
qobject_cast<Q...dow *>(widget)Description
TRUEnever evaluated
FALSEnever evaluated
0
2440 allowed = true;
never executed: allowed = true;
0
2441#endif-
2442#ifndef QT_NO_TOOLBAR-
2443 if (QToolBar *tb = qobject_cast<QToolBar*>(widget))
QToolBar *tb =...lBar*>(widget)Description
TRUEnever evaluated
FALSEnever evaluated
0
2444 allowed = tb->isAreaAllowed(toToolBarArea(path.at(1)));
never executed: allowed = tb->isAreaAllowed(toToolBarArea(path.at(1)));
0
2445#endif-
2446-
2447 if (!allowed)
!allowedDescription
TRUEnever evaluated
FALSEnever evaluated
0
2448 path.clear();
never executed: path.clear();
0
2449 }
never executed: end of block
0
2450-
2451 if (path == currentGapPos)
path == currentGapPosDescription
TRUEnever evaluated
FALSEnever evaluated
0
2452 return; // the gap is already there
never executed: return;
0
2453-
2454 currentGapPos = path;-
2455 if (path.isEmpty()) {
path.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
2456 fixToolBarOrientation(widgetItem, 2); // 2 = top dock, ie. horizontal-
2457 restore(true);-
2458 return;
never executed: return;
0
2459 }-
2460-
2461 fixToolBarOrientation(widgetItem, currentGapPos.at(1));-
2462-
2463 QMainWindowLayoutState newState = savedState;-
2464-
2465 if (!newState.insertGap(path, widgetItem)) {
!newState.inse...h, widgetItem)Description
TRUEnever evaluated
FALSEnever evaluated
0
2466 restore(true); // not enough space-
2467 return;
never executed: return;
0
2468 }-
2469-
2470 QSize min = newState.minimumSize();-
2471 QSize size = newState.rect.size();-
2472-
2473 if (min.width() > size.width() || min.height() > size.height()) {
min.width() > size.width()Description
TRUEnever evaluated
FALSEnever evaluated
min.height() > size.height()Description
TRUEnever evaluated
FALSEnever evaluated
0
2474 restore(true);-
2475 return;
never executed: return;
0
2476 }-
2477-
2478 newState.fitLayout();-
2479-
2480 currentGapRect = newState.gapRect(currentGapPos);-
2481-
2482#ifndef QT_NO_DOCKWIDGET-
2483 parentWidget()->update(layoutState.dockAreaLayout.separatorRegion());-
2484#endif-
2485 layoutState = newState;-
2486 applyState(layoutState);-
2487-
2488 updateGapIndicator();-
2489}
never executed: end of block
0
2490-
2491QDockWidgetGroupWindow *QMainWindowLayout::createTabbedDockWindow()-
2492{-
2493 QDockWidgetGroupWindow* f = new QDockWidgetGroupWindow(parentWidget(), Qt::Tool);-
2494 new QDockWidgetGroupLayout(f);-
2495 return f;
never executed: return f;
0
2496}-
2497-
2498void QMainWindowLayout::applyState(QMainWindowLayoutState &newState, bool animate)-
2499{-
2500#ifndef QT_NO_DOCKWIDGET-
2501#ifndef QT_NO_TABBAR-
2502 QSet<QTabBar*> used = newState.dockAreaLayout.usedTabBars();-
2503 foreach (QDockWidgetGroupWindow *dwgw,-
2504 parent()->findChildren<QDockWidgetGroupWindow*>(QString(), Qt::FindDirectChildrenOnly)) {-
2505 used += dwgw->layoutInfo()->usedTabBars();-
2506 }
never executed: end of block
0
2507-
2508 QSet<QTabBar*> retired = usedTabBars - used;-
2509 usedTabBars = used;-
2510 foreach (QTabBar *tab_bar, retired) {-
2511 tab_bar->hide();-
2512 while (tab_bar->count() > 0)
tab_bar->count() > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2513 tab_bar->removeTab(0);
never executed: tab_bar->removeTab(0);
0
2514 unusedTabBars.append(tab_bar);-
2515 }
never executed: end of block
0
2516-
2517 if (sep == 1) {
sep == 1Description
TRUEnever evaluated
FALSEnever evaluated
0
2518 QSet<QWidget*> usedSeps = newState.dockAreaLayout.usedSeparatorWidgets();-
2519 QSet<QWidget*> retiredSeps = usedSeparatorWidgets - usedSeps;-
2520 usedSeparatorWidgets = usedSeps;-
2521 foreach (QWidget *sepWidget, retiredSeps) {-
2522 unusedSeparatorWidgets.append(sepWidget);-
2523 }
never executed: end of block
0
2524 }
never executed: end of block
0
2525-
2526 for (int i = 0; i < QInternal::DockCount; ++i)
i < QInternal::DockCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
2527 newState.dockAreaLayout.docks[i].reparentWidgets(parentWidget());
never executed: newState.dockAreaLayout.docks[i].reparentWidgets(parentWidget());
0
2528-
2529#endif // QT_NO_TABBAR-
2530#endif // QT_NO_DOCKWIDGET-
2531 newState.apply(dockOptions & QMainWindow::AnimatedDocks && animate);-
2532}
never executed: end of block
0
2533-
2534void QMainWindowLayout::saveState(QDataStream &stream) const-
2535{-
2536 layoutState.saveState(stream);-
2537}
never executed: end of block
0
2538-
2539bool QMainWindowLayout::restoreState(QDataStream &stream)-
2540{-
2541 savedState = layoutState;-
2542 layoutState.clear();-
2543 layoutState.rect = savedState.rect;-
2544-
2545 if (!layoutState.restoreState(stream, savedState)) {
!layoutState.r...m, savedState)Description
TRUEnever evaluated
FALSEnever evaluated
0
2546 layoutState.deleteAllLayoutItems();-
2547 layoutState = savedState;-
2548 if (parentWidget()->isVisible())
parentWidget()->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
0
2549 applyState(layoutState, false); // hides tabBars allocated by newState
never executed: applyState(layoutState, false);
0
2550 return false;
never executed: return false;
0
2551 }-
2552-
2553 if (parentWidget()->isVisible()) {
parentWidget()->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
0
2554 layoutState.fitLayout();-
2555 applyState(layoutState, false);-
2556 }
never executed: end of block
0
2557-
2558 savedState.deleteAllLayoutItems();-
2559 savedState.clear();-
2560-
2561#ifndef QT_NO_DOCKWIDGET-
2562 if (parentWidget()->isVisible()) {
parentWidget()->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
0
2563#ifndef QT_NO_TABBAR-
2564 foreach (QTabBar *tab_bar, usedTabBars)-
2565 tab_bar->show();
never executed: tab_bar->show();
0
2566-
2567#endif-
2568 }
never executed: end of block
0
2569#endif // QT_NO_DOCKWIDGET-
2570-
2571 return true;
never executed: return true;
0
2572}-
2573-
2574-
2575// Returns if this toolbar *should* be using HIToolbar. Won't work for all in between cases-
2576// for example, you have a toolbar in the top area and then you suddenly turn on-
2577// HIToolbar.-
2578bool QMainWindowLayout::usesHIToolBar(QToolBar *toolbar) const-
2579{-
2580#ifndef Q_DEAD_CODE_FROM_QT4_MAC-
2581 Q_UNUSED(toolbar);-
2582 return false;
never executed: return false;
0
2583#else-
2584 return qtoolbarsInUnifiedToolbarList.contains(toolbar)-
2585 || ((toolBarArea(toolbar) == Qt::TopToolBarArea)-
2586 && layoutState.mainWindow->unifiedTitleAndToolBarOnMac());-
2587#endif-
2588}-
2589-
2590void QMainWindowLayout::timerEvent(QTimerEvent *e)-
2591{-
2592#ifndef QT_NO_DOCKWIDGET-
2593 if (e->timerId() == separatorMoveTimer.timerId()) {
e->timerId() =...imer.timerId()Description
TRUEnever evaluated
FALSEnever evaluated
0
2594 //let's move the separators-
2595 separatorMoveTimer.stop();-
2596 if (movingSeparator.isEmpty())
movingSeparator.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
2597 return;
never executed: return;
0
2598 if (movingSeparatorOrigin == movingSeparatorPos)
movingSeparato...ngSeparatorPosDescription
TRUEnever evaluated
FALSEnever evaluated
0
2599 return;
never executed: return;
0
2600-
2601 //when moving the separator, we need to update the previous position-
2602 parentWidget()->update(layoutState.dockAreaLayout.separatorRegion());-
2603-
2604 layoutState = savedState;-
2605 layoutState.dockAreaLayout.separatorMove(movingSeparator, movingSeparatorOrigin,-
2606 movingSeparatorPos);-
2607 movingSeparatorPos = movingSeparatorOrigin;-
2608 }
never executed: end of block
0
2609#endif-
2610 QLayout::timerEvent(e);-
2611}
never executed: end of block
0
2612-
2613-
2614QT_END_NAMESPACE-
2615-
2616#include "moc_qmainwindowlayout_p.cpp"-
2617-
2618#endif // QT_NO_MAINWINDOW-
Source codeSwitch to Preprocessed file

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