qdockarealayout.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/widgets/widgets/qdockarealayout.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8extern QMainWindowLayout *qt_mainwindow_layout(const QMainWindow *window);-
9-
10enum { StateFlagVisible = 1, StateFlagFloating = 2 };-
11-
12-
13-
14-
15-
16QPlaceHolderItem::QPlaceHolderItem(QWidget *w)-
17{-
18 objectName = w->objectName();-
19 hidden = w->isHidden();-
20 window = w->isWindow();-
21 if (window)-
22 topLevelRect = w->geometry();-
23}-
24-
25-
26-
27-
28-
29QDockAreaLayoutItem::QDockAreaLayoutItem(QLayoutItem *_widgetItem)-
30 : widgetItem(_widgetItem), subinfo(0), placeHolderItem(0), pos(0), size(-1), flags(NoFlags)-
31{-
32}-
33-
34QDockAreaLayoutItem::QDockAreaLayoutItem(QDockAreaLayoutInfo *_subinfo)-
35 : widgetItem(0), subinfo(_subinfo), placeHolderItem(0), pos(0), size(-1), flags(NoFlags)-
36{-
37}-
38-
39QDockAreaLayoutItem::QDockAreaLayoutItem(QPlaceHolderItem *_placeHolderItem)-
40 : widgetItem(0), subinfo(0), placeHolderItem(_placeHolderItem), pos(0), size(-1), flags(NoFlags)-
41{-
42}-
43-
44QDockAreaLayoutItem::QDockAreaLayoutItem(const QDockAreaLayoutItem &other)-
45 : widgetItem(other.widgetItem), subinfo(0), placeHolderItem(0), pos(other.pos),-
46 size(other.size), flags(other.flags)-
47{-
48 if (other.subinfo != 0)-
49 subinfo = new QDockAreaLayoutInfo(*other.subinfo);-
50 else if (other.placeHolderItem != 0)-
51 placeHolderItem = new QPlaceHolderItem(*other.placeHolderItem);-
52}-
53-
54QDockAreaLayoutItem::~QDockAreaLayoutItem()-
55{-
56 delete subinfo;-
57 delete placeHolderItem;-
58}-
59-
60bool QDockAreaLayoutItem::skip() const-
61{-
62 if (placeHolderItem != 0)-
63 return true;-
64-
65 if (flags & GapItem)-
66 return false;-
67-
68 if (widgetItem != 0)-
69 return widgetItem->isEmpty();-
70-
71 if (subinfo != 0) {-
72 for (int i = 0; i < subinfo->item_list.count(); ++i) {-
73 if (!subinfo->item_list.at(i).skip())-
74 return false;-
75 }-
76 }-
77-
78 return true;-
79}-
80-
81QSize QDockAreaLayoutItem::minimumSize() const-
82{-
83 if (widgetItem != 0) {-
84 int left, top, right, bottom;-
85 widgetItem->widget()->getContentsMargins(&left, &top, &right, &bottom);-
86 return widgetItem->minimumSize() + QSize(left+right, top+bottom);-
87 }-
88 if (subinfo != 0)-
89 return subinfo->minimumSize();-
90 return QSize(0, 0);-
91}-
92-
93QSize QDockAreaLayoutItem::maximumSize() const-
94{-
95 if (widgetItem != 0) {-
96 int left, top, right, bottom;-
97 widgetItem->widget()->getContentsMargins(&left, &top, &right, &bottom);-
98 return widgetItem->maximumSize()+ QSize(left+right, top+bottom);-
99 }-
100 if (subinfo != 0)-
101 return subinfo->maximumSize();-
102 return QSize(((1<<24)-1), ((1<<24)-1));-
103}-
104-
105bool QDockAreaLayoutItem::hasFixedSize(Qt::Orientation o) const-
106{-
107 return perp(o, minimumSize()) == perp(o, maximumSize());-
108}-
109-
110bool QDockAreaLayoutItem::expansive(Qt::Orientation o) const-
111{-
112 if ((flags & GapItem) || placeHolderItem != 0)-
113 return false;-
114 if (widgetItem != 0)-
115 return ((widgetItem->expandingDirections() & o) == o);-
116 if (subinfo != 0)-
117 return subinfo->expansive(o);-
118 return false;-
119}-
120-
121QSize QDockAreaLayoutItem::sizeHint() const-
122{-
123 if (placeHolderItem != 0)-
124 return QSize(0, 0);-
125 if (widgetItem != 0) {-
126 int left, top, right, bottom;-
127 widgetItem->widget()->getContentsMargins(&left, &top, &right, &bottom);-
128 return widgetItem->sizeHint() + QSize(left+right, top+bottom);-
129 }-
130 if (subinfo != 0)-
131 return subinfo->sizeHint();-
132 return QSize(-1, -1);-
133}-
134-
135QDockAreaLayoutItem-
136 &QDockAreaLayoutItem::operator = (const QDockAreaLayoutItem &other)-
137{-
138 widgetItem = other.widgetItem;-
139 if (other.subinfo == 0)-
140 subinfo = 0;-
141 else-
142 subinfo = new QDockAreaLayoutInfo(*other.subinfo);-
143-
144 delete placeHolderItem;-
145 if (other.placeHolderItem == 0)-
146 placeHolderItem = 0;-
147 else-
148 placeHolderItem = new QPlaceHolderItem(*other.placeHolderItem);-
149-
150 pos = other.pos;-
151 size = other.size;-
152 flags = other.flags;-
153-
154 return *this;-
155}-
156-
157-
158-
159-
160-
161-
162static quintptr tabId(const QDockAreaLayoutItem &item)-
163{-
164 if (item.widgetItem == 0)-
165 return 0;-
166 return reinterpret_cast<quintptr>(item.widgetItem->widget());-
167}-
168-
169-
170static const int zero = 0;-
171-
172QDockAreaLayoutInfo::QDockAreaLayoutInfo()-
173 : sep(&zero), dockPos(QInternal::LeftDock), o(Qt::Horizontal), mainWindow(0)-
174-
175 , tabbed(false), tabBar(0), tabBarShape(QTabBar::RoundedSouth)-
176-
177{-
178}-
179-
180QDockAreaLayoutInfo::QDockAreaLayoutInfo(const int *_sep, QInternal::DockPosition _dockPos,-
181 Qt::Orientation _o, int tbshape,-
182 QMainWindow *window)-
183 : sep(_sep), dockPos(_dockPos), o(_o), mainWindow(window)-
184-
185 , tabbed(false), tabBar(0), tabBarShape(static_cast<QTabBar::Shape>(tbshape))-
186-
187{-
188-
189-
190-
191}-
192-
193QSize QDockAreaLayoutInfo::size() const-
194{-
195 return isEmpty() ? QSize(0, 0) : rect.size();-
196}-
197-
198void QDockAreaLayoutInfo::clear()-
199{-
200 item_list.clear();-
201 rect = QRect();-
202-
203 tabbed = false;-
204 tabBar = 0;-
205-
206}-
207-
208bool QDockAreaLayoutInfo::isEmpty() const-
209{-
210 return next(-1) == -1;-
211}-
212-
213QSize QDockAreaLayoutInfo::minimumSize() const-
214{-
215 if (isEmpty())-
216 return QSize(0, 0);-
217-
218 int a = 0, b = 0;-
219 bool first = true;-
220 for (int i = 0; i < item_list.size(); ++i) {-
221 const QDockAreaLayoutItem &item = item_list.at(i);-
222 if (item.skip())-
223 continue;-
224-
225 QSize min_size = item.minimumSize();-
226-
227 if (tabbed) {-
228 a = qMax(a, pick(o, min_size));-
229 } else-
230-
231 {-
232 if (!first)-
233 a += *sep;-
234 a += pick(o, min_size);-
235 }-
236 b = qMax(b, perp(o, min_size));-
237-
238 first = false;-
239 }-
240-
241 QSize result;-
242 rpick(o, result) = a;-
243 rperp(o, result) = b;-
244-
245-
246 QSize tbm = tabBarMinimumSize();-
247 if (!tbm.isNull()) {-
248 switch (tabBarShape) {-
249 case QTabBar::RoundedNorth:-
250 case QTabBar::RoundedSouth:-
251 case QTabBar::TriangularNorth:-
252 case QTabBar::TriangularSouth:-
253 result.rheight() += tbm.height();-
254 result.rwidth() = qMax(tbm.width(), result.width());-
255 break;-
256 case QTabBar::RoundedEast:-
257 case QTabBar::RoundedWest:-
258 case QTabBar::TriangularEast:-
259 case QTabBar::TriangularWest:-
260 result.rheight() = qMax(tbm.height(), result.height());-
261 result.rwidth() += tbm.width();-
262 break;-
263 default:-
264 break;-
265 }-
266 }-
267-
268-
269 return result;-
270}-
271-
272QSize QDockAreaLayoutInfo::maximumSize() const-
273{-
274 if (isEmpty())-
275 return QSize(((1<<24)-1), ((1<<24)-1));-
276-
277 int a = 0, b = ((1<<24)-1);-
278-
279 if (tabbed)-
280 a = ((1<<24)-1);-
281-
282-
283 int min_perp = 0;-
284-
285 bool first = true;-
286 for (int i = 0; i < item_list.size(); ++i) {-
287 const QDockAreaLayoutItem &item = item_list.at(i);-
288 if (item.skip())-
289 continue;-
290-
291 QSize max_size = item.maximumSize();-
292 min_perp = qMax(min_perp, perp(o, item.minimumSize()));-
293-
294-
295 if (tabbed) {-
296 a = qMin(a, pick(o, max_size));-
297 } else-
298-
299 {-
300 if (!first)-
301 a += *sep;-
302 a += pick(o, max_size);-
303 }-
304 b = qMin(b, perp(o, max_size));-
305-
306 a = qMin(a, int(((1<<24)-1)));-
307 b = qMin(b, int(((1<<24)-1)));-
308-
309 first = false;-
310 }-
311-
312 b = qMax(b, min_perp);-
313-
314 QSize result;-
315 rpick(o, result) = a;-
316 rperp(o, result) = b;-
317-
318-
319 QSize tbh = tabBarSizeHint();-
320 if (!tbh.isNull()) {-
321 switch (tabBarShape) {-
322 case QTabBar::RoundedNorth:-
323 case QTabBar::RoundedSouth:-
324 result.rheight() += tbh.height();-
325 break;-
326 case QTabBar::RoundedEast:-
327 case QTabBar::RoundedWest:-
328 result.rwidth() += tbh.width();-
329 break;-
330 default:-
331 break;-
332 }-
333 }-
334-
335-
336 return result;-
337}-
338-
339QSize QDockAreaLayoutInfo::sizeHint() const-
340{-
341 if (isEmpty())-
342 return QSize(0, 0);-
343-
344 int a = 0, b = 0;-
345 int min_perp = 0;-
346 int max_perp = ((1<<24)-1);-
347 const QDockAreaLayoutItem *previous = 0;-
348 for (int i = 0; i < item_list.size(); ++i) {-
349 const QDockAreaLayoutItem &item = item_list.at(i);-
350 if (item.skip())-
351 continue;-
352-
353 bool gap = item.flags & QDockAreaLayoutItem::GapItem;-
354-
355 QSize size_hint = item.sizeHint();-
356 min_perp = qMax(min_perp, perp(o, item.minimumSize()));-
357 max_perp = qMin(max_perp, perp(o, item.maximumSize()));-
358-
359-
360 if (tabbed) {-
361 a = qMax(a, gap ? item.size : pick(o, size_hint));-
362 } else-
363-
364 {-
365 if (previous && !gap && !(previous->flags & QDockAreaLayoutItem::GapItem)-
366 && !previous->hasFixedSize(o)) {-
367 a += *sep;-
368 }-
369 a += gap ? item.size : pick(o, size_hint);-
370 }-
371 b = qMax(b, perp(o, size_hint));-
372-
373 previous = &item;-
374 }-
375-
376 max_perp = qMax(max_perp, min_perp);-
377 b = qMax(b, min_perp);-
378 b = qMin(b, max_perp);-
379-
380 QSize result;-
381 rpick(o, result) = a;-
382 rperp(o, result) = b;-
383-
384-
385 if (tabbed) {-
386 QSize tbh = tabBarSizeHint();-
387 switch (tabBarShape) {-
388 case QTabBar::RoundedNorth:-
389 case QTabBar::RoundedSouth:-
390 case QTabBar::TriangularNorth:-
391 case QTabBar::TriangularSouth:-
392 result.rheight() += tbh.height();-
393 result.rwidth() = qMax(tbh.width(), result.width());-
394 break;-
395 case QTabBar::RoundedEast:-
396 case QTabBar::RoundedWest:-
397 case QTabBar::TriangularEast:-
398 case QTabBar::TriangularWest:-
399 result.rheight() = qMax(tbh.height(), result.height());-
400 result.rwidth() += tbh.width();-
401 break;-
402 default:-
403 break;-
404 }-
405 }-
406-
407-
408 return result;-
409}-
410-
411bool QDockAreaLayoutInfo::expansive(Qt::Orientation o) const-
412{-
413 for (int i = 0; i < item_list.size(); ++i) {-
414 if (item_list.at(i).expansive(o))-
415 return true;-
416 }-
417 return false;-
418}-
419static int realMinSize(const QDockAreaLayoutInfo &info)-
420{-
421 int result = 0;-
422 bool first = true;-
423 for (int i = 0; i < info.item_list.size(); ++i) {-
424 const QDockAreaLayoutItem &item = info.item_list.at(i);-
425 if (item.skip())-
426 continue;-
427-
428 int min = 0;-
429 if ((item.flags & QDockAreaLayoutItem::KeepSize) && item.size != -1)-
430 min = item.size;-
431 else-
432 min = pick(info.o, item.minimumSize());-
433-
434 if (!first)-
435 result += *info.sep;-
436 result += min;-
437-
438 first = false;-
439 }-
440-
441 return result;-
442}-
443-
444static int realMaxSize(const QDockAreaLayoutInfo &info)-
445{-
446 int result = 0;-
447 bool first = true;-
448 for (int i = 0; i < info.item_list.size(); ++i) {-
449 const QDockAreaLayoutItem &item = info.item_list.at(i);-
450 if (item.skip())-
451 continue;-
452-
453 int max = 0;-
454 if ((item.flags & QDockAreaLayoutItem::KeepSize) && item.size != -1)-
455 max = item.size;-
456 else-
457 max = pick(info.o, item.maximumSize());-
458-
459 if (!first)-
460 result += *info.sep;-
461 result += max;-
462-
463 if (result >= ((1<<24)-1))-
464 return ((1<<24)-1);-
465-
466 first = false;-
467 }-
468-
469 return result;-
470}-
471-
472void QDockAreaLayoutInfo::fitItems()-
473{-
474-
475 if (tabbed) {-
476 return;-
477 }-
478-
479-
480 QVector<QLayoutStruct> layout_struct_list(item_list.size()*2);-
481 int j = 0;-
482-
483 int size = pick(o, rect.size());-
484 int min_size = realMinSize(*this);-
485 int max_size = realMaxSize(*this);-
486 int last_index = -1;-
487-
488 const QDockAreaLayoutItem *previous = 0;-
489 for (int i = 0; i < item_list.size(); ++i) {-
490 QDockAreaLayoutItem &item = item_list[i];-
491 if (item.skip())-
492 continue;-
493-
494 bool gap = item.flags & QDockAreaLayoutItem::GapItem;-
495 if (previous && !gap) {-
496 if (!(previous->flags & QDockAreaLayoutItem::GapItem)) {-
497 QLayoutStruct &ls = layout_struct_list[j++];-
498 ls.init();-
499 ls.minimumSize = ls.maximumSize = ls.sizeHint = previous->hasFixedSize(o) ? 0 : *sep;-
500 ls.empty = false;-
501 }-
502 }-
503-
504 if (item.flags & QDockAreaLayoutItem::KeepSize) {-
505-
506-
507-
508 if (size < min_size) {-
509-
510 item.flags &= ~QDockAreaLayoutItem::KeepSize;-
511 min_size -= item.size;-
512 min_size += pick(o, item.minimumSize());-
513 min_size = qMax(0, min_size);-
514 } else if (size > max_size) {-
515-
516 item.flags &= ~QDockAreaLayoutItem::KeepSize;-
517 max_size -= item.size;-
518 max_size += pick(o, item.maximumSize());-
519 max_size = qMin<int>(((1<<24)-1), max_size);-
520 }-
521 }-
522-
523 last_index = j;-
524 QLayoutStruct &ls = layout_struct_list[j++];-
525 ls.init();-
526 ls.empty = false;-
527 if (item.flags & QDockAreaLayoutItem::KeepSize) {-
528 ls.minimumSize = ls.maximumSize = ls.sizeHint = item.size;-
529 ls.expansive = false;-
530 ls.stretch = 0;-
531 } else {-
532 ls.maximumSize = pick(o, item.maximumSize());-
533 ls.expansive = item.expansive(o);-
534 ls.minimumSize = pick(o, item.minimumSize());-
535 ls.sizeHint = item.size == -1 ? pick(o, item.sizeHint()) : item.size;-
536 ls.stretch = ls.expansive ? ls.sizeHint : 0;-
537 }-
538-
539 item.flags &= ~QDockAreaLayoutItem::KeepSize;-
540 previous = &item;-
541 }-
542 layout_struct_list.resize(j);-
543-
544-
545-
546 if (size > max_size && last_index != -1) {-
547 layout_struct_list[last_index].maximumSize = ((1<<24)-1);-
548 layout_struct_list[last_index].expansive = true;-
549 }-
550-
551 qGeomCalc(layout_struct_list, 0, j, pick(o, rect.topLeft()), size, 0);-
552-
553 j = 0;-
554 bool prev_gap = false;-
555 bool first = true;-
556 for (int i = 0; i < item_list.size(); ++i) {-
557 QDockAreaLayoutItem &item = item_list[i];-
558 if (item.skip())-
559 continue;-
560-
561 bool gap = item.flags & QDockAreaLayoutItem::GapItem;-
562 if (!first && !gap && !prev_gap)-
563 ++j;-
564-
565 const QLayoutStruct &ls = layout_struct_list.at(j++);-
566 item.size = ls.size;-
567 item.pos = ls.pos;-
568-
569 if (item.subinfo != 0) {-
570 item.subinfo->rect = itemRect(i);-
571 item.subinfo->fitItems();-
572 }-
573-
574 prev_gap = gap;-
575 first = false;-
576 }-
577}-
578-
579static QInternal::DockPosition dockPosHelper(const QRect &rect, const QPoint &_pos,-
580 Qt::Orientation o,-
581 bool nestingEnabled,-
582 QDockAreaLayoutInfo::TabMode tabMode)-
583{-
584 if (tabMode == QDockAreaLayoutInfo::ForceTabs)-
585 return QInternal::DockCount;-
586-
587 QPoint pos = _pos - rect.topLeft();-
588-
589 int x = pos.x();-
590 int y = pos.y();-
591 int w = rect.width();-
592 int h = rect.height();-
593-
594 if (tabMode != QDockAreaLayoutInfo::NoTabs) {-
595-
596 if (nestingEnabled) {-
597 QRect center(w/6, h/6, 2*w/3, 2*h/3);-
598 if (center.contains(pos))-
599 return QInternal::DockCount;-
600 } else if (o == Qt::Horizontal) {-
601 if (x > w/6 && x < w*5/6)-
602 return QInternal::DockCount;-
603 } else {-
604-
605-
606-
607-
608-
609-
610-
611 if (y > h/6 && y < 5*h/6)-
612 return QInternal::DockCount;-
613 }-
614 }-
615-
616-
617 if (nestingEnabled) {-
618 if (o == Qt::Horizontal) {-
619 if (x < w/3)-
620 return QInternal::LeftDock;-
621 if (x > 2*w/3)-
622 return QInternal::RightDock;-
623 if (y < h/2)-
624 return QInternal::TopDock;-
625 return QInternal::BottomDock;-
626 } else {-
627-
628-
629-
630-
631-
632-
633-
634 if (y < h/3)-
635 return QInternal::TopDock;-
636 if (y > 2*h/3)-
637 return QInternal::BottomDock;-
638 if (x < w/2)-
639 return QInternal::LeftDock;-
640 return QInternal::RightDock;-
641 }-
642 } else {-
643 if (o == Qt::Horizontal) {-
644 return x < w/2-
645 ? QInternal::LeftDock-
646 : QInternal::RightDock;-
647 } else {-
648 return y < h/2-
649 ? QInternal::TopDock-
650 : QInternal::BottomDock;-
651 }-
652 }-
653}-
654-
655QList<int> QDockAreaLayoutInfo::gapIndex(const QPoint& _pos,-
656 bool nestingEnabled, TabMode tabMode) const-
657{-
658 QList<int> result;-
659 QRect item_rect;-
660 int item_index = 0;-
661-
662-
663 if (tabbed) {-
664 item_rect = tabContentRect();-
665 } else-
666-
667 {-
668 int pos = pick(o, _pos);-
669-
670 int last = -1;-
671 for (int i = 0; i < item_list.size(); ++i) {-
672 const QDockAreaLayoutItem &item = item_list.at(i);-
673 if (item.skip())-
674 continue;-
675-
676 last = i;-
677-
678 if (item.pos + item.size < pos)-
679 continue;-
680-
681 if (item.subinfo != 0-
682-
683 && !item.subinfo->tabbed-
684-
685 ) {-
686 result = item.subinfo->gapIndex(_pos, nestingEnabled,-
687 tabMode);-
688 result.prepend(i);-
689 return result;-
690 }-
691-
692 item_rect = itemRect(i);-
693 item_index = i;-
694 break;-
695 }-
696-
697 if (item_rect.isNull()) {-
698 result.append(last + 1);-
699 return result;-
700 }-
701 }-
702-
703 ((!(!item_rect.isNull())) ? qt_assert("!item_rect.isNull()",__FILE__,787793) : qt_noop());-
704-
705 QInternal::DockPosition dock_pos-
706 = dockPosHelper(item_rect, _pos, o, nestingEnabled, tabMode);-
707-
708 switch (dock_pos) {-
709 case QInternal::LeftDock:-
710 if (o == Qt::Horizontal)-
711 result << item_index;-
712 else-
713 result << item_index << 0;-
714-
715 break;-
716 case QInternal::RightDock:-
717 if (o == Qt::Horizontal)-
718 result << item_index + 1;-
719 else-
720 result << item_index << 1;-
721 break;-
722 case QInternal::TopDock:-
723 if (o == Qt::Horizontal)-
724 result << item_index << 0;-
725 else-
726 result << item_index;-
727 break;-
728 case QInternal::BottomDock:-
729 if (o == Qt::Horizontal)-
730 result << item_index << 1;-
731 else-
732 result << item_index + 1;-
733 break;-
734 case QInternal::DockCount:-
735 result << (-item_index - 1) << 0;-
736-
737-
738 break;-
739 default:-
740 break;-
741 }-
742-
743 return result;-
744}-
745-
746static inline int shrink(QLayoutStruct &ls, int delta)-
747{-
748 if (ls.empty)-
749 return 0;-
750 int old_size = ls.size;-
751 ls.size = qMax(ls.size - delta, ls.minimumSize);-
752 return old_size - ls.size;-
753}-
754-
755static inline int grow(QLayoutStruct &ls, int delta)-
756{-
757 if (ls.empty)-
758 return 0;-
759 int old_size = ls.size;-
760 ls.size = qMin(ls.size + delta, ls.maximumSize);-
761 return ls.size - old_size;-
762}-
763-
764static int separatorMoveHelper(QVector<QLayoutStruct> &list, int index, int delta, int sep)-
765{-
766-
767 int pos = -1;-
768 for (int i = 0; i < list.size(); ++i) {-
769 const QLayoutStruct &ls = list.at(i);-
770 if (!ls.empty) {-
771 pos = ls.pos;-
772 break;-
773 }-
774 }-
775 if (pos == -1)-
776 return 0;-
777-
778 if (delta > 0) {-
779 int growlimit = 0;-
780 for (int i = 0; i<=index; ++i) {-
781 const QLayoutStruct &ls = list.at(i);-
782 if (ls.empty)-
783 continue;-
784 if (ls.maximumSize == QLAYOUTSIZE_MAX) {-
785 growlimit = QLAYOUTSIZE_MAX;-
786 break;-
787 }-
788 growlimit += ls.maximumSize - ls.size;-
789 }-
790 if (delta > growlimit)-
791 delta = growlimit;-
792-
793 int d = 0;-
794 for (int i = index + 1; d < delta && i < list.count(); ++i)-
795 d += shrink(list[i], delta - d);-
796 delta = d;-
797 d = 0;-
798 for (int i = index; d < delta && i >= 0; --i)-
799 d += grow(list[i], delta - d);-
800 } else if (delta < 0) {-
801 int growlimit = 0;-
802 for (int i = index + 1; i < list.count(); ++i) {-
803 const QLayoutStruct &ls = list.at(i);-
804 if (ls.empty)-
805 continue;-
806 if (ls.maximumSize == QLAYOUTSIZE_MAX) {-
807 growlimit = QLAYOUTSIZE_MAX;-
808 break;-
809 }-
810 growlimit += ls.maximumSize - ls.size;-
811 }-
812 if (-delta > growlimit)-
813 delta = -growlimit;-
814-
815 int d = 0;-
816 for (int i = index; d < -delta && i >= 0; --i)-
817 d += shrink(list[i], -delta - d);-
818 delta = -d;-
819 d = 0;-
820 for (int i = index + 1; d < -delta && i < list.count(); ++i)-
821 d += grow(list[i], -delta - d);-
822 }-
823-
824-
825 bool first = true;-
826 for (int i = 0; i < list.size(); ++i) {-
827 QLayoutStruct &ls = list[i];-
828 if (ls.empty) {-
829 ls.pos = pos + (first ? 0 : sep);-
830 continue;-
831 }-
832 if (!first)-
833 pos += sep;-
834 ls.pos = pos;-
835 pos += ls.size;-
836 first = false;-
837 }-
838-
839 return delta;-
840}-
841-
842int QDockAreaLayoutInfo::separatorMove(int index, int delta)-
843{-
844-
845 ((!(!tabbed)) ? qt_assert("!tabbed",__FILE__,929935) : qt_noop());-
846-
847-
848 QVector<QLayoutStruct> list(item_list.size());-
849 for (int i = 0; i < list.size(); ++i) {-
850 const QDockAreaLayoutItem &item = item_list.at(i);-
851 QLayoutStruct &ls = list[i];-
852 ((!(!(item.flags & QDockAreaLayoutItem::GapItem))) ? qt_assert("!(item.flags & QDockAreaLayoutItem::GapItem)",__FILE__,936942) : qt_noop());-
853 if (item.skip()) {-
854 ls.empty = true;-
855 } else {-
856 const int separatorSpace = item.hasFixedSize(o) ? 0 : *sep;-
857 ls.empty = false;-
858 ls.pos = item.pos;-
859 ls.size = item.size + separatorSpace;-
860 ls.minimumSize = pick(o, item.minimumSize()) + separatorSpace;-
861 ls.maximumSize = pick(o, item.maximumSize()) + separatorSpace;-
862-
863 }-
864 }-
865-
866-
867 delta = separatorMoveHelper(list, index, delta, 0 );-
868-
869 for (int i = 0; i < list.size(); ++i) {-
870 QDockAreaLayoutItem &item = item_list[i];-
871 if (item.skip())-
872 continue;-
873 QLayoutStruct &ls = list[i];-
874 const int separatorSpace = item.hasFixedSize(o) ? 0 : *sep;-
875 item.size = ls.size - separatorSpace;-
876 item.pos = ls.pos;-
877 if (item.subinfo != 0) {-
878 item.subinfo->rect = itemRect(i);-
879 item.subinfo->fitItems();-
880 }-
881 }-
882-
883 return delta;-
884}-
885-
886void QDockAreaLayoutInfo::unnest(int index)-
887{-
888 QDockAreaLayoutItem &item = item_list[index];-
889 if (item.subinfo == 0)-
890 return;-
891 if (item.subinfo->item_list.count() > 1)-
892 return;-
893-
894 if (item.subinfo->item_list.count() == 0) {-
895 item_list.removeAt(index);-
896 } else if (item.subinfo->item_list.count() == 1) {-
897 QDockAreaLayoutItem &child = item.subinfo->item_list.first();-
898 if (child.widgetItem != 0) {-
899 item.widgetItem = child.widgetItem;-
900 delete item.subinfo;-
901 item.subinfo = 0;-
902 } else if (child.subinfo != 0) {-
903 QDockAreaLayoutInfo *tmp = item.subinfo;-
904 item.subinfo = child.subinfo;-
905 child.subinfo = 0;-
906 tmp->item_list.clear();-
907 delete tmp;-
908 }-
909 }-
910}-
911-
912void QDockAreaLayoutInfo::remove(const QList<int> &path)-
913{-
914 ((!(!path.isEmpty())) ? qt_assert("!path.isEmpty()",__FILE__,9981004) : qt_noop());-
915-
916 if (path.count() > 1) {-
917 const int index = path.first();-
918 QDockAreaLayoutItem &item = item_list[index];-
919 ((!(item.subinfo != 0)) ? qt_assert("item.subinfo != 0",__FILE__,10031009) : qt_noop());-
920 item.subinfo->remove(path.mid(1));-
921 unnest(index);-
922 } else {-
923 int index = path.first();-
924 item_list.removeAt(index);-
925 }-
926}-
927-
928QLayoutItem *QDockAreaLayoutInfo::plug(const QList<int> &path)-
929{-
930 ((!(!path.isEmpty())) ? qt_assert("!path.isEmpty()",__FILE__,10141020) : qt_noop());-
931-
932 int index = path.first();-
933 if (index < 0)-
934 index = -index - 1;-
935-
936 if (path.count() > 1) {-
937 QDockAreaLayoutItem &item = item_list[index];-
938 ((!(item.subinfo != 0)) ? qt_assert("item.subinfo != 0",__FILE__,10221028) : qt_noop());-
939 return item.subinfo->plug(path.mid(1));-
940 }-
941-
942 QDockAreaLayoutItem &item = item_list[index];-
943-
944 ((!(item.widgetItem != 0)) ? qt_assert("item.widgetItem != 0",__FILE__,10281034) : qt_noop());-
945 ((!(item.flags & QDockAreaLayoutItem::GapItem)) ? qt_assert("item.flags & QDockAreaLayoutItem::GapItem",__FILE__,10291035) : qt_noop());-
946 item.flags &= ~QDockAreaLayoutItem::GapItem;-
947-
948 QRect result;-
949-
950-
951 if (tabbed) {-
952 } else-
953-
954 {-
955 int prev = this->prev(index);-
956 int next = this->next(index);-
957-
958 if (prev != -1 && !(item_list.at(prev).flags & QDockAreaLayoutItem::GapItem)) {-
959 item.pos += *sep;-
960 item.size -= *sep;-
961 }-
962 if (next != -1 && !(item_list.at(next).flags & QDockAreaLayoutItem::GapItem))-
963 item.size -= *sep;-
964-
965 QPoint pos;-
966 rpick(o, pos) = item.pos;-
967 rperp(o, pos) = perp(o, rect.topLeft());-
968 QSize s;-
969 rpick(o, s) = item.size;-
970 rperp(o, s) = perp(o, rect.size());-
971 result = QRect(pos, s);-
972 }-
973-
974 return item.widgetItem;-
975}-
976-
977QLayoutItem *QDockAreaLayoutInfo::unplug(const QList<int> &path)-
978{-
979 ((!(!path.isEmpty())) ? qt_assert("!path.isEmpty()",__FILE__,10631069) : qt_noop());-
980-
981 const int index = path.first();-
982 if (path.count() > 1) {-
983 QDockAreaLayoutItem &item = item_list[index];-
984 ((!(item.subinfo != 0)) ? qt_assert("item.subinfo != 0",__FILE__,10681074) : qt_noop());-
985 return item.subinfo->unplug(path.mid(1));-
986 }-
987-
988 QDockAreaLayoutItem &item = item_list[index];-
989 int prev = this->prev(index);-
990 int next = this->next(index);-
991-
992 ((!(!(item.flags & QDockAreaLayoutItem::GapItem))) ? qt_assert("!(item.flags & QDockAreaLayoutItem::GapItem)",__FILE__,10761082) : qt_noop());-
993 item.flags |= QDockAreaLayoutItem::GapItem;-
994-
995-
996 if (tabbed) {-
997 } else-
998-
999 {-
1000 if (prev != -1 && !(item_list.at(prev).flags & QDockAreaLayoutItem::GapItem)) {-
1001 item.pos -= *sep;-
1002 item.size += *sep;-
1003 }-
1004 if (next != -1 && !(item_list.at(next).flags & QDockAreaLayoutItem::GapItem))-
1005 item.size += *sep;-
1006 }-
1007-
1008 return item.widgetItem;-
1009}-
1010-
1011-
1012-
1013quintptr QDockAreaLayoutInfo::currentTabId() const-
1014{-
1015 if (!tabbed || tabBar == 0)-
1016 return 0;-
1017-
1018 int index = tabBar->currentIndex();-
1019 if (index == -1)-
1020 return 0;-
1021-
1022 return qvariant_cast<quintptr>(tabBar->tabData(index));-
1023}-
1024-
1025void QDockAreaLayoutInfo::setCurrentTab(QWidget *widget)-
1026{-
1027 setCurrentTabId(reinterpret_cast<quintptr>(widget));-
1028}-
1029-
1030void QDockAreaLayoutInfo::setCurrentTabId(quintptr id)-
1031{-
1032 if (!tabbed || tabBar == 0)-
1033 return;-
1034-
1035 for (int i = 0; i < tabBar->count(); ++i) {-
1036 if (qvariant_cast<quintptr>(tabBar->tabData(i)) == id) {-
1037 tabBar->setCurrentIndex(i);-
1038 return;-
1039 }-
1040 }-
1041}-
1042-
1043-
1044-
1045static QRect dockedGeometry(QWidget *widget)-
1046{-
1047 int titleHeight = 0;-
1048-
1049 QDockWidgetLayout *layout-
1050 = qobject_cast<QDockWidgetLayout*>(widget->layout());-
1051 if(layout != 0 && layout->nativeWindowDeco())-
1052 titleHeight = layout->titleHeight();-
1053-
1054 QRect result = widget->geometry();-
1055 result.adjust(0, -titleHeight, 0, 0);-
1056 return result;-
1057}-
1058-
1059bool QDockAreaLayoutInfo::insertGap(const QList<int> &path, QLayoutItem *dockWidgetItem)-
1060{-
1061 ((!(!path.isEmpty())) ? qt_assert("!path.isEmpty()",__FILE__,11451151) : qt_noop());-
1062-
1063 bool insert_tabbed = false;-
1064 int index = path.first();-
1065 if (index < 0) {-
1066 insert_tabbed = true;-
1067 index = -index - 1;-
1068 }-
1069-
1070-
1071-
1072 if (path.count() > 1) {-
1073 QDockAreaLayoutItem &item = item_list[index];-
1074-
1075 if (item.subinfo == 0-
1076-
1077 || (item.subinfo->tabbed && !insert_tabbed)-
1078-
1079 ) {-
1080-
1081-
1082-
1083 QDockAreaLayoutInfo *subinfo = item.subinfo;-
1084 QLayoutItem *widgetItem = item.widgetItem;-
1085 QPlaceHolderItem *placeHolderItem = item.placeHolderItem;-
1086 QRect r = subinfo == 0 ? widgetItem ? dockedGeometry(widgetItem->widget()) : placeHolderItem->topLevelRect : subinfo->rect;-
1087-
1088 Qt::Orientation opposite = o == Qt::Horizontal ? Qt::Vertical : Qt::Horizontal;-
1089-
1090-
1091-
1092 QDockAreaLayoutInfo *new_info-
1093 = new QDockAreaLayoutInfo(sep, dockPos, opposite, tabBarShape, mainWindow);-
1094-
1095-
1096 item.subinfo = new_info;-
1097 item.widgetItem = 0;-
1098 item.placeHolderItem = 0;-
1099-
1100 QDockAreaLayoutItem new_item-
1101 = widgetItem == 0-
1102 ? QDockAreaLayoutItem(subinfo)-
1103 : widgetItem ? QDockAreaLayoutItem(widgetItem) : QDockAreaLayoutItem(placeHolderItem);-
1104 new_item.size = pick(opposite, r.size());-
1105 new_item.pos = pick(opposite, r.topLeft());-
1106 new_info->item_list.append(new_item);-
1107-
1108 if (insert_tabbed) {-
1109 new_info->tabbed = true;-
1110 }-
1111-
1112 }-
1113-
1114 return item.subinfo->insertGap(path.mid(1), dockWidgetItem);-
1115 }-
1116-
1117-
1118 QDockAreaLayoutItem gap_item;-
1119 gap_item.flags |= QDockAreaLayoutItem::GapItem;-
1120 gap_item.widgetItem = dockWidgetItem;-
1121-
1122-
1123 if (!tabbed)-
1124-
1125 {-
1126 int prev = this->prev(index);-
1127 int next = this->next(index - 1);-
1128-
1129 int space = 0;-
1130 if (isEmpty()) {-
1131-
1132 switch (dockPos) {-
1133 case QInternal::LeftDock:-
1134 case QInternal::RightDock:-
1135 if (o == Qt::Vertical) {-
1136-
1137 space = pick(Qt::Vertical, rect.size());-
1138 } else {-
1139 space = pick(Qt::Horizontal, dockWidgetItem->widget()->size());-
1140 }-
1141 break;-
1142 case QInternal::TopDock:-
1143 case QInternal::BottomDock:-
1144 default:-
1145 if (o == Qt::Horizontal) {-
1146-
1147 space = pick(Qt::Horizontal, rect.size());-
1148 } else {-
1149 space = pick(Qt::Vertical, dockWidgetItem->widget()->size());-
1150 }-
1151 break;-
1152 }-
1153 } else {-
1154 for (int i = 0; i < item_list.count(); ++i) {-
1155 const QDockAreaLayoutItem &item = item_list.at(i);-
1156 if (item.skip())-
1157 continue;-
1158 ((!(!(item.flags & QDockAreaLayoutItem::GapItem))) ? qt_assert("!(item.flags & QDockAreaLayoutItem::GapItem)",__FILE__,12421248) : qt_noop());-
1159 space += item.size - pick(o, item.minimumSize());-
1160 }-
1161 }-
1162-
1163-
1164 int gap_size = 0;-
1165 int sep_size = 0;-
1166 if (isEmpty()) {-
1167 gap_size = space;-
1168 sep_size = 0;-
1169 } else {-
1170 QRect r = dockedGeometry(dockWidgetItem->widget());-
1171 gap_size = pick(o, r.size());-
1172 if (prev != -1 && !(item_list.at(prev).flags & QDockAreaLayoutItem::GapItem))-
1173 sep_size += *sep;-
1174 if (next != -1 && !(item_list.at(next).flags & QDockAreaLayoutItem::GapItem))-
1175 sep_size += *sep;-
1176 }-
1177 if (gap_size + sep_size > space)-
1178 gap_size = pick(o, gap_item.minimumSize());-
1179 gap_item.size = gap_size + sep_size;-
1180 }-
1181-
1182-
1183 item_list.insert(index, gap_item);-
1184-
1185-
1186-
1187 return true;-
1188}-
1189-
1190QDockAreaLayoutInfo *QDockAreaLayoutInfo::info(QWidget *widget)-
1191{-
1192 for (int i = 0; i < item_list.count(); ++i) {-
1193 const QDockAreaLayoutItem &item = item_list.at(i);-
1194 if (item.skip())-
1195 continue;-
1196-
1197-
1198 if (tabbed && widget == tabBar)-
1199 return this;-
1200-
1201-
1202 if (item.widgetItem != 0 && item.widgetItem->widget() == widget)-
1203 return this;-
1204-
1205 if (item.subinfo != 0) {-
1206 if (QDockAreaLayoutInfo *result = item.subinfo->info(widget))-
1207 return result;-
1208 }-
1209 }-
1210-
1211 return 0;-
1212}-
1213-
1214QDockAreaLayoutInfo *QDockAreaLayoutInfo::info(const QList<int> &path)-
1215{-
1216 int index = path.first();-
1217 if (index < 0)-
1218 index = -index - 1;-
1219 if (index >= item_list.count())-
1220 return this;-
1221 if (path.count() == 1 || item_list[index].subinfo == 0)-
1222 return this;-
1223 return item_list[index].subinfo->info(path.mid(1));-
1224}-
1225-
1226QRect QDockAreaLayoutInfo::itemRect(int index) const-
1227{-
1228 const QDockAreaLayoutItem &item = item_list.at(index);-
1229-
1230 if (item.skip())-
1231 return QRect();-
1232-
1233 QRect result;-
1234-
1235-
1236 if (tabbed) {-
1237 if (tabId(item) == currentTabId())-
1238 result = tabContentRect();-
1239 } else-
1240-
1241 {-
1242 QPoint pos;-
1243 rpick(o, pos) = item.pos;-
1244 rperp(o, pos) = perp(o, rect.topLeft());-
1245 QSize s;-
1246 rpick(o, s) = item.size;-
1247 rperp(o, s) = perp(o, rect.size());-
1248 result = QRect(pos, s);-
1249 }-
1250-
1251 return result;-
1252}-
1253-
1254QRect QDockAreaLayoutInfo::itemRect(const QList<int> &path) const-
1255{-
1256 ((!(!path.isEmpty())) ? qt_assert("!path.isEmpty()",__FILE__,13401346) : qt_noop());-
1257-
1258 const int index = path.first();-
1259 if (path.count() > 1) {-
1260 const QDockAreaLayoutItem &item = item_list.at(index);-
1261 ((!(item.subinfo != 0)) ? qt_assert("item.subinfo != 0",__FILE__,13451351) : qt_noop());-
1262 return item.subinfo->itemRect(path.mid(1));-
1263 }-
1264-
1265 return itemRect(index);-
1266}-
1267-
1268QRect QDockAreaLayoutInfo::separatorRect(int index) const-
1269{-
1270-
1271 if (tabbed)-
1272 return QRect();-
1273-
1274-
1275 const QDockAreaLayoutItem &item = item_list.at(index);-
1276 if (item.skip())-
1277 return QRect();-
1278-
1279 QPoint pos = rect.topLeft();-
1280 rpick(o, pos) = item.pos + item.size;-
1281 QSize s = rect.size();-
1282 rpick(o, s) = *sep;-
1283-
1284 return QRect(pos, s);-
1285}-
1286-
1287QRect QDockAreaLayoutInfo::separatorRect(const QList<int> &path) const-
1288{-
1289 ((!(!path.isEmpty())) ? qt_assert("!path.isEmpty()",__FILE__,13731379) : qt_noop());-
1290-
1291 const int index = path.first();-
1292 if (path.count() > 1) {-
1293 const QDockAreaLayoutItem &item = item_list.at(index);-
1294 ((!(item.subinfo != 0)) ? qt_assert("item.subinfo != 0",__FILE__,13781384) : qt_noop());-
1295 return item.subinfo->separatorRect(path.mid(1));-
1296 }-
1297 return separatorRect(index);-
1298}-
1299-
1300QList<int> QDockAreaLayoutInfo::findSeparator(const QPoint &_pos) const-
1301{-
1302-
1303 if (tabbed)-
1304 return QList<int>();-
1305-
1306-
1307 int pos = pick(o, _pos);-
1308-
1309 for (int i = 0; i < item_list.size(); ++i) {-
1310 const QDockAreaLayoutItem &item = item_list.at(i);-
1311 if (item.skip() || (item.flags & QDockAreaLayoutItem::GapItem))-
1312 continue;-
1313-
1314 if (item.pos + item.size > pos) {-
1315 if (item.subinfo != 0) {-
1316 QList<int> result = item.subinfo->findSeparator(_pos);-
1317 if (!result.isEmpty()) {-
1318 result.prepend(i);-
1319 return result;-
1320 } else {-
1321 return QList<int>();-
1322 }-
1323 }-
1324 }-
1325-
1326 int next = this->next(i);-
1327 if (next == -1 || (item_list.at(next).flags & QDockAreaLayoutItem::GapItem))-
1328 continue;-
1329-
1330 QRect sepRect = separatorRect(i);-
1331 if (!sepRect.isNull() && *sep == 1)-
1332 sepRect.adjust(-2, -2, 2, 2);-
1333-
1334 if (sepRect.contains(_pos) && !item.hasFixedSize(o)) {-
1335 return QList<int>() << i;-
1336 }-
1337-
1338 }-
1339-
1340 return QList<int>();-
1341}-
1342-
1343QList<int> QDockAreaLayoutInfo::indexOfPlaceHolder(const QString &objectName) const-
1344{-
1345 for (int i = 0; i < item_list.size(); ++i) {-
1346 const QDockAreaLayoutItem &item = item_list.at(i);-
1347-
1348 if (item.subinfo != 0) {-
1349 QList<int> result = item.subinfo->indexOfPlaceHolder(objectName);-
1350 if (!result.isEmpty()) {-
1351 result.prepend(i);-
1352 return result;-
1353 }-
1354 continue;-
1355 }-
1356-
1357 if (item.placeHolderItem != 0 && item.placeHolderItem->objectName == objectName) {-
1358 QList<int> result;-
1359 result << i;-
1360 return result;-
1361 }-
1362 }-
1363-
1364 return QList<int>();-
1365}-
1366-
1367QList<int> QDockAreaLayoutInfo::indexOf(QWidget *widget) const-
1368{-
1369 for (int i = 0; i < item_list.size(); ++i) {-
1370 const QDockAreaLayoutItem &item = item_list.at(i);-
1371-
1372 if (item.placeHolderItem != 0)-
1373 continue;-
1374-
1375 if (item.subinfo != 0) {-
1376 QList<int> result = item.subinfo->indexOf(widget);-
1377 if (!result.isEmpty()) {-
1378 result.prepend(i);-
1379 return result;-
1380 }-
1381 continue;-
1382 }-
1383-
1384 if (!(item.flags & QDockAreaLayoutItem::GapItem) && item.widgetItem && item.widgetItem->widget() == widget) {-
1385 QList<int> result;-
1386 result << i;-
1387 return result;-
1388 }-
1389 }-
1390-
1391 return QList<int>();-
1392}-
1393-
1394QMainWindowLayout *QDockAreaLayoutInfo::mainWindowLayout() const-
1395{-
1396 QMainWindowLayout *result = qt_mainwindow_layout(mainWindow);-
1397 ((!(result != 0)) ? qt_assert("result != 0",__FILE__,14811487) : qt_noop());-
1398 return result;-
1399}-
1400-
1401bool QDockAreaLayoutInfo::hasFixedSize() const-
1402{-
1403 return perp(o, minimumSize()) == perp(o, maximumSize());-
1404}-
1405-
1406-
1407void QDockAreaLayoutInfo::apply(bool animate)-
1408{-
1409 QWidgetAnimator &widgetAnimator = mainWindowLayout()->widgetAnimator;-
1410-
1411-
1412 if (tabbed) {-
1413 QRect tab_rect;-
1414 QSize tbh = tabBarSizeHint();-
1415-
1416 if (!tbh.isNull()) {-
1417 switch (tabBarShape) {-
1418 case QTabBar::RoundedNorth:-
1419 case QTabBar::TriangularNorth:-
1420 tab_rect = QRect(rect.left(), rect.top(), rect.width(), tbh.height());-
1421 break;-
1422 case QTabBar::RoundedSouth:-
1423 case QTabBar::TriangularSouth:-
1424 tab_rect = QRect(rect.left(), rect.bottom() - tbh.height() + 1,-
1425 rect.width(), tbh.height());-
1426 break;-
1427 case QTabBar::RoundedEast:-
1428 case QTabBar::TriangularEast:-
1429 tab_rect = QRect(rect.right() - tbh.width() + 1, rect.top(),-
1430 tbh.width(), rect.height());-
1431 break;-
1432 case QTabBar::RoundedWest:-
1433 case QTabBar::TriangularWest:-
1434 tab_rect = QRect(rect.left(), rect.top(),-
1435 tbh.width(), rect.height());-
1436 break;-
1437 default:-
1438 break;-
1439 }-
1440 }-
1441-
1442 widgetAnimator.animate(tabBar, tab_rect, animate);-
1443 }-
1444-
1445-
1446 for (int i = 0; i < item_list.size(); ++i) {-
1447 QDockAreaLayoutItem &item = item_list[i];-
1448-
1449 if (item.flags & QDockAreaLayoutItem::GapItem)-
1450 continue;-
1451-
1452 if (item.subinfo != 0) {-
1453 item.subinfo->apply(animate);-
1454 continue;-
1455 }-
1456-
1457 if (item.skip())-
1458 continue;-
1459-
1460 ((!(item.widgetItem)) ? qt_assert("item.widgetItem",__FILE__,15441550) : qt_noop());-
1461 QRect r = itemRect(i);-
1462 QWidget *w = item.widgetItem->widget();-
1463-
1464 QRect geo = w->geometry();-
1465 widgetAnimator.animate(w, r, animate);-
1466 if (!w->isHidden() && w->window()->isVisible()) {-
1467 QDockWidget *dw = qobject_cast<QDockWidget*>(w);-
1468 if (!r.isValid() && geo.right() >= 0 && geo.bottom() >= 0) {-
1469 dw->lower();-
1470 dw->visibilityChanged(false);-
1471 } else if (r.isValid()-
1472 && (geo.right() < 0 || geo.bottom() < 0)) {-
1473 dw->visibilityChanged(true);-
1474 }-
1475 }-
1476 }-
1477-
1478 if (*sep == 1)-
1479 updateSeparatorWidgets();-
1480-
1481}-
1482-
1483static void paintSep(QPainter *p, QWidget *w, const QRect &r, Qt::Orientation o, bool mouse_over)-
1484{-
1485 QStyleOption opt(0);-
1486 opt.state = QStyle::State_None;-
1487 if (w->isEnabled())-
1488 opt.state |= QStyle::State_Enabled;-
1489 if (o != Qt::Horizontal)-
1490 opt.state |= QStyle::State_Horizontal;-
1491 if (mouse_over)-
1492 opt.state |= QStyle::State_MouseOver;-
1493 opt.rect = r;-
1494 opt.palette = w->palette();-
1495-
1496 w->style()->drawPrimitive(QStyle::PE_IndicatorDockWidgetResizeHandle, &opt, p, w);-
1497}-
1498-
1499QRegion QDockAreaLayoutInfo::separatorRegion() const-
1500{-
1501 QRegion result;-
1502-
1503 if (isEmpty())-
1504 return result;-
1505-
1506 if (tabbed)-
1507 return result;-
1508-
1509-
1510 for (int i = 0; i < item_list.count(); ++i) {-
1511 const QDockAreaLayoutItem &item = item_list.at(i);-
1512-
1513 if (item.skip())-
1514 continue;-
1515-
1516 int next = this->next(i);-
1517-
1518 if (item.subinfo)-
1519 result |= item.subinfo->separatorRegion();-
1520-
1521 if (next == -1)-
1522 break;-
1523 result |= separatorRect(i);-
1524 }-
1525-
1526 return result;-
1527}-
1528-
1529void QDockAreaLayoutInfo::paintSeparators(QPainter *p, QWidget *widget,-
1530 const QRegion &clip,-
1531 const QPoint &mouse) const-
1532{-
1533 if (isEmpty())-
1534 return;-
1535-
1536 if (tabbed)-
1537 return;-
1538-
1539-
1540 for (int i = 0; i < item_list.count(); ++i) {-
1541 const QDockAreaLayoutItem &item = item_list.at(i);-
1542-
1543 if (item.skip())-
1544 continue;-
1545-
1546 int next = this->next(i);-
1547 if ((item.flags & QDockAreaLayoutItem::GapItem)-
1548 || (next != -1 && (item_list.at(next).flags & QDockAreaLayoutItem::GapItem)))-
1549 continue;-
1550-
1551 if (item.subinfo) {-
1552 if (clip.contains(item.subinfo->rect))-
1553 item.subinfo->paintSeparators(p, widget, clip, mouse);-
1554 }-
1555-
1556 if (next == -1)-
1557 break;-
1558 QRect r = separatorRect(i);-
1559 if (clip.contains(r) && !item.hasFixedSize(o))-
1560 paintSep(p, widget, r, o, r.contains(mouse));-
1561 }-
1562}-
1563-
1564int QDockAreaLayoutInfo::next(int index) const-
1565{-
1566 for (int i = index + 1; i < item_list.size(); ++i) {-
1567 if (!item_list.at(i).skip())-
1568 return i;-
1569 }-
1570 return -1;-
1571}-
1572-
1573int QDockAreaLayoutInfo::prev(int index) const-
1574{-
1575 for (int i = index - 1; i >= 0; --i) {-
1576 if (!item_list.at(i).skip())-
1577 return i;-
1578 }-
1579 return -1;-
1580}-
1581-
1582void QDockAreaLayoutInfo::tab(int index, QLayoutItem *dockWidgetItem)-
1583{-
1584-
1585-
1586-
1587-
1588 if (tabbed
tabbedDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1589 item_list.append(QDockAreaLayoutItem(dockWidgetItem));-
1590 updateTabBar();-
1591 setCurrentTab(dockWidgetItem->widget());-
1592 }
never executed: end of block
else {
0
1593 QDockAreaLayoutInfo *new_info-
1594 = new QDockAreaLayoutInfo(sep, dockPos, o, tabBarShape, mainWindow);-
1595 item_list[index].subinfo = new_info;-
1596 new_info->item_list.append(QDockAreaLayoutItem(item_list.at(index).widgetItem);));-
1597 item_list[index].widgetItem = 0;-
1598 new_info->item_list.append(QDockAreaLayoutItem(dockWidgetItem);));-
1599 new_info->tabbed = true;-
1600 new_info->updateTabBar();-
1601 new_info->setCurrentTab(dockWidgetItem->widget());-
1602 }
never executed: end of block
0
1603-
1604}-
1605-
1606void QDockAreaLayoutInfo::split(int index, Qt::Orientation orientation,-
1607 QLayoutItem *dockWidgetItem)-
1608{-
1609 if (orientation == o
orientation == oDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1610 item_list.insert(index + 1, QDockAreaLayoutItem(dockWidgetItem));-
1611 }
never executed: end of block
else {
0
1612-
1613-
1614-
1615 QDockAreaLayoutInfo *new_info-
1616 = new QDockAreaLayoutInfo(sep, dockPos, orientation, tabBarShape, mainWindow);-
1617 item_list[index].subinfo = new_info;-
1618 new_info->item_list.append(QDockAreaLayoutItem(item_list.at(index).widgetItem);));-
1619 item_list[index].widgetItem = 0;-
1620 new_info->item_list.append(QDockAreaLayoutItem(dockWidgetItem);));-
1621 }
never executed: end of block
0
1622}-
1623-
1624QDockAreaLayoutItem &QDockAreaLayoutInfo::item(const QList<int> &path)-
1625{-
1626 ((!(!path.isEmpty())) ? qt_assert("!path.isEmpty()",__FILE__,17101716) : qt_noop());-
1627 const int index = path.first();-
1628 if (path.count() > 1) {-
1629 const QDockAreaLayoutItem &item = item_list[index];-
1630 ((!(item.subinfo != 0)) ? qt_assert("item.subinfo != 0",__FILE__,17141720) : qt_noop());-
1631 return item.subinfo->item(path.mid(1));-
1632 }-
1633 return item_list[index];-
1634}-
1635-
1636QLayoutItem *QDockAreaLayoutInfo::itemAt(int *x, int index) const-
1637{-
1638 for (int i = 0; i < item_list.count(); ++i) {-
1639 const QDockAreaLayoutItem &item = item_list.at(i);-
1640 if (item.placeHolderItem != 0)-
1641 continue;-
1642 if (item.subinfo) {-
1643 if (QLayoutItem *ret = item.subinfo->itemAt(x, index))-
1644 return ret;-
1645 } else if (item.widgetItem) {-
1646 if ((*x)++ == index)-
1647 return item.widgetItem;-
1648 }-
1649 }-
1650 return 0;-
1651}-
1652-
1653QLayoutItem *QDockAreaLayoutInfo::takeAt(int *x, int index)-
1654{-
1655 for (int i = 0; i < item_list.count(); ++i) {-
1656 QDockAreaLayoutItem &item = item_list[i];-
1657 if (item.placeHolderItem != 0)-
1658 continue;-
1659 else if (item.subinfo) {-
1660 if (QLayoutItem *ret = item.subinfo->takeAt(x, index)) {-
1661 unnest(i);-
1662 return ret;-
1663 }-
1664 } else if (item.widgetItem) {-
1665 if ((*x)++ == index) {-
1666 item.placeHolderItem = new QPlaceHolderItem(item.widgetItem->widget());-
1667 QLayoutItem *ret = item.widgetItem;-
1668 item.widgetItem = 0;-
1669 if (item.size != -1)-
1670 item.flags |= QDockAreaLayoutItem::KeepSize;-
1671 return ret;-
1672 }-
1673 }-
1674 }-
1675 return 0;-
1676}-
1677-
1678void QDockAreaLayoutInfo::deleteAllLayoutItems()-
1679{-
1680 for (int i = 0; i < item_list.count(); ++i) {-
1681 QDockAreaLayoutItem &item= item_list[i];-
1682 if (item.subinfo) {-
1683 item.subinfo->deleteAllLayoutItems();-
1684 } else {-
1685 delete item.widgetItem;-
1686 item.widgetItem = 0;-
1687 }-
1688 }-
1689}-
1690-
1691void QDockAreaLayoutInfo::saveState(QDataStream &stream) const-
1692{-
1693-
1694 if (tabbed
tabbedDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1695 stream << (uchar) TabMarker;-
1696-
1697-
1698 quintptr id = currentTabId();-
1699 int index = -1;-
1700 for (int i = 0; i < item_list.count()
i < item_list.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
1701 if (tabId(item_list.at(i)) == id
tabId(item_list.at(i)) == idDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1702 index = i;-
1703 break;
never executed: break;
0
1704 }-
1705 }
never executed: end of block
0
1706 stream << index;-
1707 }
never executed: end of block
else
0
1708-
1709 {-
1710 stream << (uchar) SequenceMarker;-
1711 }
never executed: end of block
0
1712-
1713 stream << (uchar) o << item_list.count();-
1714-
1715 for (int i = 0; i < item_list.count()
i < item_list.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
1716 const QDockAreaLayoutItem &item = item_list.at(i);-
1717 if (item.widgetItem != 0
item.widgetItem != 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1718 stream << (uchar) WidgetMarker;-
1719 QWidget *w = item.widgetItem->widget();-
1720 QString name = w->objectName();-
1721 if (__builtin_expect(!!(
__builtin_expe...pty()), false)Description
TRUEnever evaluated
FALSEnever evaluated
name.isEmpty())()), false)
__builtin_expe...pty()), false)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1722 QMessageLogger(__FILE__, 18061812, __PRETTY_FUNCTION__).warning("QMainWindow::saveState(): 'objectName' not set for QDockWidget %p '%s'%ls;",-
1723 w, static_cast<const wchar_t*>(static_cast<const void*>(QString(w->windowTitle()).toLocal8Bit().constData());utf16())));-
1724 }
never executed: end of block
0
1725 stream << name;-
1726-
1727 uchar flags = 0;-
1728 if (!w->isHidden()
!w->isHidden()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1729 flags |= StateFlagVisible;
never executed: flags |= StateFlagVisible;
0
1730 if (w->isWindow()
w->isWindow()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1731 flags |= StateFlagFloating;
never executed: flags |= StateFlagFloating;
0
1732 stream << flags;-
1733-
1734 if (w->isWindow()
w->isWindow()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1735 const QRect geometry = w->geometry();-
1736 stream << geometry.x() << geometry.y() << geometry.width() << geometry.height();-
1737 }
never executed: end of block
else {
0
1738 stream << item.pos << item.size << pick(o, item.minimumSize())-
1739 << pick(o, item.maximumSize());-
1740 }
never executed: end of block
0
1741 } else if (item.placeHolderItem != 0
item.placeHolderItem != 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1742 stream << (uchar) WidgetMarker;-
1743 stream << item.placeHolderItem->objectName;-
1744 uchar flags = 0;-
1745 if (!item.placeHolderItem->hidden
!item.placeHolderItem->hiddenDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1746 flags |= StateFlagVisible;
never executed: flags |= StateFlagVisible;
0
1747 if (item.placeHolderItem->window
item.placeHolderItem->windowDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1748 flags |= StateFlagFloating;
never executed: flags |= StateFlagFloating;
0
1749 stream << flags;-
1750 if (item.placeHolderItem->window
item.placeHolderItem->windowDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1751 QRect r = item.placeHolderItem->topLevelRect;-
1752 stream << r.x() << r.y() << r.width() << r.height();-
1753 }
never executed: end of block
else {
0
1754 stream << item.pos << item.size << (int)0 << (int)0;-
1755 }
never executed: end of block
0
1756 } else if (item.subinfo != 0
item.subinfo != 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1757 stream << (uchar) SequenceMarker << item.pos << item.size << pick(o, item.minimumSize()) << pick(o, item.maximumSize());-
1758 item.subinfo->saveState(stream);-
1759 }
never executed: end of block
0
1760 }
never executed: end of block
0
1761}
never executed: end of block
0
1762-
1763static Qt::DockWidgetArea toDockWidgetArea(QInternal::DockPosition pos)-
1764{-
1765 switch (pos) {-
1766 case QInternal::LeftDock: return Qt::LeftDockWidgetArea;-
1767 case QInternal::RightDock: return Qt::RightDockWidgetArea;-
1768 case QInternal::TopDock: return Qt::TopDockWidgetArea;-
1769 case QInternal::BottomDock: return Qt::BottomDockWidgetArea;-
1770 default: break;-
1771 }-
1772 return Qt::NoDockWidgetArea;-
1773}-
1774-
1775bool QDockAreaLayoutInfo::restoreState(QDataStream &stream, QList<QDockWidget*> &widgets, bool testing)-
1776{-
1777 uchar marker;-
1778 stream >> marker;-
1779 if (marker != TabMarker && marker != SequenceMarker)-
1780 return false;-
1781-
1782-
1783 tabbed = marker == TabMarker;-
1784-
1785 int index = -1;-
1786 if (tabbed)-
1787 stream >> index;-
1788-
1789-
1790 uchar orientation;-
1791 stream >> orientation;-
1792 o = static_cast<Qt::Orientation>(orientation);-
1793-
1794 int cnt;-
1795 stream >> cnt;-
1796-
1797 for (int i = 0; i < cnt; ++i) {-
1798 uchar nextMarker;-
1799 stream >> nextMarker;-
1800 if (nextMarker == WidgetMarker) {-
1801 QString name;-
1802 uchar flags;-
1803 stream >> name >> flags;-
1804 if (name.isEmpty()) {-
1805 int dummy;-
1806 stream >> dummy >> dummy >> dummy >> dummy;-
1807 continue;-
1808 }-
1809-
1810 QDockWidget *widget = 0;-
1811 for (int j = 0; j < widgets.count(); ++j) {-
1812 if (widgets.at(j)->objectName() == name) {-
1813 widget = widgets.takeAt(j);-
1814 break;-
1815 }-
1816 }-
1817-
1818 if (widget == 0) {-
1819 QPlaceHolderItem *placeHolder = new QPlaceHolderItem;-
1820 QDockAreaLayoutItem item(placeHolder);-
1821-
1822 placeHolder->objectName = name;-
1823 placeHolder->window = flags & StateFlagFloating;-
1824 placeHolder->hidden = !(flags & StateFlagVisible);-
1825 if (placeHolder->window) {-
1826 int x, y, w, h;-
1827 stream >> x >> y >> w >> h;-
1828 placeHolder->topLevelRect = QRect(x, y, w, h);-
1829 } else {-
1830 int dummy;-
1831 stream >> item.pos >> item.size >> dummy >> dummy;-
1832 }-
1833 if (item.size != -1)-
1834 item.flags |= QDockAreaLayoutItem::KeepSize;-
1835 if (!testing)-
1836 item_list.append(item);-
1837 } else {-
1838 QDockAreaLayoutItem item(new QDockWidgetItem(widget));-
1839 if (flags & StateFlagFloating) {-
1840 bool drawer = false;-
1841-
1842-
1843-
1844-
1845-
1846-
1847 if (!testing) {-
1848 widget->hide();-
1849 if (!drawer)-
1850 widget->setFloating(true);-
1851 }-
1852-
1853 int x, y, w, h;-
1854 stream >> x >> y >> w >> h;-
1855 if (!testing)-
1856 widget->setGeometry(QDockAreaLayout::constrainedRect(QRect(x, y, w, h), widget));-
1857-
1858 if (!testing) {-
1859 widget->setVisible(flags & StateFlagVisible);-
1860 item_list.append(item);-
1861 }-
1862 } else {-
1863 int dummy;-
1864 stream >> item.pos >> item.size >> dummy >> dummy;-
1865 if (!testing) {-
1866 item_list.append(item);-
1867 widget->setFloating(false);-
1868 widget->setVisible(flags & StateFlagVisible);-
1869 widget->dockLocationChanged(toDockWidgetArea(dockPos));-
1870 }-
1871 }-
1872 if (testing) {-
1873-
1874 delete item.widgetItem;-
1875 }-
1876 }-
1877 } else if (nextMarker == SequenceMarker) {-
1878 int dummy;-
1879-
1880-
1881-
1882 QDockAreaLayoutItem item(new QDockAreaLayoutInfo(sep, dockPos, o,-
1883 tabBarShape, mainWindow));-
1884 stream >> item.pos >> item.size >> dummy >> dummy;-
1885-
1886 if (!testing)-
1887 item_list.append(item);-
1888-
1889-
1890 QDockAreaLayoutItem &lastItem = testing ? item : item_list.last();-
1891-
1892 if (!lastItem.subinfo->restoreState(stream, widgets, testing))-
1893 return false;-
1894-
1895 } else {-
1896 return false;-
1897 }-
1898 }-
1899-
1900-
1901 if (!testing && tabbed && index >= 0 && index < item_list.count()) {-
1902 updateTabBar();-
1903 setCurrentTabId(tabId(item_list.at(index)));-
1904 }-
1905 if (!testing && *sep == 1)-
1906 updateSeparatorWidgets();-
1907-
1908-
1909 return true;-
1910}-
1911-
1912-
1913void QDockAreaLayoutInfo::updateSeparatorWidgets() const-
1914{-
1915 if (tabbed) {-
1916 separatorWidgets.clear();-
1917 return;-
1918 }-
1919-
1920 int j = 0;-
1921 for (int i = 0; i < item_list.count(); ++i) {-
1922 const QDockAreaLayoutItem &item = item_list.at(i);-
1923-
1924 if (item.skip())-
1925 continue;-
1926-
1927 int next = this->next(i);-
1928 if ((item.flags & QDockAreaLayoutItem::GapItem)-
1929 || (next != -1 && (item_list.at(next).flags & QDockAreaLayoutItem::GapItem)))-
1930 continue;-
1931-
1932 if (item.subinfo) {-
1933 item.subinfo->updateSeparatorWidgets();-
1934 }-
1935-
1936 if (next == -1)-
1937 break;-
1938-
1939 QWidget *sepWidget;-
1940 if (j < separatorWidgets.size() && separatorWidgets.at(j)) {-
1941 sepWidget = separatorWidgets.at(j);-
1942 } else {-
1943 sepWidget = mainWindowLayout()->getSeparatorWidget();-
1944 separatorWidgets.append(sepWidget);-
1945 }-
1946 j++;-
1947-
1948-
1949 sepWidget->raise();-
1950-
1951 QRect sepRect = separatorRect(i).adjusted(-2, -2, 2, 2);-
1952 sepWidget->setGeometry(sepRect);-
1953 sepWidget->setMask( QRegion(separatorRect(i).translated( - sepRect.topLeft())));-
1954 sepWidget->show();-
1955 }-
1956-
1957 for (int k = j; k < separatorWidgets.size(); ++k) {-
1958 separatorWidgets[k]->hide();-
1959 }-
1960 separatorWidgets.resize(j);-
1961 ((!(separatorWidgets.size() == j)) ? qt_assert("separatorWidgets.size() == j",__FILE__,20532059) : qt_noop());-
1962}-
1963void QDockAreaLayoutInfo::reparentWidgets(QWidget *parent)-
1964{-
1965 if (tabBar
tabBarDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1966 tabBar->setParent(parent);
never executed: tabBar->setParent(parent);
0
1967-
1968 for (int i = 0; i < item_list.count()
i < item_list.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
1969 const QDockAreaLayoutItem &item = item_list.at(i);-
1970 if (item.flags & QDockAreaLayoutItem::GapItem
item.flags & Q...tItem::GapItemDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1971 continue;
never executed: continue;
0
1972 if (item.skip()
item.skip()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1973 continue;
never executed: continue;
0
1974 if (item.subinfo
item.subinfoDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1975 item.subinfo->reparentWidgets(parent);
never executed: item.subinfo->reparentWidgets(parent);
0
1976 if (item.widgetItem
item.widgetItemDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1977 QWidget *w = item.widgetItem->widget();-
1978 if (qobject_cast<QDockWidgetGroupWindow *>(w))0
continue;if (w->parent() != parent
w->parent() != parentDescription
TRUEnever evaluated
FALSEnever evaluated
) {
1979 bool hidden = w->isHidden();-
1980 w->setParent(parent, w->windowFlags()););-
1981 if (!hidden
!hiddenDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1982 w->show();
never executed: w->show();
0
1983 }
never executed: end of block
0
1984 }
never executed: end of block
0
1985 }
never executed: end of block
0
1986}
never executed: end of block
0
1987-
1988-
1989bool QDockAreaLayoutInfo::updateTabBar() const-
1990{-
1991 if (!tabbed)-
1992 return false;-
1993-
1994 QDockAreaLayoutInfo *that = const_cast<QDockAreaLayoutInfo*>(this);-
1995-
1996 if (that->tabBar == 0) {-
1997 that->tabBar = mainWindowLayout()->getTabBar();-
1998 that->tabBar->setShape(static_cast<QTabBar::Shape>(tabBarShape));-
1999 that->tabBar->setDrawBase(true);-
2000 }-
2001-
2002 const QSignalBlocker blocker(tabBar);-
2003 bool gap = false;-
2004-
2005 const quintptr oldCurrentId = currentTabId();-
2006-
2007 int tab_idx = 0;-
2008 for (int i = 0; i < item_list.count(); ++i) {-
2009 const QDockAreaLayoutItem &item = item_list.at(i);-
2010 if (item.skip())-
2011 continue;-
2012 if (item.flags & QDockAreaLayoutItem::GapItem) {-
2013 gap = true;-
2014 continue;-
2015 }-
2016 if (item.widgetItem == 0)-
2017 continue;-
2018-
2019 QDockWidget *dw = qobject_cast<QDockWidget*>(item.widgetItem->widget());-
2020 QString title = dw->d_func()->fixedWindowTitle;-
2021 quintptr id = tabId(item);-
2022 if (tab_idx == tabBar->count()) {-
2023 tabBar->insertTab(tab_idx, title);-
2024-
2025 tabBar->setTabToolTip(tab_idx, title);-
2026-
2027 tabBar->setTabData(tab_idx, id);-
2028 } else if (qvariant_cast<quintptr>(tabBar->tabData(tab_idx)) != id) {-
2029 if (tab_idx + 1 < tabBar->count()-
2030 && qvariant_cast<quintptr>(tabBar->tabData(tab_idx + 1)) == id)-
2031 tabBar->removeTab(tab_idx);-
2032 else {-
2033 tabBar->insertTab(tab_idx, title);-
2034-
2035 tabBar->setTabToolTip(tab_idx, title);-
2036-
2037 tabBar->setTabData(tab_idx, id);-
2038 }-
2039 }-
2040-
2041 if (title != tabBar->tabText(tab_idx)) {-
2042 tabBar->setTabText(tab_idx, title);-
2043-
2044 tabBar->setTabToolTip(tab_idx, title);-
2045-
2046 }-
2047-
2048 ++tab_idx;-
2049 }-
2050-
2051 while (tab_idx < tabBar->count()) {-
2052 tabBar->removeTab(tab_idx);-
2053 }-
2054-
2055 if (oldCurrentId > 0 && currentTabId() != oldCurrentId)-
2056 that->setCurrentTabId(oldCurrentId);-
2057-
2058 if (QDockWidgetGroupWindow *dwgw = qobject_cast<QDockWidgetGroupWindow *>(tabBar->parent()))-
2059 dwgw->adjustFlags();-
2060-
2061-
2062 return ( (gap ? 1 : 0) + tabBar->count()) > 1;-
2063}-
2064-
2065void QDockAreaLayoutInfo::setTabBarShape(int shape)-
2066{-
2067 if (shape == tabBarShape)-
2068 return;-
2069 tabBarShape = shape;-
2070 if (tabBar != 0)-
2071 tabBar->setShape(static_cast<QTabBar::Shape>(shape));-
2072-
2073 for (int i = 0; i < item_list.count(); ++i) {-
2074 QDockAreaLayoutItem &item = item_list[i];-
2075 if (item.subinfo != 0)-
2076 item.subinfo->setTabBarShape(shape);-
2077 }-
2078}-
2079-
2080QSize QDockAreaLayoutInfo::tabBarMinimumSize() const-
2081{-
2082 if (!updateTabBar())-
2083 return QSize(0, 0);-
2084-
2085 return tabBar->minimumSizeHint();-
2086}-
2087-
2088QSize QDockAreaLayoutInfo::tabBarSizeHint() const-
2089{-
2090 if (!updateTabBar())-
2091 return QSize(0, 0);-
2092-
2093 return tabBar->sizeHint();-
2094}-
2095-
2096QSet<QTabBar*> QDockAreaLayoutInfo::usedTabBars() const-
2097{-
2098 QSet<QTabBar*> result;-
2099-
2100 if (tabbed) {-
2101 updateTabBar();-
2102 result.insert(tabBar);-
2103 }-
2104-
2105 for (int i = 0; i < item_list.count(); ++i) {-
2106 const QDockAreaLayoutItem &item = item_list.at(i);-
2107 if (item.subinfo != 0)-
2108 result += item.subinfo->usedTabBars();-
2109 }-
2110-
2111 return result;-
2112}-
2113-
2114-
2115-
2116QSet<QWidget*> QDockAreaLayoutInfo::usedSeparatorWidgets() const-
2117{-
2118 QSet<QWidget*> result;-
2119 const int numSeparatorWidgets = separatorWidgets.count();-
2120 result.reserve(numSeparatorWidgets);-
2121-
2122 for (int i = 0; i < numSeparatorWidgets; ++i)-
2123 result << separatorWidgets.at(i);-
2124-
2125 for (int i = 0; i < item_list.count(); ++i) {-
2126 const QDockAreaLayoutItem &item = item_list.at(i);-
2127 if (item.subinfo != 0)-
2128 result += item.subinfo->usedSeparatorWidgets();-
2129 }-
2130-
2131 return result;-
2132}-
2133-
2134QRect QDockAreaLayoutInfo::tabContentRect() const-
2135{-
2136 if (!tabbed)-
2137 return QRect();-
2138-
2139 QRect result = rect;-
2140 QSize tbh = tabBarSizeHint();-
2141-
2142 if (!tbh.isNull()) {-
2143 switch (tabBarShape) {-
2144 case QTabBar::RoundedNorth:-
2145 case QTabBar::TriangularNorth:-
2146 result.adjust(0, tbh.height(), 0, 0);-
2147 break;-
2148 case QTabBar::RoundedSouth:-
2149 case QTabBar::TriangularSouth:-
2150 result.adjust(0, 0, 0, -tbh.height());-
2151 break;-
2152 case QTabBar::RoundedEast:-
2153 case QTabBar::TriangularEast:-
2154 result.adjust(0, 0, -tbh.width(), 0);-
2155 break;-
2156 case QTabBar::RoundedWest:-
2157 case QTabBar::TriangularWest:-
2158 result.adjust(tbh.width(), 0, 0, 0);-
2159 break;-
2160 default:-
2161 break;-
2162 }-
2163 }-
2164-
2165 return result;-
2166}-
2167-
2168int QDockAreaLayoutInfo::tabIndexToListIndex(int tabIndex) const-
2169{-
2170 ((!(tabbed && tabBar)) ? qt_assert("tabbed && tabBar",__FILE__,22702276) : qt_noop());-
2171 quintptr data = qvariant_cast<quintptr>(tabBar->tabData(tabIndex));-
2172 for (int i = 0; i < item_list.count(); ++i) {-
2173 if (tabId(item_list.at(i)) == data)-
2174 return i;-
2175 }-
2176 return -1;-
2177}-
2178-
2179void QDockAreaLayoutInfo::moveTab(int from, int to)-
2180{-
2181 item_list.move(tabIndexToListIndex(from), tabIndexToListIndex(to));-
2182}-
2183-
2184-
2185-
2186-
2187-
2188-
2189QDockAreaLayout::QDockAreaLayout(QMainWindow *win) : fallbackToSizeHints(true)-
2190{-
2191 mainWindow = win;-
2192 sep = win->style()->pixelMetric(QStyle::PM_DockWidgetSeparatorExtent, 0, win);-
2193-
2194 const int tabShape = QTabBar::RoundedSouth;-
2195-
2196-
2197-
2198 docks[QInternal::LeftDock]-
2199 = QDockAreaLayoutInfo(&sep, QInternal::LeftDock, Qt::Vertical, tabShape, win);-
2200 docks[QInternal::RightDock]-
2201 = QDockAreaLayoutInfo(&sep, QInternal::RightDock, Qt::Vertical, tabShape, win);-
2202 docks[QInternal::TopDock]-
2203 = QDockAreaLayoutInfo(&sep, QInternal::TopDock, Qt::Horizontal, tabShape, win);-
2204 docks[QInternal::BottomDock]-
2205 = QDockAreaLayoutInfo(&sep, QInternal::BottomDock, Qt::Horizontal, tabShape, win);-
2206 centralWidgetItem = 0;-
2207-
2208-
2209 corners[Qt::TopLeftCorner] = Qt::TopDockWidgetArea;-
2210 corners[Qt::TopRightCorner] = Qt::TopDockWidgetArea;-
2211 corners[Qt::BottomLeftCorner] = Qt::BottomDockWidgetArea;-
2212 corners[Qt::BottomRightCorner] = Qt::BottomDockWidgetArea;-
2213}-
2214-
2215bool QDockAreaLayout::isValid() const-
2216{-
2217 return rect.isValid();-
2218}-
2219-
2220void QDockAreaLayout::saveState(QDataStream &stream) const-
2221{-
2222 stream << (uchar) DockWidgetStateMarker;-
2223 int cnt = 0;-
2224 for (int i = 0; i < QInternal::DockCount; ++i) {-
2225 if (!docks[i].item_list.isEmpty())-
2226 ++cnt;-
2227 }-
2228 stream << cnt;-
2229 for (int i = 0; i < QInternal::DockCount; ++i) {-
2230 if (docks[i].item_list.isEmpty())-
2231 continue;-
2232 stream << i << docks[i].rect.size();-
2233 docks[i].saveState(stream);-
2234 }-
2235-
2236 stream << centralWidgetRect.size();-
2237-
2238 for (int i = 0; i < 4; ++i)-
2239 stream << static_cast<int>(corners[i]);-
2240}-
2241-
2242bool QDockAreaLayout::restoreState(QDataStream &stream, const QList<QDockWidget*> &_dockwidgets, bool testing)-
2243{-
2244 QList<QDockWidget*> dockwidgets = _dockwidgets;-
2245-
2246 int cnt;-
2247 stream >> cnt;-
2248 for (int i = 0; i < cnt; ++i) {-
2249 int pos;-
2250 stream >> pos;-
2251 QSize size;-
2252 stream >> size;-
2253 if (!testing) {-
2254 docks[pos].rect = QRect(QPoint(0, 0), size);-
2255 }-
2256 if (!docks[pos].restoreState(stream, dockwidgets, testing)) {-
2257 stream.setStatus(QDataStream::ReadCorruptData);-
2258 return false;-
2259 }-
2260 }-
2261-
2262 QSize size;-
2263 stream >> size;-
2264 centralWidgetRect = QRect(QPoint(0, 0), size);-
2265-
2266 bool ok = stream.status() == QDataStream::Ok;-
2267-
2268 if (ok) {-
2269 int cornerData[4];-
2270 for (int i = 0; i < 4; ++i)-
2271 stream >> cornerData[i];-
2272 if (stream.status() == QDataStream::Ok) {-
2273 for (int i = 0; i < 4; ++i)-
2274 corners[i] = static_cast<Qt::DockWidgetArea>(cornerData[i]);-
2275 }-
2276-
2277 if (!testing)-
2278 fallbackToSizeHints = false;-
2279 }-
2280-
2281 return ok;-
2282}-
2283-
2284QList<int> QDockAreaLayout::indexOfPlaceHolder(const QString &objectName) const-
2285{-
2286 for (int i = 0; i < QInternal::DockCount; ++i) {-
2287 QList<int> result = docks[i].indexOfPlaceHolder(objectName);-
2288 if (!result.isEmpty()) {-
2289 result.prepend(i);-
2290 return result;-
2291 }-
2292 }-
2293 return QList<int>();-
2294}-
2295-
2296QList<int> QDockAreaLayout::indexOf(QWidget *dockWidget) const-
2297{-
2298 for (int i = 0; i < QInternal::DockCount; ++i) {-
2299 QList<int> result = docks[i].indexOf(dockWidget);-
2300 if (!result.isEmpty()) {-
2301 result.prepend(i);-
2302 return result;-
2303 }-
2304 }-
2305 return QList<int>();-
2306}-
2307-
2308QList<int> QDockAreaLayout::gapIndex(const QPoint &pos) const-
2309{-
2310 QMainWindow::DockOptions opts = mainWindow->dockOptions();-
2311 bool nestingEnabled = opts & QMainWindow::AllowNestedDocks;-
2312 QDockAreaLayoutInfo::TabMode tabMode = QDockAreaLayoutInfo::NoTabs;-
2313-
2314 if (opts & QMainWindow::AllowTabbedDocks-
2315 || opts & QMainWindow::VerticalTabs)-
2316 tabMode = QDockAreaLayoutInfo::AllowTabs;-
2317 if (opts & QMainWindow::ForceTabbedDocks)-
2318 tabMode = QDockAreaLayoutInfo::ForceTabs;-
2319-
2320 if (tabMode == QDockAreaLayoutInfo::ForceTabs)-
2321 nestingEnabled = false;-
2322-
2323-
2324-
2325 for (int i = 0; i < QInternal::DockCount; ++i) {-
2326 const QDockAreaLayoutInfo &info = docks[i];-
2327-
2328 if (!info.isEmpty() && info.rect.contains(pos)) {-
2329 QList<int> result-
2330 = docks[i].gapIndex(pos, nestingEnabled, tabMode);-
2331 if (!result.isEmpty())-
2332 result.prepend(i);-
2333 return result;-
2334 }-
2335 }-
2336-
2337 for (int i = 0; i < QInternal::DockCount; ++i) {-
2338 const QDockAreaLayoutInfo &info = docks[i];-
2339-
2340 if (info.isEmpty()) {-
2341 QRect r;-
2342 switch (i) {-
2343 case QInternal::LeftDock:-
2344 r = QRect(rect.left(), rect.top(), EmptyDropAreaSize, rect.height());-
2345 break;-
2346 case QInternal::RightDock:-
2347 r = QRect(rect.right() - EmptyDropAreaSize, rect.top(),-
2348 EmptyDropAreaSize, rect.height());-
2349 break;-
2350 case QInternal::TopDock:-
2351 r = QRect(rect.left(), rect.top(), rect.width(), EmptyDropAreaSize);-
2352 break;-
2353 case QInternal::BottomDock:-
2354 r = QRect(rect.left(), rect.bottom() - EmptyDropAreaSize,-
2355 rect.width(), EmptyDropAreaSize);-
2356 break;-
2357 }-
2358 if (r.contains(pos)) {-
2359 if (opts & QMainWindow::ForceTabbedDocks && !info.item_list.isEmpty()) {-
2360-
2361-
2362 return QList<int>() << i << -1 << 0;-
2363 } else {-
2364 return QList<int>() << i << 0;-
2365 }-
2366 }-
2367 }-
2368 }-
2369-
2370 return QList<int>();-
2371}-
2372-
2373QList<int> QDockAreaLayout::findSeparator(const QPoint &pos) const-
2374{-
2375 QList<int> result;-
2376 for (int i = 0; i < QInternal::DockCount; ++i) {-
2377 const QDockAreaLayoutInfo &info = docks[i];-
2378 if (info.isEmpty())-
2379 continue;-
2380 QRect rect = separatorRect(i);-
2381 if (!rect.isNull() && sep == 1)-
2382 rect.adjust(-2, -2, 2, 2);-
2383 if (rect.contains(pos) && !info.hasFixedSize()) {-
2384 result << i;-
2385 break;-
2386 } else if (info.rect.contains(pos)) {-
2387 result = docks[i].findSeparator(pos);-
2388 if (!result.isEmpty()) {-
2389 result.prepend(i);-
2390 break;-
2391 }-
2392 }-
2393 }-
2394-
2395 return result;-
2396}-
2397-
2398QDockAreaLayoutInfo *QDockAreaLayout::info(QWidget *widget)-
2399{-
2400 for (int i = 0; i < QInternal::DockCount; ++i) {-
2401 if (QDockAreaLayoutInfo *result = docks[i].info(widget))-
2402 return result;-
2403 }-
2404-
2405 return 0;-
2406}-
2407-
2408QDockAreaLayoutInfo *QDockAreaLayout::info(const QList<int> &path)-
2409{-
2410 ((!(!path.isEmpty())) ? qt_assert("!path.isEmpty()",__FILE__,25102516) : qt_noop());-
2411 const int index = path.first();-
2412 ((!(index >= 0 && index < QInternal::DockCount)) ? qt_assert("index >= 0 && index < QInternal::DockCount",__FILE__,25122518) : qt_noop());-
2413-
2414 if (path.count() == 1)-
2415 return &docks[index];-
2416-
2417 return docks[index].info(path.mid(1));-
2418}-
2419-
2420const QDockAreaLayoutInfo *QDockAreaLayout::info(const QList<int> &path) const-
2421{-
2422 return const_cast<QDockAreaLayout*>(this)->info(path);-
2423}-
2424-
2425QDockAreaLayoutItem &QDockAreaLayout::item(const QList<int> &path)-
2426{-
2427 ((!(!path.isEmpty())) ? qt_assert("!path.isEmpty()",__FILE__,25272533) : qt_noop());-
2428 const int index = path.first();-
2429 ((!(index >= 0 && index < QInternal::DockCount)) ? qt_assert("index >= 0 && index < QInternal::DockCount",__FILE__,25292535) : qt_noop());-
2430 return docks[index].item(path.mid(1));-
2431}-
2432-
2433QRect QDockAreaLayout::itemRect(const QList<int> &path) const-
2434{-
2435 ((!(!path.isEmpty())) ? qt_assert("!path.isEmpty()",__FILE__,25352541) : qt_noop());-
2436 const int index = path.first();-
2437 ((!(index >= 0 && index < QInternal::DockCount)) ? qt_assert("index >= 0 && index < QInternal::DockCount",__FILE__,25372543) : qt_noop());-
2438 return docks[index].itemRect(path.mid(1));-
2439}-
2440-
2441QRect QDockAreaLayout::separatorRect(int index) const-
2442{-
2443 const QDockAreaLayoutInfo &dock = docks[index];-
2444 if (dock.isEmpty())-
2445 return QRect();-
2446 QRect r = dock.rect;-
2447 switch (index) {-
2448 case QInternal::LeftDock:-
2449 return QRect(r.right() + 1, r.top(), sep, r.height());-
2450 case QInternal::RightDock:-
2451 return QRect(r.left() - sep, r.top(), sep, r.height());-
2452 case QInternal::TopDock:-
2453 return QRect(r.left(), r.bottom() + 1, r.width(), sep);-
2454 case QInternal::BottomDock:-
2455 return QRect(r.left(), r.top() - sep, r.width(), sep);-
2456 default:-
2457 break;-
2458 }-
2459 return QRect();-
2460}-
2461-
2462QRect QDockAreaLayout::separatorRect(const QList<int> &path) const-
2463{-
2464 ((!(!path.isEmpty())) ? qt_assert("!path.isEmpty()",__FILE__,25642570) : qt_noop());-
2465-
2466 const int index = path.first();-
2467 ((!(index >= 0 && index < QInternal::DockCount)) ? qt_assert("index >= 0 && index < QInternal::DockCount",__FILE__,25672573) : qt_noop());-
2468-
2469 if (path.count() == 1)-
2470 return separatorRect(index);-
2471 else-
2472 return docks[index].separatorRect(path.mid(1));-
2473}-
2474-
2475bool QDockAreaLayout::insertGap(const QList<int> &path, QLayoutItem *dockWidgetItem)-
2476{-
2477 ((!(!path.isEmpty())) ? qt_assert("!path.isEmpty()",__FILE__,25772583) : qt_noop());-
2478 const int index = path.first();-
2479 ((!(index >= 0 && index < QInternal::DockCount)) ? qt_assert("index >= 0 && index < QInternal::DockCount",__FILE__,25792585) : qt_noop());-
2480 return docks[index].insertGap(path.mid(1), dockWidgetItem);-
2481}-
2482-
2483QLayoutItem *QDockAreaLayout::plug(const QList<int> &path)-
2484{-
2485 ((!(!path.isEmpty())) ? qt_assert("!path.isEmpty()",__FILE__,25852591) : qt_noop());-
2486 const int index = path.first();-
2487 ((!(index >= 0 && index < QInternal::DockCount)) ? qt_assert("index >= 0 && index < QInternal::DockCount",__FILE__,25872593) : qt_noop());-
2488 QLayoutItem *item =return
never executed: return docks[index].plug(path.mid(1));
never executed: return docks[index].plug(path.mid(1));
docks[index].plug(path.mid(1));
never executed: return docks[index].plug(path.mid(1));
0
docks[index].reparentWidgets(mainWindow);
return item;}
2490-
2491QLayoutItem *QDockAreaLayout::unplug(const QList<int> &path)-
2492{-
2493 ((!(!path.isEmpty())) ? qt_assert("!path.isEmpty()",__FILE__,25952599) : qt_noop());-
2494 const int index = path.first();-
2495 ((!(index >= 0 && index < QInternal::DockCount)) ? qt_assert("index >= 0 && index < QInternal::DockCount",__FILE__,25972601) : qt_noop());-
2496 return docks[index].unplug(path.mid(1));-
2497}-
2498-
2499void QDockAreaLayout::remove(const QList<int> &path)-
2500{-
2501 ((!(!path.isEmpty())) ? qt_assert("!path.isEmpty()",__FILE__,26032607) : qt_noop());-
2502 const int index = path.first();-
2503 ((!(index >= 0 && index < QInternal::DockCount)) ? qt_assert("index >= 0 && index < QInternal::DockCount",__FILE__,26052609) : qt_noop());-
2504 docks[index].remove(path.mid(1));-
2505}-
2506-
2507void QDockAreaLayout::removePlaceHolder(const QString &name)-
2508{-
2509 QList<int> index = indexOfPlaceHolder(name);-
2510 if (!index.isEmpty())-
2511 remove(index);-
2512 for (QForeachContainer<typename QtPrivate::remove_reference<decltype(mainWindow->findChildren<QDockWidgetGroupWindow *>( QString(), Qt::FindDirectChildrenOnly))>::type> _container_((mainWindow->findChildren<QDockWidgetGroupWindow *>( QString(), Qt::FindDirectChildrenOnly))); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (QDockWidgetGroupWindow *dwgw = *_container_.i; _container_.control; _container_.control = 0)-
2513 {-
2514 index = dwgw->layoutInfo()->indexOfPlaceHolder(name);-
2515 if (!index.isEmpty()) {-
2516 dwgw->layoutInfo()->remove(index);-
2517 dwgw->destroyOrHideIfEmpty();-
2518 }-
2519 }-
2520}-
2521-
2522static inline int qMax(int i1, int i2, int i3) { return qMax(i1, qMax(i2, i3)); }-
2523-
2524void QDockAreaLayout::getGrid(QVector<QLayoutStruct> *_ver_struct_list,-
2525 QVector<QLayoutStruct> *_hor_struct_list)-
2526{-
2527 QSize center_hint(0, 0);-
2528 QSize center_min(0, 0);-
2529 QSize center_max(0, 0);-
2530 const bool have_central = centralWidgetItem != 0 && !centralWidgetItem->isEmpty();-
2531 if (have_central) {-
2532 center_hint = centralWidgetRect.size();-
2533 if (!center_hint.isValid())-
2534 center_hint = centralWidgetItem->sizeHint();-
2535 center_min = centralWidgetItem->minimumSize();-
2536 center_max = centralWidgetItem->maximumSize();-
2537 }-
2538-
2539 QRect center_rect = rect;-
2540 if (!docks[QInternal::LeftDock].isEmpty())-
2541 center_rect.setLeft(rect.left() + docks[QInternal::LeftDock].rect.width() + sep);-
2542 if (!docks[QInternal::TopDock].isEmpty())-
2543 center_rect.setTop(rect.top() + docks[QInternal::TopDock].rect.height() + sep);-
2544 if (!docks[QInternal::RightDock].isEmpty())-
2545 center_rect.setRight(rect.right() - docks[QInternal::RightDock].rect.width() - sep);-
2546 if (!docks[QInternal::BottomDock].isEmpty())-
2547 center_rect.setBottom(rect.bottom() - docks[QInternal::BottomDock].rect.height() - sep);-
2548-
2549 QSize left_hint = docks[QInternal::LeftDock].size();-
2550 if (left_hint.isNull() || fallbackToSizeHints)-
2551 left_hint = docks[QInternal::LeftDock].sizeHint();-
2552 QSize left_min = docks[QInternal::LeftDock].minimumSize();-
2553 QSize left_max = docks[QInternal::LeftDock].maximumSize();-
2554 left_hint = left_hint.boundedTo(left_max).expandedTo(left_min);-
2555-
2556 QSize right_hint = docks[QInternal::RightDock].size();-
2557 if (right_hint.isNull() || fallbackToSizeHints)-
2558 right_hint = docks[QInternal::RightDock].sizeHint();-
2559 QSize right_min = docks[QInternal::RightDock].minimumSize();-
2560 QSize right_max = docks[QInternal::RightDock].maximumSize();-
2561 right_hint = right_hint.boundedTo(right_max).expandedTo(right_min);-
2562-
2563 QSize top_hint = docks[QInternal::TopDock].size();-
2564 if (top_hint.isNull() || fallbackToSizeHints)-
2565 top_hint = docks[QInternal::TopDock].sizeHint();-
2566 QSize top_min = docks[QInternal::TopDock].minimumSize();-
2567 QSize top_max = docks[QInternal::TopDock].maximumSize();-
2568 top_hint = top_hint.boundedTo(top_max).expandedTo(top_min);-
2569-
2570 QSize bottom_hint = docks[QInternal::BottomDock].size();-
2571 if (bottom_hint.isNull() || fallbackToSizeHints)-
2572 bottom_hint = docks[QInternal::BottomDock].sizeHint();-
2573 QSize bottom_min = docks[QInternal::BottomDock].minimumSize();-
2574 QSize bottom_max = docks[QInternal::BottomDock].maximumSize();-
2575 bottom_hint = bottom_hint.boundedTo(bottom_max).expandedTo(bottom_min);-
2576-
2577 if (_ver_struct_list != 0) {-
2578 QVector<QLayoutStruct> &ver_struct_list = *_ver_struct_list;-
2579 ver_struct_list.resize(3);-
2580-
2581-
2582 ver_struct_list[0].init();-
2583 ver_struct_list[0].stretch = 0;-
2584 ver_struct_list[0].sizeHint = top_hint.height();-
2585 ver_struct_list[0].minimumSize = top_min.height();-
2586 ver_struct_list[0].maximumSize = top_max.height();-
2587 ver_struct_list[0].expansive = false;-
2588 ver_struct_list[0].empty = docks[QInternal::TopDock].isEmpty();-
2589 ver_struct_list[0].pos = docks[QInternal::TopDock].rect.top();-
2590 ver_struct_list[0].size = docks[QInternal::TopDock].rect.height();-
2591-
2592-
2593 ver_struct_list[1].init();-
2594 ver_struct_list[1].stretch = center_hint.height();-
2595-
2596 bool tl_significant = corners[Qt::TopLeftCorner] == Qt::TopDockWidgetArea-
2597 || docks[QInternal::TopDock].isEmpty();-
2598 bool bl_significant = corners[Qt::BottomLeftCorner] == Qt::BottomDockWidgetArea-
2599 || docks[QInternal::BottomDock].isEmpty();-
2600 bool tr_significant = corners[Qt::TopRightCorner] == Qt::TopDockWidgetArea-
2601 || docks[QInternal::TopDock].isEmpty();-
2602 bool br_significant = corners[Qt::BottomRightCorner] == Qt::BottomDockWidgetArea-
2603 || docks[QInternal::BottomDock].isEmpty();-
2604-
2605 int left = (tl_significant && bl_significant) ? left_hint.height() : 0;-
2606 int right = (tr_significant && br_significant) ? right_hint.height() : 0;-
2607 ver_struct_list[1].sizeHint = qMax(left, center_hint.height(), right);-
2608-
2609 left = (tl_significant && bl_significant) ? left_min.height() : 0;-
2610 right = (tr_significant && br_significant) ? right_min.height() : 0;-
2611 ver_struct_list[1].minimumSize = qMax(left, center_min.height(), right);-
2612 ver_struct_list[1].maximumSize = center_max.height();-
2613 ver_struct_list[1].expansive = have_central;-
2614 ver_struct_list[1].empty = docks[QInternal::LeftDock].isEmpty()-
2615 && !have_central-
2616 && docks[QInternal::RightDock].isEmpty();-
2617 ver_struct_list[1].pos = center_rect.top();-
2618 ver_struct_list[1].size = center_rect.height();-
2619-
2620-
2621 ver_struct_list[2].init();-
2622 ver_struct_list[2].stretch = 0;-
2623 ver_struct_list[2].sizeHint = bottom_hint.height();-
2624 ver_struct_list[2].minimumSize = bottom_min.height();-
2625 ver_struct_list[2].maximumSize = bottom_max.height();-
2626 ver_struct_list[2].expansive = false;-
2627 ver_struct_list[2].empty = docks[QInternal::BottomDock].isEmpty();-
2628 ver_struct_list[2].pos = docks[QInternal::BottomDock].rect.top();-
2629 ver_struct_list[2].size = docks[QInternal::BottomDock].rect.height();-
2630-
2631 for (int i = 0; i < 3; ++i) {-
2632 ver_struct_list[i].sizeHint-
2633 = qMax(ver_struct_list[i].sizeHint, ver_struct_list[i].minimumSize);-
2634 }-
2635 if (have_central && ver_struct_list[0].empty && ver_struct_list[2].empty)-
2636 ver_struct_list[1].maximumSize = ((1<<24)-1);-
2637 }-
2638-
2639 if (_hor_struct_list != 0) {-
2640 QVector<QLayoutStruct> &hor_struct_list = *_hor_struct_list;-
2641 hor_struct_list.resize(3);-
2642-
2643-
2644 hor_struct_list[0].init();-
2645 hor_struct_list[0].stretch = 0;-
2646 hor_struct_list[0].sizeHint = left_hint.width();-
2647 hor_struct_list[0].minimumSize = left_min.width();-
2648 hor_struct_list[0].maximumSize = left_max.width();-
2649 hor_struct_list[0].expansive = false;-
2650 hor_struct_list[0].empty = docks[QInternal::LeftDock].isEmpty();-
2651 hor_struct_list[0].pos = docks[QInternal::LeftDock].rect.left();-
2652 hor_struct_list[0].size = docks[QInternal::LeftDock].rect.width();-
2653-
2654-
2655 hor_struct_list[1].init();-
2656 hor_struct_list[1].stretch = center_hint.width();-
2657-
2658 bool tl_significant = corners[Qt::TopLeftCorner] == Qt::LeftDockWidgetArea-
2659 || docks[QInternal::LeftDock].isEmpty();-
2660 bool tr_significant = corners[Qt::TopRightCorner] == Qt::RightDockWidgetArea-
2661 || docks[QInternal::RightDock].isEmpty();-
2662 bool bl_significant = corners[Qt::BottomLeftCorner] == Qt::LeftDockWidgetArea-
2663 || docks[QInternal::LeftDock].isEmpty();-
2664 bool br_significant = corners[Qt::BottomRightCorner] == Qt::RightDockWidgetArea-
2665 || docks[QInternal::RightDock].isEmpty();-
2666-
2667 int top = (tl_significant && tr_significant) ? top_hint.width() : 0;-
2668 int bottom = (bl_significant && br_significant) ? bottom_hint.width() : 0;-
2669 hor_struct_list[1].sizeHint = qMax(top, center_hint.width(), bottom);-
2670-
2671 top = (tl_significant && tr_significant) ? top_min.width() : 0;-
2672 bottom = (bl_significant && br_significant) ? bottom_min.width() : 0;-
2673 hor_struct_list[1].minimumSize = qMax(top, center_min.width(), bottom);-
2674-
2675 hor_struct_list[1].maximumSize = center_max.width();-
2676 hor_struct_list[1].expansive = have_central;-
2677 hor_struct_list[1].empty = !have_central;-
2678 hor_struct_list[1].pos = center_rect.left();-
2679 hor_struct_list[1].size = center_rect.width();-
2680-
2681-
2682 hor_struct_list[2].init();-
2683 hor_struct_list[2].stretch = 0;-
2684 hor_struct_list[2].sizeHint = right_hint.width();-
2685 hor_struct_list[2].minimumSize = right_min.width();-
2686 hor_struct_list[2].maximumSize = right_max.width();-
2687 hor_struct_list[2].expansive = false;-
2688 hor_struct_list[2].empty = docks[QInternal::RightDock].isEmpty();-
2689 hor_struct_list[2].pos = docks[QInternal::RightDock].rect.left();-
2690 hor_struct_list[2].size = docks[QInternal::RightDock].rect.width();-
2691-
2692 for (int i = 0; i < 3; ++i) {-
2693 hor_struct_list[i].sizeHint-
2694 = qMax(hor_struct_list[i].sizeHint, hor_struct_list[i].minimumSize);-
2695 }-
2696 if (have_central && hor_struct_list[0].empty && hor_struct_list[2].empty)-
2697 hor_struct_list[1].maximumSize = ((1<<24)-1);-
2698-
2699 }-
2700}-
2701-
2702void QDockAreaLayout::setGrid(QVector<QLayoutStruct> *ver_struct_list,-
2703 QVector<QLayoutStruct> *hor_struct_list)-
2704{-
2705-
2706-
2707-
2708 if (!docks[QInternal::TopDock].isEmpty()) {-
2709 QRect r = docks[QInternal::TopDock].rect;-
2710 if (hor_struct_list != 0) {-
2711 r.setLeft(corners[Qt::TopLeftCorner] == Qt::TopDockWidgetArea-
2712 || docks[QInternal::LeftDock].isEmpty()-
2713 ? rect.left() : hor_struct_list->at(1).pos);-
2714 r.setRight(corners[Qt::TopRightCorner] == Qt::TopDockWidgetArea-
2715 || docks[QInternal::RightDock].isEmpty()-
2716 ? rect.right() : hor_struct_list->at(2).pos - sep - 1);-
2717 }-
2718 if (ver_struct_list != 0) {-
2719 r.setTop(rect.top());-
2720 r.setBottom(ver_struct_list->at(1).pos - sep - 1);-
2721 }-
2722 docks[QInternal::TopDock].rect = r;-
2723 docks[QInternal::TopDock].fitItems();-
2724 }-
2725-
2726-
2727-
2728 if (!docks[QInternal::BottomDock].isEmpty()) {-
2729 QRect r = docks[QInternal::BottomDock].rect;-
2730 if (hor_struct_list != 0) {-
2731 r.setLeft(corners[Qt::BottomLeftCorner] == Qt::BottomDockWidgetArea-
2732 || docks[QInternal::LeftDock].isEmpty()-
2733 ? rect.left() : hor_struct_list->at(1).pos);-
2734 r.setRight(corners[Qt::BottomRightCorner] == Qt::BottomDockWidgetArea-
2735 || docks[QInternal::RightDock].isEmpty()-
2736 ? rect.right() : hor_struct_list->at(2).pos - sep - 1);-
2737 }-
2738 if (ver_struct_list != 0) {-
2739 r.setTop(ver_struct_list->at(2).pos);-
2740 r.setBottom(rect.bottom());-
2741 }-
2742 docks[QInternal::BottomDock].rect = r;-
2743 docks[QInternal::BottomDock].fitItems();-
2744 }-
2745-
2746-
2747-
2748 if (!docks[QInternal::LeftDock].isEmpty()) {-
2749 QRect r = docks[QInternal::LeftDock].rect;-
2750 if (hor_struct_list != 0) {-
2751 r.setLeft(rect.left());-
2752 r.setRight(hor_struct_list->at(1).pos - sep - 1);-
2753 }-
2754 if (ver_struct_list != 0) {-
2755 r.setTop(corners[Qt::TopLeftCorner] == Qt::LeftDockWidgetArea-
2756 || docks[QInternal::TopDock].isEmpty()-
2757 ? rect.top() : ver_struct_list->at(1).pos);-
2758 r.setBottom(corners[Qt::BottomLeftCorner] == Qt::LeftDockWidgetArea-
2759 || docks[QInternal::BottomDock].isEmpty()-
2760 ? rect.bottom() : ver_struct_list->at(2).pos - sep - 1);-
2761 }-
2762 docks[QInternal::LeftDock].rect = r;-
2763 docks[QInternal::LeftDock].fitItems();-
2764 }-
2765-
2766-
2767-
2768 if (!docks[QInternal::RightDock].isEmpty()) {-
2769 QRect r = docks[QInternal::RightDock].rect;-
2770 if (hor_struct_list != 0) {-
2771 r.setLeft(hor_struct_list->at(2).pos);-
2772 r.setRight(rect.right());-
2773 }-
2774 if (ver_struct_list != 0) {-
2775 r.setTop(corners[Qt::TopRightCorner] == Qt::RightDockWidgetArea-
2776 || docks[QInternal::TopDock].isEmpty()-
2777 ? rect.top() : ver_struct_list->at(1).pos);-
2778 r.setBottom(corners[Qt::BottomRightCorner] == Qt::RightDockWidgetArea-
2779 || docks[QInternal::BottomDock].isEmpty()-
2780 ? rect.bottom() : ver_struct_list->at(2).pos - sep - 1);-
2781 }-
2782 docks[QInternal::RightDock].rect = r;-
2783 docks[QInternal::RightDock].fitItems();-
2784 }-
2785-
2786-
2787-
2788 if (hor_struct_list != 0) {-
2789 centralWidgetRect.setLeft(hor_struct_list->at(1).pos);-
2790 centralWidgetRect.setWidth(hor_struct_list->at(1).size);-
2791 }-
2792 if (ver_struct_list != 0) {-
2793 centralWidgetRect.setTop(ver_struct_list->at(1).pos);-
2794 centralWidgetRect.setHeight(ver_struct_list->at(1).size);-
2795 }-
2796}-
2797-
2798void QDockAreaLayout::fitLayout()-
2799{-
2800 QVector<QLayoutStruct> ver_struct_list(3);-
2801 QVector<QLayoutStruct> hor_struct_list(3);-
2802 getGrid(&ver_struct_list, &hor_struct_list);-
2803-
2804 qGeomCalc(ver_struct_list, 0, 3, rect.top(), rect.height(), sep);-
2805 qGeomCalc(hor_struct_list, 0, 3, rect.left(), rect.width(), sep);-
2806-
2807 setGrid(&ver_struct_list, &hor_struct_list);-
2808}-
2809-
2810void QDockAreaLayout::clear()-
2811{-
2812 for (int i = 0; i < QInternal::DockCount; ++i)-
2813 docks[i].clear();-
2814-
2815 rect = QRect();-
2816 centralWidgetRect = QRect();-
2817}-
2818-
2819QSize QDockAreaLayout::sizeHint() const-
2820{-
2821 int left_sep = 0;-
2822 int right_sep = 0;-
2823 int top_sep = 0;-
2824 int bottom_sep = 0;-
2825-
2826 if (centralWidgetItem != 0) {-
2827 left_sep = docks[QInternal::LeftDock].isEmpty() ? 0 : sep;-
2828 right_sep = docks[QInternal::RightDock].isEmpty() ? 0 : sep;-
2829 top_sep = docks[QInternal::TopDock].isEmpty() ? 0 : sep;-
2830 bottom_sep = docks[QInternal::BottomDock].isEmpty() ? 0 : sep;-
2831 }-
2832-
2833 QSize left = docks[QInternal::LeftDock].sizeHint() + QSize(left_sep, 0);-
2834 QSize right = docks[QInternal::RightDock].sizeHint() + QSize(right_sep, 0);-
2835 QSize top = docks[QInternal::TopDock].sizeHint() + QSize(0, top_sep);-
2836 QSize bottom = docks[QInternal::BottomDock].sizeHint() + QSize(0, bottom_sep);-
2837 QSize center = centralWidgetItem == 0 ? QSize(0, 0) : centralWidgetItem->sizeHint();-
2838-
2839 int row1 = top.width();-
2840 int row2 = left.width() + center.width() + right.width();-
2841 int row3 = bottom.width();-
2842 int col1 = left.height();-
2843 int col2 = top.height() + center.height() + bottom.height();-
2844 int col3 = right.height();-
2845-
2846 if (corners[Qt::TopLeftCorner] == Qt::LeftDockWidgetArea)-
2847 row1 += left.width();-
2848 else-
2849 col1 += top.height();-
2850-
2851 if (corners[Qt::TopRightCorner] == Qt::RightDockWidgetArea)-
2852 row1 += right.width();-
2853 else-
2854 col3 += top.height();-
2855-
2856 if (corners[Qt::BottomLeftCorner] == Qt::LeftDockWidgetArea)-
2857 row3 += left.width();-
2858 else-
2859 col1 += bottom.height();-
2860-
2861 if (corners[Qt::BottomRightCorner] == Qt::RightDockWidgetArea)-
2862 row3 += right.width();-
2863 else-
2864 col3 += bottom.height();-
2865-
2866 return QSize(qMax(row1, row2, row3), qMax(col1, col2, col3));-
2867}-
2868-
2869QSize QDockAreaLayout::minimumSize() const-
2870{-
2871 int left_sep = 0;-
2872 int right_sep = 0;-
2873 int top_sep = 0;-
2874 int bottom_sep = 0;-
2875-
2876 if (centralWidgetItem != 0) {-
2877 left_sep = docks[QInternal::LeftDock].isEmpty() ? 0 : sep;-
2878 right_sep = docks[QInternal::RightDock].isEmpty() ? 0 : sep;-
2879 top_sep = docks[QInternal::TopDock].isEmpty() ? 0 : sep;-
2880 bottom_sep = docks[QInternal::BottomDock].isEmpty() ? 0 : sep;-
2881 }-
2882-
2883 QSize left = docks[QInternal::LeftDock].minimumSize() + QSize(left_sep, 0);-
2884 QSize right = docks[QInternal::RightDock].minimumSize() + QSize(right_sep, 0);-
2885 QSize top = docks[QInternal::TopDock].minimumSize() + QSize(0, top_sep);-
2886 QSize bottom = docks[QInternal::BottomDock].minimumSize() + QSize(0, bottom_sep);-
2887 QSize center = centralWidgetItem == 0 ? QSize(0, 0) : centralWidgetItem->minimumSize();-
2888-
2889 int row1 = top.width();-
2890 int row2 = left.width() + center.width() + right.width();-
2891 int row3 = bottom.width();-
2892 int col1 = left.height();-
2893 int col2 = top.height() + center.height() + bottom.height();-
2894 int col3 = right.height();-
2895-
2896 if (corners[Qt::TopLeftCorner] == Qt::LeftDockWidgetArea)-
2897 row1 += left.width();-
2898 else-
2899 col1 += top.height();-
2900-
2901 if (corners[Qt::TopRightCorner] == Qt::RightDockWidgetArea)-
2902 row1 += right.width();-
2903 else-
2904 col3 += top.height();-
2905-
2906 if (corners[Qt::BottomLeftCorner] == Qt::LeftDockWidgetArea)-
2907 row3 += left.width();-
2908 else-
2909 col1 += bottom.height();-
2910-
2911 if (corners[Qt::BottomRightCorner] == Qt::RightDockWidgetArea)-
2912 row3 += right.width();-
2913 else-
2914 col3 += bottom.height();-
2915-
2916 return QSize(qMax(row1, row2, row3), qMax(col1, col2, col3));-
2917}-
2918-
2919-
2920-
2921-
2922-
2923-
2924-
2925QRect QDockAreaLayout::constrainedRect(QRect rect, QWidget* widget)-
2926{-
2927 QRect desktop;-
2928 QDesktopWidget *desktopW = QApplication::desktop();-
2929 if (desktopW->isVirtualDesktop())-
2930 desktop = desktopW->screenGeometry(rect.topLeft());-
2931 else-
2932 desktop = desktopW->screenGeometry(widget);-
2933-
2934 if (desktop.isValid()) {-
2935 rect.setWidth(qMin(rect.width(), desktop.width()));-
2936 rect.setHeight(qMin(rect.height(), desktop.height()));-
2937 rect.moveLeft(qMax(rect.left(), desktop.left()));-
2938 rect.moveTop(qMax(rect.top(), desktop.top()));-
2939 rect.moveRight(qMin(rect.right(), desktop.right()));-
2940 rect.moveBottom(qMin(rect.bottom(), desktop.bottom()));-
2941 }-
2942-
2943 return rect;-
2944}-
2945-
2946bool QDockAreaLayout::restoreDockWidget(QDockWidget *dockWidget)-
2947{-
2948 QDockAreaLayoutItem *item = 0;-
2949 for (QForeachContainer<typename QtPrivate::remove_reference<decltype(mainWindow->findChildren<QDockWidgetGroupWindow *>( QString(), Qt::FindDirectChildrenOnly))>::type> _container_((mainWindow->findChildren<QDockWidgetGroupWindow *>( QString(), Qt::FindDirectChildrenOnly))); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (QDockWidgetGroupWindow *dwgw = *_container_.i; _container_.control; _container_.control = 0)-
2950 {-
2951 QList<int> index = dwgw->layoutInfo()->indexOfPlaceHolder(dockWidget->objectName());-
2952 if (!index.isEmpty()) {-
2953 dockWidget->setParent(dwgw);-
2954 item = const_cast<QDockAreaLayoutItem *>(&dwgw->layoutInfo()->item(index));-
2955 break;-
2956 }-
2957 }-
2958 if (!item) {-
2959 QList<int> index = indexOfPlaceHolder(dockWidget->objectName());-
2960 if (index.isEmpty())-
2961 return false;-
2962 item = const_cast<QDockAreaLayoutItem *>(&this->item(index));-
2963 }-
2964-
2965 QPlaceHolderItem *placeHolder = item->placeHolderItem;-
2966 ((!(placeHolder != 0)) ? qt_assert("placeHolder != 0",__FILE__,30683072) : qt_noop());-
2967-
2968 item->widgetItem = new QDockWidgetItem(dockWidget);-
2969-
2970 if (placeHolder->window) {-
2971 const QRect r = constrainedRect(placeHolder->topLevelRect, dockWidget);-
2972 dockWidget->d_func()->setWindowState(true, true, r);-
2973 }-
2974 dockWidget->setVisible(!placeHolder->hidden);-
2975-
2976-
2977-
2978-
2979-
2980 item->placeHolderItem = 0;-
2981 delete placeHolder;-
2982-
2983 return true;-
2984}-
2985-
2986void QDockAreaLayout::addDockWidget(QInternal::DockPosition pos, QDockWidget *dockWidget,-
2987 Qt::Orientation orientation)-
2988{-
2989 QLayoutItem *dockWidgetItem = new QDockWidgetItem(dockWidget);-
2990 QDockAreaLayoutInfo &info = docks[pos];-
2991 if (orientation == info.o
orientation == info.oDescription
TRUEnever evaluated
FALSEnever evaluated
|| info.item_list.count() <= 1
info.item_list.count() <= 1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2992-
2993-
2994 info.o = orientation;-
2995-
2996 QDockAreaLayoutItem new_item(dockWidgetItem);-
2997 info.item_list.append(new_item);-
2998-
2999 if (info.tabbed
info.tabbedDescription
TRUEnever evaluated
FALSEnever evaluated
&& !new_item.skip()
!new_item.skip()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
3000 info.updateTabBar();-
3001 info.setCurrentTabId(tabId(new_item));-
3002 }
never executed: end of block
0
3003-
3004 }
never executed: end of block
else {
0
3005-
3006 int tbshape = info.tabBarShape;-
3007-
3008-
3009-
3010 QDockAreaLayoutInfo new_info(&sep, pos, orientation, tbshape, mainWindow);-
3011 new_info.item_list.append(QDockAreaLayoutItem(new QDockAreaLayoutInfo(info));)));-
3012 new_info.item_list.append(QDockAreaLayoutItem(dockWidgetItem);));-
3013 info = new_info;-
3014 }
never executed: end of block
0
3015-
3016 removePlaceHolder(dockWidget->objectName());-
3017}
never executed: end of block
0
3018-
3019void QDockAreaLayout::tabifyDockWidget(QDockWidget *first, QDockWidget *second)-
3020{-
3021 const QList<int> path = indexOf(first);-
3022 if (path.isEmpty()
path.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
3023 return;
never executed: return;
0
3024-
3025 QDockAreaLayoutInfo *info = this->info(path);-
3026 ((!(info != 0)) ? qt_assert("info != 0",__FILE__,31283132) : qt_noop());-
3027 info->tab(path.last(), new QDockWidgetItem(second));-
3028-
3029 removePlaceHolder(second->objectName());-
3030}
never executed: end of block
0
3031-
3032void QDockAreaLayout::resizeDocks(const QList<QDockWidget *> &docks,-
3033 const QList<int> &sizes, Qt::Orientation o)-
3034{-
3035 if (__builtin_expect(!!(
__builtin_expe...unt()), false)Description
TRUEnever evaluated
FALSEnever evaluated
docks.count() != sizes.count())()), false)
__builtin_expe...unt()), false)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
3036 QMessageLogger(__FILE__, 31383142, __PRETTY_FUNCTION__).warning("QMainWidget::resizeDocks: size of the lists are not the same");-
3037 return;
never executed: return;
0
3038 }-
3039 int count = docks.count();-
3040 fallbackToSizeHints = false;-
3041 for (int i = 0; i < count
i < countDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
3042 QList<int> path = indexOf(docks[i]);-
3043 if (__builtin_expect(!!(
__builtin_expe...pty()), false)Description
TRUEnever evaluated
FALSEnever evaluated
path.isEmpty())()), false)
__builtin_expe...pty()), false)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
3044 QMessageLogger(__FILE__, 31463150, __PRETTY_FUNCTION__).warning("QMainWidget::resizeDocks: one QDockWidget is not part of the layout");-
3045 continue;
never executed: continue;
0
3046 }-
3047 int size = sizes[i];-
3048 if (__builtin_expect(!!(
__builtin_expe... <= 0), false)Description
TRUEnever evaluated
FALSEnever evaluated
size <= 0)), false)
__builtin_expe... <= 0), false)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
3049 QMessageLogger(__FILE__, 31513155, __PRETTY_FUNCTION__).warning("QMainWidget::resizeDocks: all sizes need to be larger than 0");-
3050 size = 1;-
3051 }
never executed: end of block
0
3052-
3053 while (path.size() > 1
path.size() > 1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
3054 QDockAreaLayoutInfo *info = this->info(path);-
3055 if (!info->tabbed
!info->tabbedDescription
TRUEnever evaluated
FALSEnever evaluated
&& info->o == o
info->o == oDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
3056 info->item_list[path.lastconstLast()].size = size;-
3057 int totalSize = 0;-
3058 for (QForeachContainer<typename QtPrivate::remove_reference<decltype(info->item_list)>::type> _container_((info->item_list)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (const QDockAreaLayoutItem &item = *_container_.i; _container_.control; _container_.control = 0) {-
3059 if (!item.skip()
!item.skip()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
3060 if (totalSize != 0
totalSize != 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
3061 totalSize += sep;
never executed: totalSize += sep;
0
3062 totalSize += item.size == -1
item.size == -1Description
TRUEnever evaluated
FALSEnever evaluated
? pick(o, item.sizeHint()) : item.size;
0
3063 }
never executed: end of block
0
3064 }
never executed: end of block
0
3065 size = totalSize;-
3066 }
never executed: end of block
0
3067 path.removeLast();-
3068 }
never executed: end of block
0
3069-
3070 const int dockNum = path.firstconstFirst();-
3071 ((!(dockNum < QInternal::DockCount)) ? qt_assert("dockNum < QInternal::DockCount",__FILE__,31733177) : qt_noop());-
3072 QRect &r = this->docks[dockNum].rect;-
3073 QSize s = r.size();-
3074 rpick(o, s) = size;-
3075 r.setSize(s);-
3076 }
never executed: end of block
0
3077}
never executed: end of block
0
3078-
3079void QDockAreaLayout::splitDockWidget(QDockWidget *after,-
3080 QDockWidget *dockWidget,-
3081 Qt::Orientation orientation)-
3082{-
3083 const QList<int> path = indexOf(after);-
3084 if (path.isEmpty()
path.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
3085 return;
never executed: return;
0
3086-
3087 QDockAreaLayoutInfo *info = this->info(path);-
3088 ((!(info != 0)) ? qt_assert("info != 0",__FILE__,31903194) : qt_noop());-
3089 info->split(path.last(), orientation, new QDockWidgetItem(dockWidget));-
3090-
3091 removePlaceHolder(dockWidget->objectName());-
3092}
never executed: end of block
0
3093-
3094void QDockAreaLayout::apply(bool animate)-
3095{-
3096 QWidgetAnimator &widgetAnimator = qt_mainwindow_layout(mainWindow)->widgetAnimator;-
3097-
3098 for (int i = 0; i < QInternal::DockCount; ++i)-
3099 docks[i].apply(animate);-
3100 if (centralWidgetItem != 0 && !centralWidgetItem->isEmpty()) {-
3101 widgetAnimator.animate(centralWidgetItem->widget(), centralWidgetRect,-
3102 animate);-
3103 }-
3104-
3105 if (sep == 1)-
3106 updateSeparatorWidgets();-
3107-
3108}-
3109-
3110void QDockAreaLayout::paintSeparators(QPainter *p, QWidget *widget,-
3111 const QRegion &clip,-
3112 const QPoint &mouse) const-
3113{-
3114 for (int i = 0; i < QInternal::DockCount; ++i) {-
3115 const QDockAreaLayoutInfo &dock = docks[i];-
3116 if (dock.isEmpty())-
3117 continue;-
3118 QRect r = separatorRect(i);-
3119 if (clip.contains(r) && !dock.hasFixedSize()) {-
3120 Qt::Orientation opposite = dock.o == Qt::Horizontal-
3121 ? Qt::Vertical : Qt::Horizontal;-
3122 paintSep(p, widget, r, opposite, r.contains(mouse));-
3123 }-
3124 if (clip.contains(dock.rect))-
3125 dock.paintSeparators(p, widget, clip, mouse);-
3126 }-
3127}-
3128-
3129QRegion QDockAreaLayout::separatorRegion() const-
3130{-
3131 QRegion result;-
3132-
3133 for (int i = 0; i < QInternal::DockCount; ++i) {-
3134 const QDockAreaLayoutInfo &dock = docks[i];-
3135 if (dock.isEmpty())-
3136 continue;-
3137 result |= separatorRect(i);-
3138 result |= dock.separatorRegion();-
3139 }-
3140-
3141 return result;-
3142}-
3143-
3144int QDockAreaLayout::separatorMove(const QList<int> &separator, const QPoint &origin,-
3145 const QPoint &dest)-
3146{-
3147 int delta = 0;-
3148 int index = separator.last();-
3149-
3150 if (separator.count() > 1) {-
3151 QDockAreaLayoutInfo *info = this->info(separator);-
3152 delta = pick(info->o, dest - origin);-
3153 if (delta != 0)-
3154 delta = info->separatorMove(index, delta);-
3155 info->apply(false);-
3156 return delta;-
3157 }-
3158-
3159 QVector<QLayoutStruct> list;-
3160-
3161 if (index == QInternal::LeftDock || index == QInternal::RightDock)-
3162 getGrid(0, &list);-
3163 else-
3164 getGrid(&list, 0);-
3165-
3166 int sep_index = index == QInternal::LeftDock || index == QInternal::TopDock-
3167 ? 0 : 1;-
3168 Qt::Orientation o = index == QInternal::LeftDock || index == QInternal::RightDock-
3169 ? Qt::Horizontal-
3170 : Qt::Vertical;-
3171-
3172 delta = pick(o, dest - origin);-
3173 delta = separatorMoveHelper(list, sep_index, delta, sep);-
3174-
3175 if (index == QInternal::LeftDock || index == QInternal::RightDock)-
3176 setGrid(0, &list);-
3177 else-
3178 setGrid(&list, 0);-
3179-
3180 apply(false);-
3181-
3182 return delta;-
3183}-
3184-
3185-
3186-
3187-
3188void QDockAreaLayout::updateSeparatorWidgets() const-
3189{-
3190 int j = 0;-
3191-
3192 for (int i = 0; i < QInternal::DockCount; ++i) {-
3193 const QDockAreaLayoutInfo &dock = docks[i];-
3194 if (dock.isEmpty())-
3195 continue;-
3196-
3197 QWidget *sepWidget;-
3198 if (j < separatorWidgets.size()) {-
3199 sepWidget = separatorWidgets.at(j);-
3200 } else {-
3201 sepWidget = qt_mainwindow_layout(mainWindow)->getSeparatorWidget();-
3202 separatorWidgets.append(sepWidget);-
3203 }-
3204 j++;-
3205-
3206-
3207 sepWidget->raise();-
3208-
3209 QRect sepRect = separatorRect(i).adjusted(-2, -2, 2, 2);-
3210 sepWidget->setGeometry(sepRect);-
3211 sepWidget->setMask( QRegion(separatorRect(i).translated( - sepRect.topLeft())));-
3212 sepWidget->show();-
3213 }-
3214 for (int i = j; i < separatorWidgets.size(); ++i)-
3215 separatorWidgets.at(i)->hide();-
3216-
3217 separatorWidgets.resize(j);-
3218}-
3219-
3220-
3221QLayoutItem *QDockAreaLayout::itemAt(int *x, int index) const-
3222{-
3223 ((!(x != 0)) ? qt_assert("x != 0",__FILE__,33253329) : qt_noop());-
3224-
3225 for (int i = 0; i < QInternal::DockCount; ++i) {-
3226 const QDockAreaLayoutInfo &dock = docks[i];-
3227 if (QLayoutItem *ret = dock.itemAt(x, index))-
3228 return ret;-
3229 }-
3230-
3231 if (centralWidgetItem && (*x)++ == index)-
3232 return centralWidgetItem;-
3233-
3234 return 0;-
3235}-
3236-
3237QLayoutItem *QDockAreaLayout::takeAt(int *x, int index)-
3238{-
3239 ((!(x != 0)) ? qt_assert("x != 0",__FILE__,33413345) : qt_noop());-
3240-
3241 for (int i = 0; i < QInternal::DockCount; ++i) {-
3242 QDockAreaLayoutInfo &dock = docks[i];-
3243 if (QLayoutItem *ret = dock.takeAt(x, index))-
3244 return ret;-
3245 }-
3246-
3247 if (centralWidgetItem && (*x)++ == index) {-
3248 QLayoutItem *ret = centralWidgetItem;-
3249 centralWidgetItem = 0;-
3250 return ret;-
3251 }-
3252-
3253 return 0;-
3254}-
3255-
3256void QDockAreaLayout::deleteAllLayoutItems()-
3257{-
3258 for (int i = 0; i < QInternal::DockCount; ++i)-
3259 docks[i].deleteAllLayoutItems();-
3260}-
3261-
3262-
3263QSet<QTabBar*> QDockAreaLayout::usedTabBars() const-
3264{-
3265 QSet<QTabBar*> result;-
3266 for (int i = 0; i < QInternal::DockCount; ++i) {-
3267 const QDockAreaLayoutInfo &dock = docks[i];-
3268 result += dock.usedTabBars();-
3269 }-
3270 return result;-
3271}-
3272-
3273-
3274QSet<QWidget*> QDockAreaLayout::usedSeparatorWidgets() const-
3275{-
3276 QSet<QWidget*> result;-
3277 const int numSeparators = separatorWidgets.count();-
3278 result.reserve(numSeparators);-
3279 for (int i = 0; i < numSeparators; ++i)-
3280 result << separatorWidgets.at(i);-
3281 for (int i = 0; i < QInternal::DockCount; ++i) {-
3282 const QDockAreaLayoutInfo &dock = docks[i];-
3283 result += dock.usedSeparatorWidgets();-
3284 }-
3285 return result;-
3286}-
3287-
3288-
3289QRect QDockAreaLayout::gapRect(const QList<int> &path) const-
3290{-
3291 const QDockAreaLayoutInfo *info = this->info(path);-
3292 if (info == 0)-
3293 return QRect();-
3294 const QList<QDockAreaLayoutItem> &item_list = info->item_list;-
3295 Qt::Orientation o = info->o;-
3296 int index = path.last();-
3297 if (index < 0 || index >= item_list.count())-
3298 return QRect();-
3299 const QDockAreaLayoutItem &item = item_list.at(index);-
3300 if (!(item.flags & QDockAreaLayoutItem::GapItem))-
3301 return QRect();-
3302-
3303 QRect result;-
3304-
3305-
3306 if (info->tabbed) {-
3307 result = info->tabContentRect();-
3308 } else-
3309-
3310 {-
3311 int pos = item.pos;-
3312 int size = item.size;-
3313-
3314 int prev = info->prev(index);-
3315 int next = info->next(index);-
3316-
3317 if (prev != -1 && !(item_list.at(prev).flags & QDockAreaLayoutItem::GapItem)) {-
3318 pos += sep;-
3319 size -= sep;-
3320 }-
3321 if (next != -1 && !(item_list.at(next).flags & QDockAreaLayoutItem::GapItem))-
3322 size -= sep;-
3323-
3324 QPoint p;-
3325 rpick(o, p) = pos;-
3326 rperp(o, p) = perp(o, info->rect.topLeft());-
3327 QSize s;-
3328 rpick(o, s) = size;-
3329 rperp(o, s) = perp(o, info->rect.size());-
3330-
3331 result = QRect(p, s);-
3332 }-
3333-
3334 return result;-
3335}-
3336-
3337void QDockAreaLayout::keepSize(QDockWidget *w)-
3338{-
3339 QList<int> path = indexOf(w);-
3340 if (path.isEmpty())-
3341 return;-
3342 QDockAreaLayoutItem &item = this->item(path);-
3343 if (item.size != -1)-
3344 item.flags |= QDockAreaLayoutItem::KeepSize;-
3345}-
3346-
3347void QDockAreaLayout::styleChangedEvent()-
3348{-
3349 sep = mainWindow->style()->pixelMetric(QStyle::PM_DockWidgetSeparatorExtent, 0, mainWindow);-
3350 if (isValid())-
3351 fitLayout();-
3352}-
3353-
3354-
Switch to Source codePreprocessed file

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