Qt 4.8
Public Types | Public Functions | Public Variables | List of all members
QDockAreaLayoutInfo Class Reference

#include <qdockarealayout_p.h>

Public Types

enum  { SequenceMarker = 0xfc, TabMarker = 0xfa, WidgetMarker = 0xfb }
 
enum  TabMode { NoTabs, AllowTabs, ForceTabs }
 

Public Functions

void apply (bool animate)
 
int changeSize (int index, int size, bool below)
 
void clear ()
 
quintptr currentTabId () const
 
void deleteAllLayoutItems ()
 
bool expansive (Qt::Orientation o) const
 
QList< int > findSeparator (const QPoint &pos) const
 
void fitItems ()
 
QList< int > gapIndex (const QPoint &pos, bool nestingEnabled, TabMode tabMode) const
 
bool hasFixedSize () const
 
QList< int > indexOf (QWidget *widget) const
 
QList< int > indexOfPlaceHolder (const QString &objectName) const
 
QDockAreaLayoutInfoinfo (const QList< int > &path)
 
QDockAreaLayoutInfoinfo (QWidget *widget)
 
bool insertGap (const QList< int > &path, QLayoutItem *dockWidgetItem)
 
bool isEmpty () const
 
QDockAreaLayoutItemitem (const QList< int > &path)
 
QLayoutItemitemAt (int *x, int index) const
 
QRect itemRect (int index) const
 
QRect itemRect (const QList< int > &path) const
 
QMainWindowLayoutmainWindowLayout () const
 
QSize maximumSize () const
 
QSize minimumSize () const
 
int next (int idx) const
 
void paintSeparators (QPainter *p, QWidget *widget, const QRegion &clip, const QPoint &mouse) const
 
QLayoutItemplug (const QList< int > &path)
 
int prev (int idx) const
 
 QDockAreaLayoutInfo ()
 
 QDockAreaLayoutInfo (const int *_sep, QInternal::DockPosition _dockPos, Qt::Orientation _o, int tbhape, QMainWindow *window)
 
void remove (const QList< int > &path)
 
bool restoreState (QDataStream &stream, QList< QDockWidget *> &widgets, bool testing)
 
void saveState (QDataStream &stream) const
 
int separatorMove (int index, int delta)
 
QRect separatorRect (int index) const
 
QRect separatorRect (const QList< int > &path) const
 
QRegion separatorRegion () const
 
void setCurrentTab (QWidget *widget)
 
void setCurrentTabId (quintptr id)
 
void setTabBarShape (int shape)
 
QSize size () const
 
QSize sizeHint () const
 
void split (int index, Qt::Orientation orientation, QLayoutItem *dockWidgetItem)
 
void tab (int index, QLayoutItem *dockWidgetItem)
 
QSize tabBarMinimumSize () const
 
QSize tabBarSizeHint () const
 
QRect tabContentRect () const
 
QLayoutItemtakeAt (int *x, int index)
 
void unnest (int index)
 
QLayoutItemunplug (const QList< int > &path)
 
void updateSeparatorWidgets () const
 
bool updateTabBar () const
 
QSet< QWidget * > usedSeparatorWidgets () const
 
QSet< QTabBar * > usedTabBars () const
 

Public Variables

QInternal::DockPosition dockPos
 
QList< QDockAreaLayoutItemitem_list
 
QMainWindowmainWindow
 
Qt::Orientation o
 
QRect rect
 
const int * sep
 
QVector< QWidget * > separatorWidgets
 
QTabBartabBar
 
int tabBarShape
 
bool tabbed
 

Detailed Description

Definition at line 127 of file qdockarealayout_p.h.

Enumerations

◆ anonymous enum

anonymous enum
Enumerator
SequenceMarker 
TabMarker 
WidgetMarker 

Definition at line 153 of file qdockarealayout_p.h.

153  { // sentinel values used to validate state data
154  SequenceMarker = 0xfc,
155  TabMarker = 0xfa,
156  WidgetMarker = 0xfb
157  };

◆ TabMode

Constructors and Destructors

◆ QDockAreaLayoutInfo() [1/2]

QDockAreaLayoutInfo::QDockAreaLayoutInfo ( )

Definition at line 228 of file qdockarealayout.cpp.

Referenced by restoreState(), split(), and tab().

230 #ifndef QT_NO_TABBAR
232 #endif
233 {
234 }
QMainWindow * mainWindow
static const int zero
QInternal::DockPosition dockPos

◆ QDockAreaLayoutInfo() [2/2]

QDockAreaLayoutInfo::QDockAreaLayoutInfo ( const int *  _sep,
QInternal::DockPosition  _dockPos,
Qt::Orientation  _o,
int  tbhape,
QMainWindow window 
)

Definition at line 236 of file qdockarealayout.cpp.

239  : sep(_sep), dockPos(_dockPos), o(_o), mainWindow(window)
240 #ifndef QT_NO_TABBAR
241  , tabbed(false), tabBar(0), tabBarShape(static_cast<QTabBar::Shape>(tbshape))
242 #endif
243 {
244 #ifdef QT_NO_TABBAR
245  Q_UNUSED(tbshape);
246 #endif
247 }
QMainWindow * mainWindow
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
QInternal::DockPosition dockPos

Functions

◆ apply()

void QDockAreaLayoutInfo::apply ( bool  animate)

Definition at line 1497 of file qdockarealayout.cpp.

Referenced by apply(), QDockAreaLayout::separatorMove(), and QMainWindowLayout::tabChanged().

1498 {
1499  QWidgetAnimator &widgetAnimator = mainWindowLayout()->widgetAnimator;
1500 
1501 #ifndef QT_NO_TABBAR
1502  if (tabbed) {
1503  QRect tab_rect;
1504  QSize tbh = tabBarSizeHint();
1505 
1506  if (!tbh.isNull()) {
1507  switch (tabBarShape) {
1508  case QTabBar::RoundedNorth:
1510  tab_rect = QRect(rect.left(), rect.top(), rect.width(), tbh.height());
1511  break;
1512  case QTabBar::RoundedSouth:
1514  tab_rect = QRect(rect.left(), rect.bottom() - tbh.height() + 1,
1515  rect.width(), tbh.height());
1516  break;
1517  case QTabBar::RoundedEast:
1519  tab_rect = QRect(rect.right() - tbh.width() + 1, rect.top(),
1520  tbh.width(), rect.height());
1521  break;
1522  case QTabBar::RoundedWest:
1524  tab_rect = QRect(rect.left(), rect.top(),
1525  tbh.width(), rect.height());
1526  break;
1527  default:
1528  break;
1529  }
1530  }
1531 
1532  widgetAnimator.animate(tabBar, tab_rect, animate);
1533  }
1534 #endif // QT_NO_TABBAR
1535 
1536  for (int i = 0; i < item_list.size(); ++i) {
1538 
1540  continue;
1541 
1542  if (item.subinfo != 0) {
1543  item.subinfo->apply(animate);
1544  continue;
1545  }
1546 
1547  if (item.skip())
1548  continue;
1549 
1550  Q_ASSERT(item.widgetItem);
1551  QRect r = itemRect(i);
1552  QWidget *w = item.widgetItem->widget();
1553 
1554  QRect geo = w->geometry();
1555  widgetAnimator.animate(w, r, animate);
1556  if (!w->isHidden() && w->window()->isVisible()) {
1558  if (!r.isValid() && geo.right() >= 0 && geo.bottom() >= 0) {
1559  dw->lower();
1560  emit dw->visibilityChanged(false);
1561  } else if (r.isValid()
1562  && (geo.right() < 0 || geo.bottom() < 0)) {
1563  emit dw->visibilityChanged(true);
1564  }
1565  }
1566  }
1567 #ifndef QT_NO_TABBAR
1568  if (*sep == 1)
1570 #endif //QT_NO_TABBAR
1571 }
T qobject_cast(QObject *object)
Definition: qobject.h:375
QList< QDockAreaLayoutItem > item_list
The QDockWidget class provides a widget that can be docked inside a QMainWindow or floated as a top-l...
Definition: qdockwidget.h:60
void visibilityChanged(bool visible)
This signal is emitted when the dock widget becomes visible (or invisible).
bool isVisible() const
Definition: qwidget.h:1005
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
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
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
void apply(bool animate)
QRect itemRect(int index) const
bool isHidden() const
Returns true if the widget is hidden, otherwise returns false.
Definition: qwidget.h:1008
void updateSeparatorWidgets() const
QMainWindowLayout * mainWindowLayout() const
int width() const
Returns the width.
Definition: qsize.h:126
void lower()
Lowers the widget to the bottom of the parent widget&#39;s stack.
Definition: qwidget.cpp:11939
#define emit
Definition: qobjectdefs.h:76
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
int right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:246
QDockAreaLayoutInfo * subinfo
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
int height() const
Returns the height.
Definition: qsize.h:129
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
QWidget * window() const
Returns the window for this widget, i.e.
Definition: qwidget.cpp:4492
virtual QWidget * widget()
If this item is a QWidget, it is returned as a QWidget; otherwise 0 is returned.
QWidgetAnimator widgetAnimator
bool isNull() const
Returns true if both the width and height is 0; otherwise returns false.
Definition: qsize.h:117
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
QSize tabBarSizeHint() const
bool isValid() const
Returns true if the rectangle is valid, otherwise returns false.
Definition: qrect.h:237
QDockAreaLayoutItem & item(const QList< int > &path)
QRect geometry
the geometry of the widget relative to its parent and excluding the window frame
Definition: qwidget.h:158
void animate(QWidget *widget, const QRect &final_geometry, bool animate)
QLayoutItem * widgetItem

◆ changeSize()

int QDockAreaLayoutInfo::changeSize ( int  index,
int  size,
bool  below 
)

◆ clear()

void QDockAreaLayoutInfo::clear ( )

Definition at line 254 of file qdockarealayout.cpp.

255 {
256  item_list.clear();
257  rect = QRect();
258 #ifndef QT_NO_TABBAR
259  tabbed = false;
260  tabBar = 0;
261 #endif
262 }
QList< QDockAreaLayoutItem > item_list
void clear()
Removes all items from the list.
Definition: qlist.h:764
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58

◆ currentTabId()

quintptr QDockAreaLayoutInfo::currentTabId ( ) const

Definition at line 1103 of file qdockarealayout.cpp.

Referenced by itemRect(), and saveState().

1104 {
1105  if (!tabbed || tabBar == 0)
1106  return 0;
1107 
1108  int index = tabBar->currentIndex();
1109  if (index == -1)
1110  return 0;
1111 
1112  return qvariant_cast<quintptr>(tabBar->tabData(index));
1113 }
QIntegerForSizeof< void * >::Unsigned quintptr
Definition: qglobal.h:986
QVariant tabData(int index) const
Returns the data of the tab at position index, or a null variant if index is out of range...
Definition: qtabbar.cpp:1167
T qvariant_cast(const QVariant &)
Definition: qvariant.h:571
quint16 index
int currentIndex
the index of the tab bar&#39;s visible tab
Definition: qtabbar.h:65

◆ deleteAllLayoutItems()

void QDockAreaLayoutInfo::deleteAllLayoutItems ( )

Definition at line 1768 of file qdockarealayout.cpp.

Referenced by deleteAllLayoutItems().

1769 {
1770  for (int i = 0; i < item_list.count(); ++i) {
1772  if (item.subinfo) {
1773  item.subinfo->deleteAllLayoutItems();
1774  } else {
1775  delete item.widgetItem;
1776  item.widgetItem = 0;
1777  }
1778  }
1779 }
QList< QDockAreaLayoutItem > item_list
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
QDockAreaLayoutInfo * subinfo
QDockAreaLayoutItem & item(const QList< int > &path)
QLayoutItem * widgetItem

◆ expansive()

