Qt 4.8
qmdiarea.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
171 #include "qmdiarea_p.h"
172 
173 #ifndef QT_NO_MDIAREA
174 
175 #include <QApplication>
176 #include <QStyle>
177 #if defined(Q_WS_MAC) && !defined(QT_NO_STYLE_MAC)
178 #include <QMacStyle>
179 #endif
180 #include <QChildEvent>
181 #include <QResizeEvent>
182 #include <QScrollBar>
183 #include <QtAlgorithms>
184 #include <QMutableListIterator>
185 #include <QPainter>
186 #include <QFontMetrics>
187 #include <QStyleOption>
188 #include <QDesktopWidget>
189 #include <QDebug>
190 #include <qmath.h>
191 #include <private/qlayoutengine_p.h>
192 
194 
195 using namespace QMdi;
196 
197 // Asserts in debug mode, gives warning otherwise.
198 static bool sanityCheck(const QMdiSubWindow * const child, const char *where)
199 {
200  if (!child) {
201  const char error[] = "null pointer";
202  Q_ASSERT_X(false, where, error);
203  qWarning("%s:%s", where, error);
204  return false;
205  }
206  return true;
207 }
208 
209 static bool sanityCheck(const QList<QWidget *> &widgets, const int index, const char *where)
210 {
211  if (index < 0 || index >= widgets.size()) {
212  const char error[] = "index out of range";
213  Q_ASSERT_X(false, where, error);
214  qWarning("%s:%s", where, error);
215  return false;
216  }
217  if (!widgets.at(index)) {
218  const char error[] = "null pointer";
219  Q_ASSERT_X(false, where, error);
220  qWarning("%s:%s", where, error);
221  return false;
222  }
223  return true;
224 }
225 
226 static void setIndex(int *index, int candidate, int min, int max, bool isIncreasing)
227 {
228  if (!index)
229  return;
230 
231  if (isIncreasing) {
232  if (candidate > max)
233  *index = min;
234  else
235  *index = qMax(candidate, min);
236  } else {
237  if (candidate < min)
238  *index = max;
239  else
240  *index = qMin(candidate, max);
241  }
242  Q_ASSERT(*index >= min && *index <= max);
243 }
244 
245 static inline bool useScrollBar(const QRect &childrenRect, const QSize &maxViewportSize,
246  Qt::Orientation orientation)
247 {
248  if (orientation == Qt::Horizontal)
249  return childrenRect.width() > maxViewportSize.width()
250  || childrenRect.left() < 0
251  || childrenRect.right() >= maxViewportSize.width();
252  else
253  return childrenRect.height() > maxViewportSize.height()
254  || childrenRect.top() < 0
255  || childrenRect.bottom() >= maxViewportSize.height();
256 }
257 
258 // Returns the closest mdi area containing the widget (if any).
260 {
261  if (!widget)
262  return 0;
263 
264  QWidget *parent = widget->parentWidget();
265  while (parent) {
266  if (QMdiArea *area = qobject_cast<QMdiArea *>(parent))
267  return area;
268  parent = parent->parentWidget();
269  }
270  return 0;
271 }
272 
273 #ifndef QT_NO_TABWIDGET
275 {
276  const bool rounded = (shape == QTabWidget::Rounded);
277  if (position == QTabWidget::North)
279  if (position == QTabWidget::South)
281  if (position == QTabWidget::East)
283  if (position == QTabWidget::West)
285  return QTabBar::RoundedNorth;
286 }
287 #endif // QT_NO_TABWIDGET
288 
289 static inline QString tabTextFor(QMdiSubWindow *subWindow)
290 {
291  if (!subWindow)
292  return QString();
293 
294  QString title = subWindow->windowTitle();
295  if (subWindow->isWindowModified()) {
296  title.replace(QLatin1String("[*]"), QLatin1String("*"));
297  } else {
298  extern QString qt_setWindowTitle_helperHelper(const QString&, const QWidget*);
299  title = qt_setWindowTitle_helperHelper(title, subWindow);
300  }
301 
302  return title.isEmpty() ? QMdiArea::tr("(Untitled)") : title;
303 }
304 
308 void RegularTiler::rearrange(QList<QWidget *> &widgets, const QRect &domain) const
309 {
310  if (widgets.isEmpty())
311  return;
312 
313  const int n = widgets.size();
314  const int ncols = qMax(qCeil(qSqrt(qreal(n))), 1);
315  const int nrows = qMax((n % ncols) ? (n / ncols + 1) : (n / ncols), 1);
316  const int nspecial = (n % ncols) ? (ncols - n % ncols) : 0;
317  const int dx = domain.width() / ncols;
318  const int dy = domain.height() / nrows;
319 
320  int i = 0;
321  for (int row = 0; row < nrows; ++row) {
322  const int y1 = int(row * (dy + 1));
323  for (int col = 0; col < ncols; ++col) {
324  if (row == 1 && col < nspecial)
325  continue;
326  const int x1 = int(col * (dx + 1));
327  int x2 = int(x1 + dx);
328  int y2 = int(y1 + dy);
329  if (row == 0 && col < nspecial) {
330  y2 *= 2;
331  if (nrows != 2)
332  y2 += 1;
333  else
334  y2 = domain.bottom();
335  }
336  if (col == ncols - 1 && x2 != domain.right())
337  x2 = domain.right();
338  if (row == nrows - 1 && y2 != domain.bottom())
339  y2 = domain.bottom();
340  if (!sanityCheck(widgets, i, "RegularTiler"))
341  continue;
342  QWidget *widget = widgets.at(i++);
343  QRect newGeometry = QRect(QPoint(x1, y1), QPoint(x2, y2));
344  widget->setGeometry(QStyle::visualRect(widget->layoutDirection(), domain, newGeometry));
345  }
346  }
347 }
348 
352 void SimpleCascader::rearrange(QList<QWidget *> &widgets, const QRect &domain) const
353 {
354  if (widgets.isEmpty())
355  return;
356 
357  // Tunables:
358  const int topOffset = 0;
359  const int bottomOffset = 50;
360  const int leftOffset = 0;
361  const int rightOffset = 100;
362  const int dx = 10;
363 
364  QStyleOptionTitleBar options;
365  options.initFrom(widgets.at(0));
366  int titleBarHeight = widgets.at(0)->style()->pixelMetric(QStyle::PM_TitleBarHeight, &options, widgets.at(0));
367 #if defined(Q_WS_MAC) && !defined(QT_NO_STYLE_MAC)
368  // ### Remove this after the mac style has been fixed
369  if (qobject_cast<QMacStyle *>(widgets.at(0)->style()))
370  titleBarHeight -= 4;
371 #endif
372  const QFontMetrics fontMetrics = QFontMetrics(QApplication::font("QWorkspaceTitleBar"));
373  const int dy = qMax(titleBarHeight - (titleBarHeight - fontMetrics.height()) / 2, 1);
374 
375  const int n = widgets.size();
376  const int nrows = qMax((domain.height() - (topOffset + bottomOffset)) / dy, 1);
377  const int ncols = qMax(n / nrows + ((n % nrows) ? 1 : 0), 1);
378  const int dcol = (domain.width() - (leftOffset + rightOffset)) / ncols;
379 
380  int i = 0;
381  for (int row = 0; row < nrows; ++row) {
382  for (int col = 0; col < ncols; ++col) {
383  const int x = leftOffset + row * dx + col * dcol;
384  const int y = topOffset + row * dy;
385  if (!sanityCheck(widgets, i, "SimpleCascader"))
386  continue;
387  QWidget *widget = widgets.at(i++);
388  QRect newGeometry = QRect(QPoint(x, y), widget->sizeHint());
389  widget->setGeometry(QStyle::visualRect(widget->layoutDirection(), domain, newGeometry));
390  if (i == n)
391  return;
392  }
393  }
394 }
395 
399 void IconTiler::rearrange(QList<QWidget *> &widgets, const QRect &domain) const
400 {
401  if (widgets.isEmpty() || !sanityCheck(widgets, 0, "IconTiler"))
402  return;
403 
404  const int n = widgets.size();
405  const int width = widgets.at(0)->width();
406  const int height = widgets.at(0)->height();
407  const int ncols = qMax(domain.width() / width, 1);
408  const int nrows = n / ncols + ((n % ncols) ? 1 : 0);
409 
410  int i = 0;
411  for (int row = 0; row < nrows; ++row) {
412  for (int col = 0; col < ncols; ++col) {
413  const int x = col * width;
414  const int y = domain.height() - height - row * height;
415  if (!sanityCheck(widgets, i, "IconTiler"))
416  continue;
417  QWidget *widget = widgets.at(i++);
418  QPoint newPos(x, y);
419  QRect newGeometry = QRect(newPos.x(), newPos.y(), widget->width(), widget->height());
420  widget->setGeometry(QStyle::visualRect(widget->layoutDirection(), domain, newGeometry));
421  if (i == n)
422  return;
423  }
424  }
425 }
426 
435 {
436  int accOverlap = 0;
437  foreach (const QRect &rect, rects) {
438  QRect intersection = source.intersected(rect);
439  accOverlap += intersection.width() * intersection.height();
440  }
441  return accOverlap;
442 }
443 
444 
454 {
455  int minAccOverlap = -1;
456  QRect minAccOverlapRect;
457  foreach (const QRect &srcRect, source) {
458  const int accOverlap = accumulatedOverlap(srcRect, rects);
459  if (accOverlap < minAccOverlap || minAccOverlap == -1) {
460  minAccOverlap = accOverlap;
461  minAccOverlapRect = srcRect;
462  }
463  }
464  return minAccOverlapRect;
465 }
466 
475  const QRect &domain,QList<QRect> &candidates)
476 {
477  QSet<int> xset;
478  QSet<int> yset;
479  xset << domain.left() << domain.right() - size.width() + 1;
480  yset << domain.top();
481  if (domain.bottom() - size.height() + 1 >= 0)
482  yset << domain.bottom() - size.height() + 1;
483  foreach (const QRect &rect, rects) {
484  xset << rect.right() + 1;
485  yset << rect.bottom() + 1;
486  }
487 
488  QList<int> xlist = xset.values();
489  qSort(xlist.begin(), xlist.end());
490  QList<int> ylist = yset.values();
491  qSort(ylist.begin(), ylist.end());
492 
493  foreach (int y, ylist)
494  foreach (int x, xlist)
495  candidates << QRect(QPoint(x, y), size);
496 }
497 
507  QList<QRect> &result)
508 {
509  QMutableListIterator<QRect> it(source);
510  while (it.hasNext()) {
511  const QRect srcRect = it.next();
512  if (!domain.contains(srcRect)) {
513  result << srcRect;
514  it.remove();
515  }
516  }
517 }
518 
527 void MinOverlapPlacer::findMaxOverlappers(const QRect &domain, const QList<QRect> &source,
528  QList<QRect> &result)
529 {
530  int maxOverlap = -1;
531  foreach (const QRect &srcRect, source) {
532  QRect intersection = domain.intersected(srcRect);
533  const int overlap = intersection.width() * intersection.height();
534  if (overlap >= maxOverlap || maxOverlap == -1) {
535  if (overlap > maxOverlap) {
536  maxOverlap = overlap;
537  result.clear();
538  }
539  result << srcRect;
540  }
541  }
542 }
543 
554  QList<QRect> &source)
555 {
556  QList<QRect> nonInsiders;
557  findNonInsiders(domain, source, nonInsiders);
558 
559  if (!source.empty())
560  return findMinOverlapRect(source, rects).topLeft();
561 
562  QList<QRect> maxOverlappers;
563  findMaxOverlappers(domain, nonInsiders, maxOverlappers);
564  return findMinOverlapRect(maxOverlappers, rects).topLeft();
565 }
566 
567 
578  const QRect &domain) const
579 {
580  if (size.isEmpty() || !domain.isValid())
581  return QPoint();
582  foreach (const QRect &rect, rects) {
583  if (!rect.isValid())
584  return QPoint();
585  }
586 
587  QList<QRect> candidates;
588  getCandidatePlacements(size, rects, domain, candidates);
589  return findBestPlacement(domain, rects, candidates);
590 }
591 
592 #ifndef QT_NO_TABBAR
593 class QMdiAreaTabBar : public QTabBar
594 {
595 public:
596  QMdiAreaTabBar(QWidget *parent) : QTabBar(parent) {}
597 
598 protected:
599  void mousePressEvent(QMouseEvent *event);
600 #ifndef QT_NO_CONTEXTMENU
601  void contextMenuEvent(QContextMenuEvent *event);
602 #endif
603 
604 private:
605  QMdiSubWindow *subWindowFromIndex(int index) const;
606 };
607 
612 {
613  if (event->button() != Qt::MidButton) {
615  return;
616  }
617 
618  QMdiSubWindow *subWindow = subWindowFromIndex(tabAt(event->pos()));
619  if (!subWindow) {
620  event->ignore();
621  return;
622  }
623 
624  subWindow->close();
625 }
626 
627 #ifndef QT_NO_CONTEXTMENU
628 
632 {
633  QPointer<QMdiSubWindow> subWindow = subWindowFromIndex(tabAt(event->pos()));
634  if (!subWindow || subWindow->isHidden()) {
635  event->ignore();
636  return;
637  }
638 
639 #ifndef QT_NO_MENU
640  QMdiSubWindowPrivate *subWindowPrivate = subWindow->d_func();
641  if (!subWindowPrivate->systemMenu) {
642  event->ignore();
643  return;
644  }
645 
646  QMdiSubWindow *currentSubWindow = subWindowFromIndex(currentIndex());
647  Q_ASSERT(currentSubWindow);
648 
649  // We don't want these actions to show up in the system menu when the
650  // current sub-window is maximized, i.e. covers the entire viewport.
651  if (currentSubWindow->isMaximized()) {
652  subWindowPrivate->setVisible(QMdiSubWindowPrivate::MoveAction, false);
653  subWindowPrivate->setVisible(QMdiSubWindowPrivate::ResizeAction, false);
654  subWindowPrivate->setVisible(QMdiSubWindowPrivate::MinimizeAction, false);
655  subWindowPrivate->setVisible(QMdiSubWindowPrivate::MaximizeAction, false);
656  subWindowPrivate->setVisible(QMdiSubWindowPrivate::RestoreAction, false);
657  subWindowPrivate->setVisible(QMdiSubWindowPrivate::StayOnTopAction, false);
658  }
659 
660  // Show system menu.
661  subWindowPrivate->systemMenu->exec(event->globalPos());
662  if (!subWindow)
663  return;
664 
665  // Restore action visibility.
666  subWindowPrivate->updateActions();
667 #endif // QT_NO_MENU
668 }
669 #endif // QT_NO_CONTEXTMENU
670 
675 {
676  if (index < 0 || index >= count())
677  return 0;
678 
679  QMdiArea *mdiArea = qobject_cast<QMdiArea *>(parentWidget());
680  Q_ASSERT(mdiArea);
681 
682  const QList<QMdiSubWindow *> subWindows = mdiArea->subWindowList();
683  Q_ASSERT(index < subWindows.size());
684 
685  QMdiSubWindow *subWindow = mdiArea->subWindowList().at(index);
686  Q_ASSERT(subWindow);
687 
688  return subWindow;
689 }
690 #endif // QT_NO_TABBAR
691 
696  : cascader(0),
697  regularTiler(0),
698  iconTiler(0),
699  placer(0),
700 #ifndef QT_NO_RUBBERBAND
701  rubberBand(0),
702 #endif
703 #ifndef QT_NO_TABBAR
704  tabBar(0),
705 #endif
706  activationOrder(QMdiArea::CreationOrder),
707  viewMode(QMdiArea::SubWindowView),
708 #ifndef QT_NO_TABBAR
709  documentMode(false),
710  tabsClosable(false),
711  tabsMovable(false),
712 #endif
713 #ifndef QT_NO_TABWIDGET
714  tabShape(QTabWidget::Rounded),
715  tabPosition(QTabWidget::North),
716 #endif
717  ignoreGeometryChange(false),
718  ignoreWindowStateChange(false),
719  isActivated(false),
720  isSubWindowsTiled(false),
721  showActiveWindowMaximized(false),
722  tileCalledFromResizeEvent(false),
723  updatesDisabledByUs(false),
724  inViewModeChange(false),
725  indexToNextWindow(-1),
726  indexToPreviousWindow(-1),
727  indexToHighlighted(-1),
728  indexToLastActiveTab(-1),
729  resizeTimerId(-1),
730  tabToPreviousTimerId(-1)
731 {
732 }
733 
738 {
740  return;
741 
742  Q_Q(QMdiArea);
743  if (!aboutToActivate)
745  else
746  aboutToBecomeActive = aboutToActivate;
747  Q_ASSERT(aboutToBecomeActive);
748 
749  foreach (QMdiSubWindow *child, childWindows) {
750  if (!sanityCheck(child, "QMdiArea::deactivateAllWindows") || aboutToBecomeActive == child)
751  continue;
752  // We don't want to handle signals caused by child->showNormal().
755  showActiveWindowMaximized = child->isMaximized() && child->isVisible();
756  if (showActiveWindowMaximized && child->isMaximized()) {
757  if (q->updatesEnabled()) {
758  updatesDisabledByUs = true;
759  q->setUpdatesEnabled(false);
760  }
761  child->showNormal();
762  }
763  if (child->isMinimized() && !child->isShaded() && !windowStaysOnTop(child))
764  child->lower();
765  ignoreWindowStateChange = false;
766  child->d_func()->setActive(false);
767  }
768 }
769 
773 void QMdiAreaPrivate::_q_processWindowStateChanged(Qt::WindowStates oldState,
774  Qt::WindowStates newState)
775 {
777  return;
778 
779  Q_Q(QMdiArea);
780  QMdiSubWindow *child = qobject_cast<QMdiSubWindow *>(q->sender());
781  if (!child)
782  return;
783 
784  // windowActivated
785  if (!(oldState & Qt::WindowActive) && (newState & Qt::WindowActive))
786  emitWindowActivated(child);
787  // windowDeactivated
788  else if ((oldState & Qt::WindowActive) && !(newState & Qt::WindowActive))
789  resetActiveWindow(child);
790 
791  // windowMinimized
792  if (!(oldState & Qt::WindowMinimized) && (newState & Qt::WindowMinimized)) {
793  isSubWindowsTiled = false;
795  // windowMaximized
796  } else if (!(oldState & Qt::WindowMaximized) && (newState & Qt::WindowMaximized)) {
797  internalRaise(child);
798  // windowRestored
799  } else if (!(newState & (Qt::WindowMaximized | Qt::WindowMinimized))) {
800  internalRaise(child);
801  if (oldState & Qt::WindowMinimized)
803  }
804 }
805 
807 {
808 #ifdef QT_NO_TABBAR
809  Q_UNUSED(index);
810 #else
811  if (!tabBar || index < 0)
812  return;
813 
814  // If the previous active sub-window was hidden, disable the tab.
815  if (indexToLastActiveTab >= 0 && indexToLastActiveTab < tabBar->count()
818  if (lastActive && lastActive->isHidden())
820  }
821 
824  QMdiSubWindow *subWindow = childWindows.at(index);
825  Q_ASSERT(subWindow);
826  activateWindow(subWindow);
827 #endif // QT_NO_TABBAR
828 }
829 
831 {
832 #ifdef QT_NO_TABBAR
833  Q_UNUSED(index);
834 #else
835  QMdiSubWindow *subWindow = childWindows.at(index);
836  Q_ASSERT(subWindow);
837  subWindow->close();
838 #endif // QT_NO_TABBAR
839 }
840 
841 void QMdiAreaPrivate::_q_moveTab(int from, int to)
842 {
843 #ifdef QT_NO_TABBAR
844  Q_UNUSED(from);
845  Q_UNUSED(to);
846 #else
847  childWindows.move(from, to);
848 #endif // QT_NO_TABBAR
849 }
850 
855 {
856  Q_Q(QMdiArea);
857  Q_ASSERT(child && childWindows.indexOf(child) == -1);
858 
859  if (child->parent() != viewport)
860  child->setParent(viewport, child->windowFlags());
862 
863  if (!child->testAttribute(Qt::WA_Resized) && q->isVisible()) {
864  QSize newSize(child->sizeHint().boundedTo(viewport->size()));
865  child->resize(newSize.expandedTo(qSmartMinSize(child)));
866  }
867 
868  if (!placer)
869  placer = new MinOverlapPlacer;
870  place(placer, child);
871 
874  else
876 
879  else
881 
882  internalRaise(child);
885 
886 #ifndef QT_NO_TABBAR
887  if (tabBar) {
888  tabBar->addTab(child->windowIcon(), tabTextFor(child));
892  }
893 #endif
894 
895  if (!(child->windowFlags() & Qt::SubWindow))
897  child->installEventFilter(q);
898 
899  QObject::connect(child, SIGNAL(aboutToActivate()), q, SLOT(_q_deactivateAllWindows()));
900  QObject::connect(child, SIGNAL(windowStateChanged(Qt::WindowStates,Qt::WindowStates)),
901  q, SLOT(_q_processWindowStateChanged(Qt::WindowStates,Qt::WindowStates)));
902 }
903 
908 {
909  if (!placer || !child)
910  return;
911 
912  Q_Q(QMdiArea);
913  if (!q->isVisible()) {
914  // The window is only laid out when it's added to QMdiArea,
915  // so there's no need to check that we don't have it in the
916  // list already. appendChild() ensures that.
917  pendingPlacements.append(child);
918  return;
919  }
920 
921  QList<QRect> rects;
922  QRect parentRect = q->rect();
923  foreach (QMdiSubWindow *window, childWindows) {
924  if (!sanityCheck(window, "QMdiArea::place") || window == child || !window->isVisibleTo(q)
925  || !window->testAttribute(Qt::WA_Moved)) {
926  continue;
927  }
928  QRect occupiedGeometry;
929  if (window->isMaximized()) {
930  occupiedGeometry = QRect(window->d_func()->oldGeometry.topLeft(),
931  window->d_func()->restoreSize);
932  } else {
933  occupiedGeometry = window->geometry();
934  }
935  rects.append(QStyle::visualRect(child->layoutDirection(), parentRect, occupiedGeometry));
936  }
937  QPoint newPos = placer->place(child->size(), rects, parentRect);
938  QRect newGeometry = QRect(newPos.x(), newPos.y(), child->width(), child->height());
939  child->setGeometry(QStyle::visualRect(child->layoutDirection(), parentRect, newGeometry));
940 }
941 
946 {
947  if (!rearranger)
948  return;
949 
950  Q_Q(QMdiArea);
951  if (!q->isVisible()) {
952  // Compress if we already have the rearranger in the list.
953  int index = pendingRearrangements.indexOf(rearranger);
954  if (index != -1)
956  else
957  pendingRearrangements.append(rearranger);
958  return;
959  }
960 
961  QList<QWidget *> widgets;
962  const bool reverseList = rearranger->type() == Rearranger::RegularTiler;
963  const QList<QMdiSubWindow *> subWindows = subWindowList(activationOrder, reverseList);
964  QSize minSubWindowSize;
965  foreach (QMdiSubWindow *child, subWindows) {
966  if (!sanityCheck(child, "QMdiArea::rearrange") || !child->isVisible())
967  continue;
968  if (rearranger->type() == Rearranger::IconTiler) {
969  if (child->isMinimized() && !child->isShaded() && !(child->windowFlags() & Qt::FramelessWindowHint))
970  widgets.append(child);
971  } else {
972  if (child->isMinimized() && !child->isShaded())
973  continue;
974  if (child->isMaximized() || child->isShaded())
975  child->showNormal();
976  minSubWindowSize = minSubWindowSize.expandedTo(child->minimumSize())
977  .expandedTo(child->d_func()->internalMinimumSize);
978  widgets.append(child);
979  }
980  }
981 
982  if (active && rearranger->type() == Rearranger::RegularTiler) {
983  // Move active window in front if necessary. That's the case if we
984  // have any windows with staysOnTopHint set.
985  int indexToActive = widgets.indexOf((QWidget *)active);
986  if (indexToActive > 0)
987  widgets.move(indexToActive, 0);
988  }
989 
990  QRect domain = viewport->rect();
991  if (rearranger->type() == Rearranger::RegularTiler && !widgets.isEmpty())
992  domain = resizeToMinimumTileSize(minSubWindowSize, widgets.count());
993 
994  rearranger->rearrange(widgets, domain);
995 
996  if (rearranger->type() == Rearranger::RegularTiler && !widgets.isEmpty()) {
997  isSubWindowsTiled = true;
999  } else if (rearranger->type() == Rearranger::SimpleCascader) {
1000  isSubWindowsTiled = false;
1001  }
1002 }
1003 
1013 {
1014  if (!iconTiler)
1015  iconTiler = new IconTiler;
1017 }
1018 
1023 {
1024  if (childWindows.isEmpty()) {
1025  Q_ASSERT(!child);
1026  Q_ASSERT(!active);
1027  return;
1028  }
1029 
1030  if (!child) {
1031  if (active) {
1032  Q_ASSERT(active->d_func()->isActive);
1033  active->d_func()->setActive(false);
1035  }
1036  return;
1037  }
1038 
1039  if (child->isHidden() || child == active)
1040  return;
1041  child->d_func()->setActive(true);
1042 }
1043 
1048 {
1049  QMdiSubWindow *current = q_func()->currentSubWindow();
1050  if (current && !isExplicitlyDeactivated(current)) {
1051  current->d_func()->activationEnabled = true;
1052  current->d_func()->setActive(true, /*changeFocus=*/false);
1053  }
1054 }
1055 
1057 {
1058  if (indexToHighlighted < 0)
1059  return;
1060 
1062  if (tabToPreviousTimerId != -1)
1064  else
1066 #ifndef QT_NO_RUBBERBAND
1067  hideRubberBand();
1068 #endif
1069 }
1070 
1075 {
1076  Q_Q(QMdiArea);
1077  Q_ASSERT(activeWindow);
1078  if (activeWindow == active)
1079  return;
1080  Q_ASSERT(activeWindow->d_func()->isActive);
1081 
1082  if (!aboutToBecomeActive)
1083  _q_deactivateAllWindows(activeWindow);
1085 
1086  // This is true only if 'DontMaximizeSubWindowOnActivation' is disabled
1087  // and the previous active window was maximized.
1089  if (!activeWindow->isMaximized())
1090  activeWindow->showMaximized();
1091  showActiveWindowMaximized = false;
1092  }
1093 
1094  // Put in front to update activation order.
1095  const int indexToActiveWindow = childWindows.indexOf(activeWindow);
1096  Q_ASSERT(indexToActiveWindow != -1);
1097  const int index = indicesToActivatedChildren.indexOf(indexToActiveWindow);
1098  Q_ASSERT(index != -1);
1099  indicesToActivatedChildren.move(index, 0);
1100  internalRaise(activeWindow);
1101 
1102  if (updatesDisabledByUs) {
1103  q->setUpdatesEnabled(true);
1104  updatesDisabledByUs = false;
1105  }
1106 
1107  Q_ASSERT(aboutToBecomeActive == activeWindow);
1108  active = activeWindow;
1109  aboutToBecomeActive = 0;
1110  Q_ASSERT(active->d_func()->isActive);
1111 
1112 #ifndef QT_NO_TABBAR
1113  if (tabBar && tabBar->currentIndex() != indexToActiveWindow)
1114  tabBar->setCurrentIndex(indexToActiveWindow);
1115 #endif
1116 
1117  if (active->isMaximized() && scrollBarsEnabled())
1118  updateScrollBars();
1119 
1120  emit q->subWindowActivated(active);
1121 }
1122 
1127 {
1128  Q_Q(QMdiArea);
1129  if (deactivatedWindow) {
1130  if (deactivatedWindow != active)
1131  return;
1132  active = 0;
1134  && !isExplicitlyDeactivated(deactivatedWindow) && !q->window()->isMinimized()) {
1135  return;
1136  }
1137  emit q->subWindowActivated(0);
1138  return;
1139  }
1140 
1141  if (aboutToBecomeActive)
1142  return;
1143 
1144  active = 0;
1145  emit q->subWindowActivated(0);
1146 }
1147 
1151 void QMdiAreaPrivate::updateActiveWindow(int removedIndex, bool activeRemoved)
1152 {
1154 
1155 #ifndef QT_NO_TABBAR
1156  if (tabBar && removedIndex >= 0) {
1157  tabBar->blockSignals(true);
1158  tabBar->removeTab(removedIndex);
1160  tabBar->blockSignals(false);
1161  }
1162 #endif
1163 
1164  if (childWindows.isEmpty()) {
1165  showActiveWindowMaximized = false;
1167  return;
1168  }
1169 
1170  if (indexToHighlighted >= 0) {
1171 #ifndef QT_NO_RUBBERBAND
1172  // Hide rubber band if highlighted window is removed.
1173  if (indexToHighlighted == removedIndex)
1174  hideRubberBand();
1175  else
1176 #endif
1177  // or update index if necessary.
1178  if (indexToHighlighted > removedIndex)
1180  }
1181 
1182  // Update indices list
1183  for (int i = 0; i < indicesToActivatedChildren.size(); ++i) {
1184  int *index = &indicesToActivatedChildren[i];
1185  if (*index > removedIndex)
1186  --*index;
1187  }
1188 
1189  if (!activeRemoved)
1190  return;
1191 
1192  // Activate next window.
1193  QMdiSubWindow *next = nextVisibleSubWindow(0, activationOrder, removedIndex);
1194  if (next)
1195  activateWindow(next);
1196 }
1197 
1202 {
1204  return;
1205 
1206  Q_Q(QMdiArea);
1207  QSize maxSize = q->maximumViewportSize();
1208  QSize hbarExtent = hbar->sizeHint();
1209  QSize vbarExtent = vbar->sizeHint();
1210 
1211  if (q->style()->styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents, 0, q)) {
1212  const int doubleFrameWidth = frameWidth * 2;
1214  maxSize.rheight() -= doubleFrameWidth;
1216  maxSize.rwidth() -= doubleFrameWidth;
1217  hbarExtent.rheight() += doubleFrameWidth;
1218  vbarExtent.rwidth() += doubleFrameWidth;
1219  }
1220 
1221  const QRect childrenRect = active && active->isMaximized()
1223  bool useHorizontalScrollBar = useScrollBar(childrenRect, maxSize, Qt::Horizontal);
1224  bool useVerticalScrollBar = useScrollBar(childrenRect, maxSize, Qt::Vertical);
1225 
1226  if (useHorizontalScrollBar && !useVerticalScrollBar) {
1227  const QSize max = maxSize - QSize(0, hbarExtent.height());
1228  useVerticalScrollBar = useScrollBar(childrenRect, max, Qt::Vertical);
1229  }
1230 
1231  if (useVerticalScrollBar && !useHorizontalScrollBar) {
1232  const QSize max = maxSize - QSize(vbarExtent.width(), 0);
1233  useHorizontalScrollBar = useScrollBar(childrenRect, max, Qt::Horizontal);
1234  }
1235 
1236  if (useHorizontalScrollBar && hbarpolicy != Qt::ScrollBarAlwaysOn)
1237  maxSize.rheight() -= hbarExtent.height();
1238  if (useVerticalScrollBar && vbarpolicy != Qt::ScrollBarAlwaysOn)
1239  maxSize.rwidth() -= vbarExtent.width();
1240 
1241  QRect viewportRect(QPoint(0, 0), maxSize);
1242  const int startX = q->isLeftToRight() ? childrenRect.left() : viewportRect.right()
1243  - childrenRect.right();
1244 
1245  // Horizontal scroll bar.
1246  if (isSubWindowsTiled && hbar->value() != 0)
1247  hbar->setValue(0);
1248  const int xOffset = startX + hbar->value();
1249  hbar->setRange(qMin(0, xOffset),
1250  qMax(0, xOffset + childrenRect.width() - viewportRect.width()));
1251  hbar->setPageStep(childrenRect.width());
1252  hbar->setSingleStep(childrenRect.width() / 20);
1253 
1254  // Vertical scroll bar.
1255  if (isSubWindowsTiled && vbar->value() != 0)
1256  vbar->setValue(0);
1257  const int yOffset = childrenRect.top() + vbar->value();
1258  vbar->setRange(qMin(0, yOffset),
1259  qMax(0, yOffset + childrenRect.height() - viewportRect.height()));
1260  vbar->setPageStep(childrenRect.height());
1261  vbar->setSingleStep(childrenRect.height() / 20);
1262 }
1263 
1268 {
1269  if (!sanityCheck(mdiChild, "QMdiArea::internalRaise") || childWindows.size() < 2)
1270  return;
1271 
1272  QMdiSubWindow *stackUnderChild = 0;
1273  if (!windowStaysOnTop(mdiChild)) {
1274  foreach (QObject *object, viewport->children()) {
1275  QMdiSubWindow *child = qobject_cast<QMdiSubWindow *>(object);
1276  if (!child || !childWindows.contains(child))
1277  continue;
1278  if (!child->isHidden() && windowStaysOnTop(child)) {
1279  if (stackUnderChild)
1280  child->stackUnder(stackUnderChild);
1281  else
1282  child->raise();
1283  stackUnderChild = child;
1284  }
1285  }
1286  }
1287 
1288  if (stackUnderChild)
1289  mdiChild->stackUnder(stackUnderChild);
1290  else
1291  mdiChild->raise();
1292 }
1293 
1294 QRect QMdiAreaPrivate::resizeToMinimumTileSize(const QSize &minSubWindowSize, int subWindowCount)
1295 {
1296  Q_Q(QMdiArea);
1297  if (!minSubWindowSize.isValid() || subWindowCount <= 0)
1298  return viewport->rect();
1299 
1300  // Calculate minimum size.
1301  const int columns = qMax(qCeil(qSqrt(qreal(subWindowCount))), 1);
1302  const int rows = qMax((subWindowCount % columns) ? (subWindowCount / columns + 1)
1303  : (subWindowCount / columns), 1);
1304  const int minWidth = minSubWindowSize.width() * columns;
1305  const int minHeight = minSubWindowSize.height() * rows;
1306 
1307  // Increase area size if necessary. Scroll bars are provided if we're not able
1308  // to resize to the minimum size.
1310  QWidget *topLevel = q;
1311  // Find the topLevel for this area, either a real top-level or a sub-window.
1312  while (topLevel && !topLevel->isWindow() && topLevel->windowType() != Qt::SubWindow)
1313  topLevel = topLevel->parentWidget();
1314  // We don't want sub-subwindows to be placed at the edge, thus add 2 pixels.
1315  int minAreaWidth = minWidth + left + right + 2;
1316  int minAreaHeight = minHeight + top + bottom + 2;
1317  if (hbar->isVisible())
1318  minAreaHeight += hbar->height();
1319  if (vbar->isVisible())
1320  minAreaWidth += vbar->width();
1321  if (q->style()->styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents, 0, q)) {
1322  const int frame = q->style()->pixelMetric(QStyle::PM_DefaultFrameWidth, 0, q);
1323  minAreaWidth += 2 * frame;
1324  minAreaHeight += 2 * frame;
1325  }
1326  const QSize diff = QSize(minAreaWidth, minAreaHeight).expandedTo(q->size()) - q->size();
1327  topLevel->resize(topLevel->size() + diff);
1328  }
1329 
1330  QRect domain = viewport->rect();
1331 
1332  // Adjust domain width and provide horizontal scroll bar.
1333  if (domain.width() < minWidth) {
1334  domain.setWidth(minWidth);
1336  q->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
1337  else
1338  hbar->setValue(0);
1339  }
1340  // Adjust domain height and provide vertical scroll bar.
1341  if (domain.height() < minHeight) {
1342  domain.setHeight(minHeight);
1344  q->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
1345  else
1346  vbar->setValue(0);
1347  }
1348  return domain;
1349 }
1350 
1355 {
1357 }
1358 
1363 {
1364  if (childWindows.count() != 1)
1365  return false;
1366 
1367  QMdiSubWindow *last = childWindows.at(0);
1368  if (!last)
1369  return true;
1370 
1371  if (!last->testAttribute(Qt::WA_DeleteOnClose))
1372  return false;
1373 
1374  return last->d_func()->data.is_closing;
1375 }
1376 
1380 void QMdiAreaPrivate::setChildActivationEnabled(bool enable, bool onlyNextActivationEvent) const
1381 {
1382  foreach (QMdiSubWindow *subWindow, childWindows) {
1383  if (!subWindow || !subWindow->isVisible())
1384  continue;
1385  if (onlyNextActivationEvent)
1386  subWindow->d_func()->ignoreNextActivationEvent = !enable;
1387  else
1388  subWindow->d_func()->activationEnabled = enable;
1389  }
1390 }
1391 
1397 {
1398  if (childWindows.isEmpty())
1399  return;
1400 
1401  const QMdiSubWindow::SubWindowOption option = orientation == Qt::Horizontal ?
1403  const bool enable = policy != Qt::ScrollBarAlwaysOff;
1404  foreach (QMdiSubWindow *child, childWindows) {
1405  if (!sanityCheck(child, "QMdiArea::scrollBarPolicyChanged"))
1406  continue;
1407  child->setOption(option, enable);
1408  }
1409  updateScrollBars();
1410 }
1411 
1414 {
1416  if (childWindows.isEmpty())
1417  return list;
1418 
1419  if (order == QMdiArea::CreationOrder) {
1420  foreach (QMdiSubWindow *child, childWindows) {
1421  if (!child)
1422  continue;
1423  if (!reversed)
1424  list.append(child);
1425  else
1426  list.prepend(child);
1427  }
1428  } else if (order == QMdiArea::StackingOrder) {
1429  foreach (QObject *object, viewport->children()) {
1430  QMdiSubWindow *child = qobject_cast<QMdiSubWindow *>(object);
1431  if (!child || !childWindows.contains(child))
1432  continue;
1433  if (!reversed)
1434  list.append(child);
1435  else
1436  list.prepend(child);
1437  }
1438  } else { // ActivationHistoryOrder
1440  for (int i = indicesToActivatedChildren.count() - 1; i >= 0; --i) {
1442  if (!child)
1443  continue;
1444  if (!reversed)
1445  list.append(child);
1446  else
1447  list.prepend(child);
1448  }
1449  }
1450  return list;
1451 }
1452 
1457 {
1458  if (!subWindow)
1459  return;
1460 
1461  Q_Q(QMdiArea);
1462  QObject::disconnect(subWindow, 0, q, 0);
1463  subWindow->removeEventFilter(q);
1464 }
1465 
1470  int removedIndex, int fromIndex) const
1471 {
1472  if (childWindows.isEmpty())
1473  return 0;
1474 
1475  Q_Q(const QMdiArea);
1476  const QList<QMdiSubWindow *> subWindows = q->subWindowList(order);
1477  QMdiSubWindow *current = 0;
1478 
1479  if (removedIndex < 0) {
1480  if (fromIndex >= 0 && fromIndex < subWindows.size())
1481  current = childWindows.at(fromIndex);
1482  else
1483  current = q->currentSubWindow();
1484  }
1485 
1486  // There's no current sub-window (removed or deactivated),
1487  // so we have to pick the last active or the next in creation order.
1488  if (!current) {
1489  if (removedIndex >= 0 && order == QMdiArea::CreationOrder) {
1490  int candidateIndex = -1;
1491  setIndex(&candidateIndex, removedIndex, 0, subWindows.size() - 1, true);
1492  current = childWindows.at(candidateIndex);
1493  } else {
1494  current = subWindows.back();
1495  }
1496  }
1497  Q_ASSERT(current);
1498 
1499  // Find the index for the current sub-window in the given activation order
1500  const int indexToCurrent = subWindows.indexOf(current);
1501  const bool increasing = increaseFactor > 0 ? true : false;
1502 
1503  // and use that index + increseFactor as a candidate.
1504  int index = -1;
1505  setIndex(&index, indexToCurrent + increaseFactor, 0, subWindows.size() - 1, increasing);
1506  Q_ASSERT(index != -1);
1507 
1508  // Try to find another window if the candidate is hidden.
1509  while (subWindows.at(index)->isHidden()) {
1510  setIndex(&index, index + increaseFactor, 0, subWindows.size() - 1, increasing);
1511  if (index == indexToCurrent)
1512  break;
1513  }
1514 
1515  if (!subWindows.at(index)->isHidden())
1516  return subWindows.at(index);
1517  return 0;
1518 }
1519 
1524 {
1525  if (childWindows.size() == 1)
1526  return;
1527 
1528  Q_Q(QMdiArea);
1529  // There's no highlighted sub-window atm, use current.
1530  if (indexToHighlighted < 0) {
1531  QMdiSubWindow *current = q->currentSubWindow();
1532  if (!current)
1533  return;
1535  }
1536 
1539 
1540  QMdiSubWindow *highlight = nextVisibleSubWindow(increaseFactor, activationOrder, -1, indexToHighlighted);
1541  if (!highlight)
1542  return;
1543 
1544 #ifndef QT_NO_RUBBERBAND
1545  if (!rubberBand) {
1547  // For accessibility to identify this special widget.
1548  rubberBand->setObjectName(QLatin1String("qt_rubberband"));
1550  }
1551 #endif
1552 
1553  // Only highlight if we're not switching back to the previously active window (Ctrl-Tab once).
1554 #ifndef QT_NO_RUBBERBAND
1555  if (tabToPreviousTimerId == -1)
1556  showRubberBandFor(highlight);
1557 #endif
1558 
1561 }
1562 
1568 {
1569  Q_Q(QMdiArea);
1570  if (viewMode == mode || inViewModeChange)
1571  return;
1572 
1573  // Just a guard since we cannot set viewMode = mode here.
1574  inViewModeChange = true;
1575 
1576 #ifndef QT_NO_TABBAR
1577  if (mode == QMdiArea::TabbedView) {
1578  Q_ASSERT(!tabBar);
1579  tabBar = new QMdiAreaTabBar(q);
1583 #ifndef QT_NO_TABWIDGET
1585 #endif
1586 
1587  isSubWindowsTiled = false;
1588 
1589  foreach (QMdiSubWindow *subWindow, childWindows)
1590  tabBar->addTab(subWindow->windowIcon(), tabTextFor(subWindow));
1591 
1592  QMdiSubWindow *current = q->currentSubWindow();
1593  if (current) {
1595  // Restore sub-window (i.e. cleanup buttons in menu bar and window title).
1596  if (current->isMaximized())
1597  current->showNormal();
1598 
1599  viewMode = mode;
1600 
1601  // Now, maximize it.
1602  if (!q->testOption(QMdiArea::DontMaximizeSubWindowOnActivation)) {
1603  current->showMaximized();
1604  }
1605  } else {
1606  viewMode = mode;
1607  }
1608 
1609  if (q->isVisible())
1610  tabBar->show();
1612 
1613  QObject::connect(tabBar, SIGNAL(currentChanged(int)), q, SLOT(_q_currentTabChanged(int)));
1614  QObject::connect(tabBar, SIGNAL(tabCloseRequested(int)), q, SLOT(_q_closeTab(int)));
1615  QObject::connect(tabBar, SIGNAL(tabMoved(int,int)), q, SLOT(_q_moveTab(int,int)));
1616  } else
1617 #endif // QT_NO_TABBAR
1618  { // SubWindowView
1619 #ifndef QT_NO_TABBAR
1620  delete tabBar;
1621  tabBar = 0;
1622 #endif // QT_NO_TABBAR
1623 
1624  viewMode = mode;
1625  q->setViewportMargins(0, 0, 0, 0);
1626  indexToLastActiveTab = -1;
1627 
1628  QMdiSubWindow *current = q->currentSubWindow();
1629  if (current && current->isMaximized())
1630  current->showNormal();
1631  }
1632 
1633  Q_ASSERT(viewMode == mode);
1634  inViewModeChange = false;
1635 }
1636 
1637 #ifndef QT_NO_TABBAR
1638 
1642 {
1643  if (!tabBar)
1644  return;
1645 
1646  Q_Q(QMdiArea);
1647 #ifndef QT_NO_TABWIDGET
1649 #endif
1650  const QSize tabBarSizeHint = tabBar->sizeHint();
1651 
1652  int areaHeight = q->height();
1653  if (hbar && hbar->isVisible())
1654  areaHeight -= hbar->height();
1655 
1656  int areaWidth = q->width();
1657  if (vbar && vbar->isVisible())
1658  areaWidth -= vbar->width();
1659 
1660  QRect tabBarRect;
1661 #ifndef QT_NO_TABWIDGET
1662  switch (tabPosition) {
1663  case QTabWidget::North:
1664  q->setViewportMargins(0, tabBarSizeHint.height(), 0, 0);
1665  tabBarRect = QRect(0, 0, areaWidth, tabBarSizeHint.height());
1666  break;
1667  case QTabWidget::South:
1668  q->setViewportMargins(0, 0, 0, tabBarSizeHint.height());
1669  tabBarRect = QRect(0, areaHeight - tabBarSizeHint.height(), areaWidth, tabBarSizeHint.height());
1670  break;
1671  case QTabWidget::East:
1672  if (q->layoutDirection() == Qt::LeftToRight)
1673  q->setViewportMargins(0, 0, tabBarSizeHint.width(), 0);
1674  else
1675  q->setViewportMargins(tabBarSizeHint.width(), 0, 0, 0);
1676  tabBarRect = QRect(areaWidth - tabBarSizeHint.width(), 0, tabBarSizeHint.width(), areaHeight);
1677  break;
1678  case QTabWidget::West:
1679  if (q->layoutDirection() == Qt::LeftToRight)
1680  q->setViewportMargins(tabBarSizeHint.width(), 0, 0, 0);
1681  else
1682  q->setViewportMargins(0, 0, tabBarSizeHint.width(), 0);
1683  tabBarRect = QRect(0, 0, tabBarSizeHint.width(), areaHeight);
1684  break;
1685  default:
1686  break;
1687  }
1688 #endif // QT_NO_TABWIDGET
1689 
1690  tabBar->setGeometry(QStyle::visualRect(q->layoutDirection(), q->contentsRect(), tabBarRect));
1691 }
1692 
1697 {
1698  if (!tabBar)
1699  return;
1700 
1704 #ifndef QT_NO_TABWIDGET
1706 #endif
1708 }
1709 #endif // QT_NO_TABBAR
1710 
1716  : QAbstractScrollArea(*new QMdiAreaPrivate, parent)
1717 {
1722  setViewport(0);
1725 }
1726 
1731 {
1732  Q_D(QMdiArea);
1733  delete d->cascader;
1734  d->cascader = 0;
1735 
1736  delete d->regularTiler;
1737  d->regularTiler = 0;
1738 
1739  delete d->iconTiler;
1740  d->iconTiler = 0;
1741 
1742  delete d->placer;
1743  d->placer = 0;
1744 }
1745 
1750 {
1751  // Calculate a proper scale factor for QDesktopWidget::size().
1752  // This also takes into account that we can have nested workspaces.
1753  int nestedCount = 0;
1754  QWidget *widget = this->parentWidget();
1755  while (widget) {
1756  if (qobject_cast<QMdiArea *>(widget))
1757  ++nestedCount;
1758  widget = widget->parentWidget();
1759  }
1760  const int scaleFactor = 3 * (nestedCount + 1);
1761 
1762  QSize desktopSize = QApplication::desktop()->size();
1763  QSize size(desktopSize.width() * 2 / scaleFactor, desktopSize.height() * 2 / scaleFactor);
1764  foreach (QMdiSubWindow *child, d_func()->childWindows) {
1765  if (!sanityCheck(child, "QMdiArea::sizeHint"))
1766  continue;
1767  size = size.expandedTo(child->sizeHint());
1768  }
1770 }
1771 
1776 {
1777  Q_D(const QMdiArea);
1778  QSize size(style()->pixelMetric(QStyle::PM_MdiSubWindowMinimizedWidth, 0, this),
1779  style()->pixelMetric(QStyle::PM_TitleBarHeight, 0, this));
1781  if (!d->scrollBarsEnabled()) {
1782  foreach (QMdiSubWindow *child, d->childWindows) {
1783  if (!sanityCheck(child, "QMdiArea::sizeHint"))
1784  continue;
1785  size = size.expandedTo(child->minimumSizeHint());
1786  }
1787  }
1788  return size.expandedTo(QApplication::globalStrut());
1789 }
1790 
1801 {
1802  Q_D(const QMdiArea);
1803  if (d->childWindows.isEmpty())
1804  return 0;
1805 
1806  if (d->active)
1807  return d->active;
1808 
1809  if (d->isActivated && !window()->isMinimized())
1810  return 0;
1811 
1812  Q_ASSERT(d->indicesToActivatedChildren.count() > 0);
1813  int index = d->indicesToActivatedChildren.at(0);
1814  Q_ASSERT(index >= 0 && index < d->childWindows.size());
1815  QMdiSubWindow *current = d->childWindows.at(index);
1816  Q_ASSERT(current);
1817  return current;
1818 }
1819 
1833 {
1834  Q_D(const QMdiArea);
1835  return d->active;
1836 }
1837 
1845 {
1846  Q_D(QMdiArea);
1847  if (!window) {
1848  d->activateWindow(0);
1849  return;
1850  }
1851 
1852  if (d->childWindows.isEmpty()) {
1853  qWarning("QMdiArea::setActiveSubWindow: workspace is empty");
1854  return;
1855  }
1856 
1857  if (d->childWindows.indexOf(window) == -1) {
1858  qWarning("QMdiArea::setActiveSubWindow: window is not inside workspace");
1859  return;
1860  }
1861 
1862  d->activateWindow(window);
1863 }
1864 
1871 {
1872  Q_D(QMdiArea);
1873  if (d->active)
1874  d->active->close();
1875 }
1876 
1889 {
1890  Q_D(const QMdiArea);
1891  return d->subWindowList(order, false);
1892 }
1893 
1905 {
1906  Q_D(QMdiArea);
1907  if (d->childWindows.isEmpty())
1908  return;
1909 
1910  d->isSubWindowsTiled = false;
1911  foreach (QMdiSubWindow *child, d->childWindows) {
1912  if (!sanityCheck(child, "QMdiArea::closeAllSubWindows"))
1913  continue;
1914  child->close();
1915  }
1916 
1917  d->updateScrollBars();
1918 }
1919 
1928 {
1929  Q_D(QMdiArea);
1930  if (d->childWindows.isEmpty())
1931  return;
1932 
1933  QMdiSubWindow *next = d->nextVisibleSubWindow(1, d->activationOrder);
1934  if (next)
1935  d->activateWindow(next);
1936 }
1937 
1946 {
1947  Q_D(QMdiArea);
1948  if (d->childWindows.isEmpty())
1949  return;
1950 
1951  QMdiSubWindow *previous = d->nextVisibleSubWindow(-1, d->activationOrder);
1952  if (previous)
1953  d->activateWindow(previous);
1954 }
1955 
1980 {
1981  if (!widget) {
1982  qWarning("QMdiArea::addSubWindow: null pointer to widget");
1983  return 0;
1984  }
1985 
1986  Q_D(QMdiArea);
1987  // QWidget::setParent clears focusWidget so store it
1988  QWidget *childFocus = widget->focusWidget();
1990 
1991  // Widget is already a QMdiSubWindow
1992  if (child) {
1993  if (d->childWindows.indexOf(child) != -1) {
1994  qWarning("QMdiArea::addSubWindow: window is already added");
1995  return child;
1996  }
1997  child->setParent(viewport(), windowFlags ? windowFlags : child->windowFlags());
1998  // Create a QMdiSubWindow
1999  } else {
2000  child = new QMdiSubWindow(viewport(), windowFlags);
2002  child->setWidget(widget);
2004  }
2005 
2006  if (childFocus)
2007  childFocus->setFocus();
2008  d->appendChild(child);
2009  return child;
2010 }
2011 
2023 {
2024  if (!widget) {
2025  qWarning("QMdiArea::removeSubWindow: null pointer to widget");
2026  return;
2027  }
2028 
2029  Q_D(QMdiArea);
2030  if (d->childWindows.isEmpty())
2031  return;
2032 
2033  if (QMdiSubWindow *child = qobject_cast<QMdiSubWindow *>(widget)) {
2034  int index = d->childWindows.indexOf(child);
2035  if (index == -1) {
2036  qWarning("QMdiArea::removeSubWindow: window is not inside workspace");
2037  return;
2038  }
2039  d->disconnectSubWindow(child);
2040  d->childWindows.removeAll(child);
2041  d->indicesToActivatedChildren.removeAll(index);
2042  d->updateActiveWindow(index, d->active == child);
2043  child->setParent(0);
2044  return;
2045  }
2046 
2047  bool found = false;
2048  foreach (QMdiSubWindow *child, d->childWindows) {
2049  if (!sanityCheck(child, "QMdiArea::removeSubWindow"))
2050  continue;
2051  if (child->widget() == widget) {
2052  child->setWidget(0);
2053  Q_ASSERT(!child->widget());
2054  found = true;
2055  break;
2056  }
2057  }
2058 
2059  if (!found)
2060  qWarning("QMdiArea::removeSubWindow: widget is not child of any window inside QMdiArea");
2061 }
2062 
2075 {
2076  return d_func()->background;
2077 }
2078 
2080 {
2081  Q_D(QMdiArea);
2082  if (d->background != brush) {
2083  d->background = brush;
2084  d->viewport->setAttribute(Qt::WA_OpaquePaintEvent, brush.isOpaque());
2085  update();
2086  }
2087 }
2088 
2089 
2105 {
2106  Q_D(const QMdiArea);
2107  return d->activationOrder;
2108 }
2109 
2111 {
2112  Q_D(QMdiArea);
2113  if (order != d->activationOrder)
2114  d->activationOrder = order;
2115 }
2116 
2123 void QMdiArea::setOption(AreaOption option, bool on)
2124 {
2125  Q_D(QMdiArea);
2126  if (on && !(d->options & option))
2127  d->options |= option;
2128  else if (!on && (d->options & option))
2129  d->options &= ~option;
2130 }
2131 
2138 {
2139  return d_func()->options & option;
2140 }
2141 
2155 {
2156  Q_D(const QMdiArea);
2157  return d->viewMode;
2158 }
2159 
2161 {
2162  Q_D(QMdiArea);
2163  d->setViewMode(mode);
2164 }
2165 
2166 #ifndef QT_NO_TABBAR
2167 
2179 bool QMdiArea::documentMode() const
2180 {
2181  Q_D(const QMdiArea);
2182  return d->documentMode;
2183 }
2184 
2186 {
2187  Q_D(QMdiArea);
2188  if (d->documentMode == enabled)
2189  return;
2190 
2191  d->documentMode = enabled;
2192  d->refreshTabBar();
2193 }
2194 
2207 bool QMdiArea::tabsClosable() const
2208 {
2209  Q_D(const QMdiArea);
2210  return d->tabsClosable;
2211 }
2212 
2213 void QMdiArea::setTabsClosable(bool closable)
2214 {
2215  Q_D(QMdiArea);
2216  if (d->tabsClosable == closable)
2217  return;
2218 
2219  d->tabsClosable = closable;
2220  d->refreshTabBar();
2221 }
2222 
2235 bool QMdiArea::tabsMovable() const
2236 {
2237  Q_D(const QMdiArea);
2238  return d->tabsMovable;
2239 }
2240 
2241 void QMdiArea::setTabsMovable(bool movable)
2242 {
2243  Q_D(QMdiArea);
2244  if (d->tabsMovable == movable)
2245  return;
2246 
2247  d->tabsMovable = movable;
2248  d->refreshTabBar();
2249 }
2250 #endif // QT_NO_TABBAR
2251 
2252 #ifndef QT_NO_TABWIDGET
2253 
2267 {
2268  Q_D(const QMdiArea);
2269  return d->tabShape;
2270 }
2271 
2273 {
2274  Q_D(QMdiArea);
2275  if (d->tabShape == shape)
2276  return;
2277 
2278  d->tabShape = shape;
2279  d->refreshTabBar();
2280 }
2281 
2296 {
2297  Q_D(const QMdiArea);
2298  return d->tabPosition;
2299 }
2300 
2302 {
2303  Q_D(QMdiArea);
2304  if (d->tabPosition == position)
2305  return;
2306 
2307  d->tabPosition = position;
2308  d->refreshTabBar();
2309 }
2310 #endif // QT_NO_TABWIDGET
2311 
2316 {
2317  Q_D(QMdiArea);
2318  if (childEvent->type() == QEvent::ChildPolished) {
2319  if (QMdiSubWindow *mdiChild = qobject_cast<QMdiSubWindow *>(childEvent->child())) {
2320  if (d->childWindows.indexOf(mdiChild) == -1)
2321  d->appendChild(mdiChild);
2322  }
2323  }
2324 }
2325 
2330 {
2331  Q_D(QMdiArea);
2332  if (d->childWindows.isEmpty()) {
2333  resizeEvent->ignore();
2334  return;
2335  }
2336 
2337 #ifndef QT_NO_TABBAR
2338  d->updateTabBarGeometry();
2339 #endif
2340 
2341  // Re-tile the views if we're in tiled mode. Re-tile means we will change
2342  // the geometry of the children, which in turn means 'isSubWindowsTiled'
2343  // is set to false, so we have to update the state at the end.
2344  if (d->isSubWindowsTiled) {
2345  d->tileCalledFromResizeEvent = true;
2346  tileSubWindows();
2347  d->tileCalledFromResizeEvent = false;
2348  d->isSubWindowsTiled = true;
2349  d->startResizeTimer();
2350  // We don't have scroll bars or any maximized views.
2351  return;
2352  }
2353 
2354  // Resize maximized views.
2355  bool hasMaximizedSubWindow = false;
2356  foreach (QMdiSubWindow *child, d->childWindows) {
2357  if (sanityCheck(child, "QMdiArea::resizeEvent") && child->isMaximized()
2358  && child->size() != resizeEvent->size()) {
2359  child->resize(resizeEvent->size());
2360  if (!hasMaximizedSubWindow)
2361  hasMaximizedSubWindow = true;
2362  }
2363  }
2364 
2365  d->updateScrollBars();
2366 
2367  // Minimized views are stacked under maximized views so there's
2368  // no need to re-arrange minimized views on-demand. Start a timer
2369  // just to make things faster with subsequent resize events.
2370  if (hasMaximizedSubWindow)
2371  d->startResizeTimer();
2372  else
2373  d->arrangeMinimizedSubWindows();
2374 }
2375 
2380 {
2381  Q_D(QMdiArea);
2382  if (timerEvent->timerId() == d->resizeTimerId) {
2383  killTimer(d->resizeTimerId);
2384  d->resizeTimerId = -1;
2385  d->arrangeMinimizedSubWindows();
2386  } else if (timerEvent->timerId() == d->tabToPreviousTimerId) {
2387  killTimer(d->tabToPreviousTimerId);
2388  d->tabToPreviousTimerId = -1;
2389  if (d->indexToHighlighted < 0)
2390  return;
2391 #ifndef QT_NO_RUBBERBAND
2392  // We're not doing a "quick switch" ... show rubber band.
2393  Q_ASSERT(d->indexToHighlighted < d->childWindows.size());
2394  Q_ASSERT(d->rubberBand);
2395  d->showRubberBandFor(d->childWindows.at(d->indexToHighlighted));
2396 #endif
2397  }
2398 }
2399 
2404 {
2405  Q_D(QMdiArea);
2406  if (!d->pendingRearrangements.isEmpty()) {
2407  bool skipPlacement = false;
2408  foreach (Rearranger *rearranger, d->pendingRearrangements) {
2409  // If this is the case, we don't have to lay out pending child windows
2410  // since the rearranger will find a placement for them.
2411  if (rearranger->type() != Rearranger::IconTiler && !skipPlacement)
2412  skipPlacement = true;
2413  d->rearrange(rearranger);
2414  }
2415  d->pendingRearrangements.clear();
2416 
2417  if (skipPlacement && !d->pendingPlacements.isEmpty())
2418  d->pendingPlacements.clear();
2419  }
2420 
2421  if (!d->pendingPlacements.isEmpty()) {
2422  foreach (QMdiSubWindow *window, d->pendingPlacements) {
2423  if (!window)
2424  continue;
2425  if (!window->testAttribute(Qt::WA_Resized)) {
2426  QSize newSize(window->sizeHint().boundedTo(viewport()->size()));
2427  window->resize(newSize.expandedTo(qSmartMinSize(window)));
2428  }
2429  if (!window->testAttribute(Qt::WA_Moved) && !window->isMinimized()
2430  && !window->isMaximized()) {
2431  d->place(d->placer, window);
2432  }
2433  }
2434  d->pendingPlacements.clear();
2435  }
2436 
2437  d->setChildActivationEnabled(true);
2438  d->activateCurrentWindow();
2439 
2440  QAbstractScrollArea::showEvent(showEvent);
2441 }
2442 
2447 {
2448  Q_D(QMdiArea);
2449  switch (event->type()) {
2450  case QEvent::ChildRemoved: {
2451  d->isSubWindowsTiled = false;
2452  QObject *removedChild = static_cast<QChildEvent *>(event)->child();
2453  for (int i = 0; i < d->childWindows.size(); ++i) {
2454  QObject *child = d->childWindows.at(i);
2455  if (!child || child == removedChild || !child->parent()
2456  || child->parent() != viewport()) {
2458  // In this case we can only rely on the child being a QObject
2459  // (or 0), but let's try and see if we can get more information.
2460  QWidget *mdiChild = qobject_cast<QWidget *>(removedChild);
2461  if (mdiChild && mdiChild->isMaximized())
2462  d->showActiveWindowMaximized = true;
2463  }
2464  d->disconnectSubWindow(child);
2465  const bool activeRemoved = i == d->indicesToActivatedChildren.at(0);
2466  d->childWindows.removeAt(i);
2467  d->indicesToActivatedChildren.removeAll(i);
2468  d->updateActiveWindow(i, activeRemoved);
2469  d->arrangeMinimizedSubWindows();
2470  break;
2471  }
2472  }
2473  d->updateScrollBars();
2474  break;
2475  }
2476  case QEvent::Destroy:
2477  d->isSubWindowsTiled = false;
2478  d->resetActiveWindow();
2479  d->childWindows.clear();
2480  qWarning("QMdiArea: Deleting the view port is undefined, use setViewport instead.");
2481  break;
2482  default:
2483  break;
2484  }
2485  return QAbstractScrollArea::viewportEvent(event);
2486 }
2487 
2491 void QMdiArea::scrollContentsBy(int dx, int dy)
2492 {
2493  Q_D(QMdiArea);
2494  const bool wasSubWindowsTiled = d->isSubWindowsTiled;
2495  d->ignoreGeometryChange = true;
2496  viewport()->scroll(isLeftToRight() ? dx : -dx, dy);
2497  d->arrangeMinimizedSubWindows();
2498  d->ignoreGeometryChange = false;
2499  if (wasSubWindowsTiled)
2500  d->isSubWindowsTiled = true;
2501 }
2502 
2509 {
2510  Q_D(QMdiArea);
2511  if (!d->regularTiler)
2512  d->regularTiler = new RegularTiler;
2513  d->rearrange(d->regularTiler);
2514 }
2515 
2522 {
2523  Q_D(QMdiArea);
2524  if (!d->cascader)
2525  d->cascader = new SimpleCascader;
2526  d->rearrange(d->cascader);
2527 }
2528 
2533 {
2534  Q_D(QMdiArea);
2535  switch (event->type()) {
2536 #ifdef Q_WS_WIN
2537  // QWidgetPrivate::hide_helper activates another sub-window when closing a
2538  // modal dialog on Windows (see activateWindow() inside the the ifdef).
2540  d->activateCurrentWindow();
2541  break;
2542 #endif
2543  case QEvent::WindowActivate: {
2544  d->isActivated = true;
2545  if (d->childWindows.isEmpty())
2546  break;
2547  if (!d->active)
2548  d->activateCurrentWindow();
2549  d->setChildActivationEnabled(false, true);
2550  break;
2551  }
2553  d->isActivated = false;
2554  d->setChildActivationEnabled(false, true);
2555  break;
2556  case QEvent::StyleChange:
2557  // Re-tile the views if we're in tiled mode. Re-tile means we will change
2558  // the geometry of the children, which in turn means 'isSubWindowsTiled'
2559  // is set to false, so we have to update the state at the end.
2560  if (d->isSubWindowsTiled) {
2561  tileSubWindows();
2562  d->isSubWindowsTiled = true;
2563  }
2564  break;
2566  foreach (QMdiSubWindow *window, d->childWindows) {
2567  if (sanityCheck(window, "QMdiArea::WindowIconChange"))
2568  QApplication::sendEvent(window, event);
2569  }
2570  break;
2571  case QEvent::Hide:
2572  d->setActive(d->active, false, false);
2573  d->setChildActivationEnabled(false);
2574  break;
2575 #ifndef QT_NO_TABBAR
2577  d->updateTabBarGeometry();
2578  break;
2579 #endif
2580  default:
2581  break;
2582  }
2583  return QAbstractScrollArea::event(event);
2584 }
2585 
2590 {
2591  if (!object)
2592  return QAbstractScrollArea::eventFilter(object, event);
2593 
2594  Q_D(QMdiArea);
2595  // Global key events with Ctrl modifier.
2596  if (event->type() == QEvent::KeyPress || event->type() == QEvent::KeyRelease) {
2597 
2598  QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
2599  // Ingore key events without a Ctrl modifier (except for press/release on the modifier itself).
2600 #ifdef Q_WS_MAC
2601  if (!(keyEvent->modifiers() & Qt::MetaModifier) && keyEvent->key() != Qt::Key_Meta)
2602 #else
2603  if (!(keyEvent->modifiers() & Qt::ControlModifier) && keyEvent->key() != Qt::Key_Control)
2604 #endif
2605  return QAbstractScrollArea::eventFilter(object, event);
2606 
2607  // Find closest mdi area (in case we have a nested workspace).
2608  QMdiArea *area = mdiAreaParent(static_cast<QWidget *>(object));
2609  if (!area)
2610  return QAbstractScrollArea::eventFilter(object, event);
2611 
2612  const bool keyPress = (event->type() == QEvent::KeyPress) ? true : false;
2613 
2614  // 1) Ctrl-Tab once -> activate the previously active window.
2615  // 2) Ctrl-Tab (Tab, Tab, ...) -> iterate through all windows (activateNextSubWindow()).
2616  // 3) Ctrl-Shift-Tab (Tab, Tab, ...) -> iterate through all windows in the opposite
2617  // direction (activatePreviousSubWindow())
2618  switch (keyEvent->key()) {
2619 #ifdef Q_WS_MAC
2620  case Qt::Key_Meta:
2621 #else
2622  case Qt::Key_Control:
2623 #endif
2624  if (keyPress)
2625  area->d_func()->startTabToPreviousTimer();
2626  else
2627  area->d_func()->activateHighlightedWindow();
2628  break;
2629  case Qt::Key_Tab:
2630  case Qt::Key_Backtab:
2631  if (keyPress)
2632  area->d_func()->highlightNextSubWindow(keyEvent->key() == Qt::Key_Tab ? 1 : -1);
2633  return true;
2634 #ifndef QT_NO_RUBBERBAND
2635  case Qt::Key_Escape:
2636  area->d_func()->hideRubberBand();
2637  break;
2638 #endif
2639  default:
2640  break;
2641  }
2642  return QAbstractScrollArea::eventFilter(object, event);
2643  }
2644 
2645  QMdiSubWindow *subWindow = qobject_cast<QMdiSubWindow *>(object);
2646 
2647  if (!subWindow) {
2648  // QApplication events:
2649  if (event->type() == QEvent::ApplicationActivate && !d->active
2650  && isVisible() && !window()->isMinimized()) {
2651  d->activateCurrentWindow();
2652  } else if (event->type() == QEvent::ApplicationDeactivate && d->active) {
2653  d->setActive(d->active, false, false);
2654  }
2655  return QAbstractScrollArea::eventFilter(object, event);
2656  }
2657 
2658  // QMdiSubWindow events:
2659  switch (event->type()) {
2660  case QEvent::Move:
2661  case QEvent::Resize:
2662  if (d->tileCalledFromResizeEvent)
2663  break;
2664  d->updateScrollBars();
2665  if (!subWindow->isMinimized())
2666  d->isSubWindowsTiled = false;
2667  break;
2668  case QEvent::Show:
2669 #ifndef QT_NO_TABBAR
2670  if (d->tabBar) {
2671  const int tabIndex = d->childWindows.indexOf(subWindow);
2672  if (!d->tabBar->isTabEnabled(tabIndex))
2673  d->tabBar->setTabEnabled(tabIndex, true);
2674  }
2675 #endif // QT_NO_TABBAR
2676  // fall through
2677  case QEvent::Hide:
2678  d->isSubWindowsTiled = false;
2679  break;
2680 #ifndef QT_NO_RUBBERBAND
2681  case QEvent::Close:
2682  if (d->childWindows.indexOf(subWindow) == d->indexToHighlighted)
2683  d->hideRubberBand();
2684  break;
2685 #endif
2686 #ifndef QT_NO_TABBAR
2689  if (d->tabBar)
2690  d->tabBar->setTabText(d->childWindows.indexOf(subWindow), tabTextFor(subWindow));
2691  break;
2693  if (d->tabBar)
2694  d->tabBar->setTabIcon(d->childWindows.indexOf(subWindow), subWindow->windowIcon());
2695  break;
2696 #endif // QT_NO_TABBAR
2697  default:
2698  break;
2699  }
2700  return QAbstractScrollArea::eventFilter(object, event);
2701 }
2702 
2707 {
2708  Q_D(QMdiArea);
2709  QPainter painter(d->viewport);
2710  const QVector<QRect> &exposedRects = paintEvent->region().rects();
2711  for (int i = 0; i < exposedRects.size(); ++i)
2712  painter.fillRect(exposedRects.at(i), d->background);
2713 }
2714 
2723 {
2724  Q_D(QMdiArea);
2725  if (viewport)
2726  viewport->setAttribute(Qt::WA_OpaquePaintEvent, d->background.isOpaque());
2727  foreach (QMdiSubWindow *child, d->childWindows) {
2728  if (!sanityCheck(child, "QMdiArea::setupViewport"))
2729  continue;
2730  child->setParent(viewport, child->windowFlags());
2731  }
2732 }
2733 
2735 
2736 #include "moc_qmdiarea.cpp"
2737 
2738 #endif // QT_NO_MDIAREA
void scroll(int dx, int dy)
Scrolls the widget including its children dx pixels to the right and dy downward. ...
Definition: qwidget.cpp:10684
QSize minimumSizeHint() const
Reimplemented Function
Definition: qmdiarea.cpp:1775
T qobject_cast(QObject *object)
Definition: qobject.h:375
void showMaximized()
Shows the widget maximized.
Definition: qwidget.cpp:3218
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
bool updatesDisabledByUs
Definition: qmdiarea_p.h:181
void scrollBarPolicyChanged(Qt::Orientation, Qt::ScrollBarPolicy)
Definition: qmdiarea.cpp:1396
double d
Definition: qnumeric_p.h:62
void stackUnder(QWidget *)
Places the widget under w in the parent widget&#39;s stack.
Definition: qwidget.cpp:11972
bool enabled
whether the widget is enabled
Definition: qwidget.h:157
void setViewMode(QMdiArea::ViewMode mode)
Definition: qmdiarea.cpp:1567
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
void activateWindow(QMdiSubWindow *child)
Definition: qmdiarea.cpp:1022
bool blockSignals(bool b)
If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke...
Definition: qobject.cpp:1406
QTabWidget::TabShape tabShape() const
void _q_closeTab(int index)
Definition: qmdiarea.cpp:830
The QKeyEvent class describes a key event.
Definition: qevent.h:224
QWidget * focusWidget() const
Returns the last child of this widget that setFocus had been called on.
Definition: qwidget.cpp:6863
void setHeight(int h)
Sets the height of the rectangle to the given height.
Definition: qrect.h:445
virtual void showEvent(QShowEvent *)
This event handler can be reimplemented in a subclass to receive widget show events which are passed ...
Definition: qwidget.cpp:9842
QList< QMdi::Rearranger * > pendingRearrangements
Definition: qmdiarea_p.h:156
double qreal
Definition: qglobal.h:1193
void mousePressEvent(QMouseEvent *event)
Definition: qmdiarea.cpp:611
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
The QFontMetrics class provides font metrics information.
Definition: qfontmetrics.h:65
bool viewportEvent(QEvent *event)
Reimplemented Function
Definition: qmdiarea.cpp:2446
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
void rearrange(QMdi::Rearranger *rearranger)
Definition: qmdiarea.cpp:945
QPointer< QMdiSubWindow > aboutToBecomeActive
Definition: qmdiarea_p.h:161
void setParent(QWidget *parent)
Sets the parent of the widget to parent, and resets the window flags.
Definition: qwidget.cpp:10479
Q_GUI_EXPORT QSize qSmartMinSize(const QSize &sizeHint, const QSize &minSizeHint, const QSize &minSize, const QSize &maxSize, const QSizePolicy &sizePolicy)
QSize size() const
EventRef event
QPointer< QWidget > widget
QMdiSubWindow * subWindowFromIndex(int index) const
Definition: qmdiarea.cpp:674
bool showActiveWindowMaximized
Definition: qmdiarea_p.h:179
static void keyEvent(KeyAction action, QWidget *widget, char ascii, Qt::KeyboardModifiers modifier=Qt::NoModifier, int delay=-1)
QRect childrenRect
the bounding rectangle of the widget&#39;s children
Definition: qwidget.h:169
int width
the width of the widget excluding any window frame
Definition: qwidget.h:166
int qCeil(qreal v)
Definition: qmath.h:63
#define it(className, varName)
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
The QContextMenuEvent class contains parameters that describe a context menu event.
Definition: qevent.h:396
int indexToHighlighted
Definition: qmdiarea_p.h:185
QMdiArea::AreaOptions options
Definition: qmdiarea_p.h:164
void closeActiveSubWindow()
Closes the active subwindow.
Definition: qmdiarea.cpp:1870
bool isVisible() const
Definition: qwidget.h:1005
const QPoint & pos() const
Returns the position of the mouse pointer relative to the widget that received the event...
Definition: qevent.h:412
bool isVisibleTo(QWidget *) const
Returns true if this widget would become visible if ancestor is shown; otherwise returns false...
Definition: qwidget.cpp:8371
static QSize globalStrut()
TabPosition
This enum type defines where QTabWidget draws the tab row:
Definition: qtabwidget.h:112
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const =0
Returns the value of the given pixel metric.
#define error(msg)
QString & replace(int i, int len, QChar after)
Definition: qstring.cpp:2005
QMdiAreaTabBar * tabBar
Definition: qmdiarea_p.h:155
QSize sizeHint() const
Reimplemented Function
bool ignoreWindowStateChange
Definition: qmdiarea_p.h:176
#define SLOT(a)
Definition: qobjectdefs.h:226
bool empty() const
This function is provided for STL compatibility.
Definition: qlist.h:304
void removeEventFilter(QObject *)
Removes an event filter object obj from this object.
Definition: qobject.cpp:2099
The QStyleOptionTitleBar class is used to describe the parameters for drawing a title bar...
Definition: qstyleoption.h:816
virtual void rearrange(QList< QWidget *> &widgets, const QRect &domain) const =0
void setTabShape(QTabWidget::TabShape shape)
Definition: qmdiarea.cpp:2272
static qreal position(QGraphicsObject *item, QDeclarativeAnchorLine::AnchorLine anchorLine)
bool lastWindowAboutToBeDestroyed() const
Definition: qmdiarea.cpp:1362
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
void setOption(AreaOption option, bool on=true)
If on is true, option is enabled on the MDI area; otherwise it is disabled.
Definition: qmdiarea.cpp:2123
iterator begin()
Returns an STL-style iterator pointing to the first item in the list.
Definition: qlist.h:267
void setHorizontalScrollBarPolicy(Qt::ScrollBarPolicy)
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
void setCurrentIndex(int index)
Definition: qtabbar.cpp:1238
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
void showRubberBandFor(QMdiSubWindow *subWindow)
Definition: qmdiarea_p.h:263
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
ViewMode
This enum describes the view mode of the area; i.
Definition: qmdiarea.h:88
static QMdiArea * mdiAreaParent(QWidget *widget)
Definition: qmdiarea.cpp:259
QTabWidget::TabPosition tabPosition() const
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
QRect intersected(const QRect &other) const
Returns the intersection of this rectangle and the given rectangle.
Definition: qrect.h:481
QList< QPointer< QMdiSubWindow > > pendingPlacements
Definition: qmdiarea_p.h:157
The QAbstractScrollArea widget provides a scrolling area with on-demand scroll bars.
The QTabBar class provides a tab bar, e.g.
Definition: qtabbar.h:59
void setOption(SubWindowOption option, bool on=true)
If on is true, option is enabled on the subwindow; otherwise it is disabled.
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
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
void disconnectSubWindow(QObject *subWindow)
Definition: qmdiarea.cpp:1456
int bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:249
The QString class provides a Unicode character string.
Definition: qstring.h:83
void mousePressEvent(QMouseEvent *)
em>Reimplemented Function
Definition: qtabbar.cpp:1779
T * qobject_cast(QObject *object)
Definition: qobject.h:375
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
QSize sizeHint() const
em>Reimplemented Function
Definition: qtabbar.cpp:1317
void removeTab(int index)
Removes the tab at position index.
Definition: qtabbar.cpp:902
#define Q_D(Class)
Definition: qglobal.h:2482
ViewMode viewMode() const
int height() const
void internalRaise(QMdiSubWindow *child) const
Definition: qmdiarea.cpp:1267
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
void rearrange(QList< QWidget *> &widgets, const QRect &domain) const
Definition: qmdiarea.cpp:352
void appendChild(QMdiSubWindow *child)
Definition: qmdiarea.cpp:854
QMdiSubWindow * currentSubWindow() const
Returns a pointer to the current subwindow, or 0 if there is no current subwindow.
Definition: qmdiarea.cpp:1800
void showNormal()
Restores the widget after it has been maximized or minimized.
Definition: qwidget.cpp:3250
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
void setRange(int min, int max)
Sets the slider&#39;s minimum to min and its maximum to max.
QMdiArea::ViewMode viewMode
Definition: qmdiarea_p.h:165
const QPoint & pos() const
Returns the position of the mouse cursor, relative to the widget that received the event...
Definition: qevent.h:95
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
QStyle * style() const
Definition: qwidget.cpp:2742
void setObjectName(const QString &name)
Definition: qobject.cpp:1112
#define Q_Q(Class)
Definition: qglobal.h:2483
bool eventFilter(QObject *object, QEvent *event)
Reimplemented Function
Definition: qmdiarea.cpp:2589
static QFont font()
Returns the default application font.
void setVisible(WindowStateAction, bool visible=true)
bool isHidden() const
Returns true if the widget is hidden, otherwise returns false.
Definition: qwidget.h:1008
void update()
Updates the widget unless updates are disabled or the widget is hidden.
Definition: qwidget.cpp:10883
virtual QPoint place(const QSize &size, const QList< QRect > &rects, const QRect &domain) const =0
QWidget * viewport() const
Returns the viewport widget.
void move(int from, int to)
Moves the item at index position from to index position to.
Definition: qlist.h:628
QList< QPointer< QMdiSubWindow > > childWindows
Definition: qmdiarea_p.h:158
Qt::KeyboardModifiers modifiers() const
Returns the keyboard modifier flags that existed immediately after the event occurred.
Definition: qevent.cpp:999
bool isWindowModified() const
Definition: qwidget.cpp:11554
int key() const
Returns the code of the key that was pressed or released.
Definition: qevent.h:231
#define SIGNAL(a)
Definition: qobjectdefs.h:227
QBrush background() const
QIcon windowIcon() const
NSWindow * window
int width() const
Returns the width.
Definition: qsize.h:126
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
void _q_currentTabChanged(int index)
Definition: qmdiarea.cpp:806
void removeSubWindow(QWidget *widget)
Removes widget from the MDI area.
Definition: qmdiarea.cpp:2022
int value() const
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
static bool sanityCheck(const QMdiSubWindow *const child, const char *where)
Definition: qmdiarea.cpp:198
void resizeEvent(QResizeEvent *resizeEvent)
Reimplemented Function
Definition: qmdiarea.cpp:2329
Shape
This enum type lists the built-in shapes supported by QTabBar.
Definition: qtabbar.h:81
QBool contains(const T &t) const
Returns true if the list contains an occurrence of value; otherwise returns false.
Definition: qlist.h:880
void lower()
Lowers the widget to the bottom of the parent widget&#39;s stack.
Definition: qwidget.cpp:11939
short frameWidth
Definition: qframe_p.h:74
bool scrollBarsEnabled() const
Definition: qmdiarea.cpp:1354
bool tileCalledFromResizeEvent
Definition: qmdiarea_p.h:180
void setTabsClosable(bool closable)
Definition: qtabbar.cpp:2158
QWidget * widget() const
Returns the current internal widget.
void activateCurrentWindow()
Definition: qmdiarea.cpp:1047
int height
the height of the widget excluding any window frame
Definition: qwidget.h:167
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
Definition: qobject.cpp:2580
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
void raise()
Raises this widget to the top of the parent widget&#39;s stack.
Definition: qwidget.cpp:11901
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
void contextMenuEvent(QContextMenuEvent *event)
Definition: qmdiarea.cpp:631
int width() const
T & back()
This function is provided for STL compatibility.
Definition: qlist.h:300
void initFrom(const QWidget *w)
Definition: qstyleoption.h:99
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the list...
Definition: qlist.h:270
void prepend(const T &t)
Inserts value at the beginning of the list.
Definition: qlist.h:541
The QMdiArea widget provides an area in which MDI windows are displayed.
Definition: qmdiarea.h:59
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
#define emit
Definition: qobjectdefs.h:76
void scrollContentsBy(int dx, int dy)
Reimplemented Function
Definition: qmdiarea.cpp:2491
void closeAllSubWindows()
Closes all subwindows by sending a QCloseEvent to each window.
Definition: qmdiarea.cpp:1904
void setWindowFlags(Qt::WindowFlags type)
Definition: qwidget.cpp:10399
void setDocumentMode(bool set)
Definition: qtabbar.cpp:2325
QList< QMdiSubWindow * > subWindowList(WindowOrder order=CreationOrder) const
Returns a list of all subwindows in the MDI area.
Definition: qmdiarea.cpp:1888
void refreshTabBar()
Definition: qmdiarea.cpp:1696
const QPalette & palette() const
void setShape(Shape shape)
Definition: qtabbar.cpp:778
The QResizeEvent class contains event parameters for resize events.
Definition: qevent.h:349
const QRegion & region() const
Returns the region that needs to be updated.
Definition: qevent.h:306
Q_CORE_EXPORT void qWarning(const char *,...)
int timerId() const
Returns the unique timer identifier, which is the same identifier as returned from QObject::startTime...
Definition: qcoreevent.h:346
static Bigint * diff(Bigint *a, Bigint *b)
void paintEvent(QPaintEvent *paintEvent)
Reimplemented Function
Definition: qmdiarea.cpp:2706
QString windowTitle() const
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
bool isShaded() const
Returns true if this window is shaded; otherwise returns false.
QPointer< QMdiSubWindow > active
Definition: qmdiarea_p.h:160
void activatePreviousSubWindow()
Gives the keyboard focus to another window in the list of child windows.
Definition: qmdiarea.cpp:1945
void updateActiveWindow(int removedIndex, bool activeRemoved)
Definition: qmdiarea.cpp:1151
QSize size
the size of the widget excluding any window frame
Definition: qwidget.h:165
virtual Type type() const =0
void clear()
Removes all items from the list.
Definition: qlist.h:764
bool windowStaysOnTop(QMdiSubWindow *subWindow) const
Definition: qmdiarea_p.h:242
bool ignoreGeometryChange
Definition: qmdiarea_p.h:175
void show()
Shows the widget and its child widgets.
bool isOpaque() const
Returns true if the brush is fully opaque otherwise false.
Definition: qbrush.cpp:910
The QShowEvent class provides an event that is sent when a widget is shown.
Definition: qevent.h:380
void setTabEnabled(int index, bool)
If enabled is true then the tab at position index is enabled; otherwise the item at position index is...
Definition: qtabbar.cpp:989
Qt::MouseButton button() const
Returns the button that caused the event.
Definition: qevent.h:101
void setupViewport(QWidget *viewport)
This slot is called by QAbstractScrollArea after setViewport() has been called.
Definition: qmdiarea.cpp:2722
void activateHighlightedWindow()
Definition: qmdiarea.cpp:1056
void qSort(RandomAccessIterator start, RandomAccessIterator end)
Definition: qalgorithms.h:177
bool contains(const QPoint &p, bool proper=false) const
Returns true if the given point is inside or on the edge of the rectangle, otherwise returns false...
Definition: qrect.cpp:1101
void setMovable(bool movable)
Definition: qtabbar.cpp:2299
QTabWidget::TabShape tabShape
Definition: qmdiarea_p.h:172
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
static bool useScrollBar(const QRect &childrenRect, const QSize &maxViewportSize, Qt::Orientation orientation)
Definition: qmdiarea.cpp:245
QRubberBand * rubberBand
Definition: qmdiarea_p.h:153
static QWidget * parentWidget(const QWidget *w)
bool isMaximized() const
Definition: qwidget.cpp:3074
virtual bool eventFilter(QObject *, QEvent *)
Filters events if this object has been installed as an event filter for the watched object...
Definition: qobject.cpp:1375
QMdiSubWindow * nextVisibleSubWindow(int increaseFactor, QMdiArea::WindowOrder, int removed=-1, int fromIndex=-1) const
Definition: qmdiarea.cpp:1469
The QMouseEvent class contains parameters that describe a mouse event.
Definition: qevent.h:85
#define QT_NO_TABWIDGET
void setTabsMovable(bool movable)
Definition: qmdiarea.cpp:2241
void setDocumentMode(bool enabled)
Definition: qmdiarea.cpp:2185
Qt::LayoutDirection layoutDirection
the layout direction for this widget
Definition: qwidget.h:216
static void getCandidatePlacements(const QSize &size, const QList< QRect > &rects, const QRect &domain, QList< QRect > &candidates)
Gets candidates for the final placement.
Definition: qmdiarea.cpp:474
static QDesktopWidget * desktop()
Returns the desktop widget (also called the root window).
The QChildEvent class contains event parameters for child object events.
Definition: qcoreevent.h:353
static void keyPress(QWidget *widget, char key, Qt::KeyboardModifiers modifier=Qt::NoModifier, int delay=-1)
QAction * exec()
Executes this menu synchronously.
Definition: qmenu.cpp:2101
virtual bool viewportEvent(QEvent *)
The main event handler for the scrolling area (the viewport() widget).
The QBrush class defines the fill pattern of shapes drawn by QPainter.
Definition: qbrush.h:76
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
Disconnects signal in object sender from method in object receiver.
Definition: qobject.cpp:2895
void setVerticalScrollBarPolicy(Qt::ScrollBarPolicy)
QList< QMdiSubWindow * > subWindowList(QMdiArea::WindowOrder, bool reversed=false) const
Definition: qmdiarea.cpp:1413
void setFocus()
Gives the keyboard input focus to this widget (or its focus proxy) if this widget or one of its paren...
Definition: qwidget.h:432
QMdiSubWindow * activeSubWindow() const
Returns a pointer to the current active subwindow.
Definition: qmdiarea.cpp:1832
void setViewMode(ViewMode mode)
Definition: qmdiarea.cpp:2160
~QMdiArea()
Destroys the MDI area.
Definition: qmdiarea.cpp:1730
void activateNextSubWindow()
Gives the keyboard focus to another window in the list of child windows.
Definition: qmdiarea.cpp:1927
#define Q_ASSERT_X(cond, where, what)
Definition: qglobal.h:1837
void setActiveSubWindow(QMdiSubWindow *window)
Activates the subwindow window.
Definition: qmdiarea.cpp:1844
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
void place(QMdi::Placer *placer, QMdiSubWindow *child)
Definition: qmdiarea.cpp:907
int right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:246
int indexOf(const T &t, int from=0) const
Returns the index position of the first occurrence of value in the list, searching forward from index...
Definition: qlist.h:847
void resize(int w, int h)
This corresponds to resize(QSize(w, h)).
Definition: qwidget.h:1014
Qt::LayoutDirection layoutDirection() const
QSize sizeHint() const
Reimplemented Function
Definition: qscrollbar.cpp:490
static void findNonInsiders(const QRect &domain, QList< QRect > &source, QList< QRect > &result)
Finds all rectangles in &#39;source&#39; not completely inside &#39;domain&#39;.
Definition: qmdiarea.cpp:506
void rearrange(QList< QWidget *> &widgets, const QRect &domain) const
Definition: qmdiarea.cpp:308
The QTimerEvent class contains parameters that describe a timer event.
Definition: qcoreevent.h:341
QRect rect
the internal geometry of the widget excluding any window frame
Definition: qwidget.h:168
static QCoreApplication * instance()
Returns a pointer to the application&#39;s QCoreApplication (or QApplication) instance.
const QSize & size() const
Returns the new size of the widget.
Definition: qevent.h:355
void timerEvent(QTimerEvent *timerEvent)
Reimplemented Function
Definition: qmdiarea.cpp:2379
QList< int > indicesToActivatedChildren
Definition: qmdiarea_p.h:159
void setWidget(QWidget *widget)
Sets widget as the internal widget of this subwindow.
void childEvent(QChildEvent *childEvent)
Reimplemented Function
Definition: qmdiarea.cpp:2315
ScrollBarPolicy
Definition: qnamespace.h:1420
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
void showEvent(QShowEvent *showEvent)
Reimplemented Function
Definition: qmdiarea.cpp:2403
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
QVector< QRect > rects() const
Returns an array of non-overlapping rectangles that make up the region.
Definition: qregion.cpp:4412
void setFrameStyle(int)
Sets the frame style to style.
Definition: qframe.cpp:329
void installEventFilter(QObject *)
Installs an event filter filterObj on this object.
Definition: qobject.cpp:2070
QPointer< QMenu > systemMenu
bool event(QEvent *event)
Reimplemented Function
Definition: qmdiarea.cpp:2532
#define QT_NO_RUBBERBAND
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
void _q_deactivateAllWindows(QMdiSubWindow *aboutToActivate=0)
Definition: qmdiarea.cpp:737
WindowOrder
Specifies the criteria to use for ordering the list of child windows returned by subWindowList().
Definition: qmdiarea.h:82
static QRect findMinOverlapRect(const QList< QRect > &source, const QList< QRect > &rects)
Finds among &#39;source&#39; the rectangle with the minimum accumulated overlap with the rectangles in &#39;rects...
Definition: qmdiarea.cpp:453
void setWidth(int w)
Sets the width of the rectangle to the given width.
Definition: qrect.h:442
int & rheight()
Returns a reference to the height.
Definition: qsize.h:144
void resetActiveWindow(QMdiSubWindow *child=0)
Definition: qmdiarea.cpp:1126
QSize minimumSizeHint() const
Reimplemented Function
int height() const
Returns the height.
Definition: qsize.h:129
static int accumulatedOverlap(const QRect &source, const QList< QRect > &rects)
Calculates the accumulated overlap (intersection area) between &#39;source&#39; and &#39;rects&#39;.
Definition: qmdiarea.cpp:434
if(void) toggleToolbarShown
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
bool isValid() const
Returns true if both the width and height is equal to or greater than 0; otherwise returns false...
Definition: qsize.h:123
bool isExplicitlyDeactivated(QMdiSubWindow *subWindow) const
Definition: qmdiarea_p.h:249
void setTabPosition(QTabWidget::TabPosition position)
Definition: qmdiarea.cpp:2301
QSize minimumSize() const
QString qt_setWindowTitle_helperHelper(const QString &, const QWidget *)
Returns a modified window title with the [*] place holder replaced according to the rules described i...
Definition: qwidget.cpp:6240
const QObjectList & children() const
Returns a list of child objects.
Definition: qobject.h:197
static QTabBar::Shape tabBarShapeFrom(QTabWidget::TabShape shape, QTabWidget::TabPosition position)
Definition: qmdiarea.cpp:274
QSize sizeHint() const
Reimplemented Function
Definition: qmdiarea.cpp:1749
static void setIndex(int *index, int candidate, int min, int max, bool isIncreasing)
Definition: qmdiarea.cpp:226
bool testOption(AreaOption opton) const
Returns true if option is enabled; otherwise returns false.
Definition: qmdiarea.cpp:2137
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
void setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
Definition: qwidget.cpp:11087
void _q_processWindowStateChanged(Qt::WindowStates oldState, Qt::WindowStates newState)
Definition: qmdiarea.cpp:773
quint16 index
void _q_moveTab(int from, int to)
Definition: qmdiarea.cpp:841
QWidget * window() const
Returns the window for this widget, i.e.
Definition: qwidget.cpp:4492
bool isMinimized() const
Definition: qwidget.cpp:3027
QObject * parent
Definition: qobject.h:92
bool documentMode() const
bool isLeftToRight() const
Definition: qwidget.h:429
bool event(QEvent *)
Reimplemented Function
QPoint place(const QSize &size, const QList< QRect > &rects, const QRect &domain) const
Places the rectangle defined by &#39;size&#39; relative to &#39;rects&#39; and &#39;domain&#39; so that it overlaps &#39;rects&#39; a...
Definition: qmdiarea.cpp:577
void setTabsClosable(bool closable)
Definition: qmdiarea.cpp:2213
void tileSubWindows()
Arranges all child windows in a tile pattern.
Definition: qmdiarea.cpp:2508
AreaOption
This enum describes options that customize the behavior of the QMdiArea.
Definition: qmdiarea.h:77
void highlightNextSubWindow(int increaseFactor)
Definition: qmdiarea.cpp:1523
QMdiSubWindow * addSubWindow(QWidget *widget, Qt::WindowFlags flags=0)
Adds widget as a new subwindow to the MDI area.
Definition: qmdiarea.cpp:1979
void ignore()
Clears the accept flag parameter of the event object, the equivalent of calling setAccepted(false).
Definition: qcoreevent.h:310
void hideRubberBand()
Definition: qmdiarea_p.h:272
QMdiAreaTabBar(QWidget *parent)
Definition: qmdiarea.cpp:596
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
QSize sizeHint
the recommended size for the widget
Definition: qwidget.h:195
Qt::WindowType windowType() const
Returns the window type of this widget.
Definition: qwidget.h:937
void setViewport(QWidget *widget)
Sets the viewport to be the given widget.
void updateScrollBars()
Definition: qmdiarea.cpp:1201
void rearrange(QList< QWidget *> &widgets, const QRect &domain) const
Definition: qmdiarea.cpp:399
bool close()
Closes this widget.
Definition: qwidget.cpp:8305
The QTabWidget class provides a stack of tabbed widgets.
Definition: qtabwidget.h:60
Shape shape() const
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
const QPoint & globalPos() const
Returns the global position of the mouse pointer at the time of the event.
Definition: qevent.h:413
QMdi::Rearranger * iconTiler
Definition: qmdiarea_p.h:150
Qt::WindowFlags windowFlags() const
Window flags are a combination of a type (e.
Definition: qwidget.h:939
void arrangeMinimizedSubWindows()
Arranges all minimized windows at the bottom of the workspace.
Definition: qmdiarea.cpp:1012
QList< T > values() const
Definition: qset.h:232
void updateTabBarGeometry()
Definition: qmdiarea.cpp:1641
QRect resizeToMinimumTileSize(const QSize &minSubWindowSize, int subWindowCount)
Definition: qmdiarea.cpp:1294
bool isEmpty() const
Returns true if either of the width and height is less than or equal to 0; otherwise returns false...
Definition: qsize.h:120
bool isSubWindowsTiled
Definition: qmdiarea_p.h:178
bool inViewModeChange
Definition: qmdiarea_p.h:182
void setChildActivationEnabled(bool enable=true, bool onlyNextActivationEvent=false) const
Definition: qmdiarea.cpp:1380
bool tabsClosable() const
bool isValid() const
Returns true if the rectangle is valid, otherwise returns false.
Definition: qrect.h:237
int height() const
Returns the height of the font.
const QRect & geometry() const
int currentIndex() const
The QPaintEvent class contains event parameters for paint events.
Definition: qevent.h:298
WindowOrder activationOrder() const
void setBackground(const QBrush &background)
Definition: qmdiarea.cpp:2079
Orientation
Definition: qnamespace.h:174
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56
The QRubberBand class provides a rectangle or line that can indicate a selection or a boundary...
Definition: qrubberband.h:58
static QString tabTextFor(QMdiSubWindow *subWindow)
Definition: qmdiarea.cpp:289
Type type() const
Returns the event type.
Definition: qcoreevent.h:303
QTabWidget::TabPosition tabPosition
Definition: qmdiarea_p.h:173
int addTab(const QString &text)
Adds a new tab with text text.
Definition: qtabbar.cpp:819
QMdi::Placer * placer
Definition: qmdiarea_p.h:151
#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
qreal qSqrt(qreal v)
Definition: qmath.h:205
void cascadeSubWindows()
Arranges all the child windows in a cascade pattern.
Definition: qmdiarea.cpp:2521
SubWindowOption
This enum describes options that customize the behavior of QMdiSubWindow.
Definition: qmdisubwindow.h:66
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137
QMdiArea::WindowOrder activationOrder
Definition: qmdiarea_p.h:163
static void findMaxOverlappers(const QRect &domain, const QList< QRect > &source, QList< QRect > &result)
Finds all rectangles in &#39;source&#39; that overlaps &#39;domain&#39; by the maximum overlap area between &#39;domain&#39; ...
Definition: qmdiarea.cpp:527
void emitWindowActivated(QMdiSubWindow *child)
Definition: qmdiarea.cpp:1074
int indexToLastActiveTab
Definition: qmdiarea_p.h:186
QMdiArea(QWidget *parent=0)
Constructs an empty mdi area.
Definition: qmdiarea.cpp:1715
QSize minimumSizeHint() const
Reimplemented Function
The QMdiSubWindow class provides a subwindow class for QMdiArea.
Definition: qmdisubwindow.h:60
TabShape
This enum type defines the shape of the tabs:
Definition: qtabwidget.h:126
#define QT_NO_TABBAR
QObject * child() const
Returns the child object that was added or removed.
Definition: qcoreevent.h:358
void fillRect(const QRectF &, const QBrush &)
Fills the given rectangle with the brush specified.
Definition: qpainter.cpp:7420
int & rwidth()
Returns a reference to the width.
Definition: qsize.h:141
static QPoint findBestPlacement(const QRect &domain, const QList< QRect > &rects, QList< QRect > &source)
Finds among the rectangles in &#39;source&#39; the best placement.
Definition: qmdiarea.cpp:553
bool tabsMovable() const
void setFocusPolicy(Qt::FocusPolicy policy)
Definition: qwidget.cpp:7631
void setActivationOrder(WindowOrder order)
Definition: qmdiarea.cpp:2110
static int area(const QSize &s)
Definition: qicon.cpp:155
void killTimer(int id)
Kills the timer with timer identifier, id.
Definition: qobject.cpp:1650
int tabToPreviousTimerId
Definition: qmdiarea_p.h:188