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

#include <qtoolbararealayout_p.h>

Public Types

enum  { ToolBarStateMarker = 0xfe, ToolBarStateMarkerEx = 0xfc }
 

Public Functions

QLayoutItemaddToolBar (QInternal::DockPosition pos, QToolBar *toolBar)
 
void addToolBarBreak (QInternal::DockPosition pos)
 
void apply (bool animate)
 
void clear ()
 
QList< int > currentGapIndex () const
 
void deleteAllLayoutItems ()
 
QInternal::DockPosition findToolBar (QToolBar *toolBar) const
 
QRect fitLayout ()
 
QList< int > gapIndex (const QPoint &pos) const
 
void getStyleOptionInfo (QStyleOptionToolBar *option, QToolBar *toolBar) const
 
QList< int > indexOf (QWidget *toolBar) const
 
bool insertGap (const QList< int > &path, QLayoutItem *item)
 
void insertItem (QInternal::DockPosition pos, QLayoutItem *item)
 
void insertItem (QToolBar *before, QLayoutItem *item)
 
QLayoutIteminsertToolBar (QToolBar *before, QToolBar *toolBar)
 
void insertToolBarBreak (QToolBar *before)
 
bool isEmpty () const
 
QToolBarAreaLayoutItemitem (const QList< int > &path)
 
QLayoutItemitemAt (int *x, int index) const
 
QRect itemRect (const QList< int > &path) const
 
QSize minimumSize (const QSize &centerMin) const
 
void moveToolBar (QToolBar *toolbar, int pos)
 
QLayoutItemplug (const QList< int > &path)
 
 QToolBarAreaLayout (const QMainWindow *win)
 
QRect rectHint (const QRect &r) const
 
void remove (const QList< int > &path)
 
void remove (QLayoutItem *item)
 
void removeToolBar (QToolBar *toolBar)
 
void removeToolBarBreak (QToolBar *before)
 
bool restoreState (QDataStream &stream, const QList< QToolBar *> &toolBars, uchar tmarker, bool pre43, bool testing=false)
 
void saveState (QDataStream &stream) const
 
QSize sizeHint (const QSize &center) const
 
QLayoutItemtakeAt (int *x, int index)
 
bool toolBarBreak (QToolBar *toolBar) const
 
QLayoutItemunplug (const QList< int > &path, QToolBarAreaLayout *other)
 

Public Variables

QToolBarAreaLayoutInfo docks [4]
 
const QMainWindowmainWindow
 
QRect rect
 
bool visible
 

Detailed Description

Definition at line 186 of file qtoolbararealayout_p.h.

Enumerations

◆ anonymous enum

anonymous enum
Enumerator
ToolBarStateMarker 
ToolBarStateMarkerEx 

Definition at line 189 of file qtoolbararealayout_p.h.

189  { // sentinel values used to validate state data
190  ToolBarStateMarker = 0xfe,
191  ToolBarStateMarkerEx = 0xfc
192  };

Constructors and Destructors

◆ QToolBarAreaLayout()

QToolBarAreaLayout::QToolBarAreaLayout ( const QMainWindow win)

Definition at line 625 of file qtoolbararealayout.cpp.

625  : mainWindow(win), visible(true)
626 {
627  for (int i = 0; i < QInternal::DockCount; ++i) {
628  QInternal::DockPosition pos = static_cast<QInternal::DockPosition>(i);
629  docks[i] = QToolBarAreaLayoutInfo(pos);
630  }
631 }
const QMainWindow * mainWindow
QToolBarAreaLayoutInfo docks[4]

Functions

◆ addToolBar()

QLayoutItem * QToolBarAreaLayout::addToolBar ( QInternal::DockPosition  pos,
QToolBar toolBar 
)

Definition at line 825 of file qtoolbararealayout.cpp.

826 {
827  return docks[pos].insertToolBar(0, toolBar);
828 }
QToolBarAreaLayoutInfo docks[4]
QLayoutItem * insertToolBar(QToolBar *before, QToolBar *toolBar)

◆ addToolBarBreak()

void QToolBarAreaLayout::addToolBarBreak ( QInternal::DockPosition  pos)

Definition at line 846 of file qtoolbararealayout.cpp.

847 {
848  docks[pos].insertToolBarBreak(0);
849 }
void insertToolBarBreak(QToolBar *before)
QToolBarAreaLayoutInfo docks[4]

◆ apply()

void QToolBarAreaLayout::apply ( bool  animate)

Definition at line 876 of file qtoolbararealayout.cpp.

Referenced by QMainWindowLayoutState::apply(), and QToolBarLayout::setExpanded().