bool QDockAreaLayoutInfo::expansive ( Qt::Orientation  o) const

Definition at line 467 of file qdockarealayout.cpp.

Referenced by QDockAreaLayoutItem::expansive().

468 {
469  for (int i = 0; i < item_list.size(); ++i) {
470  if (item_list.at(i).expansive(o))
471  return true;
472  }
473  return false;
474 }
QList< QDockAreaLayoutItem > item_list
bool expansive(Qt::Orientation o) const
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
int size() const
Returns the number of items in the list.
Definition: qlist.h:137

◆ findSeparator()

QList< int > QDockAreaLayoutInfo::findSeparator ( const QPoint pos) const

Definition at line 1390 of file qdockarealayout.cpp.

Referenced by findSeparator(), and QDockAreaLayout::findSeparator().

1391 {
1392 #ifndef QT_NO_TABBAR
1393  if (tabbed)
1394  return QList<int>();
1395 #endif
1396 
1397  int pos = pick(o, _pos);
1398 
1399  for (int i = 0; i < item_list.size(); ++i) {
1400  const QDockAreaLayoutItem &item = item_list.at(i);
1401  if (item.skip() || (item.flags & QDockAreaLayoutItem::GapItem))
1402  continue;
1403 
1404  if (item.pos + item.size > pos) {
1405  if (item.subinfo != 0) {
1406  QList<int> result = item.subinfo->findSeparator(_pos);
1407  if (!result.isEmpty()) {
1408  result.prepend(i);
1409  return result;
1410  } else {
1411  return QList<int>();
1412  }
1413  }
1414  }
1415 
1416  int next = this->next(i);
1417  if (next == -1 || (item_list.at(next).flags & QDockAreaLayoutItem::GapItem))
1418  continue;
1419 
1420  QRect sepRect = separatorRect(i);
1421  if (!sepRect.isNull() && *sep == 1)
1422  sepRect.adjust(-2, -2, 2, 2);
1423  //we also make sure we don't find a separator that's not there
1424  if (sepRect.contains(_pos) && !item.hasFixedSize(o)) {
1425  return QList<int>() << i;
1426  }
1427 
1428  }
1429 
1430  return QList<int>();
1431 }
QList< QDockAreaLayoutItem > item_list
bool isNull() const
Returns true if the rectangle is a null rectangle, otherwise returns false.
Definition: qrect.h:231
QRect separatorRect(int index) const
int next(int idx) const
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
void prepend(const T &t)
Inserts value at the beginning of the list.
Definition: qlist.h:541
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
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
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
QList< int > findSeparator(const QPoint &pos) const
bool hasFixedSize(Qt::Orientation o) const
QDockAreaLayoutInfo * subinfo
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
static int pick(bool vertical, const QSize &size)
QDockAreaLayoutItem & item(const QList< int > &path)

◆ fitItems()

void QDockAreaLayoutInfo::fitItems ( )

Definition at line 536 of file qdockarealayout.cpp.

Referenced by fitItems(), separatorMove(), and QDockAreaLayout::setGrid().

537 {
538 #ifndef QT_NO_TABBAR
539  if (tabbed) {
540  return;
541  }
542 #endif
543 
544  QVector<QLayoutStruct> layout_struct_list(item_list.size()*2);
545  int j = 0;
546 
547  int size = pick(o, rect.size());
548  int min_size = realMinSize(*this);
549  int max_size = realMaxSize(*this);
550  int last_index = -1;
551 
552  const QDockAreaLayoutItem *previous = 0;
553  for (int i = 0; i < item_list.size(); ++i) {
555  if (item.skip())
556  continue;
557 
558  bool gap = item.flags & QDockAreaLayoutItem::GapItem;
559  if (previous && !gap) {
560  if (!(previous->flags & QDockAreaLayoutItem::GapItem)) {
561  QLayoutStruct &ls = layout_struct_list[j++];
562  ls.init();
563  ls.minimumSize = ls.maximumSize = ls.sizeHint = previous->hasFixedSize(o) ? 0 : *sep;
564  ls.empty = false;
565  }
566  }
567 
569  // Check if the item can keep its size, without violating size constraints
570  // of other items.
571 
572  if (size < min_size) {
573  // There is too little space to keep this widget's size
574  item.flags &= ~QDockAreaLayoutItem::KeepSize;
575  min_size -= item.size;
576  min_size += pick(o, item.minimumSize());
577  min_size = qMax(0, min_size);
578  } else if (size > max_size) {
579  // There is too much space to keep this widget's size
580  item.flags &= ~QDockAreaLayoutItem::KeepSize;
581  max_size -= item.size;
582  max_size += pick(o, item.maximumSize());
583  max_size = qMin<int>(QWIDGETSIZE_MAX, max_size);
584  }
585  }
586 
587  last_index = j;
588  QLayoutStruct &ls = layout_struct_list[j++];
589  ls.init();
590  ls.empty = false;
592  ls.minimumSize = ls.maximumSize = ls.sizeHint = item.size;
593  ls.expansive = false;
594  ls.stretch = 0;
595  } else {
596  ls.maximumSize = pick(o, item.maximumSize());
597  ls.expansive = item.expansive(o);
598  ls.minimumSize = pick(o, item.minimumSize());
599  ls.sizeHint = item.size == -1 ? pick(o, item.sizeHint()) : item.size;
600  ls.stretch = ls.expansive ? ls.sizeHint : 0;
601  }
602 
603  item.flags &= ~QDockAreaLayoutItem::KeepSize;
604  previous = &item;
605  }
606  layout_struct_list.resize(j);
607 
608  // If there is more space than the widgets can take (due to maximum size constraints),
609  // we detect it here and stretch the last widget to take up the rest of the space.
610  if (size > max_size && last_index != -1) {
611  layout_struct_list[last_index].maximumSize = QWIDGETSIZE_MAX;
612  layout_struct_list[last_index].expansive = true;
613  }
614 
615  qGeomCalc(layout_struct_list, 0, j, pick(o, rect.topLeft()), size, 0);
616 
617  j = 0;
618  bool prev_gap = false;
619  bool first = true;
620  for (int i = 0; i < item_list.size(); ++i) {
621  QDockAreaLayoutItem &item = item_list[i];
622  if (item.skip())
623  continue;
624 
625  bool gap = item.flags & QDockAreaLayoutItem::GapItem;
626  if (!first && !gap && !prev_gap)
627  ++j;
628 
629  const QLayoutStruct &ls = layout_struct_list.at(j++);
630  item.size = ls.size;
631  item.pos = ls.pos;
632 
633  if (item.subinfo != 0) {
634  item.subinfo->rect = itemRect(i);
635  item.subinfo->fitItems();
636  }
637 
638  prev_gap = gap;
639  first = false;
640  }
641 }
QList< QDockAreaLayoutItem > item_list
static int realMaxSize(const QDockAreaLayoutInfo &info)
static int qMax(int i1, int i2, int i3)
void init(int stretchFactor=0, int minSize=0)
#define QWIDGETSIZE_MAX
Defines the maximum size for a QWidget object.
Definition: qwidget.h:1087
QRect itemRect(int index) const
bool expansive(Qt::Orientation o) const
QSize size() const
Returns the size of the rectangle.
Definition: qrect.h:309
QSize maximumSize() const
void qGeomCalc(QVector< QLayoutStruct > &chain, int start, int count, int pos, int space, int spacer)
static int realMinSize(const QDockAreaLayoutInfo &info)
bool hasFixedSize(Qt::Orientation o) const
QDockAreaLayoutInfo * subinfo
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
static int pick(bool vertical, const QSize &size)
QDockAreaLayoutItem & item(const QList< int > &path)
QPoint topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:288
QSize minimumSize() const

◆ gapIndex()

QList< int > QDockAreaLayoutInfo::gapIndex ( const QPoint pos,
bool  nestingEnabled,
TabMode  tabMode 
) const

Definition at line 745 of file qdockarealayout.cpp.

Referenced by gapIndex(), and QDockAreaLayout::gapIndex().

747 {
748  QList<int> result;
749  QRect item_rect;
750  int item_index = 0;
751 
752 #ifndef QT_NO_TABBAR
753  if (tabbed) {
754  item_rect = tabContentRect();
755  } else
756 #endif
757  {
758  int pos = pick(o, _pos);
759 
760  int last = -1;
761  for (int i = 0; i < item_list.size(); ++i) {
762  const QDockAreaLayoutItem &item = item_list.at(i);
763  if (item.skip())
764  continue;
765 
766  last = i;
767 
768  if (item.pos + item.size < pos)
769  continue;
770 
771  if (item.subinfo != 0
772 #ifndef QT_NO_TABBAR
773  && !item.subinfo->tabbed
774 #endif
775  ) {
776  result = item.subinfo->gapIndex(_pos, nestingEnabled,
777  tabMode);
778  result.prepend(i);
779  return result;
780  }
781 
782  item_rect = itemRect(i);
783  item_index = i;
784  break;
785  }
786 
787  if (item_rect.isNull()) {
788  result.append(last + 1);
789  return result;
790  }
791  }
792 
793  Q_ASSERT(!item_rect.isNull());
794 
795  QInternal::DockPosition dock_pos
796  = dockPosHelper(item_rect, _pos, o, nestingEnabled, tabMode);
797 
798  switch (dock_pos) {
799  case QInternal::LeftDock:
800  if (o == Qt::Horizontal)
801  result << item_index;
802  else
803  result << item_index << 0; // this subinfo doesn't exist yet, but insertGap()
804  // handles this by inserting it
805  break;
807  if (o == Qt::Horizontal)
808  result << item_index + 1;
809  else
810  result << item_index << 1;
811  break;
812  case QInternal::TopDock:
813  if (o == Qt::Horizontal)
814  result << item_index << 0;
815  else
816  result << item_index;
817  break;
819  if (o == Qt::Horizontal)
820  result << item_index << 1;
821  else
822  result << item_index + 1;
823  break;
825  result << (-item_index - 1) << 0; // negative item_index means "on top of"
826  // -item_index - 1, insertGap()
827  // will insert a tabbed subinfo
828  break;
829  default:
830  break;
831  }
832 
833  return result;
834 }
QList< QDockAreaLayoutItem > item_list
bool isNull() const
Returns true if the rectangle is a null rectangle, otherwise returns false.
Definition: qrect.h:231
QRect tabContentRect() const
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
static QInternal::DockPosition dockPosHelper(const QRect &rect, const QPoint &_pos, Qt::Orientation o, bool nestingEnabled, QDockAreaLayoutInfo::TabMode tabMode)
QRect itemRect(int index) const
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
void prepend(const T &t)
Inserts value at the beginning of the list.
Definition: qlist.h:541
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
QDockAreaLayoutInfo * subinfo
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
static int pick(bool vertical, const QSize &size)
QDockAreaLayoutItem & item(const QList< int > &path)
#define QT_NO_TABBAR
QList< int > gapIndex(const QPoint &pos, bool nestingEnabled, TabMode tabMode) const

◆ hasFixedSize()

bool QDockAreaLayoutInfo::hasFixedSize ( ) const

Definition at line 1491 of file qdockarealayout.cpp.

Referenced by QDockAreaLayout::findSeparator(), and QDockAreaLayout::paintSeparators().

1492 {
1493  return perp(o, minimumSize()) == perp(o, maximumSize());
1494 }
QSize maximumSize() const
static int perp(bool vertical, const QSize &size)
QSize minimumSize() const

◆ indexOf()

QList< int > QDockAreaLayoutInfo::indexOf ( QWidget widget) const

Definition at line 1457 of file qdockarealayout.cpp.

Referenced by indexOf(), and QDockAreaLayout::indexOf().

