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

#include <qmainwindowlayout_p.h>

Public Functions

void apply (bool animated)
 
QWidgetcentralWidget () const
 
bool checkFormat (QDataStream &stream, bool pre43)
 
void clear ()
 
bool contains (QWidget *widget) const
 
void deleteAllLayoutItems ()
 
void deleteCentralWidgetItem ()
 
void fitLayout ()
 
QList< int > gapIndex (QWidget *widget, const QPoint &pos) const
 
QRect gapRect (const QList< int > &path) const
 
QList< int > indexOf (QWidget *widget) const
 
bool insertGap (const QList< int > &path, QLayoutItem *item)
 
bool isValid () const
 
QLayoutItemitem (const QList< int > &path)
 
QLayoutItemitemAt (int index, int *x) const
 
QRect itemRect (const QList< int > &path) const
 
QSize minimumSize () const
 
QLayoutItemplug (const QList< int > &path)
 
 QMainWindowLayoutState (QMainWindow *win)
 
void remove (const QList< int > &path)
 
void remove (QLayoutItem *item)
 
bool restoreState (QDataStream &stream, const QMainWindowLayoutState &oldState)
 
void saveState (QDataStream &stream) const
 
void setCentralWidget (QWidget *widget)
 
QSize sizeHint () const
 
QLayoutItemtakeAt (int index, int *x)
 
QLayoutItemunplug (const QList< int > &path, QMainWindowLayoutState *savedState=0)
 

Public Variables

QDockAreaLayout dockAreaLayout
 
QMainWindowmainWindow
 
QRect rect
 
QToolBarAreaLayout toolBarAreaLayout
 

Detailed Description

Definition at line 105 of file qmainwindowlayout_p.h.

Constructors and Destructors

◆ QMainWindowLayoutState()

QMainWindowLayoutState::QMainWindowLayoutState ( QMainWindow win)

Definition at line 179 of file qmainwindowlayout.cpp.

180  :
181 #ifndef QT_NO_TOOLBAR
182  toolBarAreaLayout(win),
183 #endif
184 #ifndef QT_NO_DOCKWIDGET
185  dockAreaLayout(win)
186 #else
187  centralWidgetItem(0)
188 #endif
189 
190 {
191  mainWindow = win;
192 }
QDockAreaLayout dockAreaLayout
QToolBarAreaLayout toolBarAreaLayout

Functions

◆ apply()

void QMainWindowLayoutState::apply ( bool  animated)

Definition at line 231 of file qmainwindowlayout.cpp.

Referenced by QMainWindowLayout::applyState().

232 {
233 #ifndef QT_NO_TOOLBAR
234  toolBarAreaLayout.apply(animated);
235 #endif
236 
237 #ifndef QT_NO_DOCKWIDGET
238 // dumpLayout(dockAreaLayout, QString());
239  dockAreaLayout.apply(animated);
240 #else
241  if (centralWidgetItem != 0) {
243  Q_ASSERT(layout != 0);
244  layout->widgetAnimator.animate(centralWidgetItem->widget(), centralWidgetRect, animated);
245  }
246 #endif
247 }
QMainWindowLayout * qt_mainwindow_layout(const QMainWindow *window)
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
QDockAreaLayout dockAreaLayout
const char * layout
void apply(bool animate)
QWidgetAnimator widgetAnimator
void apply(bool animate)
QToolBarAreaLayout toolBarAreaLayout
void animate(QWidget *widget, const QRect &final_geometry, bool animate)

◆ centralWidget()

QWidget * QMainWindowLayoutState::centralWidget ( ) const

Definition at line 390 of file qmainwindowlayout.cpp.

Referenced by QMainWindowLayout::centralWidget().

391 {
392  QLayoutItem *item = 0;
393 
394 #ifndef QT_NO_DOCKWIDGET
396 #else
397  item = centralWidgetItem;
398 #endif
399 
400  if (item != 0)
401  return item->widget();
402  return 0;
403 }
QDockAreaLayout dockAreaLayout
QLayoutItem * centralWidgetItem
The QLayoutItem class provides an abstract item that a QLayout manipulates.
Definition: qlayoutitem.h:64
QLayoutItem * item(const QList< int > &path)
virtual QWidget * widget()
If this item is a QWidget, it is returned as a QWidget; otherwise 0 is returned.