877 {
879  Q_ASSERT(layout != 0);
880 
882 
883  for (int i = 0; i < QInternal::DockCount; ++i) {
884  const QToolBarAreaLayoutInfo &dock = docks[i];
885 
886  for (int j = 0; j < dock.lines.count(); ++j) {
887  const QToolBarAreaLayoutLine &line = dock.lines.at(j);
888  if (line.skip())
889  continue;
890 
891  for (int k = 0; k < line.toolBarItems.count(); ++k) {
892  const QToolBarAreaLayoutItem &item = line.toolBarItems.at(k);
893  if (item.skip() || item.gap)
894  continue;
895 
896  QRect geo;
897  if (visible) {
898  if (line.o == Qt::Horizontal) {
899  geo.setTop(line.rect.top());
900  geo.setBottom(line.rect.bottom());
901  geo.setLeft(line.rect.left() + item.pos);
902  geo.setRight(line.rect.left() + item.pos + item.size - 1);
903  } else {
904  geo.setLeft(line.rect.left());
905  geo.setRight(line.rect.right());
906  geo.setTop(line.rect.top() + item.pos);
907  geo.setBottom(line.rect.top() + item.pos + item.size - 1);
908  }
909  }
910 
911  QWidget *widget = item.widgetItem->widget();
912  if (QToolBar *toolBar = qobject_cast<QToolBar*>(widget)) {
913  QToolBarLayout *tbl = qobject_cast<QToolBarLayout*>(toolBar->layout());
914  if (tbl->expanded) {
915  QPoint tr = geo.topRight();
916  QSize size = tbl->expandedSize(geo.size());
917  geo.setSize(size);
918  geo.moveTopRight(tr);
919  if (geo.bottom() > rect.bottom())
920  geo.moveBottom(rect.bottom());
921  if (geo.right() > rect.right())
922  geo.moveRight(rect.right());
923  if (geo.left() < 0)
924  geo.moveLeft(0);
925  if (geo.top() < 0)
926  geo.moveTop(0);
927  }
928  }
929 
930  if (visible && dock.o == Qt::Horizontal)
931  geo = QStyle::visualRect(dir, line.rect, geo);
932 
933  layout->widgetAnimator.animate(widget, geo, animate);
934  }
935  }
936  }
937 }
T qobject_cast(QObject *object)
Definition: qobject.h:375
void setBottom(int pos)
Sets the bottom edge of the rectangle to the given y coordinate.
Definition: qrect.h:267
QList< QToolBarAreaLayoutLine > lines
QPointer< QWidget > widget
QToolBarAreaLayoutItem * item(const QList< int > &path)
void moveLeft(int pos)
Moves the rectangle horizontally, leaving the rectangle&#39;s left edge at the given x coordinate...
Definition: qrect.h:350
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
void moveRight(int pos)
Moves the rectangle horizontally, leaving the rectangle&#39;s right edge at the given x coordinate...
Definition: qrect.h:356
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
const QMainWindow * mainWindow
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
QSize expandedSize(const QSize &size) const
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 moveBottom(int pos)
Moves the rectangle vertically, leaving the rectangle&#39;s bottom edge at the given y coordinate...
Definition: qrect.h:362
QToolBarAreaLayoutInfo docks[4]
QMainWindowLayout * qt_mainwindow_layout(const QMainWindow *mainWindow)
The QToolBar class provides a movable panel that contains a set of controls.
Definition: qtoolbar.h:62
void setTop(int pos)
Sets the top edge of the rectangle to the given y coordinate.
Definition: qrect.h:261
void moveTopRight(const QPoint &p)
Moves the rectangle, leaving the top-right corner at the given position.
Definition: qrect.h:380
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
const char * layout
void setRight(int pos)
Sets the right edge of the rectangle to the given x coordinate.
Definition: qrect.h:264
LayoutDirection
Definition: qnamespace.h:1580
void setSize(const QSize &s)
Sets the size of the rectangle to the given size.
Definition: qrect.h:448
QPoint topRight() const
Returns the position of the rectangle&#39;s top-right corner.
Definition: qrect.h:294
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
static QRect visualRect(Qt::LayoutDirection direction, const QRect &boundingRect, const QRect &logicalRect)
Returns the given logicalRectangle converted to screen coordinates based on the specified direction...
Definition: qstyle.cpp:2087
int right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:246
Qt::LayoutDirection layoutDirection() const
void setLeft(int pos)
Sets the left edge of the rectangle to the given x coordinate.
Definition: qrect.h:258
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
QList< QToolBarAreaLayoutItem > toolBarItems
virtual QWidget * widget()
If this item is a QWidget, it is returned as a QWidget; otherwise 0 is returned.
QWidgetAnimator widgetAnimator
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
void moveTop(int pos)
Moves the rectangle vertically, leaving the rectangle&#39;s top edge at the given y coordinate.
Definition: qrect.h:353
void animate(QWidget *widget, const QRect &final_geometry, bool animate)

◆ clear()

void QToolBarAreaLayout::clear ( )

Definition at line 1102 of file qtoolbararealayout.cpp.

Referenced by QMainWindowLayoutState::clear().

1103 {
1104  for (int i = 0; i < QInternal::DockCount; ++i)
1105  docks[i].clear();
1106  rect = QRect();
1107 }
QToolBarAreaLayoutInfo docks[4]
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58

◆ currentGapIndex()

QList< int > QToolBarAreaLayout::currentGapIndex ( ) const

Definition at line 1048 of file qtoolbararealayout.cpp.

1049 {
1050  for (int i = 0; i < QInternal::DockCount; ++i) {
1051  const QToolBarAreaLayoutInfo &dock = docks[i];
1052 
1053  for (int j = 0; j < dock.lines.count(); ++j) {
1054  const QToolBarAreaLayoutLine &line = dock.lines[j];
1055 
1056  for (int k = 0; k < line.toolBarItems.count(); k++) {
1057  if (line.toolBarItems[k].gap) {
1058  QList<int> result;
1059  result << i << j << k;
1060  return result;
1061  }
1062  }
1063  }
1064  }
1065  return QList<int>();
1066 }
QList< QToolBarAreaLayoutLine > lines
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
QToolBarAreaLayoutInfo docks[4]
QList< QToolBarAreaLayoutItem > toolBarItems

◆ deleteAllLayoutItems()

void QToolBarAreaLayout::deleteAllLayoutItems ( )

Definition at line 772 of file qtoolbararealayout.cpp.

Referenced by QMainWindowLayoutState::deleteAllLayoutItems().

773 {
774  for (int i = 0; i < QInternal::DockCount; ++i) {
775  QToolBarAreaLayoutInfo &dock = docks[i];
776 
777  for (int j = 0; j < dock.lines.count(); ++j) {
778  QToolBarAreaLayoutLine &line = dock.lines[j];
779 
780  for (int k = 0; k < line.toolBarItems.count(); ++k) {
782  if (!item.gap)
783  delete item.widgetItem;
784  item.widgetItem = 0;
785  }
786  }
787  }
788 }
QList< QToolBarAreaLayoutLine > lines
QToolBarAreaLayoutItem * item(const QList< int > &path)
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
QToolBarAreaLayoutInfo docks[4]
QList< QToolBarAreaLayoutItem > toolBarItems