1458 {
1459  for (int i = 0; i < item_list.size(); ++i) {
1460  const QDockAreaLayoutItem &item = item_list.at(i);
1461 
1462  if (item.placeHolderItem != 0)
1463  continue;
1464 
1465  if (item.subinfo != 0) {
1466  QList<int> result = item.subinfo->indexOf(widget);
1467  if (!result.isEmpty()) {
1468  result.prepend(i);
1469  return result;
1470  }
1471  continue;
1472  }
1473 
1474  if (!(item.flags & QDockAreaLayoutItem::GapItem) && item.widgetItem->widget() == widget) {
1475  QList<int> result;
1476  result << i;
1477  return result;
1478  }
1479  }
1480 
1481  return QList<int>();
1482 }
QList< int > indexOf(QWidget *widget) const
QList< QDockAreaLayoutItem > item_list
QPointer< QWidget > widget
QPlaceHolderItem * placeHolderItem
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
void prepend(const T &t)
Inserts value at the beginning of the list.
Definition: qlist.h:541
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
QDockAreaLayoutInfo * subinfo
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
virtual QWidget * widget()
If this item is a QWidget, it is returned as a QWidget; otherwise 0 is returned.
QDockAreaLayoutItem & item(const QList< int > &path)
QLayoutItem * widgetItem

◆ indexOfPlaceHolder()

QList< int > QDockAreaLayoutInfo::indexOfPlaceHolder ( const QString objectName) const

Definition at line 1433 of file qdockarealayout.cpp.

Referenced by indexOfPlaceHolder(), and QDockAreaLayout::indexOfPlaceHolder().

1434 {
1435  for (int i = 0; i < item_list.size(); ++i) {
1436  const QDockAreaLayoutItem &item = item_list.at(i);
1437 
1438  if (item.subinfo != 0) {
1439  QList<int> result = item.subinfo->indexOfPlaceHolder(objectName);
1440  if (!result.isEmpty()) {
1441  result.prepend(i);
1442  return result;
1443  }
1444  continue;
1445  }
1446 
1447  if (item.placeHolderItem != 0 && item.placeHolderItem->objectName == objectName) {
1448  QList<int> result;
1449  result << i;
1450  return result;
1451  }
1452  }
1453 
1454  return QList<int>();
1455 }
QList< QDockAreaLayoutItem > item_list
QPlaceHolderItem * placeHolderItem
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
void prepend(const T &t)
Inserts value at the beginning of the list.
Definition: qlist.h:541
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
QDockAreaLayoutInfo * subinfo
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
QList< int > indexOfPlaceHolder(const QString &objectName) const
QDockAreaLayoutItem & item(const QList< int > &path)

◆ info() [1/2]

QDockAreaLayoutInfo * QDockAreaLayoutInfo::info ( const QList< int > &  path)

Definition at line 1304 of file qdockarealayout.cpp.

Referenced by info(), and QDockAreaLayout::info().

1305 {
1306  int index = path.first();
1307  if (index < 0)
1308  index = -index - 1;
1309  if (index >= item_list.count())
1310  return this;
1311  if (path.count() == 1 || item_list[index].subinfo == 0)
1312  return this;
1313  return item_list[index].subinfo->info(path.mid(1));
1314 }
QList< QDockAreaLayoutItem > item_list
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
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
T & first()
Returns a reference to the first item in the list.
Definition: qlist.h:282
quint16 index

◆ info() [2/2]

QDockAreaLayoutInfo * QDockAreaLayoutInfo::info ( QWidget widget)

Definition at line 1280 of file qdockarealayout.cpp.

1281 {
1282  for (int i = 0; i < item_list.count(); ++i) {
1283  const QDockAreaLayoutItem &item = item_list.at(i);
1284  if (item.skip())
1285  continue;
1286 
1287 #ifndef QT_NO_TABBAR
1288  if (tabbed && widget == tabBar)
1289  return this;
1290 #endif
1291 
1292  if (item.widgetItem != 0 && item.widgetItem->widget() == widget)
1293  return this;
1294 
1295  if (item.subinfo != 0) {
1296  if (QDockAreaLayoutInfo *result = item.subinfo->info(widget))
1297  return result;
1298  }
1299  }
1300 
1301  return 0;
1302 }
QList< QDockAreaLayoutItem > item_list
QPointer< QWidget > widget
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
QDockAreaLayoutInfo * info(const QList< int > &path)
QDockAreaLayoutInfo * subinfo
virtual QWidget * widget()
If this item is a QWidget, it is returned as a QWidget; otherwise 0 is returned.
QDockAreaLayoutItem & item(const QList< int > &path)
QLayoutItem * widgetItem

◆ insertGap()

bool QDockAreaLayoutInfo::insertGap ( const QList< int > &  path,
QLayoutItem dockWidgetItem 
)

Definition at line 1149 of file qdockarealayout.cpp.

Referenced by insertGap(), and QDockAreaLayout::insertGap().

1150 {
1151  Q_ASSERT(!path.isEmpty());
1152 
1153  bool insert_tabbed = false;
1154  int index = path.first();
1155  if (index < 0) {
1156  insert_tabbed = true;
1157  index = -index - 1;
1158  }
1159 
1160 // dump(qDebug() << "insertGap() before:" << index << tabIndex, *this, QString());
1161 
1162  if (path.count() > 1) {
1164 
1165  if (item.subinfo == 0
1166 #ifndef QT_NO_TABBAR
1167  || (item.subinfo->tabbed && !insert_tabbed)
1168 #endif
1169  ) {
1170 
1171  // this is not yet a nested layout - make it
1172 
1173  QDockAreaLayoutInfo *subinfo = item.subinfo;
1174  QLayoutItem *widgetItem = item.widgetItem;
1175  QPlaceHolderItem *placeHolderItem = item.placeHolderItem;
1176  QRect r = subinfo == 0 ? widgetItem ? dockedGeometry(widgetItem->widget()) : placeHolderItem->topLevelRect : subinfo->rect;
1177 
1179 #ifdef QT_NO_TABBAR
1180  const int tabBarShape = 0;
1181 #endif
1182  QDockAreaLayoutInfo *new_info
1184 
1185  //item become a new top-level
1186  item.subinfo = new_info;
1187  item.widgetItem = 0;
1188  item.placeHolderItem = 0;
1189 
1190  QDockAreaLayoutItem new_item
1191  = widgetItem == 0
1192  ? QDockAreaLayoutItem(subinfo)
1193  : widgetItem ? QDockAreaLayoutItem(widgetItem) : QDockAreaLayoutItem(placeHolderItem);
1194  new_item.size = pick(opposite, r.size());
1195  new_item.pos = pick(opposite, r.topLeft());
1196  new_info->item_list.append(new_item);
1197 #ifndef QT_NO_TABBAR
1198  if (insert_tabbed) {
1199  new_info->tabbed = true;
1200  }
1201 #endif
1202  }
1203 
1204  return item.subinfo->insertGap(path.mid(1), dockWidgetItem);
1205  }
1206 
1207  // create the gap item
1208  QDockAreaLayoutItem gap_item;
1209  gap_item.flags |= QDockAreaLayoutItem::GapItem;
1210  gap_item.widgetItem = dockWidgetItem; // so minimumSize(), maximumSize() and
1211  // sizeHint() will work
1212 #ifndef QT_NO_TABBAR
1213  if (!tabbed)
1214 #endif
1215  {
1216  int prev = this->prev(index);
1217  int next = this->next(index - 1);
1218  // find out how much space we have in the layout
1219  int space = 0;
1220  if (isEmpty()) {
1221  // I am an empty dock area, therefore I am a top-level dock area.
1222  switch (dockPos) {
1223  case QInternal::LeftDock:
1224  case QInternal::RightDock:
1225  if (o == Qt::Vertical) {
1226  // the "size" is the height of the dock area (remember we are empty)
1227  space = pick(Qt::Vertical, rect.size());
1228  } else {
1229  space = pick(Qt::Horizontal, dockWidgetItem->widget()->size());
1230  }
1231  break;
1232  case QInternal::TopDock:
1233  case QInternal::BottomDock:
1234  default:
1235  if (o == Qt::Horizontal) {
1236  // the "size" is width of the dock area
1237  space = pick(Qt::Horizontal, rect.size());
1238  } else {
1239  space = pick(Qt::Vertical, dockWidgetItem->widget()->size());
1240  }
1241  break;
1242  }
1243  } else {
1244  for (int i = 0; i < item_list.count(); ++i) {
1245  const QDockAreaLayoutItem &item = item_list.at(i);
1246  if (item.skip())
1247  continue;
1249  space += item.size - pick(o, item.minimumSize());
1250  }
1251  }
1252 
1253  // find the actual size of the gap
1254  int gap_size = 0;
1255  int sep_size = 0;
1256  if (isEmpty()) {
1257  gap_size = space;
1258  sep_size = 0;
1259  } else {
1260  QRect r = dockedGeometry(dockWidgetItem->widget());
1261  gap_size = pick(o, r.size());
1262  if (prev != -1 && !(item_list.at(prev).flags & QDockAreaLayoutItem::GapItem))
1263  sep_size += *sep;
1264  if (next != -1 && !(item_list.at(next).flags & QDockAreaLayoutItem::GapItem))
1265  sep_size += *sep;
1266  }
1267  if (gap_size + sep_size > space)
1268  gap_size = pick(o, gap_item.minimumSize());
1269  gap_item.size = gap_size + sep_size;
1270  }
1271 
1272  // finally, insert the gap
1273  item_list.insert(index, gap_item);
1274 
1275 // dump(qDebug() << "insertGap() after:" << index << tabIndex, *this, QString());
1276 
1277  return true;
1278 }
QList< QDockAreaLayoutItem > item_list
int prev(int idx) const
void insert(int i, const T &t)
Inserts value at index position i in the list.
Definition: qlist.h:575
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
QPlaceHolderItem * placeHolderItem
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
int next(int idx) const
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
The QLayoutItem class provides an abstract item that a QLayout manipulates.
Definition: qlayoutitem.h:64
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
QSize size
the size of the widget excluding any window frame
Definition: qwidget.h:165
T & first()
Returns a reference to the first item in the list.
Definition: qlist.h:282
static QRect dockedGeometry(QWidget *widget)
QDockAreaLayoutInfo * subinfo
QMainWindow * mainWindow
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
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.
bool insertGap(const QList< int > &path, QLayoutItem *dockWidgetItem)
QDockAreaLayoutItem & item(const QList< int > &path)
Orientation
Definition: qnamespace.h:174
QInternal::DockPosition dockPos
#define QT_NO_TABBAR
QLayoutItem * widgetItem
QPoint topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:288
QSize minimumSize() const

◆ isEmpty()

bool QDockAreaLayoutInfo::isEmpty ( ) const

◆ item()

QDockAreaLayoutItem & QDockAreaLayoutInfo::item ( const QList< int > &  path)

Definition at line 1714 of file qdockarealayout.cpp.

Referenced by apply(), deleteAllLayoutItems(), findSeparator(), fitItems(), gapIndex(), indexOf(), indexOfPlaceHolder(), info(), insertGap(), item(), QDockAreaLayout::item(), itemAt(), itemRect(), maximumSize(), minimumSize(), paintSeparators(), plug(), realMaxSize(), realMinSize(), remove(), restoreState(), saveState(), separatorMove(), separatorRect(), separatorRegion(), setTabBarShape(), sizeHint(), takeAt(), unnest(), unplug(), updateSeparatorWidgets(), updateTabBar(), usedSeparatorWidgets(), and usedTabBars().

1715 {
1716  Q_ASSERT(!path.isEmpty());
1717  const int index = path.first();
1718  if (path.count() > 1) {
1720  Q_ASSERT(item.subinfo != 0);
1721  return item.subinfo->item(path.mid(1));
1722  }
1723  return item_list[index];
1724 }
QList< QDockAreaLayoutItem > item_list
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
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
T & first()
Returns a reference to the first item in the list.
Definition: qlist.h:282
QDockAreaLayoutInfo * subinfo
quint16 index
QDockAreaLayoutItem & item(const QList< int > &path)

