Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/widgets/widgets/qmdiarea.cpp |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | /**************************************************************************** | - | ||||||||||||||||||
2 | ** | - | ||||||||||||||||||
3 | ** Copyright (C) 2015 The Qt Company Ltd. | - | ||||||||||||||||||
4 | ** Contact: http://www.qt.io/licensing/ | - | ||||||||||||||||||
5 | ** | - | ||||||||||||||||||
6 | ** This file is part of the QtWidgets module of the Qt Toolkit. | - | ||||||||||||||||||
7 | ** | - | ||||||||||||||||||
8 | ** $QT_BEGIN_LICENSE:LGPL21$ | - | ||||||||||||||||||
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 The Qt Company. For licensing terms | - | ||||||||||||||||||
14 | ** and conditions see http://www.qt.io/terms-conditions. For further | - | ||||||||||||||||||
15 | ** information use the contact form at http://www.qt.io/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 or version 3 as published by the Free | - | ||||||||||||||||||
20 | ** Software Foundation and appearing in the file LICENSE.LGPLv21 and | - | ||||||||||||||||||
21 | ** LICENSE.LGPLv3 included in the packaging of this file. Please review the | - | ||||||||||||||||||
22 | ** following information to ensure the GNU Lesser General Public License | - | ||||||||||||||||||
23 | ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and | - | ||||||||||||||||||
24 | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - | ||||||||||||||||||
25 | ** | - | ||||||||||||||||||
26 | ** As a special exception, The Qt Company gives you certain additional | - | ||||||||||||||||||
27 | ** rights. These rights are described in The Qt Company LGPL Exception | - | ||||||||||||||||||
28 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - | ||||||||||||||||||
29 | ** | - | ||||||||||||||||||
30 | ** $QT_END_LICENSE$ | - | ||||||||||||||||||
31 | ** | - | ||||||||||||||||||
32 | ****************************************************************************/ | - | ||||||||||||||||||
33 | - | |||||||||||||||||||
34 | /*! | - | ||||||||||||||||||
35 | \class QMdiArea | - | ||||||||||||||||||
36 | \brief The QMdiArea widget provides an area in which MDI windows are displayed. | - | ||||||||||||||||||
37 | \since 4.3 | - | ||||||||||||||||||
38 | \ingroup mainwindow-classes | - | ||||||||||||||||||
39 | \inmodule QtWidgets | - | ||||||||||||||||||
40 | - | |||||||||||||||||||
41 | QMdiArea functions, essentially, like a window manager for MDI | - | ||||||||||||||||||
42 | windows. For instance, it draws the windows it manages on itself | - | ||||||||||||||||||
43 | and arranges them in a cascading or tile pattern. QMdiArea is | - | ||||||||||||||||||
44 | commonly used as the center widget in a QMainWindow to create MDI | - | ||||||||||||||||||
45 | applications, but can also be placed in any layout. The following | - | ||||||||||||||||||
46 | code adds an area to a main window: | - | ||||||||||||||||||
47 | - | |||||||||||||||||||
48 | \snippet mdiareasnippets.cpp 0 | - | ||||||||||||||||||
49 | - | |||||||||||||||||||
50 | Unlike the window managers for top-level windows, all window flags | - | ||||||||||||||||||
51 | (Qt::WindowFlags) are supported by QMdiArea as long as the flags | - | ||||||||||||||||||
52 | are supported by the current widget style. If a specific flag is | - | ||||||||||||||||||
53 | not supported by the style (e.g., the | - | ||||||||||||||||||
54 | \l{Qt::}{WindowShadeButtonHint}), you can still shade the window | - | ||||||||||||||||||
55 | with showShaded(). | - | ||||||||||||||||||
56 | - | |||||||||||||||||||
57 | Subwindows in QMdiArea are instances of QMdiSubWindow. They | - | ||||||||||||||||||
58 | are added to an MDI area with addSubWindow(). It is common to pass | - | ||||||||||||||||||
59 | a QWidget, which is set as the internal widget, to this function, | - | ||||||||||||||||||
60 | but it is also possible to pass a QMdiSubWindow directly.The class | - | ||||||||||||||||||
61 | inherits QWidget, and you can use the same API as with a normal | - | ||||||||||||||||||
62 | top-level window when programming. QMdiSubWindow also has behavior | - | ||||||||||||||||||
63 | that is specific to MDI windows. See the QMdiSubWindow class | - | ||||||||||||||||||
64 | description for more details. | - | ||||||||||||||||||
65 | - | |||||||||||||||||||
66 | A subwindow becomes active when it gets the keyboard focus, or | - | ||||||||||||||||||
67 | when setFocus() is called. The user activates a window by moving | - | ||||||||||||||||||
68 | focus in the usual ways. The MDI area emits the | - | ||||||||||||||||||
69 | subWindowActivated() signal when the active window changes, and | - | ||||||||||||||||||
70 | the activeSubWindow() function returns the active subwindow. | - | ||||||||||||||||||
71 | - | |||||||||||||||||||
72 | The convenience function subWindowList() returns a list of all | - | ||||||||||||||||||
73 | subwindows. This information could be used in a popup menu | - | ||||||||||||||||||
74 | containing a list of windows, for example. | - | ||||||||||||||||||
75 | - | |||||||||||||||||||
76 | The subwindows are sorted by the current | - | ||||||||||||||||||
77 | \l{QMdiArea::}{WindowOrder}. This is used for the subWindowList() | - | ||||||||||||||||||
78 | and for activateNextSubWindow() and activatePreviousSubWindow(). | - | ||||||||||||||||||
79 | Also, it is used when cascading or tiling the windows with | - | ||||||||||||||||||
80 | cascadeSubWindows() and tileSubWindows(). | - | ||||||||||||||||||
81 | - | |||||||||||||||||||
82 | QMdiArea provides two built-in layout strategies for | - | ||||||||||||||||||
83 | subwindows: cascadeSubWindows() and tileSubWindows(). Both are | - | ||||||||||||||||||
84 | slots and are easily connected to menu entries. | - | ||||||||||||||||||
85 | - | |||||||||||||||||||
86 | \table | - | ||||||||||||||||||
87 | \row \li \inlineimage mdi-cascade.png | - | ||||||||||||||||||
88 | \li \inlineimage mdi-tile.png | - | ||||||||||||||||||
89 | \endtable | - | ||||||||||||||||||
90 | - | |||||||||||||||||||
91 | \note The default scroll bar property for QMdiArea is Qt::ScrollBarAlwaysOff. | - | ||||||||||||||||||
92 | - | |||||||||||||||||||
93 | \sa QMdiSubWindow | - | ||||||||||||||||||
94 | */ | - | ||||||||||||||||||
95 | - | |||||||||||||||||||
96 | /*! | - | ||||||||||||||||||
97 | \fn QMdiArea::subWindowActivated(QMdiSubWindow *window) | - | ||||||||||||||||||
98 | - | |||||||||||||||||||
99 | QMdiArea emits this signal after \a window has been activated. When \a | - | ||||||||||||||||||
100 | window is 0, QMdiArea has just deactivated its last active window, and | - | ||||||||||||||||||
101 | there are no active windows on the workspace. | - | ||||||||||||||||||
102 | - | |||||||||||||||||||
103 | \sa QMdiArea::activeSubWindow() | - | ||||||||||||||||||
104 | */ | - | ||||||||||||||||||
105 | - | |||||||||||||||||||
106 | /*! | - | ||||||||||||||||||
107 | \enum QMdiArea::AreaOption | - | ||||||||||||||||||
108 | - | |||||||||||||||||||
109 | This enum describes options that customize the behavior of the | - | ||||||||||||||||||
110 | QMdiArea. | - | ||||||||||||||||||
111 | - | |||||||||||||||||||
112 | \value DontMaximizeSubWindowOnActivation When the active subwindow | - | ||||||||||||||||||
113 | is maximized, the default behavior is to maximize the next | - | ||||||||||||||||||
114 | subwindow that is activated. Set this option if you do not want | - | ||||||||||||||||||
115 | this behavior. | - | ||||||||||||||||||
116 | */ | - | ||||||||||||||||||
117 | - | |||||||||||||||||||
118 | /*! | - | ||||||||||||||||||
119 | \enum QMdiArea::WindowOrder | - | ||||||||||||||||||
120 | - | |||||||||||||||||||
121 | Specifies the criteria to use for ordering the list of child windows | - | ||||||||||||||||||
122 | returned by subWindowList(). The functions cascadeSubWindows() and | - | ||||||||||||||||||
123 | tileSubWindows() follow this order when arranging the windows. | - | ||||||||||||||||||
124 | - | |||||||||||||||||||
125 | \value CreationOrder The windows are returned in the order of | - | ||||||||||||||||||
126 | their creation. | - | ||||||||||||||||||
127 | - | |||||||||||||||||||
128 | \value StackingOrder The windows are returned in the order in | - | ||||||||||||||||||
129 | which they are stacked, with the top-most window being last in | - | ||||||||||||||||||
130 | the list. | - | ||||||||||||||||||
131 | - | |||||||||||||||||||
132 | \value ActivationHistoryOrder The windows are returned in the order in | - | ||||||||||||||||||
133 | which they were activated. | - | ||||||||||||||||||
134 | - | |||||||||||||||||||
135 | \sa subWindowList() | - | ||||||||||||||||||
136 | */ | - | ||||||||||||||||||
137 | - | |||||||||||||||||||
138 | /*! | - | ||||||||||||||||||
139 | \enum QMdiArea::ViewMode | - | ||||||||||||||||||
140 | \since 4.4 | - | ||||||||||||||||||
141 | - | |||||||||||||||||||
142 | This enum describes the view mode of the area; i.e. how sub-windows | - | ||||||||||||||||||
143 | will be displayed. | - | ||||||||||||||||||
144 | - | |||||||||||||||||||
145 | \value SubWindowView Display sub-windows with window frames (default). | - | ||||||||||||||||||
146 | \value TabbedView Display sub-windows with tabs in a tab bar. | - | ||||||||||||||||||
147 | - | |||||||||||||||||||
148 | \sa setViewMode() | - | ||||||||||||||||||
149 | */ | - | ||||||||||||||||||
150 | - | |||||||||||||||||||
151 | #include "qmdiarea_p.h" | - | ||||||||||||||||||
152 | - | |||||||||||||||||||
153 | #ifndef QT_NO_MDIAREA | - | ||||||||||||||||||
154 | - | |||||||||||||||||||
155 | #include <QApplication> | - | ||||||||||||||||||
156 | #include <QStyle> | - | ||||||||||||||||||
157 | #if defined(Q_DEAD_CODE_FROM_QT4_MAC) && !defined(QT_NO_STYLE_MAC) | - | ||||||||||||||||||
158 | #include <private/qmacstyle_mac_p.h> | - | ||||||||||||||||||
159 | #endif | - | ||||||||||||||||||
160 | #include <QChildEvent> | - | ||||||||||||||||||
161 | #include <QResizeEvent> | - | ||||||||||||||||||
162 | #include <QScrollBar> | - | ||||||||||||||||||
163 | #include <QtAlgorithms> | - | ||||||||||||||||||
164 | #include <QMutableVectorIterator> | - | ||||||||||||||||||
165 | #include <QPainter> | - | ||||||||||||||||||
166 | #include <QFontMetrics> | - | ||||||||||||||||||
167 | #include <QStyleOption> | - | ||||||||||||||||||
168 | #include <QDesktopWidget> | - | ||||||||||||||||||
169 | #include <QDebug> | - | ||||||||||||||||||
170 | #include <qmath.h> | - | ||||||||||||||||||
171 | #include <private/qlayoutengine_p.h> | - | ||||||||||||||||||
172 | - | |||||||||||||||||||
173 | #include <algorithm> | - | ||||||||||||||||||
174 | - | |||||||||||||||||||
175 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||
176 | - | |||||||||||||||||||
177 | using namespace QMdi; | - | ||||||||||||||||||
178 | - | |||||||||||||||||||
179 | // Asserts in debug mode, gives warning otherwise. | - | ||||||||||||||||||
180 | static bool sanityCheck(const QMdiSubWindow * const child, const char *where) | - | ||||||||||||||||||
181 | { | - | ||||||||||||||||||
182 | if (!child) {
| 0 | ||||||||||||||||||
183 | const char error[] = "null pointer"; | - | ||||||||||||||||||
184 | Q_ASSERT_X(false, where, error); | - | ||||||||||||||||||
185 | qWarning("%s:%s", where, error); | - | ||||||||||||||||||
186 | return false; never executed: return false; | 0 | ||||||||||||||||||
187 | } | - | ||||||||||||||||||
188 | return true; never executed: return true; | 0 | ||||||||||||||||||
189 | } | - | ||||||||||||||||||
190 | - | |||||||||||||||||||
191 | static bool sanityCheck(const QList<QWidget *> &widgets, const int index, const char *where) | - | ||||||||||||||||||
192 | { | - | ||||||||||||||||||
193 | if (index < 0 || index >= widgets.size()) {
| 0 | ||||||||||||||||||
194 | const char error[] = "index out of range"; | - | ||||||||||||||||||
195 | Q_ASSERT_X(false, where, error); | - | ||||||||||||||||||
196 | qWarning("%s:%s", where, error); | - | ||||||||||||||||||
197 | return false; never executed: return false; | 0 | ||||||||||||||||||
198 | } | - | ||||||||||||||||||
199 | if (!widgets.at(index)) {
| 0 | ||||||||||||||||||
200 | const char error[] = "null pointer"; | - | ||||||||||||||||||
201 | Q_ASSERT_X(false, where, error); | - | ||||||||||||||||||
202 | qWarning("%s:%s", where, error); | - | ||||||||||||||||||
203 | return false; never executed: return false; | 0 | ||||||||||||||||||
204 | } | - | ||||||||||||||||||
205 | return true; never executed: return true; | 0 | ||||||||||||||||||
206 | } | - | ||||||||||||||||||
207 | - | |||||||||||||||||||
208 | static void setIndex(int *index, int candidate, int min, int max, bool isIncreasing) | - | ||||||||||||||||||
209 | { | - | ||||||||||||||||||
210 | if (!index)
| 0 | ||||||||||||||||||
211 | return; never executed: return; | 0 | ||||||||||||||||||
212 | - | |||||||||||||||||||
213 | if (isIncreasing) {
| 0 | ||||||||||||||||||
214 | if (candidate > max)
| 0 | ||||||||||||||||||
215 | *index = min; never executed: *index = min; | 0 | ||||||||||||||||||
216 | else | - | ||||||||||||||||||
217 | *index = qMax(candidate, min); never executed: *index = qMax(candidate, min); | 0 | ||||||||||||||||||
218 | } else { | - | ||||||||||||||||||
219 | if (candidate < min)
| 0 | ||||||||||||||||||
220 | *index = max; never executed: *index = max; | 0 | ||||||||||||||||||
221 | else | - | ||||||||||||||||||
222 | *index = qMin(candidate, max); never executed: *index = qMin(candidate, max); | 0 | ||||||||||||||||||
223 | } | - | ||||||||||||||||||
224 | Q_ASSERT(*index >= min && *index <= max); | - | ||||||||||||||||||
225 | } never executed: end of block | 0 | ||||||||||||||||||
226 | - | |||||||||||||||||||
227 | static inline bool useScrollBar(const QRect &childrenRect, const QSize &maxViewportSize, | - | ||||||||||||||||||
228 | Qt::Orientation orientation) | - | ||||||||||||||||||
229 | { | - | ||||||||||||||||||
230 | if (orientation == Qt::Horizontal)
| 0 | ||||||||||||||||||
231 | return childrenRect.width() > maxViewportSize.width() never executed: return childrenRect.width() > maxViewportSize.width() || childrenRect.left() < 0 || childrenRect.right() >= maxViewportSize.width();
| 0 | ||||||||||||||||||
232 | || childrenRect.left() < 0 never executed: return childrenRect.width() > maxViewportSize.width() || childrenRect.left() < 0 || childrenRect.right() >= maxViewportSize.width();
| 0 | ||||||||||||||||||
233 | || childrenRect.right() >= maxViewportSize.width(); never executed: return childrenRect.width() > maxViewportSize.width() || childrenRect.left() < 0 || childrenRect.right() >= maxViewportSize.width();
| 0 | ||||||||||||||||||
234 | else | - | ||||||||||||||||||
235 | return childrenRect.height() > maxViewportSize.height() never executed: return childrenRect.height() > maxViewportSize.height() || childrenRect.top() < 0 || childrenRect.bottom() >= maxViewportSize.height();
| 0 | ||||||||||||||||||
236 | || childrenRect.top() < 0 never executed: return childrenRect.height() > maxViewportSize.height() || childrenRect.top() < 0 || childrenRect.bottom() >= maxViewportSize.height();
| 0 | ||||||||||||||||||
237 | || childrenRect.bottom() >= maxViewportSize.height(); never executed: return childrenRect.height() > maxViewportSize.height() || childrenRect.top() < 0 || childrenRect.bottom() >= maxViewportSize.height();
| 0 | ||||||||||||||||||
238 | } | - | ||||||||||||||||||
239 | - | |||||||||||||||||||
240 | // Returns the closest mdi area containing the widget (if any). | - | ||||||||||||||||||
241 | static inline QMdiArea *mdiAreaParent(QWidget *widget) | - | ||||||||||||||||||
242 | { | - | ||||||||||||||||||
243 | if (!widget)
| 0 | ||||||||||||||||||
244 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
245 | - | |||||||||||||||||||
246 | QWidget *parent = widget->parentWidget(); | - | ||||||||||||||||||
247 | while (parent) {
| 0 | ||||||||||||||||||
248 | if (QMdiArea *area = qobject_cast<QMdiArea *>(parent))
| 0 | ||||||||||||||||||
249 | return area; never executed: return area; | 0 | ||||||||||||||||||
250 | parent = parent->parentWidget(); | - | ||||||||||||||||||
251 | } never executed: end of block | 0 | ||||||||||||||||||
252 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
253 | } | - | ||||||||||||||||||
254 | - | |||||||||||||||||||
255 | #ifndef QT_NO_TABWIDGET | - | ||||||||||||||||||
256 | static inline QTabBar::Shape tabBarShapeFrom(QTabWidget::TabShape shape, QTabWidget::TabPosition position) | - | ||||||||||||||||||
257 | { | - | ||||||||||||||||||
258 | const bool rounded = (shape == QTabWidget::Rounded); | - | ||||||||||||||||||
259 | if (position == QTabWidget::North)
| 0 | ||||||||||||||||||
260 | return rounded ? QTabBar::RoundedNorth : QTabBar::TriangularNorth; never executed: return rounded ? QTabBar::RoundedNorth : QTabBar::TriangularNorth;
| 0 | ||||||||||||||||||
261 | if (position == QTabWidget::South)
| 0 | ||||||||||||||||||
262 | return rounded ? QTabBar::RoundedSouth : QTabBar::TriangularSouth; never executed: return rounded ? QTabBar::RoundedSouth : QTabBar::TriangularSouth;
| 0 | ||||||||||||||||||
263 | if (position == QTabWidget::East)
| 0 | ||||||||||||||||||
264 | return rounded ? QTabBar::RoundedEast : QTabBar::TriangularEast; never executed: return rounded ? QTabBar::RoundedEast : QTabBar::TriangularEast;
| 0 | ||||||||||||||||||
265 | if (position == QTabWidget::West)
| 0 | ||||||||||||||||||
266 | return rounded ? QTabBar::RoundedWest : QTabBar::TriangularWest; never executed: return rounded ? QTabBar::RoundedWest : QTabBar::TriangularWest;
| 0 | ||||||||||||||||||
267 | return QTabBar::RoundedNorth; never executed: return QTabBar::RoundedNorth; | 0 | ||||||||||||||||||
268 | } | - | ||||||||||||||||||
269 | #endif // QT_NO_TABWIDGET | - | ||||||||||||||||||
270 | - | |||||||||||||||||||
271 | static inline QString tabTextFor(QMdiSubWindow *subWindow) | - | ||||||||||||||||||
272 | { | - | ||||||||||||||||||
273 | if (!subWindow)
| 0 | ||||||||||||||||||
274 | return QString(); never executed: return QString(); | 0 | ||||||||||||||||||
275 | - | |||||||||||||||||||
276 | QString title = subWindow->windowTitle(); | - | ||||||||||||||||||
277 | if (subWindow->isWindowModified()) {
| 0 | ||||||||||||||||||
278 | title.replace(QLatin1String("[*]"), QLatin1String("*")); | - | ||||||||||||||||||
279 | } else { never executed: end of block | 0 | ||||||||||||||||||
280 | extern QString qt_setWindowTitle_helperHelper(const QString&, const QWidget*); | - | ||||||||||||||||||
281 | title = qt_setWindowTitle_helperHelper(title, subWindow); | - | ||||||||||||||||||
282 | } never executed: end of block | 0 | ||||||||||||||||||
283 | - | |||||||||||||||||||
284 | return title.isEmpty() ? QMdiArea::tr("(Untitled)") : title; never executed: return title.isEmpty() ? QMdiArea::tr("(Untitled)") : title;
| 0 | ||||||||||||||||||
285 | } | - | ||||||||||||||||||
286 | - | |||||||||||||||||||
287 | /*! | - | ||||||||||||||||||
288 | \internal | - | ||||||||||||||||||
289 | */ | - | ||||||||||||||||||
290 | void RegularTiler::rearrange(QList<QWidget *> &widgets, const QRect &domain) const | - | ||||||||||||||||||
291 | { | - | ||||||||||||||||||
292 | if (widgets.isEmpty())
| 0 | ||||||||||||||||||
293 | return; never executed: return; | 0 | ||||||||||||||||||
294 | - | |||||||||||||||||||
295 | const int n = widgets.size(); | - | ||||||||||||||||||
296 | const int ncols = qMax(qCeil(qSqrt(qreal(n))), 1); | - | ||||||||||||||||||
297 | const int nrows = qMax((n % ncols) ? (n / ncols + 1) : (n / ncols), 1); | - | ||||||||||||||||||
298 | const int nspecial = (n % ncols) ? (ncols - n % ncols) : 0;
| 0 | ||||||||||||||||||
299 | const int dx = domain.width() / ncols; | - | ||||||||||||||||||
300 | const int dy = domain.height() / nrows; | - | ||||||||||||||||||
301 | - | |||||||||||||||||||
302 | int i = 0; | - | ||||||||||||||||||
303 | for (int row = 0; row < nrows; ++row) {
| 0 | ||||||||||||||||||
304 | const int y1 = int(row * (dy + 1)); | - | ||||||||||||||||||
305 | for (int col = 0; col < ncols; ++col) {
| 0 | ||||||||||||||||||
306 | if (row == 1 && col < nspecial)
| 0 | ||||||||||||||||||
307 | continue; never executed: continue; | 0 | ||||||||||||||||||
308 | const int x1 = int(col * (dx + 1)); | - | ||||||||||||||||||
309 | int x2 = int(x1 + dx); | - | ||||||||||||||||||
310 | int y2 = int(y1 + dy); | - | ||||||||||||||||||
311 | if (row == 0 && col < nspecial) {
| 0 | ||||||||||||||||||
312 | y2 *= 2; | - | ||||||||||||||||||
313 | if (nrows != 2)
| 0 | ||||||||||||||||||
314 | y2 += 1; never executed: y2 += 1; | 0 | ||||||||||||||||||
315 | else | - | ||||||||||||||||||
316 | y2 = domain.bottom(); never executed: y2 = domain.bottom(); | 0 | ||||||||||||||||||
317 | } | - | ||||||||||||||||||
318 | if (col == ncols - 1 && x2 != domain.right())
| 0 | ||||||||||||||||||
319 | x2 = domain.right(); never executed: x2 = domain.right(); | 0 | ||||||||||||||||||
320 | if (row == nrows - 1 && y2 != domain.bottom())
| 0 | ||||||||||||||||||
321 | y2 = domain.bottom(); never executed: y2 = domain.bottom(); | 0 | ||||||||||||||||||
322 | if (!sanityCheck(widgets, i, "RegularTiler"))
| 0 | ||||||||||||||||||
323 | continue; never executed: continue; | 0 | ||||||||||||||||||
324 | QWidget *widget = widgets.at(i++); | - | ||||||||||||||||||
325 | QRect newGeometry = QRect(QPoint(x1, y1), QPoint(x2, y2)); | - | ||||||||||||||||||
326 | widget->setGeometry(QStyle::visualRect(widget->layoutDirection(), domain, newGeometry)); | - | ||||||||||||||||||
327 | } never executed: end of block | 0 | ||||||||||||||||||
328 | } never executed: end of block | 0 | ||||||||||||||||||
329 | } never executed: end of block | 0 | ||||||||||||||||||
330 | - | |||||||||||||||||||
331 | /*! | - | ||||||||||||||||||
332 | \internal | - | ||||||||||||||||||
333 | */ | - | ||||||||||||||||||
334 | void SimpleCascader::rearrange(QList<QWidget *> &widgets, const QRect &domain) const | - | ||||||||||||||||||
335 | { | - | ||||||||||||||||||
336 | if (widgets.isEmpty())
| 0 | ||||||||||||||||||
337 | return; never executed: return; | 0 | ||||||||||||||||||
338 | - | |||||||||||||||||||
339 | // Tunables: | - | ||||||||||||||||||
340 | const int topOffset = 0; | - | ||||||||||||||||||
341 | const int bottomOffset = 50; | - | ||||||||||||||||||
342 | const int leftOffset = 0; | - | ||||||||||||||||||
343 | const int rightOffset = 100; | - | ||||||||||||||||||
344 | const int dx = 10; | - | ||||||||||||||||||
345 | - | |||||||||||||||||||
346 | QStyleOptionTitleBar options; | - | ||||||||||||||||||
347 | options.initFrom(widgets.at(0)); | - | ||||||||||||||||||
348 | int titleBarHeight = widgets.at(0)->style()->pixelMetric(QStyle::PM_TitleBarHeight, &options, widgets.at(0)); | - | ||||||||||||||||||
349 | const QFontMetrics fontMetrics = QFontMetrics(QApplication::font("QMdiSubWindowTitleBar")); | - | ||||||||||||||||||
350 | const int dy = qMax(titleBarHeight - (titleBarHeight - fontMetrics.height()) / 2, 1) | - | ||||||||||||||||||
351 | + widgets.at(0)->style()->pixelMetric(QStyle::PM_FocusFrameVMargin, 0, widgets.at(0)); | - | ||||||||||||||||||
352 | - | |||||||||||||||||||
353 | const int n = widgets.size(); | - | ||||||||||||||||||
354 | const int nrows = qMax((domain.height() - (topOffset + bottomOffset)) / dy, 1); | - | ||||||||||||||||||
355 | const int ncols = qMax(n / nrows + ((n % nrows) ? 1 : 0), 1); | - | ||||||||||||||||||
356 | const int dcol = (domain.width() - (leftOffset + rightOffset)) / ncols; | - | ||||||||||||||||||
357 | - | |||||||||||||||||||
358 | int i = 0; | - | ||||||||||||||||||
359 | for (int row = 0; row < nrows; ++row) {
| 0 | ||||||||||||||||||
360 | for (int col = 0; col < ncols; ++col) {
| 0 | ||||||||||||||||||
361 | const int x = leftOffset + row * dx + col * dcol; | - | ||||||||||||||||||
362 | const int y = topOffset + row * dy; | - | ||||||||||||||||||
363 | if (!sanityCheck(widgets, i, "SimpleCascader"))
| 0 | ||||||||||||||||||
364 | continue; never executed: continue; | 0 | ||||||||||||||||||
365 | QWidget *widget = widgets.at(i++); | - | ||||||||||||||||||
366 | QRect newGeometry = QRect(QPoint(x, y), widget->sizeHint()); | - | ||||||||||||||||||
367 | widget->setGeometry(QStyle::visualRect(widget->layoutDirection(), domain, newGeometry)); | - | ||||||||||||||||||
368 | if (i == n)
| 0 | ||||||||||||||||||
369 | return; never executed: return; | 0 | ||||||||||||||||||
370 | } never executed: end of block | 0 | ||||||||||||||||||
371 | } never executed: end of block | 0 | ||||||||||||||||||
372 | } never executed: end of block | 0 | ||||||||||||||||||
373 | - | |||||||||||||||||||
374 | /*! | - | ||||||||||||||||||
375 | \internal | - | ||||||||||||||||||
376 | */ | - | ||||||||||||||||||
377 | void IconTiler::rearrange(QList<QWidget *> &widgets, const QRect &domain) const | - | ||||||||||||||||||
378 | { | - | ||||||||||||||||||
379 | if (widgets.isEmpty() || !sanityCheck(widgets, 0, "IconTiler"))
| 0 | ||||||||||||||||||
380 | return; never executed: return; | 0 | ||||||||||||||||||
381 | - | |||||||||||||||||||
382 | const int n = widgets.size(); | - | ||||||||||||||||||
383 | const int width = widgets.at(0)->width(); | - | ||||||||||||||||||
384 | const int height = widgets.at(0)->height(); | - | ||||||||||||||||||
385 | const int ncols = qMax(domain.width() / width, 1); | - | ||||||||||||||||||
386 | const int nrows = n / ncols + ((n % ncols) ? 1 : 0);
| 0 | ||||||||||||||||||
387 | - | |||||||||||||||||||
388 | int i = 0; | - | ||||||||||||||||||
389 | for (int row = 0; row < nrows; ++row) {
| 0 | ||||||||||||||||||
390 | for (int col = 0; col < ncols; ++col) {
| 0 | ||||||||||||||||||
391 | const int x = col * width; | - | ||||||||||||||||||
392 | const int y = domain.height() - height - row * height; | - | ||||||||||||||||||
393 | if (!sanityCheck(widgets, i, "IconTiler"))
| 0 | ||||||||||||||||||
394 | continue; never executed: continue; | 0 | ||||||||||||||||||
395 | QWidget *widget = widgets.at(i++); | - | ||||||||||||||||||
396 | QPoint newPos(x, y); | - | ||||||||||||||||||
397 | QRect newGeometry = QRect(newPos.x(), newPos.y(), widget->width(), widget->height()); | - | ||||||||||||||||||
398 | widget->setGeometry(QStyle::visualRect(widget->layoutDirection(), domain, newGeometry)); | - | ||||||||||||||||||
399 | if (i == n)
| 0 | ||||||||||||||||||
400 | return; never executed: return; | 0 | ||||||||||||||||||
401 | } never executed: end of block | 0 | ||||||||||||||||||
402 | } never executed: end of block | 0 | ||||||||||||||||||
403 | } never executed: end of block | 0 | ||||||||||||||||||
404 | - | |||||||||||||||||||
405 | /*! | - | ||||||||||||||||||
406 | \internal | - | ||||||||||||||||||
407 | Calculates the accumulated overlap (intersection area) between 'source' and 'rects'. | - | ||||||||||||||||||
408 | */ | - | ||||||||||||||||||
409 | int MinOverlapPlacer::accumulatedOverlap(const QRect &source, const QVector<QRect> &rects) | - | ||||||||||||||||||
410 | { | - | ||||||||||||||||||
411 | int accOverlap = 0; | - | ||||||||||||||||||
412 | foreach (const QRect &rect, rects) { | - | ||||||||||||||||||
413 | QRect intersection = source.intersected(rect); | - | ||||||||||||||||||
414 | accOverlap += intersection.width() * intersection.height(); | - | ||||||||||||||||||
415 | } never executed: end of block | 0 | ||||||||||||||||||
416 | return accOverlap; never executed: return accOverlap; | 0 | ||||||||||||||||||
417 | } | - | ||||||||||||||||||
418 | - | |||||||||||||||||||
419 | - | |||||||||||||||||||
420 | /*! | - | ||||||||||||||||||
421 | \internal | - | ||||||||||||||||||
422 | Finds among 'source' the rectangle with the minimum accumulated overlap with the | - | ||||||||||||||||||
423 | rectangles in 'rects'. | - | ||||||||||||||||||
424 | */ | - | ||||||||||||||||||
425 | QRect MinOverlapPlacer::findMinOverlapRect(const QVector<QRect> &source, const QVector<QRect> &rects) | - | ||||||||||||||||||
426 | { | - | ||||||||||||||||||
427 | int minAccOverlap = -1; | - | ||||||||||||||||||
428 | QRect minAccOverlapRect; | - | ||||||||||||||||||
429 | foreach (const QRect &srcRect, source) { | - | ||||||||||||||||||
430 | const int accOverlap = accumulatedOverlap(srcRect, rects); | - | ||||||||||||||||||
431 | if (accOverlap < minAccOverlap || minAccOverlap == -1) {
| 0 | ||||||||||||||||||
432 | minAccOverlap = accOverlap; | - | ||||||||||||||||||
433 | minAccOverlapRect = srcRect; | - | ||||||||||||||||||
434 | } never executed: end of block | 0 | ||||||||||||||||||
435 | } never executed: end of block | 0 | ||||||||||||||||||
436 | return minAccOverlapRect; never executed: return minAccOverlapRect; | 0 | ||||||||||||||||||
437 | } | - | ||||||||||||||||||
438 | - | |||||||||||||||||||
439 | /*! | - | ||||||||||||||||||
440 | \internal | - | ||||||||||||||||||
441 | Gets candidates for the final placement. | - | ||||||||||||||||||
442 | */ | - | ||||||||||||||||||
443 | QVector<QRect> MinOverlapPlacer::getCandidatePlacements(const QSize &size, const QVector<QRect> &rects, | - | ||||||||||||||||||
444 | const QRect &domain) | - | ||||||||||||||||||
445 | { | - | ||||||||||||||||||
446 | QVector<QRect> result; | - | ||||||||||||||||||
447 | - | |||||||||||||||||||
448 | QVector<int> xlist; | - | ||||||||||||||||||
449 | xlist.reserve(2 + rects.size()); | - | ||||||||||||||||||
450 | xlist << domain.left() << domain.right() - size.width() + 1; | - | ||||||||||||||||||
451 | - | |||||||||||||||||||
452 | QVector<int> ylist; | - | ||||||||||||||||||
453 | ylist.reserve(2 + rects.size()); | - | ||||||||||||||||||
454 | ylist << domain.top(); | - | ||||||||||||||||||
455 | if (domain.bottom() - size.height() + 1 >= 0)
| 0 | ||||||||||||||||||
456 | ylist << domain.bottom() - size.height() + 1; never executed: ylist << domain.bottom() - size.height() + 1; | 0 | ||||||||||||||||||
457 | - | |||||||||||||||||||
458 | foreach (const QRect &rect, rects) { | - | ||||||||||||||||||
459 | xlist << rect.right() + 1; | - | ||||||||||||||||||
460 | ylist << rect.bottom() + 1; | - | ||||||||||||||||||
461 | } never executed: end of block | 0 | ||||||||||||||||||
462 | - | |||||||||||||||||||
463 | std::sort(xlist.begin(), xlist.end()); | - | ||||||||||||||||||
464 | xlist.erase(std::unique(xlist.begin(), xlist.end()), xlist.end()); | - | ||||||||||||||||||
465 | - | |||||||||||||||||||
466 | std::sort(ylist.begin(), ylist.end()); | - | ||||||||||||||||||
467 | ylist.erase(std::unique(ylist.begin(), ylist.end()), ylist.end()); | - | ||||||||||||||||||
468 | - | |||||||||||||||||||
469 | result.reserve(ylist.size() * xlist.size()); | - | ||||||||||||||||||
470 | foreach (int y, ylist) | - | ||||||||||||||||||
471 | foreach (int x, xlist) | - | ||||||||||||||||||
472 | result << QRect(QPoint(x, y), size); never executed: result << QRect(QPoint(x, y), size); | 0 | ||||||||||||||||||
473 | return result; never executed: return result; | 0 | ||||||||||||||||||
474 | } | - | ||||||||||||||||||
475 | - | |||||||||||||||||||
476 | /*! | - | ||||||||||||||||||
477 | \internal | - | ||||||||||||||||||
478 | Finds all rectangles in 'source' not completely inside 'domain'. The result is stored | - | ||||||||||||||||||
479 | in 'result' and also removed from 'source'. | - | ||||||||||||||||||
480 | */ | - | ||||||||||||||||||
481 | QVector<QRect> MinOverlapPlacer::findNonInsiders(const QRect &domain, QVector<QRect> &source) | - | ||||||||||||||||||
482 | { | - | ||||||||||||||||||
483 | QVector<QRect> result; | - | ||||||||||||||||||
484 | result.reserve(source.size()); | - | ||||||||||||||||||
485 | - | |||||||||||||||||||
486 | QMutableVectorIterator<QRect> it(source); | - | ||||||||||||||||||
487 | while (it.hasNext()) {
| 0 | ||||||||||||||||||
488 | const QRect srcRect = it.next(); | - | ||||||||||||||||||
489 | if (!domain.contains(srcRect)) {
| 0 | ||||||||||||||||||
490 | result << srcRect; | - | ||||||||||||||||||
491 | it.remove(); | - | ||||||||||||||||||
492 | } never executed: end of block | 0 | ||||||||||||||||||
493 | } never executed: end of block | 0 | ||||||||||||||||||
494 | - | |||||||||||||||||||
495 | return result; never executed: return result; | 0 | ||||||||||||||||||
496 | } | - | ||||||||||||||||||
497 | - | |||||||||||||||||||
498 | /*! | - | ||||||||||||||||||
499 | \internal | - | ||||||||||||||||||
500 | Finds all rectangles in 'source' that overlaps 'domain' by the maximum overlap area | - | ||||||||||||||||||
501 | between 'domain' and any rectangle in 'source'. The result is stored in 'result'. | - | ||||||||||||||||||
502 | */ | - | ||||||||||||||||||
503 | QVector<QRect> MinOverlapPlacer::findMaxOverlappers(const QRect &domain, const QVector<QRect> &source) | - | ||||||||||||||||||
504 | { | - | ||||||||||||||||||
505 | QVector<QRect> result; | - | ||||||||||||||||||
506 | result.reserve(source.size()); | - | ||||||||||||||||||
507 | - | |||||||||||||||||||
508 | int maxOverlap = -1; | - | ||||||||||||||||||
509 | foreach (const QRect &srcRect, source) { | - | ||||||||||||||||||
510 | QRect intersection = domain.intersected(srcRect); | - | ||||||||||||||||||
511 | const int overlap = intersection.width() * intersection.height(); | - | ||||||||||||||||||
512 | if (overlap >= maxOverlap || maxOverlap == -1) {
| 0 | ||||||||||||||||||
513 | if (overlap > maxOverlap) {
| 0 | ||||||||||||||||||
514 | maxOverlap = overlap; | - | ||||||||||||||||||
515 | result.clear(); | - | ||||||||||||||||||
516 | } never executed: end of block | 0 | ||||||||||||||||||
517 | result << srcRect; | - | ||||||||||||||||||
518 | } never executed: end of block | 0 | ||||||||||||||||||
519 | } never executed: end of block | 0 | ||||||||||||||||||
520 | - | |||||||||||||||||||
521 | return result; never executed: return result; | 0 | ||||||||||||||||||
522 | } | - | ||||||||||||||||||
523 | - | |||||||||||||||||||
524 | /*! | - | ||||||||||||||||||
525 | \internal | - | ||||||||||||||||||
526 | Finds among the rectangles in 'source' the best placement. Here, 'best' means the | - | ||||||||||||||||||
527 | placement that overlaps the rectangles in 'rects' as little as possible while at the | - | ||||||||||||||||||
528 | same time being as much as possible inside 'domain'. | - | ||||||||||||||||||
529 | */ | - | ||||||||||||||||||
530 | QPoint MinOverlapPlacer::findBestPlacement(const QRect &domain, const QVector<QRect> &rects, | - | ||||||||||||||||||
531 | QVector<QRect> &source) | - | ||||||||||||||||||
532 | { | - | ||||||||||||||||||
533 | const QVector<QRect> nonInsiders = findNonInsiders(domain, source); | - | ||||||||||||||||||
534 | - | |||||||||||||||||||
535 | if (!source.empty())
| 0 | ||||||||||||||||||
536 | return findMinOverlapRect(source, rects).topLeft(); never executed: return findMinOverlapRect(source, rects).topLeft(); | 0 | ||||||||||||||||||
537 | - | |||||||||||||||||||
538 | QVector<QRect> maxOverlappers = findMaxOverlappers(domain, nonInsiders); | - | ||||||||||||||||||
539 | return findMinOverlapRect(maxOverlappers, rects).topLeft(); never executed: return findMinOverlapRect(maxOverlappers, rects).topLeft(); | 0 | ||||||||||||||||||
540 | } | - | ||||||||||||||||||
541 | - | |||||||||||||||||||
542 | - | |||||||||||||||||||
543 | /*! | - | ||||||||||||||||||
544 | \internal | - | ||||||||||||||||||
545 | Places the rectangle defined by 'size' relative to 'rects' and 'domain' so that it | - | ||||||||||||||||||
546 | overlaps 'rects' as little as possible and 'domain' as much as possible. | - | ||||||||||||||||||
547 | Returns the position of the resulting rectangle. | - | ||||||||||||||||||
548 | */ | - | ||||||||||||||||||
549 | QPoint MinOverlapPlacer::place(const QSize &size, const QVector<QRect> &rects, | - | ||||||||||||||||||
550 | const QRect &domain) const | - | ||||||||||||||||||
551 | { | - | ||||||||||||||||||
552 | if (size.isEmpty() || !domain.isValid())
| 0 | ||||||||||||||||||
553 | return QPoint(); never executed: return QPoint(); | 0 | ||||||||||||||||||
554 | foreach (const QRect &rect, rects) { | - | ||||||||||||||||||
555 | if (!rect.isValid())
| 0 | ||||||||||||||||||
556 | return QPoint(); never executed: return QPoint(); | 0 | ||||||||||||||||||
557 | } never executed: end of block | 0 | ||||||||||||||||||
558 | - | |||||||||||||||||||
559 | QVector<QRect> candidates = getCandidatePlacements(size, rects, domain); | - | ||||||||||||||||||
560 | return findBestPlacement(domain, rects, candidates); never executed: return findBestPlacement(domain, rects, candidates); | 0 | ||||||||||||||||||
561 | } | - | ||||||||||||||||||
562 | - | |||||||||||||||||||
563 | #ifndef QT_NO_TABBAR | - | ||||||||||||||||||
564 | class QMdiAreaTabBar : public QTabBar | - | ||||||||||||||||||
565 | { | - | ||||||||||||||||||
566 | public: | - | ||||||||||||||||||
567 | QMdiAreaTabBar(QWidget *parent) : QTabBar(parent) {} never executed: end of block | 0 | ||||||||||||||||||
568 | - | |||||||||||||||||||
569 | protected: | - | ||||||||||||||||||
570 | void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; | - | ||||||||||||||||||
571 | #ifndef QT_NO_CONTEXTMENU | - | ||||||||||||||||||
572 | void contextMenuEvent(QContextMenuEvent *event) Q_DECL_OVERRIDE; | - | ||||||||||||||||||
573 | #endif | - | ||||||||||||||||||
574 | - | |||||||||||||||||||
575 | private: | - | ||||||||||||||||||
576 | QMdiSubWindow *subWindowFromIndex(int index) const; | - | ||||||||||||||||||
577 | }; | - | ||||||||||||||||||
578 | - | |||||||||||||||||||
579 | /*! | - | ||||||||||||||||||
580 | \internal | - | ||||||||||||||||||
581 | */ | - | ||||||||||||||||||
582 | void QMdiAreaTabBar::mousePressEvent(QMouseEvent *event) | - | ||||||||||||||||||
583 | { | - | ||||||||||||||||||
584 | if (event->button() != Qt::MidButton) {
| 0 | ||||||||||||||||||
585 | QTabBar::mousePressEvent(event); | - | ||||||||||||||||||
586 | return; never executed: return; | 0 | ||||||||||||||||||
587 | } | - | ||||||||||||||||||
588 | - | |||||||||||||||||||
589 | QMdiSubWindow *subWindow = subWindowFromIndex(tabAt(event->pos())); | - | ||||||||||||||||||
590 | if (!subWindow) {
| 0 | ||||||||||||||||||
591 | event->ignore(); | - | ||||||||||||||||||
592 | return; never executed: return; | 0 | ||||||||||||||||||
593 | } | - | ||||||||||||||||||
594 | - | |||||||||||||||||||
595 | subWindow->close(); | - | ||||||||||||||||||
596 | } never executed: end of block | 0 | ||||||||||||||||||
597 | - | |||||||||||||||||||
598 | #ifndef QT_NO_CONTEXTMENU | - | ||||||||||||||||||
599 | /*! | - | ||||||||||||||||||
600 | \internal | - | ||||||||||||||||||
601 | */ | - | ||||||||||||||||||
602 | void QMdiAreaTabBar::contextMenuEvent(QContextMenuEvent *event) | - | ||||||||||||||||||
603 | { | - | ||||||||||||||||||
604 | QPointer<QMdiSubWindow> subWindow = subWindowFromIndex(tabAt(event->pos())); | - | ||||||||||||||||||
605 | if (!subWindow || subWindow->isHidden()) {
| 0 | ||||||||||||||||||
606 | event->ignore(); | - | ||||||||||||||||||
607 | return; never executed: return; | 0 | ||||||||||||||||||
608 | } | - | ||||||||||||||||||
609 | - | |||||||||||||||||||
610 | #ifndef QT_NO_MENU | - | ||||||||||||||||||
611 | QMdiSubWindowPrivate *subWindowPrivate = subWindow->d_func(); | - | ||||||||||||||||||
612 | if (!subWindowPrivate->systemMenu) {
| 0 | ||||||||||||||||||
613 | event->ignore(); | - | ||||||||||||||||||
614 | return; never executed: return; | 0 | ||||||||||||||||||
615 | } | - | ||||||||||||||||||
616 | - | |||||||||||||||||||
617 | QMdiSubWindow *currentSubWindow = subWindowFromIndex(currentIndex()); | - | ||||||||||||||||||
618 | Q_ASSERT(currentSubWindow); | - | ||||||||||||||||||
619 | - | |||||||||||||||||||
620 | // We don't want these actions to show up in the system menu when the | - | ||||||||||||||||||
621 | // current sub-window is maximized, i.e. covers the entire viewport. | - | ||||||||||||||||||
622 | if (currentSubWindow->isMaximized()) {
| 0 | ||||||||||||||||||
623 | subWindowPrivate->setVisible(QMdiSubWindowPrivate::MoveAction, false); | - | ||||||||||||||||||
624 | subWindowPrivate->setVisible(QMdiSubWindowPrivate::ResizeAction, false); | - | ||||||||||||||||||
625 | subWindowPrivate->setVisible(QMdiSubWindowPrivate::MinimizeAction, false); | - | ||||||||||||||||||
626 | subWindowPrivate->setVisible(QMdiSubWindowPrivate::MaximizeAction, false); | - | ||||||||||||||||||
627 | subWindowPrivate->setVisible(QMdiSubWindowPrivate::RestoreAction, false); | - | ||||||||||||||||||
628 | subWindowPrivate->setVisible(QMdiSubWindowPrivate::StayOnTopAction, false); | - | ||||||||||||||||||
629 | } never executed: end of block | 0 | ||||||||||||||||||
630 | - | |||||||||||||||||||
631 | // Show system menu. | - | ||||||||||||||||||
632 | subWindowPrivate->systemMenu->exec(event->globalPos()); | - | ||||||||||||||||||
633 | if (!subWindow)
| 0 | ||||||||||||||||||
634 | return; never executed: return; | 0 | ||||||||||||||||||
635 | - | |||||||||||||||||||
636 | // Restore action visibility. | - | ||||||||||||||||||
637 | subWindowPrivate->updateActions(); | - | ||||||||||||||||||
638 | #endif // QT_NO_MENU | - | ||||||||||||||||||
639 | } never executed: end of block | 0 | ||||||||||||||||||
640 | #endif // QT_NO_CONTEXTMENU | - | ||||||||||||||||||
641 | - | |||||||||||||||||||
642 | /*! | - | ||||||||||||||||||
643 | \internal | - | ||||||||||||||||||
644 | */ | - | ||||||||||||||||||
645 | QMdiSubWindow *QMdiAreaTabBar::subWindowFromIndex(int index) const | - | ||||||||||||||||||
646 | { | - | ||||||||||||||||||
647 | if (index < 0 || index >= count())
| 0 | ||||||||||||||||||
648 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
649 | - | |||||||||||||||||||
650 | QMdiArea *mdiArea = qobject_cast<QMdiArea *>(parentWidget()); | - | ||||||||||||||||||
651 | Q_ASSERT(mdiArea); | - | ||||||||||||||||||
652 | - | |||||||||||||||||||
653 | const QList<QMdiSubWindow *> subWindows = mdiArea->subWindowList(); | - | ||||||||||||||||||
654 | Q_ASSERT(index < subWindows.size()); | - | ||||||||||||||||||
655 | - | |||||||||||||||||||
656 | QMdiSubWindow *subWindow = mdiArea->subWindowList().at(index); | - | ||||||||||||||||||
657 | Q_ASSERT(subWindow); | - | ||||||||||||||||||
658 | - | |||||||||||||||||||
659 | return subWindow; never executed: return subWindow; | 0 | ||||||||||||||||||
660 | } | - | ||||||||||||||||||
661 | #endif // QT_NO_TABBAR | - | ||||||||||||||||||
662 | - | |||||||||||||||||||
663 | /*! | - | ||||||||||||||||||
664 | \internal | - | ||||||||||||||||||
665 | */ | - | ||||||||||||||||||
666 | QMdiAreaPrivate::QMdiAreaPrivate() | - | ||||||||||||||||||
667 | : cascader(0), | - | ||||||||||||||||||
668 | regularTiler(0), | - | ||||||||||||||||||
669 | iconTiler(0), | - | ||||||||||||||||||
670 | placer(0), | - | ||||||||||||||||||
671 | #ifndef QT_NO_RUBBERBAND | - | ||||||||||||||||||
672 | rubberBand(0), | - | ||||||||||||||||||
673 | #endif | - | ||||||||||||||||||
674 | #ifndef QT_NO_TABBAR | - | ||||||||||||||||||
675 | tabBar(0), | - | ||||||||||||||||||
676 | #endif | - | ||||||||||||||||||
677 | activationOrder(QMdiArea::CreationOrder), | - | ||||||||||||||||||
678 | viewMode(QMdiArea::SubWindowView), | - | ||||||||||||||||||
679 | #ifndef QT_NO_TABBAR | - | ||||||||||||||||||
680 | documentMode(false), | - | ||||||||||||||||||
681 | tabsClosable(false), | - | ||||||||||||||||||
682 | tabsMovable(false), | - | ||||||||||||||||||
683 | #endif | - | ||||||||||||||||||
684 | #ifndef QT_NO_TABWIDGET | - | ||||||||||||||||||
685 | tabShape(QTabWidget::Rounded), | - | ||||||||||||||||||
686 | tabPosition(QTabWidget::North), | - | ||||||||||||||||||
687 | #endif | - | ||||||||||||||||||
688 | ignoreGeometryChange(false), | - | ||||||||||||||||||
689 | ignoreWindowStateChange(false), | - | ||||||||||||||||||
690 | isActivated(false), | - | ||||||||||||||||||
691 | isSubWindowsTiled(false), | - | ||||||||||||||||||
692 | showActiveWindowMaximized(false), | - | ||||||||||||||||||
693 | tileCalledFromResizeEvent(false), | - | ||||||||||||||||||
694 | updatesDisabledByUs(false), | - | ||||||||||||||||||
695 | inViewModeChange(false), | - | ||||||||||||||||||
696 | indexToNextWindow(-1), | - | ||||||||||||||||||
697 | indexToPreviousWindow(-1), | - | ||||||||||||||||||
698 | indexToHighlighted(-1), | - | ||||||||||||||||||
699 | indexToLastActiveTab(-1), | - | ||||||||||||||||||
700 | resizeTimerId(-1), | - | ||||||||||||||||||
701 | tabToPreviousTimerId(-1) | - | ||||||||||||||||||
702 | { | - | ||||||||||||||||||
703 | } never executed: end of block | 0 | ||||||||||||||||||
704 | - | |||||||||||||||||||
705 | /*! | - | ||||||||||||||||||
706 | \internal | - | ||||||||||||||||||
707 | */ | - | ||||||||||||||||||
708 | void QMdiAreaPrivate::_q_deactivateAllWindows(QMdiSubWindow *aboutToActivate) | - | ||||||||||||||||||
709 | { | - | ||||||||||||||||||
710 | if (ignoreWindowStateChange)
| 0 | ||||||||||||||||||
711 | return; never executed: return; | 0 | ||||||||||||||||||
712 | - | |||||||||||||||||||
713 | Q_Q(QMdiArea); | - | ||||||||||||||||||
714 | if (!aboutToActivate)
| 0 | ||||||||||||||||||
715 | aboutToBecomeActive = qobject_cast<QMdiSubWindow *>(q->sender()); never executed: aboutToBecomeActive = qobject_cast<QMdiSubWindow *>(q->sender()); | 0 | ||||||||||||||||||
716 | else | - | ||||||||||||||||||
717 | aboutToBecomeActive = aboutToActivate; never executed: aboutToBecomeActive = aboutToActivate; | 0 | ||||||||||||||||||
718 | Q_ASSERT(aboutToBecomeActive); | - | ||||||||||||||||||
719 | - | |||||||||||||||||||
720 | foreach (QMdiSubWindow *child, childWindows) { | - | ||||||||||||||||||
721 | if (!sanityCheck(child, "QMdiArea::deactivateAllWindows") || aboutToBecomeActive == child)
| 0 | ||||||||||||||||||
722 | continue; never executed: continue; | 0 | ||||||||||||||||||
723 | // We don't want to handle signals caused by child->showNormal(). | - | ||||||||||||||||||
724 | ignoreWindowStateChange = true; | - | ||||||||||||||||||
725 | if(!(options & QMdiArea::DontMaximizeSubWindowOnActivation) && !showActiveWindowMaximized)
| 0 | ||||||||||||||||||
726 | showActiveWindowMaximized = child->isMaximized() && child->isVisible(); never executed: showActiveWindowMaximized = child->isMaximized() && child->isVisible();
| 0 | ||||||||||||||||||
727 | if (showActiveWindowMaximized && child->isMaximized()) {
| 0 | ||||||||||||||||||
728 | if (q->updatesEnabled()) {
| 0 | ||||||||||||||||||
729 | updatesDisabledByUs = true; | - | ||||||||||||||||||
730 | q->setUpdatesEnabled(false); | - | ||||||||||||||||||
731 | } never executed: end of block | 0 | ||||||||||||||||||
732 | child->showNormal(); | - | ||||||||||||||||||
733 | } never executed: end of block | 0 | ||||||||||||||||||
734 | if (child->isMinimized() && !child->isShaded() && !windowStaysOnTop(child))
| 0 | ||||||||||||||||||
735 | child->lower(); never executed: child->lower(); | 0 | ||||||||||||||||||
736 | ignoreWindowStateChange = false; | - | ||||||||||||||||||
737 | child->d_func()->setActive(false); | - | ||||||||||||||||||
738 | } never executed: end of block | 0 | ||||||||||||||||||
739 | } never executed: end of block | 0 | ||||||||||||||||||
740 | - | |||||||||||||||||||
741 | /*! | - | ||||||||||||||||||
742 | \internal | - | ||||||||||||||||||
743 | */ | - | ||||||||||||||||||
744 | void QMdiAreaPrivate::_q_processWindowStateChanged(Qt::WindowStates oldState, | - | ||||||||||||||||||
745 | Qt::WindowStates newState) | - | ||||||||||||||||||
746 | { | - | ||||||||||||||||||
747 | if (ignoreWindowStateChange)
| 0 | ||||||||||||||||||
748 | return; never executed: return; | 0 | ||||||||||||||||||
749 | - | |||||||||||||||||||
750 | Q_Q(QMdiArea); | - | ||||||||||||||||||
751 | QMdiSubWindow *child = qobject_cast<QMdiSubWindow *>(q->sender()); | - | ||||||||||||||||||
752 | if (!child)
| 0 | ||||||||||||||||||
753 | return; never executed: return; | 0 | ||||||||||||||||||
754 | - | |||||||||||||||||||
755 | // windowActivated | - | ||||||||||||||||||
756 | if (!(oldState & Qt::WindowActive) && (newState & Qt::WindowActive))
| 0 | ||||||||||||||||||
757 | emitWindowActivated(child); never executed: emitWindowActivated(child); | 0 | ||||||||||||||||||
758 | // windowDeactivated | - | ||||||||||||||||||
759 | else if ((oldState & Qt::WindowActive) && !(newState & Qt::WindowActive))
| 0 | ||||||||||||||||||
760 | resetActiveWindow(child); never executed: resetActiveWindow(child); | 0 | ||||||||||||||||||
761 | - | |||||||||||||||||||
762 | // windowMinimized | - | ||||||||||||||||||
763 | if (!(oldState & Qt::WindowMinimized) && (newState & Qt::WindowMinimized)) {
| 0 | ||||||||||||||||||
764 | isSubWindowsTiled = false; | - | ||||||||||||||||||
765 | arrangeMinimizedSubWindows(); | - | ||||||||||||||||||
766 | // windowMaximized | - | ||||||||||||||||||
767 | } else if (!(oldState & Qt::WindowMaximized) && (newState & Qt::WindowMaximized)) { never executed: end of block
| 0 | ||||||||||||||||||
768 | internalRaise(child); | - | ||||||||||||||||||
769 | // windowRestored | - | ||||||||||||||||||
770 | } else if (!(newState & (Qt::WindowMaximized | Qt::WindowMinimized))) { never executed: end of block
| 0 | ||||||||||||||||||
771 | internalRaise(child); | - | ||||||||||||||||||
772 | if (oldState & Qt::WindowMinimized)
| 0 | ||||||||||||||||||
773 | arrangeMinimizedSubWindows(); never executed: arrangeMinimizedSubWindows(); | 0 | ||||||||||||||||||
774 | } never executed: end of block | 0 | ||||||||||||||||||
775 | } never executed: end of block | 0 | ||||||||||||||||||
776 | - | |||||||||||||||||||
777 | void QMdiAreaPrivate::_q_currentTabChanged(int index) | - | ||||||||||||||||||
778 | { | - | ||||||||||||||||||
779 | #ifdef QT_NO_TABBAR | - | ||||||||||||||||||
780 | Q_UNUSED(index); | - | ||||||||||||||||||
781 | #else | - | ||||||||||||||||||
782 | if (!tabBar || index < 0)
| 0 | ||||||||||||||||||
783 | return; never executed: return; | 0 | ||||||||||||||||||
784 | - | |||||||||||||||||||
785 | // If the previous active sub-window was hidden, disable the tab. | - | ||||||||||||||||||
786 | if (indexToLastActiveTab >= 0 && indexToLastActiveTab < tabBar->count()
| 0 | ||||||||||||||||||
787 | && indexToLastActiveTab < childWindows.count()) {
| 0 | ||||||||||||||||||
788 | QMdiSubWindow *lastActive = childWindows.at(indexToLastActiveTab); | - | ||||||||||||||||||
789 | if (lastActive && lastActive->isHidden())
| 0 | ||||||||||||||||||
790 | tabBar->setTabEnabled(indexToLastActiveTab, false); never executed: tabBar->setTabEnabled(indexToLastActiveTab, false); | 0 | ||||||||||||||||||
791 | } never executed: end of block | 0 | ||||||||||||||||||
792 | - | |||||||||||||||||||
793 | indexToLastActiveTab = index; | - | ||||||||||||||||||
794 | Q_ASSERT(childWindows.size() > index); | - | ||||||||||||||||||
795 | QMdiSubWindow *subWindow = childWindows.at(index); | - | ||||||||||||||||||
796 | Q_ASSERT(subWindow); | - | ||||||||||||||||||
797 | activateWindow(subWindow); | - | ||||||||||||||||||
798 | #endif // QT_NO_TABBAR | - | ||||||||||||||||||
799 | } never executed: end of block | 0 | ||||||||||||||||||
800 | - | |||||||||||||||||||
801 | void QMdiAreaPrivate::_q_closeTab(int index) | - | ||||||||||||||||||
802 | { | - | ||||||||||||||||||
803 | #ifdef QT_NO_TABBAR | - | ||||||||||||||||||
804 | Q_UNUSED(index); | - | ||||||||||||||||||
805 | #else | - | ||||||||||||||||||
806 | QMdiSubWindow *subWindow = childWindows.at(index); | - | ||||||||||||||||||
807 | Q_ASSERT(subWindow); | - | ||||||||||||||||||
808 | subWindow->close(); | - | ||||||||||||||||||
809 | #endif // QT_NO_TABBAR | - | ||||||||||||||||||
810 | } never executed: end of block | 0 | ||||||||||||||||||
811 | - | |||||||||||||||||||
812 | void QMdiAreaPrivate::_q_moveTab(int from, int to) | - | ||||||||||||||||||
813 | { | - | ||||||||||||||||||
814 | #ifdef QT_NO_TABBAR | - | ||||||||||||||||||
815 | Q_UNUSED(from); | - | ||||||||||||||||||
816 | Q_UNUSED(to); | - | ||||||||||||||||||
817 | #else | - | ||||||||||||||||||
818 | childWindows.move(from, to); | - | ||||||||||||||||||
819 | #endif // QT_NO_TABBAR | - | ||||||||||||||||||
820 | } never executed: end of block | 0 | ||||||||||||||||||
821 | - | |||||||||||||||||||
822 | /*! | - | ||||||||||||||||||
823 | \internal | - | ||||||||||||||||||
824 | */ | - | ||||||||||||||||||
825 | void QMdiAreaPrivate::appendChild(QMdiSubWindow *child) | - | ||||||||||||||||||
826 | { | - | ||||||||||||||||||
827 | Q_Q(QMdiArea); | - | ||||||||||||||||||
828 | Q_ASSERT(child && childWindows.indexOf(child) == -1); | - | ||||||||||||||||||
829 | - | |||||||||||||||||||
830 | if (child->parent() != viewport)
| 0 | ||||||||||||||||||
831 | child->setParent(viewport, child->windowFlags()); never executed: child->setParent(viewport, child->windowFlags()); | 0 | ||||||||||||||||||
832 | childWindows.append(QPointer<QMdiSubWindow>(child)); | - | ||||||||||||||||||
833 | - | |||||||||||||||||||
834 | if (!child->testAttribute(Qt::WA_Resized) && q->isVisible()) {
| 0 | ||||||||||||||||||
835 | QSize newSize(child->sizeHint().boundedTo(viewport->size())); | - | ||||||||||||||||||
836 | child->resize(newSize.expandedTo(qSmartMinSize(child))); | - | ||||||||||||||||||
837 | } never executed: end of block | 0 | ||||||||||||||||||
838 | - | |||||||||||||||||||
839 | if (!placer)
| 0 | ||||||||||||||||||
840 | placer = new MinOverlapPlacer; never executed: placer = new MinOverlapPlacer; | 0 | ||||||||||||||||||
841 | place(placer, child); | - | ||||||||||||||||||
842 | - | |||||||||||||||||||
843 | if (hbarpolicy != Qt::ScrollBarAlwaysOff)
| 0 | ||||||||||||||||||
844 | child->setOption(QMdiSubWindow::AllowOutsideAreaHorizontally, true); never executed: child->setOption(QMdiSubWindow::AllowOutsideAreaHorizontally, true); | 0 | ||||||||||||||||||
845 | else | - | ||||||||||||||||||
846 | child->setOption(QMdiSubWindow::AllowOutsideAreaHorizontally, false); never executed: child->setOption(QMdiSubWindow::AllowOutsideAreaHorizontally, false); | 0 | ||||||||||||||||||
847 | - | |||||||||||||||||||
848 | if (vbarpolicy != Qt::ScrollBarAlwaysOff)
| 0 | ||||||||||||||||||
849 | child->setOption(QMdiSubWindow::AllowOutsideAreaVertically, true); never executed: child->setOption(QMdiSubWindow::AllowOutsideAreaVertically, true); | 0 | ||||||||||||||||||
850 | else | - | ||||||||||||||||||
851 | child->setOption(QMdiSubWindow::AllowOutsideAreaVertically, false); never executed: child->setOption(QMdiSubWindow::AllowOutsideAreaVertically, false); | 0 | ||||||||||||||||||
852 | - | |||||||||||||||||||
853 | internalRaise(child); | - | ||||||||||||||||||
854 | indicesToActivatedChildren.prepend(childWindows.size() - 1); | - | ||||||||||||||||||
855 | Q_ASSERT(indicesToActivatedChildren.size() == childWindows.size()); | - | ||||||||||||||||||
856 | - | |||||||||||||||||||
857 | #ifndef QT_NO_TABBAR | - | ||||||||||||||||||
858 | if (tabBar) {
| 0 | ||||||||||||||||||
859 | tabBar->addTab(child->windowIcon(), tabTextFor(child)); | - | ||||||||||||||||||
860 | updateTabBarGeometry(); | - | ||||||||||||||||||
861 | if (childWindows.count() == 1 && !(options & QMdiArea::DontMaximizeSubWindowOnActivation))
| 0 | ||||||||||||||||||
862 | showActiveWindowMaximized = true; never executed: showActiveWindowMaximized = true; | 0 | ||||||||||||||||||
863 | } never executed: end of block | 0 | ||||||||||||||||||
864 | #endif | - | ||||||||||||||||||
865 | - | |||||||||||||||||||
866 | if (!(child->windowFlags() & Qt::SubWindow))
| 0 | ||||||||||||||||||
867 | child->setWindowFlags(Qt::SubWindow); never executed: child->setWindowFlags(Qt::SubWindow); | 0 | ||||||||||||||||||
868 | child->installEventFilter(q); | - | ||||||||||||||||||
869 | - | |||||||||||||||||||
870 | QObject::connect(child, SIGNAL(aboutToActivate()), q, SLOT(_q_deactivateAllWindows())); | - | ||||||||||||||||||
871 | QObject::connect(child, SIGNAL(windowStateChanged(Qt::WindowStates,Qt::WindowStates)), | - | ||||||||||||||||||
872 | q, SLOT(_q_processWindowStateChanged(Qt::WindowStates,Qt::WindowStates))); | - | ||||||||||||||||||
873 | } never executed: end of block | 0 | ||||||||||||||||||
874 | - | |||||||||||||||||||
875 | /*! | - | ||||||||||||||||||
876 | \internal | - | ||||||||||||||||||
877 | */ | - | ||||||||||||||||||
878 | void QMdiAreaPrivate::place(Placer *placer, QMdiSubWindow *child) | - | ||||||||||||||||||
879 | { | - | ||||||||||||||||||
880 | if (!placer || !child)
| 0 | ||||||||||||||||||
881 | return; never executed: return; | 0 | ||||||||||||||||||
882 | - | |||||||||||||||||||
883 | Q_Q(QMdiArea); | - | ||||||||||||||||||
884 | if (!q->isVisible()) {
| 0 | ||||||||||||||||||
885 | // The window is only laid out when it's added to QMdiArea, | - | ||||||||||||||||||
886 | // so there's no need to check that we don't have it in the | - | ||||||||||||||||||
887 | // list already. appendChild() ensures that. | - | ||||||||||||||||||
888 | pendingPlacements.append(child); | - | ||||||||||||||||||
889 | return; never executed: return; | 0 | ||||||||||||||||||
890 | } | - | ||||||||||||||||||
891 | - | |||||||||||||||||||
892 | QVector<QRect> rects; | - | ||||||||||||||||||
893 | rects.reserve(childWindows.size()); | - | ||||||||||||||||||
894 | QRect parentRect = q->rect(); | - | ||||||||||||||||||
895 | foreach (QMdiSubWindow *window, childWindows) { | - | ||||||||||||||||||
896 | if (!sanityCheck(window, "QMdiArea::place") || window == child || !window->isVisibleTo(q)
| 0 | ||||||||||||||||||
897 | || !window->testAttribute(Qt::WA_Moved)) {
| 0 | ||||||||||||||||||
898 | continue; never executed: continue; | 0 | ||||||||||||||||||
899 | } | - | ||||||||||||||||||
900 | QRect occupiedGeometry; | - | ||||||||||||||||||
901 | if (window->isMaximized()) {
| 0 | ||||||||||||||||||
902 | occupiedGeometry = QRect(window->d_func()->oldGeometry.topLeft(), | - | ||||||||||||||||||
903 | window->d_func()->restoreSize); | - | ||||||||||||||||||
904 | } else { never executed: end of block | 0 | ||||||||||||||||||
905 | occupiedGeometry = window->geometry(); | - | ||||||||||||||||||
906 | } never executed: end of block | 0 | ||||||||||||||||||
907 | rects.append(QStyle::visualRect(child->layoutDirection(), parentRect, occupiedGeometry)); | - | ||||||||||||||||||
908 | } never executed: end of block | 0 | ||||||||||||||||||
909 | QPoint newPos = placer->place(child->size(), rects, parentRect); | - | ||||||||||||||||||
910 | QRect newGeometry = QRect(newPos.x(), newPos.y(), child->width(), child->height()); | - | ||||||||||||||||||
911 | child->setGeometry(QStyle::visualRect(child->layoutDirection(), parentRect, newGeometry)); | - | ||||||||||||||||||
912 | } never executed: end of block | 0 | ||||||||||||||||||
913 | - | |||||||||||||||||||
914 | /*! | - | ||||||||||||||||||
915 | \internal | - | ||||||||||||||||||
916 | */ | - | ||||||||||||||||||
917 | void QMdiAreaPrivate::rearrange(Rearranger *rearranger) | - | ||||||||||||||||||
918 | { | - | ||||||||||||||||||
919 | if (!rearranger)
| 0 | ||||||||||||||||||
920 | return; never executed: return; | 0 | ||||||||||||||||||
921 | - | |||||||||||||||||||
922 | Q_Q(QMdiArea); | - | ||||||||||||||||||
923 | if (!q->isVisible()) {
| 0 | ||||||||||||||||||
924 | // Compress if we already have the rearranger in the list. | - | ||||||||||||||||||
925 | int index = pendingRearrangements.indexOf(rearranger); | - | ||||||||||||||||||
926 | if (index != -1)
| 0 | ||||||||||||||||||
927 | pendingRearrangements.move(index, pendingRearrangements.size() - 1); never executed: pendingRearrangements.move(index, pendingRearrangements.size() - 1); | 0 | ||||||||||||||||||
928 | else | - | ||||||||||||||||||
929 | pendingRearrangements.append(rearranger); never executed: pendingRearrangements.append(rearranger); | 0 | ||||||||||||||||||
930 | return; never executed: return; | 0 | ||||||||||||||||||
931 | } | - | ||||||||||||||||||
932 | - | |||||||||||||||||||
933 | QList<QWidget *> widgets; | - | ||||||||||||||||||
934 | const bool reverseList = rearranger->type() == Rearranger::RegularTiler; | - | ||||||||||||||||||
935 | const QList<QMdiSubWindow *> subWindows = subWindowList(activationOrder, reverseList); | - | ||||||||||||||||||
936 | QSize minSubWindowSize; | - | ||||||||||||||||||
937 | foreach (QMdiSubWindow *child, subWindows) { | - | ||||||||||||||||||
938 | if (!sanityCheck(child, "QMdiArea::rearrange") || !child->isVisible())
| 0 | ||||||||||||||||||
939 | continue; never executed: continue; | 0 | ||||||||||||||||||
940 | if (rearranger->type() == Rearranger::IconTiler) {
| 0 | ||||||||||||||||||
941 | if (child->isMinimized() && !child->isShaded() && !(child->windowFlags() & Qt::FramelessWindowHint))
| 0 | ||||||||||||||||||
942 | widgets.append(child); never executed: widgets.append(child); | 0 | ||||||||||||||||||
943 | } else { never executed: end of block | 0 | ||||||||||||||||||
944 | if (child->isMinimized() && !child->isShaded())
| 0 | ||||||||||||||||||
945 | continue; never executed: continue; | 0 | ||||||||||||||||||
946 | if (child->isMaximized() || child->isShaded())
| 0 | ||||||||||||||||||
947 | child->showNormal(); never executed: child->showNormal(); | 0 | ||||||||||||||||||
948 | minSubWindowSize = minSubWindowSize.expandedTo(child->minimumSize()) | - | ||||||||||||||||||
949 | .expandedTo(child->d_func()->internalMinimumSize); | - | ||||||||||||||||||
950 | widgets.append(child); | - | ||||||||||||||||||
951 | } never executed: end of block | 0 | ||||||||||||||||||
952 | } | - | ||||||||||||||||||
953 | - | |||||||||||||||||||
954 | if (active && rearranger->type() == Rearranger::RegularTiler) {
| 0 | ||||||||||||||||||
955 | // Move active window in front if necessary. That's the case if we | - | ||||||||||||||||||
956 | // have any windows with staysOnTopHint set. | - | ||||||||||||||||||
957 | int indexToActive = widgets.indexOf((QWidget *)active); | - | ||||||||||||||||||
958 | if (indexToActive > 0)
| 0 | ||||||||||||||||||
959 | widgets.move(indexToActive, 0); never executed: widgets.move(indexToActive, 0); | 0 | ||||||||||||||||||
960 | } never executed: end of block | 0 | ||||||||||||||||||
961 | - | |||||||||||||||||||
962 | QRect domain = viewport->rect(); | - | ||||||||||||||||||
963 | if (rearranger->type() == Rearranger::RegularTiler && !widgets.isEmpty())
| 0 | ||||||||||||||||||
964 | domain = resizeToMinimumTileSize(minSubWindowSize, widgets.count()); never executed: domain = resizeToMinimumTileSize(minSubWindowSize, widgets.count()); | 0 | ||||||||||||||||||
965 | - | |||||||||||||||||||
966 | rearranger->rearrange(widgets, domain); | - | ||||||||||||||||||
967 | - | |||||||||||||||||||
968 | if (rearranger->type() == Rearranger::RegularTiler && !widgets.isEmpty()) {
| 0 | ||||||||||||||||||
969 | isSubWindowsTiled = true; | - | ||||||||||||||||||
970 | updateScrollBars(); | - | ||||||||||||||||||
971 | } else if (rearranger->type() == Rearranger::SimpleCascader) { never executed: end of block
| 0 | ||||||||||||||||||
972 | isSubWindowsTiled = false; | - | ||||||||||||||||||
973 | } never executed: end of block | 0 | ||||||||||||||||||
974 | } never executed: end of block | 0 | ||||||||||||||||||
975 | - | |||||||||||||||||||
976 | /*! | - | ||||||||||||||||||
977 | \internal | - | ||||||||||||||||||
978 | - | |||||||||||||||||||
979 | Arranges all minimized windows at the bottom of the workspace. | - | ||||||||||||||||||
980 | */ | - | ||||||||||||||||||
981 | void QMdiAreaPrivate::arrangeMinimizedSubWindows() | - | ||||||||||||||||||
982 | { | - | ||||||||||||||||||
983 | if (!iconTiler)
| 0 | ||||||||||||||||||
984 | iconTiler = new IconTiler; never executed: iconTiler = new IconTiler; | 0 | ||||||||||||||||||
985 | rearrange(iconTiler); | - | ||||||||||||||||||
986 | } never executed: end of block | 0 | ||||||||||||||||||
987 | - | |||||||||||||||||||
988 | /*! | - | ||||||||||||||||||
989 | \internal | - | ||||||||||||||||||
990 | */ | - | ||||||||||||||||||
991 | void QMdiAreaPrivate::activateWindow(QMdiSubWindow *child) | - | ||||||||||||||||||
992 | { | - | ||||||||||||||||||
993 | if (childWindows.isEmpty()) {
| 0 | ||||||||||||||||||
994 | Q_ASSERT(!child); | - | ||||||||||||||||||
995 | Q_ASSERT(!active); | - | ||||||||||||||||||
996 | return; never executed: return; | 0 | ||||||||||||||||||
997 | } | - | ||||||||||||||||||
998 | - | |||||||||||||||||||
999 | if (!child) {
| 0 | ||||||||||||||||||
1000 | if (active) {
| 0 | ||||||||||||||||||
1001 | Q_ASSERT(active->d_func()->isActive); | - | ||||||||||||||||||
1002 | active->d_func()->setActive(false); | - | ||||||||||||||||||
1003 | resetActiveWindow(); | - | ||||||||||||||||||
1004 | } never executed: end of block | 0 | ||||||||||||||||||
1005 | return; never executed: return; | 0 | ||||||||||||||||||
1006 | } | - | ||||||||||||||||||
1007 | - | |||||||||||||||||||
1008 | if (child->isHidden() || child == active)
| 0 | ||||||||||||||||||
1009 | return; never executed: return; | 0 | ||||||||||||||||||
1010 | child->d_func()->setActive(true); | - | ||||||||||||||||||
1011 | } never executed: end of block | 0 | ||||||||||||||||||
1012 | - | |||||||||||||||||||
1013 | /*! | - | ||||||||||||||||||
1014 | \internal | - | ||||||||||||||||||
1015 | */ | - | ||||||||||||||||||
1016 | void QMdiAreaPrivate::activateCurrentWindow() | - | ||||||||||||||||||
1017 | { | - | ||||||||||||||||||
1018 | QMdiSubWindow *current = q_func()->currentSubWindow(); | - | ||||||||||||||||||
1019 | if (current && !isExplicitlyDeactivated(current)) {
| 0 | ||||||||||||||||||
1020 | current->d_func()->activationEnabled = true; | - | ||||||||||||||||||
1021 | current->d_func()->setActive(true, /*changeFocus=*/false); | - | ||||||||||||||||||
1022 | } never executed: end of block | 0 | ||||||||||||||||||
1023 | } never executed: end of block | 0 | ||||||||||||||||||
1024 | - | |||||||||||||||||||
1025 | void QMdiAreaPrivate::activateHighlightedWindow() | - | ||||||||||||||||||
1026 | { | - | ||||||||||||||||||
1027 | if (indexToHighlighted < 0)
| 0 | ||||||||||||||||||
1028 | return; never executed: return; | 0 | ||||||||||||||||||
1029 | - | |||||||||||||||||||
1030 | Q_ASSERT(indexToHighlighted < childWindows.size()); | - | ||||||||||||||||||
1031 | if (tabToPreviousTimerId != -1)
| 0 | ||||||||||||||||||
1032 | activateWindow(nextVisibleSubWindow(-1, QMdiArea::ActivationHistoryOrder)); never executed: activateWindow(nextVisibleSubWindow(-1, QMdiArea::ActivationHistoryOrder)); | 0 | ||||||||||||||||||
1033 | else | - | ||||||||||||||||||
1034 | activateWindow(childWindows.at(indexToHighlighted)); never executed: activateWindow(childWindows.at(indexToHighlighted)); | 0 | ||||||||||||||||||
1035 | #ifndef QT_NO_RUBBERBAND | - | ||||||||||||||||||
1036 | hideRubberBand(); | - | ||||||||||||||||||
1037 | #endif | - | ||||||||||||||||||
1038 | } never executed: end of block | 0 | ||||||||||||||||||
1039 | - | |||||||||||||||||||
1040 | /*! | - | ||||||||||||||||||
1041 | \internal | - | ||||||||||||||||||
1042 | */ | - | ||||||||||||||||||
1043 | void QMdiAreaPrivate::emitWindowActivated(QMdiSubWindow *activeWindow) | - | ||||||||||||||||||
1044 | { | - | ||||||||||||||||||
1045 | Q_Q(QMdiArea); | - | ||||||||||||||||||
1046 | Q_ASSERT(activeWindow); | - | ||||||||||||||||||
1047 | if (activeWindow == active)
| 0 | ||||||||||||||||||
1048 | return; never executed: return; | 0 | ||||||||||||||||||
1049 | Q_ASSERT(activeWindow->d_func()->isActive); | - | ||||||||||||||||||
1050 | - | |||||||||||||||||||
1051 | if (!aboutToBecomeActive)
| 0 | ||||||||||||||||||
1052 | _q_deactivateAllWindows(activeWindow); never executed: _q_deactivateAllWindows(activeWindow); | 0 | ||||||||||||||||||
1053 | Q_ASSERT(aboutToBecomeActive); | - | ||||||||||||||||||
1054 | - | |||||||||||||||||||
1055 | // This is true only if 'DontMaximizeSubWindowOnActivation' is disabled | - | ||||||||||||||||||
1056 | // and the previous active window was maximized. | - | ||||||||||||||||||
1057 | if (showActiveWindowMaximized) {
| 0 | ||||||||||||||||||
1058 | if (!activeWindow->isMaximized())
| 0 | ||||||||||||||||||
1059 | activeWindow->showMaximized(); never executed: activeWindow->showMaximized(); | 0 | ||||||||||||||||||
1060 | showActiveWindowMaximized = false; | - | ||||||||||||||||||
1061 | } never executed: end of block | 0 | ||||||||||||||||||
1062 | - | |||||||||||||||||||
1063 | // Put in front to update activation order. | - | ||||||||||||||||||
1064 | const int indexToActiveWindow = childWindows.indexOf(activeWindow); | - | ||||||||||||||||||
1065 | Q_ASSERT(indexToActiveWindow != -1); | - | ||||||||||||||||||
1066 | const int index = indicesToActivatedChildren.indexOf(indexToActiveWindow); | - | ||||||||||||||||||
1067 | Q_ASSERT(index != -1); | - | ||||||||||||||||||
1068 | indicesToActivatedChildren.move(index, 0); | - | ||||||||||||||||||
1069 | internalRaise(activeWindow); | - | ||||||||||||||||||
1070 | - | |||||||||||||||||||
1071 | if (updatesDisabledByUs) {
| 0 | ||||||||||||||||||
1072 | q->setUpdatesEnabled(true); | - | ||||||||||||||||||
1073 | updatesDisabledByUs = false; | - | ||||||||||||||||||
1074 | } never executed: end of block | 0 | ||||||||||||||||||
1075 | - | |||||||||||||||||||
1076 | Q_ASSERT(aboutToBecomeActive == activeWindow); | - | ||||||||||||||||||
1077 | active = activeWindow; | - | ||||||||||||||||||
1078 | aboutToBecomeActive = 0; | - | ||||||||||||||||||
1079 | Q_ASSERT(active->d_func()->isActive); | - | ||||||||||||||||||
1080 | - | |||||||||||||||||||
1081 | #ifndef QT_NO_TABBAR | - | ||||||||||||||||||
1082 | if (tabBar && tabBar->currentIndex() != indexToActiveWindow)
| 0 | ||||||||||||||||||
1083 | tabBar->setCurrentIndex(indexToActiveWindow); never executed: tabBar->setCurrentIndex(indexToActiveWindow); | 0 | ||||||||||||||||||
1084 | #endif | - | ||||||||||||||||||
1085 | - | |||||||||||||||||||
1086 | if (active->isMaximized() && scrollBarsEnabled())
| 0 | ||||||||||||||||||
1087 | updateScrollBars(); never executed: updateScrollBars(); | 0 | ||||||||||||||||||
1088 | - | |||||||||||||||||||
1089 | emit q->subWindowActivated(active); | - | ||||||||||||||||||
1090 | } never executed: end of block | 0 | ||||||||||||||||||
1091 | - | |||||||||||||||||||
1092 | /*! | - | ||||||||||||||||||
1093 | \internal | - | ||||||||||||||||||
1094 | */ | - | ||||||||||||||||||
1095 | void QMdiAreaPrivate::resetActiveWindow(QMdiSubWindow *deactivatedWindow) | - | ||||||||||||||||||
1096 | { | - | ||||||||||||||||||
1097 | Q_Q(QMdiArea); | - | ||||||||||||||||||
1098 | if (deactivatedWindow) {
| 0 | ||||||||||||||||||
1099 | if (deactivatedWindow != active)
| 0 | ||||||||||||||||||
1100 | return; never executed: return; | 0 | ||||||||||||||||||
1101 | active = 0; | - | ||||||||||||||||||
1102 | if ((aboutToBecomeActive || isActivated || lastWindowAboutToBeDestroyed())
| 0 | ||||||||||||||||||
1103 | && !isExplicitlyDeactivated(deactivatedWindow) && !q->window()->isMinimized()) {
| 0 | ||||||||||||||||||
1104 | return; never executed: return; | 0 | ||||||||||||||||||
1105 | } | - | ||||||||||||||||||
1106 | emit q->subWindowActivated(0); | - | ||||||||||||||||||
1107 | return; never executed: return; | 0 | ||||||||||||||||||
1108 | } | - | ||||||||||||||||||
1109 | - | |||||||||||||||||||
1110 | if (aboutToBecomeActive)
| 0 | ||||||||||||||||||
1111 | return; never executed: return; | 0 | ||||||||||||||||||
1112 | - | |||||||||||||||||||
1113 | active = 0; | - | ||||||||||||||||||
1114 | emit q->subWindowActivated(0); | - | ||||||||||||||||||
1115 | } never executed: end of block | 0 | ||||||||||||||||||
1116 | - | |||||||||||||||||||
1117 | /*! | - | ||||||||||||||||||
1118 | \internal | - | ||||||||||||||||||
1119 | */ | - | ||||||||||||||||||
1120 | void QMdiAreaPrivate::updateActiveWindow(int removedIndex, bool activeRemoved) | - | ||||||||||||||||||
1121 | { | - | ||||||||||||||||||
1122 | Q_ASSERT(indicesToActivatedChildren.size() == childWindows.size()); | - | ||||||||||||||||||
1123 | - | |||||||||||||||||||
1124 | #ifndef QT_NO_TABBAR | - | ||||||||||||||||||
1125 | if (tabBar && removedIndex >= 0) {
| 0 | ||||||||||||||||||
1126 | const QSignalBlocker blocker(tabBar); | - | ||||||||||||||||||
1127 | tabBar->removeTab(removedIndex); | - | ||||||||||||||||||
1128 | updateTabBarGeometry(); | - | ||||||||||||||||||
1129 | } never executed: end of block | 0 | ||||||||||||||||||
1130 | #endif | - | ||||||||||||||||||
1131 | - | |||||||||||||||||||
1132 | if (childWindows.isEmpty()) {
| 0 | ||||||||||||||||||
1133 | showActiveWindowMaximized = false; | - | ||||||||||||||||||
1134 | resetActiveWindow(); | - | ||||||||||||||||||
1135 | return; never executed: return; | 0 | ||||||||||||||||||
1136 | } | - | ||||||||||||||||||
1137 | - | |||||||||||||||||||
1138 | if (indexToHighlighted >= 0) {
| 0 | ||||||||||||||||||
1139 | #ifndef QT_NO_RUBBERBAND | - | ||||||||||||||||||
1140 | // Hide rubber band if highlighted window is removed. | - | ||||||||||||||||||
1141 | if (indexToHighlighted == removedIndex)
| 0 | ||||||||||||||||||
1142 | hideRubberBand(); never executed: hideRubberBand(); | 0 | ||||||||||||||||||
1143 | else | - | ||||||||||||||||||
1144 | #endif | - | ||||||||||||||||||
1145 | // or update index if necessary. | - | ||||||||||||||||||
1146 | if (indexToHighlighted > removedIndex)
| 0 | ||||||||||||||||||
1147 | --indexToHighlighted; never executed: --indexToHighlighted; | 0 | ||||||||||||||||||
1148 | } never executed: end of block | 0 | ||||||||||||||||||
1149 | - | |||||||||||||||||||
1150 | // Update indices list | - | ||||||||||||||||||
1151 | for (int i = 0; i < indicesToActivatedChildren.size(); ++i) {
| 0 | ||||||||||||||||||
1152 | int *index = &indicesToActivatedChildren[i]; | - | ||||||||||||||||||
1153 | if (*index > removedIndex)
| 0 | ||||||||||||||||||
1154 | --*index; never executed: --*index; | 0 | ||||||||||||||||||
1155 | } never executed: end of block | 0 | ||||||||||||||||||
1156 | - | |||||||||||||||||||
1157 | if (!activeRemoved)
| 0 | ||||||||||||||||||
1158 | return; never executed: return; | 0 | ||||||||||||||||||
1159 | - | |||||||||||||||||||
1160 | // Activate next window. | - | ||||||||||||||||||
1161 | QMdiSubWindow *next = nextVisibleSubWindow(0, activationOrder, removedIndex); | - | ||||||||||||||||||
1162 | if (next)
| 0 | ||||||||||||||||||
1163 | activateWindow(next); never executed: activateWindow(next); | 0 | ||||||||||||||||||
1164 | } never executed: end of block | 0 | ||||||||||||||||||
1165 | - | |||||||||||||||||||
1166 | /*! | - | ||||||||||||||||||
1167 | \internal | - | ||||||||||||||||||
1168 | */ | - | ||||||||||||||||||
1169 | void QMdiAreaPrivate::updateScrollBars() | - | ||||||||||||||||||
1170 | { | - | ||||||||||||||||||
1171 | if (ignoreGeometryChange || !scrollBarsEnabled())
| 0 | ||||||||||||||||||
1172 | return; never executed: return; | 0 | ||||||||||||||||||
1173 | - | |||||||||||||||||||
1174 | Q_Q(QMdiArea); | - | ||||||||||||||||||
1175 | QSize maxSize = q->maximumViewportSize(); | - | ||||||||||||||||||
1176 | QSize hbarExtent = hbar->sizeHint(); | - | ||||||||||||||||||
1177 | QSize vbarExtent = vbar->sizeHint(); | - | ||||||||||||||||||
1178 | - | |||||||||||||||||||
1179 | if (q->style()->styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents, 0, q)) {
| 0 | ||||||||||||||||||
1180 | const int doubleFrameWidth = frameWidth * 2; | - | ||||||||||||||||||
1181 | if (hbarpolicy == Qt::ScrollBarAlwaysOn)
| 0 | ||||||||||||||||||
1182 | maxSize.rheight() -= doubleFrameWidth; never executed: maxSize.rheight() -= doubleFrameWidth; | 0 | ||||||||||||||||||
1183 | if (vbarpolicy == Qt::ScrollBarAlwaysOn)
| 0 | ||||||||||||||||||
1184 | maxSize.rwidth() -= doubleFrameWidth; never executed: maxSize.rwidth() -= doubleFrameWidth; | 0 | ||||||||||||||||||
1185 | hbarExtent.rheight() += doubleFrameWidth; | - | ||||||||||||||||||
1186 | vbarExtent.rwidth() += doubleFrameWidth; | - | ||||||||||||||||||
1187 | } never executed: end of block | 0 | ||||||||||||||||||
1188 | - | |||||||||||||||||||
1189 | const QRect childrenRect = active && active->isMaximized()
| 0 | ||||||||||||||||||
1190 | ? active->geometry() : viewport->childrenRect(); | - | ||||||||||||||||||
1191 | bool useHorizontalScrollBar = useScrollBar(childrenRect, maxSize, Qt::Horizontal); | - | ||||||||||||||||||
1192 | bool useVerticalScrollBar = useScrollBar(childrenRect, maxSize, Qt::Vertical); | - | ||||||||||||||||||
1193 | - | |||||||||||||||||||
1194 | if (useHorizontalScrollBar && !useVerticalScrollBar) {
| 0 | ||||||||||||||||||
1195 | const QSize max = maxSize - QSize(0, hbarExtent.height()); | - | ||||||||||||||||||
1196 | useVerticalScrollBar = useScrollBar(childrenRect, max, Qt::Vertical); | - | ||||||||||||||||||
1197 | } never executed: end of block | 0 | ||||||||||||||||||
1198 | - | |||||||||||||||||||
1199 | if (useVerticalScrollBar && !useHorizontalScrollBar) {
| 0 | ||||||||||||||||||
1200 | const QSize max = maxSize - QSize(vbarExtent.width(), 0); | - | ||||||||||||||||||
1201 | useHorizontalScrollBar = useScrollBar(childrenRect, max, Qt::Horizontal); | - | ||||||||||||||||||
1202 | } never executed: end of block | 0 | ||||||||||||||||||
1203 | - | |||||||||||||||||||
1204 | if (useHorizontalScrollBar && hbarpolicy != Qt::ScrollBarAlwaysOn)
| 0 | ||||||||||||||||||
1205 | maxSize.rheight() -= hbarExtent.height(); never executed: maxSize.rheight() -= hbarExtent.height(); | 0 | ||||||||||||||||||
1206 | if (useVerticalScrollBar && vbarpolicy != Qt::ScrollBarAlwaysOn)
| 0 | ||||||||||||||||||
1207 | maxSize.rwidth() -= vbarExtent.width(); never executed: maxSize.rwidth() -= vbarExtent.width(); | 0 | ||||||||||||||||||
1208 | - | |||||||||||||||||||
1209 | QRect viewportRect(QPoint(0, 0), maxSize); | - | ||||||||||||||||||
1210 | const int startX = q->isLeftToRight() ? childrenRect.left() : viewportRect.right()
| 0 | ||||||||||||||||||
1211 | - childrenRect.right(); | - | ||||||||||||||||||
1212 | - | |||||||||||||||||||
1213 | // Horizontal scroll bar. | - | ||||||||||||||||||
1214 | if (isSubWindowsTiled && hbar->value() != 0)
| 0 | ||||||||||||||||||
1215 | hbar->setValue(0); never executed: hbar->setValue(0); | 0 | ||||||||||||||||||
1216 | const int xOffset = startX + hbar->value(); | - | ||||||||||||||||||
1217 | hbar->setRange(qMin(0, xOffset), | - | ||||||||||||||||||
1218 | qMax(0, xOffset + childrenRect.width() - viewportRect.width())); | - | ||||||||||||||||||
1219 | hbar->setPageStep(childrenRect.width()); | - | ||||||||||||||||||
1220 | hbar->setSingleStep(childrenRect.width() / 20); | - | ||||||||||||||||||
1221 | - | |||||||||||||||||||
1222 | // Vertical scroll bar. | - | ||||||||||||||||||
1223 | if (isSubWindowsTiled && vbar->value() != 0)
| 0 | ||||||||||||||||||
1224 | vbar->setValue(0); never executed: vbar->setValue(0); | 0 | ||||||||||||||||||
1225 | const int yOffset = childrenRect.top() + vbar->value(); | - | ||||||||||||||||||
1226 | vbar->setRange(qMin(0, yOffset), | - | ||||||||||||||||||
1227 | qMax(0, yOffset + childrenRect.height() - viewportRect.height())); | - | ||||||||||||||||||
1228 | vbar->setPageStep(childrenRect.height()); | - | ||||||||||||||||||
1229 | vbar->setSingleStep(childrenRect.height() / 20); | - | ||||||||||||||||||
1230 | } never executed: end of block | 0 | ||||||||||||||||||
1231 | - | |||||||||||||||||||
1232 | /*! | - | ||||||||||||||||||
1233 | \internal | - | ||||||||||||||||||
1234 | */ | - | ||||||||||||||||||
1235 | void QMdiAreaPrivate::internalRaise(QMdiSubWindow *mdiChild) const | - | ||||||||||||||||||
1236 | { | - | ||||||||||||||||||
1237 | if (!sanityCheck(mdiChild, "QMdiArea::internalRaise") || childWindows.size() < 2)
| 0 | ||||||||||||||||||
1238 | return; never executed: return; | 0 | ||||||||||||||||||
1239 | - | |||||||||||||||||||
1240 | QMdiSubWindow *stackUnderChild = 0; | - | ||||||||||||||||||
1241 | if (!windowStaysOnTop(mdiChild)) {
| 0 | ||||||||||||||||||
1242 | foreach (QObject *object, viewport->children()) { | - | ||||||||||||||||||
1243 | QMdiSubWindow *child = qobject_cast<QMdiSubWindow *>(object); | - | ||||||||||||||||||
1244 | if (!child || !childWindows.contains(child))
| 0 | ||||||||||||||||||
1245 | continue; never executed: continue; | 0 | ||||||||||||||||||
1246 | if (!child->isHidden() && windowStaysOnTop(child)) {
| 0 | ||||||||||||||||||
1247 | if (stackUnderChild)
| 0 | ||||||||||||||||||
1248 | child->stackUnder(stackUnderChild); never executed: child->stackUnder(stackUnderChild); | 0 | ||||||||||||||||||
1249 | else | - | ||||||||||||||||||
1250 | child->raise(); never executed: child->raise(); | 0 | ||||||||||||||||||
1251 | stackUnderChild = child; | - | ||||||||||||||||||
1252 | } never executed: end of block | 0 | ||||||||||||||||||
1253 | } never executed: end of block | 0 | ||||||||||||||||||
1254 | } never executed: end of block | 0 | ||||||||||||||||||
1255 | - | |||||||||||||||||||
1256 | if (stackUnderChild)
| 0 | ||||||||||||||||||
1257 | mdiChild->stackUnder(stackUnderChild); never executed: mdiChild->stackUnder(stackUnderChild); | 0 | ||||||||||||||||||
1258 | else | - | ||||||||||||||||||
1259 | mdiChild->raise(); never executed: mdiChild->raise(); | 0 | ||||||||||||||||||
1260 | } | - | ||||||||||||||||||
1261 | - | |||||||||||||||||||
1262 | QRect QMdiAreaPrivate::resizeToMinimumTileSize(const QSize &minSubWindowSize, int subWindowCount) | - | ||||||||||||||||||
1263 | { | - | ||||||||||||||||||
1264 | Q_Q(QMdiArea); | - | ||||||||||||||||||
1265 | if (!minSubWindowSize.isValid() || subWindowCount <= 0)
| 0 | ||||||||||||||||||
1266 | return viewport->rect(); never executed: return viewport->rect(); | 0 | ||||||||||||||||||
1267 | - | |||||||||||||||||||
1268 | // Calculate minimum size. | - | ||||||||||||||||||
1269 | const int columns = qMax(qCeil(qSqrt(qreal(subWindowCount))), 1); | - | ||||||||||||||||||
1270 | const int rows = qMax((subWindowCount % columns) ? (subWindowCount / columns + 1) | - | ||||||||||||||||||
1271 | : (subWindowCount / columns), 1); | - | ||||||||||||||||||
1272 | const int minWidth = minSubWindowSize.width() * columns; | - | ||||||||||||||||||
1273 | const int minHeight = minSubWindowSize.height() * rows; | - | ||||||||||||||||||
1274 | - | |||||||||||||||||||
1275 | // Increase area size if necessary. Scroll bars are provided if we're not able | - | ||||||||||||||||||
1276 | // to resize to the minimum size. | - | ||||||||||||||||||
1277 | if (!tileCalledFromResizeEvent) {
| 0 | ||||||||||||||||||
1278 | QWidget *topLevel = q; | - | ||||||||||||||||||
1279 | // Find the topLevel for this area, either a real top-level or a sub-window. | - | ||||||||||||||||||
1280 | while (topLevel && !topLevel->isWindow() && topLevel->windowType() != Qt::SubWindow)
| 0 | ||||||||||||||||||
1281 | topLevel = topLevel->parentWidget(); never executed: topLevel = topLevel->parentWidget(); | 0 | ||||||||||||||||||
1282 | // We don't want sub-subwindows to be placed at the edge, thus add 2 pixels. | - | ||||||||||||||||||
1283 | int minAreaWidth = minWidth + left + right + 2; | - | ||||||||||||||||||
1284 | int minAreaHeight = minHeight + top + bottom + 2; | - | ||||||||||||||||||
1285 | if (hbar->isVisible())
| 0 | ||||||||||||||||||
1286 | minAreaHeight += hbar->height(); never executed: minAreaHeight += hbar->height(); | 0 | ||||||||||||||||||
1287 | if (vbar->isVisible())
| 0 | ||||||||||||||||||
1288 | minAreaWidth += vbar->width(); never executed: minAreaWidth += vbar->width(); | 0 | ||||||||||||||||||
1289 | if (q->style()->styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents, 0, q)) {
| 0 | ||||||||||||||||||
1290 | const int frame = q->style()->pixelMetric(QStyle::PM_DefaultFrameWidth, 0, q); | - | ||||||||||||||||||
1291 | minAreaWidth += 2 * frame; | - | ||||||||||||||||||
1292 | minAreaHeight += 2 * frame; | - | ||||||||||||||||||
1293 | } never executed: end of block | 0 | ||||||||||||||||||
1294 | const QSize diff = QSize(minAreaWidth, minAreaHeight).expandedTo(q->size()) - q->size(); | - | ||||||||||||||||||
1295 | topLevel->resize(topLevel->size() + diff); | - | ||||||||||||||||||
1296 | } never executed: end of block | 0 | ||||||||||||||||||
1297 | - | |||||||||||||||||||
1298 | QRect domain = viewport->rect(); | - | ||||||||||||||||||
1299 | - | |||||||||||||||||||
1300 | // Adjust domain width and provide horizontal scroll bar. | - | ||||||||||||||||||
1301 | if (domain.width() < minWidth) {
| 0 | ||||||||||||||||||
1302 | domain.setWidth(minWidth); | - | ||||||||||||||||||
1303 | if (hbarpolicy == Qt::ScrollBarAlwaysOff)
| 0 | ||||||||||||||||||
1304 | q->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); never executed: q->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); | 0 | ||||||||||||||||||
1305 | else | - | ||||||||||||||||||
1306 | hbar->setValue(0); never executed: hbar->setValue(0); | 0 | ||||||||||||||||||
1307 | } | - | ||||||||||||||||||
1308 | // Adjust domain height and provide vertical scroll bar. | - | ||||||||||||||||||
1309 | if (domain.height() < minHeight) {
| 0 | ||||||||||||||||||
1310 | domain.setHeight(minHeight); | - | ||||||||||||||||||
1311 | if (vbarpolicy == Qt::ScrollBarAlwaysOff)
| 0 | ||||||||||||||||||
1312 | q->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); never executed: q->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); | 0 | ||||||||||||||||||
1313 | else | - | ||||||||||||||||||
1314 | vbar->setValue(0); never executed: vbar->setValue(0); | 0 | ||||||||||||||||||
1315 | } | - | ||||||||||||||||||
1316 | return domain; never executed: return domain; | 0 | ||||||||||||||||||
1317 | } | - | ||||||||||||||||||
1318 | - | |||||||||||||||||||
1319 | /*! | - | ||||||||||||||||||
1320 | \internal | - | ||||||||||||||||||
1321 | */ | - | ||||||||||||||||||
1322 | bool QMdiAreaPrivate::scrollBarsEnabled() const | - | ||||||||||||||||||
1323 | { | - | ||||||||||||||||||
1324 | return hbarpolicy != Qt::ScrollBarAlwaysOff || vbarpolicy != Qt::ScrollBarAlwaysOff; never executed: return hbarpolicy != Qt::ScrollBarAlwaysOff || vbarpolicy != Qt::ScrollBarAlwaysOff;
| 0 | ||||||||||||||||||
1325 | } | - | ||||||||||||||||||
1326 | - | |||||||||||||||||||
1327 | /*! | - | ||||||||||||||||||
1328 | \internal | - | ||||||||||||||||||
1329 | */ | - | ||||||||||||||||||
1330 | bool QMdiAreaPrivate::lastWindowAboutToBeDestroyed() const | - | ||||||||||||||||||
1331 | { | - | ||||||||||||||||||
1332 | if (childWindows.count() != 1)
| 0 | ||||||||||||||||||
1333 | return false; never executed: return false; | 0 | ||||||||||||||||||
1334 | - | |||||||||||||||||||
1335 | QMdiSubWindow *last = childWindows.at(0); | - | ||||||||||||||||||
1336 | if (!last)
| 0 | ||||||||||||||||||
1337 | return true; never executed: return true; | 0 | ||||||||||||||||||
1338 | - | |||||||||||||||||||
1339 | if (!last->testAttribute(Qt::WA_DeleteOnClose))
| 0 | ||||||||||||||||||
1340 | return false; never executed: return false; | 0 | ||||||||||||||||||
1341 | - | |||||||||||||||||||
1342 | return last->d_func()->data.is_closing; never executed: return last->d_func()->data.is_closing; | 0 | ||||||||||||||||||
1343 | } | - | ||||||||||||||||||
1344 | - | |||||||||||||||||||
1345 | /*! | - | ||||||||||||||||||
1346 | \internal | - | ||||||||||||||||||
1347 | */ | - | ||||||||||||||||||
1348 | void QMdiAreaPrivate::setChildActivationEnabled(bool enable, bool onlyNextActivationEvent) const | - | ||||||||||||||||||
1349 | { | - | ||||||||||||||||||
1350 | foreach (QMdiSubWindow *subWindow, childWindows) { | - | ||||||||||||||||||
1351 | if (!subWindow || !subWindow->isVisible())
| 0 | ||||||||||||||||||
1352 | continue; never executed: continue; | 0 | ||||||||||||||||||
1353 | if (onlyNextActivationEvent)
| 0 | ||||||||||||||||||
1354 | subWindow->d_func()->ignoreNextActivationEvent = !enable; never executed: subWindow->d_func()->ignoreNextActivationEvent = !enable; | 0 | ||||||||||||||||||
1355 | else | - | ||||||||||||||||||
1356 | subWindow->d_func()->activationEnabled = enable; never executed: subWindow->d_func()->activationEnabled = enable; | 0 | ||||||||||||||||||
1357 | } | - | ||||||||||||||||||
1358 | } never executed: end of block | 0 | ||||||||||||||||||
1359 | - | |||||||||||||||||||
1360 | /*! | - | ||||||||||||||||||
1361 | \internal | - | ||||||||||||||||||
1362 | \reimp | - | ||||||||||||||||||
1363 | */ | - | ||||||||||||||||||
1364 | void QMdiAreaPrivate::scrollBarPolicyChanged(Qt::Orientation orientation, Qt::ScrollBarPolicy policy) | - | ||||||||||||||||||
1365 | { | - | ||||||||||||||||||
1366 | if (childWindows.isEmpty())
| 0 | ||||||||||||||||||
1367 | return; never executed: return; | 0 | ||||||||||||||||||
1368 | - | |||||||||||||||||||
1369 | const QMdiSubWindow::SubWindowOption option = orientation == Qt::Horizontal ?
| 0 | ||||||||||||||||||
1370 | QMdiSubWindow::AllowOutsideAreaHorizontally : QMdiSubWindow::AllowOutsideAreaVertically; | - | ||||||||||||||||||
1371 | const bool enable = policy != Qt::ScrollBarAlwaysOff; | - | ||||||||||||||||||
1372 | foreach (QMdiSubWindow *child, childWindows) { | - | ||||||||||||||||||
1373 | if (!sanityCheck(child, "QMdiArea::scrollBarPolicyChanged"))
| 0 | ||||||||||||||||||
1374 | continue; never executed: continue; | 0 | ||||||||||||||||||
1375 | child->setOption(option, enable); | - | ||||||||||||||||||
1376 | } never executed: end of block | 0 | ||||||||||||||||||
1377 | updateScrollBars(); | - | ||||||||||||||||||
1378 | } never executed: end of block | 0 | ||||||||||||||||||
1379 | - | |||||||||||||||||||
1380 | QList<QMdiSubWindow*> | - | ||||||||||||||||||
1381 | QMdiAreaPrivate::subWindowList(QMdiArea::WindowOrder order, bool reversed) const | - | ||||||||||||||||||
1382 | { | - | ||||||||||||||||||
1383 | QList<QMdiSubWindow *> list; | - | ||||||||||||||||||
1384 | if (childWindows.isEmpty())
| 0 | ||||||||||||||||||
1385 | return list; never executed: return list; | 0 | ||||||||||||||||||
1386 | - | |||||||||||||||||||
1387 | if (order == QMdiArea::CreationOrder) {
| 0 | ||||||||||||||||||
1388 | foreach (QMdiSubWindow *child, childWindows) { | - | ||||||||||||||||||
1389 | if (!child)
| 0 | ||||||||||||||||||
1390 | continue; never executed: continue; | 0 | ||||||||||||||||||
1391 | if (!reversed)
| 0 | ||||||||||||||||||
1392 | list.append(child); never executed: list.append(child); | 0 | ||||||||||||||||||
1393 | else | - | ||||||||||||||||||
1394 | list.prepend(child); never executed: list.prepend(child); | 0 | ||||||||||||||||||
1395 | } | - | ||||||||||||||||||
1396 | } else if (order == QMdiArea::StackingOrder) { never executed: end of block
| 0 | ||||||||||||||||||
1397 | foreach (QObject *object, viewport->children()) { | - | ||||||||||||||||||
1398 | QMdiSubWindow *child = qobject_cast<QMdiSubWindow *>(object); | - | ||||||||||||||||||
1399 | if (!child || !childWindows.contains(child))
| 0 | ||||||||||||||||||
1400 | continue; never executed: continue; | 0 | ||||||||||||||||||
1401 | if (!reversed)
| 0 | ||||||||||||||||||
1402 | list.append(child); never executed: list.append(child); | 0 | ||||||||||||||||||
1403 | else | - | ||||||||||||||||||
1404 | list.prepend(child); never executed: list.prepend(child); | 0 | ||||||||||||||||||
1405 | } | - | ||||||||||||||||||
1406 | } else { // ActivationHistoryOrder never executed: end of block | 0 | ||||||||||||||||||
1407 | Q_ASSERT(indicesToActivatedChildren.size() == childWindows.size()); | - | ||||||||||||||||||
1408 | for (int i = indicesToActivatedChildren.count() - 1; i >= 0; --i) {
| 0 | ||||||||||||||||||
1409 | QMdiSubWindow *child = childWindows.at(indicesToActivatedChildren.at(i)); | - | ||||||||||||||||||
1410 | if (!child)
| 0 | ||||||||||||||||||
1411 | continue; never executed: continue; | 0 | ||||||||||||||||||
1412 | if (!reversed)
| 0 | ||||||||||||||||||
1413 | list.append(child); never executed: list.append(child); | 0 | ||||||||||||||||||
1414 | else | - | ||||||||||||||||||
1415 | list.prepend(child); never executed: list.prepend(child); | 0 | ||||||||||||||||||
1416 | } | - | ||||||||||||||||||
1417 | } never executed: end of block | 0 | ||||||||||||||||||
1418 | return list; never executed: return list; | 0 | ||||||||||||||||||
1419 | } | - | ||||||||||||||||||
1420 | - | |||||||||||||||||||
1421 | /*! | - | ||||||||||||||||||
1422 | \internal | - | ||||||||||||||||||
1423 | */ | - | ||||||||||||||||||
1424 | void QMdiAreaPrivate::disconnectSubWindow(QObject *subWindow) | - | ||||||||||||||||||
1425 | { | - | ||||||||||||||||||
1426 | if (!subWindow)
| 0 | ||||||||||||||||||
1427 | return; never executed: return; | 0 | ||||||||||||||||||
1428 | - | |||||||||||||||||||
1429 | Q_Q(QMdiArea); | - | ||||||||||||||||||
1430 | QObject::disconnect(subWindow, 0, q, 0); | - | ||||||||||||||||||
1431 | subWindow->removeEventFilter(q); | - | ||||||||||||||||||
1432 | } never executed: end of block | 0 | ||||||||||||||||||
1433 | - | |||||||||||||||||||
1434 | /*! | - | ||||||||||||||||||
1435 | \internal | - | ||||||||||||||||||
1436 | */ | - | ||||||||||||||||||
1437 | QMdiSubWindow *QMdiAreaPrivate::nextVisibleSubWindow(int increaseFactor, QMdiArea::WindowOrder order, | - | ||||||||||||||||||
1438 | int removedIndex, int fromIndex) const | - | ||||||||||||||||||
1439 | { | - | ||||||||||||||||||
1440 | if (childWindows.isEmpty())
| 0 | ||||||||||||||||||
1441 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
1442 | - | |||||||||||||||||||
1443 | Q_Q(const QMdiArea); | - | ||||||||||||||||||
1444 | const QList<QMdiSubWindow *> subWindows = q->subWindowList(order); | - | ||||||||||||||||||
1445 | QMdiSubWindow *current = 0; | - | ||||||||||||||||||
1446 | - | |||||||||||||||||||
1447 | if (removedIndex < 0) {
| 0 | ||||||||||||||||||
1448 | if (fromIndex >= 0 && fromIndex < subWindows.size())
| 0 | ||||||||||||||||||
1449 | current = childWindows.at(fromIndex); never executed: current = childWindows.at(fromIndex); | 0 | ||||||||||||||||||
1450 | else | - | ||||||||||||||||||
1451 | current = q->currentSubWindow(); never executed: current = q->currentSubWindow(); | 0 | ||||||||||||||||||
1452 | } | - | ||||||||||||||||||
1453 | - | |||||||||||||||||||
1454 | // There's no current sub-window (removed or deactivated), | - | ||||||||||||||||||
1455 | // so we have to pick the last active or the next in creation order. | - | ||||||||||||||||||
1456 | if (!current) {
| 0 | ||||||||||||||||||
1457 | if (removedIndex >= 0 && order == QMdiArea::CreationOrder) {
| 0 | ||||||||||||||||||
1458 | int candidateIndex = -1; | - | ||||||||||||||||||
1459 | setIndex(&candidateIndex, removedIndex, 0, subWindows.size() - 1, true); | - | ||||||||||||||||||
1460 | current = childWindows.at(candidateIndex); | - | ||||||||||||||||||
1461 | } else { never executed: end of block | 0 | ||||||||||||||||||
1462 | current = subWindows.back(); | - | ||||||||||||||||||
1463 | } never executed: end of block | 0 | ||||||||||||||||||
1464 | } | - | ||||||||||||||||||
1465 | Q_ASSERT(current); | - | ||||||||||||||||||
1466 | - | |||||||||||||||||||
1467 | // Find the index for the current sub-window in the given activation order | - | ||||||||||||||||||
1468 | const int indexToCurrent = subWindows.indexOf(current); | - | ||||||||||||||||||
1469 | const bool increasing = increaseFactor > 0; | - | ||||||||||||||||||
1470 | - | |||||||||||||||||||
1471 | // and use that index + increseFactor as a candidate. | - | ||||||||||||||||||
1472 | int index = -1; | - | ||||||||||||||||||
1473 | setIndex(&index, indexToCurrent + increaseFactor, 0, subWindows.size() - 1, increasing); | - | ||||||||||||||||||
1474 | Q_ASSERT(index != -1); | - | ||||||||||||||||||
1475 | - | |||||||||||||||||||
1476 | // Try to find another window if the candidate is hidden. | - | ||||||||||||||||||
1477 | while (subWindows.at(index)->isHidden()) {
| 0 | ||||||||||||||||||
1478 | setIndex(&index, index + increaseFactor, 0, subWindows.size() - 1, increasing); | - | ||||||||||||||||||
1479 | if (index == indexToCurrent)
| 0 | ||||||||||||||||||
1480 | break; never executed: break; | 0 | ||||||||||||||||||
1481 | } never executed: end of block | 0 | ||||||||||||||||||
1482 | - | |||||||||||||||||||
1483 | if (!subWindows.at(index)->isHidden())
| 0 | ||||||||||||||||||
1484 | return subWindows.at(index); never executed: return subWindows.at(index); | 0 | ||||||||||||||||||
1485 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
1486 | } | - | ||||||||||||||||||
1487 | - | |||||||||||||||||||
1488 | /*! | - | ||||||||||||||||||
1489 | \internal | - | ||||||||||||||||||
1490 | */ | - | ||||||||||||||||||
1491 | void QMdiAreaPrivate::highlightNextSubWindow(int increaseFactor) | - | ||||||||||||||||||
1492 | { | - | ||||||||||||||||||
1493 | if (childWindows.size() == 1)
| 0 | ||||||||||||||||||
1494 | return; never executed: return; | 0 | ||||||||||||||||||
1495 | - | |||||||||||||||||||
1496 | Q_Q(QMdiArea); | - | ||||||||||||||||||
1497 | // There's no highlighted sub-window atm, use current. | - | ||||||||||||||||||
1498 | if (indexToHighlighted < 0) {
| 0 | ||||||||||||||||||
1499 | QMdiSubWindow *current = q->currentSubWindow(); | - | ||||||||||||||||||
1500 | if (!current)
| 0 | ||||||||||||||||||
1501 | return; never executed: return; | 0 | ||||||||||||||||||
1502 | indexToHighlighted = childWindows.indexOf(current); | - | ||||||||||||||||||
1503 | } never executed: end of block | 0 | ||||||||||||||||||
1504 | - | |||||||||||||||||||
1505 | Q_ASSERT(indexToHighlighted >= 0); | - | ||||||||||||||||||
1506 | Q_ASSERT(indexToHighlighted < childWindows.size()); | - | ||||||||||||||||||
1507 | - | |||||||||||||||||||
1508 | QMdiSubWindow *highlight = nextVisibleSubWindow(increaseFactor, activationOrder, -1, indexToHighlighted); | - | ||||||||||||||||||
1509 | if (!highlight)
| 0 | ||||||||||||||||||
1510 | return; never executed: return; | 0 | ||||||||||||||||||
1511 | - | |||||||||||||||||||
1512 | #ifndef QT_NO_RUBBERBAND | - | ||||||||||||||||||
1513 | if (!rubberBand) {
| 0 | ||||||||||||||||||
1514 | rubberBand = new QRubberBand(QRubberBand::Rectangle, q); | - | ||||||||||||||||||
1515 | // For accessibility to identify this special widget. | - | ||||||||||||||||||
1516 | rubberBand->setObjectName(QLatin1String("qt_rubberband")); | - | ||||||||||||||||||
1517 | rubberBand->setWindowFlags(rubberBand->windowFlags() | Qt::WindowStaysOnTopHint); | - | ||||||||||||||||||
1518 | } never executed: end of block | 0 | ||||||||||||||||||
1519 | #endif | - | ||||||||||||||||||
1520 | - | |||||||||||||||||||
1521 | // Only highlight if we're not switching back to the previously active window (Ctrl-Tab once). | - | ||||||||||||||||||
1522 | #ifndef QT_NO_RUBBERBAND | - | ||||||||||||||||||
1523 | if (tabToPreviousTimerId == -1)
| 0 | ||||||||||||||||||
1524 | showRubberBandFor(highlight); never executed: showRubberBandFor(highlight); | 0 | ||||||||||||||||||
1525 | #endif | - | ||||||||||||||||||
1526 | - | |||||||||||||||||||
1527 | indexToHighlighted = childWindows.indexOf(highlight); | - | ||||||||||||||||||
1528 | Q_ASSERT(indexToHighlighted >= 0); | - | ||||||||||||||||||
1529 | } never executed: end of block | 0 | ||||||||||||||||||
1530 | - | |||||||||||||||||||
1531 | void QMdiAreaPrivate::showRubberBandFor(QMdiSubWindow *subWindow) | - | ||||||||||||||||||
1532 | { | - | ||||||||||||||||||
1533 | if (!subWindow || !rubberBand)
| 0 | ||||||||||||||||||
1534 | return; never executed: return; | 0 | ||||||||||||||||||
1535 | - | |||||||||||||||||||
1536 | if (viewMode == QMdiArea::TabbedView)
| 0 | ||||||||||||||||||
1537 | rubberBand->setGeometry(tabBar->tabRect(childWindows.indexOf(subWindow))); never executed: rubberBand->setGeometry(tabBar->tabRect(childWindows.indexOf(subWindow))); | 0 | ||||||||||||||||||
1538 | else | - | ||||||||||||||||||
1539 | rubberBand->setGeometry(subWindow->geometry()); never executed: rubberBand->setGeometry(subWindow->geometry()); | 0 | ||||||||||||||||||
1540 | - | |||||||||||||||||||
1541 | rubberBand->raise(); | - | ||||||||||||||||||
1542 | rubberBand->show(); | - | ||||||||||||||||||
1543 | } never executed: end of block | 0 | ||||||||||||||||||
1544 | - | |||||||||||||||||||
1545 | /*! | - | ||||||||||||||||||
1546 | \internal | - | ||||||||||||||||||
1547 | \since 4.4 | - | ||||||||||||||||||
1548 | */ | - | ||||||||||||||||||
1549 | void QMdiAreaPrivate::setViewMode(QMdiArea::ViewMode mode) | - | ||||||||||||||||||
1550 | { | - | ||||||||||||||||||
1551 | Q_Q(QMdiArea); | - | ||||||||||||||||||
1552 | if (viewMode == mode || inViewModeChange)
| 0 | ||||||||||||||||||
1553 | return; never executed: return; | 0 | ||||||||||||||||||
1554 | - | |||||||||||||||||||
1555 | // Just a guard since we cannot set viewMode = mode here. | - | ||||||||||||||||||
1556 | inViewModeChange = true; | - | ||||||||||||||||||
1557 | - | |||||||||||||||||||
1558 | #ifndef QT_NO_TABBAR | - | ||||||||||||||||||
1559 | if (mode == QMdiArea::TabbedView) {
| 0 | ||||||||||||||||||
1560 | Q_ASSERT(!tabBar); | - | ||||||||||||||||||
1561 | tabBar = new QMdiAreaTabBar(q); | - | ||||||||||||||||||
1562 | tabBar->setDocumentMode(documentMode); | - | ||||||||||||||||||
1563 | tabBar->setTabsClosable(tabsClosable); | - | ||||||||||||||||||
1564 | tabBar->setMovable(tabsMovable); | - | ||||||||||||||||||
1565 | #ifndef QT_NO_TABWIDGET | - | ||||||||||||||||||
1566 | tabBar->setShape(tabBarShapeFrom(tabShape, tabPosition)); | - | ||||||||||||||||||
1567 | #endif | - | ||||||||||||||||||
1568 | - | |||||||||||||||||||
1569 | isSubWindowsTiled = false; | - | ||||||||||||||||||
1570 | - | |||||||||||||||||||
1571 | foreach (QMdiSubWindow *subWindow, childWindows) | - | ||||||||||||||||||
1572 | tabBar->addTab(subWindow->windowIcon(), tabTextFor(subWindow)); never executed: tabBar->addTab(subWindow->windowIcon(), tabTextFor(subWindow)); | 0 | ||||||||||||||||||
1573 | - | |||||||||||||||||||
1574 | QMdiSubWindow *current = q->currentSubWindow(); | - | ||||||||||||||||||
1575 | if (current) {
| 0 | ||||||||||||||||||
1576 | tabBar->setCurrentIndex(childWindows.indexOf(current)); | - | ||||||||||||||||||
1577 | // Restore sub-window (i.e. cleanup buttons in menu bar and window title). | - | ||||||||||||||||||
1578 | if (current->isMaximized())
| 0 | ||||||||||||||||||
1579 | current->showNormal(); never executed: current->showNormal(); | 0 | ||||||||||||||||||
1580 | - | |||||||||||||||||||
1581 | viewMode = mode; | - | ||||||||||||||||||
1582 | - | |||||||||||||||||||
1583 | // Now, maximize it. | - | ||||||||||||||||||
1584 | if (!q->testOption(QMdiArea::DontMaximizeSubWindowOnActivation)) {
| 0 | ||||||||||||||||||
1585 | current->showMaximized(); | - | ||||||||||||||||||
1586 | } never executed: end of block | 0 | ||||||||||||||||||
1587 | } else { never executed: end of block | 0 | ||||||||||||||||||
1588 | viewMode = mode; | - | ||||||||||||||||||
1589 | } never executed: end of block | 0 | ||||||||||||||||||
1590 | - | |||||||||||||||||||
1591 | if (q->isVisible())
| 0 | ||||||||||||||||||
1592 | tabBar->show(); never executed: tabBar->show(); | 0 | ||||||||||||||||||
1593 | updateTabBarGeometry(); | - | ||||||||||||||||||
1594 | - | |||||||||||||||||||
1595 | QObject::connect(tabBar, SIGNAL(currentChanged(int)), q, SLOT(_q_currentTabChanged(int))); | - | ||||||||||||||||||
1596 | QObject::connect(tabBar, SIGNAL(tabCloseRequested(int)), q, SLOT(_q_closeTab(int))); | - | ||||||||||||||||||
1597 | QObject::connect(tabBar, SIGNAL(tabMoved(int,int)), q, SLOT(_q_moveTab(int,int))); | - | ||||||||||||||||||
1598 | } else never executed: end of block | 0 | ||||||||||||||||||
1599 | #endif // QT_NO_TABBAR | - | ||||||||||||||||||
1600 | { // SubWindowView | - | ||||||||||||||||||
1601 | #ifndef QT_NO_TABBAR | - | ||||||||||||||||||
1602 | delete tabBar; | - | ||||||||||||||||||
1603 | tabBar = 0; | - | ||||||||||||||||||
1604 | #endif // QT_NO_TABBAR | - | ||||||||||||||||||
1605 | - | |||||||||||||||||||
1606 | viewMode = mode; | - | ||||||||||||||||||
1607 | q->setViewportMargins(0, 0, 0, 0); | - | ||||||||||||||||||
1608 | indexToLastActiveTab = -1; | - | ||||||||||||||||||
1609 | - | |||||||||||||||||||
1610 | QMdiSubWindow *current = q->currentSubWindow(); | - | ||||||||||||||||||
1611 | if (current && current->isMaximized())
| 0 | ||||||||||||||||||
1612 | current->showNormal(); never executed: current->showNormal(); | 0 | ||||||||||||||||||
1613 | } never executed: end of block | 0 | ||||||||||||||||||
1614 | - | |||||||||||||||||||
1615 | Q_ASSERT(viewMode == mode); | - | ||||||||||||||||||
1616 | inViewModeChange = false; | - | ||||||||||||||||||
1617 | } never executed: end of block | 0 | ||||||||||||||||||
1618 | - | |||||||||||||||||||
1619 | #ifndef QT_NO_TABBAR | - | ||||||||||||||||||
1620 | /*! | - | ||||||||||||||||||
1621 | \internal | - | ||||||||||||||||||
1622 | */ | - | ||||||||||||||||||
1623 | void QMdiAreaPrivate::updateTabBarGeometry() | - | ||||||||||||||||||
1624 | { | - | ||||||||||||||||||
1625 | if (!tabBar)
| 0 | ||||||||||||||||||
1626 | return; never executed: return; | 0 | ||||||||||||||||||
1627 | - | |||||||||||||||||||
1628 | Q_Q(QMdiArea); | - | ||||||||||||||||||
1629 | #ifndef QT_NO_TABWIDGET | - | ||||||||||||||||||
1630 | Q_ASSERT(tabBarShapeFrom(tabShape, tabPosition) == tabBar->shape()); | - | ||||||||||||||||||
1631 | #endif | - | ||||||||||||||||||
1632 | const QSize tabBarSizeHint = tabBar->sizeHint(); | - | ||||||||||||||||||
1633 | - | |||||||||||||||||||
1634 | int areaHeight = q->height(); | - | ||||||||||||||||||
1635 | if (hbar && hbar->isVisible())
| 0 | ||||||||||||||||||
1636 | areaHeight -= hbar->height(); never executed: areaHeight -= hbar->height(); | 0 | ||||||||||||||||||
1637 | - | |||||||||||||||||||
1638 | int areaWidth = q->width(); | - | ||||||||||||||||||
1639 | if (vbar && vbar->isVisible())
| 0 | ||||||||||||||||||
1640 | areaWidth -= vbar->width(); never executed: areaWidth -= vbar->width(); | 0 | ||||||||||||||||||
1641 | - | |||||||||||||||||||
1642 | QRect tabBarRect; | - | ||||||||||||||||||
1643 | #ifndef QT_NO_TABWIDGET | - | ||||||||||||||||||
1644 | switch (tabPosition) { | - | ||||||||||||||||||
1645 | case QTabWidget::North: never executed: case QTabWidget::North: | 0 | ||||||||||||||||||
1646 | q->setViewportMargins(0, tabBarSizeHint.height(), 0, 0); | - | ||||||||||||||||||
1647 | tabBarRect = QRect(0, 0, areaWidth, tabBarSizeHint.height()); | - | ||||||||||||||||||
1648 | break; never executed: break; | 0 | ||||||||||||||||||
1649 | case QTabWidget::South: never executed: case QTabWidget::South: | 0 | ||||||||||||||||||
1650 | q->setViewportMargins(0, 0, 0, tabBarSizeHint.height()); | - | ||||||||||||||||||
1651 | tabBarRect = QRect(0, areaHeight - tabBarSizeHint.height(), areaWidth, tabBarSizeHint.height()); | - | ||||||||||||||||||
1652 | break; never executed: break; | 0 | ||||||||||||||||||
1653 | case QTabWidget::East: never executed: case QTabWidget::East: | 0 | ||||||||||||||||||
1654 | if (q->layoutDirection() == Qt::LeftToRight)
| 0 | ||||||||||||||||||
1655 | q->setViewportMargins(0, 0, tabBarSizeHint.width(), 0); never executed: q->setViewportMargins(0, 0, tabBarSizeHint.width(), 0); | 0 | ||||||||||||||||||
1656 | else | - | ||||||||||||||||||
1657 | q->setViewportMargins(tabBarSizeHint.width(), 0, 0, 0); never executed: q->setViewportMargins(tabBarSizeHint.width(), 0, 0, 0); | 0 | ||||||||||||||||||
1658 | tabBarRect = QRect(areaWidth - tabBarSizeHint.width(), 0, tabBarSizeHint.width(), areaHeight); | - | ||||||||||||||||||
1659 | break; never executed: break; | 0 | ||||||||||||||||||
1660 | case QTabWidget::West: never executed: case QTabWidget::West: | 0 | ||||||||||||||||||
1661 | if (q->layoutDirection() == Qt::LeftToRight)
| 0 | ||||||||||||||||||
1662 | q->setViewportMargins(tabBarSizeHint.width(), 0, 0, 0); never executed: q->setViewportMargins(tabBarSizeHint.width(), 0, 0, 0); | 0 | ||||||||||||||||||
1663 | else | - | ||||||||||||||||||
1664 | q->setViewportMargins(0, 0, tabBarSizeHint.width(), 0); never executed: q->setViewportMargins(0, 0, tabBarSizeHint.width(), 0); | 0 | ||||||||||||||||||
1665 | tabBarRect = QRect(0, 0, tabBarSizeHint.width(), areaHeight); | - | ||||||||||||||||||
1666 | break; never executed: break; | 0 | ||||||||||||||||||
1667 | default: never executed: default: | 0 | ||||||||||||||||||
1668 | break; never executed: break; | 0 | ||||||||||||||||||
1669 | } | - | ||||||||||||||||||
1670 | #endif // QT_NO_TABWIDGET | - | ||||||||||||||||||
1671 | - | |||||||||||||||||||
1672 | tabBar->setGeometry(QStyle::visualRect(q->layoutDirection(), q->contentsRect(), tabBarRect)); | - | ||||||||||||||||||
1673 | } never executed: end of block | 0 | ||||||||||||||||||
1674 | - | |||||||||||||||||||
1675 | /*! | - | ||||||||||||||||||
1676 | \internal | - | ||||||||||||||||||
1677 | */ | - | ||||||||||||||||||
1678 | void QMdiAreaPrivate::refreshTabBar() | - | ||||||||||||||||||
1679 | { | - | ||||||||||||||||||
1680 | if (!tabBar)
| 0 | ||||||||||||||||||
1681 | return; never executed: return; | 0 | ||||||||||||||||||
1682 | - | |||||||||||||||||||
1683 | tabBar->setDocumentMode(documentMode); | - | ||||||||||||||||||
1684 | tabBar->setTabsClosable(tabsClosable); | - | ||||||||||||||||||
1685 | tabBar->setMovable(tabsMovable); | - | ||||||||||||||||||
1686 | #ifndef QT_NO_TABWIDGET | - | ||||||||||||||||||
1687 | tabBar->setShape(tabBarShapeFrom(tabShape, tabPosition)); | - | ||||||||||||||||||
1688 | #endif | - | ||||||||||||||||||
1689 | updateTabBarGeometry(); | - | ||||||||||||||||||
1690 | } never executed: end of block | 0 | ||||||||||||||||||
1691 | #endif // QT_NO_TABBAR | - | ||||||||||||||||||
1692 | - | |||||||||||||||||||
1693 | /*! | - | ||||||||||||||||||
1694 | Constructs an empty mdi area. \a parent is passed to QWidget's | - | ||||||||||||||||||
1695 | constructor. | - | ||||||||||||||||||
1696 | */ | - | ||||||||||||||||||
1697 | QMdiArea::QMdiArea(QWidget *parent) | - | ||||||||||||||||||
1698 | : QAbstractScrollArea(*new QMdiAreaPrivate, parent) | - | ||||||||||||||||||
1699 | { | - | ||||||||||||||||||
1700 | setBackground(palette().brush(QPalette::Dark)); | - | ||||||||||||||||||
1701 | setFrameStyle(QFrame::NoFrame); | - | ||||||||||||||||||
1702 | setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); | - | ||||||||||||||||||
1703 | setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); | - | ||||||||||||||||||
1704 | setViewport(0); | - | ||||||||||||||||||
1705 | setFocusPolicy(Qt::NoFocus); | - | ||||||||||||||||||
1706 | QApplication::instance()->installEventFilter(this); | - | ||||||||||||||||||
1707 | } never executed: end of block | 0 | ||||||||||||||||||
1708 | - | |||||||||||||||||||
1709 | /*! | - | ||||||||||||||||||
1710 | Destroys the MDI area. | - | ||||||||||||||||||
1711 | */ | - | ||||||||||||||||||
1712 | QMdiArea::~QMdiArea() | - | ||||||||||||||||||
1713 | { | - | ||||||||||||||||||
1714 | Q_D(QMdiArea); | - | ||||||||||||||||||
1715 | delete d->cascader; | - | ||||||||||||||||||
1716 | d->cascader = 0; | - | ||||||||||||||||||
1717 | - | |||||||||||||||||||
1718 | delete d->regularTiler; | - | ||||||||||||||||||
1719 | d->regularTiler = 0; | - | ||||||||||||||||||
1720 | - | |||||||||||||||||||
1721 | delete d->iconTiler; | - | ||||||||||||||||||
1722 | d->iconTiler = 0; | - | ||||||||||||||||||
1723 | - | |||||||||||||||||||
1724 | delete d->placer; | - | ||||||||||||||||||
1725 | d->placer = 0; | - | ||||||||||||||||||
1726 | } never executed: end of block | 0 | ||||||||||||||||||
1727 | - | |||||||||||||||||||
1728 | /*! | - | ||||||||||||||||||
1729 | \reimp | - | ||||||||||||||||||
1730 | */ | - | ||||||||||||||||||
1731 | QSize QMdiArea::sizeHint() const | - | ||||||||||||||||||
1732 | { | - | ||||||||||||||||||
1733 | // Calculate a proper scale factor for QDesktopWidget::size(). | - | ||||||||||||||||||
1734 | // This also takes into account that we can have nested workspaces. | - | ||||||||||||||||||
1735 | int nestedCount = 0; | - | ||||||||||||||||||
1736 | QWidget *widget = this->parentWidget(); | - | ||||||||||||||||||
1737 | while (widget) {
| 0 | ||||||||||||||||||
1738 | if (qobject_cast<QMdiArea *>(widget))
| 0 | ||||||||||||||||||
1739 | ++nestedCount; never executed: ++nestedCount; | 0 | ||||||||||||||||||
1740 | widget = widget->parentWidget(); | - | ||||||||||||||||||
1741 | } never executed: end of block | 0 | ||||||||||||||||||
1742 | const int scaleFactor = 3 * (nestedCount + 1); | - | ||||||||||||||||||
1743 | - | |||||||||||||||||||
1744 | QSize desktopSize = QApplication::desktop()->size(); | - | ||||||||||||||||||
1745 | QSize size(desktopSize.width() * 2 / scaleFactor, desktopSize.height() * 2 / scaleFactor); | - | ||||||||||||||||||
1746 | foreach (QMdiSubWindow *child, d_func()->childWindows) { | - | ||||||||||||||||||
1747 | if (!sanityCheck(child, "QMdiArea::sizeHint"))
| 0 | ||||||||||||||||||
1748 | continue; never executed: continue; | 0 | ||||||||||||||||||
1749 | size = size.expandedTo(child->sizeHint()); | - | ||||||||||||||||||
1750 | } never executed: end of block | 0 | ||||||||||||||||||
1751 | return size.expandedTo(QApplication::globalStrut()); never executed: return size.expandedTo(QApplication::globalStrut()); | 0 | ||||||||||||||||||
1752 | } | - | ||||||||||||||||||
1753 | - | |||||||||||||||||||
1754 | /*! | - | ||||||||||||||||||
1755 | \reimp | - | ||||||||||||||||||
1756 | */ | - | ||||||||||||||||||
1757 | QSize QMdiArea::minimumSizeHint() const | - | ||||||||||||||||||
1758 | { | - | ||||||||||||||||||
1759 | Q_D(const QMdiArea); | - | ||||||||||||||||||
1760 | QSize size(style()->pixelMetric(QStyle::PM_MdiSubWindowMinimizedWidth, 0, this), | - | ||||||||||||||||||
1761 | style()->pixelMetric(QStyle::PM_TitleBarHeight, 0, this)); | - | ||||||||||||||||||
1762 | size = size.expandedTo(QAbstractScrollArea::minimumSizeHint()); | - | ||||||||||||||||||
1763 | if (!d->scrollBarsEnabled()) {
| 0 | ||||||||||||||||||
1764 | foreach (QMdiSubWindow *child, d->childWindows) { | - | ||||||||||||||||||
1765 | if (!sanityCheck(child, "QMdiArea::sizeHint"))
| 0 | ||||||||||||||||||
1766 | continue; never executed: continue; | 0 | ||||||||||||||||||
1767 | size = size.expandedTo(child->minimumSizeHint()); | - | ||||||||||||||||||
1768 | } never executed: end of block | 0 | ||||||||||||||||||
1769 | } never executed: end of block | 0 | ||||||||||||||||||
1770 | return size.expandedTo(QApplication::globalStrut()); never executed: return size.expandedTo(QApplication::globalStrut()); | 0 | ||||||||||||||||||
1771 | } | - | ||||||||||||||||||
1772 | - | |||||||||||||||||||
1773 | /*! | - | ||||||||||||||||||
1774 | Returns a pointer to the current subwindow, or 0 if there is | - | ||||||||||||||||||
1775 | no current subwindow. | - | ||||||||||||||||||
1776 | - | |||||||||||||||||||
1777 | This function will return the same as activeSubWindow() if | - | ||||||||||||||||||
1778 | the QApplication containing QMdiArea is active. | - | ||||||||||||||||||
1779 | - | |||||||||||||||||||
1780 | \sa activeSubWindow(), QApplication::activeWindow() | - | ||||||||||||||||||
1781 | */ | - | ||||||||||||||||||
1782 | QMdiSubWindow *QMdiArea::currentSubWindow() const | - | ||||||||||||||||||
1783 | { | - | ||||||||||||||||||
1784 | Q_D(const QMdiArea); | - | ||||||||||||||||||
1785 | if (d->childWindows.isEmpty())
| 0 | ||||||||||||||||||
1786 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
1787 | - | |||||||||||||||||||
1788 | if (d->active)
| 0 | ||||||||||||||||||
1789 | return d->active; never executed: return d->active; | 0 | ||||||||||||||||||
1790 | - | |||||||||||||||||||
1791 | if (d->isActivated && !window()->isMinimized())
| 0 | ||||||||||||||||||
1792 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
1793 | - | |||||||||||||||||||
1794 | Q_ASSERT(d->indicesToActivatedChildren.count() > 0); | - | ||||||||||||||||||
1795 | int index = d->indicesToActivatedChildren.at(0); | - | ||||||||||||||||||
1796 | Q_ASSERT(index >= 0 && index < d->childWindows.size()); | - | ||||||||||||||||||
1797 | QMdiSubWindow *current = d->childWindows.at(index); | - | ||||||||||||||||||
1798 | Q_ASSERT(current); | - | ||||||||||||||||||
1799 | return current; never executed: return current; | 0 | ||||||||||||||||||
1800 | } | - | ||||||||||||||||||
1801 | - | |||||||||||||||||||
1802 | /*! | - | ||||||||||||||||||
1803 | Returns a pointer to the current active subwindow. If no | - | ||||||||||||||||||
1804 | window is currently active, 0 is returned. | - | ||||||||||||||||||
1805 | - | |||||||||||||||||||
1806 | Subwindows are treated as top-level windows with respect to | - | ||||||||||||||||||
1807 | window state, i.e., if a widget outside the MDI area is the active | - | ||||||||||||||||||
1808 | window, no subwindow will be active. Note that if a widget in the | - | ||||||||||||||||||
1809 | window in which the MDI area lives gains focus, the window will be | - | ||||||||||||||||||
1810 | activated. | - | ||||||||||||||||||
1811 | - | |||||||||||||||||||
1812 | \sa setActiveSubWindow(), Qt::WindowState | - | ||||||||||||||||||
1813 | */ | - | ||||||||||||||||||
1814 | QMdiSubWindow *QMdiArea::activeSubWindow() const | - | ||||||||||||||||||
1815 | { | - | ||||||||||||||||||
1816 | Q_D(const QMdiArea); | - | ||||||||||||||||||
1817 | return d->active; never executed: return d->active; | 0 | ||||||||||||||||||
1818 | } | - | ||||||||||||||||||
1819 | - | |||||||||||||||||||
1820 | /*! | - | ||||||||||||||||||
1821 | Activates the subwindow \a window. If \a window is 0, any | - | ||||||||||||||||||
1822 | current active window is deactivated. | - | ||||||||||||||||||
1823 | - | |||||||||||||||||||
1824 | \sa activeSubWindow() | - | ||||||||||||||||||
1825 | */ | - | ||||||||||||||||||
1826 | void QMdiArea::setActiveSubWindow(QMdiSubWindow *window) | - | ||||||||||||||||||
1827 | { | - | ||||||||||||||||||
1828 | Q_D(QMdiArea); | - | ||||||||||||||||||
1829 | if (!window) {
| 0 | ||||||||||||||||||
1830 | d->activateWindow(0); | - | ||||||||||||||||||
1831 | return; never executed: return; | 0 | ||||||||||||||||||
1832 | } | - | ||||||||||||||||||
1833 | - | |||||||||||||||||||
1834 | if (d->childWindows.isEmpty()) {
| 0 | ||||||||||||||||||
1835 | qWarning("QMdiArea::setActiveSubWindow: workspace is empty"); | - | ||||||||||||||||||
1836 | return; never executed: return; | 0 | ||||||||||||||||||
1837 | } | - | ||||||||||||||||||
1838 | - | |||||||||||||||||||
1839 | if (d->childWindows.indexOf(window) == -1) {
| 0 | ||||||||||||||||||
1840 | qWarning("QMdiArea::setActiveSubWindow: window is not inside workspace"); | - | ||||||||||||||||||
1841 | return; never executed: return; | 0 | ||||||||||||||||||
1842 | } | - | ||||||||||||||||||
1843 | - | |||||||||||||||||||
1844 | d->activateWindow(window); | - | ||||||||||||||||||
1845 | } never executed: end of block | 0 | ||||||||||||||||||
1846 | - | |||||||||||||||||||
1847 | /*! | - | ||||||||||||||||||
1848 | Closes the active subwindow. | - | ||||||||||||||||||
1849 | - | |||||||||||||||||||
1850 | \sa closeAllSubWindows() | - | ||||||||||||||||||
1851 | */ | - | ||||||||||||||||||
1852 | void QMdiArea::closeActiveSubWindow() | - | ||||||||||||||||||
1853 | { | - | ||||||||||||||||||
1854 | Q_D(QMdiArea); | - | ||||||||||||||||||
1855 | if (d->active)
| 0 | ||||||||||||||||||
1856 | d->active->close(); never executed: d->active->close(); | 0 | ||||||||||||||||||
1857 | } never executed: end of block | 0 | ||||||||||||||||||
1858 | - | |||||||||||||||||||
1859 | /*! | - | ||||||||||||||||||
1860 | Returns a list of all subwindows in the MDI area. If \a order is | - | ||||||||||||||||||
1861 | CreationOrder (the default), the windows are sorted in the order | - | ||||||||||||||||||
1862 | in which they were inserted into the workspace. If \a order is | - | ||||||||||||||||||
1863 | StackingOrder, the windows are listed in their stacking order, | - | ||||||||||||||||||
1864 | with the topmost window as the last item in the list. If \a order | - | ||||||||||||||||||
1865 | is ActivationHistoryOrder, the windows are listed according to | - | ||||||||||||||||||
1866 | their recent activation history. | - | ||||||||||||||||||
1867 | - | |||||||||||||||||||
1868 | \sa WindowOrder | - | ||||||||||||||||||
1869 | */ | - | ||||||||||||||||||
1870 | QList<QMdiSubWindow *> QMdiArea::subWindowList(WindowOrder order) const | - | ||||||||||||||||||
1871 | { | - | ||||||||||||||||||
1872 | Q_D(const QMdiArea); | - | ||||||||||||||||||
1873 | return d->subWindowList(order, false); never executed: return d->subWindowList(order, false); | 0 | ||||||||||||||||||
1874 | } | - | ||||||||||||||||||
1875 | - | |||||||||||||||||||
1876 | /*! | - | ||||||||||||||||||
1877 | Closes all subwindows by sending a QCloseEvent to each window. | - | ||||||||||||||||||
1878 | You may receive subWindowActivated() signals from subwindows | - | ||||||||||||||||||
1879 | before they are closed (if the MDI area activates the subwindow | - | ||||||||||||||||||
1880 | when another is closing). | - | ||||||||||||||||||
1881 | - | |||||||||||||||||||
1882 | Subwindows that ignore the close event will remain open. | - | ||||||||||||||||||
1883 | - | |||||||||||||||||||
1884 | \sa closeActiveSubWindow() | - | ||||||||||||||||||
1885 | */ | - | ||||||||||||||||||
1886 | void QMdiArea::closeAllSubWindows() | - | ||||||||||||||||||
1887 | { | - | ||||||||||||||||||
1888 | Q_D(QMdiArea); | - | ||||||||||||||||||
1889 | if (d->childWindows.isEmpty())
| 0 | ||||||||||||||||||
1890 | return; never executed: return; | 0 | ||||||||||||||||||
1891 | - | |||||||||||||||||||
1892 | d->isSubWindowsTiled = false; | - | ||||||||||||||||||
1893 | foreach (QMdiSubWindow *child, d->childWindows) { | - | ||||||||||||||||||
1894 | if (!sanityCheck(child, "QMdiArea::closeAllSubWindows"))
| 0 | ||||||||||||||||||
1895 | continue; never executed: continue; | 0 | ||||||||||||||||||
1896 | child->close(); | - | ||||||||||||||||||
1897 | } never executed: end of block | 0 | ||||||||||||||||||
1898 | - | |||||||||||||||||||
1899 | d->updateScrollBars(); | - | ||||||||||||||||||
1900 | } never executed: end of block | 0 | ||||||||||||||||||
1901 | - | |||||||||||||||||||
1902 | /*! | - | ||||||||||||||||||
1903 | Gives the keyboard focus to another window in the list of child | - | ||||||||||||||||||
1904 | windows. The window activated will be the next one determined | - | ||||||||||||||||||
1905 | by the current \l{QMdiArea::WindowOrder} {activation order}. | - | ||||||||||||||||||
1906 | - | |||||||||||||||||||
1907 | \sa activatePreviousSubWindow(), QMdiArea::WindowOrder | - | ||||||||||||||||||
1908 | */ | - | ||||||||||||||||||
1909 | void QMdiArea::activateNextSubWindow() | - | ||||||||||||||||||
1910 | { | - | ||||||||||||||||||
1911 | Q_D(QMdiArea); | - | ||||||||||||||||||
1912 | if (d->childWindows.isEmpty())
| 0 | ||||||||||||||||||
1913 | return; never executed: return; | 0 | ||||||||||||||||||
1914 | - | |||||||||||||||||||
1915 | QMdiSubWindow *next = d->nextVisibleSubWindow(1, d->activationOrder); | - | ||||||||||||||||||
1916 | if (next)
| 0 | ||||||||||||||||||
1917 | d->activateWindow(next); never executed: d->activateWindow(next); | 0 | ||||||||||||||||||
1918 | } never executed: end of block | 0 | ||||||||||||||||||
1919 | - | |||||||||||||||||||
1920 | /*! | - | ||||||||||||||||||
1921 | Gives the keyboard focus to another window in the list of child | - | ||||||||||||||||||
1922 | windows. The window activated will be the previous one determined | - | ||||||||||||||||||
1923 | by the current \l{QMdiArea::WindowOrder} {activation order}. | - | ||||||||||||||||||
1924 | - | |||||||||||||||||||
1925 | \sa activateNextSubWindow(), QMdiArea::WindowOrder | - | ||||||||||||||||||
1926 | */ | - | ||||||||||||||||||
1927 | void QMdiArea::activatePreviousSubWindow() | - | ||||||||||||||||||
1928 | { | - | ||||||||||||||||||
1929 | Q_D(QMdiArea); | - | ||||||||||||||||||
1930 | if (d->childWindows.isEmpty())
| 0 | ||||||||||||||||||
1931 | return; never executed: return; | 0 | ||||||||||||||||||
1932 | - | |||||||||||||||||||
1933 | QMdiSubWindow *previous = d->nextVisibleSubWindow(-1, d->activationOrder); | - | ||||||||||||||||||
1934 | if (previous)
| 0 | ||||||||||||||||||
1935 | d->activateWindow(previous); never executed: d->activateWindow(previous); | 0 | ||||||||||||||||||
1936 | } never executed: end of block | 0 | ||||||||||||||||||
1937 | - | |||||||||||||||||||
1938 | /*! | - | ||||||||||||||||||
1939 | Adds \a widget as a new subwindow to the MDI area. If \a | - | ||||||||||||||||||
1940 | windowFlags are non-zero, they will override the flags set on the | - | ||||||||||||||||||
1941 | widget. | - | ||||||||||||||||||
1942 | - | |||||||||||||||||||
1943 | The \a widget can be either a QMdiSubWindow or another QWidget | - | ||||||||||||||||||
1944 | (in which case the MDI area will create a subwindow and set the \a | - | ||||||||||||||||||
1945 | widget as the internal widget). | - | ||||||||||||||||||
1946 | - | |||||||||||||||||||
1947 | \note Once the subwindow has been added, its parent will be the | - | ||||||||||||||||||
1948 | \e{viewport widget} of the QMdiArea. | - | ||||||||||||||||||
1949 | - | |||||||||||||||||||
1950 | \snippet mdiareasnippets.cpp 1 | - | ||||||||||||||||||
1951 | - | |||||||||||||||||||
1952 | When you create your own subwindow, you must set the | - | ||||||||||||||||||
1953 | Qt::WA_DeleteOnClose widget attribute if you want the window to be | - | ||||||||||||||||||
1954 | deleted when closed in the MDI area. If not, the window will be | - | ||||||||||||||||||
1955 | hidden and the MDI area will not activate the next subwindow. | - | ||||||||||||||||||
1956 | - | |||||||||||||||||||
1957 | Returns the QMdiSubWindow that is added to the MDI area. | - | ||||||||||||||||||
1958 | - | |||||||||||||||||||
1959 | \sa removeSubWindow() | - | ||||||||||||||||||
1960 | */ | - | ||||||||||||||||||
1961 | QMdiSubWindow *QMdiArea::addSubWindow(QWidget *widget, Qt::WindowFlags windowFlags) | - | ||||||||||||||||||
1962 | { | - | ||||||||||||||||||
1963 | if (!widget) {
| 0 | ||||||||||||||||||
1964 | qWarning("QMdiArea::addSubWindow: null pointer to widget"); | - | ||||||||||||||||||
1965 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
1966 | } | - | ||||||||||||||||||
1967 | - | |||||||||||||||||||
1968 | Q_D(QMdiArea); | - | ||||||||||||||||||
1969 | // QWidget::setParent clears focusWidget so store it | - | ||||||||||||||||||
1970 | QWidget *childFocus = widget->focusWidget(); | - | ||||||||||||||||||
1971 | QMdiSubWindow *child = qobject_cast<QMdiSubWindow *>(widget); | - | ||||||||||||||||||
1972 | - | |||||||||||||||||||
1973 | // Widget is already a QMdiSubWindow | - | ||||||||||||||||||
1974 | if (child) {
| 0 | ||||||||||||||||||
1975 | if (d->childWindows.indexOf(child) != -1) {
| 0 | ||||||||||||||||||
1976 | qWarning("QMdiArea::addSubWindow: window is already added"); | - | ||||||||||||||||||
1977 | return child; never executed: return child; | 0 | ||||||||||||||||||
1978 | } | - | ||||||||||||||||||
1979 | child->setParent(viewport(), windowFlags ? windowFlags : child->windowFlags()); | - | ||||||||||||||||||
1980 | // Create a QMdiSubWindow | - | ||||||||||||||||||
1981 | } else { never executed: end of block | 0 | ||||||||||||||||||
1982 | child = new QMdiSubWindow(viewport(), windowFlags); | - | ||||||||||||||||||
1983 | child->setAttribute(Qt::WA_DeleteOnClose); | - | ||||||||||||||||||
1984 | child->setWidget(widget); | - | ||||||||||||||||||
1985 | Q_ASSERT(child->testAttribute(Qt::WA_DeleteOnClose)); | - | ||||||||||||||||||
1986 | } never executed: end of block | 0 | ||||||||||||||||||
1987 | - | |||||||||||||||||||
1988 | if (childFocus)
| 0 | ||||||||||||||||||
1989 | childFocus->setFocus(); never executed: childFocus->setFocus(); | 0 | ||||||||||||||||||
1990 | d->appendChild(child); | - | ||||||||||||||||||
1991 | return child; never executed: return child; | 0 | ||||||||||||||||||
1992 | } | - | ||||||||||||||||||
1993 | - | |||||||||||||||||||
1994 | /*! | - | ||||||||||||||||||
1995 | Removes \a widget from the MDI area. The \a widget must be | - | ||||||||||||||||||
1996 | either a QMdiSubWindow or a widget that is the internal widget of | - | ||||||||||||||||||
1997 | a subwindow. Note \a widget is never actually deleted by QMdiArea. | - | ||||||||||||||||||
1998 | If a QMdiSubWindow is passed in its parent is set to 0 and it is | - | ||||||||||||||||||
1999 | removed, but if an internal widget is passed in the child widget | - | ||||||||||||||||||
2000 | is set to 0 but the QMdiSubWindow is not removed. | - | ||||||||||||||||||
2001 | - | |||||||||||||||||||
2002 | \sa addSubWindow() | - | ||||||||||||||||||
2003 | */ | - | ||||||||||||||||||
2004 | void QMdiArea::removeSubWindow(QWidget *widget) | - | ||||||||||||||||||
2005 | { | - | ||||||||||||||||||
2006 | if (!widget) {
| 0 | ||||||||||||||||||
2007 | qWarning("QMdiArea::removeSubWindow: null pointer to widget"); | - | ||||||||||||||||||
2008 | return; never executed: return; | 0 | ||||||||||||||||||
2009 | } | - | ||||||||||||||||||
2010 | - | |||||||||||||||||||
2011 | Q_D(QMdiArea); | - | ||||||||||||||||||
2012 | if (d->childWindows.isEmpty())
| 0 | ||||||||||||||||||
2013 | return; never executed: return; | 0 | ||||||||||||||||||
2014 | - | |||||||||||||||||||
2015 | if (QMdiSubWindow *child = qobject_cast<QMdiSubWindow *>(widget)) {
| 0 | ||||||||||||||||||
2016 | int index = d->childWindows.indexOf(child); | - | ||||||||||||||||||
2017 | if (index == -1) {
| 0 | ||||||||||||||||||
2018 | qWarning("QMdiArea::removeSubWindow: window is not inside workspace"); | - | ||||||||||||||||||
2019 | return; never executed: return; | 0 | ||||||||||||||||||
2020 | } | - | ||||||||||||||||||
2021 | d->disconnectSubWindow(child); | - | ||||||||||||||||||
2022 | d->childWindows.removeAll(child); | - | ||||||||||||||||||
2023 | d->indicesToActivatedChildren.removeAll(index); | - | ||||||||||||||||||
2024 | d->updateActiveWindow(index, d->active == child); | - | ||||||||||||||||||
2025 | child->setParent(0); | - | ||||||||||||||||||
2026 | return; never executed: return; | 0 | ||||||||||||||||||
2027 | } | - | ||||||||||||||||||
2028 | - | |||||||||||||||||||
2029 | bool found = false; | - | ||||||||||||||||||
2030 | foreach (QMdiSubWindow *child, d->childWindows) { | - | ||||||||||||||||||
2031 | if (!sanityCheck(child, "QMdiArea::removeSubWindow"))
| 0 | ||||||||||||||||||
2032 | continue; never executed: continue; | 0 | ||||||||||||||||||
2033 | if (child->widget() == widget) {
| 0 | ||||||||||||||||||
2034 | child->setWidget(0); | - | ||||||||||||||||||
2035 | Q_ASSERT(!child->widget()); | - | ||||||||||||||||||
2036 | found = true; | - | ||||||||||||||||||
2037 | break; never executed: break; | 0 | ||||||||||||||||||
2038 | } | - | ||||||||||||||||||
2039 | } never executed: end of block | 0 | ||||||||||||||||||
2040 | - | |||||||||||||||||||
2041 | if (!found)
| 0 | ||||||||||||||||||
2042 | qWarning("QMdiArea::removeSubWindow: widget is not child of any window inside QMdiArea"); never executed: QMessageLogger(__FILE__, 2042, __PRETTY_FUNCTION__).warning("QMdiArea::removeSubWindow: widget is not child of any window inside QMdiArea"); | 0 | ||||||||||||||||||
2043 | } never executed: end of block | 0 | ||||||||||||||||||
2044 | - | |||||||||||||||||||
2045 | /*! | - | ||||||||||||||||||
2046 | \property QMdiArea::background | - | ||||||||||||||||||
2047 | \brief the background brush for the workspace | - | ||||||||||||||||||
2048 | - | |||||||||||||||||||
2049 | This property sets the background brush for the workspace area | - | ||||||||||||||||||
2050 | itself. By default, it is a gray color, but can be any brush | - | ||||||||||||||||||
2051 | (e.g., colors, gradients or pixmaps). | - | ||||||||||||||||||
2052 | */ | - | ||||||||||||||||||
2053 | QBrush QMdiArea::background() const | - | ||||||||||||||||||
2054 | { | - | ||||||||||||||||||
2055 | return d_func()->background; never executed: return d_func()->background; | 0 | ||||||||||||||||||
2056 | } | - | ||||||||||||||||||
2057 | - | |||||||||||||||||||
2058 | void QMdiArea::setBackground(const QBrush &brush) | - | ||||||||||||||||||
2059 | { | - | ||||||||||||||||||
2060 | Q_D(QMdiArea); | - | ||||||||||||||||||
2061 | if (d->background != brush) {
| 0 | ||||||||||||||||||
2062 | d->background = brush; | - | ||||||||||||||||||
2063 | d->viewport->setAttribute(Qt::WA_OpaquePaintEvent, brush.isOpaque()); | - | ||||||||||||||||||
2064 | d->viewport->update(); | - | ||||||||||||||||||
2065 | } never executed: end of block | 0 | ||||||||||||||||||
2066 | } never executed: end of block | 0 | ||||||||||||||||||
2067 | - | |||||||||||||||||||
2068 | - | |||||||||||||||||||
2069 | /*! | - | ||||||||||||||||||
2070 | \property QMdiArea::activationOrder | - | ||||||||||||||||||
2071 | \brief the ordering criteria for subwindow lists | - | ||||||||||||||||||
2072 | \since 4.4 | - | ||||||||||||||||||
2073 | - | |||||||||||||||||||
2074 | This property specifies the ordering criteria for the list of | - | ||||||||||||||||||
2075 | subwindows returned by subWindowList(). By default, it is the window | - | ||||||||||||||||||
2076 | creation order. | - | ||||||||||||||||||
2077 | - | |||||||||||||||||||
2078 | \sa subWindowList() | - | ||||||||||||||||||
2079 | */ | - | ||||||||||||||||||
2080 | QMdiArea::WindowOrder QMdiArea::activationOrder() const | - | ||||||||||||||||||
2081 | { | - | ||||||||||||||||||
2082 | Q_D(const QMdiArea); | - | ||||||||||||||||||
2083 | return d->activationOrder; never executed: return d->activationOrder; | 0 | ||||||||||||||||||
2084 | } | - | ||||||||||||||||||
2085 | - | |||||||||||||||||||
2086 | void QMdiArea::setActivationOrder(WindowOrder order) | - | ||||||||||||||||||
2087 | { | - | ||||||||||||||||||
2088 | Q_D(QMdiArea); | - | ||||||||||||||||||
2089 | if (order != d->activationOrder)
| 0 | ||||||||||||||||||
2090 | d->activationOrder = order; never executed: d->activationOrder = order; | 0 | ||||||||||||||||||
2091 | } never executed: end of block | 0 | ||||||||||||||||||
2092 | - | |||||||||||||||||||
2093 | /*! | - | ||||||||||||||||||
2094 | If \a on is true, \a option is enabled on the MDI area; otherwise | - | ||||||||||||||||||
2095 | it is disabled. See AreaOption for the effect of each option. | - | ||||||||||||||||||
2096 | - | |||||||||||||||||||
2097 | \sa AreaOption, testOption() | - | ||||||||||||||||||
2098 | */ | - | ||||||||||||||||||
2099 | void QMdiArea::setOption(AreaOption option, bool on) | - | ||||||||||||||||||
2100 | { | - | ||||||||||||||||||
2101 | Q_D(QMdiArea); | - | ||||||||||||||||||
2102 | if (on && !(d->options & option))
| 0 | ||||||||||||||||||
2103 | d->options |= option; never executed: d->options |= option; | 0 | ||||||||||||||||||
2104 | else if (!on && (d->options & option))
| 0 | ||||||||||||||||||
2105 | d->options &= ~option; never executed: d->options &= ~option; | 0 | ||||||||||||||||||
2106 | } never executed: end of block | 0 | ||||||||||||||||||
2107 | - | |||||||||||||||||||
2108 | /*! | - | ||||||||||||||||||
2109 | Returns \c true if \a option is enabled; otherwise returns \c false. | - | ||||||||||||||||||
2110 | - | |||||||||||||||||||
2111 | \sa AreaOption, setOption() | - | ||||||||||||||||||
2112 | */ | - | ||||||||||||||||||
2113 | bool QMdiArea::testOption(AreaOption option) const | - | ||||||||||||||||||
2114 | { | - | ||||||||||||||||||
2115 | return d_func()->options & option; never executed: return d_func()->options & option; | 0 | ||||||||||||||||||
2116 | } | - | ||||||||||||||||||
2117 | - | |||||||||||||||||||
2118 | /*! | - | ||||||||||||||||||
2119 | \property QMdiArea::viewMode | - | ||||||||||||||||||
2120 | \brief the way sub-windows are displayed in the QMdiArea. | - | ||||||||||||||||||
2121 | \since 4.4 | - | ||||||||||||||||||
2122 | - | |||||||||||||||||||
2123 | By default, the SubWindowView is used to display sub-windows. | - | ||||||||||||||||||
2124 | - | |||||||||||||||||||
2125 | \sa ViewMode, setTabShape(), setTabPosition() | - | ||||||||||||||||||
2126 | */ | - | ||||||||||||||||||
2127 | QMdiArea::ViewMode QMdiArea::viewMode() const | - | ||||||||||||||||||
2128 | { | - | ||||||||||||||||||
2129 | Q_D(const QMdiArea); | - | ||||||||||||||||||
2130 | return d->viewMode; never executed: return d->viewMode; | 0 | ||||||||||||||||||
2131 | } | - | ||||||||||||||||||
2132 | - | |||||||||||||||||||
2133 | void QMdiArea::setViewMode(ViewMode mode) | - | ||||||||||||||||||
2134 | { | - | ||||||||||||||||||
2135 | Q_D(QMdiArea); | - | ||||||||||||||||||
2136 | d->setViewMode(mode); | - | ||||||||||||||||||
2137 | } never executed: end of block | 0 | ||||||||||||||||||
2138 | - | |||||||||||||||||||
2139 | #ifndef QT_NO_TABBAR | - | ||||||||||||||||||
2140 | /*! | - | ||||||||||||||||||
2141 | \property QMdiArea::documentMode | - | ||||||||||||||||||
2142 | \brief whether the tab bar is set to document mode in tabbed view mode. | - | ||||||||||||||||||
2143 | \since 4.5 | - | ||||||||||||||||||
2144 | - | |||||||||||||||||||
2145 | Document mode is disabled by default. | - | ||||||||||||||||||
2146 | - | |||||||||||||||||||
2147 | \sa QTabBar::documentMode, setViewMode() | - | ||||||||||||||||||
2148 | */ | - | ||||||||||||||||||
2149 | bool QMdiArea::documentMode() const | - | ||||||||||||||||||
2150 | { | - | ||||||||||||||||||
2151 | Q_D(const QMdiArea); | - | ||||||||||||||||||
2152 | return d->documentMode; never executed: return d->documentMode; | 0 | ||||||||||||||||||
2153 | } | - | ||||||||||||||||||
2154 | - | |||||||||||||||||||
2155 | void QMdiArea::setDocumentMode(bool enabled) | - | ||||||||||||||||||
2156 | { | - | ||||||||||||||||||
2157 | Q_D(QMdiArea); | - | ||||||||||||||||||
2158 | if (d->documentMode == enabled)
| 0 | ||||||||||||||||||
2159 | return; never executed: return; | 0 | ||||||||||||||||||
2160 | - | |||||||||||||||||||
2161 | d->documentMode = enabled; | - | ||||||||||||||||||
2162 | d->refreshTabBar(); | - | ||||||||||||||||||
2163 | } never executed: end of block | 0 | ||||||||||||||||||
2164 | - | |||||||||||||||||||
2165 | /*! | - | ||||||||||||||||||
2166 | \property QMdiArea::tabsClosable | - | ||||||||||||||||||
2167 | \brief whether the tab bar should place close buttons on each tab in tabbed view mode. | - | ||||||||||||||||||
2168 | \since 4.8 | - | ||||||||||||||||||
2169 | - | |||||||||||||||||||
2170 | Tabs are not closable by default. | - | ||||||||||||||||||
2171 | - | |||||||||||||||||||
2172 | \sa QTabBar::tabsClosable, setViewMode() | - | ||||||||||||||||||
2173 | */ | - | ||||||||||||||||||
2174 | bool QMdiArea::tabsClosable() const | - | ||||||||||||||||||
2175 | { | - | ||||||||||||||||||
2176 | Q_D(const QMdiArea); | - | ||||||||||||||||||
2177 | return d->tabsClosable; never executed: return d->tabsClosable; | 0 | ||||||||||||||||||
2178 | } | - | ||||||||||||||||||
2179 | - | |||||||||||||||||||
2180 | void QMdiArea::setTabsClosable(bool closable) | - | ||||||||||||||||||
2181 | { | - | ||||||||||||||||||
2182 | Q_D(QMdiArea); | - | ||||||||||||||||||
2183 | if (d->tabsClosable == closable)
| 0 | ||||||||||||||||||
2184 | return; never executed: return; | 0 | ||||||||||||||||||
2185 | - | |||||||||||||||||||
2186 | d->tabsClosable = closable; | - | ||||||||||||||||||
2187 | d->refreshTabBar(); | - | ||||||||||||||||||
2188 | } never executed: end of block | 0 | ||||||||||||||||||
2189 | - | |||||||||||||||||||
2190 | /*! | - | ||||||||||||||||||
2191 | \property QMdiArea::tabsMovable | - | ||||||||||||||||||
2192 | \brief whether the user can move the tabs within the tabbar area in tabbed view mode. | - | ||||||||||||||||||
2193 | \since 4.8 | - | ||||||||||||||||||
2194 | - | |||||||||||||||||||
2195 | Tabs are not movable by default. | - | ||||||||||||||||||
2196 | - | |||||||||||||||||||
2197 | \sa QTabBar::movable, setViewMode() | - | ||||||||||||||||||
2198 | */ | - | ||||||||||||||||||
2199 | bool QMdiArea::tabsMovable() const | - | ||||||||||||||||||
2200 | { | - | ||||||||||||||||||
2201 | Q_D(const QMdiArea); | - | ||||||||||||||||||
2202 | return d->tabsMovable; never executed: return d->tabsMovable; | 0 | ||||||||||||||||||
2203 | } | - | ||||||||||||||||||
2204 | - | |||||||||||||||||||
2205 | void QMdiArea::setTabsMovable(bool movable) | - | ||||||||||||||||||
2206 | { | - | ||||||||||||||||||
2207 | Q_D(QMdiArea); | - | ||||||||||||||||||
2208 | if (d->tabsMovable == movable)
| 0 | ||||||||||||||||||
2209 | return; never executed: return; | 0 | ||||||||||||||||||
2210 | - | |||||||||||||||||||
2211 | d->tabsMovable = movable; | - | ||||||||||||||||||
2212 | d->refreshTabBar(); | - | ||||||||||||||||||
2213 | } never executed: end of block | 0 | ||||||||||||||||||
2214 | #endif // QT_NO_TABBAR | - | ||||||||||||||||||
2215 | - | |||||||||||||||||||
2216 | #ifndef QT_NO_TABWIDGET | - | ||||||||||||||||||
2217 | /*! | - | ||||||||||||||||||
2218 | \property QMdiArea::tabShape | - | ||||||||||||||||||
2219 | \brief the shape of the tabs in tabbed view mode. | - | ||||||||||||||||||
2220 | \since 4.4 | - | ||||||||||||||||||
2221 | - | |||||||||||||||||||
2222 | Possible values for this property are QTabWidget::Rounded | - | ||||||||||||||||||
2223 | (default) or QTabWidget::Triangular. | - | ||||||||||||||||||
2224 | - | |||||||||||||||||||
2225 | \sa QTabWidget::TabShape, setViewMode() | - | ||||||||||||||||||
2226 | */ | - | ||||||||||||||||||
2227 | QTabWidget::TabShape QMdiArea::tabShape() const | - | ||||||||||||||||||
2228 | { | - | ||||||||||||||||||
2229 | Q_D(const QMdiArea); | - | ||||||||||||||||||
2230 | return d->tabShape; never executed: return d->tabShape; | 0 | ||||||||||||||||||
2231 | } | - | ||||||||||||||||||
2232 | - | |||||||||||||||||||
2233 | void QMdiArea::setTabShape(QTabWidget::TabShape shape) | - | ||||||||||||||||||
2234 | { | - | ||||||||||||||||||
2235 | Q_D(QMdiArea); | - | ||||||||||||||||||
2236 | if (d->tabShape == shape)
| 0 | ||||||||||||||||||
2237 | return; never executed: return; | 0 | ||||||||||||||||||
2238 | - | |||||||||||||||||||
2239 | d->tabShape = shape; | - | ||||||||||||||||||
2240 | d->refreshTabBar(); | - | ||||||||||||||||||
2241 | } never executed: end of block | 0 | ||||||||||||||||||
2242 | - | |||||||||||||||||||
2243 | /*! | - | ||||||||||||||||||
2244 | \property QMdiArea::tabPosition | - | ||||||||||||||||||
2245 | \brief the position of the tabs in tabbed view mode. | - | ||||||||||||||||||
2246 | \since 4.4 | - | ||||||||||||||||||
2247 | - | |||||||||||||||||||
2248 | Possible values for this property are described by the | - | ||||||||||||||||||
2249 | QTabWidget::TabPosition enum. | - | ||||||||||||||||||
2250 | - | |||||||||||||||||||
2251 | \sa QTabWidget::TabPosition, setViewMode() | - | ||||||||||||||||||
2252 | */ | - | ||||||||||||||||||
2253 | QTabWidget::TabPosition QMdiArea::tabPosition() const | - | ||||||||||||||||||
2254 | { | - | ||||||||||||||||||
2255 | Q_D(const QMdiArea); | - | ||||||||||||||||||
2256 | return d->tabPosition; never executed: return d->tabPosition; | 0 | ||||||||||||||||||
2257 | } | - | ||||||||||||||||||
2258 | - | |||||||||||||||||||
2259 | void QMdiArea::setTabPosition(QTabWidget::TabPosition position) | - | ||||||||||||||||||
2260 | { | - | ||||||||||||||||||
2261 | Q_D(QMdiArea); | - | ||||||||||||||||||
2262 | if (d->tabPosition == position)
| 0 | ||||||||||||||||||
2263 | return; never executed: return; | 0 | ||||||||||||||||||
2264 | - | |||||||||||||||||||
2265 | d->tabPosition = position; | - | ||||||||||||||||||
2266 | d->refreshTabBar(); | - | ||||||||||||||||||
2267 | } never executed: end of block | 0 | ||||||||||||||||||
2268 | #endif // QT_NO_TABWIDGET | - | ||||||||||||||||||
2269 | - | |||||||||||||||||||
2270 | /*! | - | ||||||||||||||||||
2271 | \reimp | - | ||||||||||||||||||
2272 | */ | - | ||||||||||||||||||
2273 | void QMdiArea::childEvent(QChildEvent *childEvent) | - | ||||||||||||||||||
2274 | { | - | ||||||||||||||||||
2275 | Q_D(QMdiArea); | - | ||||||||||||||||||
2276 | if (childEvent->type() == QEvent::ChildPolished) {
| 0 | ||||||||||||||||||
2277 | if (QMdiSubWindow *mdiChild = qobject_cast<QMdiSubWindow *>(childEvent->child())) {
| 0 | ||||||||||||||||||
2278 | if (d->childWindows.indexOf(mdiChild) == -1)
| 0 | ||||||||||||||||||
2279 | d->appendChild(mdiChild); never executed: d->appendChild(mdiChild); | 0 | ||||||||||||||||||
2280 | } never executed: end of block | 0 | ||||||||||||||||||
2281 | } never executed: end of block | 0 | ||||||||||||||||||
2282 | } never executed: end of block | 0 | ||||||||||||||||||
2283 | - | |||||||||||||||||||
2284 | /*! | - | ||||||||||||||||||
2285 | \reimp | - | ||||||||||||||||||
2286 | */ | - | ||||||||||||||||||
2287 | void QMdiArea::resizeEvent(QResizeEvent *resizeEvent) | - | ||||||||||||||||||
2288 | { | - | ||||||||||||||||||
2289 | Q_D(QMdiArea); | - | ||||||||||||||||||
2290 | if (d->childWindows.isEmpty()) {
| 0 | ||||||||||||||||||
2291 | resizeEvent->ignore(); | - | ||||||||||||||||||
2292 | return; never executed: return; | 0 | ||||||||||||||||||
2293 | } | - | ||||||||||||||||||
2294 | - | |||||||||||||||||||
2295 | #ifndef QT_NO_TABBAR | - | ||||||||||||||||||
2296 | d->updateTabBarGeometry(); | - | ||||||||||||||||||
2297 | #endif | - | ||||||||||||||||||
2298 | - | |||||||||||||||||||
2299 | // Re-tile the views if we're in tiled mode. Re-tile means we will change | - | ||||||||||||||||||
2300 | // the geometry of the children, which in turn means 'isSubWindowsTiled' | - | ||||||||||||||||||
2301 | // is set to false, so we have to update the state at the end. | - | ||||||||||||||||||
2302 | if (d->isSubWindowsTiled) {
| 0 | ||||||||||||||||||
2303 | d->tileCalledFromResizeEvent = true; | - | ||||||||||||||||||
2304 | tileSubWindows(); | - | ||||||||||||||||||
2305 | d->tileCalledFromResizeEvent = false; | - | ||||||||||||||||||
2306 | d->isSubWindowsTiled = true; | - | ||||||||||||||||||
2307 | d->startResizeTimer(); | - | ||||||||||||||||||
2308 | // We don't have scroll bars or any maximized views. | - | ||||||||||||||||||
2309 | return; never executed: return; | 0 | ||||||||||||||||||
2310 | } | - | ||||||||||||||||||
2311 | - | |||||||||||||||||||
2312 | // Resize maximized views. | - | ||||||||||||||||||
2313 | bool hasMaximizedSubWindow = false; | - | ||||||||||||||||||
2314 | foreach (QMdiSubWindow *child, d->childWindows) { | - | ||||||||||||||||||
2315 | if (sanityCheck(child, "QMdiArea::resizeEvent") && child->isMaximized()
| 0 | ||||||||||||||||||
2316 | && child->size() != resizeEvent->size()) {
| 0 | ||||||||||||||||||
2317 | child->resize(resizeEvent->size()); | - | ||||||||||||||||||
2318 | if (!hasMaximizedSubWindow)
| 0 | ||||||||||||||||||
2319 | hasMaximizedSubWindow = true; never executed: hasMaximizedSubWindow = true; | 0 | ||||||||||||||||||
2320 | } never executed: end of block | 0 | ||||||||||||||||||
2321 | } never executed: end of block | 0 | ||||||||||||||||||
2322 | - | |||||||||||||||||||
2323 | d->updateScrollBars(); | - | ||||||||||||||||||
2324 | - | |||||||||||||||||||
2325 | // Minimized views are stacked under maximized views so there's | - | ||||||||||||||||||
2326 | // no need to re-arrange minimized views on-demand. Start a timer | - | ||||||||||||||||||
2327 | // just to make things faster with subsequent resize events. | - | ||||||||||||||||||
2328 | if (hasMaximizedSubWindow)
| 0 | ||||||||||||||||||
2329 | d->startResizeTimer(); never executed: d->startResizeTimer(); | 0 | ||||||||||||||||||
2330 | else | - | ||||||||||||||||||
2331 | d->arrangeMinimizedSubWindows(); never executed: d->arrangeMinimizedSubWindows(); | 0 | ||||||||||||||||||
2332 | } | - | ||||||||||||||||||
2333 | - | |||||||||||||||||||
2334 | /*! | - | ||||||||||||||||||
2335 | \reimp | - | ||||||||||||||||||
2336 | */ | - | ||||||||||||||||||
2337 | void QMdiArea::timerEvent(QTimerEvent *timerEvent) | - | ||||||||||||||||||
2338 | { | - | ||||||||||||||||||
2339 | Q_D(QMdiArea); | - | ||||||||||||||||||
2340 | if (timerEvent->timerId() == d->resizeTimerId) {
| 0 | ||||||||||||||||||
2341 | killTimer(d->resizeTimerId); | - | ||||||||||||||||||
2342 | d->resizeTimerId = -1; | - | ||||||||||||||||||
2343 | d->arrangeMinimizedSubWindows(); | - | ||||||||||||||||||
2344 | } else if (timerEvent->timerId() == d->tabToPreviousTimerId) { never executed: end of block
| 0 | ||||||||||||||||||
2345 | killTimer(d->tabToPreviousTimerId); | - | ||||||||||||||||||
2346 | d->tabToPreviousTimerId = -1; | - | ||||||||||||||||||
2347 | if (d->indexToHighlighted < 0)
| 0 | ||||||||||||||||||
2348 | return; never executed: return; | 0 | ||||||||||||||||||
2349 | #ifndef QT_NO_RUBBERBAND | - | ||||||||||||||||||
2350 | // We're not doing a "quick switch" ... show rubber band. | - | ||||||||||||||||||
2351 | Q_ASSERT(d->indexToHighlighted < d->childWindows.size()); | - | ||||||||||||||||||
2352 | Q_ASSERT(d->rubberBand); | - | ||||||||||||||||||
2353 | d->showRubberBandFor(d->childWindows.at(d->indexToHighlighted)); | - | ||||||||||||||||||
2354 | #endif | - | ||||||||||||||||||
2355 | } never executed: end of block | 0 | ||||||||||||||||||
2356 | } never executed: end of block | 0 | ||||||||||||||||||
2357 | - | |||||||||||||||||||
2358 | /*! | - | ||||||||||||||||||
2359 | \reimp | - | ||||||||||||||||||
2360 | */ | - | ||||||||||||||||||
2361 | void QMdiArea::showEvent(QShowEvent *showEvent) | - | ||||||||||||||||||
2362 | { | - | ||||||||||||||||||
2363 | Q_D(QMdiArea); | - | ||||||||||||||||||
2364 | if (!d->pendingRearrangements.isEmpty()) {
| 0 | ||||||||||||||||||
2365 | bool skipPlacement = false; | - | ||||||||||||||||||
2366 | foreach (Rearranger *rearranger, d->pendingRearrangements) { | - | ||||||||||||||||||
2367 | // If this is the case, we don't have to lay out pending child windows | - | ||||||||||||||||||
2368 | // since the rearranger will find a placement for them. | - | ||||||||||||||||||
2369 | if (rearranger->type() != Rearranger::IconTiler && !skipPlacement)
| 0 | ||||||||||||||||||
2370 | skipPlacement = true; never executed: skipPlacement = true; | 0 | ||||||||||||||||||
2371 | d->rearrange(rearranger); | - | ||||||||||||||||||
2372 | } never executed: end of block | 0 | ||||||||||||||||||
2373 | d->pendingRearrangements.clear(); | - | ||||||||||||||||||
2374 | - | |||||||||||||||||||
2375 | if (skipPlacement && !d->pendingPlacements.isEmpty())
| 0 | ||||||||||||||||||
2376 | d->pendingPlacements.clear(); never executed: d->pendingPlacements.clear(); | 0 | ||||||||||||||||||
2377 | } never executed: end of block | 0 | ||||||||||||||||||
2378 | - | |||||||||||||||||||
2379 | if (!d->pendingPlacements.isEmpty()) {
| 0 | ||||||||||||||||||
2380 | foreach (QMdiSubWindow *window, d->pendingPlacements) { | - | ||||||||||||||||||
2381 | if (!window)
| 0 | ||||||||||||||||||
2382 | continue; never executed: continue; | 0 | ||||||||||||||||||
2383 | if (!window->testAttribute(Qt::WA_Resized)) {
| 0 | ||||||||||||||||||
2384 | QSize newSize(window->sizeHint().boundedTo(viewport()->size())); | - | ||||||||||||||||||
2385 | window->resize(newSize.expandedTo(qSmartMinSize(window))); | - | ||||||||||||||||||
2386 | } never executed: end of block | 0 | ||||||||||||||||||
2387 | if (!window->testAttribute(Qt::WA_Moved) && !window->isMinimized()
| 0 | ||||||||||||||||||
2388 | && !window->isMaximized()) {
| 0 | ||||||||||||||||||
2389 | d->place(d->placer, window); | - | ||||||||||||||||||
2390 | } never executed: end of block | 0 | ||||||||||||||||||
2391 | } never executed: end of block | 0 | ||||||||||||||||||
2392 | d->pendingPlacements.clear(); | - | ||||||||||||||||||
2393 | } never executed: end of block | 0 | ||||||||||||||||||
2394 | - | |||||||||||||||||||
2395 | d->setChildActivationEnabled(true); | - | ||||||||||||||||||
2396 | d->activateCurrentWindow(); | - | ||||||||||||||||||
2397 | - | |||||||||||||||||||
2398 | QAbstractScrollArea::showEvent(showEvent); | - | ||||||||||||||||||
2399 | } never executed: end of block | 0 | ||||||||||||||||||
2400 | - | |||||||||||||||||||
2401 | /*! | - | ||||||||||||||||||
2402 | \reimp | - | ||||||||||||||||||
2403 | */ | - | ||||||||||||||||||
2404 | bool QMdiArea::viewportEvent(QEvent *event) | - | ||||||||||||||||||
2405 | { | - | ||||||||||||||||||
2406 | Q_D(QMdiArea); | - | ||||||||||||||||||
2407 | switch (event->type()) { | - | ||||||||||||||||||
2408 | case QEvent::ChildRemoved: { never executed: case QEvent::ChildRemoved: | 0 | ||||||||||||||||||
2409 | d->isSubWindowsTiled = false; | - | ||||||||||||||||||
2410 | QObject *removedChild = static_cast<QChildEvent *>(event)->child(); | - | ||||||||||||||||||
2411 | for (int i = 0; i < d->childWindows.size(); ++i) {
| 0 | ||||||||||||||||||
2412 | QObject *child = d->childWindows.at(i); | - | ||||||||||||||||||
2413 | if (!child || child == removedChild || !child->parent()
| 0 | ||||||||||||||||||
2414 | || child->parent() != viewport()) {
| 0 | ||||||||||||||||||
2415 | if (!testOption(DontMaximizeSubWindowOnActivation)) {
| 0 | ||||||||||||||||||
2416 | // In this case we can only rely on the child being a QObject | - | ||||||||||||||||||
2417 | // (or 0), but let's try and see if we can get more information. | - | ||||||||||||||||||
2418 | QWidget *mdiChild = qobject_cast<QWidget *>(removedChild); | - | ||||||||||||||||||
2419 | if (mdiChild && mdiChild->isMaximized())
| 0 | ||||||||||||||||||
2420 | d->showActiveWindowMaximized = true; never executed: d->showActiveWindowMaximized = true; | 0 | ||||||||||||||||||
2421 | } never executed: end of block | 0 | ||||||||||||||||||
2422 | d->disconnectSubWindow(child); | - | ||||||||||||||||||
2423 | const bool activeRemoved = i == d->indicesToActivatedChildren.at(0); | - | ||||||||||||||||||
2424 | d->childWindows.removeAt(i); | - | ||||||||||||||||||
2425 | d->indicesToActivatedChildren.removeAll(i); | - | ||||||||||||||||||
2426 | d->updateActiveWindow(i, activeRemoved); | - | ||||||||||||||||||
2427 | d->arrangeMinimizedSubWindows(); | - | ||||||||||||||||||
2428 | break; never executed: break; | 0 | ||||||||||||||||||
2429 | } | - | ||||||||||||||||||
2430 | } never executed: end of block | 0 | ||||||||||||||||||
2431 | d->updateScrollBars(); | - | ||||||||||||||||||
2432 | break; never executed: break; | 0 | ||||||||||||||||||
2433 | } | - | ||||||||||||||||||
2434 | case QEvent::Destroy: never executed: case QEvent::Destroy: | 0 | ||||||||||||||||||
2435 | d->isSubWindowsTiled = false; | - | ||||||||||||||||||
2436 | d->resetActiveWindow(); | - | ||||||||||||||||||
2437 | d->childWindows.clear(); | - | ||||||||||||||||||
2438 | qWarning("QMdiArea: Deleting the view port is undefined, use setViewport instead."); | - | ||||||||||||||||||
2439 | break; never executed: break; | 0 | ||||||||||||||||||
2440 | default: never executed: default: | 0 | ||||||||||||||||||
2441 | break; never executed: break; | 0 | ||||||||||||||||||
2442 | } | - | ||||||||||||||||||
2443 | return QAbstractScrollArea::viewportEvent(event); never executed: return QAbstractScrollArea::viewportEvent(event); | 0 | ||||||||||||||||||
2444 | } | - | ||||||||||||||||||
2445 | - | |||||||||||||||||||
2446 | /*! | - | ||||||||||||||||||
2447 | \reimp | - | ||||||||||||||||||
2448 | */ | - | ||||||||||||||||||
2449 | void QMdiArea::scrollContentsBy(int dx, int dy) | - | ||||||||||||||||||
2450 | { | - | ||||||||||||||||||
2451 | Q_D(QMdiArea); | - | ||||||||||||||||||
2452 | const bool wasSubWindowsTiled = d->isSubWindowsTiled; | - | ||||||||||||||||||
2453 | d->ignoreGeometryChange = true; | - | ||||||||||||||||||
2454 | viewport()->scroll(isLeftToRight() ? dx : -dx, dy); | - | ||||||||||||||||||
2455 | d->arrangeMinimizedSubWindows(); | - | ||||||||||||||||||
2456 | d->ignoreGeometryChange = false; | - | ||||||||||||||||||
2457 | if (wasSubWindowsTiled)
| 0 | ||||||||||||||||||
2458 | d->isSubWindowsTiled = true; never executed: d->isSubWindowsTiled = true; | 0 | ||||||||||||||||||
2459 | } never executed: end of block | 0 | ||||||||||||||||||
2460 | - | |||||||||||||||||||
2461 | /*! | - | ||||||||||||||||||
2462 | Arranges all child windows in a tile pattern. | - | ||||||||||||||||||
2463 | - | |||||||||||||||||||
2464 | \sa cascadeSubWindows() | - | ||||||||||||||||||
2465 | */ | - | ||||||||||||||||||
2466 | void QMdiArea::tileSubWindows() | - | ||||||||||||||||||
2467 | { | - | ||||||||||||||||||
2468 | Q_D(QMdiArea); | - | ||||||||||||||||||
2469 | if (!d->regularTiler)
| 0 | ||||||||||||||||||
2470 | d->regularTiler = new RegularTiler; never executed: d->regularTiler = new RegularTiler; | 0 | ||||||||||||||||||
2471 | d->rearrange(d->regularTiler); | - | ||||||||||||||||||
2472 | } never executed: end of block | 0 | ||||||||||||||||||
2473 | - | |||||||||||||||||||
2474 | /*! | - | ||||||||||||||||||
2475 | Arranges all the child windows in a cascade pattern. | - | ||||||||||||||||||
2476 | - | |||||||||||||||||||
2477 | \sa tileSubWindows() | - | ||||||||||||||||||
2478 | */ | - | ||||||||||||||||||
2479 | void QMdiArea::cascadeSubWindows() | - | ||||||||||||||||||
2480 | { | - | ||||||||||||||||||
2481 | Q_D(QMdiArea); | - | ||||||||||||||||||
2482 | if (!d->cascader)
| 0 | ||||||||||||||||||
2483 | d->cascader = new SimpleCascader; never executed: d->cascader = new SimpleCascader; | 0 | ||||||||||||||||||
2484 | d->rearrange(d->cascader); | - | ||||||||||||||||||
2485 | } never executed: end of block | 0 | ||||||||||||||||||
2486 | - | |||||||||||||||||||
2487 | /*! | - | ||||||||||||||||||
2488 | \reimp | - | ||||||||||||||||||
2489 | */ | - | ||||||||||||||||||
2490 | bool QMdiArea::event(QEvent *event) | - | ||||||||||||||||||
2491 | { | - | ||||||||||||||||||
2492 | Q_D(QMdiArea); | - | ||||||||||||||||||
2493 | switch (event->type()) { | - | ||||||||||||||||||
2494 | #ifdef Q_DEAD_CODE_FROM_QT4_WIN | - | ||||||||||||||||||
2495 | // QWidgetPrivate::hide_helper activates another sub-window when closing a | - | ||||||||||||||||||
2496 | // modal dialog on Windows (see activateWindow() inside the ifdef). | - | ||||||||||||||||||
2497 | case QEvent::WindowUnblocked: | - | ||||||||||||||||||
2498 | d->activateCurrentWindow(); | - | ||||||||||||||||||
2499 | break; | - | ||||||||||||||||||
2500 | #endif | - | ||||||||||||||||||
2501 | case QEvent::WindowActivate: { never executed: case QEvent::WindowActivate: | 0 | ||||||||||||||||||
2502 | d->isActivated = true; | - | ||||||||||||||||||
2503 | if (d->childWindows.isEmpty())
| 0 | ||||||||||||||||||
2504 | break; never executed: break; | 0 | ||||||||||||||||||
2505 | if (!d->active)
| 0 | ||||||||||||||||||
2506 | d->activateCurrentWindow(); never executed: d->activateCurrentWindow(); | 0 | ||||||||||||||||||
2507 | d->setChildActivationEnabled(false, true); | - | ||||||||||||||||||
2508 | break; never executed: break; | 0 | ||||||||||||||||||
2509 | } | - | ||||||||||||||||||
2510 | case QEvent::WindowDeactivate: never executed: case QEvent::WindowDeactivate: | 0 | ||||||||||||||||||
2511 | d->isActivated = false; | - | ||||||||||||||||||
2512 | d->setChildActivationEnabled(false, true); | - | ||||||||||||||||||
2513 | break; never executed: break; | 0 | ||||||||||||||||||
2514 | case QEvent::StyleChange: never executed: case QEvent::StyleChange: | 0 | ||||||||||||||||||
2515 | // Re-tile the views if we're in tiled mode. Re-tile means we will change | - | ||||||||||||||||||
2516 | // the geometry of the children, which in turn means 'isSubWindowsTiled' | - | ||||||||||||||||||
2517 | // is set to false, so we have to update the state at the end. | - | ||||||||||||||||||
2518 | if (d->isSubWindowsTiled) {
| 0 | ||||||||||||||||||
2519 | tileSubWindows(); | - | ||||||||||||||||||
2520 | d->isSubWindowsTiled = true; | - | ||||||||||||||||||
2521 | } never executed: end of block | 0 | ||||||||||||||||||
2522 | break; never executed: break; | 0 | ||||||||||||||||||
2523 | case QEvent::WindowIconChange: never executed: case QEvent::WindowIconChange: | 0 | ||||||||||||||||||
2524 | foreach (QMdiSubWindow *window, d->childWindows) { | - | ||||||||||||||||||
2525 | if (sanityCheck(window, "QMdiArea::WindowIconChange"))
| 0 | ||||||||||||||||||
2526 | QApplication::sendEvent(window, event); never executed: QApplication::sendEvent(window, event); | 0 | ||||||||||||||||||
2527 | } never executed: end of block | 0 | ||||||||||||||||||
2528 | break; never executed: break; | 0 | ||||||||||||||||||
2529 | case QEvent::Hide: never executed: case QEvent::Hide: | 0 | ||||||||||||||||||
2530 | d->setActive(d->active, false, false); | - | ||||||||||||||||||
2531 | d->setChildActivationEnabled(false); | - | ||||||||||||||||||
2532 | break; never executed: break; | 0 | ||||||||||||||||||
2533 | #ifndef QT_NO_TABBAR | - | ||||||||||||||||||
2534 | case QEvent::LayoutDirectionChange: never executed: case QEvent::LayoutDirectionChange: | 0 | ||||||||||||||||||
2535 | d->updateTabBarGeometry(); | - | ||||||||||||||||||
2536 | break; never executed: break; | 0 | ||||||||||||||||||
2537 | #endif | - | ||||||||||||||||||
2538 | default: never executed: default: | 0 | ||||||||||||||||||
2539 | break; never executed: break; | 0 | ||||||||||||||||||
2540 | } | - | ||||||||||||||||||
2541 | return QAbstractScrollArea::event(event); never executed: return QAbstractScrollArea::event(event); | 0 | ||||||||||||||||||
2542 | } | - | ||||||||||||||||||
2543 | - | |||||||||||||||||||
2544 | /*! | - | ||||||||||||||||||
2545 | \reimp | - | ||||||||||||||||||
2546 | */ | - | ||||||||||||||||||
2547 | bool QMdiArea::eventFilter(QObject *object, QEvent *event) | - | ||||||||||||||||||
2548 | { | - | ||||||||||||||||||
2549 | if (!object)
| 0 | ||||||||||||||||||
2550 | return QAbstractScrollArea::eventFilter(object, event); never executed: return QAbstractScrollArea::eventFilter(object, event); | 0 | ||||||||||||||||||
2551 | - | |||||||||||||||||||
2552 | Q_D(QMdiArea); | - | ||||||||||||||||||
2553 | // Global key events with Ctrl modifier. | - | ||||||||||||||||||
2554 | if (event->type() == QEvent::KeyPress || event->type() == QEvent::KeyRelease) {
| 0 | ||||||||||||||||||
2555 | - | |||||||||||||||||||
2556 | QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event); | - | ||||||||||||||||||
2557 | // Ingore key events without a Ctrl modifier (except for press/release on the modifier itself). | - | ||||||||||||||||||
2558 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||
2559 | if (!(keyEvent->modifiers() & Qt::MetaModifier) && keyEvent->key() != Qt::Key_Meta) | - | ||||||||||||||||||
2560 | #else | - | ||||||||||||||||||
2561 | if (!(keyEvent->modifiers() & Qt::ControlModifier) && keyEvent->key() != Qt::Key_Control)
| 0 | ||||||||||||||||||
2562 | #endif | - | ||||||||||||||||||
2563 | return QAbstractScrollArea::eventFilter(object, event); never executed: return QAbstractScrollArea::eventFilter(object, event); | 0 | ||||||||||||||||||
2564 | - | |||||||||||||||||||
2565 | // Find closest mdi area (in case we have a nested workspace). | - | ||||||||||||||||||
2566 | QMdiArea *area = mdiAreaParent(static_cast<QWidget *>(object)); | - | ||||||||||||||||||
2567 | if (!area)
| 0 | ||||||||||||||||||
2568 | return QAbstractScrollArea::eventFilter(object, event); never executed: return QAbstractScrollArea::eventFilter(object, event); | 0 | ||||||||||||||||||
2569 | - | |||||||||||||||||||
2570 | const bool keyPress = (event->type() == QEvent::KeyPress); | - | ||||||||||||||||||
2571 | - | |||||||||||||||||||
2572 | // 1) Ctrl-Tab once -> activate the previously active window. | - | ||||||||||||||||||
2573 | // 2) Ctrl-Tab (Tab, Tab, ...) -> iterate through all windows (activateNextSubWindow()). | - | ||||||||||||||||||
2574 | // 3) Ctrl-Shift-Tab (Tab, Tab, ...) -> iterate through all windows in the opposite | - | ||||||||||||||||||
2575 | // direction (activatePreviousSubWindow()) | - | ||||||||||||||||||
2576 | switch (keyEvent->key()) { | - | ||||||||||||||||||
2577 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||
2578 | case Qt::Key_Meta: | - | ||||||||||||||||||
2579 | #else | - | ||||||||||||||||||
2580 | case Qt::Key_Control: never executed: case Qt::Key_Control: | 0 | ||||||||||||||||||
2581 | #endif | - | ||||||||||||||||||
2582 | if (keyPress)
| 0 | ||||||||||||||||||
2583 | area->d_func()->startTabToPreviousTimer(); never executed: area->d_func()->startTabToPreviousTimer(); | 0 | ||||||||||||||||||
2584 | else | - | ||||||||||||||||||
2585 | area->d_func()->activateHighlightedWindow(); never executed: area->d_func()->activateHighlightedWindow(); | 0 | ||||||||||||||||||
2586 | break; never executed: break; | 0 | ||||||||||||||||||
2587 | case Qt::Key_Tab: never executed: case Qt::Key_Tab: | 0 | ||||||||||||||||||
2588 | case Qt::Key_Backtab: never executed: case Qt::Key_Backtab: | 0 | ||||||||||||||||||
2589 | if (keyPress)
| 0 | ||||||||||||||||||
2590 | area->d_func()->highlightNextSubWindow(keyEvent->key() == Qt::Key_Tab ? 1 : -1); never executed: area->d_func()->highlightNextSubWindow(keyEvent->key() == Qt::Key_Tab ? 1 : -1); | 0 | ||||||||||||||||||
2591 | return true; never executed: return true; | 0 | ||||||||||||||||||
2592 | #ifndef QT_NO_RUBBERBAND | - | ||||||||||||||||||
2593 | case Qt::Key_Escape: never executed: case Qt::Key_Escape: | 0 | ||||||||||||||||||
2594 | area->d_func()->hideRubberBand(); | - | ||||||||||||||||||
2595 | break; never executed: break; | 0 | ||||||||||||||||||
2596 | #endif | - | ||||||||||||||||||
2597 | default: never executed: default: | 0 | ||||||||||||||||||
2598 | break; never executed: break; | 0 | ||||||||||||||||||
2599 | } | - | ||||||||||||||||||
2600 | return QAbstractScrollArea::eventFilter(object, event); never executed: return QAbstractScrollArea::eventFilter(object, event); | 0 | ||||||||||||||||||
2601 | } | - | ||||||||||||||||||
2602 | - | |||||||||||||||||||
2603 | QMdiSubWindow *subWindow = qobject_cast<QMdiSubWindow *>(object); | - | ||||||||||||||||||
2604 | - | |||||||||||||||||||
2605 | if (!subWindow) {
| 0 | ||||||||||||||||||
2606 | // QApplication events: | - | ||||||||||||||||||
2607 | if (event->type() == QEvent::ApplicationActivate && !d->active
| 0 | ||||||||||||||||||
2608 | && isVisible() && !window()->isMinimized()) {
| 0 | ||||||||||||||||||
2609 | d->activateCurrentWindow(); | - | ||||||||||||||||||
2610 | } else if (event->type() == QEvent::ApplicationDeactivate && d->active) { never executed: end of block
| 0 | ||||||||||||||||||
2611 | d->setActive(d->active, false, false); | - | ||||||||||||||||||
2612 | } never executed: end of block | 0 | ||||||||||||||||||
2613 | return QAbstractScrollArea::eventFilter(object, event); never executed: return QAbstractScrollArea::eventFilter(object, event); | 0 | ||||||||||||||||||
2614 | } | - | ||||||||||||||||||
2615 | - | |||||||||||||||||||
2616 | if (subWindow->mdiArea() != this)
| 0 | ||||||||||||||||||
2617 | return QAbstractScrollArea::eventFilter(object, event); never executed: return QAbstractScrollArea::eventFilter(object, event); | 0 | ||||||||||||||||||
2618 | - | |||||||||||||||||||
2619 | // QMdiSubWindow events: | - | ||||||||||||||||||
2620 | switch (event->type()) { | - | ||||||||||||||||||
2621 | case QEvent::Move: never executed: case QEvent::Move: | 0 | ||||||||||||||||||
2622 | case QEvent::Resize: never executed: case QEvent::Resize: | 0 | ||||||||||||||||||
2623 | if (d->tileCalledFromResizeEvent)
| 0 | ||||||||||||||||||
2624 | break; never executed: break; | 0 | ||||||||||||||||||
2625 | d->updateScrollBars(); | - | ||||||||||||||||||
2626 | if (!subWindow->isMinimized())
| 0 | ||||||||||||||||||
2627 | d->isSubWindowsTiled = false; never executed: d->isSubWindowsTiled = false; | 0 | ||||||||||||||||||
2628 | break; never executed: break; | 0 | ||||||||||||||||||
2629 | case QEvent::Show: never executed: case QEvent::Show: | 0 | ||||||||||||||||||
2630 | #ifndef QT_NO_TABBAR | - | ||||||||||||||||||
2631 | if (d->tabBar) {
| 0 | ||||||||||||||||||
2632 | const int tabIndex = d->childWindows.indexOf(subWindow); | - | ||||||||||||||||||
2633 | if (!d->tabBar->isTabEnabled(tabIndex))
| 0 | ||||||||||||||||||
2634 | d->tabBar->setTabEnabled(tabIndex, true); never executed: d->tabBar->setTabEnabled(tabIndex, true); | 0 | ||||||||||||||||||
2635 | } never executed: end of block | 0 | ||||||||||||||||||
2636 | #endif // QT_NO_TABBAR | - | ||||||||||||||||||
2637 | // fall through | - | ||||||||||||||||||
2638 | case QEvent::Hide: code before this statement never executed: case QEvent::Hide: never executed: case QEvent::Hide: | 0 | ||||||||||||||||||
2639 | d->isSubWindowsTiled = false; | - | ||||||||||||||||||
2640 | break; never executed: break; | 0 | ||||||||||||||||||
2641 | #ifndef QT_NO_RUBBERBAND | - | ||||||||||||||||||
2642 | case QEvent::Close: never executed: case QEvent::Close: | 0 | ||||||||||||||||||
2643 | if (d->childWindows.indexOf(subWindow) == d->indexToHighlighted)
| 0 | ||||||||||||||||||
2644 | d->hideRubberBand(); never executed: d->hideRubberBand(); | 0 | ||||||||||||||||||
2645 | break; never executed: break; | 0 | ||||||||||||||||||
2646 | #endif | - | ||||||||||||||||||
2647 | #ifndef QT_NO_TABBAR | - | ||||||||||||||||||
2648 | case QEvent::WindowTitleChange: never executed: case QEvent::WindowTitleChange: | 0 | ||||||||||||||||||
2649 | case QEvent::ModifiedChange: never executed: case QEvent::ModifiedChange: | 0 | ||||||||||||||||||
2650 | if (d->tabBar)
| 0 | ||||||||||||||||||
2651 | d->tabBar->setTabText(d->childWindows.indexOf(subWindow), tabTextFor(subWindow)); never executed: d->tabBar->setTabText(d->childWindows.indexOf(subWindow), tabTextFor(subWindow)); | 0 | ||||||||||||||||||
2652 | break; never executed: break; | 0 | ||||||||||||||||||
2653 | case QEvent::WindowIconChange: never executed: case QEvent::WindowIconChange: | 0 | ||||||||||||||||||
2654 | if (d->tabBar)
| 0 | ||||||||||||||||||
2655 | d->tabBar->setTabIcon(d->childWindows.indexOf(subWindow), subWindow->windowIcon()); never executed: d->tabBar->setTabIcon(d->childWindows.indexOf(subWindow), subWindow->windowIcon()); | 0 | ||||||||||||||||||
2656 | break; never executed: break; | 0 | ||||||||||||||||||
2657 | #endif // QT_NO_TABBAR | - | ||||||||||||||||||
2658 | default: never executed: default: | 0 | ||||||||||||||||||
2659 | break; never executed: break; | 0 | ||||||||||||||||||
2660 | } | - | ||||||||||||||||||
2661 | return QAbstractScrollArea::eventFilter(object, event); never executed: return QAbstractScrollArea::eventFilter(object, event); | 0 | ||||||||||||||||||
2662 | } | - | ||||||||||||||||||
2663 | - | |||||||||||||||||||
2664 | /*! | - | ||||||||||||||||||
2665 | \reimp | - | ||||||||||||||||||
2666 | */ | - | ||||||||||||||||||
2667 | void QMdiArea::paintEvent(QPaintEvent *paintEvent) | - | ||||||||||||||||||
2668 | { | - | ||||||||||||||||||
2669 | Q_D(QMdiArea); | - | ||||||||||||||||||
2670 | QPainter painter(d->viewport); | - | ||||||||||||||||||
2671 | const QVector<QRect> &exposedRects = paintEvent->region().rects(); | - | ||||||||||||||||||
2672 | for (int i = 0; i < exposedRects.size(); ++i)
| 0 | ||||||||||||||||||
2673 | painter.fillRect(exposedRects.at(i), d->background); never executed: painter.fillRect(exposedRects.at(i), d->background); | 0 | ||||||||||||||||||
2674 | } never executed: end of block | 0 | ||||||||||||||||||
2675 | - | |||||||||||||||||||
2676 | /*! | - | ||||||||||||||||||
2677 | This slot is called by QAbstractScrollArea after setViewport() has been | - | ||||||||||||||||||
2678 | called. Reimplement this function in a subclass of QMdiArea to | - | ||||||||||||||||||
2679 | initialize the new \a viewport before it is used. | - | ||||||||||||||||||
2680 | - | |||||||||||||||||||
2681 | \sa setViewport() | - | ||||||||||||||||||
2682 | */ | - | ||||||||||||||||||
2683 | void QMdiArea::setupViewport(QWidget *viewport) | - | ||||||||||||||||||
2684 | { | - | ||||||||||||||||||
2685 | Q_D(QMdiArea); | - | ||||||||||||||||||
2686 | if (viewport)
| 0 | ||||||||||||||||||
2687 | viewport->setAttribute(Qt::WA_OpaquePaintEvent, d->background.isOpaque()); never executed: viewport->setAttribute(Qt::WA_OpaquePaintEvent, d->background.isOpaque()); | 0 | ||||||||||||||||||
2688 | foreach (QMdiSubWindow *child, d->childWindows) { | - | ||||||||||||||||||
2689 | if (!sanityCheck(child, "QMdiArea::setupViewport"))
| 0 | ||||||||||||||||||
2690 | continue; never executed: continue; | 0 | ||||||||||||||||||
2691 | child->setParent(viewport, child->windowFlags()); | - | ||||||||||||||||||
2692 | } never executed: end of block | 0 | ||||||||||||||||||
2693 | } never executed: end of block | 0 | ||||||||||||||||||
2694 | - | |||||||||||||||||||
2695 | QT_END_NAMESPACE | - | ||||||||||||||||||
2696 | - | |||||||||||||||||||
2697 | #include "moc_qmdiarea.cpp" | - | ||||||||||||||||||
2698 | - | |||||||||||||||||||
2699 | #endif // QT_NO_MDIAREA | - | ||||||||||||||||||
Source code | Switch to Preprocessed file |