◆ findToolBar()

QInternal::DockPosition QToolBarAreaLayout::findToolBar ( QToolBar toolBar) const

Definition at line 790 of file qtoolbararealayout.cpp.

Referenced by insertItem(), insertToolBar(), insertToolBarBreak(), moveToolBar(), removeToolBar(), and removeToolBarBreak().

791 {
792  for (int i = 0; i < QInternal::DockCount; ++i) {
793  const QToolBarAreaLayoutInfo &dock = docks[i];
794 
795  for (int j = 0; j < dock.lines.count(); ++j) {
796  const QToolBarAreaLayoutLine &line = dock.lines.at(j);
797 
798  for (int k = 0; k < line.toolBarItems.count(); ++k) {
799  if (line.toolBarItems.at(k).widgetItem->widget() == toolBar)
800  return static_cast<QInternal::DockPosition>(i);
801  }
802  }
803  }
804 
805  return QInternal::DockCount;
806 }
QList< QToolBarAreaLayoutLine > lines
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
QToolBarAreaLayoutInfo docks[4]
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
QList< QToolBarAreaLayoutItem > toolBarItems
virtual QWidget * widget()
If this item is a QWidget, it is returned as a QWidget; otherwise 0 is returned.

◆ fitLayout()

QRect QToolBarAreaLayout::fitLayout ( )

Definition at line 633 of file qtoolbararealayout.cpp.

Referenced by QMainWindowLayoutState::fitLayout().

634 {
635  if (!visible)
636  return rect;
637 
638  QSize left_hint = docks[QInternal::LeftDock].sizeHint();
639  QSize right_hint = docks[QInternal::RightDock].sizeHint();
640  QSize top_hint = docks[QInternal::TopDock].sizeHint();
641  QSize bottom_hint = docks[QInternal::BottomDock].sizeHint();
642 
643  QRect center = rect.adjusted(left_hint.width(), top_hint.height(),
644  -right_hint.width(), -bottom_hint.height());
645 
647  rect.width(), top_hint.height());
649  left_hint.width(), center.height());
650  docks[QInternal::RightDock].rect = QRect(center.right() + 1, center.top(),
651  right_hint.width(), center.height());
652  docks[QInternal::BottomDock].rect = QRect(rect.left(), center.bottom() + 1,
653  rect.width(), bottom_hint.height());
654 
657  }
661 
662  return center;
663 }
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
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
const QMainWindow * mainWindow
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
QToolBarAreaLayoutInfo docks[4]
int width() const
Returns the width.
Definition: qsize.h:126
Q_CORE_EXPORT QTextStream & center(QTextStream &s)
bool unifiedTitleAndToolBarOnMac
whether the window uses the unified title and toolbar look on Mac OS X
Definition: qmainwindow.h:83
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
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
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53

◆ gapIndex()

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

Definition at line 1029 of file qtoolbararealayout.cpp.

Referenced by QMainWindowLayoutState::gapIndex().

1030 {
1032  int minDistance = 80; // when a dock area is empty, how "wide" is it?
1033  QList<int> ret; //return value
1034  for (int i = 0; i < QInternal::DockCount; ++i) {
1035  QPoint p = pos;
1036  if (docks[i].o == Qt::Horizontal)
1037  p = QStyle::visualPos(dir, docks[i].rect, p);
1038  QList<int> result = docks[i].gapIndex(p, &minDistance);
1039  if (!result.isEmpty()) {
1040  result.prepend(i);
1041  ret = result;
1042  }
1043  }
1044 
1045  return ret;
1046 }
static QPoint visualPos(Qt::LayoutDirection direction, const QRect &boundingRect, const QPoint &logicalPos)
Returns the given logicalPosition converted to screen coordinates based on the specified direction...
Definition: qstyle.cpp:2109
const QMainWindow * mainWindow
QList< int > gapIndex(const QPoint &pos, int *maxDistance) const
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
QToolBarAreaLayoutInfo docks[4]
void prepend(const T &t)
Inserts value at the beginning of the list.
Definition: qlist.h:541
LayoutDirection
Definition: qnamespace.h:1580
Qt::LayoutDirection layoutDirection() const
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53

◆ getStyleOptionInfo()

void QToolBarAreaLayout::getStyleOptionInfo ( QStyleOptionToolBar option,
QToolBar toolBar 
) const

Definition at line 957 of file qtoolbararealayout.cpp.

958 {
959  for (int i = 0; i < QInternal::DockCount; ++i) {
960  const QToolBarAreaLayoutInfo &dock = docks[i];
961 
962  for (int j = 0; j < dock.lines.count(); ++j) {
963  const QToolBarAreaLayoutLine &line = dock.lines.at(j);
964 
965  for (int k = 0; k < line.toolBarItems.count(); ++k) {
966  if (line.toolBarItems.at(k).widgetItem->widget() == toolBar) {
967  if (line.toolBarItems.count() == 1)
969  else if (k == 0)
971  else if (k == line.toolBarItems.count() - 1)
973  else
975 
976  if (dock.lines.count() == 1)
978  else if (j == 0)
980  else if (j == dock.lines.count() - 1)
982  else
984 
985  return;
986  }
987  }
988  }
989  }
990 }
QList< QToolBarAreaLayoutLine > lines
ToolBarPosition positionWithinLine
This variable holds the position of the toolbar within a line.
Definition: qstyleoption.h:378
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
QToolBarAreaLayoutInfo docks[4]
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
if(void) toggleToolbarShown
ToolBarPosition positionOfLine
This variable holds the position of the toolbar line.
Definition: qstyleoption.h:377
QList< QToolBarAreaLayoutItem > toolBarItems
virtual QWidget * widget()
If this item is a QWidget, it is returned as a QWidget; otherwise 0 is returned.

◆ indexOf()

