| Line | Source Code | Coverage |
|---|
| 1 | /**************************************************************************** | - |
| | ** | |
| | ** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). | |
| | ** Contact: http://www.qt-project.org/legal | |
| | ** | |
| | ** This file is part of the QtGui module of the Qt Toolkit. | |
| | ** | |
| | ** $QT_BEGIN_LICENSE:LGPL$ | |
| | ** Commercial License Usage | |
| | ** Licensees holding valid commercial Qt licenses may use this file in | |
| | ** accordance with the commercial license agreement provided with the | |
| | ** Software or, alternatively, in accordance with the terms contained in | |
| | ** a written agreement between you and Digia. For licensing terms and | |
| | ** conditions see http://qt.digia.com/licensing. For further information | |
| | ** use the contact form at http://qt.digia.com/contact-us. | |
| | ** | |
| | ** GNU Lesser General Public License Usage | |
| | ** Alternatively, this file may be used under the terms of the GNU Lesser | |
| | ** General Public License version 2.1 as published by the Free Software | |
| | ** Foundation and appearing in the file LICENSE.LGPL included in the | |
| | ** packaging of this file. Please review the following information to | |
| | ** ensure the GNU Lesser General Public License version 2.1 requirements | |
| | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | |
| | ** | |
| | ** In addition, as a special exception, Digia gives you certain additional | |
| | ** rights. These rights are described in the Digia Qt LGPL Exception | |
| | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | |
| | ** | |
| | ** GNU General Public License Usage | |
| | ** Alternatively, this file may be used under the terms of the GNU | |
| | ** General Public License version 3.0 as published by the Free Software | |
| | ** Foundation and appearing in the file LICENSE.GPL included in the | |
| | ** packaging of this file. Please review the following information to | |
| | ** ensure the GNU General Public License version 3.0 requirements will be | |
| | ** met: http://www.gnu.org/copyleft/gpl.html. | |
| | ** | |
| | ** | |
| | ** $QT_END_LICENSE$ | |
| | ** | |
| | ****************************************************************************/**************************************************************************** | |
| 2 | ** | - |
| 3 | ** Copyright (C) 2013 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 | | - |
| 42 | /*! | - |
| 43 | \class QMdiSubWindow | - |
| 44 | \brief The QMdiSubWindow class provides a subwindow class for | - |
| 45 | QMdiArea. | - |
| 46 | \since 4.3 | - |
| 47 | \ingroup mainwindow-classes | - |
| 48 | \inmodule QtWidgets | - |
| 49 | | - |
| 50 | QMdiSubWindow represents a top-level window in a QMdiArea, and consists | - |
| 51 | of a title bar with window decorations, an internal widget, and | - |
| 52 | (depending on the current style) a window frame and a size | - |
| 53 | grip. QMdiSubWindow has its own layout, which consists of the | - |
| 54 | title bar and a center area for the internal widget. | - |
| 55 | | - |
| 56 | \image qmdisubwindowlayout.png | - |
| 57 | | - |
| 58 | The most common way to construct a QMdiSubWindow is to call | - |
| 59 | QMdiArea::addSubWindow() with the internal widget as the argument. | - |
| 60 | You can also create a subwindow yourself, and set an internal | - |
| 61 | widget by calling setWidget(). | - |
| 62 | | - |
| 63 | You use the same API when programming with subwindows as with | - |
| 64 | regular top-level windows (e.g., you can call functions such as | - |
| 65 | show(), hide(), showMaximized(), and setWindowTitle()). | - |
| 66 | | - |
| 67 | \section1 Subwindow Handling | - |
| 68 | | - |
| 69 | QMdiSubWindow also supports behavior specific to subwindows in | - |
| 70 | an MDI area. | - |
| 71 | | - |
| 72 | By default, each QMdiSubWindow is visible inside the MDI area | - |
| 73 | viewport when moved around, but it is also possible to specify | - |
| 74 | transparent window movement and resizing behavior, where only | - |
| 75 | the outline of a subwindow is updated during these operations. | - |
| 76 | The setOption() function is used to enable this behavior. | - |
| 77 | | - |
| 78 | The isShaded() function detects whether the subwindow is | - |
| 79 | currently shaded (i.e., the window is collapsed so that only the | - |
| 80 | title bar is visible). To enter shaded mode, call showShaded(). | - |
| 81 | QMdiSubWindow emits the windowStateChanged() signal whenever the | - |
| 82 | window state has changed (e.g., when the window becomes minimized, | - |
| 83 | or is restored). It also emits aboutToActivate() before it is | - |
| 84 | activated. | - |
| 85 | | - |
| 86 | In keyboard-interactive mode, the windows are moved and resized | - |
| 87 | with the keyboard. You can enter this mode through the system menu | - |
| 88 | of the window. The keyboardSingleStep and keyboardPageStep | - |
| 89 | properties control the distance the widget is moved or resized for | - |
| 90 | each keypress event. When shift is pressed down page step is used; | - |
| 91 | otherwise single step is used. | - |
| 92 | | - |
| 93 | You can also change the active window with the keyboard. By | - |
| 94 | pressing the control and tab keys at the same time, the next | - |
| 95 | (using the current \l{QMdiArea::}{WindowOrder}) subwindow will be | - |
| 96 | activated. By pressing control, shift, and tab, you will activate | - |
| 97 | the previous window. This is equivalent to calling | - |
| 98 | \l{QMdiArea::}{activateNextSubWindow()} and | - |
| 99 | \l{QMdiArea::}{activatePreviousSubWindow()}. Note that these | - |
| 100 | shortcuts overrides global shortcuts, but not the \l{QMdiArea}s | - |
| 101 | shortcuts. | - |
| 102 | | - |
| 103 | \sa QMdiArea | - |
| 104 | */ | - |
| 105 | | - |
| 106 | /*! | - |
| 107 | \enum QMdiSubWindow::SubWindowOption | - |
| 108 | | - |
| 109 | This enum describes options that customize the behavior | - |
| 110 | of QMdiSubWindow. | - |
| 111 | | - |
| 112 | \omitvalue AllowOutsideAreaHorizontally | - |
| 113 | \omitvalue AllowOutsideAreaVertically | - |
| 114 | | - |
| 115 | \value RubberBandResize If you enable this option, a rubber band | - |
| 116 | control is used to represent the subwindow's outline, and the user | - |
| 117 | resizes this instead of the subwindow itself. | - |
| 118 | As a result, the subwindow maintains its original position and size | - |
| 119 | until the resize operation has been completed, at which time it will | - |
| 120 | receive a single QResizeEvent. | - |
| 121 | By default, this option is disabled. | - |
| 122 | | - |
| 123 | \value RubberBandMove If you enable this option, a rubber band | - |
| 124 | control is used to represent the subwindow's outline, and the user | - |
| 125 | moves this instead of the subwindow itself. | - |
| 126 | As a result, the subwindow remains in its original position until | - |
| 127 | the move operation has completed, at which time a QMoveEvent is | - |
| 128 | sent to the window. By default, this option is disabled. | - |
| 129 | */ | - |
| 130 | | - |
| 131 | /*! | - |
| 132 | \fn QMdiSubWindow::windowStateChanged(Qt::WindowStates oldState, Qt::WindowStates newState) | - |
| 133 | | - |
| 134 | QMdiSubWindow emits this signal after the window state changes. \a | - |
| 135 | oldState is the window state before it changed, and \a newState is the | - |
| 136 | new, current state. | - |
| 137 | */ | - |
| 138 | | - |
| 139 | /*! | - |
| 140 | \fn QMdiSubWindow::aboutToActivate() | - |
| 141 | | - |
| 142 | QMdiSubWindow emits this signal immediately before it is | - |
| 143 | activated. After the subwindow has been activated, the QMdiArea that | - |
| 144 | manages the subwindow will also emit the | - |
| 145 | \l{QMdiArea::}{subWindowActivated()} signal. | - |
| 146 | | - |
| 147 | \sa QMdiArea::subWindowActivated() | - |
| 148 | */ | - |
| 149 | | - |
| 150 | #include "qmdisubwindow_p.h" | - |
| 151 | | - |
| 152 | #ifndef QT_NO_MDIAREA | - |
| 153 | | - |
| 154 | #include <QApplication> | - |
| 155 | #include <QStylePainter> | - |
| 156 | #include <QVBoxLayout> | - |
| 157 | #include <QMouseEvent> | - |
| 158 | #include <QWhatsThis> | - |
| 159 | #include <QToolTip> | - |
| 160 | #include <QMainWindow> | - |
| 161 | #include <QScrollBar> | - |
| 162 | #include <QDebug> | - |
| 163 | #if defined(Q_WS_MACQ_OS_MAC) && !defined(QT_NO_STYLE_MAC) | - |
| 164 | #include <private/qmacstyle_mac_p.h> | - |
| 165 | #endif | - |
| 166 | #include <QMdiArea> | - |
| 167 | | - |
| 168 | QT_BEGIN_NAMESPACE | - |
| 169 | | - |
| 170 | using namespace QMdi; | - |
| 171 | | - |
| 172 | static const QStyle::SubControl SubControls[] = | - |
| 173 | { | - |
| 174 | QStyle::SC_TitleBarLabel, // 1 | - |
| 175 | QStyle::SC_TitleBarSysMenu, // 2 | - |
| 176 | QStyle::SC_TitleBarMinButton, // 3 | - |
| 177 | QStyle::SC_TitleBarMaxButton, // 4 | - |
| 178 | QStyle::SC_TitleBarShadeButton, // 5 | - |
| 179 | QStyle::SC_TitleBarCloseButton, // 6 | - |
| 180 | QStyle::SC_TitleBarNormalButton, // 7 | - |
| 181 | QStyle::SC_TitleBarUnshadeButton, // 8 | - |
| 182 | QStyle::SC_TitleBarContextHelpButton // 9 | - |
| 183 | }; | - |
| 184 | static const int NumSubControls = sizeof(SubControls) / sizeof(SubControls[0]); | - |
| 185 | | - |
| 186 | static const QStyle::StandardPixmap ButtonPixmaps[] = | - |
| 187 | { | - |
| 188 | QStyle::SP_TitleBarMinButton, | - |
| 189 | QStyle::SP_TitleBarNormalButton, | - |
| 190 | QStyle::SP_TitleBarCloseButton | - |
| 191 | }; | - |
| 192 | static const int NumButtonPixmaps = sizeof(ButtonPixmaps) / sizeof(ButtonPixmaps[0]); | - |
| 193 | | - |
| 194 | static const Qt::WindowFlags CustomizeWindowFlags = | - |
| 195 | Qt::FramelessWindowHint | - |
| 196 | | Qt::CustomizeWindowHint | - |
| 197 | | Qt::WindowTitleHint | - |
| 198 | | Qt::WindowSystemMenuHint | - |
| 199 | | Qt::WindowMinimizeButtonHint | - |
| 200 | | Qt::WindowMaximizeButtonHint | - |
| 201 | | Qt::WindowMinMaxButtonsHint; | - |
| 202 | | - |
| 203 | | - |
| 204 | static const int BoundaryMargin = 5; | - |
| 205 | | - |
| 206 | static inline int getMoveDeltaComponent(uint cflags, uint moveFlag, uint resizeFlag, | - |
| 207 | int delta, int maxDelta, int minDelta) | - |
| 208 | { | - |
| 209 | if (cflags & moveFlag) { | - |
| 210 | if (delta > 0) | - |
| 211 | return (cflags & resizeFlag) ? qMin(delta, maxDelta) : delta; | - |
| 212 | return (cflags & resizeFlag) ? qMax(delta, minDelta) : delta; | - |
| 213 | } | - |
| 214 | return 0; | - |
| 215 | } | - |
| 216 | | - |
| 217 | static inline int getResizeDeltaComponent(uint cflags, uint resizeFlag, | - |
| 218 | uint resizeReverseFlag, int delta) | - |
| 219 | { | - |
| 220 | if (cflags & resizeFlag) { | - |
| 221 | if (cflags & resizeReverseFlag) | - |
| 222 | return -delta; | - |
| 223 | return delta; | - |
| 224 | } | - |
| 225 | return 0; | - |
| 226 | } | - |
| 227 | | - |
| 228 | static inline bool isChildOfQMdiSubWindow(const QWidget *child) | - |
| 229 | { | - |
| 230 | Q_ASSERT(child); | - |
| 231 | QWidget *parent = child->parentWidget(); | - |
| 232 | while (parent) { | - |
| 233 | if (qobject_cast<QMdiSubWindow *>(parent)) | - |
| 234 | return true; | - |
| 235 | parent = parent->parentWidget(); | - |
| 236 | } | - |
| 237 | return false; | - |
| 238 | } | - |
| 239 | | - |
| 240 | static inline bool isChildOfTabbedQMdiArea(const QMdiSubWindow *child) | - |
| 241 | { | - |
| 242 | Q_ASSERT(child); | - |
| 243 | if (QMdiArea *mdiArea = child->mdiArea()) { | - |
| 244 | if (mdiArea->viewMode() == QMdiArea::TabbedView) | - |
| 245 | return true; | - |
| 246 | } | - |
| 247 | return false; | - |
| 248 | } | - |
| 249 | | - |
| 250 | template<typename T> | - |
| 251 | static inline ControlElement<T> *ptr(QWidget *widget) | - |
| 252 | { | - |
| 253 | if (widget && widget->qt_metacast("ControlElement") | - |
| 254 | && strcmp(widget->metaObject()->className(), T::staticMetaObject.className()) == 0) { | - |
| 255 | return static_cast<ControlElement<T> *>(widget); | - |
| 256 | } | - |
| 257 | return 0; | - |
| 258 | } | - |
| 259 | | - |
| 260 | QString QMdiSubWindowPrivate::originalWindowTitle() | - |
| 261 | { | - |
| 262 | Q_Q(QMdiSubWindow); | - |
| 263 | if (originalTitle.isNull()) { | - |
| 264 | originalTitle = q->window()->windowTitle(); | - |
| 265 | if (originalTitle.isNull()) | - |
| 266 | originalTitle = QLatin1String(""); | - |
| 267 | } | - |
| 268 | return originalTitle; | - |
| 269 | } | - |
| 270 | | - |
| 271 | void QMdiSubWindowPrivate::setNewWindowTitle() | - |
| 272 | { | - |
| 273 | Q_Q(QMdiSubWindow); | - |
| 274 | QString childTitle = q->windowTitle(); | - |
| 275 | if (childTitle.isEmpty()) | - |
| 276 | return; | - |
| 277 | QString original = originalWindowTitle(); | - |
| 278 | if (!original.isEmpty()) { | - |
| 279 | if (!original.contains(QMdiSubWindow::tr("- [%1]").arg(childTitle))) | - |
| 280 | q->window()->setWindowTitle(QMdiSubWindow::tr("%1 - [%2]").arg(original, childTitle)); | - |
| 281 | | - |
| 282 | } else { | - |
| 283 | q->window()->setWindowTitle(childTitle); | - |
| 284 | } | - |
| 285 | } | - |
| 286 | | - |
| 287 | static inline bool isHoverControl(QStyle::SubControl control) | - |
| 288 | { | - |
| 289 | return control != QStyle::SC_None && control != QStyle::SC_TitleBarLabel; | - |
| 290 | } | - |
| 291 | | - |
| 292 | #if defined(Q_WS_WIN) | - |
| 293 | static inline QRgb colorref2qrgb(COLORREF col) | - |
| 294 | { | - |
| 295 | return qRgb(GetRValue(col),GetGValue(col),GetBValue(col)); | - |
| 296 | } | - |
| 297 | #endif | - |
| 298 | | - |
| 299 | #ifndef QT_NO_TOOLTIP | - |
| 300 | static void showToolTip(QHelpEvent *helpEvent, QWidget *widget, const QStyleOptionComplex &opt, | - |
| 301 | QStyle::ComplexControl complexControl, QStyle::SubControl subControl) | - |
| 302 | { | - |
| 303 | Q_ASSERT(helpEvent); never executed (the execution status of this line is deduced): qt_noop(); | - |
| 304 | Q_ASSERT(helpEvent->type() == QEvent::ToolTip); never executed (the execution status of this line is deduced): qt_noop(); | - |
| 305 | Q_ASSERT(widget); never executed (the execution status of this line is deduced): qt_noop(); | - |
| 306 | | - |
| 307 | #if defined(Q_WS_MACQ_OS_MAC) && !defined(QT_NO_STYLE_MAC) | - |
| 308 | // Native Mac windows don't show tool tip. | - |
| 309 | if (qobject_cast<QMacStyle *>(widget->style())) | - |
| 310 | return; | - |
| 311 | #endif | - |
| 312 | | - |
| 313 | // Convert CC_MdiControls to CC_TitleBar. Sub controls of different complex | - |
| 314 | // controls cannot be in the same switch as they might have the same value. | - |
| 315 | if (complexControl == QStyle::CC_MdiControls) { never evaluated: complexControl == QStyle::CC_MdiControls | 0 |
| 316 | if (subControl == QStyle::SC_MdiMinButton) never evaluated: subControl == QStyle::SC_MdiMinButton | 0 |
| 317 | subControl = QStyle::SC_TitleBarMinButton; never executed: subControl = QStyle::SC_TitleBarMinButton; | 0 |
| 318 | else if (subControl == QStyle::SC_MdiCloseButton) never evaluated: subControl == QStyle::SC_MdiCloseButton | 0 |
| 319 | subControl = QStyle::SC_TitleBarCloseButton; never executed: subControl = QStyle::SC_TitleBarCloseButton; | 0 |
| 320 | else if (subControl == QStyle::SC_MdiNormalButton) never evaluated: subControl == QStyle::SC_MdiNormalButton | 0 |
| 321 | subControl = QStyle::SC_TitleBarNormalButton; never executed: subControl = QStyle::SC_TitleBarNormalButton; | 0 |
| 322 | else | - |
| 323 | subControl = QStyle::SC_None; never executed: subControl = QStyle::SC_None; | 0 |
| 324 | } | - |
| 325 | | - |
| 326 | // Don't change the tooltip for the base widget itself. | - |
| 327 | if (subControl == QStyle::SC_None) never evaluated: subControl == QStyle::SC_None | 0 |
| 328 | return; | 0 |
| 329 | | - |
| 330 | QString toolTip; never executed (the execution status of this line is deduced): QString toolTip; | - |
| 331 | | - |
| 332 | switch (subControl) { | - |
| 333 | case QStyle::SC_TitleBarMinButton: | - |
| 334 | toolTip = QMdiSubWindow::tr("Minimize"); never executed (the execution status of this line is deduced): toolTip = QMdiSubWindow::tr("Minimize"); | - |
| 335 | break; | 0 |
| 336 | case QStyle::SC_TitleBarMaxButton: | - |
| 337 | toolTip = QMdiSubWindow::tr("Maximize"); never executed (the execution status of this line is deduced): toolTip = QMdiSubWindow::tr("Maximize"); | - |
| 338 | break; | 0 |
| 339 | case QStyle::SC_TitleBarUnshadeButton: | - |
| 340 | toolTip = QMdiSubWindow::tr("Unshade"); never executed (the execution status of this line is deduced): toolTip = QMdiSubWindow::tr("Unshade"); | - |
| 341 | break; | 0 |
| 342 | case QStyle::SC_TitleBarShadeButton: | - |
| 343 | toolTip = QMdiSubWindow::tr("Shade"); never executed (the execution status of this line is deduced): toolTip = QMdiSubWindow::tr("Shade"); | - |
| 344 | break; | 0 |
| 345 | case QStyle::SC_TitleBarNormalButton: | - |
| 346 | if (widget->isMaximized() || !qobject_cast<QMdiSubWindow *>(widget)) never evaluated: widget->isMaximized() never evaluated: !qobject_cast<QMdiSubWindow *>(widget) | 0 |
| 347 | toolTip = QMdiSubWindow::tr("Restore Down"); never executed: toolTip = QMdiSubWindow::tr("Restore Down"); | 0 |
| 348 | else | - |
| 349 | toolTip = QMdiSubWindow::tr("Restore"); never executed: toolTip = QMdiSubWindow::tr("Restore"); | 0 |
| 350 | break; | 0 |
| 351 | case QStyle::SC_TitleBarCloseButton: | - |
| 352 | toolTip = QMdiSubWindow::tr("Close"); never executed (the execution status of this line is deduced): toolTip = QMdiSubWindow::tr("Close"); | - |
| 353 | break; | 0 |
| 354 | case QStyle::SC_TitleBarContextHelpButton: | - |
| 355 | toolTip = QMdiSubWindow::tr("Help"); never executed (the execution status of this line is deduced): toolTip = QMdiSubWindow::tr("Help"); | - |
| 356 | break; | 0 |
| 357 | case QStyle::SC_TitleBarSysMenu: | - |
| 358 | toolTip = QMdiSubWindow::tr("Menu"); never executed (the execution status of this line is deduced): toolTip = QMdiSubWindow::tr("Menu"); | - |
| 359 | break; | 0 |
| 360 | default: | - |
| 361 | break; | 0 |
| 362 | } | - |
| 363 | | - |
| 364 | const QRect rect = widget->style()->subControlRect(complexControl, &opt, subControl, widget); never executed (the execution status of this line is deduced): const QRect rect = widget->style()->subControlRect(complexControl, &opt, subControl, widget); | - |
| 365 | QToolTip::showText(helpEvent->globalPos(), toolTip, widget, rect); never executed (the execution status of this line is deduced): QToolTip::showText(helpEvent->globalPos(), toolTip, widget, rect); | - |
| 366 | } | 0 |
| 367 | #endif // QT_NO_TOOLTIP | - |
| 368 | | - |
| 369 | namespace QMdi { | - |
| 370 | /* | - |
| 371 | \class ControlLabel | - |
| 372 | \internal | - |
| 373 | */ | - |
| 374 | class ControlLabel : public QWidget | - |
| 375 | { | - |
| 376 | Q_OBJECT | - |
| 377 | public: | - |
| 378 | ControlLabel(QMdiSubWindow *subWindow, QWidget *parent = 0); | - |
| 379 | | - |
| 380 | QSize sizeHint() const; | - |
| 381 | | - |
| 382 | signals: | - |
| 383 | void _q_clicked(); | - |
| 384 | void _q_doubleClicked(); | - |
| 385 | | - |
| 386 | protected: | - |
| 387 | bool event(QEvent *event); | - |
| 388 | void paintEvent(QPaintEvent *paintEvent); | - |
| 389 | void mousePressEvent(QMouseEvent *mouseEvent); | - |
| 390 | void mouseDoubleClickEvent(QMouseEvent *mouseEvent); | - |
| 391 | void mouseReleaseEvent(QMouseEvent *mouseEvent); | - |
| 392 | | - |
| 393 | private: | - |
| 394 | QPixmap label; | - |
| 395 | bool isPressed; | - |
| 396 | void updateWindowIcon(); | - |
| 397 | }; | - |
| 398 | } // namespace QMdi | - |
| 399 | | - |
| 400 | ControlLabel::ControlLabel(QMdiSubWindow *subWindow, QWidget *parent) | - |
| 401 | : QWidget(parent), isPressed(false) | - |
| 402 | { | - |
| 403 | Q_UNUSED(subWindow); | - |
| 404 | setFocusPolicy(Qt::NoFocus); | - |
| 405 | updateWindowIcon(); | - |
| 406 | setFixedSize(label.size()); | - |
| 407 | } | - |
| 408 | | - |
| 409 | /* | - |
| 410 | \internal | - |
| 411 | */ | - |
| 412 | QSize ControlLabel::sizeHint() const | - |
| 413 | { | - |
| 414 | return label.size(); | - |
| 415 | } | - |
| 416 | | - |
| 417 | /* | - |
| 418 | \internal | - |
| 419 | */ | - |
| 420 | bool ControlLabel::event(QEvent *event) | - |
| 421 | { | - |
| 422 | if (event->type() == QEvent::WindowIconChange) | - |
| 423 | updateWindowIcon(); | - |
| 424 | #ifndef QT_NO_TOOLTIP | - |
| 425 | else if (event->type() == QEvent::ToolTip) { | - |
| 426 | QStyleOptionTitleBar options; | - |
| 427 | options.initFrom(this); | - |
| 428 | showToolTip(static_cast<QHelpEvent *>(event), this, options, | - |
| 429 | QStyle::CC_TitleBar, QStyle::SC_TitleBarSysMenu); | - |
| 430 | } | - |
| 431 | #endif | - |
| 432 | return QWidget::event(event); | - |
| 433 | } | - |
| 434 | | - |
| 435 | /* | - |
| 436 | \internal | - |
| 437 | */ | - |
| 438 | void ControlLabel::paintEvent(QPaintEvent * /*paintEvent*/) | - |
| 439 | { | - |
| 440 | QPainter painter(this); | - |
| 441 | painter.drawPixmap(0, 0, label); | - |
| 442 | } | - |
| 443 | | - |
| 444 | /* | - |
| 445 | \internal | - |
| 446 | */ | - |
| 447 | void ControlLabel::mousePressEvent(QMouseEvent *mouseEvent) | - |
| 448 | { | - |
| 449 | if (mouseEvent->button() != Qt::LeftButton) { | - |
| 450 | mouseEvent->ignore(); | - |
| 451 | return; | - |
| 452 | } | - |
| 453 | isPressed = true; | - |
| 454 | } | - |
| 455 | | - |
| 456 | /* | - |
| 457 | \internal | - |
| 458 | */ | - |
| 459 | void ControlLabel::mouseDoubleClickEvent(QMouseEvent *mouseEvent) | - |
| 460 | { | - |
| 461 | if (mouseEvent->button() != Qt::LeftButton) { | - |
| 462 | mouseEvent->ignore(); | - |
| 463 | return; | - |
| 464 | } | - |
| 465 | isPressed = false; | - |
| 466 | emit _q_doubleClicked(); | - |
| 467 | } | - |
| 468 | | - |
| 469 | /* | - |
| 470 | \internal | - |
| 471 | */ | - |
| 472 | void ControlLabel::mouseReleaseEvent(QMouseEvent *mouseEvent) | - |
| 473 | { | - |
| 474 | if (mouseEvent->button() != Qt::LeftButton) { | - |
| 475 | mouseEvent->ignore(); | - |
| 476 | return; | - |
| 477 | } | - |
| 478 | if (isPressed) { | - |
| 479 | isPressed = false; | - |
| 480 | emit _q_clicked(); | - |
| 481 | } | - |
| 482 | } | - |
| 483 | | - |
| 484 | /* | - |
| 485 | \internal | - |
| 486 | */ | - |
| 487 | void ControlLabel::updateWindowIcon() | - |
| 488 | { | - |
| 489 | QIcon menuIcon = windowIcon(); | - |
| 490 | if (menuIcon.isNull()) | - |
| 491 | menuIcon = style()->standardIcon(QStyle::SP_TitleBarMenuButton, 0, parentWidget()); | - |
| 492 | label = menuIcon.pixmap(16, 16); | - |
| 493 | update(); | - |
| 494 | } | - |
| 495 | | - |
| 496 | namespace QMdi { | - |
| 497 | /* | - |
| 498 | \class ControllerWidget | - |
| 499 | \internal | - |
| 500 | */ | - |
| 501 | class ControllerWidget : public QWidget | - |
| 502 | { | - |
| 503 | Q_OBJECT | - |
| 504 | public: | - |
| 505 | ControllerWidget(QMdiSubWindow *subWindow, QWidget *parent = 0); | - |
| 506 | QSize sizeHint() const; | - |
| 507 | void setControlVisible(QMdiSubWindowPrivate::WindowStateAction action, bool visible); | - |
| 508 | inline bool hasVisibleControls() const | - |
| 509 | { | - |
| 510 | return (visibleControls & QStyle::SC_MdiMinButton) | - |
| 511 | || (visibleControls & QStyle::SC_MdiNormalButton) | - |
| 512 | || (visibleControls & QStyle::SC_MdiCloseButton); | - |
| 513 | } | - |
| 514 | | - |
| 515 | signals: | - |
| 516 | void _q_minimize(); | - |
| 517 | void _q_restore(); | - |
| 518 | void _q_close(); | - |
| 519 | | - |
| 520 | protected: | - |
| 521 | void paintEvent(QPaintEvent *event); | - |
| 522 | void mousePressEvent(QMouseEvent *event); | - |
| 523 | void mouseReleaseEvent(QMouseEvent *event); | - |
| 524 | void mouseMoveEvent(QMouseEvent *event); | - |
| 525 | void leaveEvent(QEvent *event); | - |
| 526 | bool event(QEvent *event); | - |
| 527 | | - |
| 528 | private: | - |
| 529 | QStyle::SubControl activeControl; | - |
| 530 | QStyle::SubControl hoverControl; | - |
| 531 | QStyle::SubControls visibleControls; | - |
| 532 | void initStyleOption(QStyleOptionComplex *option) const; | - |
| 533 | QMdiArea *mdiArea; | - |
| 534 | inline QStyle::SubControl getSubControl(const QPoint &pos) const | - |
| 535 | { | - |
| 536 | QStyleOptionComplex opt; | - |
| 537 | initStyleOption(&opt); | - |
| 538 | return style()->hitTestComplexControl(QStyle::CC_MdiControls, &opt, pos, mdiArea); | - |
| 539 | } | - |
| 540 | }; | - |
| 541 | } // namespace QMdi | - |
| 542 | | - |
| 543 | /* | - |
| 544 | \internal | - |
| 545 | */ | - |
| 546 | ControllerWidget::ControllerWidget(QMdiSubWindow *subWindow, QWidget *parent) | - |
| 547 | : QWidget(parent), | - |
| 548 | activeControl(QStyle::SC_None), | - |
| 549 | hoverControl(QStyle::SC_None), | - |
| 550 | visibleControls(QStyle::SC_None), | - |
| 551 | mdiArea(0) | - |
| 552 | { | - |
| 553 | if (subWindow->parentWidget()) | - |
| 554 | mdiArea = qobject_cast<QMdiArea *>(subWindow->parentWidget()->parentWidget()); | - |
| 555 | setFocusPolicy(Qt::NoFocus); | - |
| 556 | setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); | - |
| 557 | setMouseTracking(true); | - |
| 558 | } | - |
| 559 | | - |
| 560 | /* | - |
| 561 | \internal | - |
| 562 | */ | - |
| 563 | QSize ControllerWidget::sizeHint() const | - |
| 564 | { | - |
| 565 | ensurePolished(); | - |
| 566 | QStyleOptionComplex opt; | - |
| 567 | initStyleOption(&opt); | - |
| 568 | QSize size(48, 16); | - |
| 569 | return style()->sizeFromContents(QStyle::CT_MdiControls, &opt, size, mdiArea); | - |
| 570 | } | - |
| 571 | | - |
| 572 | void ControllerWidget::setControlVisible(QMdiSubWindowPrivate::WindowStateAction action, bool visible) | - |
| 573 | { | - |
| 574 | QStyle::SubControl subControl = QStyle::SC_None; | - |
| 575 | | - |
| 576 | // Map action from QMdiSubWindowPrivate::WindowStateAction to QStyle::SubControl. | - |
| 577 | if (action == QMdiSubWindowPrivate::MaximizeAction) | - |
| 578 | subControl = QStyle::SC_MdiNormalButton; | - |
| 579 | else if (action == QMdiSubWindowPrivate::CloseAction) | - |
| 580 | subControl = QStyle::SC_MdiCloseButton; | - |
| 581 | else if (action == QMdiSubWindowPrivate::MinimizeAction) | - |
| 582 | subControl = QStyle::SC_MdiMinButton; | - |
| 583 | | - |
| 584 | if (subControl == QStyle::SC_None) | - |
| 585 | return; | - |
| 586 | | - |
| 587 | if (visible && !(visibleControls & subControl)) | - |
| 588 | visibleControls |= subControl; | - |
| 589 | else if (!visible && (visibleControls & subControl)) | - |
| 590 | visibleControls &= ~subControl; | - |
| 591 | } | - |
| 592 | | - |
| 593 | /* | - |
| 594 | \internal | - |
| 595 | */ | - |
| 596 | void ControllerWidget::paintEvent(QPaintEvent * /*paintEvent*/) | - |
| 597 | { | - |
| 598 | QStyleOptionComplex opt; | - |
| 599 | initStyleOption(&opt); | - |
| 600 | if (activeControl == hoverControl) { | - |
| 601 | opt.activeSubControls = activeControl; | - |
| 602 | opt.state |= QStyle::State_Sunken; | - |
| 603 | } else if (hoverControl != QStyle::SC_None && (activeControl == QStyle::SC_None)) { | - |
| 604 | opt.activeSubControls = hoverControl; | - |
| 605 | opt.state |= QStyle::State_MouseOver; | - |
| 606 | } | - |
| 607 | QPainter painter(this); | - |
| 608 | style()->drawComplexControl(QStyle::CC_MdiControls, &opt, &painter, mdiArea); | - |
| 609 | } | - |
| 610 | | - |
| 611 | /* | - |
| 612 | \internal | - |
| 613 | */ | - |
| 614 | void ControllerWidget::mousePressEvent(QMouseEvent *event) | - |
| 615 | { | - |
| 616 | if (event->button() != Qt::LeftButton) { | - |
| 617 | event->ignore(); | - |
| 618 | return; | - |
| 619 | } | - |
| 620 | activeControl = getSubControl(event->pos()); | - |
| 621 | update(); | - |
| 622 | } | - |
| 623 | | - |
| 624 | /* | - |
| 625 | \internal | - |
| 626 | */ | - |
| 627 | void ControllerWidget::mouseReleaseEvent(QMouseEvent *event) | - |
| 628 | { | - |
| 629 | if (event->button() != Qt::LeftButton) { | - |
| 630 | event->ignore(); | - |
| 631 | return; | - |
| 632 | } | - |
| 633 | | - |
| 634 | QStyle::SubControl under_mouse = getSubControl(event->pos()); | - |
| 635 | if (under_mouse == activeControl) { | - |
| 636 | switch (activeControl) { | - |
| 637 | case QStyle::SC_MdiCloseButton: | - |
| 638 | emit _q_close(); | - |
| 639 | break; | - |
| 640 | case QStyle::SC_MdiNormalButton: | - |
| 641 | emit _q_restore(); | - |
| 642 | break; | - |
| 643 | case QStyle::SC_MdiMinButton: | - |
| 644 | emit _q_minimize(); | - |
| 645 | break; | - |
| 646 | default: | - |
| 647 | break; | - |
| 648 | } | - |
| 649 | } | - |
| 650 | | - |
| 651 | activeControl = QStyle::SC_None; | - |
| 652 | update(); | - |
| 653 | } | - |
| 654 | | - |
| 655 | /* | - |
| 656 | \internal | - |
| 657 | */ | - |
| 658 | void ControllerWidget::mouseMoveEvent(QMouseEvent *event) | - |
| 659 | { | - |
| 660 | QStyle::SubControl under_mouse = getSubControl(event->pos()); | - |
| 661 | //test if hover state changes | - |
| 662 | if (hoverControl != under_mouse) { | - |
| 663 | hoverControl = under_mouse; | - |
| 664 | update(); | - |
| 665 | } | - |
| 666 | } | - |
| 667 | | - |
| 668 | /* | - |
| 669 | \internal | - |
| 670 | */ | - |
| 671 | void ControllerWidget::leaveEvent(QEvent * /*event*/) | - |
| 672 | { | - |
| 673 | hoverControl = QStyle::SC_None; | - |
| 674 | update(); | - |
| 675 | } | - |
| 676 | | - |
| 677 | /* | - |
| 678 | \internal | - |
| 679 | */ | - |
| 680 | bool ControllerWidget::event(QEvent *event) | - |
| 681 | { | - |
| 682 | #ifndef QT_NO_TOOLTIP | - |
| 683 | if (event->type() == QEvent::ToolTip) { | - |
| 684 | QStyleOptionComplex opt; | - |
| 685 | initStyleOption(&opt); | - |
| 686 | QHelpEvent *helpEvent = static_cast<QHelpEvent *>(event); | - |
| 687 | showToolTip(helpEvent, this, opt, QStyle::CC_MdiControls, getSubControl(helpEvent->pos())); | - |
| 688 | } | - |
| 689 | #endif // QT_NO_TOOLTIP | - |
| 690 | return QWidget::event(event); | - |
| 691 | } | - |
| 692 | | - |
| 693 | /* | - |
| 694 | \internal | - |
| 695 | */ | - |
| 696 | void ControllerWidget::initStyleOption(QStyleOptionComplex *option) const | - |
| 697 | { | - |
| 698 | option->initFrom(this); | - |
| 699 | option->subControls = visibleControls; | - |
| 700 | option->activeSubControls = QStyle::SC_None; | - |
| 701 | } | - |
| 702 | | - |
| 703 | /* | - |
| 704 | \internal | - |
| 705 | */ | - |
| 706 | ControlContainer::ControlContainer(QMdiSubWindow *mdiChild) | - |
| 707 | : QObject(mdiChild), | - |
| 708 | previousLeft(0), | - |
| 709 | previousRight(0), | - |
| 710 | #ifndef QT_NO_MENUBAR | - |
| 711 | m_menuBar(0), | - |
| 712 | #endif | - |
| 713 | mdiChild(mdiChild) | - |
| 714 | { | - |
| 715 | Q_ASSERT(mdiChild); | - |
| 716 | | - |
| 717 | m_controllerWidget = new ControlElement<ControllerWidget>(mdiChild); | - |
| 718 | connect(m_controllerWidget, SIGNAL(_q_close()), mdiChild, SLOT(close())); | - |
| 719 | connect(m_controllerWidget, SIGNAL(_q_restore()), mdiChild, SLOT(showNormal())); | - |
| 720 | connect(m_controllerWidget, SIGNAL(_q_minimize()), mdiChild, SLOT(showMinimized())); | - |
| 721 | | - |
| 722 | m_menuLabel = new ControlElement<ControlLabel>(mdiChild); | - |
| 723 | m_menuLabel->setWindowIcon(mdiChild->windowIcon()); | - |
| 724 | #ifndef QT_NO_MENU | - |
| 725 | connect(m_menuLabel, SIGNAL(_q_clicked()), mdiChild, SLOT(showSystemMenu())); | - |
| 726 | #endif | - |
| 727 | connect(m_menuLabel, SIGNAL(_q_doubleClicked()), mdiChild, SLOT(close())); | - |
| 728 | } | - |
| 729 | | - |
| 730 | ControlContainer::~ControlContainer() | - |
| 731 | { | - |
| 732 | #ifndef QT_NO_MENUBAR | - |
| 733 | removeButtonsFromMenuBar(); | - |
| 734 | #endif | - |
| 735 | delete m_menuLabel; | - |
| 736 | m_menuLabel = 0; | - |
| 737 | delete m_controllerWidget; | - |
| 738 | m_controllerWidget = 0; | - |
| 739 | } | - |
| 740 | | - |
| 741 | #ifndef QT_NO_MENUBAR | - |
| 742 | /* | - |
| 743 | \internal | - |
| 744 | */ | - |
| 745 | QMenuBar *QMdiSubWindowPrivate::menuBar() const | - |
| 746 | { | - |
| 747 | #if defined(QT_NO_MAINWINDOW) | - |
| 748 | return 0; | - |
| 749 | #else | - |
| 750 | Q_Q(const QMdiSubWindow); | - |
| 751 | if (!q->isMaximized() || drawTitleBarWhenMaximized() || isChildOfTabbedQMdiArea(q)) | - |
| 752 | return 0; | - |
| 753 | | - |
| 754 | if (QMainWindow *mainWindow = qobject_cast<QMainWindow *>(q->window())) | - |
| 755 | return mainWindow->menuBar(); | - |
| 756 | | - |
| 757 | return 0; | - |
| 758 | #endif | - |
| 759 | } | - |
| 760 | | - |
| 761 | /* | - |
| 762 | \internal | - |
| 763 | */ | - |
| 764 | void ControlContainer::showButtonsInMenuBar(QMenuBar *menuBar) | - |
| 765 | { | - |
| 766 | if (!menuBar || !mdiChild || mdiChild->windowFlags() & Qt::FramelessWindowHint) | - |
| 767 | return; | - |
| 768 | m_menuBar = menuBar; | - |
| 769 | | - |
| 770 | if (m_menuLabel && mdiChild->windowFlags() & Qt::WindowSystemMenuHint) { | - |
| 771 | QWidget *currentLeft = menuBar->cornerWidget(Qt::TopLeftCorner); | - |
| 772 | if (currentLeft) | - |
| 773 | currentLeft->hide(); | - |
| 774 | if (currentLeft != m_menuLabel) { | - |
| 775 | menuBar->setCornerWidget(m_menuLabel, Qt::TopLeftCorner); | - |
| 776 | previousLeft = currentLeft; | - |
| 777 | } | - |
| 778 | m_menuLabel->show(); | - |
| 779 | } | - |
| 780 | ControllerWidget *controllerWidget = qobject_cast<ControllerWidget *>(m_controllerWidget); | - |
| 781 | if (controllerWidget && controllerWidget->hasVisibleControls()) { | - |
| 782 | QWidget *currentRight = menuBar->cornerWidget(Qt::TopRightCorner); | - |
| 783 | if (currentRight) | - |
| 784 | currentRight->hide(); | - |
| 785 | if (currentRight != m_controllerWidget) { | - |
| 786 | menuBar->setCornerWidget(m_controllerWidget, Qt::TopRightCorner); | - |
| 787 | previousRight = currentRight; | - |
| 788 | } | - |
| 789 | m_controllerWidget->show(); | - |
| 790 | } | - |
| 791 | mdiChild->d_func()->setNewWindowTitle(); | - |
| 792 | } | - |
| 793 | | - |
| 794 | /* | - |
| 795 | \internal | - |
| 796 | */ | - |
| 797 | void ControlContainer::removeButtonsFromMenuBar(QMenuBar *menuBar) | - |
| 798 | { | - |
| 799 | if (menuBar && menuBar != m_menuBar) { | - |
| 800 | // m_menubar was deleted while sub-window was maximized | - |
| 801 | previousRight = 0; | - |
| 802 | previousLeft = 0; | - |
| 803 | m_menuBar = menuBar; | - |
| 804 | } | - |
| 805 | | - |
| 806 | if (!m_menuBar || !mdiChild || qt_widget_private(mdiChild->window())->data.in_destructor) | - |
| 807 | return; | - |
| 808 | | - |
| 809 | QMdiSubWindow *child = 0; | - |
| 810 | if (m_controllerWidget) { | - |
| 811 | QWidget *currentRight = m_menuBar->cornerWidget(Qt::TopRightCorner); | - |
| 812 | if (currentRight == m_controllerWidget) { | - |
| 813 | if (ControlElement<ControllerWidget> *ce = ptr<ControllerWidget>(previousRight)) { | - |
| 814 | if (!ce->mdiChild || !ce->mdiChild->isMaximized()) | - |
| 815 | previousRight = 0; | - |
| 816 | else | - |
| 817 | child = ce->mdiChild; | - |
| 818 | } | - |
| 819 | m_menuBar->setCornerWidget(previousRight, Qt::TopRightCorner); | - |
| 820 | if (previousRight) { | - |
| 821 | previousRight->show(); | - |
| 822 | previousRight = 0; | - |
| 823 | } | - |
| 824 | } | - |
| 825 | m_controllerWidget->hide(); | - |
| 826 | m_controllerWidget->setParent(0); | - |
| 827 | } | - |
| 828 | if (m_menuLabel) { | - |
| 829 | QWidget *currentLeft = m_menuBar->cornerWidget(Qt::TopLeftCorner); | - |
| 830 | if (currentLeft == m_menuLabel) { | - |
| 831 | if (ControlElement<ControlLabel> *ce = ptr<ControlLabel>(previousLeft)) { | - |
| 832 | if (!ce->mdiChild || !ce->mdiChild->isMaximized()) | - |
| 833 | previousLeft = 0; | - |
| 834 | else if (!child) | - |
| 835 | child = mdiChild; | - |
| 836 | } | - |
| 837 | m_menuBar->setCornerWidget(previousLeft, Qt::TopLeftCorner); | - |
| 838 | if (previousLeft) { | - |
| 839 | previousLeft->show(); | - |
| 840 | previousLeft = 0; | - |
| 841 | } | - |
| 842 | } | - |
| 843 | m_menuLabel->hide(); | - |
| 844 | m_menuLabel->setParent(0); | - |
| 845 | } | - |
| 846 | m_menuBar->update(); | - |
| 847 | if (child) | - |
| 848 | child->d_func()->setNewWindowTitle(); | - |
| 849 | else if (mdiChild) | - |
| 850 | mdiChild->window()->setWindowTitle(mdiChild->d_func()->originalWindowTitle()); | - |
| 851 | } | - |
| 852 | | - |
| 853 | #endif // QT_NO_MENUBAR | - |
| 854 | | - |
| 855 | void ControlContainer::updateWindowIcon(const QIcon &windowIcon) | - |
| 856 | { | - |
| 857 | if (m_menuLabel) | - |
| 858 | m_menuLabel->setWindowIcon(windowIcon); | - |
| 859 | } | - |
| 860 | | - |
| 861 | /*! | - |
| 862 | \internal | - |
| 863 | */ | - |
| 864 | QMdiSubWindowPrivate::QMdiSubWindowPrivate() | - |
| 865 | : baseWidget(0), | - |
| 866 | restoreFocusWidget(0), | - |
| 867 | controlContainer(0), | - |
| 868 | #ifndef QT_NO_SIZEGRIP | - |
| 869 | sizeGrip(0), | - |
| 870 | #endif | - |
| 871 | #ifndef QT_NO_RUBBERBAND | - |
| 872 | rubberBand(0), | - |
| 873 | #endif | - |
| 874 | userMinimumSize(0,0), | - |
| 875 | resizeEnabled(true), | - |
| 876 | moveEnabled(true), | - |
| 877 | isInInteractiveMode(false), | - |
| 878 | #ifndef QT_NO_RUBBERBAND | - |
| 879 | isInRubberBandMode(false), | - |
| 880 | #endif | - |
| 881 | isShadeMode(false), | - |
| 882 | ignoreWindowTitleChange(false), | - |
| 883 | ignoreNextActivationEvent(false), | - |
| 884 | activationEnabled(true), | - |
| 885 | isShadeRequestFromMinimizeMode(false), | - |
| 886 | isMaximizeMode(false), | - |
| 887 | isWidgetHiddenByUs(false), | - |
| 888 | isActive(false), | - |
| 889 | isExplicitlyDeactivated(false), | - |
| 890 | keyboardSingleStep(5), | - |
| 891 | keyboardPageStep(20), | - |
| 892 | resizeTimerId(-1), | - |
| 893 | currentOperation(None), | - |
| 894 | hoveredSubControl(QStyle::SC_None), | - |
| 895 | activeSubControl(QStyle::SC_None), | - |
| 896 | focusInReason(Qt::ActiveWindowFocusReason) | - |
| 897 | { | - |
| 898 | initOperationMap(); | - |
| 899 | } | - |
| 900 | | - |
| 901 | /*! | - |
| 902 | \internal | - |
| 903 | */ | - |
| 904 | void QMdiSubWindowPrivate::_q_updateStaysOnTopHint() | - |
| 905 | { | - |
| 906 | #ifndef QT_NO_ACTION | - |
| 907 | Q_Q(QMdiSubWindow); | - |
| 908 | if (QAction *senderAction = qobject_cast<QAction *>(q->sender())) { | - |
| 909 | if (senderAction->isChecked()) { | - |
| 910 | q->setWindowFlags(q->windowFlags() | Qt::WindowStaysOnTopHint); | - |
| 911 | q->raise(); | - |
| 912 | } else { | - |
| 913 | q->setWindowFlags(q->windowFlags() & ~Qt::WindowStaysOnTopHint); | - |
| 914 | q->lower(); | - |
| 915 | } | - |
| 916 | } | - |
| 917 | #endif // QT_NO_ACTION | - |
| 918 | } | - |
| 919 | | - |
| 920 | /*! | - |
| 921 | \internal | - |
| 922 | */ | - |
| 923 | void QMdiSubWindowPrivate::_q_enterInteractiveMode() | - |
| 924 | { | - |
| 925 | #ifndef QT_NO_ACTION | - |
| 926 | Q_Q(QMdiSubWindow); | - |
| 927 | QAction *action = qobject_cast<QAction *>(q->sender()); | - |
| 928 | if (!action) | - |
| 929 | return; | - |
| 930 | | - |
| 931 | QPoint pressPos; | - |
| 932 | if (actions[MoveAction] && actions[MoveAction] == action) { | - |
| 933 | currentOperation = Move; | - |
| 934 | pressPos = QPoint(q->width() / 2, titleBarHeight() - 1); | - |
| 935 | } else if (actions[ResizeAction] && actions[ResizeAction] == action) { | - |
| 936 | currentOperation = q->isLeftToRight() ? BottomRightResize : BottomLeftResize; | - |
| 937 | int offset = q->style()->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth, 0, q) / 2; | - |
| 938 | int x = q->isLeftToRight() ? q->width() - offset : offset; | - |
| 939 | pressPos = QPoint(x, q->height() - offset); | - |
| 940 | } else { | - |
| 941 | return; | - |
| 942 | } | - |
| 943 | | - |
| 944 | updateCursor(); | - |
| 945 | #ifndef QT_NO_CURSOR | - |
| 946 | q->cursor().setPos(q->mapToGlobal(pressPos)); | - |
| 947 | #endif | - |
| 948 | mousePressPosition = q->mapToParent(pressPos); | - |
| 949 | oldGeometry = q->geometry(); | - |
| 950 | isInInteractiveMode = true; | - |
| 951 | q->setFocus(); | - |
| 952 | #ifndef QT_NO_RUBBERBAND | - |
| 953 | if ((q->testOption(QMdiSubWindow::RubberBandResize) | - |
| 954 | && (currentOperation == BottomRightResize || currentOperation == BottomLeftResize)) | - |
| 955 | || (q->testOption(QMdiSubWindow::RubberBandMove) && currentOperation == Move)) { | - |
| 956 | enterRubberBandMode(); | - |
| 957 | } else | - |
| 958 | #endif // QT_NO_RUBBERBAND | - |
| 959 | { | - |
| 960 | q->grabMouse(); | - |
| 961 | } | - |
| 962 | #endif // QT_NO_ACTION | - |
| 963 | } | - |
| 964 | | - |
| 965 | /*! | - |
| 966 | \internal | - |
| 967 | */ | - |
| 968 | void QMdiSubWindowPrivate::_q_processFocusChanged(QWidget *old, QWidget *now) | - |
| 969 | { | - |
| 970 | Q_UNUSED(old); | - |
| 971 | Q_Q(QMdiSubWindow); | - |
| 972 | if (now && (now == q || q->isAncestorOf(now))) { | - |
| 973 | if (now == q && !isInInteractiveMode) | - |
| 974 | setFocusWidget(); | - |
| 975 | setActive(true); | - |
| 976 | } | - |
| 977 | } | - |
| 978 | | - |
| 979 | /*! | - |
| 980 | \internal | - |
| 981 | */ | - |
| 982 | void QMdiSubWindowPrivate::leaveInteractiveMode() | - |
| 983 | { | - |
| 984 | Q_Q(QMdiSubWindow); | - |
| 985 | #ifndef QT_NO_RUBBERBAND | - |
| 986 | if (isInRubberBandMode) | - |
| 987 | leaveRubberBandMode(); | - |
| 988 | else | - |
| 989 | #endif | - |
| 990 | q->releaseMouse(); | - |
| 991 | isInInteractiveMode = false; | - |
| 992 | currentOperation = None; | - |
| 993 | updateDirtyRegions(); | - |
| 994 | updateCursor(); | - |
| 995 | if (baseWidget && baseWidget->focusWidget()) | - |
| 996 | baseWidget->focusWidget()->setFocus(); | - |
| 997 | } | - |
| 998 | | - |
| 999 | /*! | - |
| 1000 | \internal | - |
| 1001 | */ | - |
| 1002 | void QMdiSubWindowPrivate::removeBaseWidget() | - |
| 1003 | { | - |
| 1004 | if (!baseWidget) | - |
| 1005 | return; | - |
| 1006 | | - |
| 1007 | Q_Q(QMdiSubWindow); | - |
| 1008 | baseWidget->removeEventFilter(q); | - |
| 1009 | if (layout) | - |
| 1010 | layout->removeWidget(baseWidget); | - |
| 1011 | if (baseWidget->windowTitle() == q->windowTitle()) { | - |
| 1012 | ignoreWindowTitleChange = true; | - |
| 1013 | q->setWindowTitle(QString()); | - |
| 1014 | ignoreWindowTitleChange = false; | - |
| 1015 | q->setWindowModified(false); | - |
| 1016 | } | - |
| 1017 | lastChildWindowTitle.clear(); | - |
| 1018 | baseWidget->setParent(0); | - |
| 1019 | baseWidget = 0; | - |
| 1020 | isWidgetHiddenByUs = false; | - |
| 1021 | } | - |
| 1022 | | - |
| 1023 | /*! | - |
| 1024 | \internal | - |
| 1025 | */ | - |
| 1026 | void QMdiSubWindowPrivate::initOperationMap() | - |
| 1027 | { | - |
| 1028 | operationMap.insert(Move, OperationInfo(HMove | VMove, Qt::ArrowCursor, false)); | - |
| 1029 | operationMap.insert(TopResize, OperationInfo(VMove | VResize | VResizeReverse, Qt::SizeVerCursor)); | - |
| 1030 | operationMap.insert(BottomResize, OperationInfo(VResize, Qt::SizeVerCursor)); | - |
| 1031 | operationMap.insert(LeftResize, OperationInfo(HMove | HResize | HResizeReverse, Qt::SizeHorCursor)); | - |
| 1032 | operationMap.insert(RightResize, OperationInfo(HResize, Qt::SizeHorCursor)); | - |
| 1033 | operationMap.insert(TopLeftResize, OperationInfo(HMove | VMove | HResize | VResize | VResizeReverse | - |
| 1034 | | HResizeReverse, Qt::SizeFDiagCursor)); | - |
| 1035 | operationMap.insert(TopRightResize, OperationInfo(VMove | HResize | VResize | - |
| 1036 | | VResizeReverse, Qt::SizeBDiagCursor)); | - |
| 1037 | operationMap.insert(BottomLeftResize, OperationInfo(HMove | HResize | VResize | HResizeReverse, | - |
| 1038 | Qt::SizeBDiagCursor)); | - |
| 1039 | operationMap.insert(BottomRightResize, OperationInfo(HResize | VResize, Qt::SizeFDiagCursor)); | - |
| 1040 | } | - |
| 1041 | | - |
| 1042 | #ifndef QT_NO_MENU | - |
| 1043 | | - |
| 1044 | /*! | - |
| 1045 | \internal | - |
| 1046 | */ | - |
| 1047 | void QMdiSubWindowPrivate::createSystemMenu() | - |
| 1048 | { | - |
| 1049 | Q_Q(QMdiSubWindow); | - |
| 1050 | Q_ASSERT_X(q, "QMdiSubWindowPrivate::createSystemMenu", | - |
| 1051 | "You can NOT call this function before QMdiSubWindow's ctor"); | - |
| 1052 | systemMenu = new QMenu(q); | - |
| 1053 | const QStyle *style = q->style(); | - |
| 1054 | addToSystemMenu(RestoreAction, QMdiSubWindow::tr("&Restore"), SLOT(showNormal())); | - |
| 1055 | actions[RestoreAction]->setIcon(style->standardIcon(QStyle::SP_TitleBarNormalButton, 0, q)); | - |
| 1056 | actions[RestoreAction]->setEnabled(false); | - |
| 1057 | addToSystemMenu(MoveAction, QMdiSubWindow::tr("&Move"), SLOT(_q_enterInteractiveMode())); | - |
| 1058 | addToSystemMenu(ResizeAction, QMdiSubWindow::tr("&Size"), SLOT(_q_enterInteractiveMode())); | - |
| 1059 | addToSystemMenu(MinimizeAction, QMdiSubWindow::tr("Mi&nimize"), SLOT(showMinimized())); | - |
| 1060 | actions[MinimizeAction]->setIcon(style->standardIcon(QStyle::SP_TitleBarMinButton, 0, q)); | - |
| 1061 | addToSystemMenu(MaximizeAction, QMdiSubWindow::tr("Ma&ximize"), SLOT(showMaximized())); | - |
| 1062 | actions[MaximizeAction]->setIcon(style->standardIcon(QStyle::SP_TitleBarMaxButton, 0, q)); | - |
| 1063 | addToSystemMenu(StayOnTopAction, QMdiSubWindow::tr("Stay on &Top"), SLOT(_q_updateStaysOnTopHint())); | - |
| 1064 | actions[StayOnTopAction]->setCheckable(true); | - |
| 1065 | systemMenu->addSeparator(); | - |
| 1066 | addToSystemMenu(CloseAction, QMdiSubWindow::tr("&Close"), SLOT(close())); | - |
| 1067 | actions[CloseAction]->setIcon(style->standardIcon(QStyle::SP_TitleBarCloseButton, 0, q)); | - |
| 1068 | #if !defined(QT_NO_SHORTCUT) | - |
| 1069 | actions[CloseAction]->setShortcuts(QKeySequence::Close); | - |
| 1070 | #endif | - |
| 1071 | updateActions(); | - |
| 1072 | } | - |
| 1073 | #endif | - |
| 1074 | | - |
| 1075 | /*! | - |
| 1076 | \internal | - |
| 1077 | */ | - |
| 1078 | void QMdiSubWindowPrivate::updateCursor() | - |
| 1079 | { | - |
| 1080 | #ifndef QT_NO_CURSOR | - |
| 1081 | Q_Q(QMdiSubWindow); executed (the execution status of this line is deduced): QMdiSubWindow * const q = q_func(); | - |
| 1082 | #if defined(Q_WS_MACQ_OS_MAC) && !defined(QT_NO_STYLE_MAC) | - |
| 1083 | if (qobject_cast<QMacStyle *>(q->style())) | - |
| 1084 | return; | - |
| 1085 | #endif | - |
| 1086 | | - |
| 1087 | if (currentOperation == None) { evaluated: currentOperation == None| yes Evaluation Count:95 | yes Evaluation Count:19 |
| 19-95 |
| 1088 | q->unsetCursor(); executed (the execution status of this line is deduced): q->unsetCursor(); | - |
| 1089 | return; executed: return;Execution Count:95 | 95 |
| 1090 | } | - |
| 1091 | | - |
| 1092 | if (currentOperation == Move || operationMap.find(currentOperation).value().hover) { evaluated: currentOperation == Move| yes Evaluation Count:12 | yes Evaluation Count:7 |
partially evaluated: operationMap.find(currentOperation).value().hover| yes Evaluation Count:7 | no Evaluation Count:0 |
| 0-12 |
| 1093 | q->setCursor(operationMap.find(currentOperation).value().cursorShape); executed (the execution status of this line is deduced): q->setCursor(operationMap.find(currentOperation).value().cursorShape); | - |
| 1094 | return; executed: return;Execution Count:19 | 19 |
| 1095 | } | - |
| 1096 | #endif | - |
| 1097 | } | 0 |
| 1098 | | - |
| 1099 | /*! | - |
| 1100 | \internal | - |
| 1101 | */ | - |
| 1102 | void QMdiSubWindowPrivate::updateDirtyRegions() | - |
| 1103 | { | - |
| 1104 | // No update necessary | - |
| 1105 | if (!parent) | - |
| 1106 | return; | - |
| 1107 | | - |
| 1108 | foreach (Operation operation, operationMap.keys()) | - |
| 1109 | operationMap.find(operation).value().region = getRegion(operation); | - |
| 1110 | } | - |
| 1111 | | - |
| 1112 | /*! | - |
| 1113 | \internal | - |
| 1114 | */ | - |
| 1115 | void QMdiSubWindowPrivate::updateGeometryConstraints() | - |
| 1116 | { | - |
| 1117 | Q_Q(QMdiSubWindow); | - |
| 1118 | if (!parent) | - |
| 1119 | return; | - |
| 1120 | | - |
| 1121 | internalMinimumSize = (!q->isMinimized() && !q->minimumSize().isNull()) | - |
| 1122 | ? q->minimumSize() : q->minimumSizeHint(); | - |
| 1123 | int margin, minWidth; | - |
| 1124 | sizeParameters(&margin, &minWidth); | - |
| 1125 | q->setContentsMargins(margin, titleBarHeight(), margin, margin); | - |
| 1126 | if (q->isMaximized() || (q->isMinimized() && !q->isShaded())) { | - |
| 1127 | moveEnabled = false; | - |
| 1128 | resizeEnabled = false; | - |
| 1129 | } else { | - |
| 1130 | moveEnabled = true; | - |
| 1131 | if ((q->windowFlags() & Qt::MSWindowsFixedSizeDialogHint) || q->isShaded()) | - |
| 1132 | resizeEnabled = false; | - |
| 1133 | else | - |
| 1134 | resizeEnabled = true; | - |
| 1135 | } | - |
| 1136 | updateDirtyRegions(); | - |
| 1137 | } | - |
| 1138 | | - |
| 1139 | /*! | - |
| 1140 | \internal | - |
| 1141 | */ | - |
| 1142 | void QMdiSubWindowPrivate::updateMask() | - |
| 1143 | { | - |
| 1144 | Q_Q(QMdiSubWindow); | - |
| 1145 | if (!q->mask().isEmpty()) | - |
| 1146 | q->clearMask(); | - |
| 1147 | | - |
| 1148 | if (!parent) | - |
| 1149 | return; | - |
| 1150 | | - |
| 1151 | if ((q->isMaximized() && !drawTitleBarWhenMaximized()) | - |
| 1152 | || q->windowFlags() & Qt::FramelessWindowHint) | - |
| 1153 | return; | - |
| 1154 | | - |
| 1155 | if (resizeTimerId == -1) | - |
| 1156 | cachedStyleOptions = titleBarOptions(); | - |
| 1157 | cachedStyleOptions.rect = q->rect(); | - |
| 1158 | QStyleHintReturnMask frameMask; | - |
| 1159 | q->style()->styleHint(QStyle::SH_WindowFrame_Mask, &cachedStyleOptions, q, &frameMask); | - |
| 1160 | if (!frameMask.region.isEmpty()) | - |
| 1161 | q->setMask(frameMask.region); | - |
| 1162 | } | - |
| 1163 | | - |
| 1164 | /*! | - |
| 1165 | \internal | - |
| 1166 | */ | - |
| 1167 | void QMdiSubWindowPrivate::setNewGeometry(const QPoint &pos) | - |
| 1168 | { | - |
| 1169 | Q_Q(QMdiSubWindow); | - |
| 1170 | Q_ASSERT(currentOperation != None); | - |
| 1171 | Q_ASSERT(parent); | - |
| 1172 | | - |
| 1173 | uint cflags = operationMap.find(currentOperation).value().changeFlags; | - |
| 1174 | int posX = pos.x(); | - |
| 1175 | int posY = pos.y(); | - |
| 1176 | | - |
| 1177 | const bool restrictHorizontal = !q->testOption(QMdiSubWindow::AllowOutsideAreaHorizontally); | - |
| 1178 | const bool restrictVertical = !q->testOption(QMdiSubWindow::AllowOutsideAreaVertically); | - |
| 1179 | | - |
| 1180 | if (restrictHorizontal || restrictVertical) { | - |
| 1181 | QRect parentRect = q->parentWidget()->rect(); | - |
| 1182 | if (restrictVertical && (cflags & VResizeReverse || currentOperation == Move)) { | - |
| 1183 | posY = qMin(qMax(mousePressPosition.y() - oldGeometry.y(), posY), | - |
| 1184 | parentRect.height() - BoundaryMargin); | - |
| 1185 | } | - |
| 1186 | if (currentOperation == Move) { | - |
| 1187 | if (restrictHorizontal) | - |
| 1188 | posX = qMin(qMax(BoundaryMargin, posX), parentRect.width() - BoundaryMargin); | - |
| 1189 | if (restrictVertical) | - |
| 1190 | posY = qMin(posY, parentRect.height() - BoundaryMargin); | - |
| 1191 | } else { | - |
| 1192 | if (restrictHorizontal) { | - |
| 1193 | if (cflags & HResizeReverse) | - |
| 1194 | posX = qMax(mousePressPosition.x() - oldGeometry.x(), posX); | - |
| 1195 | else | - |
| 1196 | posX = qMin(parentRect.width() - (oldGeometry.x() + oldGeometry.width() | - |
| 1197 | - mousePressPosition.x()), posX); | - |
| 1198 | } | - |
| 1199 | if (restrictVertical && !(cflags & VResizeReverse)) { | - |
| 1200 | posY = qMin(parentRect.height() - (oldGeometry.y() + oldGeometry.height() | - |
| 1201 | - mousePressPosition.y()), posY); | - |
| 1202 | } | - |
| 1203 | } | - |
| 1204 | } | - |
| 1205 | | - |
| 1206 | QRect geometry; | - |
| 1207 | if (cflags & (HMove | VMove)) { | - |
| 1208 | int dx = getMoveDeltaComponent(cflags, HMove, HResize, posX - mousePressPosition.x(), | - |
| 1209 | oldGeometry.width() - internalMinimumSize.width(), | - |
| 1210 | oldGeometry.width() - q->maximumWidth()); | - |
| 1211 | int dy = getMoveDeltaComponent(cflags, VMove, VResize, posY - mousePressPosition.y(), | - |
| 1212 | oldGeometry.height() - internalMinimumSize.height(), | - |
| 1213 | oldGeometry.height() - q->maximumHeight()); | - |
| 1214 | geometry.setTopLeft(oldGeometry.topLeft() + QPoint(dx, dy)); | - |
| 1215 | } else { | - |
| 1216 | geometry.setTopLeft(q->geometry().topLeft()); | - |
| 1217 | } | - |
| 1218 | | - |
| 1219 | if (cflags & (HResize | VResize)) { | - |
| 1220 | int dx = getResizeDeltaComponent(cflags, HResize, HResizeReverse, | - |
| 1221 | posX - mousePressPosition.x()); | - |
| 1222 | int dy = getResizeDeltaComponent(cflags, VResize, VResizeReverse, | - |
| 1223 | posY - mousePressPosition.y()); | - |
| 1224 | geometry.setSize(oldGeometry.size() + QSize(dx, dy)); | - |
| 1225 | } else { | - |
| 1226 | geometry.setSize(q->geometry().size()); | - |
| 1227 | } | - |
| 1228 | | - |
| 1229 | setNewGeometry(&geometry); | - |
| 1230 | } | - |
| 1231 | | - |
| 1232 | /*! | - |
| 1233 | \internal | - |
| 1234 | */ | - |
| 1235 | void QMdiSubWindowPrivate::setMinimizeMode() | - |
| 1236 | { | - |
| 1237 | Q_Q(QMdiSubWindow); | - |
| 1238 | Q_ASSERT(parent); | - |
| 1239 | | - |
| 1240 | ensureWindowState(Qt::WindowMinimized); | - |
| 1241 | isShadeRequestFromMinimizeMode = true; | - |
| 1242 | q->showShaded(); | - |
| 1243 | isShadeRequestFromMinimizeMode = false; | - |
| 1244 | | - |
| 1245 | moveEnabled = false; | - |
| 1246 | #ifndef QT_NO_ACTION | - |
| 1247 | setEnabled(MoveAction, moveEnabled); | - |
| 1248 | #endif | - |
| 1249 | | - |
| 1250 | Q_ASSERT(q->windowState() & Qt::WindowMinimized); | - |
| 1251 | Q_ASSERT(!(q->windowState() & Qt::WindowMaximized)); | - |
| 1252 | // This should be a valid assert, but people can actually re-implement | - |
| 1253 | // setVisible and do crazy stuff, so we're not guaranteed that | - |
| 1254 | // the widget is hidden after calling hide(). | - |
| 1255 | // Q_ASSERT(baseWidget ? baseWidget->isHidden() : true); | - |
| 1256 | | - |
| 1257 | setActive(true); | - |
| 1258 | } | - |
| 1259 | | - |
| 1260 | /*! | - |
| 1261 | \internal | - |
| 1262 | */ | - |
| 1263 | void QMdiSubWindowPrivate::setNormalMode() | - |
| 1264 | { | - |
| 1265 | Q_Q(QMdiSubWindow); | - |
| 1266 | Q_ASSERT(parent); | - |
| 1267 | | - |
| 1268 | isShadeMode = false; | - |
| 1269 | isMaximizeMode = false; | - |
| 1270 | | - |
| 1271 | ensureWindowState(Qt::WindowNoState); | - |
| 1272 | #ifndef QT_NO_MENUBAR | - |
| 1273 | removeButtonsFromMenuBar(); | - |
| 1274 | #endif | - |
| 1275 | | - |
| 1276 | // Hide the window before we change the geometry to avoid multiple resize | - |
| 1277 | // events and wrong window state. | - |
| 1278 | const bool wasVisible = q->isVisible(); | - |
| 1279 | if (wasVisible) | - |
| 1280 | q->setVisible(false); | - |
| 1281 | | - |
| 1282 | // Restore minimum size if set by user. | - |
| 1283 | if (!userMinimumSize.isNull()) { | - |
| 1284 | q->setMinimumSize(userMinimumSize); | - |
| 1285 | userMinimumSize = QSize(0, 0); | - |
| 1286 | } | - |
| 1287 | | - |
| 1288 | // Show the internal widget if it was hidden by us, | - |
| 1289 | if (baseWidget && isWidgetHiddenByUs) { | - |
| 1290 | baseWidget->show(); | - |
| 1291 | isWidgetHiddenByUs = false; | - |
| 1292 | } | - |
| 1293 | | - |
| 1294 | updateGeometryConstraints(); | - |
| 1295 | QRect newGeometry = oldGeometry; | - |
| 1296 | newGeometry.setSize(restoreSize.expandedTo(internalMinimumSize)); | - |
| 1297 | q->setGeometry(newGeometry); | - |
| 1298 | | - |
| 1299 | if (wasVisible) | - |
| 1300 | q->setVisible(true); | - |
| 1301 | | - |
| 1302 | // Invalidate the restore size. | - |
| 1303 | restoreSize.setWidth(-1); | - |
| 1304 | restoreSize.setHeight(-1); | - |
| 1305 | | - |
| 1306 | #ifndef QT_NO_SIZEGRIP | - |
| 1307 | setSizeGripVisible(true); | - |
| 1308 | #endif | - |
| 1309 | | - |
| 1310 | #ifndef QT_NO_ACTION | - |
| 1311 | setEnabled(MoveAction, true); | - |
| 1312 | setEnabled(MaximizeAction, true); | - |
| 1313 | setEnabled(MinimizeAction, true); | - |
| 1314 | setEnabled(RestoreAction, false); | - |
| 1315 | setEnabled(ResizeAction, resizeEnabled); | - |
| 1316 | #endif // QT_NO_ACTION | - |
| 1317 | | - |
| 1318 | Q_ASSERT(!(q_func()->windowState() & Qt::WindowMinimized)); | - |
| 1319 | // This sub-window can be maximized when shown above if not the | - |
| 1320 | // QMdiArea::DontMaximizeSubWindowOnActionvation is set. Make sure | - |
| 1321 | // the Qt::WindowMaximized flag is set accordingly. | - |
| 1322 | Q_ASSERT((isMaximizeMode && q_func()->windowState() & Qt::WindowMaximized) | - |
| 1323 | || (!isMaximizeMode && !(q_func()->windowState() & Qt::WindowMaximized))); | - |
| 1324 | Q_ASSERT(!isShadeMode); | - |
| 1325 | | - |
| 1326 | setActive(true); | - |
| 1327 | restoreFocus(); | - |
| 1328 | updateMask(); | - |
| 1329 | } | - |
| 1330 | | - |
| 1331 | /*! | - |
| 1332 | \internal | - |
| 1333 | */ | - |
| 1334 | void QMdiSubWindowPrivate::setMaximizeMode() | - |
| 1335 | { | - |
| 1336 | Q_Q(QMdiSubWindow); | - |
| 1337 | Q_ASSERT(parent); | - |
| 1338 | | - |
| 1339 | ensureWindowState(Qt::WindowMaximized); | - |
| 1340 | isShadeMode = false; | - |
| 1341 | isMaximizeMode = true; | - |
| 1342 | | - |
| 1343 | if (!restoreFocusWidget && q->isAncestorOf(QApplication::focusWidget())) | - |
| 1344 | restoreFocusWidget = QApplication::focusWidget(); | - |
| 1345 | | - |
| 1346 | #ifndef QT_NO_SIZEGRIP | - |
| 1347 | setSizeGripVisible(false); | - |
| 1348 | #endif | - |
| 1349 | | - |
| 1350 | // Store old geometry and set restore size if not already set. | - |
| 1351 | if (!restoreSize.isValid()) { | - |
| 1352 | oldGeometry = q->geometry(); | - |
| 1353 | restoreSize.setWidth(oldGeometry.width()); | - |
| 1354 | restoreSize.setHeight(oldGeometry.height()); | - |
| 1355 | } | - |
| 1356 | | - |
| 1357 | // Hide the window before we change the geometry to avoid multiple resize | - |
| 1358 | // events and wrong window state. | - |
| 1359 | const bool wasVisible = q->isVisible(); | - |
| 1360 | if (wasVisible) | - |
| 1361 | q->setVisible(false); | - |
| 1362 | | - |
| 1363 | // Show the internal widget if it was hidden by us. | - |
| 1364 | if (baseWidget && isWidgetHiddenByUs) { | - |
| 1365 | baseWidget->show(); | - |
| 1366 | isWidgetHiddenByUs = false; | - |
| 1367 | } | - |
| 1368 | | - |
| 1369 | updateGeometryConstraints(); | - |
| 1370 | | - |
| 1371 | if (wasVisible) { | - |
| 1372 | #ifndef QT_NO_MENUBAR | - |
| 1373 | if (QMenuBar *mBar = menuBar()) | - |
| 1374 | showButtonsInMenuBar(mBar); | - |
| 1375 | else | - |
| 1376 | #endif | - |
| 1377 | if (!controlContainer) | - |
| 1378 | controlContainer = new ControlContainer(q); | - |
| 1379 | } | - |
| 1380 | | - |
| 1381 | QWidget *parent = q->parentWidget(); | - |
| 1382 | QRect availableRect = parent->contentsRect(); | - |
| 1383 | | - |
| 1384 | // Adjust geometry if the sub-window is inside a scroll area. | - |
| 1385 | QAbstractScrollArea *scrollArea = qobject_cast<QAbstractScrollArea *>(parent->parentWidget()); | - |
| 1386 | if (scrollArea && scrollArea->viewport() == parent) { | - |
| 1387 | QScrollBar *hbar = scrollArea->horizontalScrollBar(); | - |
| 1388 | QScrollBar *vbar = scrollArea->verticalScrollBar(); | - |
| 1389 | const int xOffset = hbar ? hbar->value() : 0; | - |
| 1390 | const int yOffset = vbar ? vbar->value() : 0; | - |
| 1391 | availableRect.adjust(-xOffset, -yOffset, -xOffset, -yOffset); | - |
| 1392 | oldGeometry.adjust(xOffset, yOffset, xOffset, yOffset); | - |
| 1393 | } | - |
| 1394 | | - |
| 1395 | setNewGeometry(&availableRect); | - |
| 1396 | // QWidget::setGeometry will reset Qt::WindowMaximized so we have to update it here. | - |
| 1397 | ensureWindowState(Qt::WindowMaximized); | - |
| 1398 | | - |
| 1399 | if (wasVisible) | - |
| 1400 | q->setVisible(true); | - |
| 1401 | | - |
| 1402 | resizeEnabled = false; | - |
| 1403 | moveEnabled = false; | - |
| 1404 | | - |
| 1405 | #ifndef QT_NO_ACTION | - |
| 1406 | setEnabled(MoveAction, moveEnabled); | - |
| 1407 | setEnabled(MaximizeAction, false); | - |
| 1408 | setEnabled(MinimizeAction, true); | - |
| 1409 | setEnabled(RestoreAction, true); | - |
| 1410 | setEnabled(ResizeAction, resizeEnabled); | - |
| 1411 | #endif // QT_NO_ACTION | - |
| 1412 | | - |
| 1413 | Q_ASSERT(q->windowState() & Qt::WindowMaximized); | - |
| 1414 | Q_ASSERT(!(q->windowState() & Qt::WindowMinimized)); | - |
| 1415 | | - |
| 1416 | restoreFocus(); | - |
| 1417 | updateMask(); | - |
| 1418 | } | - |
| 1419 | | - |
| 1420 | /*! | - |
| 1421 | \internal | - |
| 1422 | */ | - |
| 1423 | void QMdiSubWindowPrivate::setActive(bool activate, bool changeFocus) | - |
| 1424 | { | - |
| 1425 | Q_Q(QMdiSubWindow); | - |
| 1426 | if (!parent || !activationEnabled) | - |
| 1427 | return; | - |
| 1428 | | - |
| 1429 | if (activate && !isActive && q->isEnabled()) { | - |
| 1430 | isActive = true; | - |
| 1431 | isExplicitlyDeactivated = false; | - |
| 1432 | Qt::WindowStates oldWindowState = q->windowState(); | - |
| 1433 | ensureWindowState(Qt::WindowActive); | - |
| 1434 | emit q->aboutToActivate(); | - |
| 1435 | #ifndef QT_NO_MENUBAR | - |
| 1436 | if (QMenuBar *mBar = menuBar()) | - |
| 1437 | showButtonsInMenuBar(mBar); | - |
| 1438 | #endif | - |
| 1439 | Q_ASSERT(isActive); | - |
| 1440 | emit q->windowStateChanged(oldWindowState, q->windowState()); | - |
| 1441 | } else if (!activate && isActive) { | - |
| 1442 | isActive = false; | - |
| 1443 | Qt::WindowStates oldWindowState = q->windowState(); | - |
| 1444 | q->overrideWindowState(q->windowState() & ~Qt::WindowActive); | - |
| 1445 | if (changeFocus) { | - |
| 1446 | QWidget *focusWidget = QApplication::focusWidget(); | - |
| 1447 | if (focusWidget && (focusWidget == q || q->isAncestorOf(focusWidget))) | - |
| 1448 | focusWidget->clearFocus(); | - |
| 1449 | } | - |
| 1450 | if (baseWidget) | - |
| 1451 | baseWidget->overrideWindowState(baseWidget->windowState() & ~Qt::WindowActive); | - |
| 1452 | Q_ASSERT(!isActive); | - |
| 1453 | emit q->windowStateChanged(oldWindowState, q->windowState()); | - |
| 1454 | } | - |
| 1455 | | - |
| 1456 | if (activate && isActive && q->isEnabled() && !q->hasFocus() | - |
| 1457 | && !q->isAncestorOf(QApplication::focusWidget())) { | - |
| 1458 | if (changeFocus) | - |
| 1459 | setFocusWidget(); | - |
| 1460 | ensureWindowState(Qt::WindowActive); | - |
| 1461 | } | - |
| 1462 | | - |
| 1463 | int frameWidth = q->style()->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth, 0, q); | - |
| 1464 | int titleBarHeight = this->titleBarHeight(); | - |
| 1465 | QRegion windowDecoration = QRegion(0, 0, q->width(), q->height()); | - |
| 1466 | windowDecoration -= QRegion(frameWidth, titleBarHeight, q->width() - 2 * frameWidth, | - |
| 1467 | q->height() - titleBarHeight - frameWidth); | - |
| 1468 | | - |
| 1469 | // Make sure we don't use cached style options if we get | - |
| 1470 | // resize events right before activation/deactivation. | - |
| 1471 | if (resizeTimerId != -1) { | - |
| 1472 | q->killTimer(resizeTimerId); | - |
| 1473 | resizeTimerId = -1; | - |
| 1474 | updateDirtyRegions(); | - |
| 1475 | } | - |
| 1476 | | - |
| 1477 | q->update(windowDecoration); | - |
| 1478 | } | - |
| 1479 | | - |
| 1480 | /*! | - |
| 1481 | \internal | - |
| 1482 | */ | - |
| 1483 | void QMdiSubWindowPrivate::processClickedSubControl() | - |
| 1484 | { | - |
| 1485 | Q_Q(QMdiSubWindow); never executed (the execution status of this line is deduced): QMdiSubWindow * const q = q_func(); | - |
| 1486 | switch (activeSubControl) { | - |
| 1487 | case QStyle::SC_TitleBarContextHelpButton: | - |
| 1488 | #ifndef QT_NO_WHATSTHIS | - |
| 1489 | QWhatsThis::enterWhatsThisMode(); never executed (the execution status of this line is deduced): QWhatsThis::enterWhatsThisMode(); | - |
| 1490 | #endif | - |
| 1491 | break; | 0 |
| 1492 | case QStyle::SC_TitleBarShadeButton: | - |
| 1493 | q->showShaded(); never executed (the execution status of this line is deduced): q->showShaded(); | - |
| 1494 | hoveredSubControl = QStyle::SC_TitleBarUnshadeButton; never executed (the execution status of this line is deduced): hoveredSubControl = QStyle::SC_TitleBarUnshadeButton; | - |
| 1495 | break; | 0 |
| 1496 | case QStyle::SC_TitleBarUnshadeButton: | - |
| 1497 | if (q->isShaded()) never evaluated: q->isShaded() | 0 |
| 1498 | hoveredSubControl = QStyle::SC_TitleBarShadeButton; never executed: hoveredSubControl = QStyle::SC_TitleBarShadeButton; | 0 |
| 1499 | q->showNormal(); never executed (the execution status of this line is deduced): q->showNormal(); | - |
| 1500 | break; | 0 |
| 1501 | case QStyle::SC_TitleBarMinButton: | - |
| 1502 | #if defined(Q_WS_MACQ_OS_MAC) && !defined(QT_NO_STYLE_MAC) | - |
| 1503 | if (qobject_cast<QMacStyle *>(q->style())) { | - |
| 1504 | if (q->isMinimized()) | - |
| 1505 | q->showNormal(); | - |
| 1506 | else | - |
| 1507 | q->showMinimized(); | - |
| 1508 | break; | - |
| 1509 | } | - |
| 1510 | #endif | - |
| 1511 | q->showMinimized(); never executed (the execution status of this line is deduced): q->showMinimized(); | - |
| 1512 | break; | 0 |
| 1513 | case QStyle::SC_TitleBarNormalButton: | - |
| 1514 | if (q->isShaded()) never evaluated: q->isShaded() | 0 |
| 1515 | hoveredSubControl = QStyle::SC_TitleBarMinButton; never executed: hoveredSubControl = QStyle::SC_TitleBarMinButton; | 0 |
| 1516 | q->showNormal(); never executed (the execution status of this line is deduced): q->showNormal(); | - |
| 1517 | break; | 0 |
| 1518 | case QStyle::SC_TitleBarMaxButton: | - |
| 1519 | #if defined(Q_WS_MACQ_OS_MAC) && !defined(QT_NO_STYLE_MAC) | - |
| 1520 | if (qobject_cast<QMacStyle *>(q->style())) { | - |
| 1521 | if (q->isMaximized()) | - |
| 1522 | q->showNormal(); | - |
| 1523 | else | - |
| 1524 | q->showMaximized(); | - |
| 1525 | break; | - |
| 1526 | } | - |
| 1527 | #endif | - |
| 1528 | q->showMaximized(); never executed (the execution status of this line is deduced): q->showMaximized(); | - |
| 1529 | break; | 0 |
| 1530 | case QStyle::SC_TitleBarCloseButton: | - |
| 1531 | q->close(); never executed (the execution status of this line is deduced): q->close(); | - |
| 1532 | break; | 0 |
| 1533 | default: | - |
| 1534 | break; | 0 |
| 1535 | } | - |
| 1536 | } | 0 |
| 1537 | | - |
| 1538 | /*! | - |
| 1539 | \internal | - |
| 1540 | */ | - |
| 1541 | QRegion QMdiSubWindowPrivate::getRegion(Operation operation) const | - |
| 1542 | { | - |
| 1543 | Q_Q(const QMdiSubWindow); executed (the execution status of this line is deduced): const QMdiSubWindow * const q = q_func(); | - |
| 1544 | int width = q->width(); executed (the execution status of this line is deduced): int width = q->width(); | - |
| 1545 | int height = q->height(); executed (the execution status of this line is deduced): int height = q->height(); | - |
| 1546 | int titleBarHeight = this->titleBarHeight(); executed (the execution status of this line is deduced): int titleBarHeight = this->titleBarHeight(); | - |
| 1547 | int frameWidth = q->style()->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth, 0, q); executed (the execution status of this line is deduced): int frameWidth = q->style()->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth, 0, q); | - |
| 1548 | int cornerConst = titleBarHeight - frameWidth; executed (the execution status of this line is deduced): int cornerConst = titleBarHeight - frameWidth; | - |
| 1549 | int titleBarConst = 2 * titleBarHeight; executed (the execution status of this line is deduced): int titleBarConst = 2 * titleBarHeight; | - |
| 1550 | | - |
| 1551 | if (operation == Move) { evaluated: operation == Move| yes Evaluation Count:938 | yes Evaluation Count:7504 |
| 938-7504 |
| 1552 | QStyleOptionTitleBar titleBarOptions = this->titleBarOptions(); executed (the execution status of this line is deduced): QStyleOptionTitleBar titleBarOptions = this->titleBarOptions(); | - |
| 1553 | QRegion move(frameWidth, frameWidth, width - 2 * frameWidth, cornerConst); executed (the execution status of this line is deduced): QRegion move(frameWidth, frameWidth, width - 2 * frameWidth, cornerConst); | - |
| 1554 | // Depending on which window flags are set, activated sub controllers will | - |
| 1555 | // be subtracted from the 'move' region. | - |
| 1556 | for (int i = 0; i < NumSubControls; ++i) { evaluated: i < NumSubControls| yes Evaluation Count:8442 | yes Evaluation Count:938 |
| 938-8442 |
| 1557 | if (SubControls[i] == QStyle::SC_TitleBarLabel) evaluated: SubControls[i] == QStyle::SC_TitleBarLabel| yes Evaluation Count:938 | yes Evaluation Count:7504 |
| 938-7504 |
| 1558 | continue; executed: continue;Execution Count:938 | 938 |
| 1559 | move -= QRegion(q->style()->subControlRect(QStyle::CC_TitleBar, &titleBarOptions, executed (the execution status of this line is deduced): move -= QRegion(q->style()->subControlRect(QStyle::CC_TitleBar, &titleBarOptions, | - |
| 1560 | SubControls[i])); executed (the execution status of this line is deduced): SubControls[i])); | - |
| 1561 | } executed: }Execution Count:7504 | 7504 |
| 1562 | return move; executed: return move;Execution Count:938 | 938 |
| 1563 | } | - |
| 1564 | | - |
| 1565 | QRegion region; executed (the execution status of this line is deduced): QRegion region; | - |
| 1566 | #if defined(Q_WS_MACQ_OS_MAC) && !defined(QT_NO_STYLE_MAC) | - |
| 1567 | if (qobject_cast<QMacStyle *>(q->style())) | - |
| 1568 | return region; | - |
| 1569 | #endif | - |
| 1570 | | - |
| 1571 | switch (operation) { | - |
| 1572 | case TopResize: | - |
| 1573 | region = QRegion(titleBarHeight, 0, width - titleBarConst, frameWidth); executed (the execution status of this line is deduced): region = QRegion(titleBarHeight, 0, width - titleBarConst, frameWidth); | - |
| 1574 | break; executed: break;Execution Count:938 | 938 |
| 1575 | case BottomResize: | - |
| 1576 | region = QRegion(titleBarHeight, height - frameWidth, width - titleBarConst, frameWidth); executed (the execution status of this line is deduced): region = QRegion(titleBarHeight, height - frameWidth, width - titleBarConst, frameWidth); | - |
| 1577 | break; executed: break;Execution Count:938 | 938 |
| 1578 | case LeftResize: | - |
| 1579 | region = QRegion(0, titleBarHeight, frameWidth, height - titleBarConst); executed (the execution status of this line is deduced): region = QRegion(0, titleBarHeight, frameWidth, height - titleBarConst); | - |
| 1580 | break; executed: break;Execution Count:938 | 938 |
| 1581 | case RightResize: | - |
| 1582 | region = QRegion(width - frameWidth, titleBarHeight, frameWidth, height - titleBarConst); executed (the execution status of this line is deduced): region = QRegion(width - frameWidth, titleBarHeight, frameWidth, height - titleBarConst); | - |
| 1583 | break; executed: break;Execution Count:938 | 938 |
| 1584 | case TopLeftResize: | - |
| 1585 | region = QRegion(0, 0, titleBarHeight, titleBarHeight) executed (the execution status of this line is deduced): region = QRegion(0, 0, titleBarHeight, titleBarHeight) | - |
| 1586 | - QRegion(frameWidth, frameWidth, cornerConst, cornerConst); executed (the execution status of this line is deduced): - QRegion(frameWidth, frameWidth, cornerConst, cornerConst); | - |
| 1587 | break; executed: break;Execution Count:938 | 938 |
| 1588 | case TopRightResize: | - |
| 1589 | region = QRegion(width - titleBarHeight, 0, titleBarHeight, titleBarHeight) executed (the execution status of this line is deduced): region = QRegion(width - titleBarHeight, 0, titleBarHeight, titleBarHeight) | - |
| 1590 | - QRegion(width - titleBarHeight, frameWidth, cornerConst, cornerConst); executed (the execution status of this line is deduced): - QRegion(width - titleBarHeight, frameWidth, cornerConst, cornerConst); | - |
| 1591 | break; executed: break;Execution Count:938 | 938 |
| 1592 | case BottomLeftResize: | - |
| 1593 | region = QRegion(0, height - titleBarHeight, titleBarHeight, titleBarHeight) executed (the execution status of this line is deduced): region = QRegion(0, height - titleBarHeight, titleBarHeight, titleBarHeight) | - |
| 1594 | - QRegion(frameWidth, height - titleBarHeight, cornerConst, cornerConst); executed (the execution status of this line is deduced): - QRegion(frameWidth, height - titleBarHeight, cornerConst, cornerConst); | - |
| 1595 | break; executed: break;Execution Count:938 | 938 |
| 1596 | case BottomRightResize: | - |
| 1597 | region = QRegion(width - titleBarHeight, height - titleBarHeight, titleBarHeight, titleBarHeight) executed (the execution status of this line is deduced): region = QRegion(width - titleBarHeight, height - titleBarHeight, titleBarHeight, titleBarHeight) | - |
| 1598 | - QRegion(width - titleBarHeight, height - titleBarHeight, cornerConst, cornerConst); executed (the execution status of this line is deduced): - QRegion(width - titleBarHeight, height - titleBarHeight, cornerConst, cornerConst); | - |
| 1599 | break; executed: break;Execution Count:938 | 938 |
| 1600 | default: | - |
| 1601 | break; | 0 |
| 1602 | } | - |
| 1603 | | - |
| 1604 | return region; executed: return region;Execution Count:7504 | 7504 |
| 1605 | } | - |
| 1606 | | - |
| 1607 | /*! | - |
| 1608 | \internal | - |
| 1609 | */ | - |
| 1610 | QMdiSubWindowPrivate::Operation QMdiSubWindowPrivate::getOperation(const QPoint &pos) const | - |
| 1611 | { | - |
| 1612 | OperationInfoMap::const_iterator it; | - |
| 1613 | for (it = operationMap.constBegin(); it != operationMap.constEnd(); ++it) | - |
| 1614 | if (it.value().region.contains(pos)) | - |
| 1615 | return it.key(); | - |
| 1616 | return None; | - |
| 1617 | } | - |
| 1618 | | - |
| 1619 | extern QString qt_setWindowTitle_helperHelper(const QString&, const QWidget*); | - |
| 1620 | | - |
| 1621 | /*! | - |
| 1622 | \internal | - |
| 1623 | */ | - |
| 1624 | QStyleOptionTitleBar QMdiSubWindowPrivate::titleBarOptions() const | - |
| 1625 | { | - |
| 1626 | Q_Q(const QMdiSubWindow); | - |
| 1627 | QStyleOptionTitleBar titleBarOptions; | - |
| 1628 | titleBarOptions.initFrom(q); | - |
| 1629 | if (activeSubControl != QStyle::SC_None) { | - |
| 1630 | if (hoveredSubControl == activeSubControl) { | - |
| 1631 | titleBarOptions.state |= QStyle::State_Sunken; | - |
| 1632 | titleBarOptions.activeSubControls = activeSubControl; | - |
| 1633 | } | - |
| 1634 | } else if (autoRaise() && hoveredSubControl != QStyle::SC_None | - |
| 1635 | && hoveredSubControl != QStyle::SC_TitleBarLabel) { | - |
| 1636 | titleBarOptions.state |= QStyle::State_MouseOver; | - |
| 1637 | titleBarOptions.activeSubControls = hoveredSubControl; | - |
| 1638 | } else { | - |
| 1639 | titleBarOptions.state &= ~QStyle::State_MouseOver; | - |
| 1640 | titleBarOptions.activeSubControls = QStyle::SC_None; | - |
| 1641 | } | - |
| 1642 | | - |
| 1643 | titleBarOptions.subControls = QStyle::SC_All; | - |
| 1644 | titleBarOptions.titleBarFlags = q->windowFlags(); | - |
| 1645 | titleBarOptions.titleBarState = q->windowState(); | - |
| 1646 | titleBarOptions.palette = titleBarPalette; | - |
| 1647 | titleBarOptions.icon = menuIcon; | - |
| 1648 | | - |
| 1649 | if (isActive) { | - |
| 1650 | titleBarOptions.state |= QStyle::State_Active; | - |
| 1651 | titleBarOptions.titleBarState |= QStyle::State_Active; | - |
| 1652 | titleBarOptions.palette.setCurrentColorGroup(QPalette::Active); | - |
| 1653 | } else { | - |
| 1654 | titleBarOptions.state &= ~QStyle::State_Active; | - |
| 1655 | titleBarOptions.palette.setCurrentColorGroup(QPalette::Inactive); | - |
| 1656 | } | - |
| 1657 | | - |
| 1658 | int border = hasBorder(titleBarOptions) ? 4 : 0; | - |
| 1659 | int paintHeight = titleBarHeight(titleBarOptions); | - |
| 1660 | paintHeight -= q->isMinimized() ? 2 * border : border; | - |
| 1661 | titleBarOptions.rect = QRect(border, border, q->width() - 2 * border, paintHeight); | - |
| 1662 | | - |
| 1663 | if (!windowTitle.isEmpty()) { | - |
| 1664 | // Set the text here before asking for the width of the title bar label | - |
| 1665 | // in case people uses the actual text to calculate the width. | - |
| 1666 | titleBarOptions.text = windowTitle; | - |
| 1667 | titleBarOptions.fontMetrics = QFontMetrics(font); | - |
| 1668 | int width = q->style()->subControlRect(QStyle::CC_TitleBar, &titleBarOptions, | - |
| 1669 | QStyle::SC_TitleBarLabel, q).width(); | - |
| 1670 | // Set elided text if we don't have enough space for the entire title. | - |
| 1671 | titleBarOptions.text = titleBarOptions.fontMetrics.elidedText(windowTitle, Qt::ElideRight, width); | - |
| 1672 | } | - |
| 1673 | return titleBarOptions; | - |
| 1674 | } | - |
| 1675 | | - |
| 1676 | /*! | - |
| 1677 | \internal | - |
| 1678 | */ | - |
| 1679 | void QMdiSubWindowPrivate::ensureWindowState(Qt::WindowState state) | - |
| 1680 | { | - |
| 1681 | Q_Q(QMdiSubWindow); | - |
| 1682 | Qt::WindowStates windowStates = q->windowState() | state; | - |
| 1683 | switch (state) { | - |
| 1684 | case Qt::WindowMinimized: | - |
| 1685 | windowStates &= ~Qt::WindowMaximized; | - |
| 1686 | windowStates &= ~Qt::WindowNoState; | - |
| 1687 | break; | - |
| 1688 | case Qt::WindowMaximized: | - |
| 1689 | windowStates &= ~Qt::WindowMinimized; | - |
| 1690 | windowStates &= ~Qt::WindowNoState; | - |
| 1691 | break; | - |
| 1692 | case Qt::WindowNoState: | - |
| 1693 | windowStates &= ~Qt::WindowMinimized; | - |
| 1694 | windowStates &= ~Qt::WindowMaximized; | - |
| 1695 | break; | - |
| 1696 | default: | - |
| 1697 | break; | - |
| 1698 | } | - |
| 1699 | if (baseWidget) { | - |
| 1700 | if (!(baseWidget->windowState() & Qt::WindowActive) && windowStates & Qt::WindowActive) | - |
| 1701 | baseWidget->overrideWindowState(windowStates & ~Qt::WindowActive); | - |
| 1702 | else | - |
| 1703 | baseWidget->overrideWindowState(windowStates); | - |
| 1704 | } | - |
| 1705 | q->overrideWindowState(windowStates); | - |
| 1706 | } | - |
| 1707 | | - |
| 1708 | /*! | - |
| 1709 | \internal | - |
| 1710 | */ | - |
| 1711 | int QMdiSubWindowPrivate::titleBarHeight(const QStyleOptionTitleBar &options) const | - |
| 1712 | { | - |
| 1713 | Q_Q(const QMdiSubWindow); executed (the execution status of this line is deduced): const QMdiSubWindow * const q = q_func(); | - |
| 1714 | if (!parent || q->windowFlags() & Qt::FramelessWindowHint partially evaluated: !parent| no Evaluation Count:0 | yes Evaluation Count:13954 |
partially evaluated: q->windowFlags() & Qt::FramelessWindowHint| no Evaluation Count:0 | yes Evaluation Count:13954 |
| 0-13954 |
| 1715 | || (q->isMaximized() && !drawTitleBarWhenMaximized())) { evaluated: q->isMaximized()| yes Evaluation Count:1719 | yes Evaluation Count:12235 |
evaluated: !drawTitleBarWhenMaximized()| yes Evaluation Count:190 | yes Evaluation Count:1529 |
| 190-12235 |
| 1716 | return 0; executed: return 0;Execution Count:190 | 190 |
| 1717 | } | - |
| 1718 | | - |
| 1719 | int height = q->style()->pixelMetric(QStyle::PM_TitleBarHeight, &options, q); executed (the execution status of this line is deduced): int height = q->style()->pixelMetric(QStyle::PM_TitleBarHeight, &options, q); | - |
| 1720 | #if defined(Q_WS_MACQ_OS_MAC) && !defined(QT_NO_STYLE_MAC) | - |
| 1721 | // ### Fix mac style, the +4 pixels hack is not necessary anymore | - |
| 1722 | if (qobject_cast<QMacStyle *>(q->style())) | - |
| 1723 | height -= 4; | - |
| 1724 | #endif | - |
| 1725 | if (hasBorder(options)) partially evaluated: hasBorder(options)| yes Evaluation Count:13764 | no Evaluation Count:0 |
| 0-13764 |
| 1726 | height += q->isMinimized() ? 8 : 4; executed: height += q->isMinimized() ? 8 : 4;Execution Count:13764 evaluated: q->isMinimized()| yes Evaluation Count:1118 | yes Evaluation Count:12646 |
| 1118-13764 |
| 1727 | return height; executed: return height;Execution Count:13764 | 13764 |
| 1728 | } | - |
| 1729 | | - |
| 1730 | /*! | - |
| 1731 | \internal | - |
| 1732 | */ | - |
| 1733 | void QMdiSubWindowPrivate::sizeParameters(int *margin, int *minWidth) const | - |
| 1734 | { | - |
| 1735 | Q_Q(const QMdiSubWindow); | - |
| 1736 | Qt::WindowFlags flags = q->windowFlags(); | - |
| 1737 | if (!parent || flags & Qt::FramelessWindowHint) { | - |
| 1738 | *margin = 0; | - |
| 1739 | *minWidth = 0; | - |
| 1740 | return; | - |
| 1741 | } | - |
| 1742 | | - |
| 1743 | if (q->isMaximized() && !drawTitleBarWhenMaximized()) | - |
| 1744 | *margin = 0; | - |
| 1745 | else | - |
| 1746 | *margin = q->style()->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth, 0, q); | - |
| 1747 | | - |
| 1748 | QStyleOptionTitleBar opt = this->titleBarOptions(); | - |
| 1749 | int tempWidth = 0; | - |
| 1750 | for (int i = 0; i < NumSubControls; ++i) { | - |
| 1751 | if (SubControls[i] == QStyle::SC_TitleBarLabel) { | - |
| 1752 | tempWidth += 30; | - |
| 1753 | continue; | - |
| 1754 | } | - |
| 1755 | QRect rect = q->style()->subControlRect(QStyle::CC_TitleBar, &opt, SubControls[i], q); | - |
| 1756 | if (!rect.isValid()) | - |
| 1757 | continue; | - |
| 1758 | tempWidth += rect.width(); | - |
| 1759 | } | - |
| 1760 | *minWidth = tempWidth; | - |
| 1761 | } | - |
| 1762 | | - |
| 1763 | /*! | - |
| 1764 | \internal | - |
| 1765 | */ | - |
| 1766 | bool QMdiSubWindowPrivate::drawTitleBarWhenMaximized() const | - |
| 1767 | { | - |
| 1768 | Q_Q(const QMdiSubWindow); executed (the execution status of this line is deduced): const QMdiSubWindow * const q = q_func(); | - |
| 1769 | if (q->window()->testAttribute(Qt::WA_CanHostQMdiSubWindowTitleBar)) partially evaluated: q->window()->testAttribute(Qt::WA_CanHostQMdiSubWindowTitleBar)| no Evaluation Count:0 | yes Evaluation Count:5092 |
| 0-5092 |
| 1770 | return false; never executed: return false; | 0 |
| 1771 | | - |
| 1772 | if (isChildOfTabbedQMdiArea(q)) partially evaluated: isChildOfTabbedQMdiArea(q)| no Evaluation Count:0 | yes Evaluation Count:5092 |
| 0-5092 |
| 1773 | return false; never executed: return false; | 0 |
| 1774 | | - |
| 1775 | #if defined(Q_WS_MACQ_OS_MAC) && !defined(QT_NO_STYLE_MAC) || defined(Q_OS_WINCE_WM) | - |
| 1776 | return true; | - |
| 1777 | #else | - |
| 1778 | if (q->style()->styleHint(QStyle::SH_Workspace_FillSpaceOnMaximize, 0, q)) partially evaluated: q->style()->styleHint(QStyle::SH_Workspace_FillSpaceOnMaximize, 0, q)| no Evaluation Count:0 | yes Evaluation Count:5092 |
| 0-5092 |
| 1779 | return true; never executed: return true; | 0 |
| 1780 | #if defined(QT_NO_MENUBAR) || defined(QT_NO_MAINWINDOW) | - |
| 1781 | return true; | - |
| 1782 | #else | - |
| 1783 | QMainWindow *mainWindow = qobject_cast<QMainWindow *>(q->window()); executed (the execution status of this line is deduced): QMainWindow *mainWindow = qobject_cast<QMainWindow *>(q->window()); | - |
| 1784 | if (!mainWindow || !qobject_cast<QMenuBar *>(mainWindow->menuWidget()) evaluated: !mainWindow| yes Evaluation Count:1363 | yes Evaluation Count:3729 |
evaluated: !qobject_cast<QMenuBar *>(mainWindow->menuWidget())| yes Evaluation Count:274 | yes Evaluation Count:3455 |
| 274-3729 |
| 1785 | || mainWindow->menuWidget()->isHidden()) evaluated: mainWindow->menuWidget()->isHidden()| yes Evaluation Count:950 | yes Evaluation Count:2505 |
| 950-2505 |
| 1786 | return true; executed: return true;Execution Count:2587 | 2587 |
| 1787 | | - |
| 1788 | return isChildOfQMdiSubWindow(q); executed: return isChildOfQMdiSubWindow(q);Execution Count:2505 | 2505 |
| 1789 | #endif | - |
| 1790 | #endif | - |
| 1791 | } | - |
| 1792 | | - |
| 1793 | #ifndef QT_NO_MENUBAR | - |
| 1794 | | - |
| 1795 | /*! | - |
| 1796 | \internal | - |
| 1797 | */ | - |
| 1798 | void QMdiSubWindowPrivate::showButtonsInMenuBar(QMenuBar *menuBar) | - |
| 1799 | { | - |
| 1800 | Q_Q(QMdiSubWindow); | - |
| 1801 | Q_ASSERT(q->isMaximized() && !drawTitleBarWhenMaximized()); | - |
| 1802 | | - |
| 1803 | if (isChildOfTabbedQMdiArea(q)) | - |
| 1804 | return; | - |
| 1805 | | - |
| 1806 | removeButtonsFromMenuBar(); | - |
| 1807 | if (!controlContainer) | - |
| 1808 | controlContainer = new ControlContainer(q); | - |
| 1809 | | - |
| 1810 | ignoreWindowTitleChange = true; | - |
| 1811 | controlContainer->showButtonsInMenuBar(menuBar); | - |
| 1812 | ignoreWindowTitleChange = false; | - |
| 1813 | | - |
| 1814 | QWidget *topLevelWindow = q->window(); | - |
| 1815 | topLevelWindow->setWindowModified(q->isWindowModified()); | - |
| 1816 | topLevelWindow->installEventFilter(q); | - |
| 1817 | | - |
| 1818 | int buttonHeight = 0; | - |
| 1819 | if (controlContainer->controllerWidget()) | - |
| 1820 | buttonHeight = controlContainer->controllerWidget()->height(); | - |
| 1821 | else if (controlContainer->systemMenuLabel()) | - |
| 1822 | buttonHeight = controlContainer->systemMenuLabel()->height(); | - |
| 1823 | | - |
| 1824 | // This will rarely happen. | - |
| 1825 | if (menuBar && menuBar->height() < buttonHeight | - |
| 1826 | && topLevelWindow->layout()) { | - |
| 1827 | // Make sure topLevelWindow->contentsRect returns correct geometry. | - |
| 1828 | // topLevelWidget->updateGeoemtry will not do the trick here since it will post the event. | - |
| 1829 | QEvent event(QEvent::LayoutRequest); | - |
| 1830 | QApplication::sendEvent(topLevelWindow, &event); | - |
| 1831 | } | - |
| 1832 | } | - |
| 1833 | | - |
| 1834 | /*! | - |
| 1835 | \internal | - |
| 1836 | */ | - |
| 1837 | void QMdiSubWindowPrivate::removeButtonsFromMenuBar() | - |
| 1838 | { | - |
| 1839 | Q_Q(QMdiSubWindow); | - |
| 1840 | | - |
| 1841 | if (!controlContainer || isChildOfTabbedQMdiArea(q)) | - |
| 1842 | return; | - |
| 1843 | | - |
| 1844 | QMenuBar *currentMenuBar = 0; | - |
| 1845 | #ifndef QT_NO_MAINWINDOW | - |
| 1846 | if (QMainWindow *mainWindow = qobject_cast<QMainWindow *>(q->window())) { | - |
| 1847 | // NB! We can't use menuBar() here because that one will actually create | - |
| 1848 | // a menubar for us if not set. That's not what we want :-) | - |
| 1849 | currentMenuBar = qobject_cast<QMenuBar *>(mainWindow->menuWidget()); | - |
| 1850 | } | - |
| 1851 | #endif | - |
| 1852 | | - |
| 1853 | ignoreWindowTitleChange = true; | - |
| 1854 | controlContainer->removeButtonsFromMenuBar(currentMenuBar); | - |
| 1855 | ignoreWindowTitleChange = false; | - |
| 1856 | | - |
| 1857 | QWidget *topLevelWindow = q->window(); | - |
| 1858 | topLevelWindow->removeEventFilter(q); | - |
| 1859 | if (baseWidget && !drawTitleBarWhenMaximized()) | - |
| 1860 | topLevelWindow->setWindowModified(false); | - |
| 1861 | originalTitle = QString::null; | - |
| 1862 | } | - |
| 1863 | | - |
| 1864 | #endif // QT_NO_MENUBAR | - |
| 1865 | | - |
| 1866 | void QMdiSubWindowPrivate::updateWindowTitle(bool isRequestFromChild) | - |
| 1867 | { | - |
| 1868 | Q_Q(QMdiSubWindow); | - |
| 1869 | if (isRequestFromChild && !q->windowTitle().isEmpty() && !lastChildWindowTitle.isEmpty() | - |
| 1870 | && lastChildWindowTitle != q->windowTitle()) { | - |
| 1871 | return; | - |
| 1872 | } | - |
| 1873 | | - |
| 1874 | QWidget *titleWidget = 0; | - |
| 1875 | if (isRequestFromChild) | - |
| 1876 | titleWidget = baseWidget; | - |
| 1877 | else | - |
| 1878 | titleWidget = q; | - |
| 1879 | if (!titleWidget || titleWidget->windowTitle().isEmpty()) | - |
| 1880 | return; | - |
| 1881 | | - |
| 1882 | ignoreWindowTitleChange = true; | - |
| 1883 | q->setWindowTitle(titleWidget->windowTitle()); | - |
| 1884 | if (q->maximizedButtonsWidget()) | - |
| 1885 | setNewWindowTitle(); | - |
| 1886 | ignoreWindowTitleChange = false; | - |
| 1887 | } | - |
| 1888 | | - |
| 1889 | #ifndef QT_NO_RUBBERBAND | - |
| 1890 | void QMdiSubWindowPrivate::enterRubberBandMode() | - |
| 1891 | { | - |
| 1892 | Q_Q(QMdiSubWindow); | - |
| 1893 | if (q->isMaximized()) | - |
| 1894 | return; | - |
| 1895 | Q_ASSERT(oldGeometry.isValid()); | - |
| 1896 | Q_ASSERT(parent); | - |
| 1897 | if (!rubberBand) { | - |
| 1898 | rubberBand = new QRubberBand(QRubberBand::Rectangle, q->parentWidget()); | - |
| 1899 | // For accessibility to identify this special widget. | - |
| 1900 | rubberBand->setObjectName(QLatin1String("qt_rubberband")); | - |
| 1901 | } | - |
| 1902 | QPoint rubberBandPos = q->mapToParent(QPoint(0, 0)); | - |
| 1903 | rubberBand->setGeometry(rubberBandPos.x(), rubberBandPos.y(), | - |
| 1904 | oldGeometry.width(), oldGeometry.height()); | - |
| 1905 | rubberBand->show(); | - |
| 1906 | isInRubberBandMode = true; | - |
| 1907 | q->grabMouse(); | - |
| 1908 | } | - |
| 1909 | | - |
| 1910 | void QMdiSubWindowPrivate::leaveRubberBandMode() | - |
| 1911 | { | - |
| 1912 | Q_Q(QMdiSubWindow); | - |
| 1913 | Q_ASSERT(rubberBand); | - |
| 1914 | Q_ASSERT(isInRubberBandMode); | - |
| 1915 | q->releaseMouse(); | - |
| 1916 | isInRubberBandMode = false; | - |
| 1917 | q->setGeometry(rubberBand->geometry()); | - |
| 1918 | rubberBand->hide(); | - |
| 1919 | currentOperation = None; | - |
| 1920 | } | - |
| 1921 | #endif // QT_NO_RUBBERBAND | - |
| 1922 | | - |
| 1923 | // Taken from the old QWorkspace (::readColors()) | - |
| 1924 | QPalette QMdiSubWindowPrivate::desktopPalette() const | - |
| 1925 | { | - |
| 1926 | Q_Q(const QMdiSubWindow); | - |
| 1927 | QPalette newPalette = q->palette(); | - |
| 1928 | | - |
| 1929 | bool colorsInitialized = false; | - |
| 1930 | #ifdef Q_WS_WIN // ask system properties on windows | - |
| 1931 | #ifndef SPI_GETGRADIENTCAPTIONS | - |
| 1932 | #define SPI_GETGRADIENTCAPTIONS 0x1008 | - |
| 1933 | #endif | - |
| 1934 | #ifndef COLOR_GRADIENTACTIVECAPTION | - |
| 1935 | #define COLOR_GRADIENTACTIVECAPTION 27 | - |
| 1936 | #endif | - |
| 1937 | #ifndef COLOR_GRADIENTINACTIVECAPTION | - |
| 1938 | #define COLOR_GRADIENTINACTIVECAPTION 28 | - |
| 1939 | #endif | - |
| 1940 | if (QApplication::desktopSettingsAware()) { | - |
| 1941 | newPalette.setColor(QPalette::Active, QPalette::Highlight, | - |
| 1942 | colorref2qrgb(GetSysColor(COLOR_ACTIVECAPTION))); | - |
| 1943 | newPalette.setColor(QPalette::Inactive, QPalette::Highlight, | - |
| 1944 | colorref2qrgb(GetSysColor(COLOR_INACTIVECAPTION))); | - |
| 1945 | newPalette.setColor(QPalette::Active, QPalette::HighlightedText, | - |
| 1946 | colorref2qrgb(GetSysColor(COLOR_CAPTIONTEXT))); | - |
| 1947 | newPalette.setColor(QPalette::Inactive, QPalette::HighlightedText, | - |
| 1948 | colorref2qrgb(GetSysColor(COLOR_INACTIVECAPTIONTEXT))); | - |
| 1949 | | - |
| 1950 | colorsInitialized = true; | - |
| 1951 | BOOL hasGradient = false; | - |
| 1952 | SystemParametersInfo(SPI_GETGRADIENTCAPTIONS, 0, &hasGradient, 0); | - |
| 1953 | | - |
| 1954 | if (hasGradient) { | - |
| 1955 | newPalette.setColor(QPalette::Active, QPalette::Base, | - |
| 1956 | colorref2qrgb(GetSysColor(COLOR_GRADIENTACTIVECAPTION))); | - |
| 1957 | newPalette.setColor(QPalette::Inactive, QPalette::Base, | - |
| 1958 | colorref2qrgb(GetSysColor(COLOR_GRADIENTINACTIVECAPTION))); | - |
| 1959 | } else { | - |
| 1960 | newPalette.setColor(QPalette::Active, QPalette::Base, | - |
| 1961 | newPalette.color(QPalette::Active, QPalette::Highlight)); | - |
| 1962 | newPalette.setColor(QPalette::Inactive, QPalette::Base, | - |
| 1963 | newPalette.color(QPalette::Inactive, QPalette::Highlight)); | - |
| 1964 | } | - |
| 1965 | } | - |
| 1966 | #endif // Q_WS_WIN | - |
| 1967 | if (!colorsInitialized) { | - |
| 1968 | newPalette.setColor(QPalette::Active, QPalette::Highlight, | - |
| 1969 | newPalette.color(QPalette::Active, QPalette::Highlight)); | - |
| 1970 | newPalette.setColor(QPalette::Active, QPalette::Base, | - |
| 1971 | newPalette.color(QPalette::Active, QPalette::Highlight)); | - |
| 1972 | newPalette.setColor(QPalette::Inactive, QPalette::Highlight, | - |
| 1973 | newPalette.color(QPalette::Inactive, QPalette::Dark)); | - |
| 1974 | newPalette.setColor(QPalette::Inactive, QPalette::Base, | - |
| 1975 | newPalette.color(QPalette::Inactive, QPalette::Dark)); | - |
| 1976 | newPalette.setColor(QPalette::Inactive, QPalette::HighlightedText, | - |
| 1977 | newPalette.color(QPalette::Inactive, QPalette::Window)); | - |
| 1978 | } | - |
| 1979 | | - |
| 1980 | return newPalette; | - |
| 1981 | } | - |
| 1982 | | - |
| 1983 | void QMdiSubWindowPrivate::updateActions() | - |
| 1984 | { | - |
| 1985 | Qt::WindowFlags windowFlags = q_func()->windowFlags(); | - |
| 1986 | // Hide all | - |
| 1987 | for (int i = 0; i < NumWindowStateActions; ++i) | - |
| 1988 | setVisible(WindowStateAction(i), false); | - |
| 1989 | | - |
| 1990 | if (windowFlags & Qt::FramelessWindowHint) | - |
| 1991 | return; | - |
| 1992 | | - |
| 1993 | setVisible(StayOnTopAction, true); | - |
| 1994 | setVisible(MoveAction, moveEnabled); | - |
| 1995 | setVisible(ResizeAction, resizeEnabled); | - |
| 1996 | | - |
| 1997 | // CloseAction | - |
| 1998 | if (windowFlags & Qt::WindowSystemMenuHint) | - |
| 1999 | setVisible(CloseAction, true); | - |
| 2000 | | - |
| 2001 | // RestoreAction | - |
| 2002 | if (windowFlags & (Qt::WindowMinimizeButtonHint | Qt::WindowMaximizeButtonHint)) | - |
| 2003 | setVisible(RestoreAction, true); | - |
| 2004 | | - |
| 2005 | // MinimizeAction | - |
| 2006 | if (windowFlags & Qt::WindowMinimizeButtonHint) | - |
| 2007 | setVisible(MinimizeAction, true); | - |
| 2008 | | - |
| 2009 | // MaximizeAction | - |
| 2010 | if (windowFlags & Qt::WindowMaximizeButtonHint) | - |
| 2011 | setVisible(MaximizeAction, true); | - |
| 2012 | } | - |
| 2013 | | - |
| 2014 | void QMdiSubWindowPrivate::setFocusWidget() | - |
| 2015 | { | - |
| 2016 | Q_Q(QMdiSubWindow); | - |
| 2017 | if (!baseWidget) { | - |
| 2018 | q->setFocus(); | - |
| 2019 | return; | - |
| 2020 | } | - |
| 2021 | | - |
| 2022 | // This will give focus to the next child if possible, otherwise | - |
| 2023 | // do nothing, hence it's not possible to tab between windows with | - |
| 2024 | // just hitting tab (unless Qt::TabFocus is removed from the focus policy). | - |
| 2025 | if (focusInReason == Qt::TabFocusReason) { | - |
| 2026 | q->focusNextChild(); | - |
| 2027 | return; | - |
| 2028 | } | - |
| 2029 | | - |
| 2030 | // Same as above, but gives focus to the previous child. | - |
| 2031 | if (focusInReason == Qt::BacktabFocusReason) { | - |
| 2032 | q->focusPreviousChild(); | - |
| 2033 | return; | - |
| 2034 | } | - |
| 2035 | | - |
| 2036 | if (QWidget *focusWidget = baseWidget->focusWidget()) { | - |
| 2037 | if (!focusWidget->hasFocus() && q->isAncestorOf(focusWidget) | - |
| 2038 | && focusWidget->isVisible() && !q->isMinimized() | - |
| 2039 | && focusWidget->focusPolicy() != Qt::NoFocus) { | - |
| 2040 | focusWidget->setFocus(); | - |
| 2041 | } else { | - |
| 2042 | q->setFocus(); | - |
| 2043 | } | - |
| 2044 | return; | - |
| 2045 | } | - |
| 2046 | | - |
| 2047 | QWidget *focusWidget = q->nextInFocusChain(); | - |
| 2048 | while (focusWidget && focusWidget != q && focusWidget->focusPolicy() == Qt::NoFocus) | - |
| 2049 | focusWidget = focusWidget->nextInFocusChain(); | - |
| 2050 | if (focusWidget && q->isAncestorOf(focusWidget)) | - |
| 2051 | focusWidget->setFocus(); | - |
| 2052 | else if (baseWidget->focusPolicy() != Qt::NoFocus) | - |
| 2053 | baseWidget->setFocus(); | - |
| 2054 | else if (!q->hasFocus()) | - |
| 2055 | q->setFocus(); | - |
| 2056 | } | - |
| 2057 | | - |
| 2058 | void QMdiSubWindowPrivate::restoreFocus() | - |
| 2059 | { | - |
| 2060 | if (!restoreFocusWidget) | - |
| 2061 | return; | - |
| 2062 | if (!restoreFocusWidget->hasFocus() && q_func()->isAncestorOf(restoreFocusWidget) | - |
| 2063 | && restoreFocusWidget->isVisible() | - |
| 2064 | && restoreFocusWidget->focusPolicy() != Qt::NoFocus) { | - |
| 2065 | restoreFocusWidget->setFocus(); | - |
| 2066 | } | - |
| 2067 | restoreFocusWidget = 0; | - |
| 2068 | } | - |
| 2069 | | - |
| 2070 | /*! | - |
| 2071 | \internal | - |
| 2072 | ### Please add QEvent::WindowFlagsChange event | - |
| 2073 | */ | - |
| 2074 | void QMdiSubWindowPrivate::setWindowFlags(Qt::WindowFlags windowFlags) | - |
| 2075 | { | - |
| 2076 | Q_Q(QMdiSubWindow); | - |
| 2077 | if (!parent) { | - |
| 2078 | q->setWindowFlags(windowFlags); | - |
| 2079 | return; | - |
| 2080 | } | - |
| 2081 | | - |
| 2082 | Qt::WindowFlags windowType = windowFlags & Qt::WindowType_Mask; | - |
| 2083 | if (windowType == Qt::Dialog || windowFlags & Qt::MSWindowsFixedSizeDialogHint) | - |
| 2084 | windowFlags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint; | - |
| 2085 | | - |
| 2086 | // Set standard flags if none of the customize flags are set | - |
| 2087 | if (!(windowFlags & CustomizeWindowFlags)) | - |
| 2088 | windowFlags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint; | - |
| 2089 | else if (windowFlags & Qt::FramelessWindowHint && windowFlags & Qt::WindowStaysOnTopHint) | - |
| 2090 | windowFlags = Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint; | - |
| 2091 | else if (windowFlags & Qt::FramelessWindowHint) | - |
| 2092 | windowFlags = Qt::FramelessWindowHint; | - |
| 2093 | | - |
| 2094 | windowFlags &= ~windowType; | - |
| 2095 | windowFlags &= ~Qt::WindowFullscreenButtonHint; | - |
| 2096 | windowFlags |= Qt::SubWindow; | - |
| 2097 | | - |
| 2098 | #ifndef QT_NO_ACTION | - |
| 2099 | if (QAction *stayOnTopAction = actions[QMdiSubWindowPrivate::StayOnTopAction]) { | - |
| 2100 | if (windowFlags & Qt::WindowStaysOnTopHint) | - |
| 2101 | stayOnTopAction->setChecked(true); | - |
| 2102 | else | - |
| 2103 | stayOnTopAction->setChecked(false); | - |
| 2104 | } | - |
| 2105 | #endif | - |
| 2106 | | - |
| 2107 | #ifndef QT_NO_SIZEGRIP | - |
| 2108 | if ((windowFlags & Qt::FramelessWindowHint) && sizeGrip) | - |
| 2109 | delete sizeGrip; | - |
| 2110 | #endif | - |
| 2111 | | - |
| 2112 | q->setWindowFlags(windowFlags); | - |
| 2113 | updateGeometryConstraints(); | - |
| 2114 | updateActions(); | - |
| 2115 | QSize currentSize = q->size(); | - |
| 2116 | if (q->isVisible() && (currentSize.width() < internalMinimumSize.width() | - |
| 2117 | || currentSize.height() < internalMinimumSize.height())) { | - |
| 2118 | q->resize(currentSize.expandedTo(internalMinimumSize)); | - |
| 2119 | } | - |
| 2120 | } | - |
| 2121 | | - |
| 2122 | void QMdiSubWindowPrivate::setVisible(WindowStateAction action, bool visible) | - |
| 2123 | { | - |
| 2124 | #ifndef QT_NO_ACTION | - |
| 2125 | if (actions[action]) | - |
| 2126 | actions[action]->setVisible(visible); | - |
| 2127 | #endif | - |
| 2128 | | - |
| 2129 | Q_Q(QMdiSubWindow); | - |
| 2130 | if (!controlContainer) | - |
| 2131 | controlContainer = new ControlContainer(q); | - |
| 2132 | | - |
| 2133 | if (ControllerWidget *ctrlWidget = qobject_cast<ControllerWidget *> | - |
| 2134 | (controlContainer->controllerWidget())) { | - |
| 2135 | ctrlWidget->setControlVisible(action, visible); | - |
| 2136 | } | - |
| 2137 | } | - |
| 2138 | | - |
| 2139 | #ifndef QT_NO_ACTION | - |
| 2140 | void QMdiSubWindowPrivate::setEnabled(WindowStateAction action, bool enable) | - |
| 2141 | { | - |
| 2142 | if (actions[action]) | - |
| 2143 | actions[action]->setEnabled(enable); | - |
| 2144 | } | - |
| 2145 | | - |
| 2146 | #ifndef QT_NO_MENU | - |
| 2147 | void QMdiSubWindowPrivate::addToSystemMenu(WindowStateAction action, const QString &text, | - |
| 2148 | const char *slot) | - |
| 2149 | { | - |
| 2150 | if (!systemMenu) | - |
| 2151 | return; | - |
| 2152 | actions[action] = systemMenu->addAction(text, q_func(), slot); | - |
| 2153 | } | - |
| 2154 | #endif | - |
| 2155 | #endif // QT_NO_ACTION | - |
| 2156 | | - |
| 2157 | /*! | - |
| 2158 | \internal | - |
| 2159 | */ | - |
| 2160 | QSize QMdiSubWindowPrivate::iconSize() const | - |
| 2161 | { | - |
| 2162 | Q_Q(const QMdiSubWindow); | - |
| 2163 | if (!parent || q->windowFlags() & Qt::FramelessWindowHint) | - |
| 2164 | return QSize(-1, -1); | - |
| 2165 | return QSize(q->style()->pixelMetric(QStyle::PM_MdiSubWindowMinimizedWidth, 0, q), titleBarHeight()); | - |
| 2166 | } | - |
| 2167 | | - |
| 2168 | #ifndef QT_NO_SIZEGRIP | - |
| 2169 | | - |
| 2170 | /*! | - |
| 2171 | \internal | - |
| 2172 | */ | - |
| 2173 | void QMdiSubWindowPrivate::setSizeGrip(QSizeGrip *newSizeGrip) | - |
| 2174 | { | - |
| 2175 | Q_Q(QMdiSubWindow); never executed (the execution status of this line is deduced): QMdiSubWindow * const q = q_func(); | - |
| 2176 | if (!newSizeGrip || sizeGrip || q->windowFlags() & Qt::FramelessWindowHint) never evaluated: !newSizeGrip never evaluated: sizeGrip never evaluated: q->windowFlags() & Qt::FramelessWindowHint | 0 |
| 2177 | return; | 0 |
| 2178 | | - |
| 2179 | if (layout && layout->indexOf(newSizeGrip) != -1) never evaluated: layout never evaluated: layout->indexOf(newSizeGrip) != -1 | 0 |
| 2180 | return; | 0 |
| 2181 | newSizeGrip->setFixedSize(newSizeGrip->sizeHint()); never executed (the execution status of this line is deduced): newSizeGrip->setFixedSize(newSizeGrip->sizeHint()); | - |
| 2182 | bool putSizeGripInLayout = layout ? true : false; | 0 |
| 2183 | #if defined(Q_WS_MACQ_OS_MAC) && !defined(QT_NO_STYLE_MAC) | - |
| 2184 | if (qobject_cast<QMacStyle *>(q->style())) | - |
| 2185 | putSizeGripInLayout = false; | - |
| 2186 | #endif | - |
| 2187 | if (putSizeGripInLayout) { never evaluated: putSizeGripInLayout | 0 |
| 2188 | layout->addWidget(newSizeGrip); never executed (the execution status of this line is deduced): layout->addWidget(newSizeGrip); | - |
| 2189 | layout->setAlignment(newSizeGrip, Qt::AlignBottom | Qt::AlignRight); never executed (the execution status of this line is deduced): layout->setAlignment(newSizeGrip, Qt::AlignBottom | Qt::AlignRight); | - |
| 2190 | } else { | 0 |
| 2191 | newSizeGrip->setParent(q); never executed (the execution status of this line is deduced): newSizeGrip->setParent(q); | - |
| 2192 | newSizeGrip->move(q->isLeftToRight() ? q->width() - newSizeGrip->width() : 0, never executed (the execution status of this line is deduced): newSizeGrip->move(q->isLeftToRight() ? q->width() - newSizeGrip->width() : 0, | - |
| 2193 | q->height() - newSizeGrip->height()); never executed (the execution status of this line is deduced): q->height() - newSizeGrip->height()); | - |
| 2194 | sizeGrip = newSizeGrip; never executed (the execution status of this line is deduced): sizeGrip = newSizeGrip; | - |
| 2195 | } | 0 |
| 2196 | newSizeGrip->raise(); never executed (the execution status of this line is deduced): newSizeGrip->raise(); | - |
| 2197 | updateGeometryConstraints(); never executed (the execution status of this line is deduced): updateGeometryConstraints(); | - |
| 2198 | newSizeGrip->installEventFilter(q); never executed (the execution status of this line is deduced): newSizeGrip->installEventFilter(q); | - |
| 2199 | } | 0 |
| 2200 | | - |
| 2201 | /*! | - |
| 2202 | \internal | - |
| 2203 | */ | - |
| 2204 | void QMdiSubWindowPrivate::setSizeGripVisible(bool visible) const | - |
| 2205 | { | - |
| 2206 | // See if we can find any size grips | - |
| 2207 | QList<QSizeGrip *> sizeGrips = q_func()->findChildren<QSizeGrip *>(); | - |
| 2208 | foreach (QSizeGrip *grip, sizeGrips) | - |
| 2209 | grip->setVisible(visible); | - |
| 2210 | } | - |
| 2211 | | - |
| 2212 | #endif // QT_NO_SIZEGRIP | - |
| 2213 | | - |
| 2214 | /*! | - |
| 2215 | \internal | - |
| 2216 | */ | - |
| 2217 | void QMdiSubWindowPrivate::updateInternalWindowTitle() | - |
| 2218 | { | - |
| 2219 | Q_Q(QMdiSubWindow); | - |
| 2220 | if (q->isWindowModified()) { | - |
| 2221 | windowTitle = q->windowTitle(); | - |
| 2222 | windowTitle.replace(QLatin1String("[*]"), QLatin1String("*")); | - |
| 2223 | } else { | - |
| 2224 | windowTitle = qt_setWindowTitle_helperHelper(q->windowTitle(), q); | - |
| 2225 | } | - |
| 2226 | q->update(0, 0, q->width(), titleBarHeight()); | - |
| 2227 | } | - |
| 2228 | | - |
| 2229 | /*! | - |
| | Constructs a new QMdiSubWindow widget. The \a parent and \a | |
| | flags arguments are passed to QWidget's constructor. | |
| | | |
| | Instead of using addSubWindow(), it is also simply possible to | |
| | use setParent() when you add the subwindow to a QMdiArea. | |
| | | |
| | Note that only \l{QMdiSubWindow}s can be set as children of | |
| | QMdiArea; you cannot, for instance, write: | |
| | | |
| | \badcode | |
| | QMdiArea mdiArea; | |
| | QTextEdit editor(&mdiArea); // invalid child widget | |
| | \endcode | |
| | | |
| | \sa QMdiArea::addSubWindow() | |
| | */*! | |
| 2230 | Constructs a new QMdiSubWindow widget. The \a parent and \a | - |
| 2231 | flags arguments are passed to QWidget's constructor. | - |
| 2232 | | - |
| 2233 | Instead of using addSubWindow(), it is also simply possible to | - |
| 2234 | use setParent() when you add the subwindow to a QMdiArea. | - |
| 2235 | | - |
| 2236 | Note that only \l{QMdiSubWindow}s can be set as children of | - |
| 2237 | QMdiArea; you cannot, for instance, write: | - |
| 2238 | | - |
| 2239 | \code | - |
| 2240 | //bad code | - |
| 2241 | QMdiArea mdiArea; | - |
| 2242 | QTextEdit editor(&mdiArea); // invalid child widget | - |
| 2243 | \endcode | - |
| 2244 | | - |
| 2245 | \sa QMdiArea::addSubWindow() | - |
| 2246 | */ | - |
| 2247 | QMdiSubWindow::QMdiSubWindow(QWidget *parent, Qt::WindowFlags flags) | - |
| 2248 | : QWidget(*new QMdiSubWindowPrivate, parent, 0) | - |
| 2249 | { | - |
| 2250 | Q_D(QMdiSubWindow); executed (the execution status of this line is deduced): QMdiSubWindowPrivate * const d = d_func(); | - |
| 2251 | #ifndef QT_NO_MENU | - |
| 2252 | d->createSystemMenu(); executed (the execution status of this line is deduced): d->createSystemMenu(); | - |
| 2253 | addActions(d->systemMenu->actions()); executed (the execution status of this line is deduced): addActions(d->systemMenu->actions()); | - |
| 2254 | #endif | - |
| 2255 | d->setWindowFlags(flags); executed (the execution status of this line is deduced): d->setWindowFlags(flags); | - |
| 2256 | setBackgroundRole(QPalette::Window); executed (the execution status of this line is deduced): setBackgroundRole(QPalette::Window); | - |
| 2257 | setAutoFillBackground(true); executed (the execution status of this line is deduced): setAutoFillBackground(true); | - |
| 2258 | setMouseTracking(true); executed (the execution status of this line is deduced): setMouseTracking(true); | - |
| 2259 | setLayout(new QVBoxLayout); executed (the execution status of this line is deduced): setLayout(new QVBoxLayout); | - |
| 2260 | setFocusPolicy(Qt::StrongFocus); executed (the execution status of this line is deduced): setFocusPolicy(Qt::StrongFocus); | - |
| 2261 | layout()->setMargin(0); executed (the execution status of this line is deduced): layout()->setMargin(0); | - |
| 2262 | d->updateGeometryConstraints(); executed (the execution status of this line is deduced): d->updateGeometryConstraints(); | - |
| 2263 | setAttribute(Qt::WA_Resized, false); executed (the execution status of this line is deduced): setAttribute(Qt::WA_Resized, false); | - |
| 2264 | d->titleBarPalette = d->desktopPalette(); executed (the execution status of this line is deduced): d->titleBarPalette = d->desktopPalette(); | - |
| 2265 | d->font = QApplication::font("QMdiSubWindowTitleBar"); executed (the execution status of this line is deduced): d->font = QApplication::font("QMdiSubWindowTitleBar"); | - |
| 2266 | // We don't want the menu icon by default on mac. | - |
| 2267 | #ifndef Q_WS_MACQ_OS_MAC | - |
| 2268 | if (windowIcon().isNull()) partially evaluated: windowIcon().isNull()| yes Evaluation Count:102 | no Evaluation Count:0 |
| 0-102 |
| 2269 | d->menuIcon = style()->standardIcon(QStyle::SP_TitleBarMenuButton, 0, this); executed: d->menuIcon = style()->standardIcon(QStyle::SP_TitleBarMenuButton, 0, this);Execution Count:102 | 102 |
| 2270 | else | - |
| 2271 | d->menuIcon = windowIcon(); never executed: d->menuIcon = windowIcon(); | 0 |
| 2272 | #endif | - |
| 2273 | connect(qApp, SIGNAL(focusChanged(QWidget*,QWidget*)), executed (the execution status of this line is deduced): connect((static_cast<QApplication *>(QCoreApplication::instance())), "2""focusChanged(QWidget*,QWidget*)", | - |
| 2274 | this, SLOT(_q_processFocusChanged(QWidget*,QWidget*))); executed (the execution status of this line is deduced): this, "1""_q_processFocusChanged(QWidget*,QWidget*)"); | - |
| 2275 | } executed: }Execution Count:102 | 102 |
| 2276 | | - |
| 2277 | /*! | - |
| 2278 | Destroys the subwindow. | - |
| 2279 | | - |
| 2280 | \sa QMdiArea::removeSubWindow() | - |
| 2281 | */ | - |
| 2282 | QMdiSubWindow::~QMdiSubWindow() | - |
| 2283 | { | - |
| 2284 | Q_D(QMdiSubWindow); | - |
| 2285 | #ifndef QT_NO_MENUBAR | - |
| 2286 | d->removeButtonsFromMenuBar(); | - |
| 2287 | #endif | - |
| 2288 | d->setActive(false); | - |
| 2289 | } | - |
| 2290 | | - |
| 2291 | /*! | - |
| 2292 | Sets \a widget as the internal widget of this subwindow. The | - |
| 2293 | internal widget is displayed in the center of the subwindow | - |
| 2294 | beneath the title bar. | - |
| 2295 | | - |
| 2296 | QMdiSubWindow takes temporary ownership of \a widget; you do | - |
| 2297 | not have to delete it. Any existing internal widget will be | - |
| 2298 | removed and reparented to the root window. | - |
| 2299 | | - |
| 2300 | \sa widget() | - |
| 2301 | */ | - |
| 2302 | void QMdiSubWindow::setWidget(QWidget *widget) | - |
| 2303 | { | - |
| 2304 | Q_D(QMdiSubWindow); | - |
| 2305 | if (!widget) { | - |
| 2306 | d->removeBaseWidget(); | - |
| 2307 | return; | - |
| 2308 | } | - |
| 2309 | | - |
| 2310 | if (widget == d->baseWidget) { | - |
| 2311 | qWarning("QMdiSubWindow::setWidget: widget is already set"); | - |
| 2312 | return; | - |
| 2313 | } | - |
| 2314 | | - |
| 2315 | bool wasResized = testAttribute(Qt::WA_Resized); | - |
| 2316 | d->removeBaseWidget(); | - |
| 2317 | | - |
| 2318 | if (QLayout *layout = this->layout()) | - |
| 2319 | layout->addWidget(widget); | - |
| 2320 | else | - |
| 2321 | widget->setParent(this); | - |
| 2322 | | - |
| 2323 | #ifndef QT_NO_SIZEGRIP | - |
| 2324 | QSizeGrip *sizeGrip = widget->findChild<QSizeGrip *>(); | - |
| 2325 | if (sizeGrip) | - |
| 2326 | sizeGrip->installEventFilter(this); | - |
| 2327 | if (d->sizeGrip) | - |
| 2328 | d->sizeGrip->raise(); | - |
| 2329 | #endif | - |
| 2330 | | - |
| 2331 | d->baseWidget = widget; | - |
| 2332 | d->baseWidget->installEventFilter(this); | - |
| 2333 | | - |
| 2334 | d->ignoreWindowTitleChange = true; | - |
| 2335 | bool isWindowModified = this->isWindowModified(); | - |
| 2336 | if (windowTitle().isEmpty()) { | - |
| 2337 | d->updateWindowTitle(true); | - |
| 2338 | isWindowModified = d->baseWidget->isWindowModified(); | - |
| 2339 | } | - |
| 2340 | if (!this->isWindowModified() && isWindowModified | - |
| 2341 | && windowTitle().contains(QLatin1String("[*]"))) { | - |
| 2342 | setWindowModified(isWindowModified); | - |
| 2343 | } | - |
| 2344 | d->lastChildWindowTitle = d->baseWidget->windowTitle(); | - |
| 2345 | d->ignoreWindowTitleChange = false; | - |
| 2346 | | - |
| 2347 | if (windowIcon().isNull() && !d->baseWidget->windowIcon().isNull()) | - |
| 2348 | setWindowIcon(d->baseWidget->windowIcon()); | - |
| 2349 | | - |
| 2350 | d->updateGeometryConstraints(); | - |
| 2351 | if (!wasResized && testAttribute(Qt::WA_Resized)) | - |
| 2352 | setAttribute(Qt::WA_Resized, false); | - |
| 2353 | } | - |
| 2354 | | - |
| 2355 | /*! | - |
| 2356 | Returns the current internal widget. | - |
| 2357 | | - |
| 2358 | \sa setWidget() | - |
| 2359 | */ | - |
| 2360 | QWidget *QMdiSubWindow::widget() const | - |
| 2361 | { | - |
| 2362 | return d_func()->baseWidget; | - |
| 2363 | } | - |
| 2364 | | - |
| 2365 | | - |
| 2366 | /*! | - |
| 2367 | \internal | - |
| 2368 | */ | - |
| 2369 | QWidget *QMdiSubWindow::maximizedButtonsWidget() const | - |
| 2370 | { | - |
| 2371 | Q_D(const QMdiSubWindow); | - |
| 2372 | if (isVisible() && d->controlContainer && isMaximized() && !d->drawTitleBarWhenMaximized() | - |
| 2373 | && !isChildOfTabbedQMdiArea(this)) { | - |
| 2374 | return d->controlContainer->controllerWidget(); | - |
| 2375 | } | - |
| 2376 | return 0; | - |
| 2377 | } | - |
| 2378 | | - |
| 2379 | /*! | - |
| 2380 | \internal | - |
| 2381 | */ | - |
| 2382 | QWidget *QMdiSubWindow::maximizedSystemMenuIconWidget() const | - |
| 2383 | { | - |
| 2384 | Q_D(const QMdiSubWindow); | - |
| 2385 | if (isVisible() && d->controlContainer && isMaximized() && !d->drawTitleBarWhenMaximized() | - |
| 2386 | && !isChildOfTabbedQMdiArea(this)) { | - |
| 2387 | return d->controlContainer->systemMenuLabel(); | - |
| 2388 | } | - |
| 2389 | return 0; | - |
| 2390 | } | - |
| 2391 | | - |
| 2392 | /*! | - |
| 2393 | Returns true if this window is shaded; otherwise returns false. | - |
| 2394 | | - |
| 2395 | A window is shaded if it is collapsed so that only the title bar is | - |
| 2396 | visible. | - |
| 2397 | */ | - |
| 2398 | bool QMdiSubWindow::isShaded() const | - |
| 2399 | { | - |
| 2400 | return d_func()->isShadeMode; | - |
| 2401 | } | - |
| 2402 | | - |
| 2403 | /*! | - |
| 2404 | If \a on is true, \a option is enabled on the subwindow; otherwise it is | - |
| 2405 | disabled. See SubWindowOption for the effect of each option. | - |
| 2406 | | - |
| 2407 | \sa SubWindowOption, testOption() | - |
| 2408 | */ | - |
| 2409 | void QMdiSubWindow::setOption(SubWindowOption option, bool on) | - |
| 2410 | { | - |
| 2411 | Q_D(QMdiSubWindow); | - |
| 2412 | if (on && !(d->options & option)) | - |
| 2413 | d->options |= option; | - |
| 2414 | else if (!on && (d->options & option)) | - |
| 2415 | d->options &= ~option; | - |
| 2416 | | - |
| 2417 | #ifndef QT_NO_RUBBERBAND | - |
| 2418 | if ((option & (RubberBandResize | RubberBandMove)) && !on && d->isInRubberBandMode) | - |
| 2419 | d->leaveRubberBandMode(); | - |
| 2420 | #endif | - |
| 2421 | } | - |
| 2422 | | - |
| 2423 | /*! | - |
| 2424 | Returns true if \a option is enabled; otherwise returns false. | - |
| 2425 | | - |
| 2426 | \sa SubWindowOption, setOption() | - |
| 2427 | */ | - |
| 2428 | bool QMdiSubWindow::testOption(SubWindowOption option) const | - |
| 2429 | { | - |
| 2430 | return d_func()->options & option; | - |
| 2431 | } | - |
| 2432 | | - |
| 2433 | /*! | - |
| 2434 | \property QMdiSubWindow::keyboardSingleStep | - |
| 2435 | \brief sets how far a widget should move or resize when using the | - |
| 2436 | keyboard arrow keys. | - |
| 2437 | | - |
| 2438 | When in keyboard-interactive mode, you can use the arrow and page keys to | - |
| 2439 | either move or resize the window. This property controls the arrow keys. | - |
| 2440 | The common way to enter keyboard interactive mode is to enter the | - |
| 2441 | subwindow menu, and select either "resize" or "move". | - |
| 2442 | | - |
| 2443 | The default keyboard single step value is 5 pixels. | - |
| 2444 | | - |
| 2445 | \sa keyboardPageStep | - |
| 2446 | */ | - |
| 2447 | int QMdiSubWindow::keyboardSingleStep() const | - |
| 2448 | { | - |
| 2449 | return d_func()->keyboardSingleStep; | - |
| 2450 | } | - |
| 2451 | | - |
| 2452 | void QMdiSubWindow::setKeyboardSingleStep(int step) | - |
| 2453 | { | - |
| 2454 | // Haven't done any boundary check here since negative step only | - |
| 2455 | // means inverted behavior, which is OK if the user want it. | - |
| 2456 | // A step equal to zero means "do nothing". | - |
| 2457 | d_func()->keyboardSingleStep = step; | - |
| 2458 | } | - |
| 2459 | | - |
| 2460 | /*! | - |
| 2461 | \property QMdiSubWindow::keyboardPageStep | - |
| 2462 | \brief sets how far a widget should move or resize when using the | - |
| 2463 | keyboard page keys. | - |
| 2464 | | - |
| 2465 | When in keyboard-interactive mode, you can use the arrow and page keys to | - |
| 2466 | either move or resize the window. This property controls the page | - |
| 2467 | keys. The common way to enter keyboard interactive mode is to enter the | - |
| 2468 | subwindow menu, and select either "resize" or "move". | - |
| 2469 | | - |
| 2470 | The default keyboard page step value is 20 pixels. | - |
| 2471 | | - |
| 2472 | \sa keyboardSingleStep | - |
| 2473 | */ | - |
| 2474 | int QMdiSubWindow::keyboardPageStep() const | - |
| 2475 | { | - |
| 2476 | return d_func()->keyboardPageStep; | - |
| 2477 | } | - |
| 2478 | | - |
| 2479 | void QMdiSubWindow::setKeyboardPageStep(int step) | - |
| 2480 | { | - |
| 2481 | // Haven't done any boundary check here since negative step only | - |
| 2482 | // means inverted behavior, which is OK if the user want it. | - |
| 2483 | // A step equal to zero means "do nothing". | - |
| 2484 | d_func()->keyboardPageStep = step; | - |
| 2485 | } | - |
| 2486 | | - |
| 2487 | #ifndef QT_NO_MENU | - |
| 2488 | /*! | - |
| 2489 | Sets \a systemMenu as the current system menu for this subwindow. | - |
| 2490 | | - |
| 2491 | By default, each QMdiSubWindow has a standard system menu. | - |
| 2492 | | - |
| 2493 | QActions for the system menu created by QMdiSubWindow will | - |
| 2494 | automatically be updated depending on the current window state; | - |
| 2495 | e.g., the minimize action will be disabled after the window is | - |
| 2496 | minimized. | - |
| 2497 | | - |
| 2498 | QActions added by the user are not updated by QMdiSubWindow. | - |
| 2499 | | - |
| 2500 | QMdiSubWindow takes ownership of \a systemMenu; you do not have to | - |
| 2501 | delete it. Any existing menus will be deleted. | - |
| 2502 | | - |
| 2503 | \sa systemMenu(), showSystemMenu() | - |
| 2504 | */ | - |
| 2505 | void QMdiSubWindow::setSystemMenu(QMenu *systemMenu) | - |
| 2506 | { | - |
| 2507 | Q_D(QMdiSubWindow); | - |
| 2508 | if (systemMenu && systemMenu == d->systemMenu) { | - |
| 2509 | qWarning("QMdiSubWindow::setSystemMenu: system menu is already set"); | - |
| 2510 | return; | - |
| 2511 | } | - |
| 2512 | | - |
| 2513 | if (d->systemMenu) { | - |
| 2514 | delete d->systemMenu; | - |
| 2515 | d->systemMenu = 0; | - |
| 2516 | } | - |
| 2517 | | - |
| 2518 | if (!systemMenu) | - |
| 2519 | return; | - |
| 2520 | | - |
| 2521 | if (systemMenu->parent() != this) | - |
| 2522 | systemMenu->setParent(this); | - |
| 2523 | d->systemMenu = systemMenu; | - |
| 2524 | } | - |
| 2525 | | - |
| 2526 | /*! | - |
| 2527 | Returns a pointer to the current system menu, or zero if no system | - |
| 2528 | menu is set. QMdiSubWindow provides a default system menu, but you can | - |
| 2529 | also set the menu with setSystemMenu(). | - |
| 2530 | | - |
| 2531 | \sa setSystemMenu(), showSystemMenu() | - |
| 2532 | */ | - |
| 2533 | QMenu *QMdiSubWindow::systemMenu() const | - |
| 2534 | { | - |
| 2535 | return d_func()->systemMenu; | - |
| 2536 | } | - |
| 2537 | | - |
| 2538 | /*! | - |
| 2539 | Shows the system menu below the system menu icon in the title bar. | - |
| 2540 | | - |
| 2541 | \sa setSystemMenu(), systemMenu() | - |
| 2542 | */ | - |
| 2543 | void QMdiSubWindow::showSystemMenu() | - |
| 2544 | { | - |
| 2545 | Q_D(QMdiSubWindow); | - |
| 2546 | if (!d->systemMenu) | - |
| 2547 | return; | - |
| 2548 | | - |
| 2549 | QPoint globalPopupPos; | - |
| 2550 | if (QWidget *icon = maximizedSystemMenuIconWidget()) { | - |
| 2551 | if (isLeftToRight()) | - |
| 2552 | globalPopupPos = icon->mapToGlobal(QPoint(0, icon->y() + icon->height())); | - |
| 2553 | else | - |
| 2554 | globalPopupPos = icon->mapToGlobal(QPoint(icon->width(), icon->y() + icon->height())); | - |
| 2555 | } else { | - |
| 2556 | if (isLeftToRight()) | - |
| 2557 | globalPopupPos = mapToGlobal(contentsRect().topLeft()); | - |
| 2558 | else // + QPoint(1, 0) because topRight() == QPoint(left() + width() -1, top()) | - |
| 2559 | globalPopupPos = mapToGlobal(contentsRect().topRight()) + QPoint(1, 0); | - |
| 2560 | } | - |
| 2561 | | - |
| 2562 | // Adjust x() with -menuwidth in reverse mode. | - |
| 2563 | if (isRightToLeft()) | - |
| 2564 | globalPopupPos -= QPoint(d->systemMenu->sizeHint().width(), 0); | - |
| 2565 | d->systemMenu->installEventFilter(this); | - |
| 2566 | d->systemMenu->popup(globalPopupPos); | - |
| 2567 | } | - |
| 2568 | #endif // QT_NO_MENU | - |
| 2569 | | - |
| 2570 | /*! | - |
| 2571 | \since 4.4 | - |
| 2572 | | - |
| 2573 | Returns the area containing this sub-window, or 0 if there is none. | - |
| 2574 | | - |
| 2575 | \sa QMdiArea::addSubWindow() | - |
| 2576 | */ | - |
| 2577 | QMdiArea *QMdiSubWindow::mdiArea() const | - |
| 2578 | { | - |
| 2579 | QWidget *parent = parentWidget(); | - |
| 2580 | while (parent) { | - |
| 2581 | if (QMdiArea *area = qobject_cast<QMdiArea *>(parent)) { | - |
| 2582 | if (area->viewport() == parentWidget()) | - |
| 2583 | return area; | - |
| 2584 | } | - |
| 2585 | parent = parent->parentWidget(); | - |
| 2586 | } | - |
| 2587 | return 0; | - |
| 2588 | } | - |
| 2589 | | - |
| 2590 | /*! | - |
| 2591 | Calling this function makes the subwindow enter the shaded mode. | - |
| 2592 | When the subwindow is shaded, only the title bar is visible. | - |
| 2593 | | - |
| 2594 | Although shading is not supported by all styles, this function will | - |
| 2595 | still show the subwindow as shaded, regardless of whether support | - |
| 2596 | for shading is available. However, when used with styles without | - |
| 2597 | shading support, the user will be unable to return from shaded mode | - |
| 2598 | through the user interface (e.g., through a shade button in the title | - |
| 2599 | bar). | - |
| 2600 | | - |
| 2601 | \sa isShaded() | - |
| 2602 | */ | - |
| 2603 | void QMdiSubWindow::showShaded() | - |
| 2604 | { | - |
| 2605 | if (!parent()) | - |
| 2606 | return; | - |
| 2607 | | - |
| 2608 | Q_D(QMdiSubWindow); | - |
| 2609 | // setMinimizeMode uses this function. | - |
| 2610 | if (!d->isShadeRequestFromMinimizeMode && isShaded()) | - |
| 2611 | return; | - |
| 2612 | | - |
| 2613 | d->isMaximizeMode = false; | - |
| 2614 | | - |
| 2615 | QWidget *currentFocusWidget = QApplication::focusWidget(); | - |
| 2616 | if (!d->restoreFocusWidget && isAncestorOf(currentFocusWidget)) | - |
| 2617 | d->restoreFocusWidget = currentFocusWidget; | - |
| 2618 | | - |
| 2619 | if (!d->isShadeRequestFromMinimizeMode) { | - |
| 2620 | d->isShadeMode = true; | - |
| 2621 | d->ensureWindowState(Qt::WindowMinimized); | - |
| 2622 | } | - |
| 2623 | | - |
| 2624 | #ifndef QT_NO_MENUBAR | - |
| 2625 | d->removeButtonsFromMenuBar(); | - |
| 2626 | #endif | - |
| 2627 | | - |
| 2628 | // showMinimized() will reset Qt::WindowActive, which makes sense | - |
| 2629 | // for top level widgets, but in MDI it makes sense to have an | - |
| 2630 | // active window which is minimized. | - |
| 2631 | if (hasFocus() || isAncestorOf(currentFocusWidget)) | - |
| 2632 | d->ensureWindowState(Qt::WindowActive); | - |
| 2633 | | - |
| 2634 | #ifndef QT_NO_SIZEGRIP | - |
| 2635 | d->setSizeGripVisible(false); | - |
| 2636 | #endif | - |
| 2637 | | - |
| 2638 | if (!d->restoreSize.isValid() || d->isShadeMode) { | - |
| 2639 | d->oldGeometry = geometry(); | - |
| 2640 | d->restoreSize.setWidth(d->oldGeometry.width()); | - |
| 2641 | d->restoreSize.setHeight(d->oldGeometry.height()); | - |
| 2642 | } | - |
| 2643 | | - |
| 2644 | // Hide the window before we change the geometry to avoid multiple resize | - |
| 2645 | // events and wrong window state. | - |
| 2646 | const bool wasVisible = isVisible(); | - |
| 2647 | if (wasVisible) | - |
| 2648 | setVisible(false); | - |
| 2649 | | - |
| 2650 | d->updateGeometryConstraints(); | - |
| 2651 | // Update minimum size to internalMinimumSize if set by user. | - |
| 2652 | if (!minimumSize().isNull()) { | - |
| 2653 | d->userMinimumSize = minimumSize(); | - |
| 2654 | setMinimumSize(d->internalMinimumSize); | - |
| 2655 | } | - |
| 2656 | resize(d->internalMinimumSize); | - |
| 2657 | | - |
| 2658 | // Hide the internal widget if not already hidden by the user. | - |
| 2659 | if (d->baseWidget && !d->baseWidget->isHidden()) { | - |
| 2660 | d->baseWidget->hide(); | - |
| 2661 | d->isWidgetHiddenByUs = true; | - |
| 2662 | } | - |
| 2663 | | - |
| 2664 | if (wasVisible) | - |
| 2665 | setVisible(true); | - |
| 2666 | | - |
| 2667 | d->setFocusWidget(); | - |
| 2668 | d->resizeEnabled = false; | - |
| 2669 | d->moveEnabled = true; | - |
| 2670 | d->updateDirtyRegions(); | - |
| 2671 | d->updateMask(); | - |
| 2672 | | - |
| 2673 | #ifndef QT_NO_ACTION | - |
| 2674 | d->setEnabled(QMdiSubWindowPrivate::MinimizeAction, false); | - |
| 2675 | d->setEnabled(QMdiSubWindowPrivate::ResizeAction, d->resizeEnabled); | - |
| 2676 | d->setEnabled(QMdiSubWindowPrivate::MaximizeAction, true); | - |
| 2677 | d->setEnabled(QMdiSubWindowPrivate::RestoreAction, true); | - |
| 2678 | d->setEnabled(QMdiSubWindowPrivate::MoveAction, d->moveEnabled); | - |
| 2679 | #endif | - |
| 2680 | } | - |
| 2681 | | - |
| 2682 | /*! | - |
| 2683 | \reimp | - |
| 2684 | */ | - |
| 2685 | bool QMdiSubWindow::eventFilter(QObject *object, QEvent *event) | - |
| 2686 | { | - |
| 2687 | Q_D(QMdiSubWindow); | - |
| 2688 | if (!object) | - |
| 2689 | return QWidget::eventFilter(object, event); | - |
| 2690 | | - |
| 2691 | #ifndef QT_NO_MENU | - |
| 2692 | // System menu events. | - |
| 2693 | if (d->systemMenu && d->systemMenu == object) { | - |
| 2694 | if (event->type() == QEvent::MouseButtonDblClick) { | - |
| 2695 | close(); | - |
| 2696 | } else if (event->type() == QEvent::MouseMove) { | - |
| 2697 | QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event); | - |
| 2698 | d->hoveredSubControl = d->getSubControl(mapFromGlobal(mouseEvent->globalPos())); | - |
| 2699 | } else if (event->type() == QEvent::Hide) { | - |
| 2700 | d->systemMenu->removeEventFilter(this); | - |
| 2701 | d->activeSubControl = QStyle::SC_None; | - |
| 2702 | update(QRegion(0, 0, width(), d->titleBarHeight())); | - |
| 2703 | } | - |
| 2704 | return QWidget::eventFilter(object, event); | - |
| 2705 | } | - |
| 2706 | #endif | - |
| 2707 | | - |
| 2708 | #ifndef QT_NO_SIZEGRIP | - |
| 2709 | if (object != d->baseWidget && parent() && qobject_cast<QSizeGrip *>(object)) { | - |
| 2710 | if (event->type() != QEvent::MouseButtonPress || !testOption(QMdiSubWindow::RubberBandResize)) | - |
| 2711 | return QWidget::eventFilter(object, event); | - |
| 2712 | const QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event); | - |
| 2713 | d->mousePressPosition = parentWidget()->mapFromGlobal(mouseEvent->globalPos()); | - |
| 2714 | d->oldGeometry = geometry(); | - |
| 2715 | d->currentOperation = isLeftToRight() ? QMdiSubWindowPrivate::BottomRightResize | - |
| 2716 | : QMdiSubWindowPrivate::BottomLeftResize; | - |
| 2717 | #ifndef QT_NO_RUBBERBAND | - |
| 2718 | d->enterRubberBandMode(); | - |
| 2719 | #endif | - |
| 2720 | return true; | - |
| 2721 | } | - |
| 2722 | #endif | - |
| 2723 | | - |
| 2724 | if (object != d->baseWidget && event->type() != QEvent::WindowTitleChange) | - |
| 2725 | return QWidget::eventFilter(object, event); | - |
| 2726 | | - |
| 2727 | switch (event->type()) { | - |
| 2728 | case QEvent::Show: | - |
| 2729 | d->setActive(true); | - |
| 2730 | break; | - |
| 2731 | case QEvent::ShowToParent: | - |
| 2732 | if (!d->isWidgetHiddenByUs) | - |
| 2733 | show(); | - |
| 2734 | break; | - |
| 2735 | case QEvent::WindowStateChange: { | - |
| 2736 | QWindowStateChangeEvent *changeEvent = static_cast<QWindowStateChangeEvent*>(event); | - |
| 2737 | if (changeEvent->isOverride()) | - |
| 2738 | break; | - |
| 2739 | Qt::WindowStates oldState = changeEvent->oldState(); | - |
| 2740 | Qt::WindowStates newState = d->baseWidget->windowState(); | - |
| 2741 | if (!(oldState & Qt::WindowMinimized) && (newState & Qt::WindowMinimized)) | - |
| 2742 | showMinimized(); | - |
| 2743 | else if (!(oldState & Qt::WindowMaximized) && (newState & Qt::WindowMaximized)) | - |
| 2744 | showMaximized(); | - |
| 2745 | else if (!(newState & (Qt::WindowMaximized | Qt::WindowMinimized))) | - |
| 2746 | showNormal(); | - |
| 2747 | break; | - |
| 2748 | } | - |
| 2749 | case QEvent::Enter: | - |
| 2750 | d->currentOperation = QMdiSubWindowPrivate::None; | - |
| 2751 | d->updateCursor(); | - |
| 2752 | break; | - |
| 2753 | case QEvent::LayoutRequest: | - |
| 2754 | d->updateGeometryConstraints(); | - |
| 2755 | break; | - |
| 2756 | case QEvent::WindowTitleChange: | - |
| 2757 | if (d->ignoreWindowTitleChange) | - |
| 2758 | break; | - |
| 2759 | if (object == d->baseWidget) { | - |
| 2760 | d->updateWindowTitle(true); | - |
| 2761 | d->lastChildWindowTitle = d->baseWidget->windowTitle(); | - |
| 2762 | #ifndef QT_NO_MENUBAR | - |
| 2763 | } else if (maximizedButtonsWidget() && d->controlContainer->menuBar() && d->controlContainer->menuBar() | - |
| 2764 | ->cornerWidget(Qt::TopRightCorner) == maximizedButtonsWidget()) { | - |
| 2765 | d->originalTitle = QString::null; | - |
| 2766 | if (d->baseWidget && d->baseWidget->windowTitle() == windowTitle()) | - |
| 2767 | d->updateWindowTitle(true); | - |
| 2768 | else | - |
| 2769 | d->updateWindowTitle(false); | - |
| 2770 | #endif | - |
| 2771 | } | - |
| 2772 | break; | - |
| 2773 | case QEvent::ModifiedChange: { | - |
| 2774 | if (object != d->baseWidget) | - |
| 2775 | break; | - |
| 2776 | bool windowModified = d->baseWidget->isWindowModified(); | - |
| 2777 | if (!windowModified && d->baseWidget->windowTitle() != windowTitle()) | - |
| 2778 | break; | - |
| 2779 | if (windowTitle().contains(QLatin1String("[*]"))) | - |
| 2780 | setWindowModified(windowModified); | - |
| 2781 | break; | - |
| 2782 | } | - |
| 2783 | default: | - |
| 2784 | break; | - |
| 2785 | } | - |
| 2786 | return QWidget::eventFilter(object, event); | - |
| 2787 | } | - |
| 2788 | | - |
| 2789 | /*! | - |
| 2790 | \reimp | - |
| 2791 | */ | - |
| 2792 | bool QMdiSubWindow::event(QEvent *event) | - |
| 2793 | { | - |
| 2794 | Q_D(QMdiSubWindow); executed (the execution status of this line is deduced): QMdiSubWindowPrivate * const d = d_func(); | - |
| 2795 | switch (event->type()) { | - |
| 2796 | case QEvent::StyleChange: { | - |
| 2797 | bool wasShaded = isShaded(); never executed (the execution status of this line is deduced): bool wasShaded = isShaded(); | - |
| 2798 | bool wasMinimized = isMinimized(); never executed (the execution status of this line is deduced): bool wasMinimized = isMinimized(); | - |
| 2799 | bool wasMaximized = isMaximized(); never executed (the execution status of this line is deduced): bool wasMaximized = isMaximized(); | - |
| 2800 | ensurePolished(); never executed (the execution status of this line is deduced): ensurePolished(); | - |
| 2801 | setContentsMargins(0, 0, 0, 0); never executed (the execution status of this line is deduced): setContentsMargins(0, 0, 0, 0); | - |
| 2802 | if (wasMinimized || wasMaximized || wasShaded) never evaluated: wasMinimized never evaluated: wasMaximized never evaluated: wasShaded | 0 |
| 2803 | showNormal(); never executed: showNormal(); | 0 |
| 2804 | d->updateGeometryConstraints(); never executed (the execution status of this line is deduced): d->updateGeometryConstraints(); | - |
| 2805 | resize(d->internalMinimumSize.expandedTo(size())); never executed (the execution status of this line is deduced): resize(d->internalMinimumSize.expandedTo(size())); | - |
| 2806 | d->updateMask(); never executed (the execution status of this line is deduced): d->updateMask(); | - |
| 2807 | d->updateDirtyRegions(); never executed (the execution status of this line is deduced): d->updateDirtyRegions(); | - |
| 2808 | if (wasShaded) never evaluated: wasShaded | 0 |
| 2809 | showShaded(); never executed: showShaded(); | 0 |
| 2810 | else if (wasMinimized) never evaluated: wasMinimized | 0 |
| 2811 | showMinimized(); never executed: showMinimized(); | 0 |
| 2812 | else if (wasMaximized) never evaluated: wasMaximized | 0 |
| 2813 | showMaximized(); never executed: showMaximized(); | 0 |
| 2814 | break; | 0 |
| 2815 | } | - |
| 2816 | case QEvent::ParentAboutToChange: | - |
| 2817 | d->setActive(false); executed (the execution status of this line is deduced): d->setActive(false); | - |
| 2818 | break; executed: break;Execution Count:8 | 8 |
| 2819 | case QEvent::ParentChange: { | - |
| 2820 | bool wasResized = testAttribute(Qt::WA_Resized); executed (the execution status of this line is deduced): bool wasResized = testAttribute(Qt::WA_Resized); | - |
| 2821 | #ifndef QT_NO_MENUBAR | - |
| 2822 | d->removeButtonsFromMenuBar(); executed (the execution status of this line is deduced): d->removeButtonsFromMenuBar(); | - |
| 2823 | #endif | - |
| 2824 | d->currentOperation = QMdiSubWindowPrivate::None; executed (the execution status of this line is deduced): d->currentOperation = QMdiSubWindowPrivate::None; | - |
| 2825 | d->activeSubControl = QStyle::SC_None; executed (the execution status of this line is deduced): d->activeSubControl = QStyle::SC_None; | - |
| 2826 | d->hoveredSubControl = QStyle::SC_None; executed (the execution status of this line is deduced): d->hoveredSubControl = QStyle::SC_None; | - |
| 2827 | #ifndef QT_NO_RUBBERBAND | - |
| 2828 | if (d->isInRubberBandMode) partially evaluated: d->isInRubberBandMode| no Evaluation Count:0 | yes Evaluation Count:66 |
| 0-66 |
| 2829 | d->leaveRubberBandMode(); never executed: d->leaveRubberBandMode(); | 0 |
| 2830 | #endif | - |
| 2831 | d->isShadeMode = false; executed (the execution status of this line is deduced): d->isShadeMode = false; | - |
| 2832 | d->isMaximizeMode = false; executed (the execution status of this line is deduced): d->isMaximizeMode = false; | - |
| 2833 | d->isWidgetHiddenByUs = false; executed (the execution status of this line is deduced): d->isWidgetHiddenByUs = false; | - |
| 2834 | if (!parent()) { evaluated: !parent()| yes Evaluation Count:28 | yes Evaluation Count:38 |
| 28-38 |
| 2835 | #if !defined(QT_NO_SIZEGRIP) && defined(Q_WS_MACQ_OS_MAC) && !defined(QT_NO_STYLE_MAC) | - |
| 2836 | if (qobject_cast<QMacStyle *>(style())) | - |
| 2837 | delete d->sizeGrip; | - |
| 2838 | #endif | - |
| 2839 | setOption(RubberBandResize, false); executed (the execution status of this line is deduced): setOption(RubberBandResize, false); | - |
| 2840 | setOption(RubberBandMove, false); executed (the execution status of this line is deduced): setOption(RubberBandMove, false); | - |
| 2841 | } else { executed: }Execution Count:28 | 28 |
| 2842 | d->setWindowFlags(windowFlags()); executed (the execution status of this line is deduced): d->setWindowFlags(windowFlags()); | - |
| 2843 | } executed: }Execution Count:38 | 38 |
| 2844 | setContentsMargins(0, 0, 0, 0); executed (the execution status of this line is deduced): setContentsMargins(0, 0, 0, 0); | - |
| 2845 | d->updateGeometryConstraints(); executed (the execution status of this line is deduced): d->updateGeometryConstraints(); | - |
| 2846 | d->updateCursor(); executed (the execution status of this line is deduced): d->updateCursor(); | - |
| 2847 | d->updateMask(); executed (the execution status of this line is deduced): d->updateMask(); | - |
| 2848 | d->updateDirtyRegions(); executed (the execution status of this line is deduced): d->updateDirtyRegions(); | - |
| 2849 | d->updateActions(); executed (the execution status of this line is deduced): d->updateActions(); | - |
| 2850 | if (!wasResized && testAttribute(Qt::WA_Resized)) evaluated: !wasResized| yes Evaluation Count:57 | yes Evaluation Count:9 |
partially evaluated: testAttribute(Qt::WA_Resized)| no Evaluation Count:0 | yes Evaluation Count:57 |
| 0-57 |
| 2851 | setAttribute(Qt::WA_Resized, false); never executed: setAttribute(Qt::WA_Resized, false); | 0 |
| 2852 | break; executed: break;Execution Count:66 | 66 |
| 2853 | } | - |
| 2854 | case QEvent::WindowActivate: | - |
| 2855 | if (d->ignoreNextActivationEvent) { evaluated: d->ignoreNextActivationEvent| yes Evaluation Count:54 | yes Evaluation Count:6 |
| 6-54 |
| 2856 | d->ignoreNextActivationEvent = false; executed (the execution status of this line is deduced): d->ignoreNextActivationEvent = false; | - |
| 2857 | break; executed: break;Execution Count:54 | 54 |
| 2858 | } | - |
| 2859 | d->isExplicitlyDeactivated = false; executed (the execution status of this line is deduced): d->isExplicitlyDeactivated = false; | - |
| 2860 | d->setActive(true); executed (the execution status of this line is deduced): d->setActive(true); | - |
| 2861 | break; executed: break;Execution Count:6 | 6 |
| 2862 | case QEvent::WindowDeactivate: | - |
| 2863 | if (d->ignoreNextActivationEvent) { evaluated: d->ignoreNextActivationEvent| yes Evaluation Count:30 | yes Evaluation Count:46 |
| 30-46 |
| 2864 | d->ignoreNextActivationEvent = false; executed (the execution status of this line is deduced): d->ignoreNextActivationEvent = false; | - |
| 2865 | break; executed: break;Execution Count:30 | 30 |
| 2866 | } | - |
| 2867 | d->isExplicitlyDeactivated = true; executed (the execution status of this line is deduced): d->isExplicitlyDeactivated = true; | - |
| 2868 | d->setActive(false); executed (the execution status of this line is deduced): d->setActive(false); | - |
| 2869 | break; executed: break;Execution Count:46 | 46 |
| 2870 | case QEvent::WindowTitleChange: | - |
| 2871 | if (!d->ignoreWindowTitleChange) evaluated: !d->ignoreWindowTitleChange| yes Evaluation Count:5 | yes Evaluation Count:20 |
| 5-20 |
| 2872 | d->updateWindowTitle(false); executed: d->updateWindowTitle(false);Execution Count:5 | 5 |
| 2873 | d->updateInternalWindowTitle(); executed (the execution status of this line is deduced): d->updateInternalWindowTitle(); | - |
| 2874 | break; executed: break;Execution Count:25 | 25 |
| 2875 | case QEvent::ModifiedChange: | - |
| 2876 | if (!windowTitle().contains(QLatin1String("[*]"))) evaluated: !windowTitle().contains(QLatin1String("[*]"))| yes Evaluation Count:4 | yes Evaluation Count:4 |
| 4 |
| 2877 | break; executed: break;Execution Count:4 | 4 |
| 2878 | #ifndef QT_NO_MENUBAR | - |
| 2879 | if (maximizedButtonsWidget() && d->controlContainer->menuBar() && d->controlContainer->menuBar() partially evaluated: maximizedButtonsWidget()| no Evaluation Count:0 | yes Evaluation Count:4 |
never evaluated: d->controlContainer->menuBar() never evaluated: d->controlContainer->menuBar() ->cornerWidget(Qt::TopRightCorner) == maximizedButtonsWidget() | 0-4 |
| 2880 | ->cornerWidget(Qt::TopRightCorner) == maximizedButtonsWidget()) { never evaluated: d->controlContainer->menuBar() ->cornerWidget(Qt::TopRightCorner) == maximizedButtonsWidget() | 0 |
| 2881 | window()->setWindowModified(isWindowModified()); never executed (the execution status of this line is deduced): window()->setWindowModified(isWindowModified()); | - |
| 2882 | } | 0 |
| 2883 | #endif // QT_NO_MENUBAR | - |
| 2884 | d->updateInternalWindowTitle(); executed (the execution status of this line is deduced): d->updateInternalWindowTitle(); | - |
| 2885 | break; executed: break;Execution Count:4 | 4 |
| 2886 | case QEvent::LayoutDirectionChange: | - |
| 2887 | d->updateDirtyRegions(); executed (the execution status of this line is deduced): d->updateDirtyRegions(); | - |
| 2888 | break; executed: break;Execution Count:2 | 2 |
| 2889 | case QEvent::LayoutRequest: | - |
| 2890 | d->updateGeometryConstraints(); executed (the execution status of this line is deduced): d->updateGeometryConstraints(); | - |
| 2891 | break; executed: break;Execution Count:132 | 132 |
| 2892 | case QEvent::WindowIconChange: | - |
| 2893 | d->menuIcon = windowIcon(); never executed (the execution status of this line is deduced): d->menuIcon = windowIcon(); | - |
| 2894 | if (d->menuIcon.isNull()) never evaluated: d->menuIcon.isNull() | 0 |
| 2895 | d->menuIcon = style()->standardIcon(QStyle::SP_TitleBarMenuButton, 0, this); never executed: d->menuIcon = style()->standardIcon(QStyle::SP_TitleBarMenuButton, 0, this); | 0 |
| 2896 | if (d->controlContainer) never evaluated: d->controlContainer | 0 |
| 2897 | d->controlContainer->updateWindowIcon(d->menuIcon); never executed: d->controlContainer->updateWindowIcon(d->menuIcon); | 0 |
| 2898 | if (!maximizedSystemMenuIconWidget()) never evaluated: !maximizedSystemMenuIconWidget() | 0 |
| 2899 | update(0, 0, width(), d->titleBarHeight()); never executed: update(0, 0, width(), d->titleBarHeight()); | 0 |
| 2900 | break; | 0 |
| 2901 | case QEvent::PaletteChange: | - |
| 2902 | d->titleBarPalette = d->desktopPalette(); executed (the execution status of this line is deduced): d->titleBarPalette = d->desktopPalette(); | - |
| 2903 | break; executed: break;Execution Count:102 | 102 |
| 2904 | case QEvent::FontChange: | - |
| 2905 | d->font = font(); never executed (the execution status of this line is deduced): d->font = font(); | - |
| 2906 | break; | 0 |
| 2907 | #ifndef QT_NO_TOOLTIP | - |
| 2908 | case QEvent::ToolTip: | - |
| 2909 | showToolTip(static_cast<QHelpEvent *>(event), this, d->titleBarOptions(), never executed (the execution status of this line is deduced): showToolTip(static_cast<QHelpEvent *>(event), this, d->titleBarOptions(), | - |
| 2910 | QStyle::CC_TitleBar, d->hoveredSubControl); never executed (the execution status of this line is deduced): QStyle::CC_TitleBar, d->hoveredSubControl); | - |
| 2911 | break; | 0 |
| 2912 | #endif | - |
| 2913 | default: | - |
| 2914 | break; executed: break;Execution Count:9510 | 9510 |
| 2915 | } | - |
| 2916 | return QWidget::event(event); executed: return QWidget::event(event);Execution Count:9989 | 9989 |
| 2917 | } | - |
| 2918 | | - |
| 2919 | /*! | - |
| 2920 | \reimp | - |
| 2921 | */ | - |
| 2922 | void QMdiSubWindow::showEvent(QShowEvent *showEvent) | - |
| 2923 | { | - |
| 2924 | Q_D(QMdiSubWindow); executed (the execution status of this line is deduced): QMdiSubWindowPrivate * const d = d_func(); | - |
| 2925 | if (!parent()) { evaluated: !parent()| yes Evaluation Count:10 | yes Evaluation Count:260 |
| 10-260 |
| 2926 | QWidget::showEvent(showEvent); executed (the execution status of this line is deduced): QWidget::showEvent(showEvent); | - |
| 2927 | return; executed: return;Execution Count:10 | 10 |
| 2928 | } | - |
| 2929 | | - |
| 2930 | #if !defined(QT_NO_SIZEGRIP) && defined(Q_WS_MACQ_OS_MAC) && !defined(QT_NO_STYLE_MAC) | - |
| 2931 | if (qobject_cast<QMacStyle *>(style()) && !d->sizeGrip | - |
| 2932 | && !(windowFlags() & Qt::FramelessWindowHint)) { | - |
| 2933 | d->setSizeGrip(new QSizeGrip(0)); | - |
| 2934 | Q_ASSERT(d->sizeGrip); | - |
| 2935 | if (isMinimized()) | - |
| 2936 | d->setSizeGripVisible(false); | - |
| 2937 | else | - |
| 2938 | d->setSizeGripVisible(true); | - |
| 2939 | resize(size().expandedTo(d->internalMinimumSize)); | - |
| 2940 | } | - |
| 2941 | #endif | - |
| 2942 | | - |
| 2943 | d->updateDirtyRegions(); executed (the execution status of this line is deduced): d->updateDirtyRegions(); | - |
| 2944 | // Show buttons in the menu bar if they're already not there. | - |
| 2945 | // We want to do this when QMdiSubWindow becomes visible after being hidden. | - |
| 2946 | #ifndef QT_NO_MENUBAR | - |
| 2947 | if (d->controlContainer) { partially evaluated: d->controlContainer| yes Evaluation Count:260 | no Evaluation Count:0 |
| 0-260 |
| 2948 | if (QMenuBar *menuBar = d->menuBar()) { evaluated: QMenuBar *menuBar = d->menuBar()| yes Evaluation Count:36 | yes Evaluation Count:224 |
| 36-224 |
| 2949 | if (menuBar->cornerWidget(Qt::TopRightCorner) != maximizedButtonsWidget()) evaluated: menuBar->cornerWidget(Qt::TopRightCorner) != maximizedButtonsWidget()| yes Evaluation Count:3 | yes Evaluation Count:33 |
| 3-33 |
| 2950 | d->showButtonsInMenuBar(menuBar); executed: d->showButtonsInMenuBar(menuBar);Execution Count:3 | 3 |
| 2951 | } executed: }Execution Count:36 | 36 |
| 2952 | } executed: }Execution Count:260 | 260 |
| 2953 | #endif | - |
| 2954 | d->setActive(true); executed (the execution status of this line is deduced): d->setActive(true); | - |
| 2955 | } executed: }Execution Count:260 | 260 |
| 2956 | | - |
| 2957 | /*! | - |
| 2958 | \reimp | - |
| 2959 | */ | - |
| 2960 | void QMdiSubWindow::hideEvent(QHideEvent * /*hideEvent*/) | - |
| 2961 | { | - |
| 2962 | #ifndef QT_NO_MENUBAR | - |
| 2963 | d_func()->removeButtonsFromMenuBar(); | - |
| 2964 | #endif | - |
| 2965 | } | - |
| 2966 | | - |
| 2967 | /*! | - |
| 2968 | \reimp | - |
| 2969 | */ | - |
| 2970 | void QMdiSubWindow::changeEvent(QEvent *changeEvent) | - |
| 2971 | { | - |
| 2972 | if (!parent()) { | - |
| 2973 | QWidget::changeEvent(changeEvent); | - |
| 2974 | return; | - |
| 2975 | } | - |
| 2976 | | - |
| 2977 | if (changeEvent->type() != QEvent::WindowStateChange) { | - |
| 2978 | QWidget::changeEvent(changeEvent); | - |
| 2979 | return; | - |
| 2980 | } | - |
| 2981 | | - |
| 2982 | QWindowStateChangeEvent *event = static_cast<QWindowStateChangeEvent *>(changeEvent); | - |
| 2983 | if (event->isOverride()) { | - |
| 2984 | event->ignore(); | - |
| 2985 | return; | - |
| 2986 | } | - |
| 2987 | | - |
| 2988 | Qt::WindowStates oldState = event->oldState(); | - |
| 2989 | Qt::WindowStates newState = windowState(); | - |
| 2990 | if (oldState == newState) { | - |
| 2991 | changeEvent->ignore(); | - |
| 2992 | return; | - |
| 2993 | } | - |
| 2994 | | - |
| 2995 | // QWidget ensures that the widget is visible _after_ setWindowState(), | - |
| 2996 | // but we need to ensure that the widget is visible _before_ | - |
| 2997 | // setWindowState() returns. | - |
| 2998 | Q_D(QMdiSubWindow); | - |
| 2999 | if (!isVisible()) { | - |
| 3000 | d->ensureWindowState(Qt::WindowNoState); | - |
| 3001 | setVisible(true); | - |
| 3002 | } | - |
| 3003 | | - |
| 3004 | if (!d->oldGeometry.isValid()) | - |
| 3005 | d->oldGeometry = geometry(); | - |
| 3006 | | - |
| 3007 | if ((oldState & Qt::WindowActive) && (newState & Qt::WindowActive)) | - |
| 3008 | d->currentOperation = QMdiSubWindowPrivate::None; | - |
| 3009 | | - |
| 3010 | if (!(oldState & Qt::WindowMinimized) && (newState & Qt::WindowMinimized)) | - |
| 3011 | d->setMinimizeMode(); | - |
| 3012 | else if (!(oldState & Qt::WindowMaximized) && (newState & Qt::WindowMaximized)) | - |
| 3013 | d->setMaximizeMode(); | - |
| 3014 | else if (!(newState & (Qt::WindowMaximized | Qt::WindowMinimized))) | - |
| 3015 | d->setNormalMode(); | - |
| 3016 | | - |
| 3017 | if (d->isActive) | - |
| 3018 | d->ensureWindowState(Qt::WindowActive); | - |
| 3019 | emit windowStateChanged(oldState, windowState()); | - |
| 3020 | } | - |
| 3021 | | - |
| 3022 | /*! | - |
| 3023 | \reimp | - |
| 3024 | */ | - |
| 3025 | void QMdiSubWindow::closeEvent(QCloseEvent *closeEvent) | - |
| 3026 | { | - |
| 3027 | Q_D(QMdiSubWindow); | - |
| 3028 | bool acceptClose = true; | - |
| 3029 | if (d->baseWidget) | - |
| 3030 | acceptClose = d->baseWidget->close(); | - |
| 3031 | if (!acceptClose) { | - |
| 3032 | closeEvent->ignore(); | - |
| 3033 | return; | - |
| 3034 | } | - |
| 3035 | #ifndef QT_NO_MENUBAR | - |
| 3036 | d->removeButtonsFromMenuBar(); | - |
| 3037 | #endif | - |
| 3038 | d->setActive(false); | - |
| 3039 | if (parentWidget() && testAttribute(Qt::WA_DeleteOnClose)) { | - |
| 3040 | QChildEvent childRemoved(QEvent::ChildRemoved, this); | - |
| 3041 | QApplication::sendEvent(parentWidget(), &childRemoved); | - |
| 3042 | } | - |
| 3043 | closeEvent->accept(); | - |
| 3044 | } | - |
| 3045 | | - |
| 3046 | /*! | - |
| 3047 | \reimp | - |
| 3048 | */ | - |
| 3049 | void QMdiSubWindow::leaveEvent(QEvent * /*leaveEvent*/) | - |
| 3050 | { | - |
| 3051 | Q_D(QMdiSubWindow); | - |
| 3052 | if (d->hoveredSubControl != QStyle::SC_None) { | - |
| 3053 | d->hoveredSubControl = QStyle::SC_None; | - |
| 3054 | update(QRegion(0, 0, width(), d->titleBarHeight())); | - |
| 3055 | } | - |
| 3056 | } | - |
| 3057 | | - |
| 3058 | /*! | - |
| 3059 | \reimp | - |
| 3060 | */ | - |
| 3061 | void QMdiSubWindow::resizeEvent(QResizeEvent *resizeEvent) | - |
| 3062 | { | - |
| 3063 | Q_D(QMdiSubWindow); | - |
| 3064 | #ifndef QT_NO_SIZEGRIP | - |
| 3065 | if (d->sizeGrip) { | - |
| 3066 | d->sizeGrip->move(isLeftToRight() ? width() - d->sizeGrip->width() : 0, | - |
| 3067 | height() - d->sizeGrip->height()); | - |
| 3068 | } | - |
| 3069 | #endif | - |
| 3070 | | - |
| 3071 | if (!parent()) { | - |
| 3072 | QWidget::resizeEvent(resizeEvent); | - |
| 3073 | return; | - |
| 3074 | } | - |
| 3075 | | - |
| 3076 | if (d->isMaximizeMode) | - |
| 3077 | d->ensureWindowState(Qt::WindowMaximized); | - |
| 3078 | | - |
| 3079 | d->updateMask(); | - |
| 3080 | if (!isVisible()) | - |
| 3081 | return; | - |
| 3082 | | - |
| 3083 | if (d->resizeTimerId <= 0) | - |
| 3084 | d->cachedStyleOptions = d->titleBarOptions(); | - |
| 3085 | else | - |
| 3086 | killTimer(d->resizeTimerId); | - |
| 3087 | d->resizeTimerId = startTimer(200); | - |
| 3088 | } | - |
| 3089 | | - |
| 3090 | /*! | - |
| 3091 | \reimp | - |
| 3092 | */ | - |
| 3093 | void QMdiSubWindow::timerEvent(QTimerEvent *timerEvent) | - |
| 3094 | { | - |
| 3095 | Q_D(QMdiSubWindow); | - |
| 3096 | if (timerEvent->timerId() == d->resizeTimerId) { | - |
| 3097 | killTimer(d->resizeTimerId); | - |
| 3098 | d->resizeTimerId = -1; | - |
| 3099 | d->updateDirtyRegions(); | - |
| 3100 | } | - |
| 3101 | } | - |
| 3102 | | - |
| 3103 | /*! | - |
| 3104 | \reimp | - |
| 3105 | */ | - |
| 3106 | void QMdiSubWindow::moveEvent(QMoveEvent *moveEvent) | - |
| 3107 | { | - |
| 3108 | if (!parent()) { | - |
| 3109 | QWidget::moveEvent(moveEvent); | - |
| 3110 | return; | - |
| 3111 | } | - |
| 3112 | | - |
| 3113 | Q_D(QMdiSubWindow); | - |
| 3114 | if (d->isMaximizeMode) | - |
| 3115 | d->ensureWindowState(Qt::WindowMaximized); | - |
| 3116 | } | - |
| 3117 | | - |
| 3118 | /*! | - |
| 3119 | \reimp | - |
| 3120 | */ | - |
| 3121 | void QMdiSubWindow::paintEvent(QPaintEvent *paintEvent) | - |
| 3122 | { | - |
| 3123 | if (!parent() || (windowFlags() & Qt::FramelessWindowHint)) { | - |
| 3124 | QWidget::paintEvent(paintEvent); | - |
| 3125 | return; | - |
| 3126 | } | - |
| 3127 | | - |
| 3128 | Q_D(QMdiSubWindow); | - |
| 3129 | if (isMaximized() && !d->drawTitleBarWhenMaximized()) | - |
| 3130 | return; | - |
| 3131 | | - |
| 3132 | if (d->resizeTimerId != -1) { | - |
| 3133 | // Only update the style option rect and the window title. | - |
| 3134 | int border = d->hasBorder(d->cachedStyleOptions) ? 4 : 0; | - |
| 3135 | int titleBarHeight = d->titleBarHeight(d->cachedStyleOptions); | - |
| 3136 | titleBarHeight -= isMinimized() ? 2 * border : border; | - |
| 3137 | d->cachedStyleOptions.rect = QRect(border, border, width() - 2 * border, titleBarHeight); | - |
| 3138 | if (!d->windowTitle.isEmpty()) { | - |
| 3139 | int width = style()->subControlRect(QStyle::CC_TitleBar, &d->cachedStyleOptions, | - |
| 3140 | QStyle::SC_TitleBarLabel, this).width(); | - |
| 3141 | d->cachedStyleOptions.text = d->cachedStyleOptions.fontMetrics | - |
| 3142 | .elidedText(d->windowTitle, Qt::ElideRight, width); | - |
| 3143 | } | - |
| 3144 | } else { | - |
| 3145 | // Force full update. | - |
| 3146 | d->cachedStyleOptions = d->titleBarOptions(); | - |
| 3147 | } | - |
| 3148 | | - |
| 3149 | QStylePainter painter(this); | - |
| 3150 | if (!d->windowTitle.isEmpty()) | - |
| 3151 | painter.setFont(d->font); | - |
| 3152 | painter.drawComplexControl(QStyle::CC_TitleBar, d->cachedStyleOptions); | - |
| 3153 | | - |
| 3154 | if (isMinimized() && !d->hasBorder(d->cachedStyleOptions)) | - |
| 3155 | return; | - |
| 3156 | | - |
| 3157 | QStyleOptionFrame frameOptions; | - |
| 3158 | frameOptions.initFrom(this); | - |
| 3159 | frameOptions.lineWidth = style()->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth, 0, this); | - |
| 3160 | if (d->isActive) | - |
| 3161 | frameOptions.state |= QStyle::State_Active; | - |
| 3162 | else | - |
| 3163 | frameOptions.state &= ~QStyle::State_Active; | - |
| 3164 | | - |
| 3165 | // ### Ensure that we do not require setting the cliprect for 4.4 | - |
| 3166 | if (!isMinimized() && !d->hasBorder(d->cachedStyleOptions)) | - |
| 3167 | painter.setClipRect(rect().adjusted(0, d->titleBarHeight(d->cachedStyleOptions), 0, 0)); | - |
| 3168 | if (!isMinimized() || d->hasBorder(d->cachedStyleOptions)) | - |
| 3169 | painter.drawPrimitive(QStyle::PE_FrameWindow, frameOptions); | - |
| 3170 | } | - |
| 3171 | | - |
| 3172 | /*! | - |
| 3173 | \reimp | - |
| 3174 | */ | - |
| 3175 | void QMdiSubWindow::mousePressEvent(QMouseEvent *mouseEvent) | - |
| 3176 | { | - |
| 3177 | if (!parent()) { | - |
| 3178 | QWidget::mousePressEvent(mouseEvent); | - |
| 3179 | return; | - |
| 3180 | } | - |
| 3181 | | - |
| 3182 | Q_D(QMdiSubWindow); | - |
| 3183 | if (d->isInInteractiveMode) | - |
| 3184 | d->leaveInteractiveMode(); | - |
| 3185 | #ifndef QT_NO_RUBBERBAND | - |
| 3186 | if (d->isInRubberBandMode) | - |
| 3187 | d->leaveRubberBandMode(); | - |
| 3188 | #endif | - |
| 3189 | | - |
| 3190 | if (mouseEvent->button() != Qt::LeftButton) { | - |
| 3191 | mouseEvent->ignore(); | - |
| 3192 | return; | - |
| 3193 | } | - |
| 3194 | | - |
| 3195 | if (d->currentOperation != QMdiSubWindowPrivate::None) { | - |
| 3196 | d->updateCursor(); | - |
| 3197 | d->mousePressPosition = mapToParent(mouseEvent->pos()); | - |
| 3198 | if (d->resizeEnabled || d->moveEnabled) | - |
| 3199 | d->oldGeometry = geometry(); | - |
| 3200 | #ifndef QT_NO_RUBBERBAND | - |
| 3201 | if ((testOption(QMdiSubWindow::RubberBandResize) && d->isResizeOperation()) | - |
| 3202 | || (testOption(QMdiSubWindow::RubberBandMove) && d->isMoveOperation())) { | - |
| 3203 | d->enterRubberBandMode(); | - |
| 3204 | } | - |
| 3205 | #endif | - |
| 3206 | return; | - |
| 3207 | } | - |
| 3208 | | - |
| 3209 | d->activeSubControl = d->hoveredSubControl; | - |
| 3210 | #ifndef QT_NO_MENU | - |
| 3211 | if (d->activeSubControl == QStyle::SC_TitleBarSysMenu) | - |
| 3212 | showSystemMenu(); | - |
| 3213 | else | - |
| 3214 | #endif | - |
| 3215 | update(QRegion(0, 0, width(), d->titleBarHeight())); | - |
| 3216 | } | - |
| 3217 | | - |
| 3218 | /*! | - |
| 3219 | \reimp | - |
| 3220 | */ | - |
| 3221 | void QMdiSubWindow::mouseDoubleClickEvent(QMouseEvent *mouseEvent) | - |
| 3222 | { | - |
| 3223 | if (!parent()) { | - |
| 3224 | QWidget::mouseDoubleClickEvent(mouseEvent); | - |
| 3225 | return; | - |
| 3226 | } | - |
| 3227 | | - |
| 3228 | if (mouseEvent->button() != Qt::LeftButton) { | - |
| 3229 | mouseEvent->ignore(); | - |
| 3230 | return; | - |
| 3231 | } | - |
| 3232 | | - |
| 3233 | Q_D(QMdiSubWindow); | - |
| 3234 | if (!d->isMoveOperation()) { | - |
| 3235 | #ifndef QT_NO_MENU | - |
| 3236 | if (d->hoveredSubControl == QStyle::SC_TitleBarSysMenu) | - |
| 3237 | close(); | - |
| 3238 | #endif | - |
| 3239 | return; | - |
| 3240 | } | - |
| 3241 | | - |
| 3242 | Qt::WindowFlags flags = windowFlags(); | - |
| 3243 | if (isMinimized()) { | - |
| 3244 | if ((isShaded() && (flags & Qt::WindowShadeButtonHint)) | - |
| 3245 | || (flags & Qt::WindowMinimizeButtonHint)) { | - |
| 3246 | showNormal(); | - |
| 3247 | } | - |
| 3248 | return; | - |
| 3249 | } | - |
| 3250 | | - |
| 3251 | if (isMaximized()) { | - |
| 3252 | if (flags & Qt::WindowMaximizeButtonHint) | - |
| 3253 | showNormal(); | - |
| 3254 | return; | - |
| 3255 | } | - |
| 3256 | | - |
| 3257 | if (flags & Qt::WindowShadeButtonHint) | - |
| 3258 | showShaded(); | - |
| 3259 | else if (flags & Qt::WindowMaximizeButtonHint) | - |
| 3260 | showMaximized(); | - |
| 3261 | } | - |
| 3262 | | - |
| 3263 | /*! | - |
| 3264 | \reimp | - |
| 3265 | */ | - |
| 3266 | void QMdiSubWindow::mouseReleaseEvent(QMouseEvent *mouseEvent) | - |
| 3267 | { | - |
| 3268 | if (!parent()) { | - |
| 3269 | QWidget::mouseReleaseEvent(mouseEvent); | - |
| 3270 | return; | - |
| 3271 | } | - |
| 3272 | | - |
| 3273 | if (mouseEvent->button() != Qt::LeftButton) { | - |
| 3274 | mouseEvent->ignore(); | - |
| 3275 | return; | - |
| 3276 | } | - |
| 3277 | | - |
| 3278 | Q_D(QMdiSubWindow); | - |
| 3279 | if (d->currentOperation != QMdiSubWindowPrivate::None) { | - |
| 3280 | #ifndef QT_NO_RUBBERBAND | - |
| 3281 | if (d->isInRubberBandMode && !d->isInInteractiveMode) | - |
| 3282 | d->leaveRubberBandMode(); | - |
| 3283 | #endif | - |
| 3284 | if (d->resizeEnabled || d->moveEnabled) | - |
| 3285 | d->oldGeometry = geometry(); | - |
| 3286 | } | - |
| 3287 | | - |
| 3288 | d->currentOperation = d->getOperation(mouseEvent->pos()); | - |
| 3289 | d->updateCursor(); | - |
| 3290 | | - |
| 3291 | d->hoveredSubControl = d->getSubControl(mouseEvent->pos()); | - |
| 3292 | if (d->activeSubControl != QStyle::SC_None | - |
| 3293 | && d->activeSubControl == d->hoveredSubControl) { | - |
| 3294 | d->processClickedSubControl(); | - |
| 3295 | } | - |
| 3296 | d->activeSubControl = QStyle::SC_None; | - |
| 3297 | update(QRegion(0, 0, width(), d->titleBarHeight())); | - |
| 3298 | } | - |
| 3299 | | - |
| 3300 | /*! | - |
| 3301 | \reimp | - |
| 3302 | */ | - |
| 3303 | void QMdiSubWindow::mouseMoveEvent(QMouseEvent *mouseEvent) | - |
| 3304 | { | - |
| 3305 | if (!parent()) { partially evaluated: !parent()| no Evaluation Count:0 | yes Evaluation Count:362 |
| 0-362 |
| 3306 | QWidget::mouseMoveEvent(mouseEvent); never executed (the execution status of this line is deduced): QWidget::mouseMoveEvent(mouseEvent); | - |
| 3307 | return; | 0 |
| 3308 | } | - |
| 3309 | | - |
| 3310 | Q_D(QMdiSubWindow); executed (the execution status of this line is deduced): QMdiSubWindowPrivate * const d = d_func(); | - |
| 3311 | // No update needed if we're in a move/resize operation. | - |
| 3312 | if (!d->isMoveOperation() && !d->isResizeOperation()) { evaluated: !d->isMoveOperation()| yes Evaluation Count:322 | yes Evaluation Count:40 |
evaluated: !d->isResizeOperation()| yes Evaluation Count:11 | yes Evaluation Count:311 |
| 11-322 |
| 3313 | // Find previous and current hover region. | - |
| 3314 | const QStyleOptionTitleBar options = d->titleBarOptions(); executed (the execution status of this line is deduced): const QStyleOptionTitleBar options = d->titleBarOptions(); | - |
| 3315 | QStyle::SubControl oldHover = d->hoveredSubControl; executed (the execution status of this line is deduced): QStyle::SubControl oldHover = d->hoveredSubControl; | - |
| 3316 | d->hoveredSubControl = d->getSubControl(mouseEvent->pos()); executed (the execution status of this line is deduced): d->hoveredSubControl = d->getSubControl(mouseEvent->pos()); | - |
| 3317 | QRegion hoverRegion; executed (the execution status of this line is deduced): QRegion hoverRegion; | - |
| 3318 | if (isHoverControl(oldHover) && oldHover != d->hoveredSubControl) partially evaluated: isHoverControl(oldHover)| no Evaluation Count:0 | yes Evaluation Count:11 |
never evaluated: oldHover != d->hoveredSubControl | 0-11 |
| 3319 | hoverRegion += style()->subControlRect(QStyle::CC_TitleBar, &options, oldHover, this); never executed: hoverRegion += style()->subControlRect(QStyle::CC_TitleBar, &options, oldHover, this); | 0 |
| 3320 | if (isHoverControl(d->hoveredSubControl) && d->hoveredSubControl != oldHover) { partially evaluated: isHoverControl(d->hoveredSubControl)| no Evaluation Count:0 | yes Evaluation Count:11 |
never evaluated: d->hoveredSubControl != oldHover | 0-11 |
| 3321 | hoverRegion += style()->subControlRect(QStyle::CC_TitleBar, &options, never executed (the execution status of this line is deduced): hoverRegion += style()->subControlRect(QStyle::CC_TitleBar, &options, | - |
| 3322 | d->hoveredSubControl, this); never executed (the execution status of this line is deduced): d->hoveredSubControl, this); | - |
| 3323 | } | 0 |
| 3324 | #if defined(Q_WS_MACQ_OS_MAC) && !defined(QT_NO_STYLE_MAC) | - |
| 3325 | if (qobject_cast<QMacStyle *>(style()) && !hoverRegion.isEmpty()) | - |
| 3326 | hoverRegion += QRegion(0, 0, width(), d->titleBarHeight(options)); | - |
| 3327 | #endif | - |
| 3328 | if (!hoverRegion.isEmpty()) partially evaluated: !hoverRegion.isEmpty()| no Evaluation Count:0 | yes Evaluation Count:11 |
| 0-11 |
| 3329 | update(hoverRegion); never executed: update(hoverRegion); | 0 |
| 3330 | } executed: }Execution Count:11 | 11 |
| 3331 | | - |
| 3332 | if ((mouseEvent->buttons() & Qt::LeftButton) || d->isInInteractiveMode) { evaluated: (mouseEvent->buttons() & Qt::LeftButton)| yes Evaluation Count:351 | yes Evaluation Count:11 |
partially evaluated: d->isInInteractiveMode| no Evaluation Count:0 | yes Evaluation Count:11 |
| 0-351 |
| 3333 | if ((d->isResizeOperation() && d->resizeEnabled) || (d->isMoveOperation() && d->moveEnabled)) evaluated: d->isResizeOperation()| yes Evaluation Count:311 | yes Evaluation Count:40 |
partially evaluated: d->resizeEnabled| yes Evaluation Count:311 | no Evaluation Count:0 |
partially evaluated: d->isMoveOperation()| yes Evaluation Count:40 | no Evaluation Count:0 |
partially evaluated: d->moveEnabled| yes Evaluation Count:40 | no Evaluation Count:0 |
| 0-311 |
| 3334 | d->setNewGeometry(mapToParent(mouseEvent->pos())); executed: d->setNewGeometry(mapToParent(mouseEvent->pos()));Execution Count:351 | 351 |
| 3335 | return; executed: return;Execution Count:351 | 351 |
| 3336 | } | - |
| 3337 | | - |
| 3338 | // Do not resize/move if not allowed. | - |
| 3339 | d->currentOperation = d->getOperation(mouseEvent->pos()); executed (the execution status of this line is deduced): d->currentOperation = d->getOperation(mouseEvent->pos()); | - |
| 3340 | if ((d->isResizeOperation() && !d->resizeEnabled) || (d->isMoveOperation() && !d->moveEnabled)) evaluated: d->isResizeOperation()| yes Evaluation Count:3 | yes Evaluation Count:8 |
partially evaluated: !d->resizeEnabled| no Evaluation Count:0 | yes Evaluation Count:3 |
evaluated: d->isMoveOperation()| yes Evaluation Count:3 | yes Evaluation Count:8 |
partially evaluated: !d->moveEnabled| no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-8 |
| 3341 | d->currentOperation = QMdiSubWindowPrivate::None; never executed: d->currentOperation = QMdiSubWindowPrivate::None; | 0 |
| 3342 | d->updateCursor(); executed (the execution status of this line is deduced): d->updateCursor(); | - |
| 3343 | } executed: }Execution Count:11 | 11 |
| 3344 | | - |
| 3345 | /*! | - |
| 3346 | \reimp | - |
| 3347 | */ | - |
| 3348 | void QMdiSubWindow::keyPressEvent(QKeyEvent *keyEvent) | - |
| 3349 | { | - |
| 3350 | Q_D(QMdiSubWindow); | - |
| 3351 | if (!d->isInInteractiveMode || !parent()) { | - |
| 3352 | keyEvent->ignore(); | - |
| 3353 | return; | - |
| 3354 | } | - |
| 3355 | | - |
| 3356 | QPoint delta; | - |
| 3357 | switch (keyEvent->key()) { | - |
| 3358 | case Qt::Key_Right: | - |
| 3359 | if (keyEvent->modifiers() & Qt::ShiftModifier) | - |
| 3360 | delta = QPoint(d->keyboardPageStep, 0); | - |
| 3361 | else | - |
| 3362 | delta = QPoint(d->keyboardSingleStep, 0); | - |
| 3363 | break; | - |
| 3364 | case Qt::Key_Up: | - |
| 3365 | if (keyEvent->modifiers() & Qt::ShiftModifier) | - |
| 3366 | delta = QPoint(0, -d->keyboardPageStep); | - |
| 3367 | else | - |
| 3368 | delta = QPoint(0, -d->keyboardSingleStep); | - |
| 3369 | break; | - |
| 3370 | case Qt::Key_Left: | - |
| 3371 | if (keyEvent->modifiers() & Qt::ShiftModifier) | - |
| 3372 | delta = QPoint(-d->keyboardPageStep, 0); | - |
| 3373 | else | - |
| 3374 | delta = QPoint(-d->keyboardSingleStep, 0); | - |
| 3375 | break; | - |
| 3376 | case Qt::Key_Down: | - |
| 3377 | if (keyEvent->modifiers() & Qt::ShiftModifier) | - |
| 3378 | delta = QPoint(0, d->keyboardPageStep); | - |
| 3379 | else | - |
| 3380 | delta = QPoint(0, d->keyboardSingleStep); | - |
| 3381 | break; | - |
| 3382 | case Qt::Key_Escape: | - |
| 3383 | case Qt::Key_Return: | - |
| 3384 | case Qt::Key_Enter: | - |
| 3385 | d->leaveInteractiveMode(); | - |
| 3386 | return; | - |
| 3387 | default: | - |
| 3388 | keyEvent->ignore(); | - |
| 3389 | return; | - |
| 3390 | } | - |
| 3391 | | - |
| 3392 | #ifndef QT_NO_CURSOR | - |
| 3393 | QPoint newPosition = parentWidget()->mapFromGlobal(cursor().pos() + delta); | - |
| 3394 | QRect oldGeometry = | - |
| 3395 | #ifndef QT_NO_RUBBERBAND | - |
| 3396 | d->isInRubberBandMode ? d->rubberBand->geometry() : | - |
| 3397 | #endif | - |
| 3398 | geometry(); | - |
| 3399 | d->setNewGeometry(newPosition); | - |
| 3400 | QRect currentGeometry = | - |
| 3401 | #ifndef QT_NO_RUBBERBAND | - |
| 3402 | d->isInRubberBandMode ? d->rubberBand->geometry() : | - |
| 3403 | #endif | - |
| 3404 | geometry(); | - |
| 3405 | if (currentGeometry == oldGeometry) | - |
| 3406 | return; | - |
| 3407 | | - |
| 3408 | // Update cursor position | - |
| 3409 | | - |
| 3410 | QPoint actualDelta; | - |
| 3411 | if (d->isMoveOperation()) { | - |
| 3412 | actualDelta = QPoint(currentGeometry.x() - oldGeometry.x(), | - |
| 3413 | currentGeometry.y() - oldGeometry.y()); | - |
| 3414 | } else { | - |
| 3415 | int dx = isLeftToRight() ? currentGeometry.width() - oldGeometry.width() | - |
| 3416 | : currentGeometry.x() - oldGeometry.x(); | - |
| 3417 | actualDelta = QPoint(dx, currentGeometry.height() - oldGeometry.height()); | - |
| 3418 | } | - |
| 3419 | | - |
| 3420 | // Adjust in case we weren't able to move as long as wanted. | - |
| 3421 | if (actualDelta != delta) | - |
| 3422 | newPosition += (actualDelta - delta); | - |
| 3423 | cursor().setPos(parentWidget()->mapToGlobal(newPosition)); | - |
| 3424 | #endif | - |
| 3425 | } | - |
| 3426 | | - |
| 3427 | #ifndef QT_NO_CONTEXTMENU | - |
| 3428 | /*! | - |
| 3429 | \reimp | - |
| 3430 | */ | - |
| 3431 | void QMdiSubWindow::contextMenuEvent(QContextMenuEvent *contextMenuEvent) | - |
| 3432 | { | - |
| 3433 | Q_D(QMdiSubWindow); | - |
| 3434 | if (!d->systemMenu) { | - |
| 3435 | contextMenuEvent->ignore(); | - |
| 3436 | return; | - |
| 3437 | } | - |
| 3438 | | - |
| 3439 | if (d->hoveredSubControl == QStyle::SC_TitleBarSysMenu | - |
| 3440 | || d->getRegion(QMdiSubWindowPrivate::Move).contains(contextMenuEvent->pos())) { | - |
| 3441 | d->systemMenu->exec(contextMenuEvent->globalPos()); | - |
| 3442 | } else { | - |
| 3443 | contextMenuEvent->ignore(); | - |
| 3444 | } | - |
| 3445 | } | - |
| 3446 | #endif // QT_NO_CONTEXTMENU | - |
| 3447 | | - |
| 3448 | /*! | - |
| 3449 | \reimp | - |
| 3450 | */ | - |
| 3451 | void QMdiSubWindow::focusInEvent(QFocusEvent *focusInEvent) | - |
| 3452 | { | - |
| 3453 | d_func()->focusInReason = focusInEvent->reason(); | - |
| 3454 | } | - |
| 3455 | | - |
| 3456 | /*! | - |
| 3457 | \reimp | - |
| 3458 | */ | - |
| 3459 | void QMdiSubWindow::focusOutEvent(QFocusEvent * /*focusOutEvent*/) | - |
| 3460 | { | - |
| 3461 | // To avoid update() in QWidget::focusOutEvent. | - |
| 3462 | } | - |
| 3463 | | - |
| 3464 | /*! | - |
| 3465 | \reimp | - |
| 3466 | */ | - |
| 3467 | void QMdiSubWindow::childEvent(QChildEvent *childEvent) | - |
| 3468 | { | - |
| 3469 | if (childEvent->type() != QEvent::ChildPolished) | - |
| 3470 | return; | - |
| 3471 | #ifndef QT_NO_SIZEGRIP | - |
| 3472 | if (QSizeGrip *sizeGrip = qobject_cast<QSizeGrip *>(childEvent->child())) | - |
| 3473 | d_func()->setSizeGrip(sizeGrip); | - |
| 3474 | #endif | - |
| 3475 | } | - |
| 3476 | | - |
| 3477 | /*! | - |
| 3478 | \reimp | - |
| 3479 | */ | - |
| 3480 | QSize QMdiSubWindow::sizeHint() const | - |
| 3481 | { | - |
| 3482 | Q_D(const QMdiSubWindow); | - |
| 3483 | int margin, minWidth; | - |
| 3484 | d->sizeParameters(&margin, &minWidth); | - |
| 3485 | QSize size(2 * margin, d->titleBarHeight() + margin); | - |
| 3486 | if (d->baseWidget && d->baseWidget->sizeHint().isValid()) | - |
| 3487 | size += d->baseWidget->sizeHint(); | - |
| 3488 | return size.expandedTo(minimumSizeHint()); | - |
| 3489 | } | - |
| 3490 | | - |
| 3491 | /*! | - |
| 3492 | \reimp | - |
| 3493 | */ | - |
| 3494 | QSize QMdiSubWindow::minimumSizeHint() const | - |
| 3495 | { | - |
| 3496 | Q_D(const QMdiSubWindow); executed (the execution status of this line is deduced): const QMdiSubWindowPrivate * const d = d_func(); | - |
| 3497 | if (isVisible()) evaluated: isVisible()| yes Evaluation Count:276 | yes Evaluation Count:733 |
| 276-733 |
| 3498 | ensurePolished(); executed: ensurePolished();Execution Count:276 | 276 |
| 3499 | | - |
| 3500 | // Minimized window. | - |
| 3501 | if (parent() && isMinimized() && !isShaded()) evaluated: parent()| yes Evaluation Count:998 | yes Evaluation Count:11 |
evaluated: isMinimized()| yes Evaluation Count:34 | yes Evaluation Count:964 |
evaluated: !isShaded()| yes Evaluation Count:24 | yes Evaluation Count:10 |
| 10-998 |
| 3502 | return d->iconSize(); executed: return d->iconSize();Execution Count:24 | 24 |
| 3503 | | - |
| 3504 | // Calculate window decoration. | - |
| 3505 | int margin, minWidth; executed (the execution status of this line is deduced): int margin, minWidth; | - |
| 3506 | d->sizeParameters(&margin, &minWidth); executed (the execution status of this line is deduced): d->sizeParameters(&margin, &minWidth); | - |
| 3507 | int decorationHeight = margin + d->titleBarHeight(); executed (the execution status of this line is deduced): int decorationHeight = margin + d->titleBarHeight(); | - |
| 3508 | int minHeight = decorationHeight; executed (the execution status of this line is deduced): int minHeight = decorationHeight; | - |
| 3509 | | - |
| 3510 | // Shaded window. | - |
| 3511 | if (parent() && isShaded()) evaluated: parent()| yes Evaluation Count:974 | yes Evaluation Count:11 |
evaluated: isShaded()| yes Evaluation Count:10 | yes Evaluation Count:964 |
| 10-974 |
| 3512 | return QSize(qMax(minWidth, width()), d->titleBarHeight()); executed: return QSize(qMax(minWidth, width()), d->titleBarHeight());Execution Count:10 | 10 |
| 3513 | | - |
| 3514 | // Content | - |
| 3515 | if (layout()) { evaluated: layout()| yes Evaluation Count:891 | yes Evaluation Count:84 |
| 84-891 |
| 3516 | QSize minLayoutSize = layout()->minimumSize(); executed (the execution status of this line is deduced): QSize minLayoutSize = layout()->minimumSize(); | - |
| 3517 | if (minLayoutSize.isValid()) { partially evaluated: minLayoutSize.isValid()| yes Evaluation Count:891 | no Evaluation Count:0 |
| 0-891 |
| 3518 | minWidth = qMax(minWidth, minLayoutSize.width() + 2 * margin); executed (the execution status of this line is deduced): minWidth = qMax(minWidth, minLayoutSize.width() + 2 * margin); | - |
| 3519 | minHeight += minLayoutSize.height(); executed (the execution status of this line is deduced): minHeight += minLayoutSize.height(); | - |
| 3520 | } executed: }Execution Count:891 | 891 |
| 3521 | } else if (d->baseWidget && d->baseWidget->isVisible()) { executed: }Execution Count:891 evaluated: d->baseWidget| yes Evaluation Count:2 | yes Evaluation Count:82 |
evaluated: d->baseWidget->isVisible()| yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1-891 |
| 3522 | QSize minBaseWidgetSize = d->baseWidget->minimumSizeHint(); executed (the execution status of this line is deduced): QSize minBaseWidgetSize = d->baseWidget->minimumSizeHint(); | - |
| 3523 | if (minBaseWidgetSize.isValid()) { partially evaluated: minBaseWidgetSize.isValid()| no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
| 3524 | minWidth = qMax(minWidth, minBaseWidgetSize.width() + 2 * margin); never executed (the execution status of this line is deduced): minWidth = qMax(minWidth, minBaseWidgetSize.width() + 2 * margin); | - |
| 3525 | minHeight += minBaseWidgetSize.height(); never executed (the execution status of this line is deduced): minHeight += minBaseWidgetSize.height(); | - |
| 3526 | } | 0 |
| 3527 | } executed: }Execution Count:1 | 1 |
| 3528 | | - |
| 3529 | #ifndef QT_NO_SIZEGRIP | - |
| 3530 | // SizeGrip | - |
| 3531 | int sizeGripHeight = 0; executed (the execution status of this line is deduced): int sizeGripHeight = 0; | - |
| 3532 | if (d->sizeGrip && d->sizeGrip->isVisibleTo(const_cast<QMdiSubWindow *>(this))) partially evaluated: d->sizeGrip| no Evaluation Count:0 | yes Evaluation Count:975 |
never evaluated: d->sizeGrip->isVisibleTo(const_cast<QMdiSubWindow *>(this)) | 0-975 |
| 3533 | sizeGripHeight = d->sizeGrip->height(); never executed: sizeGripHeight = d->sizeGrip->height(); | 0 |
| 3534 | #if defined(Q_WS_MACQ_OS_MAC) && !defined(QT_NO_STYLE_MAC) | - |
| 3535 | else if (parent() && qobject_cast<QMacStyle *>(style()) && !d->sizeGrip) | - |
| 3536 | sizeGripHeight = style()->pixelMetric(QStyle::PM_SizeGripSize, 0, this); | - |
| 3537 | #endif | - |
| 3538 | minHeight = qMax(minHeight, decorationHeight + sizeGripHeight); executed (the execution status of this line is deduced): minHeight = qMax(minHeight, decorationHeight + sizeGripHeight); | - |
| 3539 | #endif | - |
| 3540 | | - |
| 3541 | return QSize(minWidth, minHeight).expandedTo(QApplication::globalStrut()); executed: return QSize(minWidth, minHeight).expandedTo(QApplication::globalStrut());Execution Count:975 | 975 |
| 3542 | } | - |
| 3543 | | - |
| 3544 | QT_END_NAMESPACE | - |
| 3545 | | - |
| 3546 | #include "moc_qmdisubwindow.cpp" | - |
| 3547 | #include "qmdisubwindow.moc" | - |
| 3548 | | - |
| 3549 | #endif //QT_NO_MDIAREA | - |
| 3550 | | - |
| | |