◆ checkFormat()

bool QMainWindowLayoutState::checkFormat ( QDataStream stream,
bool  pre43 
)

Definition at line 624 of file qmainwindowlayout.cpp.

Referenced by restoreState().

625 {
626 #ifdef QT_NO_TOOLBAR
627  Q_UNUSED(pre43);
628 #endif
629  while (!stream.atEnd()) {
630  uchar marker;
631  stream >> marker;
632  switch(marker)
633  {
634 #ifndef QT_NO_TOOLBAR
637  {
638  QList<QToolBar *> toolBars = findChildrenHelper<QToolBar*>(mainWindow);
639  if (!toolBarAreaLayout.restoreState(stream, toolBars, marker,
640  pre43 /*testing 4.3 format*/, true /*testing*/)) {
641  return false;
642  }
643  }
644  break;
645 #endif // QT_NO_TOOLBAR
646 
647 #ifndef QT_NO_DOCKWIDGET
649  {
650  QList<QDockWidget *> dockWidgets = findChildrenHelper<QDockWidget*>(mainWindow);
651  if (!dockAreaLayout.restoreState(stream, dockWidgets, true /*testing*/)) {
652  return false;
653  }
654  }
655  break;
656 #endif
657  default:
658  //there was an error during the parsing
659  return false;
660  }// switch
661  } //while
662 
663  //everything went fine: it must be a pre-4.3 saved state
664  return true;
665 }
bool atEnd() const
Returns true if the I/O device has reached the end position (end of the stream or file) or if there i...
QDockAreaLayout dockAreaLayout
unsigned char uchar
Definition: qglobal.h:994
bool restoreState(QDataStream &stream, const QList< QToolBar *> &toolBars, uchar tmarker, bool pre43, bool testing=false)
bool restoreState(QDataStream &stream, const QList< QDockWidget *> &widgets, bool testing=false)
QToolBarAreaLayout toolBarAreaLayout
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ clear()

void QMainWindowLayoutState::clear ( )

Definition at line 488 of file qmainwindowlayout.cpp.

Referenced by QMainWindowLayout::restoreState().

489 {
490 #ifndef QT_NO_TOOLBAR
492 #endif
493 
494 #ifndef QT_NO_DOCKWIDGET
496 #else
497  centralWidgetRect = QRect();
498 #endif
499 
500  rect = QRect();
501 }
QDockAreaLayout dockAreaLayout
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
QToolBarAreaLayout toolBarAreaLayout

◆ contains()

bool QMainWindowLayoutState::contains ( QWidget widget) const

Definition at line 355 of file qmainwindowlayout.cpp.

356 {
357 #ifndef QT_NO_DOCKWIDGET
359  return true;
360  if (!dockAreaLayout.indexOf(widget).isEmpty())
361  return true;
362 #else
363  if (centralWidgetItem != 0 && centralWidgetItem->widget() == widget)
364  return true;
365 #endif
366 
367 #ifndef QT_NO_TOOLBAR
368  if (!toolBarAreaLayout.indexOf(widget).isEmpty())
369  return true;
370 #endif
371  return false;
372 }
QPointer< QWidget > widget
QDockAreaLayout dockAreaLayout
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
QLayoutItem * centralWidgetItem
QList< int > indexOf(QWidget *toolBar) const
QList< int > indexOf(QWidget *dockWidget) const
virtual QWidget * widget()
If this item is a QWidget, it is returned as a QWidget; otherwise 0 is returned.
QToolBarAreaLayout toolBarAreaLayout

◆ deleteAllLayoutItems()

void QMainWindowLayoutState::deleteAllLayoutItems ( )

Definition at line 267 of file qmainwindowlayout.cpp.

Referenced by QMainWindowLayout::restoreState(), and QMainWindowLayout::~QMainWindowLayout().

268 {
269 #ifndef QT_NO_TOOLBAR
271 #endif
272 
273 #ifndef QT_NO_DOCKWIDGET
275 #endif
276 }
QDockAreaLayout dockAreaLayout
QToolBarAreaLayout toolBarAreaLayout

◆ deleteCentralWidgetItem()

void QMainWindowLayoutState::deleteCentralWidgetItem ( )