QList< int > QToolBarAreaLayout::indexOf ( QWidget toolBar) const

Definition at line 992 of file qtoolbararealayout.cpp.

Referenced by QMainWindowLayoutState::contains(), QMainWindowLayoutState::indexOf(), and QMainWindowLayoutState::restoreState().

993 {
994  QList<int> result;
995 
996  bool found = false;
997 
998  for (int i = 0; i < QInternal::DockCount; ++i) {
999  const QToolBarAreaLayoutInfo &dock = docks[i];
1000 
1001  for (int j = 0; j < dock.lines.count(); ++j) {
1002  const QToolBarAreaLayoutLine &line = dock.lines.at(j);
1003 
1004  for (int k = 0; k < line.toolBarItems.count(); ++k) {
1005  const QToolBarAreaLayoutItem &item = line.toolBarItems.at(k);
1006  if (!item.gap && item.widgetItem->widget() == toolBar) {
1007  found = true;
1008  result.prepend(k);
1009  break;
1010  }
1011  }
1012 
1013  if (found) {
1014  result.prepend(j);
1015  break;
1016  }
1017  }
1018 
1019  if (found) {
1020  result.prepend(i);
1021  break;
1022  }
1023  }
1024 
1025  return result;
1026 }
QList< QToolBarAreaLayoutLine > lines
QToolBarAreaLayoutItem * item(const QList< int > &path)
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
QToolBarAreaLayoutInfo docks[4]
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
QList< QToolBarAreaLayoutItem > toolBarItems
virtual QWidget * widget()
If this item is a QWidget, it is returned as a QWidget; otherwise 0 is returned.

◆ insertGap()

bool QToolBarAreaLayout::insertGap ( const QList< int > &  path,
QLayoutItem item 
)

Definition at line 1068 of file qtoolbararealayout.cpp.

Referenced by QMainWindowLayoutState::insertGap().

1069 {
1070  Q_ASSERT(path.count() == 3);
1071  const int i = path.first();
1072  Q_ASSERT(i >= 0 && i < QInternal::DockCount);
1073  return docks[i].insertGap(path.mid(1), item);
1074 }
QToolBarAreaLayoutItem * item(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
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
QToolBarAreaLayoutInfo docks[4]
T & first()
Returns a reference to the first item in the list.
Definition: qlist.h:282
bool insertGap(const QList< int > &path, QLayoutItem *item)

◆ insertItem() [1/2]

void QToolBarAreaLayout::insertItem ( QInternal::DockPosition  pos,
QLayoutItem item 
)

Definition at line 860 of file qtoolbararealayout.cpp.

861 {
862  if (docks[pos].lines.isEmpty())
863  docks[pos].lines.append(QToolBarAreaLayoutLine(docks[pos].o));
864  docks[pos].lines.last().toolBarItems.append(item);
865 }
QList< QToolBarAreaLayoutLine > lines
QToolBarAreaLayoutInfo docks[4]
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
T & last()
Returns a reference to the last item in the list.
Definition: qlist.h:284
QList< QToolBarAreaLayoutItem > toolBarItems

◆ insertItem() [2/2]

void QToolBarAreaLayout::insertItem ( QToolBar before,
QLayoutItem item 
)

Definition at line 867 of file qtoolbararealayout.cpp.

868 {
869  QInternal::DockPosition pos = findToolBar(before);
870  if (pos == QInternal::DockCount)
871  return;
872 
873  docks[pos].insertItem(before, item);
874 }
QToolBarAreaLayoutInfo docks[4]
void insertItem(QToolBar *before, QLayoutItem *item)
QInternal::DockPosition findToolBar(QToolBar *toolBar) const

◆ insertToolBar()

QLayoutItem * QToolBarAreaLayout::insertToolBar ( QToolBar before,
QToolBar toolBar 
)

Definition at line 808 of file qtoolbararealayout.cpp.

809 {
810  QInternal::DockPosition pos = findToolBar(before);
811  if (pos == QInternal::DockCount)
812  return 0;
813 
814  return docks[pos].insertToolBar(before, toolBar);
815 }
QToolBarAreaLayoutInfo docks[4]
QLayoutItem * insertToolBar(QToolBar *before, QToolBar *toolBar)
QInternal::DockPosition findToolBar(QToolBar *toolBar) const

◆ insertToolBarBreak()

void QToolBarAreaLayout::insertToolBarBreak ( QToolBar before)

Definition at line 830 of file qtoolbararealayout.cpp.

831 {
832  QInternal::DockPosition pos = findToolBar(before);
833  if (pos == QInternal::DockCount)
834  return;
835  docks[pos].insertToolBarBreak(before);
836 }
void insertToolBarBreak(QToolBar *before)
QToolBarAreaLayoutInfo docks[4]
QInternal::DockPosition findToolBar(QToolBar *toolBar) const

◆ isEmpty()

bool QToolBarAreaLayout::isEmpty ( ) const

Definition at line 1388 of file qtoolbararealayout.cpp.

Referenced by QToolBar::~QToolBar().

1389 {
1390  for (int i = 0; i < QInternal::DockCount; ++i) {
1391  if (!docks[i].lines.isEmpty())
1392  return false;
1393  }
1394  return true;
1395 }
QToolBarAreaLayoutInfo docks[4]

◆ item()

QToolBarAreaLayoutItem * QToolBarAreaLayout::item ( const QList< int > &  path)

Definition at line 1109 of file qtoolbararealayout.cpp.

Referenced by apply(), deleteAllLayoutItems(), indexOf(), insertGap(), QMainWindowLayoutState::item(), plug(), restoreState(), saveState(), and unplug().

1110 {
1111  Q_ASSERT(path.count() == 3);
1112 
1113  if (path.at(0) < 0 || path.at(0) >= QInternal::DockCount)
1114  return 0;
1115  QToolBarAreaLayoutInfo &info = docks[path.at(0)];
1116  if (path.at(1) < 0 || path.at(1) >= info.lines.count())
1117  return 0;
1118  QToolBarAreaLayoutLine &line = info.lines[path.at(1)];
1119  if (path.at(2) < 0 || path.at(2) >= line.toolBarItems.count())
1120  return 0;
1121  return &(line.toolBarItems[path.at(2)]);
1122 }
QList< QToolBarAreaLayoutLine > lines
static mach_timebase_info_data_t info
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
QToolBarAreaLayoutInfo docks[4]
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
QList< QToolBarAreaLayoutItem > toolBarItems

◆ itemAt()

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

Definition at line 728 of file qtoolbararealayout.cpp.

Referenced by QMainWindowLayoutState::itemAt().

729 {
730  Q_ASSERT(x != 0);
731 
732  for (int i = 0; i < QInternal::DockCount; ++i) {
733  const QToolBarAreaLayoutInfo &dock = docks[i];
734 
735  for (int j = 0; j < dock.lines.count(); ++j) {
736  const QToolBarAreaLayoutLine &line = dock.lines.at(j);
737 
738  for (int k = 0; k < line.toolBarItems.count(); ++k) {
739  if ((*x)++ == index)
740  return line.toolBarItems.at(k).widgetItem;
741  }
742  }
743  }
744 
745  return 0;
746 }
QList< QToolBarAreaLayoutLine > lines
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
QToolBarAreaLayoutInfo docks[4]
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
QList< QToolBarAreaLayoutItem > toolBarItems
quint16 index

◆ itemRect()

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

Definition at line 1124 of file qtoolbararealayout.cpp.

Referenced by QMainWindowLayoutState::gapRect(), and QMainWindowLayoutState::itemRect().

1125 {
1126  const int i = path.first();
1127 
1128  QRect r = docks[i].itemRect(path.mid(1));
1129  if (docks[i].o == Qt::Horizontal)
1131  docks[i].rect, r);
1132  return r;
1133 }
const QMainWindow * mainWindow
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
QToolBarAreaLayoutInfo docks[4]
QRect itemRect(const QList< int > &path) const
T & first()
Returns a reference to the first item in the list.
Definition: qlist.h:282
static QRect visualRect(Qt::LayoutDirection direction, const QRect &boundingRect, const QRect &logicalRect)
Returns the given logicalRectangle converted to screen coordinates based on the specified direction...
Definition: qstyle.cpp:2087
Qt::LayoutDirection layoutDirection() const
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58

