123#include <QApplication>
125#include <QChildEvent>
126#include <QResizeEvent>
128#include <QtAlgorithms>
130#include <QFontMetrics>
131#include <QStyleOption>
137#include <private/qlayoutengine_p.h>
150 const char error[] =
"null pointer";
161 const char error[] =
"index out of range";
167 const char error[] =
"null pointer";
175static void setIndex(
int *
index,
int candidate,
int min,
int max,
bool isIncreasing)
198 return childrenRect.
width() > maxViewportSize.width()
199 || childrenRect.
left() < 0
200 || childrenRect.
right() >= maxViewportSize.width();
202 return childrenRect.
height() > maxViewportSize.height()
203 || childrenRect.
top() < 0
204 || childrenRect.
bottom() >= maxViewportSize.height();
222#if QT_CONFIG(tabwidget)
232 if (subWindow->isWindowModified()) {
252 const int nrows =
qMax((
n % ncols) ? (
n / ncols + 1) : (
n / ncols), 1);
253 const int nspecial = (
n % ncols) ? (ncols -
n % ncols) : 0;
254 const int dx = domain.
width() / ncols;
255 const int dy = domain.
height() / nrows;
259 const int y1 = int(
row * (dy + 1));
260 for (
int col = 0; col < ncols; ++col) {
261 if (
row == 1 && col < nspecial)
263 const int x1 = int(col * (dx + 1));
264 int x2 = int(
x1 + dx);
265 int y2 = int(
y1 + dy);
266 if (
row == 0 && col < nspecial) {
273 if (col == ncols - 1 &&
x2 != domain.
right())
295 const int topOffset = 0;
296 const int bottomOffset = 50;
305 const int dy =
qMax(titleBarHeight - (titleBarHeight -
fontMetrics.height()) / 2, 1)
309 const int nrows =
qMax((domain.
height() - (topOffset + bottomOffset)) / dy, 1);
310 const int ncols =
qMax(
n / nrows + ((
n % nrows) ? 1 : 0), 1);
315 for (
int col = 0; col < ncols; ++col) {
317 const int y = topOffset +
row * dy;
341 const int nrows =
n / ncols + ((
n % ncols) ? 1 : 0);
345 for (
int col = 0; col < ncols; ++col) {
346 const int x = col *
width;
364int MinOverlapPlacer::accumulatedOverlap(
const QRect &
source,
const QList<QRect> &rects)
369 accOverlap += intersection.
width() * intersection.
height();
380QRect MinOverlapPlacer::findMinOverlapRect(
const QList<QRect> &
source,
const QList<QRect> &rects)
382 int minAccOverlap = -1;
383 QRect minAccOverlapRect;
385 const int accOverlap = accumulatedOverlap(srcRect, rects);
386 if (accOverlap < minAccOverlap || minAccOverlap == -1) {
387 minAccOverlap = accOverlap;
388 minAccOverlapRect = srcRect;
391 return minAccOverlapRect;
398QList<QRect> MinOverlapPlacer::getCandidatePlacements(
const QSize &
size,
const QList<QRect> &rects,
404 xlist.reserve(2 + rects.size());
408 ylist.reserve(2 + rects.size());
409 ylist << domain.
top();
414 xlist <<
rect.right() + 1;
415 ylist <<
rect.bottom() + 1;
418 std::sort(xlist.begin(), xlist.end());
419 xlist.erase(std::unique(xlist.begin(), xlist.end()), xlist.end());
421 std::sort(ylist.begin(), ylist.end());
422 ylist.erase(std::unique(ylist.begin(), ylist.end()), ylist.end());
424 result.reserve(ylist.size() * xlist.size());
425 for (
int y :
std::as_const(ylist))
426 for (int
x :
std::as_const(xlist))
436QList<QRect> MinOverlapPlacer::findNonInsiders(
const QRect &domain, QList<QRect> &
source)
438 const auto containedInDomain =
439 [domain](
const QRect &srcRect) {
return domain.
contains(srcRect); };
441 const auto firstOut = std::stable_partition(
source.begin(),
source.end(), containedInDomain);
445 std::copy(firstOut,
source.end(), std::back_inserter(
result));
457QList<QRect> MinOverlapPlacer::findMaxOverlappers(
const QRect &domain,
const QList<QRect> &
source)
465 const int overlap = intersection.
width() * intersection.
height();
466 if (overlap >= maxOverlap || maxOverlap == -1) {
467 if (overlap > maxOverlap) {
468 maxOverlap = overlap;
484QPoint MinOverlapPlacer::findBestPlacement(
const QRect &domain,
const QList<QRect> &rects,
487 const QList<QRect> nonInsiders = findNonInsiders(domain,
source);
490 return findMinOverlapRect(
source, rects).topLeft();
492 QList<QRect> maxOverlappers = findMaxOverlappers(domain, nonInsiders);
493 return findMinOverlapRect(maxOverlappers, rects).topLeft();
504 const QRect &domain)
const
513 QList<QRect> candidates = getCandidatePlacements(
size, rects, domain);
514 return findBestPlacement(domain, rects, candidates);
518class QMdiAreaTabBar :
public QTabBar
525#ifndef QT_NO_CONTEXTMENU
552#ifndef QT_NO_CONTEXTMENU
558 QPointer<QMdiSubWindow> subWindow = subWindowFromIndex(tabAt(
event->pos()));
559 if (!subWindow || subWindow->isHidden()) {
566 if (!subWindowPrivate->systemMenu) {
571 QMdiSubWindow *currentSubWindow = subWindowFromIndex(currentIndex());
586 subWindowPrivate->systemMenu->exec(
event->globalPos());
591 subWindowPrivate->updateActions();
601 if (index < 0 || index >=
count())
604 QMdiArea *mdiArea = qobject_cast<QMdiArea *>(parentWidget());
607 const QList<QMdiSubWindow *> subWindows = mdiArea->
subWindowList();
631 activationOrder(
QMdiArea::CreationOrder),
642 ignoreGeometryChange(
false),
643 ignoreWindowStateChange(
false),
645 isSubWindowsTiled(
false),
646 showActiveWindowMaximized(
false),
647 tileCalledFromResizeEvent(
false),
648 updatesDisabledByUs(
false),
649 inViewModeChange(
false),
650 indexToNextWindow(-1),
651 indexToPreviousWindow(-1),
652 indexToHighlighted(-1),
653 indexToLastActiveTab(-1),
655 tabToPreviousTimerId(-1)
668 if (!aboutToActivate)
686 if (
q->updatesEnabled()) {
688 q->setUpdatesEnabled(
false);
695 child->d_func()->setActive(
false);
737#if !QT_CONFIG(tabbar)
747 if (lastActive && lastActive->isHidden())
761#if !QT_CONFIG(tabbar)
772#if !QT_CONFIG(tabbar)
818 updateTabBarGeometry();
826 child->installEventFilter(
q);
842 if (!
q->isVisible()) {
852 QRect parentRect =
q->rect();
858 QRect occupiedGeometry;
859 if (
window->isMaximized()) {
860 occupiedGeometry =
QRect(
window->d_func()->oldGeometry.topLeft(),
861 window->d_func()->restoreSize);
863 occupiedGeometry =
window->geometry();
881 if (!
q->isVisible()) {
894 QSize minSubWindowSize;
899 if (
child->isMinimized() && !
child->isShaded())
902 if (
child->isMinimized() && !
child->isShaded())
904 if (
child->isMaximized() ||
child->isShaded())
907 .expandedTo(
child->d_func()->internalMinimumSize);
916 rearranger->rearrange(
widgets, domain);
952 active->d_func()->setActive(
false);
961 if (
child->d_func()->isActive &&
active ==
nullptr)
962 child->d_func()->isActive =
false;
964 child->d_func()->setActive(
true);
974 current->d_func()->activationEnabled =
true;
975 current->d_func()->setActive(
true,
false);
989#if QT_CONFIG(rubberband)
1001 if (activeWindow ==
active)
1003 Q_ASSERT(activeWindow->d_func()->isActive);
1019 Q_ASSERT(indexToActiveWindow != -1);
1026 q->setUpdatesEnabled(
true);
1035#if QT_CONFIG(tabbar)
1036 if (
tabBar &&
tabBar->currentIndex() != indexToActiveWindow)
1037 tabBar->setCurrentIndex(indexToActiveWindow);
1052 if (deactivatedWindow) {
1053 if (deactivatedWindow !=
active)
1060 emit q->subWindowActivated(
nullptr);
1068 emit q->subWindowActivated(
nullptr);
1078#if QT_CONFIG(tabbar)
1079 if (
tabBar && removedIndex >= 0) {
1081 tabBar->removeTab(removedIndex);
1082 updateTabBarGeometry();
1093#if QT_CONFIG(rubberband)
1107 if (*
index > removedIndex)
1129 QSize maxSize =
q->maximumViewportSize();
1130 QSize hbarExtent = hbar->sizeHint();
1131 QSize vbarExtent = vbar->sizeHint();
1134 const int doubleFrameWidth = frameWidth * 2;
1136 maxSize.
rheight() -= doubleFrameWidth;
1138 maxSize.
rwidth() -= doubleFrameWidth;
1139 hbarExtent.rheight() += doubleFrameWidth;
1140 vbarExtent.rwidth() += doubleFrameWidth;
1148 if (useHorizontalScrollBar && !useVerticalScrollBar) {
1149 const QSize max = maxSize -
QSize(0, hbarExtent.height());
1153 if (useVerticalScrollBar && !useHorizontalScrollBar) {
1154 const QSize max = maxSize -
QSize(vbarExtent.width(), 0);
1159 maxSize.
rheight() -= hbarExtent.height();
1161 maxSize.
rwidth() -= vbarExtent.width();
1164 const int startX =
q->isLeftToRight() ? childrenRect.
left() : viewportRect.
right()
1165 - childrenRect.
right();
1170 const int xOffset = startX + hbar->value();
1171 hbar->setRange(
qMin(0, xOffset),
1173 hbar->setPageStep(childrenRect.
width());
1174 hbar->setSingleStep(childrenRect.
width() / 20);
1179 const int yOffset = childrenRect.
top() + vbar->value();
1180 vbar->setRange(
qMin(0, yOffset),
1182 vbar->setPageStep(childrenRect.
height());
1183 vbar->setSingleStep(childrenRect.
height() / 20);
1197 for (
QObject *
object : children) {
1202 if (stackUnderChild)
1203 child->stackUnder(stackUnderChild);
1206 stackUnderChild =
child;
1211 if (stackUnderChild)
1220 if (!minSubWindowSize.isValid() || subWindowCount <= 0)
1225 const int rows =
qMax((subWindowCount % columns) ? (subWindowCount / columns + 1)
1226 : (subWindowCount / columns), 1);
1227 const int minWidth = minSubWindowSize.width() * columns;
1228 const int minHeight = minSubWindowSize.height() * rows;
1238 int minAreaWidth = minWidth +
left +
right + 2;
1239 int minAreaHeight = minHeight +
top +
bottom + 2;
1240 if (hbar->isVisible())
1241 minAreaHeight += hbar->
height();
1242 if (vbar->isVisible())
1243 minAreaWidth += vbar->width();
1246 minAreaWidth += 2 *
frame;
1247 minAreaHeight += 2 *
frame;
1260 if (domain.
width() < minWidth) {
1268 if (domain.
height() < minHeight) {
1301 return last->d_func()->data.is_closing;
1310 if (!subWindow || !subWindow->isVisible())
1312 if (onlyNextActivationEvent)
1313 subWindow->d_func()->ignoreNextActivationEvent = !
enable;
1315 subWindow->d_func()->activationEnabled =
enable;
1343QList<QMdiSubWindow*>
1346 QList<QMdiSubWindow *>
list;
1394 subWindow->removeEventFilter(
q);
1401 int removedIndex,
int fromIndex)
const
1407 const QList<QMdiSubWindow *> subWindows =
q->subWindowList(
order);
1410 if (removedIndex < 0) {
1411 if (fromIndex >= 0 && fromIndex < subWindows.size())
1414 current =
q->currentSubWindow();
1421 int candidateIndex = -1;
1422 setIndex(&candidateIndex, removedIndex, 0, subWindows.size() - 1,
true);
1425 current = subWindows.back();
1431 const int indexToCurrent = subWindows.indexOf(current);
1432 const bool increasing = increaseFactor > 0;
1436 setIndex(&
index, indexToCurrent + increaseFactor, 0, subWindows.size() - 1, increasing);
1440 while (subWindows.at(
index)->isHidden()) {
1442 if (
index == indexToCurrent)
1446 if (!subWindows.at(
index)->isHidden())
1447 return subWindows.at(
index);
1475#if QT_CONFIG(rubberband)
1479 rubberBand->setObjectName(
"qt_rubberband"_L1);
1485#if QT_CONFIG(rubberband)
1487 showRubberBandFor(highlight);
1494#if QT_CONFIG(rubberband)
1495void QMdiAreaPrivate::showRubberBandFor(
QMdiSubWindow *subWindow)
1497 if (!subWindow || !rubberBand)
1500#if QT_CONFIG(tabbar)
1505 rubberBand->setGeometry(subWindow->geometry());
1507 rubberBand->raise();
1515void QMdiAreaPrivate::setViewMode(QMdiArea::ViewMode mode)
1518 if (viewMode ==
mode || inViewModeChange)
1522 inViewModeChange =
true;
1524#if QT_CONFIG(tabbar)
1527 tabBar =
new QMdiAreaTabBar(
q);
1528 tabBar->setDocumentMode(documentMode);
1529 tabBar->setTabsClosable(tabsClosable);
1530 tabBar->setMovable(tabsMovable);
1531#if QT_CONFIG(tabwidget)
1535 isSubWindowsTiled =
false;
1541 const auto subWindows = childWindows;
1543 tabBar->addTab(subWindow->windowIcon(),
tabTextFor(subWindow));
1547 tabBar->setCurrentIndex(childWindows.indexOf(current));
1564 updateTabBarGeometry();
1572#if QT_CONFIG(tabbar)
1578 q->setViewportMargins(0, 0, 0, 0);
1579 indexToLastActiveTab = -1;
1587 inViewModeChange =
false;
1590#if QT_CONFIG(tabbar)
1594void QMdiAreaPrivate::updateTabBarGeometry()
1600#if QT_CONFIG(tabwidget)
1605 int areaHeight =
q->height();
1606 if (hbar && hbar->isVisible())
1607 areaHeight -= hbar->height();
1609 int areaWidth =
q->width();
1610 if (vbar && vbar->isVisible())
1611 areaWidth -= vbar->width();
1614#if QT_CONFIG(tabwidget)
1615 switch (tabPosition) {
1617 q->setViewportMargins(0, tabBarSizeHint.height(), 0, 0);
1618 tabBarRect =
QRect(0, 0, areaWidth, tabBarSizeHint.height());
1621 q->setViewportMargins(0, 0, 0, tabBarSizeHint.height());
1622 tabBarRect =
QRect(0, areaHeight - tabBarSizeHint.height(), areaWidth, tabBarSizeHint.height());
1626 q->setViewportMargins(0, 0, tabBarSizeHint.width(), 0);
1628 q->setViewportMargins(tabBarSizeHint.width(), 0, 0, 0);
1629 tabBarRect =
QRect(areaWidth - tabBarSizeHint.width(), 0, tabBarSizeHint.width(), areaHeight);
1633 q->setViewportMargins(tabBarSizeHint.width(), 0, 0, 0);
1635 q->setViewportMargins(0, 0, tabBarSizeHint.width(), 0);
1636 tabBarRect =
QRect(0, 0, tabBarSizeHint.width(), areaHeight);
1649void QMdiAreaPrivate::refreshTabBar()
1654 tabBar->setDocumentMode(documentMode);
1655 tabBar->setTabsClosable(tabsClosable);
1656 tabBar->setMovable(tabsMovable);
1657#if QT_CONFIG(tabwidget)
1660 updateTabBarGeometry();
1675 setViewport(
nullptr);
1687 d->cascader =
nullptr;
1689 delete d->regularTiler;
1690 d->regularTiler =
nullptr;
1692 delete d->iconTiler;
1693 d->iconTiler =
nullptr;
1696 d->placer =
nullptr;
1706 int nestedCount = 0;
1709 if (qobject_cast<QMdiArea *>(
widget))
1713 const int scaleFactor = 3 * (nestedCount + 1);
1716 QSize size(desktopSize.width() * 2 / scaleFactor, desktopSize.height() * 2 / scaleFactor);
1733 size =
size.expandedTo(QAbstractScrollArea::minimumSizeHint());
1734 if (!
d->scrollBarsEnabled()) {
1756 if (
d->childWindows.isEmpty())
1762 if (
d->isActivated && !
window()->isMinimized())
1765 Q_ASSERT(
d->indicesToActivatedChildren.size() > 0);
1766 int index =
d->indicesToActivatedChildren.at(0);
1801 d->activateWindow(
nullptr);
1806 qWarning(
"QMdiArea::setActiveSubWindow: workspace is empty");
1811 qWarning(
"QMdiArea::setActiveSubWindow: window is not inside workspace");
1844 return d->subWindowList(
order,
false);
1860 if (
d->childWindows.isEmpty())
1863 d->isSubWindowsTiled =
false;
1867 const auto subWindows =
d->childWindows;
1874 d->updateScrollBars();
1887 if (
d->childWindows.isEmpty())
1892 d->activateWindow(
next);
1905 if (
d->childWindows.isEmpty())
1908 QMdiSubWindow *previous =
d->nextVisibleSubWindow(-1,
d->activationOrder);
1939 qWarning(
"QMdiArea::addSubWindow: null pointer to widget");
1951 qWarning(
"QMdiArea::addSubWindow: window is already added");
1966 childFocus->setFocus();
1984 qWarning(
"QMdiArea::removeSubWindow: null pointer to widget");
1989 if (
d->childWindows.isEmpty())
1995 qWarning(
"QMdiArea::removeSubWindow: window is not inside workspace");
1998 d->disconnectSubWindow(
child);
1999 d->childWindows.removeAll(
child);
2000 d->indicesToActivatedChildren.removeAll(
index);
2002 child->setParent(
nullptr);
2010 const auto subWindows =
d->childWindows;
2015 child->setWidget(
nullptr);
2023 qWarning(
"QMdiArea::removeSubWindow: widget is not child of any window inside QMdiArea");
2036 return d_func()->background;
2042 if (
d->background !=
brush) {
2045 d->viewport->update();
2064 return d->activationOrder;
2070 if (
order !=
d->activationOrder)
2071 d->activationOrder =
order;
2083 d->options.setFlag(
option, on);
2093 return d_func()->options &
option;
2114 d->setViewMode(
mode);
2117#if QT_CONFIG(tabbar)
2127bool QMdiArea::documentMode()
const
2130 return d->documentMode;
2133void QMdiArea::setDocumentMode(
bool enabled)
2152bool QMdiArea::tabsClosable()
const
2155 return d->tabsClosable;
2158void QMdiArea::setTabsClosable(
bool closable)
2161 if (
d->tabsClosable == closable)
2164 d->tabsClosable = closable;
2177bool QMdiArea::tabsMovable()
const
2180 return d->tabsMovable;
2183void QMdiArea::setTabsMovable(
bool movable)
2186 if (
d->tabsMovable == movable)
2189 d->tabsMovable = movable;
2194#if QT_CONFIG(tabwidget)
2214 if (
d->tabShape == shape)
2217 d->tabShape = shape;
2234 return d->tabPosition;
2256 if (
d->childWindows.indexOf(mdiChild) == -1)
2257 d->appendChild(mdiChild);
2268 if (
d->childWindows.isEmpty()) {
2273#if QT_CONFIG(tabbar)
2274 d->updateTabBarGeometry();
2280 if (
d->isSubWindowsTiled) {
2281 d->tileCalledFromResizeEvent =
true;
2283 d->tileCalledFromResizeEvent =
false;
2284 d->isSubWindowsTiled =
true;
2285 d->startResizeTimer();
2291 bool hasMaximizedSubWindow =
false;
2295 const auto subWindows =
d->childWindows;
2300 const auto minSizeHint =
child->minimumSizeHint();
2304 if (minSizeHint.isValid())
2305 realSize = realSize.expandedTo(minSizeHint);
2306 child->resize(realSize);
2307 if (!hasMaximizedSubWindow)
2308 hasMaximizedSubWindow =
true;
2312 d->updateScrollBars();
2317 if (hasMaximizedSubWindow)
2318 d->startResizeTimer();
2320 d->arrangeMinimizedSubWindows();
2330 killTimer(
d->resizeTimerId);
2331 d->resizeTimerId = -1;
2332 d->arrangeMinimizedSubWindows();
2333 }
else if (
timerEvent->timerId() ==
d->tabToPreviousTimerId) {
2334 killTimer(
d->tabToPreviousTimerId);
2335 d->tabToPreviousTimerId = -1;
2336 if (
d->indexToHighlighted < 0)
2338#if QT_CONFIG(rubberband)
2340 Q_ASSERT(
d->indexToHighlighted <
d->childWindows.size());
2342 d->showRubberBandFor(
d->childWindows.at(
d->indexToHighlighted));
2353 if (!
d->pendingRearrangements.isEmpty()) {
2354 bool skipPlacement =
false;
2356 const auto pendingRearrange =
d->pendingRearrangements;
2357 for (
Rearranger *rearranger : pendingRearrange) {
2361 skipPlacement =
true;
2362 d->rearrange(rearranger);
2364 d->pendingRearrangements.clear();
2366 if (skipPlacement && !
d->pendingPlacements.isEmpty())
2367 d->pendingPlacements.clear();
2370 if (!
d->pendingPlacements.isEmpty()) {
2375 const auto copy =
d->pendingPlacements;
2380 d->showActiveWindowMaximized =
true;
2381 d->emitWindowActivated(
window);
2389 && !
window->isMaximized()) {
2393 d->pendingPlacements.clear();
2396 d->setChildActivationEnabled(
true);
2397 d->activateCurrentWindow();
2399 QAbstractScrollArea::showEvent(
showEvent);
2408 switch (
event->type()) {
2410 d->isSubWindowsTiled =
false;
2412 for (
int i = 0;
i <
d->childWindows.size(); ++
i) {
2421 d->showActiveWindowMaximized =
true;
2423 d->disconnectSubWindow(
child);
2424 const bool activeRemoved =
i ==
d->indicesToActivatedChildren.at(0);
2425 d->childWindows.removeAt(
i);
2426 d->indicesToActivatedChildren.removeAll(
i);
2427 d->updateActiveWindow(
i, activeRemoved);
2428 d->arrangeMinimizedSubWindows();
2432 d->updateScrollBars();
2436 d->isSubWindowsTiled =
false;
2437 d->resetActiveWindow();
2438 d->childWindows.clear();
2439 qWarning(
"QMdiArea: Deleting the view port is undefined, use setViewport instead.");
2444 return QAbstractScrollArea::viewportEvent(
event);
2453 const bool wasSubWindowsTiled =
d->isSubWindowsTiled;
2454 d->ignoreGeometryChange =
true;
2455 viewport()->scroll(isLeftToRight() ? dx : -dx, dy);
2456 d->arrangeMinimizedSubWindows();
2457 d->ignoreGeometryChange =
false;
2458 if (wasSubWindowsTiled)
2459 d->isSubWindowsTiled =
true;
2470 if (!
d->regularTiler)
2494 switch (
event->type()) {
2496 d->isActivated =
true;
2497 if (
d->childWindows.isEmpty())
2500 d->activateCurrentWindow();
2501 d->setChildActivationEnabled(
false,
true);
2505 d->isActivated =
false;
2506 d->setChildActivationEnabled(
false,
true);
2512 if (
d->isSubWindowsTiled) {
2514 d->isSubWindowsTiled =
true;
2520 const auto subWindows =
d->childWindows;
2528 d->setActive(
d->active,
false,
false);
2529 d->setChildActivationEnabled(
false);
2531#if QT_CONFIG(tabbar)
2533 d->updateTabBarGeometry();
2539 return QAbstractScrollArea::event(
event);
2548 return QAbstractScrollArea::eventFilter(
object,
event);
2557 return QAbstractScrollArea::eventFilter(
object,
event);
2562 return QAbstractScrollArea::eventFilter(
object,
event);
2570 switch (keyEvent->
key()) {
2573 area->d_func()->startTabToPreviousTimer();
2575 area->d_func()->activateHighlightedWindow();
2582#if QT_CONFIG(rubberband)
2584 area->d_func()->hideRubberBand();
2590 return QAbstractScrollArea::eventFilter(
object,
event);
2593 QMdiSubWindow *subWindow = qobject_cast<QMdiSubWindow *>(
object);
2599 d->activateCurrentWindow();
2601 d->setActive(
d->active,
false,
false);
2603 return QAbstractScrollArea::eventFilter(
object,
event);
2606 if (subWindow->mdiArea() !=
this)
2607 return QAbstractScrollArea::eventFilter(
object,
event);
2610 switch (
event->type()) {
2613 if (
d->tileCalledFromResizeEvent)
2615 d->updateScrollBars();
2616 if (!subWindow->isMinimized())
2617 d->isSubWindowsTiled =
false;
2620#if QT_CONFIG(tabbar)
2622 const int tabIndex =
d->childWindows.indexOf(subWindow);
2623 if (!
d->tabBar->isTabEnabled(tabIndex))
2624 d->tabBar->setTabEnabled(tabIndex,
true);
2632 if (!
event->spontaneous())
2633 d->isSubWindowsTiled =
false;
2635#if QT_CONFIG(rubberband)
2637 if (
d->childWindows.indexOf(subWindow) ==
d->indexToHighlighted)
2638 d->hideRubberBand();
2641#if QT_CONFIG(tabbar)
2645 d->tabBar->setTabText(
d->childWindows.indexOf(subWindow),
tabTextFor(subWindow));
2649 d->tabBar->setTabIcon(
d->childWindows.indexOf(subWindow), subWindow->windowIcon());
2655 return QAbstractScrollArea::eventFilter(
object,
event);
2683 const auto subWindows =
d->childWindows;
2693#include "moc_qmdiarea.cpp"
static QFont font()
Returns the default application font.
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
static QCoreApplication * instance() noexcept
Returns a pointer to the application's QCoreApplication (or QGuiApplication/QApplication) instance.
\reentrant \inmodule QtGui
QScreen * primaryScreen
the primary (or default) screen of the application.
The QKeyEvent class describes a key event.
Qt::KeyboardModifiers modifiers() const
Returns the keyboard modifier flags that existed immediately after the event occurred.
int key() const
Returns the code of the key that was pressed or released.
virtual QSize minimumSize() const =0
Implemented in subclasses to return the minimum size of this item.
virtual void setGeometry(const QRect &)=0
Implemented in subclasses to set this item's geometry to r.
virtual QWidget * widget() const
If this item manages a QWidget, returns that widget.
virtual QSize sizeHint() const =0
Implemented in subclasses to return the preferred size of this item.
qsizetype size() const noexcept
bool isEmpty() const noexcept
const_reference at(qsizetype i) const noexcept
void move(qsizetype from, qsizetype to)
void prepend(rvalue_ref t)
void append(parameter_type t)
void internalRaise(QMdiSubWindow *child) const
void place(QMdi::Placer *placer, QMdiSubWindow *child)
void resetActiveWindow(QMdiSubWindow *child=nullptr)
QPointer< QMdiSubWindow > aboutToBecomeActive
void activateCurrentWindow()
QList< int > indicesToActivatedChildren
bool scrollBarsEnabled() const
void appendChild(QMdiSubWindow *child)
void activateHighlightedWindow()
void emitWindowActivated(QMdiSubWindow *child)
QMdi::Rearranger * iconTiler
QPointer< QMdiSubWindow > active
QList< QMdiSubWindow * > subWindowList(QMdiArea::WindowOrder, bool reversed=false) const
QRect resizeToMinimumTileSize(const QSize &minSubWindowSize, int subWindowCount)
QMdiArea::WindowOrder activationOrder
bool isExplicitlyDeactivated(QMdiSubWindow *subWindow) const
void arrangeMinimizedSubWindows()
bool lastWindowAboutToBeDestroyed() const
bool ignoreGeometryChange
void activateWindow(QMdiSubWindow *child)
void highlightNextSubWindow(int increaseFactor)
QList< QMdi::Rearranger * > pendingRearrangements
QMdiArea::AreaOptions options
bool tileCalledFromResizeEvent
void disconnectSubWindow(QObject *subWindow)
void _q_moveTab(int from, int to)
bool windowStaysOnTop(QMdiSubWindow *subWindow) const
QList< QPointer< QMdiSubWindow > > pendingPlacements
bool ignoreWindowStateChange
void _q_currentTabChanged(int index)
QList< QPointer< QMdiSubWindow > > childWindows
void _q_deactivateAllWindows(QMdiSubWindow *aboutToActivate=nullptr)
void scrollBarPolicyChanged(Qt::Orientation, Qt::ScrollBarPolicy) override
bool showActiveWindowMaximized
QMdiArea::ViewMode viewMode
void updateActiveWindow(int removedIndex, bool activeRemoved)
void rearrange(QMdi::Rearranger *rearranger)
void setChildActivationEnabled(bool enable=true, bool onlyNextActivationEvent=false) const
void _q_closeTab(int index)
void _q_processWindowStateChanged(Qt::WindowStates oldState, Qt::WindowStates newState)
QMdiSubWindow * nextVisibleSubWindow(int increaseFactor, QMdiArea::WindowOrder, int removed=-1, int fromIndex=-1) const
The QMdiArea widget provides an area in which MDI windows are displayed.
bool eventFilter(QObject *object, QEvent *event) override
\reimp
WindowOrder activationOrder
the ordering criteria for subwindow lists
bool testOption(AreaOption opton) const
Returns true if option is enabled; otherwise returns false.
void setActivationOrder(WindowOrder order)
QBrush background
the background brush for the workspace
void childEvent(QChildEvent *childEvent) override
\reimp
QMdiSubWindow * addSubWindow(QWidget *widget, Qt::WindowFlags flags=Qt::WindowFlags())
Adds widget as a new subwindow to the MDI area.
void setViewMode(ViewMode mode)
bool viewportEvent(QEvent *event) override
\reimp
void setBackground(const QBrush &background)
void closeActiveSubWindow()
Closes the active subwindow.
ViewMode viewMode
the way sub-windows are displayed in the QMdiArea.
void activateNextSubWindow()
Gives the keyboard focus to another window in the list of child windows.
QMdiArea(QWidget *parent=nullptr)
Constructs an empty mdi area.
WindowOrder
Specifies the criteria to use for ordering the list of child windows returned by subWindowList().
QMdiSubWindow * activeSubWindow() const
Returns a pointer to the current active subwindow.
void cascadeSubWindows()
Arranges all the child windows in a cascade pattern.
void showEvent(QShowEvent *showEvent) override
\reimp
void setOption(AreaOption option, bool on=true)
If on is true, option is enabled on the MDI area; otherwise it is disabled.
void closeAllSubWindows()
Closes all subwindows by sending a QCloseEvent to each window.
bool event(QEvent *event) override
\reimp
void tileSubWindows()
Arranges all child windows in a tile pattern.
void activatePreviousSubWindow()
Gives the keyboard focus to another window in the list of child windows.
~QMdiArea()
Destroys the MDI area.
QSize sizeHint() const override
\reimp
QSize minimumSizeHint() const override
\reimp
QMdiSubWindow * currentSubWindow() const
Returns a pointer to the current subwindow, or \nullptr if there is no current subwindow.
void setupViewport(QWidget *viewport) override
This slot is called by QAbstractScrollArea after setViewport() has been called.
void timerEvent(QTimerEvent *timerEvent) override
\reimp
void scrollContentsBy(int dx, int dy) override
\reimp
void paintEvent(QPaintEvent *paintEvent) override
\reimp
void removeSubWindow(QWidget *widget)
Removes widget from the MDI area.
QList< QMdiSubWindow * > subWindowList(WindowOrder order=CreationOrder) const
Returns a list of all subwindows in the MDI area.
AreaOption
This enum describes options that customize the behavior of the QMdiArea.
@ DontMaximizeSubWindowOnActivation
void resizeEvent(QResizeEvent *resizeEvent) override
\reimp
void setActiveSubWindow(QMdiSubWindow *window)
Activates the subwindow window.
The QMdiSubWindow class provides a subwindow class for QMdiArea.
SubWindowOption
This enum describes options that customize the behavior of QMdiSubWindow.
@ AllowOutsideAreaHorizontally
@ AllowOutsideAreaVertically
void rearrange(QList< QWidget * > &widgets, const QRect &domain) const override
QPoint place(const QSize &size, const QList< QRect > &rects, const QRect &domain) const override
virtual QPoint place(const QSize &size, const QList< QRect > &rects, const QRect &domain) const =0
void rearrange(QList< QWidget * > &widgets, const QRect &domain) const override
void rearrange(QList< QWidget * > &widgets, const QRect &domain) const override
const QObjectList & children() const
Returns a list of child objects.
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
\threadsafe
The QPaintEvent class contains event parameters for paint events.
The QPainter class performs low-level painting on widgets and other paint devices.
void fillRect(const QRectF &, const QBrush &)
Fills the given rectangle with the brush specified.
\inmodule QtCore\reentrant
constexpr int x() const noexcept
Returns the x coordinate of this point.
constexpr int y() const noexcept
Returns the y coordinate of this point.
\inmodule QtCore\reentrant
constexpr int height() const noexcept
Returns the height of the rectangle.
constexpr bool isValid() const noexcept
Returns true if the rectangle is valid, otherwise returns false.
QRect intersected(const QRect &other) const noexcept
constexpr int bottom() const noexcept
Returns the y-coordinate of the rectangle's bottom edge.
constexpr int top() const noexcept
Returns the y-coordinate of the rectangle's top edge.
bool contains(const QRect &r, bool proper=false) const noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
constexpr int left() const noexcept
Returns the x-coordinate of the rectangle's left edge.
constexpr void setWidth(int w) noexcept
Sets the width of the rectangle to the given width.
constexpr int width() const noexcept
Returns the width of the rectangle.
constexpr void setHeight(int h) noexcept
Sets the height of the rectangle to the given height.
constexpr int right() const noexcept
Returns the x-coordinate of the rectangle's right edge.
The QResizeEvent class contains event parameters for resize events.
The QRubberBand class provides a rectangle or line that can indicate a selection or a boundary.
QSize virtualSize
the pixel size of the virtual desktop to which this screen belongs
The QShowEvent class provides an event that is sent when a widget is shown.
Exception-safe wrapper around QObject::blockSignals().
constexpr int height() const noexcept
Returns the height.
constexpr int width() const noexcept
Returns the width.
constexpr int & rheight() noexcept
Returns a reference to the height.
constexpr QSize expandedTo(const QSize &) const noexcept
Returns a size holding the maximum width and height of this size and the given otherSize.
constexpr int & rwidth() noexcept
Returns a reference to the width.
\macro QT_RESTRICTED_CAST_FROM_ASCII
QString & replace(qsizetype i, qsizetype len, QChar after)
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
\variable QStyleOptionToolBox::selectedPosition
void initFrom(const QWidget *w)
@ SH_ScrollView_FrameOnlyAroundContents
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.
@ PM_MdiSubWindowMinimizedWidth
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=nullptr, const QWidget *widget=nullptr) const =0
Returns the value of the given pixel metric.
The QTabBar class provides a tab bar, e.g.
void mousePressEvent(QMouseEvent *) override
\reimp
Shape
This enum type lists the built-in shapes supported by QTabBar.
for(qsizetype i=0;i< list.size();++i)
void newState(QList< State > &states, const char *token, const char *lexem, bool pre)
Combined button and popup list for selecting options.
static jboolean copy(JNIEnv *, jobject)
DBusConnection const char DBusError * error
qfloat16 qSqrt(qfloat16 f)
static int area(const QSize &s)
Q_WIDGETS_EXPORT QSize qSmartMinSize(const QSize &sizeHint, const QSize &minSizeHint, const QSize &minSize, const QSize &maxSize, const QSizePolicy &sizePolicy)
static const double leftOffset
static const double rightOffset
static QString tabTextFor(QMdiSubWindow *subWindow)
static bool sanityCheck(const QMdiSubWindow *const child, const char *where)
static QMdiArea * mdiAreaParent(QWidget *widget)
static bool useScrollBar(const QRect &childrenRect, const QSize &maxViewportSize, Qt::Orientation orientation)
static void setIndex(int *index, int candidate, int min, int max, bool isIncreasing)
constexpr const T & qMin(const T &a, const T &b)
constexpr const T & qMax(const T &a, const T &b)
GLint GLint GLint GLint GLint x
[0]
GLint GLsizei GLsizei height
GLuint GLfloat GLfloat GLfloat GLfloat y1
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLuint GLfloat GLfloat GLfloat x1
GLdouble GLdouble GLdouble GLdouble top
GLenum GLenum GLsizei count
GLenum GLenum GLsizei const GLuint GLboolean enabled
GLsizei GLsizei GLchar * source
GLfixed GLfixed GLfixed y2
GLdouble GLdouble GLdouble GLdouble q
GLenum GLenum GLsizei void * row
GLfixed GLfixed GLint GLint order
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
#define Q_ASSERT_X(cond, x, msg)
#define QT_CONFIG(feature)
if(qFloatDistance(a, b)<(1<< 7))
[0]
QList< QWidget * > widgets
[11]
view viewport() -> scroll(dx, dy, deviceRect)
qsizetype indexOf(const AT &t, qsizetype from=0) const noexcept
bool contains(const AT &t) const noexcept