Definition at line 278 of file qmainwindowlayout.cpp.

Referenced by setCentralWidget(), and QMainWindowLayout::~QMainWindowLayout().

279 {
280 #ifndef QT_NO_DOCKWIDGET
283 #else
284  delete centralWidgetItem;
285  centralWidgetItem = 0;
286 #endif
287 }
QDockAreaLayout dockAreaLayout
QLayoutItem * centralWidgetItem

◆ fitLayout()

void QMainWindowLayoutState::fitLayout ( )

Definition at line 249 of file qmainwindowlayout.cpp.

Referenced by QMainWindowLayout::restoreState(), and QMainWindowLayout::unplug().

250 {
251  QRect r;
252 #ifdef QT_NO_TOOLBAR
253  r = rect;
254 #else
257 #endif // QT_NO_TOOLBAR
258 
259 #ifndef QT_NO_DOCKWIDGET
260  dockAreaLayout.rect = r;
262 #else
263  centralWidgetRect = r;
264 #endif
265 }
QDockAreaLayout dockAreaLayout
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
QToolBarAreaLayout toolBarAreaLayout

◆ gapIndex()

QList< int > QMainWindowLayoutState::gapIndex ( QWidget widget,
const QPoint pos 
) const

Definition at line 405 of file qmainwindowlayout.cpp.

Referenced by QMainWindowLayout::hover().

407 {
408  QList<int> result;
409 
410 #ifndef QT_NO_TOOLBAR
411  // is it a toolbar?
412  if (qobject_cast<QToolBar*>(widget) != 0) {
413  result = toolBarAreaLayout.gapIndex(pos);
414  if (!result.isEmpty())
415  result.prepend(0);
416  return result;
417  }
418 #endif
419 
420 #ifndef QT_NO_DOCKWIDGET
421  // is it a dock widget?
422  if (qobject_cast<QDockWidget *>(widget) != 0) {
423  result = dockAreaLayout.gapIndex(pos);
424  if (!result.isEmpty())
425  result.prepend(1);
426  return result;
427  }
428 #endif //QT_NO_DOCKWIDGET
429 
430  return result;
431 }
QDockAreaLayout dockAreaLayout
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
QList< int > gapIndex(const QPoint &pos) const
QList< int > gapIndex(const QPoint &pos) const
QToolBarAreaLayout toolBarAreaLayout

◆ gapRect()

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

Definition at line 545 of file qmainwindowlayout.cpp.

546 {
547  int i = path.first();
548 
549 #ifndef QT_NO_TOOLBAR
550  if (i == 0)
551  return toolBarAreaLayout.itemRect(path.mid(1));
552 #endif
553 
554 #ifndef QT_NO_DOCKWIDGET
555  if (i == 1)
556  return dockAreaLayout.gapRect(path.mid(1));
557 #endif //QT_NO_DOCKWIDGET
558 
559  return QRect();
560 }
QRect itemRect(const QList< int > &path) const
QDockAreaLayout dockAreaLayout
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 gapRect(const QList< int > &path) const
T & first()
Returns a reference to the first item in the list.
Definition: qlist.h:282
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
QToolBarAreaLayout toolBarAreaLayout

◆ indexOf()

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

Definition at line 328 of file qmainwindowlayout.cpp.

Referenced by QToolBarLayout::setExpanded(), and QMainWindowLayout::unplug().

329 {
330  QList<int> result;
331 
332 #ifndef QT_NO_TOOLBAR
333  // is it a toolbar?
334  if (QToolBar *toolBar = qobject_cast<QToolBar*>(widget)) {
335  result = toolBarAreaLayout.indexOf(toolBar);
336  if (!result.isEmpty())
337  result.prepend(0);
338  return result;
339  }
340 #endif
341 
342 #ifndef QT_NO_DOCKWIDGET
343  // is it a dock widget?
344  if (QDockWidget *dockWidget = qobject_cast<QDockWidget *>(widget)) {
345  result = dockAreaLayout.indexOf(dockWidget);
346  if (!result.isEmpty())
347  result.prepend(1);
348  return result;
349  }
350 #endif //QT_NO_DOCKWIDGET
351 
352  return result;
353 }
The QDockWidget class provides a widget that can be docked inside a QMainWindow or floated as a top-l...
Definition: qdockwidget.h:60
QDockAreaLayout dockAreaLayout
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
The QToolBar class provides a movable panel that contains a set of controls.
Definition: qtoolbar.h:62
void prepend(const T &t)
Inserts value at the beginning of the list.
Definition: qlist.h:541
QList< int > indexOf(QWidget *toolBar) const
QList< int > indexOf(QWidget *dockWidget) const
QToolBarAreaLayout toolBarAreaLayout