◆ minimumSize()

QSize QToolBarAreaLayout::minimumSize ( const QSize centerMin) const

Definition at line 665 of file qtoolbararealayout.cpp.

Referenced by QMainWindowLayoutState::minimumSize().

666 {
667  if (!visible)
668  return centerMin;
669 
670  QSize result = centerMin;
671 
676 
677  result.setWidth(qMax(top_min.width(), result.width()));
678  result.setWidth(qMax(bottom_min.width(), result.width()));
679  result.setHeight(qMax(left_min.height(), result.height()));
680  result.setHeight(qMax(right_min.height(), result.height()));
681 
682  result.rwidth() += left_min.width() + right_min.width();
683  result.rheight() += top_min.height() + bottom_min.height();
684 
685  return result;
686 }
void setHeight(int h)
Sets the height to the given height.
Definition: qsize.h:135
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
void setWidth(int w)
Sets the width to the given width.
Definition: qsize.h:132
QToolBarAreaLayoutInfo docks[4]
int width() const
Returns the width.
Definition: qsize.h:126
int & rheight()
Returns a reference to the height.
Definition: qsize.h:144
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
int & rwidth()
Returns a reference to the width.
Definition: qsize.h:141

◆ moveToolBar()

void QToolBarAreaLayout::moveToolBar ( QToolBar toolbar,
int  pos 
)

Definition at line 851 of file qtoolbararealayout.cpp.

852 {
853  QInternal::DockPosition pos = findToolBar(toolbar);
854  if (pos == QInternal::DockCount)
855  return;
856  docks[pos].moveToolBar(toolbar, p);
857 }
QToolBarAreaLayoutInfo docks[4]
void moveToolBar(QToolBar *toolbar, int pos)
QInternal::DockPosition findToolBar(QToolBar *toolBar) const

◆ plug()

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

Definition at line 1135 of file qtoolbararealayout.cpp.

Referenced by QMainWindowLayoutState::plug().

1136 {
1137  QToolBarAreaLayoutItem *item = this->item(path);
1138  if (!item) {
1139  qWarning() << Q_FUNC_INFO << "No item at" << path;
1140  return 0;
1141  }
1142  Q_ASSERT(item->gap);
1143  Q_ASSERT(item->widgetItem != 0);
1144  item->gap = false;
1145  return item->widgetItem;
1146 }
QToolBarAreaLayoutItem * item(const QList< int > &path)
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
Q_CORE_EXPORT void qWarning(const char *,...)
#define Q_FUNC_INFO
Definition: qglobal.h:1871

◆ rectHint()

QRect QToolBarAreaLayout::rectHint ( const QRect r) const

Definition at line 711 of file qtoolbararealayout.cpp.

712 {
713  int coef = visible ? 1 : -1;
714 
715  QRect result = r;
716 
717  QSize left_hint = docks[QInternal::LeftDock].sizeHint();
718  QSize right_hint = docks[QInternal::RightDock].sizeHint();
719  QSize top_hint = docks[QInternal::TopDock].sizeHint();
720  QSize bottom_hint = docks[QInternal::BottomDock].sizeHint();
721 
722  result.adjust(-left_hint.width()*coef, -top_hint.height()*coef,
723  right_hint.width()*coef, bottom_hint.height()*coef);
724 
725  return result;
726 }
QToolBarAreaLayoutInfo docks[4]
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
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53

◆ remove() [1/2]

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

Definition at line 1076 of file qtoolbararealayout.cpp.

Referenced by QMainWindowLayoutState::remove().

1077 {
1078  Q_ASSERT(path.count() == 3);
1079  docks[path.at(0)].lines[path.at(1)].toolBarItems.removeAt(path.at(2));
1080 }
QList< QToolBarAreaLayoutLine > lines
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
QToolBarAreaLayoutInfo docks[4]
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
void removeAt(int i)
Removes the item at index position i.
Definition: qlist.h:480

◆ remove() [2/2]

void QToolBarAreaLayout::remove ( QLayoutItem item)

Definition at line 1082 of file qtoolbararealayout.cpp.

1083 {
1084  for (int i = 0; i < QInternal::DockCount; ++i) {
1085  QToolBarAreaLayoutInfo &dock = docks[i];
1086 
1087  for (int j = 0; j < dock.lines.count(); ++j) {
1088  QToolBarAreaLayoutLine &line = dock.lines[j];
1089 
1090  for (int k = 0; k < line.toolBarItems.count(); k++) {
1091  if (line.toolBarItems[k].widgetItem == item) {
1092  line.toolBarItems.removeAt(k);
1093  if (line.toolBarItems.isEmpty())
1094  dock.lines.removeAt(j);
1095  return;
1096  }
1097  }
1098  }
1099  }
1100 }
QList< QToolBarAreaLayoutLine > lines
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
QToolBarAreaLayoutInfo docks[4]
QList< QToolBarAreaLayoutItem > toolBarItems
void removeAt(int i)
Removes the item at index position i.
Definition: qlist.h:480

◆ removeToolBar()

void QToolBarAreaLayout::removeToolBar ( QToolBar toolBar)

Definition at line 817 of file qtoolbararealayout.cpp.

818 {
819  QInternal::DockPosition pos = findToolBar(toolBar);
820  if (pos == QInternal::DockCount)
821  return;
822  docks[pos].removeToolBar(toolBar);
823 }
void removeToolBar(QToolBar *toolBar)
QToolBarAreaLayoutInfo docks[4]
QInternal::DockPosition findToolBar(QToolBar *toolBar) const

◆ removeToolBarBreak()

void QToolBarAreaLayout::removeToolBarBreak ( QToolBar before)

Definition at line 838 of file qtoolbararealayout.cpp.

839 {
840  QInternal::DockPosition pos = findToolBar(before);
841  if (pos == QInternal::DockCount)
842  return;
843  docks[pos].removeToolBarBreak(before);
844 }
void removeToolBarBreak(QToolBar *before)
QToolBarAreaLayoutInfo docks[4]
QInternal::DockPosition findToolBar(QToolBar *toolBar) const

◆ restoreState()

bool QToolBarAreaLayout::restoreState ( QDataStream stream,
const QList< QToolBar *> &  toolBars,
uchar  tmarker,
bool  pre43,
bool  testing = false 
)

Definition at line 1310 of file qtoolbararealayout.cpp.

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

1311 {
1312  QList<QToolBar*> toolBars = _toolBars;
1313  int lines;
1314  stream >> lines;
1315  if (!testing)
1317 
1318  for (int j = 0; j < lines; ++j) {
1319  int pos;
1320  stream >> pos;
1321  if (pos < 0 || pos >= QInternal::DockCount)
1322  return false;
1323  int cnt;
1324  stream >> cnt;
1325 
1326  QToolBarAreaLayoutInfo &dock = docks[pos];
1327  const bool applyingLayout = !testing && !(pos == QInternal::TopDock && mainWindow->unifiedTitleAndToolBarOnMac());
1328  QToolBarAreaLayoutLine line(dock.o);
1329 
1330  for (int k = 0; k < cnt; ++k) {
1332 
1333  QString objectName;
1334  stream >> objectName;
1335  uchar shown;
1336  stream >> shown;
1337  item.pos = getInt(stream, dock.o, pre43);
1338  item.size = getInt(stream, dock.o, pre43);
1339 
1340  /*
1341  4.3.0 added floating toolbars, but failed to add the ability to restore them.
1342  We need to store there geometry (four ints). We cannot change the format in a
1343  patch release (4.3.1) by adding ToolBarStateMarkerEx2 to signal extra data. So
1344  for now we'll pack it in the two legacy ints we no longer used in Qt4.3.0.
1345  In 4.4, we should add ToolBarStateMarkerEx2 and fix this properly.
1346  */
1347 
1348  QRect rect;
1349  bool floating = false;
1350  uint geom0, geom1;
1351  geom0 = getInt(stream, dock.o, pre43);
1352  if (tmarker == ToolBarStateMarkerEx) {
1353  geom1 = getInt(stream, dock.o, pre43);
1354  rect = unpackRect(geom0, geom1, &floating);
1355  }
1356 
1357  QToolBar *toolBar = 0;
1358  for (int x = 0; x < toolBars.count(); ++x) {
1359  if (toolBars.at(x)->objectName() == objectName) {
1360  toolBar = toolBars.takeAt(x);
1361  break;
1362  }
1363  }
1364  if (toolBar == 0) {
1365  continue;
1366  }
1367 
1368  if (applyingLayout) {
1369  item.widgetItem = new QWidgetItemV2(toolBar);
1370  toolBar->setOrientation(floating ? ((shown & 2) ? Qt::Vertical : Qt::Horizontal) : dock.o);
1371  toolBar->setVisible(shown & 1);
1372  toolBar->d_func()->setWindowState(floating, true, rect);
1373 
1374  item.preferredSize = item.size;
1375  line.toolBarItems.append(item);
1376  }
1377  }
1378 
1379  if (applyingLayout) {
1380  dock.lines.append(line);
1381  }
1382  }
1383 
1384 
1385  return stream.status() == QDataStream::Ok;
1386 }
Status status() const
Returns the status of the data stream.
QList< QToolBarAreaLayoutLine > lines
QToolBarAreaLayoutItem * item(const QList< int > &path)
void setWindowState(Qt::WindowStates state)
Sets the window state to windowState.
const QMainWindow * mainWindow
void setOrientation(Qt::Orientation orientation)
Definition: qtoolbar.cpp:750
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
QToolBarAreaLayoutInfo docks[4]
unsigned char uchar
Definition: qglobal.h:994
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
The QToolBar class provides a movable panel that contains a set of controls.
Definition: qtoolbar.h:62
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
unsigned int uint
Definition: qglobal.h:996
virtual void setVisible(bool visible)
Definition: qwidget.cpp:7991
bool unifiedTitleAndToolBarOnMac
whether the window uses the unified title and toolbar look on Mac OS X
Definition: qmainwindow.h:83
QString objectName() const
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
T takeAt(int i)
Removes the item at index position i and returns it.
Definition: qlist.h:484
static QRect unpackRect(uint geom0, uint geom1, bool *floating)
static int getInt(QDataStream &stream, Qt::Orientation o, bool pre43)
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ saveState()