◆ itemAt()

QLayoutItem * QDockAreaLayoutInfo::itemAt ( int *  x,
int  index 
) const

Definition at line 1726 of file qdockarealayout.cpp.

Referenced by itemAt(), and QDockAreaLayout::itemAt().

1727 {
1728  for (int i = 0; i < item_list.count(); ++i) {
1729  const QDockAreaLayoutItem &item = item_list.at(i);
1730  if (item.placeHolderItem != 0)
1731  continue;
1732  if (item.subinfo) {
1733  if (QLayoutItem *ret = item.subinfo->itemAt(x, index))
1734  return ret;
1735  } else if (item.widgetItem) {
1736  if ((*x)++ == index)
1737  return item.widgetItem;
1738  }
1739  }
1740  return 0;
1741 }
QList< QDockAreaLayoutItem > item_list
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
QPlaceHolderItem * placeHolderItem
The QLayoutItem class provides an abstract item that a QLayout manipulates.
Definition: qlayoutitem.h:64
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
QDockAreaLayoutInfo * subinfo
QLayoutItem * itemAt(int *x, int index) const
quint16 index
QDockAreaLayoutItem & item(const QList< int > &path)
QLayoutItem * widgetItem

◆ itemRect() [1/2]

QRect QDockAreaLayoutInfo::itemRect ( int  index) const

Definition at line 1316 of file qdockarealayout.cpp.

Referenced by apply(), fitItems(), gapIndex(), itemRect(), QDockAreaLayout::itemRect(), and separatorMove().

1317 {
1319 
1320  if (item.skip())
1321  return QRect();
1322 
1323  QRect result;
1324 
1325 #ifndef QT_NO_TABBAR
1326  if (tabbed) {
1327  if (tabId(item) == currentTabId())
1328  result = tabContentRect();
1329  } else
1330 #endif
1331  {
1332  QPoint pos;
1333  rpick(o, pos) = item.pos;
1334  rperp(o, pos) = perp(o, rect.topLeft());
1335  QSize s;
1336  rpick(o, s) = item.size;
1337  rperp(o, s) = perp(o, rect.size());
1338  result = QRect(pos, s);
1339  }
1340 
1341  return result;
1342 }
QList< QDockAreaLayoutItem > item_list
static int & rpick(Qt::Orientation o, QPoint &pos)
QRect tabContentRect() const
quintptr currentTabId() const
static quintptr tabId(const QDockAreaLayoutItem &item)
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
static int perp(bool vertical, const QSize &size)
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
quint16 index
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
static int & rperp(Qt::Orientation o, QPoint &pos)
QDockAreaLayoutItem & item(const QList< int > &path)
QPoint topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:288

◆ itemRect() [2/2]

QRect QDockAreaLayoutInfo::itemRect ( const QList< int > &  path) const

Definition at line 1344 of file qdockarealayout.cpp.

1345 {
1346  Q_ASSERT(!path.isEmpty());
1347 
1348  const int index = path.first();
1349  if (path.count() > 1) {
1350  const QDockAreaLayoutItem &item = item_list.at(index);
1351  Q_ASSERT(item.subinfo != 0);
1352  return item.subinfo->itemRect(path.mid(1));
1353  }
1354 
1355  return itemRect(index);
1356 }
QList< QDockAreaLayoutItem > item_list
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
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
QRect itemRect(int index) const
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
T & first()
Returns a reference to the first item in the list.
Definition: qlist.h:282
QDockAreaLayoutInfo * subinfo
quint16 index
QDockAreaLayoutItem & item(const QList< int > &path)

◆ mainWindowLayout()

QMainWindowLayout * QDockAreaLayoutInfo::mainWindowLayout ( ) const

Definition at line 1484 of file qdockarealayout.cpp.

Referenced by apply(), updateSeparatorWidgets(), and updateTabBar().

1485 {
1487  Q_ASSERT(result != 0);
1488  return result;
1489 }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
QMainWindow * mainWindow
QMainWindowLayout * qt_mainwindow_layout(const QMainWindow *window)

◆ maximumSize()

QSize QDockAreaLayoutInfo::maximumSize ( ) const

Definition at line 328 of file qdockarealayout.cpp.

Referenced by QDockAreaLayout::getGrid(), hasFixedSize(), and QDockAreaLayoutItem::maximumSize().

329 {
330  if (isEmpty())
332 
333  int a = 0, b = QWIDGETSIZE_MAX;
334 #ifndef QT_NO_TABBAR
335  if (tabbed)
336  a = QWIDGETSIZE_MAX;
337 #endif
338 
339  int min_perp = 0;
340 
341  bool first = true;
342  for (int i = 0; i < item_list.size(); ++i) {
343  const QDockAreaLayoutItem &item = item_list.at(i);
344  if (item.skip())
345  continue;
346 
347  QSize max_size = item.maximumSize();
348  min_perp = qMax(min_perp, perp(o, item.minimumSize()));
349 
350 #ifndef QT_NO_TABBAR
351  if (tabbed) {
352  a = qMin(a, pick(o, max_size));
353  } else
354 #endif
355  {
356  if (!first)
357  a += *sep;
358  a += pick(o, max_size);
359  }
360  b = qMin(b, perp(o, max_size));
361 
362  a = qMin(a, int(QWIDGETSIZE_MAX));
363  b = qMin(b, int(QWIDGETSIZE_MAX));
364 
365  first = false;
366  }
367 
368  b = qMax(b, min_perp);
369 
370  QSize result;
371  rpick(o, result) = a;
372  rperp(o, result) = b;
373 
374 #ifndef QT_NO_TABBAR
375  QSize tbh = tabBarSizeHint();
376  if (!tbh.isNull()) {
377  switch (tabBarShape) {
380  result.rheight() += tbh.height();
381  break;
384  result.rwidth() += tbh.width();
385  break;
386  default:
387  break;
388  }
389  }
390 #endif // QT_NO_TABBAR
391 
392  return result;
393 }
QList< QDockAreaLayoutItem > item_list
static int qMax(int i1, int i2, int i3)
static int & rpick(Qt::Orientation o, QPoint &pos)
#define QWIDGETSIZE_MAX
Defines the maximum size for a QWidget object.
Definition: qwidget.h:1087
long ASN1_INTEGER_get ASN1_INTEGER * a
static int qMin(int i1, int i2, int i3)
int width() const
Returns the width.
Definition: qsize.h:126
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
QSize maximumSize() const
static int perp(bool vertical, const QSize &size)
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
int & rheight()
Returns a reference to the height.
Definition: qsize.h:144
int height() const
Returns the height.
Definition: qsize.h:129
static int pick(bool vertical, const QSize &size)
bool isNull() const
Returns true if both the width and height is 0; otherwise returns false.
Definition: qsize.h:117
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
static int & rperp(Qt::Orientation o, QPoint &pos)
QSize tabBarSizeHint() const
QDockAreaLayoutItem & item(const QList< int > &path)
int & rwidth()
Returns a reference to the width.
Definition: qsize.h:141
QSize minimumSize() const

◆ minimumSize()

QSize QDockAreaLayoutInfo::minimumSize ( ) const

Definition at line 269 of file qdockarealayout.cpp.

Referenced by QDockAreaLayout::getGrid(), hasFixedSize(), QDockAreaLayoutItem::minimumSize(), and QDockAreaLayout::minimumSize().

270 {
271  if (isEmpty())
272  return QSize(0, 0);
273 
274  int a = 0, b = 0;
275  bool first = true;
276  for (int i = 0; i < item_list.size(); ++i) {
277  const QDockAreaLayoutItem &item = item_list.at(i);
278  if (item.skip())
279  continue;
280 
281  QSize min_size = item.minimumSize();
282 #ifndef QT_NO_TABBAR
283  if (tabbed) {
284  a = qMax(a, pick(o, min_size));
285  } else
286 #endif
287  {
288  if (!first)
289  a += *sep;
290  a += pick(o, min_size);
291  }
292  b = qMax(b, perp(o, min_size));
293 
294  first = false;
295  }
296 
297  QSize result;
298  rpick(o, result) = a;
299  rperp(o, result) = b;
300 
301 #ifndef QT_NO_TABBAR
302  QSize tbm = tabBarMinimumSize();
303  if (!tbm.isNull()) {
304  switch (tabBarShape) {
309  result.rheight() += tbm.height();
310  result.rwidth() = qMax(tbm.width(), result.width());
311  break;
316  result.rheight() = qMax(tbm.height(), result.height());
317  result.rwidth() += tbm.width();
318  break;
319  default:
320  break;
321  }
322  }
323 #endif // QT_NO_TABBAR
324 
325  return result;
326 }
QList< QDockAreaLayoutItem > item_list
static int qMax(int i1, int i2, int i3)
static int & rpick(Qt::Orientation o, QPoint &pos)
long ASN1_INTEGER_get ASN1_INTEGER * a
int width() const
Returns the width.
Definition: qsize.h:126
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
static int perp(bool vertical, const QSize &size)
QSize tabBarMinimumSize() const
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
int & rheight()
Returns a reference to the height.
Definition: qsize.h:144
int height() const
Returns the height.
Definition: qsize.h:129
static int pick(bool vertical, const QSize &size)
bool isNull() const
Returns true if both the width and height is 0; otherwise returns false.
Definition: qsize.h:117
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
static int & rperp(Qt::Orientation o, QPoint &pos)
QDockAreaLayoutItem & item(const QList< int > &path)
int & rwidth()
Returns a reference to the width.
Definition: qsize.h:141
QSize minimumSize() const

◆ next()

int QDockAreaLayoutInfo::next ( int  idx) const

Definition at line 1654 of file qdockarealayout.cpp.

Referenced by findSeparator(), QDockAreaLayout::gapRect(), insertGap(), isEmpty(), paintSeparators(), plug(), separatorRegion(), unplug(), and updateSeparatorWidgets().

1655 {
1656  for (int i = index + 1; i < item_list.size(); ++i) {
1657  if (!item_list.at(i).skip())
1658  return i;
1659  }
1660  return -1;
1661 }
QList< QDockAreaLayoutItem > item_list
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
quint16 index

◆ paintSeparators()

void QDockAreaLayoutInfo::paintSeparators ( QPainter p,
QWidget widget,
const QRegion clip,
const QPoint mouse 
) const

Definition at line 1619 of file qdockarealayout.cpp.

Referenced by paintSeparators(), and QDockAreaLayout::paintSeparators().

1622 {
1623  if (isEmpty())
1624  return;
1625 #ifndef QT_NO_TABBAR
1626  if (tabbed)
1627  return;
1628 #endif
1629 
1630  for (int i = 0; i < item_list.count(); ++i) {
1631  const QDockAreaLayoutItem &item = item_list.at(i);
1632 
1633  if (item.skip())
1634  continue;
1635 
1636  int next = this->next(i);
1637  if ((item.flags & QDockAreaLayoutItem::GapItem)
1638  || (next != -1 && (item_list.at(next).flags & QDockAreaLayoutItem::GapItem)))
1639  continue;
1640 
1641  if (item.subinfo) {
1642  if (clip.contains(item.subinfo->rect))
1643  item.subinfo->paintSeparators(p, widget, clip, mouse);
1644  }
1645 
1646  if (next == -1)
1647  break;
1648  QRect r = separatorRect(i);
1649  if (clip.contains(r) && !item.hasFixedSize(o))
1650  paintSep(p, widget, r, o, r.contains(mouse));
1651  }
1652 }
QList< QDockAreaLayoutItem > item_list
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
QRect separatorRect(int index) const
int next(int idx) const
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
bool contains(const QPoint &p) const
Returns true if the region contains the point p; otherwise returns false.
Definition: qregion.cpp:4104
static void paintSep(QPainter *p, QWidget *w, const QRect &r, Qt::Orientation o, bool mouse_over)
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
void paintSeparators(QPainter *p, QWidget *widget, const QRegion &clip, const QPoint &mouse) const
bool hasFixedSize(Qt::Orientation o) const
QDockAreaLayoutInfo * subinfo
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
QDockAreaLayoutItem & item(const QList< int > &path)