◆ insertGap()

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

Definition at line 433 of file qmainwindowlayout.cpp.

434 {
435  if (path.isEmpty())
436  return false;
437 
438  int i = path.first();
439 
440 #ifndef QT_NO_TOOLBAR
441  if (i == 0) {
442  Q_ASSERT(qobject_cast<QToolBar*>(item->widget()) != 0);
443  return toolBarAreaLayout.insertGap(path.mid(1), item);
444  }
445 #endif
446 
447 #ifndef QT_NO_DOCKWIDGET
448  if (i == 1) {
449  Q_ASSERT(qobject_cast<QDockWidget*>(item->widget()) != 0);
450  return dockAreaLayout.insertGap(path.mid(1), item);
451  }
452 #endif //QT_NO_DOCKWIDGET
453 
454  return false;
455 }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
bool insertGap(const QList< int > &path, QLayoutItem *item)
QDockAreaLayout dockAreaLayout
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
bool insertGap(const QList< int > &path, QLayoutItem *dockWidgetItem)
QLayoutItem * item(const QList< int > &path)
virtual QWidget * widget()
If this item is a QWidget, it is returned as a QWidget; otherwise 0 is returned.
QToolBarAreaLayout toolBarAreaLayout

◆ isValid()

bool QMainWindowLayoutState::isValid ( ) const

Definition at line 503 of file qmainwindowlayout.cpp.

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

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

◆ item()

QLayoutItem * QMainWindowLayoutState::item ( const QList< int > &  path)

Definition at line 508 of file qmainwindowlayout.cpp.

Referenced by QMainWindowLayout::addToolBar(), insertGap(), QMainWindowLayout::insertToolBar(), setCentralWidget(), and QMainWindowLayout::unplug().

509 {
510  int i = path.first();
511 
512 #ifndef QT_NO_TOOLBAR
513  if (i == 0) {
514  const QToolBarAreaLayoutItem *tbItem = toolBarAreaLayout.item(path.mid(1));
515  Q_ASSERT(tbItem);
516  return tbItem->widgetItem;
517  }
518 #endif
519 
520 #ifndef QT_NO_DOCKWIDGET
521  if (i == 1)
522  return dockAreaLayout.item(path.mid(1)).widgetItem;
523 #endif //QT_NO_DOCKWIDGET
524 
525  return 0;
526 }
QToolBarAreaLayoutItem * item(const QList< int > &path)
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
QDockAreaLayout dockAreaLayout
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
QDockAreaLayoutItem & item(const QList< int > &path)
QToolBarAreaLayout toolBarAreaLayout

◆ itemAt()

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

Definition at line 289 of file qmainwindowlayout.cpp.

290 {
291 #ifndef QT_NO_TOOLBAR
292  if (QLayoutItem *ret = toolBarAreaLayout.itemAt(x, index))
293  return ret;
294 #endif
295 
296 #ifndef QT_NO_DOCKWIDGET
297  if (QLayoutItem *ret = dockAreaLayout.itemAt(x, index))
298  return ret;
299 #else
300  if (centralWidgetItem != 0 && (*x)++ == index)
301  return centralWidgetItem;
302 #endif
303 
304  return 0;
305 }
QDockAreaLayout dockAreaLayout
The QLayoutItem class provides an abstract item that a QLayout manipulates.
Definition: qlayoutitem.h:64
QLayoutItem * itemAt(int *x, int index) const
quint16 index
QLayoutItem * itemAt(int *x, int index) const
QToolBarAreaLayout toolBarAreaLayout

◆ itemRect()

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

Definition at line 528 of file qmainwindowlayout.cpp.

Referenced by QToolBarLayout::setExpanded(), and QMainWindowLayout::unplug().