void QToolBarAreaLayout::saveState ( QDataStream stream) const

Definition at line 1247 of file qtoolbararealayout.cpp.

Referenced by QMainWindowLayoutState::saveState().

1248 {
1249  // save toolbar state
1250  stream << (uchar) ToolBarStateMarkerEx;
1251 
1252  int lineCount = 0;
1253  for (int i = 0; i < QInternal::DockCount; ++i)
1254  lineCount += docks[i].lines.count();
1255 
1256  stream << lineCount;
1257 
1258  for (int i = 0; i < QInternal::DockCount; ++i) {
1259  const QToolBarAreaLayoutInfo &dock = docks[i];
1260 
1261  for (int j = 0; j < dock.lines.count(); ++j) {
1262  const QToolBarAreaLayoutLine &line = dock.lines.at(j);
1263 
1264  stream << i << line.toolBarItems.count();
1265 
1266  for (int k = 0; k < line.toolBarItems.count(); ++k) {
1267  const QToolBarAreaLayoutItem &item = line.toolBarItems.at(k);
1268  QWidget *widget = const_cast<QLayoutItem*>(item.widgetItem)->widget();
1269  QString objectName = widget->objectName();
1270  if (objectName.isEmpty()) {
1271  qWarning("QMainWindow::saveState(): 'objectName' not set for QToolBar %p '%s'",
1272  widget, widget->windowTitle().toLocal8Bit().constData());
1273  }
1274  stream << objectName;
1275  // we store information as:
1276  // 1st bit: 1 if shown
1277  // 2nd bit: 1 if orientation is vertical (default is horizontal)
1278  uchar shownOrientation = (uchar)!widget->isHidden();
1279  if (QToolBar * tb= qobject_cast<QToolBar*>(widget)) {
1280  if (tb->orientation() == Qt::Vertical)
1281  shownOrientation |= 2;
1282  }
1283  stream << shownOrientation;
1284  stream << item.pos;
1285  //we store the preferred size. If the use rdidn't resize the toolbars it will be -1
1286  stream << item.preferredSize;
1287 
1288  uint geom0, geom1;
1289  packRect(&geom0, &geom1, widget->geometry(), widget->isWindow());
1290  stream << geom0 << geom1;
1291  }
1292  }
1293  }
1294 }
QList< QToolBarAreaLayoutLine > lines
QPointer< QWidget > widget
QToolBarAreaLayoutItem * item(const QList< int > &path)
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
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 isHidden() const
Returns true if the widget is hidden, otherwise returns false.
Definition: qwidget.h:1008
QToolBarAreaLayoutInfo docks[4]
unsigned char uchar
Definition: qglobal.h:994
The QLayoutItem class provides an abstract item that a QLayout manipulates.
Definition: qlayoutitem.h:64
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
The QToolBar class provides a movable panel that contains a set of controls.
Definition: qtoolbar.h:62
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 *,...)
unsigned int uint
Definition: qglobal.h:996
QString windowTitle
the window title (caption)
Definition: qwidget.h:198
QByteArray toLocal8Bit() const Q_REQUIRED_RESULT
Returns the local 8-bit representation of the string as a QByteArray.
Definition: qstring.cpp:4049
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
static void packRect(uint *geom0, uint *geom1, const QRect &rect, bool floating)
QString objectName() const
QList< QToolBarAreaLayoutItem > toolBarItems
QRect geometry
the geometry of the widget relative to its parent and excluding the window frame
Definition: qwidget.h:158

◆ sizeHint()

QSize QToolBarAreaLayout::sizeHint ( const QSize center) const

Definition at line 688 of file qtoolbararealayout.cpp.

Referenced by QMainWindowLayoutState::sizeHint().

689 {
690  if (!visible)
691  return centerHint;
692 
693  QSize result = centerHint;
694 
695  QSize left_hint = docks[QInternal::LeftDock].sizeHint();
696  QSize right_hint = docks[QInternal::RightDock].sizeHint();
697  QSize top_hint = docks[QInternal::TopDock].sizeHint();
698  QSize bottom_hint = docks[QInternal::BottomDock].sizeHint();
699 
700  result.setWidth(qMax(top_hint.width(), result.width()));
701  result.setWidth(qMax(bottom_hint.width(), result.width()));
702  result.setHeight(qMax(left_hint.height(), result.height()));
703  result.setHeight(qMax(right_hint.height(), result.height()));
704 
705  result.rwidth() += left_hint.width() + right_hint.width();
706  result.rheight() += top_hint.height() + bottom_hint.height();
707 
708  return result;
709 }
void setHeight(int h)
Sets the height to the given height.
Definition: qsize.h:135
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
void setWidth(int w)
Sets the width to the given width.
Definition: qsize.h:132
QToolBarAreaLayoutInfo docks[4]
int width() const
Returns the width.
Definition: qsize.h:126
int & rheight()
Returns a reference to the height.
Definition: qsize.h:144
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
int & rwidth()
Returns a reference to the width.
Definition: qsize.h:141