◆ plug()

QLayoutItem * QDockAreaLayoutInfo::plug ( const QList< int > &  path)

Definition at line 1018 of file qdockarealayout.cpp.

Referenced by plug(), and QDockAreaLayout::plug().

1019 {
1020  Q_ASSERT(!path.isEmpty());
1021 
1022  int index = path.first();
1023  if (index < 0)
1024  index = -index - 1;
1025 
1026  if (path.count() > 1) {
1027  const QDockAreaLayoutItem &item = item_list.at(index);
1028  Q_ASSERT(item.subinfo != 0);
1029  return item.subinfo->plug(path.mid(1));
1030  }
1031 
1033 
1034  Q_ASSERT(item.widgetItem != 0);
1036  item.flags &= ~QDockAreaLayoutItem::GapItem;
1037 
1038  QRect result;
1039 
1040 #ifndef QT_NO_TABBAR
1041  if (tabbed) {
1042  } else
1043 #endif
1044  {
1045  int prev = this->prev(index);
1046  int next = this->next(index);
1047 
1048  if (prev != -1 && !(item_list.at(prev).flags & QDockAreaLayoutItem::GapItem)) {
1049  item.pos += *sep;
1050  item.size -= *sep;
1051  }
1052  if (next != -1 && !(item_list.at(next).flags & QDockAreaLayoutItem::GapItem))
1053  item.size -= *sep;
1054 
1055  QPoint pos;
1056  rpick(o, pos) = item.pos;
1057  rperp(o, pos) = perp(o, rect.topLeft());
1058  QSize s;
1059  rpick(o, s) = item.size;
1060  rperp(o, s) = perp(o, rect.size());
1061  result = QRect(pos, s);
1062  }
1063 
1064  return item.widgetItem;
1065 }
QList< QDockAreaLayoutItem > item_list
int prev(int idx) const
static int & rpick(Qt::Orientation o, QPoint &pos)
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
int next(int idx) const
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
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
static int perp(bool vertical, const QSize &size)
T & first()
Returns a reference to the first item in the list.
Definition: qlist.h:282
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
QDockAreaLayoutInfo * subinfo
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
quint16 index
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
static int & rperp(Qt::Orientation o, QPoint &pos)
QDockAreaLayoutItem & item(const QList< int > &path)
QLayoutItem * plug(const QList< int > &path)
QLayoutItem * widgetItem
QPoint topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:288

◆ prev()

int QDockAreaLayoutInfo::prev ( int  idx) const

Definition at line 1663 of file qdockarealayout.cpp.

Referenced by QDockAreaLayout::gapRect(), insertGap(), plug(), and unplug().

1664 {
1665  for (int i = index - 1; i >= 0; --i) {
1666  if (!item_list.at(i).skip())
1667  return i;
1668  }
1669  return -1;
1670 }
QList< QDockAreaLayoutItem > item_list
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
quint16 index

◆ remove()

void QDockAreaLayoutInfo::remove ( const QList< int > &  path)

Definition at line 1002 of file qdockarealayout.cpp.

Referenced by remove(), and QDockAreaLayout::remove().

1003 {
1004  Q_ASSERT(!path.isEmpty());
1005 
1006  if (path.count() > 1) {
1007  const int index = path.first();
1009  Q_ASSERT(item.subinfo != 0);
1010  item.subinfo->remove(path.mid(1));
1011  unnest(index);
1012  } else {
1013  int index = path.first();
1014  item_list.removeAt(index);
1015  }
1016 }
QList< QDockAreaLayoutItem > item_list
void remove(const QList< int > &path)
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
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
void unnest(int index)
T & first()
Returns a reference to the first item in the list.
Definition: qlist.h:282
QDockAreaLayoutInfo * subinfo
quint16 index
QDockAreaLayoutItem & item(const QList< int > &path)
void removeAt(int i)
Removes the item at index position i.
Definition: qlist.h:480

◆ restoreState()

bool QDockAreaLayoutInfo::restoreState ( QDataStream stream,
QList< QDockWidget *> &  widgets,
bool  testing 
)

Definition at line 1878 of file qdockarealayout.cpp.

Referenced by restoreState().

1879 {
1880  uchar marker;
1881  stream >> marker;
1882  if (marker != TabMarker && marker != SequenceMarker)
1883  return false;
1884 
1885 #ifndef QT_NO_TABBAR
1886  tabbed = marker == TabMarker;
1887 
1888  int index = -1;
1889  if (tabbed)
1890  stream >> index;
1891 #endif
1892 
1893  uchar orientation;
1894  stream >> orientation;
1895  o = static_cast<Qt::Orientation>(orientation);
1896 
1897  int cnt;
1898  stream >> cnt;
1899 
1900  for (int i = 0; i < cnt; ++i) {
1901  uchar nextMarker;
1902  stream >> nextMarker;
1903  if (nextMarker == WidgetMarker) {
1904  QString name;
1905  uchar flags;
1906  stream >> name >> flags;
1907  if (name.isEmpty()) {
1908  int dummy;
1909  stream >> dummy >> dummy >> dummy >> dummy;
1910  continue;
1911  }
1912 
1913  QDockWidget *widget = 0;
1914  for (int j = 0; j < widgets.count(); ++j) {
1915  if (widgets.at(j)->objectName() == name) {
1916  widget = widgets.takeAt(j);
1917  break;
1918  }
1919  }
1920 
1921  if (widget == 0) {
1922  QPlaceHolderItem *placeHolder = new QPlaceHolderItem;
1923  QDockAreaLayoutItem item(placeHolder);
1924 
1925  placeHolder->objectName = name;
1926  placeHolder->window = flags & StateFlagFloating;
1927  placeHolder->hidden = !(flags & StateFlagVisible);
1928  if (placeHolder->window) {
1929  int x, y, w, h;
1930  stream >> x >> y >> w >> h;
1931  placeHolder->topLevelRect = QRect(x, y, w, h);
1932  } else {
1933  int dummy;
1934  stream >> item.pos >> item.size >> dummy >> dummy;
1935  }
1936  if (item.size != -1)
1938  if (!testing)
1940  } else {
1942  if (flags & StateFlagFloating) {
1943  bool drawer = false;
1944 #ifdef Q_WS_MAC // drawer support
1945  extern bool qt_mac_is_macdrawer(const QWidget *); //qwidget_mac.cpp
1946  extern bool qt_mac_set_drawer_preferred_edge(QWidget *, Qt::DockWidgetArea); //qwidget_mac.cpp
1947  drawer = qt_mac_is_macdrawer(widget);
1948 #endif
1949 
1950  if (!testing) {
1951  widget->hide();
1952  if (!drawer)
1953  widget->setFloating(true);
1954  }
1955 
1956  int x, y, w, h;
1957  stream >> x >> y >> w >> h;
1958 
1959 #ifdef Q_WS_MAC // drawer support
1960  if (drawer) {
1962  widget->window()->createWinId();
1964  } else
1965 #endif
1966  if (!testing) {
1967  QRect r(x, y, w, h);
1969  if (desktop->isVirtualDesktop())
1970  r = constrainedRect(r, desktop->screenGeometry(desktop->screenNumber(r.topLeft())));
1971  else
1972  r = constrainedRect(r, desktop->screenGeometry(widget));
1973  widget->move(r.topLeft());
1974  widget->resize(r.size());
1975  }
1976 
1977  if (!testing) {
1978  widget->setVisible(flags & StateFlagVisible);
1980  }
1981  } else {
1982  int dummy;
1983  stream >> item.pos >> item.size >> dummy >> dummy;
1984  if (!testing) {
1986  widget->setFloating(false);
1987  widget->setVisible(flags & StateFlagVisible);
1989  }
1990  }
1991  if (testing) {
1992  //was it is not really added to the layout, we need to delete the object here
1993  delete item.widgetItem;
1994  }
1995  }
1996  } else if (nextMarker == SequenceMarker) {
1997  int dummy;
1998 #ifdef QT_NO_TABBAR
1999  const int tabBarShape = 0;
2000 #endif
2002  tabBarShape, mainWindow));
2003  stream >> item.pos >> item.size >> dummy >> dummy;
2004  //we need to make sure the element is in the list so the dock widget can eventually be docked correctly
2005  if (!testing)
2007 
2008  //here we need to make sure we change the item in the item_list
2009  QDockAreaLayoutItem &lastItem = testing ? item : item_list.last();
2010 
2011  if (!lastItem.subinfo->restoreState(stream, widgets, testing))
2012  return false;
2013 
2014  } else {
2015  return false;
2016  }
2017  }
2018 
2019 #ifndef QT_NO_TABBAR
2020  if (!testing && tabbed && index >= 0 && index < item_list.count()) {
2021  updateTabBar();
2022  setCurrentTabId(tabId(item_list.at(index)));
2023  }
2024  if (!testing && *sep == 1)
2026 #endif
2027 
2028  return true;
2029 }
QList< QDockAreaLayoutItem > item_list
QPointer< QWidget > widget
The QDockWidget class provides a widget that can be docked inside a QMainWindow or floated as a top-l...
Definition: qdockwidget.h:60
void dockLocationChanged(Qt::DockWidgetArea area)
This signal is emitted when the dock widget is moved to another dock area, or is moved to a different...
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
The QString class provides a Unicode character string.
Definition: qstring.h:83
bool restoreState(QDataStream &stream, QList< QDockWidget *> &widgets, bool testing)
void updateSeparatorWidgets() const
void setCurrentTabId(quintptr id)
unsigned char uchar
Definition: qglobal.h:994
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
static quintptr tabId(const QDockAreaLayoutItem &item)
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
const char * name
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
#define emit
Definition: qobjectdefs.h:76
bool isVirtualDesktop() const
static Qt::DockWidgetArea toDockWidgetArea(QInternal::DockPosition pos)
virtual void setVisible(bool visible)
Definition: qwidget.cpp:7991
void hide()
Hides the widget.
Definition: qwidget.h:501
static QDesktopWidget * desktop()
Returns the desktop widget (also called the root window).
DockWidgetArea
Definition: qnamespace.h:1337
const QRect screenGeometry(int screen=-1) const
void resize(int w, int h)
This corresponds to resize(QSize(w, h)).
Definition: qwidget.h:1014
void setFloating(bool floating)
static QRect constrainedRect(QRect rect, const QRect &desktop)
T & last()
Returns a reference to the last item in the list.
Definition: qlist.h:284
QDockAreaLayoutInfo * subinfo
QMainWindow * mainWindow
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
bool qt_mac_set_drawer_preferred_edge(QWidget *w, Qt::DockWidgetArea where)
Definition: qwidget_mac.mm:321
T takeAt(int i)
Removes the item at index position i and returns it.
Definition: qlist.h:484
quint16 index
QWidget * window() const
Returns the window for this widget, i.e.
Definition: qwidget.cpp:4492
void createWinId()
Definition: qwidget.cpp:2626
int screenNumber(const QWidget *widget=0) const
QDockAreaLayoutItem & item(const QList< int > &path)
Orientation
Definition: qnamespace.h:174
bool qt_mac_is_macdrawer(const QWidget *w)
Definition: qwidget_mac.mm:306
QInternal::DockPosition dockPos
void move(int x, int y)
This corresponds to move(QPoint(x, y)).
Definition: qwidget.h:1011
QLayoutItem * widgetItem