529 {
530  int i = path.first();
531 
532 #ifndef QT_NO_TOOLBAR
533  if (i == 0)
534  return toolBarAreaLayout.itemRect(path.mid(1));
535 #endif
536 
537 #ifndef QT_NO_DOCKWIDGET
538  if (i == 1)
539  return dockAreaLayout.itemRect(path.mid(1));
540 #endif //QT_NO_DOCKWIDGET
541 
542  return QRect();
543 }
QRect itemRect(const QList< int > &path) const
QDockAreaLayout dockAreaLayout
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
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
QRect itemRect(const QList< int > &path) const
QToolBarAreaLayout toolBarAreaLayout

◆ minimumSize()

QSize QMainWindowLayoutState::minimumSize ( ) const

Definition at line 213 of file qmainwindowlayout.cpp.

214 {
215  QSize result(0, 0);
216 
217 #ifndef QT_NO_DOCKWIDGET
218  result = dockAreaLayout.minimumSize();
219 #else
220  if (centralWidgetItem != 0)
221  result = centralWidgetItem->minimumSize();
222 #endif
223 
224 #ifndef QT_NO_TOOLBAR
225  result = toolBarAreaLayout.minimumSize(result);
226 #endif // QT_NO_TOOLBAR
227 
228  return result;
229 }
QDockAreaLayout dockAreaLayout
QSize minimumSize(const QSize &centerMin) const
QSize minimumSize() const
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
QToolBarAreaLayout toolBarAreaLayout

◆ plug()

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

Definition at line 562 of file qmainwindowlayout.cpp.

563 {
564  int i = path.first();
565 
566 #ifndef QT_NO_TOOLBAR
567  if (i == 0)
568  return toolBarAreaLayout.plug(path.mid(1));
569 #endif
570 
571 #ifndef QT_NO_DOCKWIDGET
572  if (i == 1)
573  return dockAreaLayout.plug(path.mid(1));
574 #endif //QT_NO_DOCKWIDGET
575 
576  return 0;
577 }
QLayoutItem * plug(const QList< int > &path)
QDockAreaLayout dockAreaLayout
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
QLayoutItem * plug(const QList< int > &path)
QToolBarAreaLayout toolBarAreaLayout

◆ remove() [1/2]

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

Definition at line 457 of file qmainwindowlayout.cpp.

458 {
459  int i = path.first();
460 
461 #ifndef QT_NO_TOOLBAR
462  if (i == 0)
463  toolBarAreaLayout.remove(path.mid(1));
464 #endif
465 
466 #ifndef QT_NO_DOCKWIDGET
467  if (i == 1)
468  dockAreaLayout.remove(path.mid(1));
469 #endif //QT_NO_DOCKWIDGET
470 }
QDockAreaLayout dockAreaLayout
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
void remove(const QList< int > &path)
void remove(const QList< int > &path)
QToolBarAreaLayout toolBarAreaLayout

◆ remove() [2/2]

void QMainWindowLayoutState::remove ( QLayoutItem item)

Definition at line 472 of file qmainwindowlayout.cpp.

473 {
474 #ifndef QT_NO_TOOLBAR
476 #endif
477 
478 #ifndef QT_NO_DOCKWIDGET
479  // is it a dock widget?
480  if (QDockWidget *dockWidget = qobject_cast<QDockWidget *>(item->widget())) {
481  QList<int> path = dockAreaLayout.indexOf(dockWidget);
482  if (!path.isEmpty())
483  dockAreaLayout.remove(path);
484  }
485 #endif //QT_NO_DOCKWIDGET
486 }
The QDockWidget class provides a widget that can be docked inside a QMainWindow or floated as a top-l...
Definition: qdockwidget.h:60
QDockAreaLayout dockAreaLayout
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
QList< int > indexOf(QWidget *dockWidget) const
void remove(const QList< int > &path)
virtual QWidget * widget()
If this item is a QWidget, it is returned as a QWidget; otherwise 0 is returned.
void remove(const QList< int > &path)
QToolBarAreaLayout toolBarAreaLayout

◆ restoreState()

bool QMainWindowLayoutState::restoreState ( QDataStream stream,
const QMainWindowLayoutState oldState 
)

Definition at line 667 of file qmainwindowlayout.cpp.

