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