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

#include <qdockarealayout_p.h>

Public Types

enum  { EmptyDropAreaSize = 80 }
 
enum  { DockWidgetStateMarker = 0xfd }
 

Public Functions

void addDockWidget (QInternal::DockPosition pos, QDockWidget *dockWidget, Qt::Orientation orientation)
 
void apply (bool animate)
 
void clear ()
 
void deleteAllLayoutItems ()
 
QList< int > findSeparator (const QPoint &pos) const
 
void fitLayout ()
 
QList< int > gapIndex (const QPoint &pos) const
 
QRect gapRect (const QList< int > &path) const
 
void getGrid (QVector< QLayoutStruct > *ver_struct_list, QVector< QLayoutStruct > *hor_struct_list)
 
QList< int > indexOf (QWidget *dockWidget) const
 
QList< int > indexOfPlaceHolder (const QString &objectName) const
 
QDockAreaLayoutInfoinfo (const QList< int > &path)
 
const QDockAreaLayoutInfoinfo (const QList< int > &path) const
 
QDockAreaLayoutInfoinfo (QWidget *widget)
 
bool insertGap (const QList< int > &path, QLayoutItem *dockWidgetItem)
 
bool isValid () const
 
QDockAreaLayoutItemitem (const QList< int > &path)
 
QLayoutItemitemAt (int *x, int index) const
 
QRect itemRect (const QList< int > &path) const
 
void keepSize (QDockWidget *w)
 
QSize minimumSize () const
 
void paintSeparators (QPainter *p, QWidget *widget, const QRegion &clip, const QPoint &mouse) const
 
QLayoutItemplug (const QList< int > &path)
 
 QDockAreaLayout (QMainWindow *win)
 
void remove (const QList< int > &path)
 
bool restoreDockWidget (QDockWidget *dockWidget)
 
bool restoreState (QDataStream &stream, const QList< QDockWidget *> &widgets, bool testing=false)
 
void saveState (QDataStream &stream) const
 
int separatorMove (const QList< int > &separator, const QPoint &origin, const QPoint &dest)
 
QRect separatorRect (int index) const
 
QRect separatorRect (const QList< int > &path) const
 
QRegion separatorRegion () const
 
void setGrid (QVector< QLayoutStruct > *ver_struct_list, QVector< QLayoutStruct > *hor_struct_list)
 
QSize sizeHint () const
 
void splitDockWidget (QDockWidget *after, QDockWidget *dockWidget, Qt::Orientation orientation)
 
void styleChangedEvent ()
 
void tabifyDockWidget (QDockWidget *first, QDockWidget *second)
 
QLayoutItemtakeAt (int *x, int index)
 
QLayoutItemunplug (const QList< int > &path)
 
void updateSeparatorWidgets () const
 
QSet< QWidget * > usedSeparatorWidgets () const
 
QSet< QTabBar * > usedTabBars () const
 

Public Variables

QLayoutItemcentralWidgetItem
 
QRect centralWidgetRect
 
Qt::DockWidgetArea corners [4]
 
QDockAreaLayoutInfo docks [4]
 
bool fallbackToSizeHints
 
QMainWindowmainWindow
 
QRect rect
 
int sep
 
QVector< QWidget * > separatorWidgets
 

Detailed Description

Definition at line 222 of file qdockarealayout_p.h.

Enumerations

◆ anonymous enum

anonymous enum
Enumerator
EmptyDropAreaSize 

Definition at line 225 of file qdockarealayout_p.h.

225 { EmptyDropAreaSize = 80 }; // when a dock area is empty, how "wide" is it?

◆ anonymous enum

anonymous enum
Enumerator
DockWidgetStateMarker 

Definition at line 240 of file qdockarealayout_p.h.

Constructors and Destructors

◆ QDockAreaLayout()

QDockAreaLayout::QDockAreaLayout ( QMainWindow win)

Definition at line 2262 of file qdockarealayout.cpp.

2262  : fallbackToSizeHints(true)
2263 {
2264  mainWindow = win;
2266 #ifndef QT_NO_TABBAR
2267  const int tabShape = QTabBar::RoundedSouth;
2268 #else
2269  const int tabShape = 0;
2270 #endif
2279  centralWidgetItem = 0;
2280 
2281 
2286 }
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const =0
Returns the value of the given pixel metric.
QStyle * style() const
Definition: qwidget.cpp:2742
QLayoutItem * centralWidgetItem
QMainWindow * mainWindow
QDockAreaLayoutInfo docks[4]
Qt::DockWidgetArea corners[4]

Functions

◆ addDockWidget()

void QDockAreaLayout::addDockWidget ( QInternal::DockPosition  pos,
QDockWidget dockWidget,
Qt::Orientation  orientation 
)

Definition at line 3002 of file qdockarealayout.cpp.

3004 {
3005  QLayoutItem *dockWidgetItem = new QDockWidgetItem(dockWidget);
3006  QDockAreaLayoutInfo &info = docks[pos];
3007  if (orientation == info.o || info.item_list.count() <= 1) {
3008  // empty dock areas, or dock areas containing exactly one widget can have their orientation
3009  // switched.
3010  info.o = orientation;
3011 
3012  QDockAreaLayoutItem new_item(dockWidgetItem);
3013  info.item_list.append(new_item);
3014 #ifndef QT_NO_TABBAR
3015  if (info.tabbed && !new_item.skip()) {
3016  info.updateTabBar();
3017  info.setCurrentTabId(tabId(new_item));
3018  }
3019 #endif
3020  } else {
3021 #ifndef QT_NO_TABBAR
3022  int tbshape = info.tabBarShape;
3023 #else
3024  int tbshape = 0;
3025 #endif
3026  QDockAreaLayoutInfo new_info(&sep, pos, orientation, tbshape, mainWindow);
3027  new_info.item_list.append(new QDockAreaLayoutInfo(info));
3028  new_info.item_list.append(dockWidgetItem);
3029  info = new_info;
3030  }
3031 
3032  QList<int> index = indexOfPlaceHolder(dockWidget->objectName());
3033  if (!index.isEmpty())
3034  remove(index);
3035 }
QList< QDockAreaLayoutItem > item_list
QList< int > indexOfPlaceHolder(const QString &objectName) const
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
void setCurrentTabId(quintptr id)
QMainWindow * mainWindow
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
The QLayoutItem class provides an abstract item that a QLayout manipulates.
Definition: qlayoutitem.h:64
static quintptr tabId(const QDockAreaLayoutItem &item)
QDockAreaLayoutInfo * info(const QList< int > &path)
QDockAreaLayoutInfo docks[4]
QString objectName() const
quint16 index

◆ apply()

void QDockAreaLayout::apply ( bool  animate)

Definition at line 3069 of file qdockarealayout.cpp.

Referenced by QMainWindowLayoutState::apply(), and separatorMove().

3070 {
3072 
3073  for (int i = 0; i < QInternal::DockCount; ++i)
3074  docks[i].apply(animate);
3075  if (centralWidgetItem != 0 && !centralWidgetItem->isEmpty()) {
3077  animate);
3078  }
3079 #ifndef QT_NO_TABBAR
3080  if (sep == 1)
3082 #endif //QT_NO_TABBAR
3083 }
virtual bool isEmpty() const =0
Implemented in subclasses to return whether this item is empty, i.
void updateSeparatorWidgets() const
QLayoutItem * centralWidgetItem
QMainWindow * mainWindow
QDockAreaLayoutInfo docks[4]
void apply(bool animate)
virtual QWidget * widget()
If this item is a QWidget, it is returned as a QWidget; otherwise 0 is returned.
QWidgetAnimator widgetAnimator
QMainWindowLayout * qt_mainwindow_layout(const QMainWindow *window)
void animate(QWidget *widget, const QRect &final_geometry, bool animate)