Referenced by QMainWindowLayout::restoreState().

669 {
670  //make a copy of the data so that we can read it more than once
671  QByteArray copy;
672  while(!_stream.atEnd()) {
673  int length = 1024;
674  QByteArray ba(length, '\0');
675  length = _stream.readRawData(ba.data(), ba.size());
676  ba.resize(length);
677  copy += ba;
678  }
679 
680  QDataStream ds(copy);
681  const bool oldFormat = !checkFormat(ds, false);
682  if (oldFormat) {
683  //we should try with the old format
684  QDataStream ds2(copy);
685  if (!checkFormat(ds2, true)) {
686  return false; //format unknown
687  }
688  }
689 
690  QDataStream stream(copy);
691 
692  while (!stream.atEnd()) {
693  uchar marker;
694  stream >> marker;
695  switch(marker)
696  {
697 #ifndef QT_NO_DOCKWIDGET
699  {
700  QList<QDockWidget *> dockWidgets = findChildrenHelper<QDockWidget*>(mainWindow);
701  if (!dockAreaLayout.restoreState(stream, dockWidgets))
702  return false;
703 
704  for (int i = 0; i < dockWidgets.size(); ++i) {
705  QDockWidget *w = dockWidgets.at(i);
707  if (path.isEmpty()) {
708  QList<int> oldPath = oldState.dockAreaLayout.indexOf(w);
709  if (oldPath.isEmpty()) {
710  continue;
711  }
713  if (info == 0) {
714  continue;
715  }
717  }
718  }
719  }
720  break;
721 #endif // QT_NO_DOCKWIDGET
722 
723 #ifndef QT_NO_TOOLBAR
726  {
727  QList<QToolBar *> toolBars = findChildrenHelper<QToolBar*>(mainWindow);
728  if (!toolBarAreaLayout.restoreState(stream, toolBars, marker, oldFormat))
729  return false;
730 
731  for (int i = 0; i < toolBars.size(); ++i) {
732  QToolBar *w = toolBars.at(i);
734  if (path.isEmpty()) {
735  QList<int> oldPath = oldState.toolBarAreaLayout.indexOf(w);
736  if (oldPath.isEmpty()) {
737  continue;
738  }
739  toolBarAreaLayout.docks[oldPath.at(0)].insertToolBar(0, w);
740  }
741  }
742  }
743  break;
744 #endif //QT_NO_TOOLBAR
745  default:
746  return false;
747  }// switch
748  } //while
749 
750 
751  return true;
752 }
QList< QDockAreaLayoutItem > item_list
static mach_timebase_info_data_t info
The QDockWidget class provides a widget that can be docked inside a QMainWindow or floated as a top-l...
Definition: qdockwidget.h:60
bool checkFormat(QDataStream &stream, bool pre43)
bool atEnd() const
Returns true if the I/O device has reached the end position (end of the stream or file) or if there i...
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
QDockAreaLayout dockAreaLayout
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
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
static FILE * stream
QLayoutItem * insertToolBar(QToolBar *before, QToolBar *toolBar)
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
QDockAreaLayoutInfo * info(const QList< int > &path)
QList< int > indexOf(QWidget *toolBar) const
QList< int > indexOf(QWidget *dockWidget) const
bool restoreState(QDataStream &stream, const QList< QToolBar *> &toolBars, uchar tmarker, bool pre43, bool testing=false)
bool restoreState(QDataStream &stream, const QList< QDockWidget *> &widgets, bool testing=false)
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
The QDataStream class provides serialization of binary data to a QIODevice.
Definition: qdatastream.h:71
QToolBarAreaLayout toolBarAreaLayout
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ saveState()

void QMainWindowLayoutState::saveState ( QDataStream stream) const

Definition at line 598 of file qmainwindowlayout.cpp.

Referenced by QMainWindowLayout::saveState().

599 {
600 #ifndef QT_NO_DOCKWIDGET
601  dockAreaLayout.saveState(stream);
602 #endif
603 #ifndef QT_NO_TOOLBAR
605 #endif
606 }
void saveState(QDataStream &stream) const
QDockAreaLayout dockAreaLayout
void saveState(QDataStream &stream) const
QToolBarAreaLayout toolBarAreaLayout

◆ setCentralWidget()

void QMainWindowLayoutState::setCentralWidget ( QWidget widget)

Definition at line 374 of file qmainwindowlayout.cpp.

Referenced by QMainWindowLayout::setCentralWidget().

375 {
376  QLayoutItem *item = 0;
377  //make sure we remove the widget
379 
380  if (widget != 0)
381  item = new QWidgetItemV2(widget);
382 
383 #ifndef QT_NO_DOCKWIDGET
385 #else
386  centralWidgetItem = item;
387 #endif
388 }
QDockAreaLayout dockAreaLayout
QLayoutItem * centralWidgetItem
The QLayoutItem class provides an abstract item that a QLayout manipulates.
Definition: qlayoutitem.h:64
QLayoutItem * item(const QList< int > &path)

◆ sizeHint()

QSize QMainWindowLayoutState::sizeHint ( ) const

Definition at line 194 of file qmainwindowlayout.cpp.

195 {
196 
197  QSize result(0, 0);
198 
199 #ifndef QT_NO_DOCKWIDGET
200  result = dockAreaLayout.sizeHint();
201 #else
202  if (centralWidgetItem != 0)
203  result = centralWidgetItem->sizeHint();
204 #endif
205 
206 #ifndef QT_NO_TOOLBAR
207  result = toolBarAreaLayout.sizeHint(result);
208 #endif // QT_NO_TOOLBAR
209 
210  return result;
211 }
QSize sizeHint(const QSize &center) const
QDockAreaLayout dockAreaLayout
QSize sizeHint() const
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
QToolBarAreaLayout toolBarAreaLayout

◆ takeAt()

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

Definition at line 307 of file qmainwindowlayout.cpp.

308 {
309 #ifndef QT_NO_TOOLBAR
310  if (QLayoutItem *ret = toolBarAreaLayout.takeAt(x, index))
311  return ret;
312 #endif
313 
314 #ifndef QT_NO_DOCKWIDGET
315  if (QLayoutItem *ret = dockAreaLayout.takeAt(x, index))
316  return ret;
317 #else
318  if (centralWidgetItem != 0 && (*x)++ == index) {
319  QLayoutItem *ret = centralWidgetItem;
320  centralWidgetItem = 0;
321  return ret;
322  }
323 #endif
324 
325  return 0;
326 }
QDockAreaLayout dockAreaLayout
The QLayoutItem class provides an abstract item that a QLayout manipulates.
Definition: qlayoutitem.h:64
QLayoutItem * takeAt(int *x, int index)
QLayoutItem * takeAt(int *x, int index)
quint16 index
QToolBarAreaLayout toolBarAreaLayout

◆ unplug()

QLayoutItem * QMainWindowLayoutState::unplug ( const QList< int > &  path,
QMainWindowLayoutState savedState = 0 
)

Definition at line 579 of file qmainwindowlayout.cpp.

Referenced by QMainWindowLayout::unplug().

580 {
581  int i = path.first();
582 
583 #ifdef QT_NO_TOOLBAR
584  Q_UNUSED(other);
585 #else
586  if (i == 0)
587  return toolBarAreaLayout.unplug(path.mid(1), other ? &other->toolBarAreaLayout : 0);
588 #endif
589 
590 #ifndef QT_NO_DOCKWIDGET
591  if (i == 1)
592  return dockAreaLayout.unplug(path.mid(1));
593 #endif //QT_NO_DOCKWIDGET
594 
595  return 0;
596 }
QDockAreaLayout dockAreaLayout
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
QLayoutItem * unplug(const QList< int > &path)
QLayoutItem * unplug(const QList< int > &path, QToolBarAreaLayout *other)
QToolBarAreaLayout toolBarAreaLayout
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

Properties

◆ dockAreaLayout

QDockAreaLayout QMainWindowLayoutState::dockAreaLayout

◆ mainWindow

QMainWindow* QMainWindowLayoutState::mainWindow

◆ rect

QRect QMainWindowLayoutState::rect

Definition at line 108 of file qmainwindowlayout_p.h.

Referenced by clear(), fitLayout(), isValid(), and QMainWindowLayout::restoreState().

◆ toolBarAreaLayout

QToolBarAreaLayout QMainWindowLayoutState::toolBarAreaLayout

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