◆ saveState()

void QDockAreaLayoutInfo::saveState ( QDataStream stream) const

Definition at line 1781 of file qdockarealayout.cpp.

Referenced by saveState(), and QDockAreaLayout::saveState().

1782 {
1783 #ifndef QT_NO_TABBAR
1784  if (tabbed) {
1785  stream << (uchar) TabMarker;
1786 
1787  // write the index in item_list of the widget that's currently on top.
1788  quintptr id = currentTabId();
1789  int index = -1;
1790  for (int i = 0; i < item_list.count(); ++i) {
1791  if (tabId(item_list.at(i)) == id) {
1792  index = i;
1793  break;
1794  }
1795  }
1796  stream << index;
1797  } else
1798 #endif // QT_NO_TABBAR
1799  {
1800  stream << (uchar) SequenceMarker;
1801  }
1802 
1803  stream << (uchar) o << item_list.count();
1804 
1805  for (int i = 0; i < item_list.count(); ++i) {
1806  const QDockAreaLayoutItem &item = item_list.at(i);
1807  if (item.widgetItem != 0) {
1808  stream << (uchar) WidgetMarker;
1809  QWidget *w = item.widgetItem->widget();
1810  QString name = w->objectName();
1811  if (name.isEmpty()) {
1812  qWarning("QMainWindow::saveState(): 'objectName' not set for QDockWidget %p '%s;",
1813  w, qPrintable(w->windowTitle()));
1814  }
1815  stream << name;
1816 
1817  uchar flags = 0;
1818  if (!w->isHidden())
1819  flags |= StateFlagVisible;
1820  if (w->isWindow())
1821  flags |= StateFlagFloating;
1822  stream << flags;
1823 
1824  if (w->isWindow()) {
1825  stream << w->x() << w->y() << w->width() << w->height();
1826  } else {
1827  stream << item.pos << item.size << pick(o, item.minimumSize())
1828  << pick(o, item.maximumSize());
1829  }
1830  } else if (item.placeHolderItem != 0) {
1831  stream << (uchar) WidgetMarker;
1832  stream << item.placeHolderItem->objectName;
1833  uchar flags = 0;
1834  if (!item.placeHolderItem->hidden)
1835  flags |= StateFlagVisible;
1836  if (item.placeHolderItem->window)
1837  flags |= StateFlagFloating;
1838  stream << flags;
1839  if (item.placeHolderItem->window) {
1841  stream << r.x() << r.y() << r.width() << r.height();
1842  } else {
1843  stream << item.pos << item.size << (int)0 << (int)0;
1844  }
1845  } else if (item.subinfo != 0) {
1846  stream << (uchar) SequenceMarker << item.pos << item.size << pick(o, item.minimumSize()) << pick(o, item.maximumSize());
1847  item.subinfo->saveState(stream);
1848  }
1849  }
1850 }
QList< QDockAreaLayoutItem > item_list
QIntegerForSizeof< void * >::Unsigned quintptr
Definition: qglobal.h:986
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
QPlaceHolderItem * placeHolderItem
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
The QString class provides a Unicode character string.
Definition: qstring.h:83
quintptr currentTabId() const
unsigned char uchar
Definition: qglobal.h:994
static quintptr tabId(const QDockAreaLayoutItem &item)
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
const char * name
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
Q_CORE_EXPORT void qWarning(const char *,...)
QSize maximumSize() const
void saveState(QDataStream &stream) const
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
QDockAreaLayoutInfo * subinfo
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
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.
QDockAreaLayoutItem & item(const QList< int > &path)
#define qPrintable(string)
Definition: qglobal.h:1750
QLayoutItem * widgetItem
QSize minimumSize() const

◆ separatorMove()

int QDockAreaLayoutInfo::separatorMove ( int  index,
int  delta 
)

Definition at line 932 of file qdockarealayout.cpp.

Referenced by QDockAreaLayout::separatorMove().

933 {
934 #ifndef QT_NO_TABBAR
935  Q_ASSERT(!tabbed);
936 #endif
937 
939  for (int i = 0; i < list.size(); ++i) {
940  const QDockAreaLayoutItem &item = item_list.at(i);
941  QLayoutStruct &ls = list[i];
943  if (item.skip()) {
944  ls.empty = true;
945  } else {
946  const int separatorSpace = item.hasFixedSize(o) ? 0 : *sep;
947  ls.empty = false;
948  ls.pos = item.pos;
949  ls.size = item.size + separatorSpace;
950  ls.minimumSize = pick(o, item.minimumSize()) + separatorSpace;
951  ls.maximumSize = pick(o, item.maximumSize()) + separatorSpace;
952 
953  }
954  }
955 
956  //the separator space has been added to the size, so we pass 0 as a parameter
957  delta = separatorMoveHelper(list, index, delta, 0 /*separator*/);
958 
959  for (int i = 0; i < list.size(); ++i) {
960  QDockAreaLayoutItem &item = item_list[i];
961  if (item.skip())
962  continue;
963  QLayoutStruct &ls = list[i];
964  const int separatorSpace = item.hasFixedSize(o) ? 0 : *sep;
965  item.size = ls.size - separatorSpace;
966  item.pos = ls.pos;
967  if (item.subinfo != 0) {
968  item.subinfo->rect = itemRect(i);
969  item.subinfo->fitItems();
970  }
971  }
972 
973  return delta;
974 }
QList< QDockAreaLayoutItem > item_list
static int separatorMoveHelper(QVector< QLayoutStruct > &list, int index, int delta, int sep)
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
QRect itemRect(int index) const
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
QSize maximumSize() const
bool hasFixedSize(Qt::Orientation o) const
QDockAreaLayoutInfo * subinfo
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
quint16 index
static int pick(bool vertical, const QSize &size)
QDockAreaLayoutItem & item(const QList< int > &path)
QSize minimumSize() const

◆ separatorRect() [1/2]

QRect QDockAreaLayoutInfo::separatorRect ( int  index) const

Definition at line 1358 of file qdockarealayout.cpp.

Referenced by findSeparator(), paintSeparators(), separatorRect(), QDockAreaLayout::separatorRect(), separatorRegion(), and updateSeparatorWidgets().

1359 {
1360 #ifndef QT_NO_TABBAR
1361  if (tabbed)
1362  return QRect();
1363 #endif
1364 
1366  if (item.skip())
1367  return QRect();
1368 
1369  QPoint pos = rect.topLeft();
1370  rpick(o, pos) = item.pos + item.size;
1371  QSize s = rect.size();
1372  rpick(o, s) = *sep;
1373 
1374  return QRect(pos, s);
1375 }
QList< QDockAreaLayoutItem > item_list
static int & rpick(Qt::Orientation o, QPoint &pos)
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
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
quint16 index
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
QDockAreaLayoutItem & item(const QList< int > &path)
QPoint topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:288

◆ separatorRect() [2/2]

QRect QDockAreaLayoutInfo::separatorRect ( const QList< int > &  path) const

Definition at line 1377 of file qdockarealayout.cpp.

1378 {
1379  Q_ASSERT(!path.isEmpty());
1380 
1381  const int index = path.first();
1382  if (path.count() > 1) {
1383  const QDockAreaLayoutItem &item = item_list.at(index);
1384  Q_ASSERT(item.subinfo != 0);
1385  return item.subinfo->separatorRect(path.mid(1));
1386  }
1387  return separatorRect(index);
1388 }
QList< QDockAreaLayoutItem > item_list
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
QRect separatorRect(int index) const
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
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
T & first()
Returns a reference to the first item in the list.
Definition: qlist.h:282
QDockAreaLayoutInfo * subinfo
quint16 index
QDockAreaLayoutItem & item(const QList< int > &path)

◆ separatorRegion()

QRegion QDockAreaLayoutInfo::separatorRegion ( ) const

Definition at line 1589 of file qdockarealayout.cpp.

Referenced by separatorRegion(), and QDockAreaLayout::separatorRegion().

1590 {
1591  QRegion result;
1592 
1593  if (isEmpty())
1594  return result;
1595 #ifndef QT_NO_TABBAR
1596  if (tabbed)
1597  return result;
1598 #endif
1599 
1600  for (int i = 0; i < item_list.count(); ++i) {
1601  const QDockAreaLayoutItem &item = item_list.at(i);
1602 
1603  if (item.skip())
1604  continue;
1605 
1606  int next = this->next(i);
1607 
1608  if (item.subinfo)
1609  result |= item.subinfo->separatorRegion();
1610 
1611  if (next == -1)
1612  break;
1613  result |= separatorRect(i);
1614  }
1615 
1616  return result;
1617 }
QList< QDockAreaLayoutItem > item_list
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
QRect separatorRect(int index) const
int next(int idx) const
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
QDockAreaLayoutInfo * subinfo
QDockAreaLayoutItem & item(const QList< int > &path)
QRegion separatorRegion() const

◆ setCurrentTab()

void QDockAreaLayoutInfo::setCurrentTab ( QWidget widget)

Definition at line 1115 of file qdockarealayout.cpp.

Referenced by QMainWindowLayout::raise(), and tab().

1116 {
1117  setCurrentTabId(reinterpret_cast<quintptr>(widget));
1118 }
void setCurrentTabId(quintptr id)

◆ setCurrentTabId()

void QDockAreaLayoutInfo::setCurrentTabId ( quintptr  id)

Definition at line 1120 of file qdockarealayout.cpp.

Referenced by QDockAreaLayout::addDockWidget(), restoreState(), and setCurrentTab().

1121 {
1122  if (!tabbed || tabBar == 0)
1123  return;
1124 
1125  for (int i = 0; i < tabBar->count(); ++i) {
1126  if (qvariant_cast<quintptr>(tabBar->tabData(i)) == id) {
1127  tabBar->setCurrentIndex(i);
1128  return;
1129  }
1130  }
1131 }
QVariant tabData(int index) const
Returns the data of the tab at position index, or a null variant if index is out of range...
Definition: qtabbar.cpp:1167
void setCurrentIndex(int index)
Definition: qtabbar.cpp:1238
int count
the number of tabs in the tab bar
Definition: qtabbar.h:66

◆ setTabBarShape()

void QDockAreaLayoutInfo::setTabBarShape ( int  shape)

Definition at line 2156 of file qdockarealayout.cpp.

Referenced by setTabBarShape(), and QMainWindowLayout::updateTabBarShapes().

2157 {
2158  if (shape == tabBarShape)
2159  return;
2160  tabBarShape = shape;
2161  if (tabBar != 0)
2162  tabBar->setShape(static_cast<QTabBar::Shape>(shape));
2163 
2164  for (int i = 0; i < item_list.count(); ++i) {
2166  if (item.subinfo != 0)
2167  item.subinfo->setTabBarShape(shape);
2168  }
2169 }
QList< QDockAreaLayoutItem > item_list
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
void setShape(Shape shape)
Definition: qtabbar.cpp:778
void setTabBarShape(int shape)
QDockAreaLayoutInfo * subinfo
QDockAreaLayoutItem & item(const QList< int > &path)

◆ size()

QSize QDockAreaLayoutInfo::size ( ) const

Definition at line 249 of file qdockarealayout.cpp.

Referenced by fitItems(), and QDockAreaLayout::getGrid().

250 {
251  return isEmpty() ? QSize(0, 0) : rect.size();
252 }
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53

◆ sizeHint()

QSize QDockAreaLayoutInfo::sizeHint ( ) const

Definition at line 395 of file qdockarealayout.cpp.

Referenced by QDockAreaLayoutItem::sizeHint(), and QDockAreaLayout::sizeHint().