◆ clear()

void QDockAreaLayout::clear ( )

Definition at line 2864 of file qdockarealayout.cpp.

Referenced by QMainWindowLayoutState::clear().

2865 {
2866  for (int i = 0; i < QInternal::DockCount; ++i)
2867  docks[i].clear();
2868 
2869  rect = QRect();
2871 }
QDockAreaLayoutInfo docks[4]
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58

◆ deleteAllLayoutItems()

void QDockAreaLayout::deleteAllLayoutItems ( )

Definition at line 3231 of file qdockarealayout.cpp.

Referenced by QMainWindowLayoutState::deleteAllLayoutItems().

3232 {
3233  for (int i = 0; i < QInternal::DockCount; ++i)
3235 }
QDockAreaLayoutInfo docks[4]

◆ findSeparator()

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

Definition at line 2446 of file qdockarealayout.cpp.

2447 {
2448  QList<int> result;
2449  for (int i = 0; i < QInternal::DockCount; ++i) {
2450  const QDockAreaLayoutInfo &info = docks[i];
2451  if (info.isEmpty())
2452  continue;
2453  QRect rect = separatorRect(i);
2454  if (!rect.isNull() && sep == 1)
2455  rect.adjust(-2, -2, 2, 2);
2456  if (rect.contains(pos) && !info.hasFixedSize()) {
2457  result << i;
2458  break;
2459  } else if (info.rect.contains(pos)) {
2460  result = docks[i].findSeparator(pos);
2461  if (!result.isEmpty()) {
2462  result.prepend(i);
2463  break;
2464  }
2465  }
2466  }
2467 
2468  return result;
2469 }
bool isNull() const
Returns true if the rectangle is a null rectangle, otherwise returns false.
Definition: qrect.h:231
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
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
QDockAreaLayoutInfo * info(const QList< int > &path)
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
QDockAreaLayoutInfo docks[4]
QList< int > findSeparator(const QPoint &pos) const
QRect separatorRect(int index) const
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58

◆ fitLayout()

void QDockAreaLayout::fitLayout ( )

Definition at line 2852 of file qdockarealayout.cpp.

Referenced by QMainWindowLayoutState::fitLayout(), and styleChangedEvent().

2853 {
2854  QVector<QLayoutStruct> ver_struct_list(3);
2855  QVector<QLayoutStruct> hor_struct_list(3);
2856  getGrid(&ver_struct_list, &hor_struct_list);
2857 
2858  qGeomCalc(ver_struct_list, 0, 3, rect.top(), rect.height(), sep);
2859  qGeomCalc(hor_struct_list, 0, 3, rect.left(), rect.width(), sep);
2860 
2861  setGrid(&ver_struct_list, &hor_struct_list);
2862 }
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
void getGrid(QVector< QLayoutStruct > *ver_struct_list, QVector< QLayoutStruct > *hor_struct_list)
void qGeomCalc(QVector< QLayoutStruct > &chain, int start, int count, int pos, int space, int spacer)
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
void setGrid(QVector< QLayoutStruct > *ver_struct_list, QVector< QLayoutStruct > *hor_struct_list)

◆ gapIndex()

QList< int > QDockAreaLayout::gapIndex ( const QPoint pos) const

Definition at line 2381 of file qdockarealayout.cpp.

Referenced by QMainWindowLayoutState::gapIndex().

2382 {
2383  QMainWindow::DockOptions opts = mainWindow->dockOptions();
2384  bool nestingEnabled = opts & QMainWindow::AllowNestedDocks;
2386 #ifndef QT_NO_TABBAR
2388  || opts & QMainWindow::VerticalTabs)
2390  if (opts & QMainWindow::ForceTabbedDocks)
2392 
2393  if (tabMode == QDockAreaLayoutInfo::ForceTabs)
2394  nestingEnabled = false;
2395 #endif
2396 
2397 
2398  for (int i = 0; i < QInternal::DockCount; ++i) {
2399  const QDockAreaLayoutInfo &info = docks[i];
2400 
2401  if (!info.isEmpty() && info.rect.contains(pos)) {
2402  QList<int> result
2403  = docks[i].gapIndex(pos, nestingEnabled, tabMode);
2404  if (!result.isEmpty())
2405  result.prepend(i);
2406  return result;
2407  }
2408  }
2409 
2410  for (int i = 0; i < QInternal::DockCount; ++i) {
2411  const QDockAreaLayoutInfo &info = docks[i];
2412 
2413  if (info.isEmpty()) {
2414  QRect r;
2415  switch (i) {
2416  case QInternal::LeftDock:
2418  break;
2419  case QInternal::RightDock:
2422  break;
2423  case QInternal::TopDock:
2425  break;
2426  case QInternal::BottomDock:
2429  break;
2430  }
2431  if (r.contains(pos)) {
2432  if (opts & QMainWindow::ForceTabbedDocks && !info.item_list.isEmpty()) {
2433  //in case of ForceTabbedDocks, we pass -1 in order to force the gap to be tabbed
2434  //it mustn't be completely empty otherwise it won't work
2435  return QList<int>() << i << -1 << 0;
2436  } else {
2437  return QList<int>() << i << 0;
2438  }
2439  }
2440  }
2441  }
2442 
2443  return QList<int>();
2444 }
DockOptions dockOptions
the docking behavior of QMainWindow
Definition: qmainwindow.h:81
QList< QDockAreaLayoutItem > item_list
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
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
QMainWindow * mainWindow
void prepend(const T &t)
Inserts value at the beginning of the list.
Definition: qlist.h:541
QDockAreaLayoutInfo * info(const QList< int > &path)
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
QDockAreaLayoutInfo docks[4]
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
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
QList< int > gapIndex(const QPoint &pos, bool nestingEnabled, TabMode tabMode) const

◆ gapRect()

QRect QDockAreaLayout::gapRect ( const QList< int > &  path) const

Definition at line 3263 of file qdockarealayout.cpp.

Referenced by QMainWindowLayoutState::gapRect().

3264 {
3265  const QDockAreaLayoutInfo *info = this->info(path);
3266  if (info == 0)
3267  return QRect();
3268  const QList<QDockAreaLayoutItem> &item_list = info->item_list;
3269  Qt::Orientation o = info->o;
3270  int index = path.last();
3271  if (index < 0 || index >= item_list.count())
3272  return QRect();
3273  const QDockAreaLayoutItem &item = item_list.at(index);
3274  if (!(item.flags & QDockAreaLayoutItem::GapItem))
3275  return QRect();
3276 
3277  QRect result;
3278 
3279 #ifndef QT_NO_TABBAR
3280  if (info->tabbed) {
3281  result = info->tabContentRect();
3282  } else
3283 #endif
3284  {
3285  int pos = item.pos;
3286  int size = item.size;
3287 
3288  int prev = info->prev(index);
3289  int next = info->next(index);
3290 
3291  if (prev != -1 && !(item_list.at(prev).flags & QDockAreaLayoutItem::GapItem)) {
3292  pos += sep;
3293  size -= sep;
3294  }
3295  if (next != -1 && !(item_list.at(next).flags & QDockAreaLayoutItem::GapItem))
3296  size -= sep;
3297 
3298  QPoint p;
3299  rpick(o, p) = pos;
3300  rperp(o, p) = perp(o, info->rect.topLeft());
3301  QSize s;
3302  rpick(o, s) = size;
3303  rperp(o, s) = perp(o, info->rect.size());
3304 
3305  result = QRect(p, s);
3306  }
3307 
3308  return result;
3309 }
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
QRect tabContentRect() const
int next(int idx) const
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
QDockAreaLayoutInfo * info(const QList< int > &path)
static int perp(bool vertical, const QSize &size)
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
T & last()
Returns a reference to the last item in the list.
Definition: qlist.h:284
QDockAreaLayoutItem & item(const QList< int > &path)
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)
Orientation
Definition: qnamespace.h:174
QPoint topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:288