◆ takeAt()

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

Definition at line 748 of file qtoolbararealayout.cpp.

Referenced by QMainWindowLayoutState::takeAt().

749 {
750  Q_ASSERT(x != 0);
751 
752  for (int i = 0; i < QInternal::DockCount; ++i) {
753  QToolBarAreaLayoutInfo &dock = docks[i];
754 
755  for (int j = 0; j < dock.lines.count(); ++j) {
756  QToolBarAreaLayoutLine &line = dock.lines[j];
757 
758  for (int k = 0; k < line.toolBarItems.count(); ++k) {
759  if ((*x)++ == index) {
760  QLayoutItem *result = line.toolBarItems.takeAt(k).widgetItem;
761  if (line.toolBarItems.isEmpty())
762  dock.lines.removeAt(j);
763  return result;
764  }
765  }
766  }
767  }
768 
769  return 0;
770 }
QList< QToolBarAreaLayoutLine > lines
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
QToolBarAreaLayoutInfo docks[4]
The QLayoutItem class provides an abstract item that a QLayout manipulates.
Definition: qlayoutitem.h:64
T takeAt(int i)
Removes the item at index position i and returns it.
Definition: qlist.h:484
QList< QToolBarAreaLayoutItem > toolBarItems
quint16 index
void removeAt(int i)
Removes the item at index position i.
Definition: qlist.h:480

◆ toolBarBreak()

bool QToolBarAreaLayout::toolBarBreak ( QToolBar toolBar) const

Definition at line 939 of file qtoolbararealayout.cpp.

940 {
941  for (int i = 0; i < QInternal::DockCount; ++i) {
942  const QToolBarAreaLayoutInfo &dock = docks[i];
943 
944  for (int j = 0; j < dock.lines.count(); ++j) {
945  const QToolBarAreaLayoutLine &line = dock.lines.at(j);
946 
947  for (int k = 0; k < line.toolBarItems.count(); ++k) {
948  if (line.toolBarItems.at(k).widgetItem->widget() == toolBar)
949  return j > 0 && k == 0;
950  }
951  }
952  }
953 
954  return false;
955 }
QList< QToolBarAreaLayoutLine > lines
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
QToolBarAreaLayoutInfo docks[4]
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
QList< QToolBarAreaLayoutItem > toolBarItems
virtual QWidget * widget()
If this item is a QWidget, it is returned as a QWidget; otherwise 0 is returned.

◆ unplug()

QLayoutItem * QToolBarAreaLayout::unplug ( const QList< int > &  path,
QToolBarAreaLayout other 
)

Definition at line 1148 of file qtoolbararealayout.cpp.

Referenced by QMainWindowLayoutState::unplug().

1149 {
1150  //other needs to be update as well
1151  Q_ASSERT(path.count() == 3);
1152  QToolBarAreaLayoutItem *item = this->item(path);
1153  Q_ASSERT(item);
1154 
1155  //update the leading space here
1156  QToolBarAreaLayoutInfo &info = docks[path.at(0)];
1157  QToolBarAreaLayoutLine &line = info.lines[path.at(1)];
1158  if (item->size != pick(line.o, item->realSizeHint())) {
1159  //the item doesn't have its default size
1160  //so we'll give this to the next item
1161  int newExtraSpace = 0;
1162  //let's iterate over the siblings of the current item that pare placed before it
1163  //we need to find just the one before
1164  for (int i = path.at(2) - 1; i >= 0; --i) {
1165  QToolBarAreaLayoutItem &previous = line.toolBarItems[i];
1166  if (!previous.skip()) {
1167  //we need to check if it has a previous element and a next one
1168  //the previous will get its size changed
1169  for (int j = path.at(2) + 1; j < line.toolBarItems.count(); ++j) {
1170  const QToolBarAreaLayoutItem &next = line.toolBarItems.at(j);
1171  if (!next.skip()) {
1172  newExtraSpace = next.pos - previous.pos - pick(line.o, previous.sizeHint());
1173  previous.resize(line.o, next.pos - previous.pos);
1174  break;
1175  }
1176  }
1177  break;
1178  }
1179  }
1180 
1181  if (other) {
1182  QToolBarAreaLayoutInfo &info = other->docks[path.at(0)];
1183  QToolBarAreaLayoutLine &line = info.lines[path.at(1)];
1184  for (int i = path.at(2) - 1; i >= 0; --i) {
1185  QToolBarAreaLayoutItem &previous = line.toolBarItems[i];
1186  if (!previous.skip()) {
1187  previous.resize(line.o, pick(line.o, previous.sizeHint()) + newExtraSpace);
1188  break;
1189  }
1190  }
1191 
1192  }
1193  }
1194 
1195  Q_ASSERT(!item->gap);
1196  item->gap = true;
1197  return item->widgetItem;
1198 }
QList< QToolBarAreaLayoutLine > lines
static mach_timebase_info_data_t info
QToolBarAreaLayoutItem * item(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
QToolBarAreaLayoutInfo docks[4]
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
void resize(Qt::Orientation o, int newSize)
QList< QToolBarAreaLayoutItem > toolBarItems
static int pick(bool vertical, const QSize &size)

Properties

◆ docks

QToolBarAreaLayoutInfo QToolBarAreaLayout::docks[4]

◆ mainWindow

const QMainWindow* QToolBarAreaLayout::mainWindow

Definition at line 195 of file qtoolbararealayout_p.h.

Referenced by apply(), fitLayout(), gapIndex(), itemRect(), and restoreState().

◆ rect

QRect QToolBarAreaLayout::rect

◆ visible

bool QToolBarAreaLayout::visible

Definition at line 197 of file qtoolbararealayout_p.h.

Referenced by apply(), fitLayout(), minimumSize(), rectHint(), and sizeHint().


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