396 {
397  if (isEmpty())
398  return QSize(0, 0);
399 
400  int a = 0, b = 0;
401  int min_perp = 0;
402  int max_perp = QWIDGETSIZE_MAX;
403  const QDockAreaLayoutItem *previous = 0;
404  for (int i = 0; i < item_list.size(); ++i) {
405  const QDockAreaLayoutItem &item = item_list.at(i);
406  if (item.skip())
407  continue;
408 
409  bool gap = item.flags & QDockAreaLayoutItem::GapItem;
410 
411  QSize size_hint = item.sizeHint();
412  min_perp = qMax(min_perp, perp(o, item.minimumSize()));
413  max_perp = qMin(max_perp, perp(o, item.maximumSize()));
414 
415 #ifndef QT_NO_TABBAR
416  if (tabbed) {
417  a = qMax(a, gap ? item.size : pick(o, size_hint));
418  } else
419 #endif
420  {
421  if (previous && !gap && !(previous->flags & QDockAreaLayoutItem::GapItem)
422  && !previous->hasFixedSize(o)) {
423  a += *sep;
424  }
425  a += gap ? item.size : pick(o, size_hint);
426  }
427  b = qMax(b, perp(o, size_hint));
428 
429  previous = &item;
430  }
431 
432  max_perp = qMax(max_perp, min_perp);
433  b = qMax(b, min_perp);
434  b = qMin(b, max_perp);
435 
436  QSize result;
437  rpick(o, result) = a;
438  rperp(o, result) = b;
439 
440 #ifndef QT_NO_TABBAR
441  if (tabbed) {
442  QSize tbh = tabBarSizeHint();
443  switch (tabBarShape) {
448  result.rheight() += tbh.height();
449  result.rwidth() = qMax(tbh.width(), result.width());
450  break;
455  result.rheight() = qMax(tbh.height(), result.height());
456  result.rwidth() += tbh.width();
457  break;
458  default:
459  break;
460  }
461  }
462 #endif // QT_NO_TABBAR
463 
464  return result;
465 }
QList< QDockAreaLayoutItem > item_list
static int qMax(int i1, int i2, int i3)
static int & rpick(Qt::Orientation o, QPoint &pos)
#define QWIDGETSIZE_MAX
Defines the maximum size for a QWidget object.
Definition: qwidget.h:1087
long ASN1_INTEGER_get ASN1_INTEGER * a
static int qMin(int i1, int i2, int i3)
int width() const
Returns the width.
Definition: qsize.h:126
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
QSize maximumSize() const
static int perp(bool vertical, const QSize &size)
bool hasFixedSize(Qt::Orientation o) const
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
int & rheight()
Returns a reference to the height.
Definition: qsize.h:144
int height() const
Returns the height.
Definition: qsize.h:129
static int pick(bool vertical, const QSize &size)
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
static int & rperp(Qt::Orientation o, QPoint &pos)
QSize tabBarSizeHint() const
QDockAreaLayoutItem & item(const QList< int > &path)
int & rwidth()
Returns a reference to the width.
Definition: qsize.h:141
QSize minimumSize() const

◆ split()

void QDockAreaLayoutInfo::split ( int  index,
Qt::Orientation  orientation,
QLayoutItem dockWidgetItem 
)

Definition at line 1696 of file qdockarealayout.cpp.

Referenced by QDockAreaLayout::splitDockWidget().

1698 {
1699  if (orientation == o) {
1700  item_list.insert(index + 1, QDockAreaLayoutItem(dockWidgetItem));
1701  } else {
1702 #ifdef QT_NO_TABBAR
1703  const int tabBarShape = 0;
1704 #endif
1705  QDockAreaLayoutInfo *new_info
1706  = new QDockAreaLayoutInfo(sep, dockPos, orientation, tabBarShape, mainWindow);
1707  item_list[index].subinfo = new_info;
1709  item_list[index].widgetItem = 0;
1710  new_info->item_list.append(dockWidgetItem);
1711  }
1712 }
QList< QDockAreaLayoutItem > item_list
void insert(int i, const T &t)
Inserts value at index position i in the list.
Definition: qlist.h:575
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
QMainWindow * mainWindow
quint16 index
QInternal::DockPosition dockPos
QLayoutItem * widgetItem

◆ tab()

void QDockAreaLayoutInfo::tab ( int  index,
QLayoutItem dockWidgetItem 
)

Definition at line 1672 of file qdockarealayout.cpp.

Referenced by QDockAreaLayout::tabifyDockWidget().

1673 {
1674 #ifdef QT_NO_TABBAR
1675  Q_UNUSED(index);
1676  Q_UNUSED(dockWidgetItem);
1677 #else
1678  if (tabbed) {
1679  item_list.append(QDockAreaLayoutItem(dockWidgetItem));
1680  updateTabBar();
1681  setCurrentTab(dockWidgetItem->widget());
1682  } else {
1683  QDockAreaLayoutInfo *new_info
1685  item_list[index].subinfo = new_info;
1687  item_list[index].widgetItem = 0;
1688  new_info->item_list.append(dockWidgetItem);
1689  new_info->tabbed = true;
1690  new_info->updateTabBar();
1691  new_info->setCurrentTab(dockWidgetItem->widget());
1692  }
1693 #endif // QT_NO_TABBAR
1694 }
QList< QDockAreaLayoutItem > item_list
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
void setCurrentTab(QWidget *widget)
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
QMainWindow * mainWindow
quint16 index
virtual QWidget * widget()
If this item is a QWidget, it is returned as a QWidget; otherwise 0 is returned.
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
QInternal::DockPosition dockPos
QLayoutItem * widgetItem

◆ tabBarMinimumSize()

QSize QDockAreaLayoutInfo::tabBarMinimumSize ( ) const

Definition at line 2171 of file qdockarealayout.cpp.

Referenced by minimumSize().

2172 {
2173  if (!updateTabBar())
2174  return QSize(0, 0);
2175 
2176  return tabBar->minimumSizeHint();
2177 }
QSize minimumSizeHint() const
Definition: qtabbar.cpp:1331
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53

◆ tabBarSizeHint()

QSize QDockAreaLayoutInfo::tabBarSizeHint ( ) const

Definition at line 2179 of file qdockarealayout.cpp.

Referenced by apply(), maximumSize(), sizeHint(), and tabContentRect().

2180 {
2181  if (!updateTabBar())
2182  return QSize(0, 0);
2183 
2184  return tabBar->sizeHint();
2185 }
QSize sizeHint() const
em>Reimplemented Function
Definition: qtabbar.cpp:1317
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53

◆ tabContentRect()

QRect QDockAreaLayoutInfo::tabContentRect ( ) const

Definition at line 2223 of file qdockarealayout.cpp.

Referenced by gapIndex(), QDockAreaLayout::gapRect(), and itemRect().

2224 {
2225  if (!tabbed)
2226  return QRect();
2227 
2228  QRect result = rect;
2229  QSize tbh = tabBarSizeHint();
2230 
2231  if (!tbh.isNull()) {
2232  switch (tabBarShape) {
2233  case QTabBar::RoundedNorth:
2235  result.adjust(0, tbh.height(), 0, 0);
2236  break;
2237  case QTabBar::RoundedSouth:
2239  result.adjust(0, 0, 0, -tbh.height());
2240  break;
2241  case QTabBar::RoundedEast:
2243  result.adjust(0, 0, -tbh.width(), 0);
2244  break;
2245  case QTabBar::RoundedWest:
2247  result.adjust(tbh.width(), 0, 0, 0);
2248  break;
2249  default:
2250  break;
2251  }
2252  }
2253 
2254  return result;
2255 }
int width() const
Returns the width.
Definition: qsize.h:126
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
int height() const
Returns the height.
Definition: qsize.h:129
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
bool isNull() const
Returns true if both the width and height is 0; otherwise returns false.
Definition: qsize.h:117
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
QSize tabBarSizeHint() const

◆ takeAt()

QLayoutItem * QDockAreaLayoutInfo::takeAt ( int *  x,
int  index 
)

Definition at line 1743 of file qdockarealayout.cpp.

Referenced by takeAt(), and QDockAreaLayout::takeAt().

1744 {
1745  for (int i = 0; i < item_list.count(); ++i) {
1747  if (item.placeHolderItem != 0)
1748  continue;
1749  else if (item.subinfo) {
1750  if (QLayoutItem *ret = item.subinfo->takeAt(x, index)) {
1751  unnest(i);
1752  return ret;
1753  }
1754  } else if (item.widgetItem) {
1755  if ((*x)++ == index) {
1756  item.placeHolderItem = new QPlaceHolderItem(item.widgetItem->widget());
1757  QLayoutItem *ret = item.widgetItem;
1758  item.widgetItem = 0;
1759  if (item.size != -1)
1761  return ret;
1762  }
1763  }
1764  }
1765  return 0;
1766 }
QList< QDockAreaLayoutItem > item_list
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
QPlaceHolderItem * placeHolderItem
void unnest(int index)
The QLayoutItem class provides an abstract item that a QLayout manipulates.
Definition: qlayoutitem.h:64
QLayoutItem * takeAt(int *x, int index)
QDockAreaLayoutInfo * subinfo
quint16 index
virtual QWidget * widget()
If this item is a QWidget, it is returned as a QWidget; otherwise 0 is returned.
QDockAreaLayoutItem & item(const QList< int > &path)
QLayoutItem * widgetItem

◆ unnest()

void QDockAreaLayoutInfo::unnest ( int  index)

Definition at line 976 of file qdockarealayout.cpp.

Referenced by remove(), and takeAt().

977 {
979  if (item.subinfo == 0)
980  return;
981  if (item.subinfo->item_list.count() > 1)
982  return;
983 
984  if (item.subinfo->item_list.count() == 0) {
986  } else if (item.subinfo->item_list.count() == 1) {
987  QDockAreaLayoutItem &child = item.subinfo->item_list.first();
988  if (child.widgetItem != 0) {
989  item.widgetItem = child.widgetItem;
990  delete item.subinfo;
991  item.subinfo = 0;
992  } else if (child.subinfo != 0) {
993  QDockAreaLayoutInfo *tmp = item.subinfo;
994  item.subinfo = child.subinfo;
995  child.subinfo = 0;
996  tmp->item_list.clear();
997  delete tmp;
998  }
999  }
1000 }
QList< QDockAreaLayoutItem > item_list
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
void clear()
Removes all items from the list.
Definition: qlist.h:764
T & first()
Returns a reference to the first item in the list.
Definition: qlist.h:282
QDockAreaLayoutInfo * subinfo
quint16 index
QDockAreaLayoutItem & item(const QList< int > &path)
QLayoutItem * widgetItem
void removeAt(int i)
Removes the item at index position i.
Definition: qlist.h:480

◆ unplug()

QLayoutItem * QDockAreaLayoutInfo::unplug ( const QList< int > &  path)

Definition at line 1067 of file qdockarealayout.cpp.

Referenced by unplug(), and QDockAreaLayout::unplug().

1068 {
1069  Q_ASSERT(!path.isEmpty());
1070 
1071  const int index = path.first();
1072  if (path.count() > 1) {
1073  const QDockAreaLayoutItem &item = item_list.at(index);
1074  Q_ASSERT(item.subinfo != 0);
1075  return item.subinfo->unplug(path.mid(1));
1076  }
1077 
1079  int prev = this->prev(index);
1080  int next = this->next(index);
1081 
1084 
1085 #ifndef QT_NO_TABBAR
1086  if (tabbed) {
1087  } else
1088 #endif
1089  {
1090  if (prev != -1 && !(item_list.at(prev).flags & QDockAreaLayoutItem::GapItem)) {
1091  item.pos -= *sep;
1092  item.size += *sep;
1093  }
1094  if (next != -1 && !(item_list.at(next).flags & QDockAreaLayoutItem::GapItem))
1095  item.size += *sep;
1096  }
1097 
1098  return item.widgetItem;
1099 }
QLayoutItem * unplug(const QList< int > &path)
QList< QDockAreaLayoutItem > item_list
int prev(int idx) const
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
int next(int idx) const
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
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
T & first()
Returns a reference to the first item in the list.
Definition: qlist.h:282
QDockAreaLayoutInfo * subinfo
quint16 index
QDockAreaLayoutItem & item(const QList< int > &path)
QLayoutItem * widgetItem