◆ getGrid()

void QDockAreaLayout::getGrid ( QVector< QLayoutStruct > *  ver_struct_list,
QVector< QLayoutStruct > *  hor_struct_list 
)

Definition at line 2583 of file qdockarealayout.cpp.

Referenced by fitLayout(), and separatorMove().

2585 {
2586  QSize center_hint(0, 0);
2587  QSize center_min(0, 0);
2588  const bool have_central = centralWidgetItem != 0 && !centralWidgetItem->isEmpty();
2589  if (have_central) {
2590  center_hint = centralWidgetRect.size();
2591  if (!center_hint.isValid())
2592  center_hint = centralWidgetItem->sizeHint();
2593  center_min = centralWidgetItem->minimumSize();
2594  }
2595 
2596  QRect center_rect = rect;
2598  center_rect.setLeft(rect.left() + docks[QInternal::LeftDock].rect.width() + sep);
2600  center_rect.setTop(rect.top() + docks[QInternal::TopDock].rect.height() + sep);
2602  center_rect.setRight(rect.right() - docks[QInternal::RightDock].rect.width() - sep);
2605 
2606  QSize left_hint = docks[QInternal::LeftDock].size();
2607  if (left_hint.isNull() || fallbackToSizeHints)
2608  left_hint = docks[QInternal::LeftDock].sizeHint();
2611  left_hint = left_hint.boundedTo(left_max).expandedTo(left_min);
2612 
2613  QSize right_hint = docks[QInternal::RightDock].size();
2614  if (right_hint.isNull() || fallbackToSizeHints)
2615  right_hint = docks[QInternal::RightDock].sizeHint();
2618  right_hint = right_hint.boundedTo(right_max).expandedTo(right_min);
2619 
2620  QSize top_hint = docks[QInternal::TopDock].size();
2621  if (top_hint.isNull() || fallbackToSizeHints)
2622  top_hint = docks[QInternal::TopDock].sizeHint();
2625  top_hint = top_hint.boundedTo(top_max).expandedTo(top_min);
2626 
2627  QSize bottom_hint = docks[QInternal::BottomDock].size();
2628  if (bottom_hint.isNull() || fallbackToSizeHints)
2629  bottom_hint = docks[QInternal::BottomDock].sizeHint();
2630  QSize bottom_min = docks[QInternal::BottomDock].minimumSize();
2631  QSize bottom_max = docks[QInternal::BottomDock].maximumSize();
2632  bottom_hint = bottom_hint.boundedTo(bottom_max).expandedTo(bottom_min);
2633 
2634  fallbackToSizeHints = false;
2635 
2636  if (_ver_struct_list != 0) {
2637  QVector<QLayoutStruct> &ver_struct_list = *_ver_struct_list;
2638  ver_struct_list.resize(3);
2639 
2640  // top --------------------------------------------------
2641  ver_struct_list[0].init();
2642  ver_struct_list[0].stretch = 0;
2643  ver_struct_list[0].sizeHint = top_hint.height();
2644  ver_struct_list[0].minimumSize = top_min.height();
2645  ver_struct_list[0].maximumSize = top_max.height();
2646  ver_struct_list[0].expansive = false;
2647  ver_struct_list[0].empty = docks[QInternal::TopDock].isEmpty();
2648  ver_struct_list[0].pos = docks[QInternal::TopDock].rect.top();
2649  ver_struct_list[0].size = docks[QInternal::TopDock].rect.height();
2650 
2651  // center --------------------------------------------------
2652  ver_struct_list[1].init();
2653  ver_struct_list[1].stretch = center_hint.height();
2654 
2655  bool tl_significant = corners[Qt::TopLeftCorner] == Qt::TopDockWidgetArea
2657  bool bl_significant = corners[Qt::BottomLeftCorner] == Qt::BottomDockWidgetArea
2659  bool tr_significant = corners[Qt::TopRightCorner] == Qt::TopDockWidgetArea
2661  bool br_significant = corners[Qt::BottomRightCorner] == Qt::BottomDockWidgetArea
2663 
2664  int left = (tl_significant && bl_significant) ? left_hint.height() : 0;
2665  int right = (tr_significant && br_significant) ? right_hint.height() : 0;
2666  ver_struct_list[1].sizeHint = qMax(left, center_hint.height(), right);
2667 
2668  left = (tl_significant && bl_significant) ? left_min.height() : 0;
2669  right = (tr_significant && br_significant) ? right_min.height() : 0;
2670  ver_struct_list[1].minimumSize = qMax(left, center_min.height(), right);
2671  ver_struct_list[1].maximumSize = have_central ? QWIDGETSIZE_MAX : 0;
2672  ver_struct_list[1].expansive = have_central;
2673  ver_struct_list[1].empty = docks[QInternal::LeftDock].isEmpty()
2674  && !have_central
2676  ver_struct_list[1].pos = center_rect.top();
2677  ver_struct_list[1].size = center_rect.height();
2678 
2679  // bottom --------------------------------------------------
2680  ver_struct_list[2].init();
2681  ver_struct_list[2].stretch = 0;
2682  ver_struct_list[2].sizeHint = bottom_hint.height();
2683  ver_struct_list[2].minimumSize = bottom_min.height();
2684  ver_struct_list[2].maximumSize = bottom_max.height();
2685  ver_struct_list[2].expansive = false;
2686  ver_struct_list[2].empty = docks[QInternal::BottomDock].isEmpty();
2687  ver_struct_list[2].pos = docks[QInternal::BottomDock].rect.top();
2688  ver_struct_list[2].size = docks[QInternal::BottomDock].rect.height();
2689 
2690  for (int i = 0; i < 3; ++i) {
2691  ver_struct_list[i].sizeHint
2692  = qMax(ver_struct_list[i].sizeHint, ver_struct_list[i].minimumSize);
2693  }
2694  }
2695 
2696  if (_hor_struct_list != 0) {
2697  QVector<QLayoutStruct> &hor_struct_list = *_hor_struct_list;
2698  hor_struct_list.resize(3);
2699 
2700  // left --------------------------------------------------
2701  hor_struct_list[0].init();
2702  hor_struct_list[0].stretch = 0;
2703  hor_struct_list[0].sizeHint = left_hint.width();
2704  hor_struct_list[0].minimumSize = left_min.width();
2705  hor_struct_list[0].maximumSize = left_max.width();
2706  hor_struct_list[0].expansive = false;
2707  hor_struct_list[0].empty = docks[QInternal::LeftDock].isEmpty();
2708  hor_struct_list[0].pos = docks[QInternal::LeftDock].rect.left();
2709  hor_struct_list[0].size = docks[QInternal::LeftDock].rect.width();
2710 
2711  // center --------------------------------------------------
2712  hor_struct_list[1].init();
2713  hor_struct_list[1].stretch = center_hint.width();
2714 
2715  bool tl_significant = corners[Qt::TopLeftCorner] == Qt::LeftDockWidgetArea
2717  bool tr_significant = corners[Qt::TopRightCorner] == Qt::RightDockWidgetArea
2719  bool bl_significant = corners[Qt::BottomLeftCorner] == Qt::LeftDockWidgetArea
2721  bool br_significant = corners[Qt::BottomRightCorner] == Qt::RightDockWidgetArea
2723 
2724  int top = (tl_significant && tr_significant) ? top_hint.width() : 0;
2725  int bottom = (bl_significant && br_significant) ? bottom_hint.width() : 0;
2726  hor_struct_list[1].sizeHint = qMax(top, center_hint.width(), bottom);
2727 
2728  top = (tl_significant && tr_significant) ? top_min.width() : 0;
2729  bottom = (bl_significant && br_significant) ? bottom_min.width() : 0;
2730  hor_struct_list[1].minimumSize = qMax(top, center_min.width(), bottom);
2731 
2732  hor_struct_list[1].maximumSize = have_central ? QWIDGETSIZE_MAX : 0;
2733  hor_struct_list[1].expansive = have_central;
2734  hor_struct_list[1].empty = !have_central;
2735  hor_struct_list[1].pos = center_rect.left();
2736  hor_struct_list[1].size = center_rect.width();
2737 
2738  // right --------------------------------------------------
2739  hor_struct_list[2].init();
2740  hor_struct_list[2].stretch = 0;
2741  hor_struct_list[2].sizeHint = right_hint.width();
2742  hor_struct_list[2].minimumSize = right_min.width();
2743  hor_struct_list[2].maximumSize = right_max.width();
2744  hor_struct_list[2].expansive = false;
2745  hor_struct_list[2].empty = docks[QInternal::RightDock].isEmpty();
2746  hor_struct_list[2].pos = docks[QInternal::RightDock].rect.left();
2747  hor_struct_list[2].size = docks[QInternal::RightDock].rect.width();
2748 
2749  for (int i = 0; i < 3; ++i) {
2750  hor_struct_list[i].sizeHint
2751  = qMax(hor_struct_list[i].sizeHint, hor_struct_list[i].minimumSize);
2752  }
2753  }
2754 }
void setBottom(int pos)
Sets the bottom edge of the rectangle to the given y coordinate.
Definition: qrect.h:267
static int qMax(int i1, int i2, int i3)
virtual bool isEmpty() const =0
Implemented in subclasses to return whether this item is empty, i.
#define QWIDGETSIZE_MAX
Defines the maximum size for a QWidget object.
Definition: qwidget.h:1087
QSize expandedTo(const QSize &) const
Returns a size holding the maximum width and height of this size and the given otherSize.
Definition: qsize.h:187
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
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
virtual QSize minimumSize() const =0
Implemented in subclasses to return the minimum size of this item.
int bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:249
bool empty() const
This function is provided for STL compatibility.
Definition: qvector.h:285
QSize boundedTo(const QSize &) const
Returns a size holding the minimum width and height of this size and the given otherSize.
Definition: qsize.h:192
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
void resize(int size)
Sets the size of the vector to size.
Definition: qvector.h:342
QSize maximumSize() const
QLayoutItem * centralWidgetItem
int width() const
Returns the width.
Definition: qsize.h:126
static bool isEmpty(const char *str)
QSize sizeHint() const
void setTop(int pos)
Sets the top edge of the rectangle to the given y coordinate.
Definition: qrect.h:261
QSize size() const
Returns the size of the rectangle.
Definition: qrect.h:309
void setRight(int pos)
Sets the right edge of the rectangle to the given x coordinate.
Definition: qrect.h:264
QDockAreaLayoutInfo docks[4]
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
void setLeft(int pos)
Sets the left edge of the rectangle to the given x coordinate.
Definition: qrect.h:258
virtual QSize sizeHint() const =0
Implemented in subclasses to return the preferred size of this item.
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
QSize minimumSize() const
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
Q_CORE_EXPORT QTextStream & left(QTextStream &s)
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137
Qt::DockWidgetArea corners[4]
QSize minimumSize() const

◆ indexOf()

QList< int > QDockAreaLayout::indexOf ( QWidget dockWidget) const

Definition at line 2369 of file qdockarealayout.cpp.

Referenced by QMainWindowLayoutState::contains(), QMainWindowLayoutState::indexOf(), keepSize(), QMainWindowLayoutState::remove(), QMainWindowLayoutState::restoreState(), splitDockWidget(), and tabifyDockWidget().

2370 {
2371  for (int i = 0; i < QInternal::DockCount; ++i) {
2372  QList<int> result = docks[i].indexOf(dockWidget);
2373  if (!result.isEmpty()) {
2374  result.prepend(i);
2375  return result;
2376  }
2377  }
2378  return QList<int>();
2379 }
QList< int > indexOf(QWidget *widget) 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
QDockAreaLayoutInfo docks[4]

◆ indexOfPlaceHolder()

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

Definition at line 2357 of file qdockarealayout.cpp.

Referenced by addDockWidget(), restoreDockWidget(), splitDockWidget(), and tabifyDockWidget().

2358 {
2359  for (int i = 0; i < QInternal::DockCount; ++i) {
2360  QList<int> result = docks[i].indexOfPlaceHolder(objectName);
2361  if (!result.isEmpty()) {
2362  result.prepend(i);
2363  return result;
2364  }
2365  }
2366  return QList<int>();
2367 }
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
QDockAreaLayoutInfo docks[4]
QList< int > indexOfPlaceHolder(const QString &objectName) const

◆ info() [1/3]

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

Definition at line 2481 of file qdockarealayout.cpp.

Referenced by addDockWidget(), findSeparator(), gapIndex(), gapRect(), info(), QMainWindowLayoutState::restoreState(), separatorMove(), splitDockWidget(), and tabifyDockWidget().

2482 {
2483  Q_ASSERT(!path.isEmpty());
2484  const int index = path.first();
2485  Q_ASSERT(index >= 0 && index < QInternal::DockCount);
2486 
2487  if (path.count() == 1)
2488  return &docks[index];
2489 
2490  return docks[index].info(path.mid(1));
2491 }
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
QDockAreaLayoutInfo * info(const QList< int > &path)
T & first()
Returns a reference to the first item in the list.
Definition: qlist.h:282
QDockAreaLayoutInfo docks[4]
quint16 index

◆ info() [2/3]

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

Definition at line 2493 of file qdockarealayout.cpp.

2494 {
2495  return const_cast<QDockAreaLayout*>(this)->info(path);
2496 }
QDockAreaLayoutInfo * info(const QList< int > &path)

◆ info() [3/3]

QDockAreaLayoutInfo * QDockAreaLayout::info ( QWidget widget)

Definition at line 2471 of file qdockarealayout.cpp.

2472 {
2473  for (int i = 0; i < QInternal::DockCount; ++i) {
2474  if (QDockAreaLayoutInfo *result = docks[i].info(widget))
2475  return result;
2476  }
2477 
2478  return 0;
2479 }
QDockAreaLayoutInfo * info(const QList< int > &path)
QDockAreaLayoutInfo docks[4]

◆ insertGap()

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

Definition at line 2548 of file qdockarealayout.cpp.

Referenced by QMainWindowLayoutState::insertGap().

2549 {
2550  Q_ASSERT(!path.isEmpty());
2551  const int index = path.first();
2552  Q_ASSERT(index >= 0 && index < QInternal::DockCount);
2553  return docks[index].insertGap(path.mid(1), dockWidgetItem);
2554 }
#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 docks[4]
quint16 index
bool insertGap(const QList< int > &path, QLayoutItem *dockWidgetItem)

◆ isValid()

bool QDockAreaLayout::isValid ( ) const

Definition at line 2288 of file qdockarealayout.cpp.

Referenced by styleChangedEvent().

2289 {
2290  return rect.isValid();
2291 }
bool isValid() const
Returns true if the rectangle is valid, otherwise returns false.
Definition: qrect.h:237

◆ item()

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

Definition at line 2498 of file qdockarealayout.cpp.

Referenced by gapRect(), QMainWindowLayoutState::item(), keepSize(), and restoreDockWidget().

2499 {
2500  Q_ASSERT(!path.isEmpty());
2501  const int index = path.first();
2502  Q_ASSERT(index >= 0 && index < QInternal::DockCount);
2503  return docks[index].item(path.mid(1));
2504 }
#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 docks[4]
quint16 index
QDockAreaLayoutItem & item(const QList< int > &path)

◆ itemAt()

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

Definition at line 3196 of file qdockarealayout.cpp.

Referenced by QMainWindowLayoutState::itemAt().

3197 {
3198  Q_ASSERT(x != 0);
3199 
3200  for (int i = 0; i < QInternal::DockCount; ++i) {
3201  const QDockAreaLayoutInfo &dock = docks[i];
3202  if (QLayoutItem *ret = dock.itemAt(x, index))
3203  return ret;
3204  }
3205 
3206  if (centralWidgetItem && (*x)++ == index)
3207  return centralWidgetItem;
3208 
3209  return 0;
3210 }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
QLayoutItem * centralWidgetItem
The QLayoutItem class provides an abstract item that a QLayout manipulates.
Definition: qlayoutitem.h:64
QDockAreaLayoutInfo docks[4]
QLayoutItem * itemAt(int *x, int index) const
quint16 index

◆ itemRect()

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

Definition at line 2506 of file qdockarealayout.cpp.

Referenced by QMainWindowLayoutState::itemRect().

2507 {
2508  Q_ASSERT(!path.isEmpty());
2509  const int index = path.first();
2510  Q_ASSERT(index >= 0 && index < QInternal::DockCount);
2511  return docks[index].itemRect(path.mid(1));
2512 }
#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
T & first()
Returns a reference to the first item in the list.
Definition: qlist.h:282
QDockAreaLayoutInfo docks[4]
quint16 index

◆ keepSize()

void QDockAreaLayout::keepSize ( QDockWidget w)

Definition at line 3311 of file qdockarealayout.cpp.

3312 {
3313  QList<int> path = indexOf(w);
3314  if (path.isEmpty())
3315  return;
3316  QDockAreaLayoutItem &item = this->item(path);
3317  if (item.size != -1)
3319 }
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
QList< int > indexOf(QWidget *dockWidget) const
QDockAreaLayoutItem & item(const QList< int > &path)

◆ minimumSize()

QSize QDockAreaLayout::minimumSize ( ) const

Definition at line 2923 of file qdockarealayout.cpp.

Referenced by getGrid(), and QMainWindowLayoutState::minimumSize().

2924 {
2925  int left_sep = 0;
2926  int right_sep = 0;
2927  int top_sep = 0;
2928  int bottom_sep = 0;
2929 
2930  if (centralWidgetItem != 0) {
2931  left_sep = docks[QInternal::LeftDock].isEmpty() ? 0 : sep;
2932  right_sep = docks[QInternal::RightDock].isEmpty() ? 0 : sep;
2933  top_sep = docks[QInternal::TopDock].isEmpty() ? 0 : sep;
2934  bottom_sep = docks[QInternal::BottomDock].isEmpty() ? 0 : sep;
2935  }
2936 
2937  QSize left = docks[QInternal::LeftDock].minimumSize() + QSize(left_sep, 0);
2938  QSize right = docks[QInternal::RightDock].minimumSize() + QSize(right_sep, 0);
2939  QSize top = docks[QInternal::TopDock].minimumSize() + QSize(0, top_sep);
2940  QSize bottom = docks[QInternal::BottomDock].minimumSize() + QSize(0, bottom_sep);
2942 
2943  int row1 = top.width();
2944  int row2 = left.width() + center.width() + right.width();
2945  int row3 = bottom.width();
2946  int col1 = left.height();
2947  int col2 = top.height() + center.height() + bottom.height();
2948  int col3 = right.height();
2949 
2951  row1 += left.width();
2952  else
2953  col1 += top.height();
2954 
2956  row1 += right.width();
2957  else
2958  col3 += top.height();
2959 
2961  row3 += left.width();
2962  else
2963  col1 += bottom.height();
2964 
2966  row3 += right.width();
2967  else
2968  col3 += bottom.height();
2969 
2970  return QSize(qMax(row1, row2, row3), qMax(col1, col2, col3));
2971 }
static int qMax(int i1, int i2, int i3)
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
QLayoutItem * centralWidgetItem
int width() const
Returns the width.
Definition: qsize.h:126
Q_CORE_EXPORT QTextStream & center(QTextStream &s)
QDockAreaLayoutInfo docks[4]
int height() const
Returns the height.
Definition: qsize.h:129
QSize minimumSize() const
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
Q_CORE_EXPORT QTextStream & left(QTextStream &s)
Qt::DockWidgetArea corners[4]
QSize minimumSize() const

◆ paintSeparators()

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

Definition at line 3085 of file qdockarealayout.cpp.

3088 {
3089  for (int i = 0; i < QInternal::DockCount; ++i) {
3090  const QDockAreaLayoutInfo &dock = docks[i];
3091  if (dock.isEmpty())
3092  continue;
3093  QRect r = separatorRect(i);
3094  if (clip.contains(r) && !dock.hasFixedSize()) {
3095  Qt::Orientation opposite = dock.o == Qt::Horizontal
3097  paintSep(p, widget, r, opposite, r.contains(mouse));
3098  }
3099  if (clip.contains(dock.rect))
3100  dock.paintSeparators(p, widget, clip, mouse);
3101  }
3102 }
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
QDockAreaLayoutInfo docks[4]
QRect separatorRect(int index) const
void paintSeparators(QPainter *p, QWidget *widget, const QRegion &clip, const QPoint &mouse) const
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
Orientation
Definition: qnamespace.h:174

◆ plug()

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

Definition at line 2556 of file qdockarealayout.cpp.

Referenced by QMainWindowLayoutState::plug().

2557 {
2558  Q_ASSERT(!path.isEmpty());
2559  const int index = path.first();
2560  Q_ASSERT(index >= 0 && index < QInternal::DockCount);
2561  return docks[index].plug(path.mid(1));
2562 }
#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 docks[4]
quint16 index
QLayoutItem * plug(const QList< int > &path)

◆ remove()

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

Definition at line 2572 of file qdockarealayout.cpp.

Referenced by QMainWindowLayoutState::remove().

2573 {
2574  Q_ASSERT(!path.isEmpty());
2575  const int index = path.first();
2576  Q_ASSERT(index >= 0 && index < QInternal::DockCount);
2577  docks[index].remove(path.mid(1));
2578 }
void remove(const QList< int > &path)
#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 docks[4]
quint16 index

◆ restoreDockWidget()

bool QDockAreaLayout::restoreDockWidget ( QDockWidget dockWidget)

Definition at line 2973 of file qdockarealayout.cpp.

2974 {
2975  QList<int> index = indexOfPlaceHolder(dockWidget->objectName());
2976  if (index.isEmpty())
2977  return false;
2978 
2979  QDockAreaLayoutItem &item = this->item(index);
2980  QPlaceHolderItem *placeHolder = item.placeHolderItem;
2981  Q_ASSERT(placeHolder != 0);
2982 
2983  item.widgetItem = new QDockWidgetItem(dockWidget);
2984 
2985  if (placeHolder->window) {
2986  QDesktopWidget desktop;
2987  QRect r = constrainedRect(placeHolder->topLevelRect, desktop.screenGeometry(dockWidget));
2988  dockWidget->d_func()->setWindowState(true, true, r);
2989  }
2990  dockWidget->setVisible(!placeHolder->hidden);
2991 #ifdef Q_WS_X11
2992  if (placeHolder->window) // gets rid of the X11BypassWindowManager window flag
2993  dockWidget->d_func()->setWindowState(true);
2994 #endif
2995 
2996  item.placeHolderItem = 0;
2997  delete placeHolder;
2998 
2999  return true;
3000 }
void setWindowState(Qt::WindowStates state)
Sets the window state to windowState.
QList< int > indexOfPlaceHolder(const QString &objectName) const
QPlaceHolderItem * placeHolderItem
#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
virtual void setVisible(bool visible)
Definition: qwidget.cpp:7991
const QRect screenGeometry(int screen=-1) const
static QRect constrainedRect(QRect rect, const QRect &desktop)
QDockAreaLayoutItem & item(const QList< int > &path)
QString objectName() const
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
quint16 index
QLayoutItem * widgetItem

◆ restoreState()

bool QDockAreaLayout::restoreState ( QDataStream stream,
const QList< QDockWidget *> &  widgets,
bool  testing = false 
)

Definition at line 2315 of file qdockarealayout.cpp.

Referenced by QMainWindowLayoutState::checkFormat(), and QMainWindowLayoutState::restoreState().

2316 {
2317  QList<QDockWidget*> dockwidgets = _dockwidgets;
2318 
2319  int cnt;
2320  stream >> cnt;
2321  for (int i = 0; i < cnt; ++i) {
2322  int pos;
2323  stream >> pos;
2324  QSize size;
2325  stream >> size;
2326  if (!testing) {
2327  docks[pos].rect = QRect(QPoint(0, 0), size);
2328  }
2329  if (!docks[pos].restoreState(stream, dockwidgets, testing)) {
2331  return false;
2332  }
2333  }
2334 
2335  QSize size;
2336  stream >> size;
2337  centralWidgetRect = QRect(QPoint(0, 0), size);
2338 
2339  bool ok = stream.status() == QDataStream::Ok;
2340 
2341  if (ok) {
2342  int cornerData[4];
2343  for (int i = 0; i < 4; ++i)
2344  stream >> cornerData[i];
2345  if (stream.status() == QDataStream::Ok) {
2346  for (int i = 0; i < 4; ++i)
2347  corners[i] = static_cast<Qt::DockWidgetArea>(cornerData[i]);
2348  }
2349 
2350  if (!testing)
2351  fallbackToSizeHints = false;
2352  }
2353 
2354  return ok;
2355 }
Status status() const
Returns the status of the data stream.
void setStatus(Status status)
Sets the status of the data stream to the status given.
QDockAreaLayoutInfo docks[4]
bool restoreState(QDataStream &stream, const QList< QDockWidget *> &widgets, bool testing=false)
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
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
Qt::DockWidgetArea corners[4]
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ saveState()

void QDockAreaLayout::saveState ( QDataStream stream) const

Definition at line 2293 of file qdockarealayout.cpp.

Referenced by QMainWindowLayoutState::saveState().

2294 {
2295  stream << (uchar) DockWidgetStateMarker;
2296  int cnt = 0;
2297  for (int i = 0; i < QInternal::DockCount; ++i) {
2298  if (!docks[i].item_list.isEmpty())
2299  ++cnt;
2300  }
2301  stream << cnt;
2302  for (int i = 0; i < QInternal::DockCount; ++i) {
2303  if (docks[i].item_list.isEmpty())
2304  continue;
2305  stream << i << docks[i].rect.size();
2306  docks[i].saveState(stream);
2307  }
2308 
2309  stream << centralWidgetRect.size();
2310 
2311  for (int i = 0; i < 4; ++i)
2312  stream << static_cast<int>(corners[i]);
2313 }
unsigned char uchar
Definition: qglobal.h:994
QSize size() const
Returns the size of the rectangle.
Definition: qrect.h:309
void saveState(QDataStream &stream) const
QDockAreaLayoutInfo docks[4]
Qt::DockWidgetArea corners[4]

◆ separatorMove()

int QDockAreaLayout::separatorMove ( const QList< int > &  separator,
const QPoint origin,
const QPoint dest 
)

Definition at line 3119 of file qdockarealayout.cpp.

Referenced by QMainWindowLayout::timerEvent().

3121 {
3122  int delta = 0;
3123  int index = separator.last();
3124 
3125  if (separator.count() > 1) {
3126  QDockAreaLayoutInfo *info = this->info(separator);
3127  delta = pick(info->o, dest - origin);
3128  if (delta != 0)
3129  delta = info->separatorMove(index, delta);
3130  info->apply(false);
3131  return delta;
3132  }
3133 
3135 
3136  if (index == QInternal::LeftDock || index == QInternal::RightDock)
3137  getGrid(0, &list);
3138  else
3139  getGrid(&list, 0);
3140 
3141  int sep_index = index == QInternal::LeftDock || index == QInternal::TopDock
3142  ? 0 : 1;
3144  ? Qt::Horizontal
3145  : Qt::Vertical;
3146 
3147  delta = pick(o, dest - origin);
3148  delta = separatorMoveHelper(list, sep_index, delta, sep);
3149 
3150  if (index == QInternal::LeftDock || index == QInternal::RightDock)
3151  setGrid(0, &list);
3152  else
3153  setGrid(&list, 0);
3154 
3155  apply(false);
3156 
3157  return delta;
3158 }
static int separatorMoveHelper(QVector< QLayoutStruct > &list, int index, int delta, int sep)
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
void apply(bool animate)
void getGrid(QVector< QLayoutStruct > *ver_struct_list, QVector< QLayoutStruct > *hor_struct_list)
QDockAreaLayoutInfo * info(const QList< int > &path)
T & last()
Returns a reference to the last item in the list.
Definition: qlist.h:284
void apply(bool animate)
int separatorMove(int index, int delta)
quint16 index
void setGrid(QVector< QLayoutStruct > *ver_struct_list, QVector< QLayoutStruct > *hor_struct_list)
static int pick(bool vertical, const QSize &size)
Orientation
Definition: qnamespace.h:174

◆ separatorRect() [1/2]

QRect QDockAreaLayout::separatorRect ( int  index) const

Definition at line 2514 of file qdockarealayout.cpp.

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

2515 {
2516  const QDockAreaLayoutInfo &dock = docks[index];
2517  if (dock.isEmpty())
2518  return QRect();
2519  QRect r = dock.rect;
2520  switch (index) {
2521  case QInternal::LeftDock:
2522  return QRect(r.right() + 1, r.top(), sep, r.height());
2523  case QInternal::RightDock:
2524  return QRect(r.left() - sep, r.top(), sep, r.height());
2525  case QInternal::TopDock:
2526  return QRect(r.left(), r.bottom() + 1, r.width(), sep);
2527  case QInternal::BottomDock:
2528  return QRect(r.left(), r.top() - sep, r.width(), sep);
2529  default:
2530  break;
2531  }
2532  return QRect();
2533 }
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
QDockAreaLayoutInfo docks[4]
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
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
quint16 index

◆ separatorRect() [2/2]

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

Definition at line 2535 of file qdockarealayout.cpp.

2536 {
2537  Q_ASSERT(!path.isEmpty());
2538 
2539  const int index = path.first();
2540  Q_ASSERT(index >= 0 && index < QInternal::DockCount);
2541 
2542  if (path.count() == 1)
2543  return separatorRect(index);
2544  else
2545  return docks[index].separatorRect(path.mid(1));
2546 }
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
T & first()
Returns a reference to the first item in the list.
Definition: qlist.h:282
QDockAreaLayoutInfo docks[4]
QRect separatorRect(int index) const
quint16 index

◆ separatorRegion()

QRegion QDockAreaLayout::separatorRegion ( ) const

Definition at line 3104 of file qdockarealayout.cpp.

Referenced by QMainWindowLayout::hover(), and QMainWindowLayout::timerEvent().

3105 {
3106  QRegion result;
3107 
3108  for (int i = 0; i < QInternal::DockCount; ++i) {
3109  const QDockAreaLayoutInfo &dock = docks[i];
3110  if (dock.isEmpty())
3111  continue;
3112  result |= separatorRect(i);
3113  result |= dock.separatorRegion();
3114  }
3115 
3116  return result;
3117 }
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
QDockAreaLayoutInfo docks[4]
QRect separatorRect(int index) const
QRegion separatorRegion() const

◆ setGrid()

void QDockAreaLayout::setGrid ( QVector< QLayoutStruct > *  ver_struct_list,
QVector< QLayoutStruct > *  hor_struct_list 
)

Definition at line 2756 of file qdockarealayout.cpp.

Referenced by fitLayout(), and separatorMove().

2758 {
2759 
2760  // top ---------------------------------------------------
2761 
2762  if (!docks[QInternal::TopDock].isEmpty()) {
2764  if (hor_struct_list != 0) {
2767  ? rect.left() : hor_struct_list->at(1).pos);
2770  ? rect.right() : hor_struct_list->at(2).pos - sep - 1);
2771  }
2772  if (ver_struct_list != 0) {
2773  r.setTop(rect.top());
2774  r.setBottom(ver_struct_list->at(1).pos - sep - 1);
2775  }
2778  }
2779 
2780  // bottom ---------------------------------------------------
2781 
2784  if (hor_struct_list != 0) {
2787  ? rect.left() : hor_struct_list->at(1).pos);
2790  ? rect.right() : hor_struct_list->at(2).pos - sep - 1);
2791  }
2792  if (ver_struct_list != 0) {
2793  r.setTop(ver_struct_list->at(2).pos);
2794  r.setBottom(rect.bottom());
2795  }
2798  }
2799 
2800  // left ---------------------------------------------------
2801 
2802  if (!docks[QInternal::LeftDock].isEmpty()) {
2804  if (hor_struct_list != 0) {
2805  r.setLeft(rect.left());
2806  r.setRight(hor_struct_list->at(1).pos - sep - 1);
2807  }
2808  if (ver_struct_list != 0) {
2811  ? rect.top() : ver_struct_list->at(1).pos);
2814  ? rect.bottom() : ver_struct_list->at(2).pos - sep - 1);
2815  }
2818  }
2819 
2820  // right ---------------------------------------------------
2821 
2824  if (hor_struct_list != 0) {
2825  r.setLeft(hor_struct_list->at(2).pos);
2826  r.setRight(rect.right());
2827  }
2828  if (ver_struct_list != 0) {
2831  ? rect.top() : ver_struct_list->at(1).pos);
2834  ? rect.bottom() : ver_struct_list->at(2).pos - sep - 1);
2835  }
2838  }
2839 
2840  // center ---------------------------------------------------
2841 
2842  if (hor_struct_list != 0) {
2843  centralWidgetRect.setLeft(hor_struct_list->at(1).pos);
2844  centralWidgetRect.setWidth(hor_struct_list->at(1).size);
2845  }
2846  if (ver_struct_list != 0) {
2847  centralWidgetRect.setTop(ver_struct_list->at(1).pos);
2848  centralWidgetRect.setHeight(ver_struct_list->at(1).size);
2849  }
2850 }
void setHeight(int h)
Sets the height of the rectangle to the given height.
Definition: qrect.h:445
void setBottom(int pos)
Sets the bottom edge of the rectangle to the given y coordinate.
Definition: qrect.h:267
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
int bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:249
static bool isEmpty(const char *str)
void setTop(int pos)
Sets the top edge of the rectangle to the given y coordinate.
Definition: qrect.h:261
void setRight(int pos)
Sets the right edge of the rectangle to the given x coordinate.
Definition: qrect.h:264
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
QDockAreaLayoutInfo docks[4]
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
void setLeft(int pos)
Sets the left edge of the rectangle to the given x coordinate.
Definition: qrect.h:258
void setWidth(int w)
Sets the width of the rectangle to the given width.
Definition: qrect.h:442
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
Qt::DockWidgetArea corners[4]

◆ sizeHint()

QSize QDockAreaLayout::sizeHint ( ) const

Definition at line 2873 of file qdockarealayout.cpp.

Referenced by getGrid(), and QMainWindowLayoutState::sizeHint().

2874 {
2875  int left_sep = 0;
2876  int right_sep = 0;
2877  int top_sep = 0;
2878  int bottom_sep = 0;
2879 
2880  if (centralWidgetItem != 0) {
2881  left_sep = docks[QInternal::LeftDock].isEmpty() ? 0 : sep;
2882  right_sep = docks[QInternal::RightDock].isEmpty() ? 0 : sep;
2883  top_sep = docks[QInternal::TopDock].isEmpty() ? 0 : sep;
2884  bottom_sep = docks[QInternal::BottomDock].isEmpty() ? 0 : sep;
2885  }
2886 
2887  QSize left = docks[QInternal::LeftDock].sizeHint() + QSize(left_sep, 0);
2888  QSize right = docks[QInternal::RightDock].sizeHint() + QSize(right_sep, 0);
2889  QSize top = docks[QInternal::TopDock].sizeHint() + QSize(0, top_sep);
2890  QSize bottom = docks[QInternal::BottomDock].sizeHint() + QSize(0, bottom_sep);
2892 
2893  int row1 = top.width();
2894  int row2 = left.width() + center.width() + right.width();
2895  int row3 = bottom.width();
2896  int col1 = left.height();
2897  int col2 = top.height() + center.height() + bottom.height();
2898  int col3 = right.height();
2899 
2901  row1 += left.width();
2902  else
2903  col1 += top.height();
2904 
2906  row1 += right.width();
2907  else
2908  col3 += top.height();
2909 
2911  row3 += left.width();
2912  else
2913  col1 += bottom.height();
2914 
2916  row3 += right.width();
2917  else
2918  col3 += bottom.height();
2919 
2920  return QSize(qMax(row1, row2, row3), qMax(col1, col2, col3));
2921 }
static int qMax(int i1, int i2, int i3)
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
QLayoutItem * centralWidgetItem
int width() const
Returns the width.
Definition: qsize.h:126
QSize sizeHint() const
Q_CORE_EXPORT QTextStream & center(QTextStream &s)
QDockAreaLayoutInfo docks[4]
int height() const
Returns the height.
Definition: qsize.h:129
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
Q_CORE_EXPORT QTextStream & left(QTextStream &s)
Qt::DockWidgetArea corners[4]

◆ splitDockWidget()

void QDockAreaLayout::splitDockWidget ( QDockWidget after,
QDockWidget dockWidget,
Qt::Orientation  orientation 
)

Definition at line 3052 of file qdockarealayout.cpp.

3055 {
3056  QList<int> path = indexOf(after);
3057  if (path.isEmpty())
3058  return;
3059 
3060  QDockAreaLayoutInfo *info = this->info(path);
3061  Q_ASSERT(info != 0);
3062  info->split(path.last(), orientation, new QDockWidgetItem(dockWidget));
3063 
3064  QList<int> index = indexOfPlaceHolder(dockWidget->objectName());
3065  if (!index.isEmpty())
3066  remove(index);
3067 }
QList< int > indexOfPlaceHolder(const QString &objectName) const
#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
QDockAreaLayoutInfo * info(const QList< int > &path)
QList< int > indexOf(QWidget *dockWidget) const
T & last()
Returns a reference to the last item in the list.
Definition: qlist.h:284
QString objectName() const
quint16 index
void split(int index, Qt::Orientation orientation, QLayoutItem *dockWidgetItem)

◆ styleChangedEvent()

void QDockAreaLayout::styleChangedEvent ( )

Definition at line 3321 of file qdockarealayout.cpp.

3322 {
3324  if (isValid())
3325  fitLayout();
3326 }
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const =0
Returns the value of the given pixel metric.
bool isValid() const
QStyle * style() const
Definition: qwidget.cpp:2742
QMainWindow * mainWindow

◆ tabifyDockWidget()

void QDockAreaLayout::tabifyDockWidget ( QDockWidget first,
QDockWidget second 
)

Definition at line 3037 of file qdockarealayout.cpp.

3038 {
3039  QList<int> path = indexOf(first);
3040  if (path.isEmpty())
3041  return;
3042 
3043  QDockAreaLayoutInfo *info = this->info(path);
3044  Q_ASSERT(info != 0);
3045  info->tab(path.last(), new QDockWidgetItem(second));
3046 
3048  if (!index.isEmpty())
3049  remove(index);
3050 }
void tab(int index, QLayoutItem *dockWidgetItem)
QList< int > indexOfPlaceHolder(const QString &objectName) const
#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
QDockAreaLayoutInfo * info(const QList< int > &path)
QList< int > indexOf(QWidget *dockWidget) const
T & last()
Returns a reference to the last item in the list.
Definition: qlist.h:284
QString objectName() const
quint16 index

◆ takeAt()

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

Definition at line 3212 of file qdockarealayout.cpp.

Referenced by QMainWindowLayoutState::takeAt().

3213 {
3214  Q_ASSERT(x != 0);
3215 
3216  for (int i = 0; i < QInternal::DockCount; ++i) {
3217  QDockAreaLayoutInfo &dock = docks[i];
3218  if (QLayoutItem *ret = dock.takeAt(x, index))
3219  return ret;
3220  }
3221 
3222  if (centralWidgetItem && (*x)++ == index) {
3224  centralWidgetItem = 0;
3225  return ret;
3226  }
3227 
3228  return 0;
3229 }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
QLayoutItem * centralWidgetItem
The QLayoutItem class provides an abstract item that a QLayout manipulates.
Definition: qlayoutitem.h:64
QLayoutItem * takeAt(int *x, int index)
QDockAreaLayoutInfo docks[4]
quint16 index

◆ unplug()

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

Definition at line 2564 of file qdockarealayout.cpp.

Referenced by QMainWindowLayoutState::unplug().

2565 {
2566  Q_ASSERT(!path.isEmpty());
2567  const int index = path.first();
2568  Q_ASSERT(index >= 0 && index < QInternal::DockCount);
2569  return docks[index].unplug(path.mid(1));
2570 }
QLayoutItem * unplug(const QList< int > &path)
#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 docks[4]
quint16 index

◆ updateSeparatorWidgets()

void QDockAreaLayout::updateSeparatorWidgets ( ) const

Definition at line 3163 of file qdockarealayout.cpp.

Referenced by apply().

3164 {
3165  int j = 0;
3166 
3167  for (int i = 0; i < QInternal::DockCount; ++i) {
3168  const QDockAreaLayoutInfo &dock = docks[i];
3169  if (dock.isEmpty())
3170  continue;
3171 
3172  QWidget *sepWidget;
3173  if (j < separatorWidgets.size()) {
3174  sepWidget = separatorWidgets.at(j);
3175  } else {
3177  separatorWidgets.append(sepWidget);
3178  }
3179  j++;
3180 
3181 #ifndef QT_MAC_USE_COCOA
3182  sepWidget->raise();
3183 #endif
3184  QRect sepRect = separatorRect(i).adjusted(-2, -2, 2, 2);
3185  sepWidget->setGeometry(sepRect);
3186  sepWidget->setMask( QRegion(separatorRect(i).translated( - sepRect.topLeft())));
3187  sepWidget->show();
3188  }
3189  for (int i = j; i < separatorWidgets.size(); ++i)
3190  separatorWidgets.at(i)->hide();
3191 
3193 }
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()
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
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
void resize(int size)
Sets the size of the vector to size.
Definition: qvector.h:342
QMainWindow * mainWindow
void raise()
Raises this widget to the top of the parent widget&#39;s stack.
Definition: qwidget.cpp:11901
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
void hide()
Hides the widget.
Definition: qwidget.h:501
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
QDockAreaLayoutInfo docks[4]
QVector< QWidget * > separatorWidgets
QRect separatorRect(int index) const
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
QMainWindowLayout * qt_mainwindow_layout(const QMainWindow *window)
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

◆ usedSeparatorWidgets()

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

Definition at line 3249 of file qdockarealayout.cpp.

Referenced by QMainWindowLayout::applyState().

3250 {
3251  QSet<QWidget*> result;
3252 
3253  for (int i = 0; i < separatorWidgets.count(); ++i)
3254  result << separatorWidgets.at(i);
3255  for (int i = 0; i < QInternal::DockCount; ++i) {
3256  const QDockAreaLayoutInfo &dock = docks[i];
3257  result += dock.usedSeparatorWidgets();
3258  }
3259  return result;
3260 }
int count(const T &t) const
Returns the number of occurrences of value in the vector.
Definition: qvector.h:742
QSet< QWidget * > usedSeparatorWidgets() const
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
QDockAreaLayoutInfo docks[4]
QVector< QWidget * > separatorWidgets

◆ usedTabBars()

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

Definition at line 3238 of file qdockarealayout.cpp.

Referenced by QMainWindowLayout::applyState().

3239 {
3240  QSet<QTabBar*> result;
3241  for (int i = 0; i < QInternal::DockCount; ++i) {
3242  const QDockAreaLayoutInfo &dock = docks[i];
3243  result += dock.usedTabBars();
3244  }
3245  return result;
3246 }
QDockAreaLayoutInfo docks[4]
QSet< QTabBar * > usedTabBars() const

Properties

◆ centralWidgetItem

QLayoutItem* QDockAreaLayout::centralWidgetItem

◆ centralWidgetRect

QRect QDockAreaLayout::centralWidgetRect

Definition at line 231 of file qdockarealayout_p.h.

Referenced by apply(), clear(), getGrid(), restoreState(), saveState(), and setGrid().

◆ corners

Qt::DockWidgetArea QDockAreaLayout::corners[4]

◆ docks

QDockAreaLayoutInfo QDockAreaLayout::docks[4]

◆ fallbackToSizeHints

bool QDockAreaLayout::fallbackToSizeHints

Definition at line 235 of file qdockarealayout_p.h.

Referenced by getGrid(), restoreState(), and QMainWindowLayout::setCentralWidget().

◆ mainWindow

QMainWindow* QDockAreaLayout::mainWindow

◆ rect

QRect QDockAreaLayout::rect

◆ sep

int QDockAreaLayout::sep

◆ separatorWidgets

QVector<QWidget*> QDockAreaLayout::separatorWidgets
mutable

Definition at line 236 of file qdockarealayout_p.h.

Referenced by updateSeparatorWidgets(), and usedSeparatorWidgets().


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