◆ updateSeparatorWidgets()

void QDockAreaLayoutInfo::updateSeparatorWidgets ( ) const

Definition at line 2032 of file qdockarealayout.cpp.

Referenced by apply(), restoreState(), and updateSeparatorWidgets().

2033 {
2034  if (tabbed) {
2036  return;
2037  }
2038 
2039  int j = 0;
2040  for (int i = 0; i < item_list.count(); ++i) {
2041  const QDockAreaLayoutItem &item = item_list.at(i);
2042 
2043  if (item.skip())
2044  continue;
2045 
2046  int next = this->next(i);
2047  if ((item.flags & QDockAreaLayoutItem::GapItem)
2048  || (next != -1 && (item_list.at(next).flags & QDockAreaLayoutItem::GapItem)))
2049  continue;
2050 
2051  if (item.subinfo) {
2053  }
2054 
2055  if (next == -1)
2056  break;
2057 
2058  QWidget *sepWidget;
2059  if (j < separatorWidgets.size() && separatorWidgets.at(j)) {
2060  sepWidget = separatorWidgets.at(j);
2061  } else {
2062  sepWidget = mainWindowLayout()->getSeparatorWidget();
2063  separatorWidgets.append(sepWidget);
2064  }
2065  j++;
2066 
2067 #ifndef QT_MAC_USE_COCOA
2068  sepWidget->raise();
2069 #endif
2070  QRect sepRect = separatorRect(i).adjusted(-2, -2, 2, 2);
2071  sepWidget->setGeometry(sepRect);
2072  sepWidget->setMask( QRegion(separatorRect(i).translated( - sepRect.topLeft())));
2073  sepWidget->show();
2074  }
2075 
2076  for (int k = j; k < separatorWidgets.size(); ++k) {
2077  separatorWidgets[k]->hide();
2078  }
2080  Q_ASSERT(separatorWidgets.size() == j);
2081 }
QList< QDockAreaLayoutItem > item_list
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
QWidget * getSeparatorWidget()
QVector< QWidget * > separatorWidgets
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
void setGeometry(int x, int y, int w, int h)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qwidget.h:1017
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
QRect separatorRect(int index) const
int next(int idx) const
void resize(int size)
Sets the size of the vector to size.
Definition: qvector.h:342
void updateSeparatorWidgets() const
QMainWindowLayout * mainWindowLayout() const
void clear()
Removes all the elements from the vector and releases the memory used by the vector.
Definition: qvector.h:347
void raise()
Raises this widget to the top of the parent widget&#39;s stack.
Definition: qwidget.cpp:11901
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
void append(const T &t)
Inserts value at the end of the vector.
Definition: qvector.h:573
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
void show()
Shows the widget and its child widgets.
void setMask(const QBitmap &)
Causes only the pixels of the widget for which bitmap has a corresponding 1 bit to be visible...
Definition: qwidget.cpp:13309
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
QDockAreaLayoutInfo * subinfo
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
QDockAreaLayoutItem & item(const QList< int > &path)
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137
QPoint topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:288

◆ updateTabBar()

bool QDockAreaLayoutInfo::updateTabBar ( ) const

Definition at line 2086 of file qdockarealayout.cpp.

Referenced by QDockAreaLayout::addDockWidget(), restoreState(), tab(), tabBarMinimumSize(), tabBarSizeHint(), and usedTabBars().

2087 {
2088  if (!tabbed)
2089  return false;
2090 
2091  QDockAreaLayoutInfo *that = const_cast<QDockAreaLayoutInfo*>(this);
2092 
2093  if (that->tabBar == 0) {
2094  that->tabBar = mainWindowLayout()->getTabBar();
2095  that->tabBar->setShape(static_cast<QTabBar::Shape>(tabBarShape));
2096  that->tabBar->setDrawBase(true);
2097  }
2098 
2099  bool blocked = tabBar->blockSignals(true);
2100  bool gap = false;
2101 
2102  int tab_idx = 0;
2103  for (int i = 0; i < item_list.count(); ++i) {
2104  const QDockAreaLayoutItem &item = item_list.at(i);
2105  if (item.skip())
2106  continue;
2107  if (item.flags & QDockAreaLayoutItem::GapItem) {
2108  gap = true;
2109  continue;
2110  }
2111  if (item.widgetItem == 0)
2112  continue;
2113 
2115  QString title = dw->d_func()->fixedWindowTitle;
2116  quintptr id = tabId(item);
2117  if (tab_idx == tabBar->count()) {
2118  tabBar->insertTab(tab_idx, title);
2119 #ifndef QT_NO_TOOLTIP
2120  tabBar->setTabToolTip(tab_idx, title);
2121 #endif
2122  tabBar->setTabData(tab_idx, id);
2123  } else if (qvariant_cast<quintptr>(tabBar->tabData(tab_idx)) != id) {
2124  if (tab_idx + 1 < tabBar->count()
2125  && qvariant_cast<quintptr>(tabBar->tabData(tab_idx + 1)) == id)
2126  tabBar->removeTab(tab_idx);
2127  else {
2128  tabBar->insertTab(tab_idx, title);
2129 #ifndef QT_NO_TOOLTIP
2130  tabBar->setTabToolTip(tab_idx, title);
2131 #endif
2132  tabBar->setTabData(tab_idx, id);
2133  }
2134  }
2135 
2136  if (title != tabBar->tabText(tab_idx)) {
2137  tabBar->setTabText(tab_idx, title);
2138 #ifndef QT_NO_TOOLTIP
2139  tabBar->setTabToolTip(tab_idx, title);
2140 #endif
2141  }
2142 
2143  ++tab_idx;
2144  }
2145 
2146  while (tab_idx < tabBar->count()) {
2147  tabBar->removeTab(tab_idx);
2148  }
2149 
2150  tabBar->blockSignals(blocked);
2151 
2152  //returns if the tabbar is visible or not
2153  return ( (gap ? 1 : 0) + tabBar->count()) > 1;
2154 }
void setDrawBase(bool drawTheBase)
Definition: qtabbar.cpp:800
T qobject_cast(QObject *object)
Definition: qobject.h:375
bool blockSignals(bool b)
If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke...
Definition: qobject.cpp:1406
QList< QDockAreaLayoutItem > item_list
QIntegerForSizeof< void * >::Unsigned quintptr
Definition: qglobal.h:986
The QDockWidget class provides a widget that can be docked inside a QMainWindow or floated as a top-l...
Definition: qdockwidget.h:60
QVariant tabData(int index) const
Returns the data of the tab at position index, or a null variant if index is out of range...
Definition: qtabbar.cpp:1167
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
The QString class provides a Unicode character string.
Definition: qstring.h:83
void removeTab(int index)
Removes the tab at position index.
Definition: qtabbar.cpp:902
void setTabText(int index, const QString &text)
Sets the text of the tab at position index to text.
Definition: qtabbar.cpp:1021
QMainWindowLayout * mainWindowLayout() const
static quintptr tabId(const QDockAreaLayoutItem &item)
void setTabToolTip(int index, const QString &tip)
Sets the tool tip of the tab at position index to tip.
Definition: qtabbar.cpp:1097
int insertTab(int index, const QString &text)
Inserts a new tab with text text at position index.
Definition: qtabbar.cpp:843
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
void setShape(Shape shape)
Definition: qtabbar.cpp:778
void setTabData(int index, const QVariant &data)
Sets the data of the tab at position index to data.
Definition: qtabbar.cpp:1156
int count
the number of tabs in the tab bar
Definition: qtabbar.h:66
QString tabText(int index) const
Returns the text of the tab at position index, or an empty string if index is out of range...
Definition: qtabbar.cpp:1010
T qvariant_cast(const QVariant &)
Definition: qvariant.h:571
virtual QWidget * widget()
If this item is a QWidget, it is returned as a QWidget; otherwise 0 is returned.
QDockAreaLayoutItem & item(const QList< int > &path)
QLayoutItem * widgetItem

◆ usedSeparatorWidgets()

QSet< QWidget * > QDockAreaLayoutInfo::usedSeparatorWidgets ( ) const

Definition at line 2207 of file qdockarealayout.cpp.

Referenced by usedSeparatorWidgets(), and QDockAreaLayout::usedSeparatorWidgets().

2208 {
2209  QSet<QWidget*> result;
2210 
2211  for (int i = 0; i < separatorWidgets.count(); ++i)
2212  result << separatorWidgets.at(i);
2213 
2214  for (int i = 0; i < item_list.count(); ++i) {
2215  const QDockAreaLayoutItem &item = item_list.at(i);
2216  if (item.subinfo != 0)
2217  result += item.subinfo->usedSeparatorWidgets();
2218  }
2219 
2220  return result;
2221 }
QList< QDockAreaLayoutItem > item_list
int count(const T &t) const
Returns the number of occurrences of value in the vector.
Definition: qvector.h:742
QVector< QWidget * > separatorWidgets
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
QSet< QWidget * > usedSeparatorWidgets() const
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
QDockAreaLayoutInfo * subinfo
QDockAreaLayoutItem & item(const QList< int > &path)

◆ usedTabBars()

QSet< QTabBar * > QDockAreaLayoutInfo::usedTabBars ( ) const

Definition at line 2187 of file qdockarealayout.cpp.

Referenced by usedTabBars(), and QDockAreaLayout::usedTabBars().

2188 {
2189  QSet<QTabBar*> result;
2190 
2191  if (tabbed) {
2192  updateTabBar();
2193  result.insert(tabBar);
2194  }
2195 
2196  for (int i = 0; i < item_list.count(); ++i) {
2197  const QDockAreaLayoutItem &item = item_list.at(i);
2198  if (item.subinfo != 0)
2199  result += item.subinfo->usedTabBars();
2200  }
2201 
2202  return result;
2203 }
QList< QDockAreaLayoutItem > item_list
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
const_iterator insert(const T &value)
Definition: qset.h:179
QDockAreaLayoutInfo * subinfo
QDockAreaLayoutItem & item(const QList< int > &path)
QSet< QTabBar * > usedTabBars() const

Properties

◆ dockPos

QInternal::DockPosition QDockAreaLayoutInfo::dockPos

Definition at line 194 of file qdockarealayout_p.h.

Referenced by insertGap(), restoreState(), split(), and tab().

◆ item_list

QList<QDockAreaLayoutItem> QDockAreaLayoutInfo::item_list

◆ mainWindow

QMainWindow* QDockAreaLayoutInfo::mainWindow

Definition at line 197 of file qdockarealayout_p.h.

Referenced by insertGap(), mainWindowLayout(), restoreState(), split(), and tab().

◆ o

Qt::Orientation QDockAreaLayoutInfo::o

◆ rect

QRect QDockAreaLayoutInfo::rect

◆ sep

const int* QDockAreaLayoutInfo::sep

◆ separatorWidgets

QVector<QWidget*> QDockAreaLayoutInfo::separatorWidgets
mutable

Definition at line 193 of file qdockarealayout_p.h.

Referenced by updateSeparatorWidgets(), and usedSeparatorWidgets().

◆ tabBar

QTabBar* QDockAreaLayoutInfo::tabBar

◆ tabBarShape

int QDockAreaLayoutInfo::tabBarShape

◆ tabbed

bool QDockAreaLayoutInfo::tabbed

The documentation for this class was generated from the following files: