Line | Source Code | Coverage |
---|
1 | /**************************************************************************** | - |
2 | ** | - |
3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). | - |
4 | ** Contact: http://www.qt-project.org/legal | - |
5 | ** | - |
6 | ** This file is part of the QtGui module of the Qt Toolkit. | - |
7 | ** | - |
8 | ** $QT_BEGIN_LICENSE:LGPL$ | - |
9 | ** Commercial License Usage | - |
10 | ** Licensees holding valid commercial Qt licenses may use this file in | - |
11 | ** accordance with the commercial license agreement provided with the | - |
12 | ** Software or, alternatively, in accordance with the terms contained in | - |
13 | ** a written agreement between you and Digia. For licensing terms and | - |
14 | ** conditions see http://qt.digia.com/licensing. For further information | - |
15 | ** use the contact form at http://qt.digia.com/contact-us. | - |
16 | ** | - |
17 | ** GNU Lesser General Public License Usage | - |
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - |
19 | ** General Public License version 2.1 as published by the Free Software | - |
20 | ** Foundation and appearing in the file LICENSE.LGPL included in the | - |
21 | ** packaging of this file. Please review the following information to | - |
22 | ** ensure the GNU Lesser General Public License version 2.1 requirements | - |
23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - |
24 | ** | - |
25 | ** In addition, as a special exception, Digia gives you certain additional | - |
26 | ** rights. These rights are described in the Digia Qt LGPL Exception | - |
27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - |
28 | ** | - |
29 | ** GNU General Public License Usage | - |
30 | ** Alternatively, this file may be used under the terms of the GNU | - |
31 | ** General Public License version 3.0 as published by the Free Software | - |
32 | ** Foundation and appearing in the file LICENSE.GPL included in the | - |
33 | ** packaging of this file. Please review the following information to | - |
34 | ** ensure the GNU General Public License version 3.0 requirements will be | - |
35 | ** met: http://www.gnu.org/copyleft/gpl.html. | - |
36 | ** | - |
37 | ** | - |
38 | ** $QT_END_LICENSE$ | - |
39 | ** | - |
40 | ****************************************************************************/ | - |
41 | | - |
42 | //#define QT_EXPERIMENTAL_CLIENT_DECORATIONS | - |
43 | | - |
44 | #include "qmainwindow.h" | - |
45 | #include "qmainwindowlayout_p.h" | - |
46 | | - |
47 | #ifndef QT_NO_MAINWINDOW | - |
48 | | - |
49 | #include "qdockwidget.h" | - |
50 | #include "qtoolbar.h" | - |
51 | | - |
52 | #include <qapplication.h> | - |
53 | #include <qmenubar.h> | - |
54 | #include <qstatusbar.h> | - |
55 | #include <qevent.h> | - |
56 | #include <qstyle.h> | - |
57 | #include <qdebug.h> | - |
58 | #include <qpainter.h> | - |
59 | | - |
60 | #include <private/qwidget_p.h> | - |
61 | #include "qtoolbar_p.h" | - |
62 | #include "qwidgetanimator_p.h" | - |
63 | #ifdef Q_WS_MAC | - |
64 | #include <private/qt_mac_p.h> | - |
65 | #include <private/qt_cocoa_helpers_mac_p.h> | - |
66 | QT_BEGIN_NAMESPACE | - |
67 | extern OSWindowRef qt_mac_window_for(const QWidget *); // qwidget_mac.cpp | - |
68 | QT_END_NAMESPACE | - |
69 | #endif | - |
70 | | - |
71 | QT_BEGIN_NAMESPACE | - |
72 | | - |
73 | class QMainWindowPrivate : public QWidgetPrivate | - |
74 | { | - |
75 | Q_DECLARE_PUBLIC(QMainWindow) | - |
76 | public: | - |
77 | inline QMainWindowPrivate() | - |
78 | : layout(0), explicitIconSize(false), toolButtonStyle(Qt::ToolButtonIconOnly) | - |
79 | #ifdef Q_WS_MAC | - |
80 | , useHIToolBar(false) | - |
81 | , activateUnifiedToolbarAfterFullScreen(false) | - |
82 | #endif | - |
83 | #if !defined(QT_NO_DOCKWIDGET) && !defined(QT_NO_CURSOR) | - |
84 | , hasOldCursor(false) , cursorAdjusted(false) | - |
85 | #endif | - |
86 | { } executed: } Execution Count:44 | 44 |
87 | QMainWindowLayout *layout; | - |
88 | QSize iconSize; | - |
89 | bool explicitIconSize; | - |
90 | Qt::ToolButtonStyle toolButtonStyle; | - |
91 | #ifdef Q_WS_MAC | - |
92 | bool useHIToolBar; | - |
93 | bool activateUnifiedToolbarAfterFullScreen; | - |
94 | #endif | - |
95 | void init(); | - |
96 | QList<int> hoverSeparator; | - |
97 | QPoint hoverPos; | - |
98 | | - |
99 | #if !defined(QT_NO_DOCKWIDGET) && !defined(QT_NO_CURSOR) | - |
100 | QCursor separatorCursor(const QList<int> &path) const; | - |
101 | void adjustCursor(const QPoint &pos); | - |
102 | QCursor oldCursor; | - |
103 | QCursor adjustedCursor; | - |
104 | uint hasOldCursor : 1; | - |
105 | uint cursorAdjusted : 1; | - |
106 | #endif | - |
107 | | - |
108 | static inline QMainWindowLayout *mainWindowLayout(const QMainWindow *mainWindow) | - |
109 | { | - |
110 | return mainWindow ? mainWindow->d_func()->layout : static_cast<QMainWindowLayout *>(0); executed: return mainWindow ? mainWindow->d_func()->layout : static_cast<QMainWindowLayout *>(0); Execution Count:2347 | 2347 |
111 | } | - |
112 | }; | - |
113 | | - |
114 | QMainWindowLayout *qt_mainwindow_layout(const QMainWindow *mainWindow) | - |
115 | { | - |
116 | return QMainWindowPrivate::mainWindowLayout(mainWindow); executed: return QMainWindowPrivate::mainWindowLayout(mainWindow); Execution Count:2347 | 2347 |
117 | } | - |
118 | | - |
119 | #ifdef QT_EXPERIMENTAL_CLIENT_DECORATIONS | - |
120 | Q_WIDGETS_EXPORT void qt_setMainWindowTitleWidget(QMainWindow *mainWindow, Qt::DockWidgetArea area, QWidget *widget) | - |
121 | { | - |
122 | QGridLayout *topLayout = qobject_cast<QGridLayout *>(mainWindow->layout()); | - |
123 | Q_ASSERT(topLayout); | - |
124 | | - |
125 | int row = 0; | - |
126 | int column = 0; | - |
127 | | - |
128 | switch (area) { | - |
129 | case Qt::LeftDockWidgetArea: | - |
130 | row = 1; | - |
131 | column = 0; | - |
132 | break; | - |
133 | case Qt::TopDockWidgetArea: | - |
134 | row = 0; | - |
135 | column = 1; | - |
136 | break; | - |
137 | case Qt::BottomDockWidgetArea: | - |
138 | row = 2; | - |
139 | column = 1; | - |
140 | break; | - |
141 | case Qt::RightDockWidgetArea: | - |
142 | row = 1; | - |
143 | column = 2; | - |
144 | break; | - |
145 | default: | - |
146 | Q_ASSERT_X(false, "qt_setMainWindowTitleWidget", "Unknown area"); | - |
147 | return; | - |
148 | } | - |
149 | | - |
150 | if (QLayoutItem *oldItem = topLayout->itemAtPosition(row, column)) | - |
151 | delete oldItem->widget(); | - |
152 | topLayout->addWidget(widget, row, column); | - |
153 | } | - |
154 | #endif | - |
155 | | - |
156 | void QMainWindowPrivate::init() | - |
157 | { | - |
158 | Q_Q(QMainWindow); executed (the execution status of this line is deduced): QMainWindow * const q = q_func(); | - |
159 | | - |
160 | #ifdef QT_EXPERIMENTAL_CLIENT_DECORATIONS | - |
161 | QGridLayout *topLayout = new QGridLayout(q); | - |
162 | topLayout->setContentsMargins(0, 0, 0, 0); | - |
163 | | - |
164 | layout = new QMainWindowLayout(q, topLayout); | - |
165 | | - |
166 | topLayout->addItem(layout, 1, 1); | - |
167 | #else | - |
168 | layout = new QMainWindowLayout(q, 0); executed (the execution status of this line is deduced): layout = new QMainWindowLayout(q, 0); | - |
169 | #endif | - |
170 | | - |
171 | const int metric = q->style()->pixelMetric(QStyle::PM_ToolBarIconSize, 0, q); executed (the execution status of this line is deduced): const int metric = q->style()->pixelMetric(QStyle::PM_ToolBarIconSize, 0, q); | - |
172 | iconSize = QSize(metric, metric); executed (the execution status of this line is deduced): iconSize = QSize(metric, metric); | - |
173 | q->setAttribute(Qt::WA_Hover); executed (the execution status of this line is deduced): q->setAttribute(Qt::WA_Hover); | - |
174 | } executed: } Execution Count:44 | 44 |
175 | | - |
176 | /* | - |
177 | The Main Window: | - |
178 | | - |
179 | +----------------------------------------------------------+ | - |
180 | | Menu Bar | | - |
181 | +----------------------------------------------------------+ | - |
182 | | Tool Bar Area | | - |
183 | | +--------------------------------------------------+ | | - |
184 | | | Dock Window Area | | | - |
185 | | | +------------------------------------------+ | | | - |
186 | | | | | | | | - |
187 | | | | Central Widget | | | | - |
188 | | | | | | | | - |
189 | | | | | | | | - |
190 | | | | | | | | - |
191 | | | | | | | | - |
192 | | | | | | | | - |
193 | | | | | | | | - |
194 | | | | | | | | - |
195 | | | | | | | | - |
196 | | | | | | | | - |
197 | | | | | | | | - |
198 | | | +------------------------------------------+ | | | - |
199 | | | | | | - |
200 | | +--------------------------------------------------+ | | - |
201 | | | | - |
202 | +----------------------------------------------------------+ | - |
203 | | Status Bar | | - |
204 | +----------------------------------------------------------+ | - |
205 | | - |
206 | */ | - |
207 | | - |
208 | /*! | - |
209 | \class QMainWindow | - |
210 | \brief The QMainWindow class provides a main application | - |
211 | window. | - |
212 | \ingroup mainwindow-classes | - |
213 | \inmodule QtWidgets | - |
214 | | - |
215 | \tableofcontents | - |
216 | | - |
217 | \section1 Qt Main Window Framework | - |
218 | | - |
219 | A main window provides a framework for building an | - |
220 | application's user interface. Qt has QMainWindow and its \l{Main | - |
221 | Window and Related Classes}{related classes} for main window | - |
222 | management. QMainWindow has its own layout to which you can add | - |
223 | \l{QToolBar}s, \l{QDockWidget}s, a | - |
224 | QMenuBar, and a QStatusBar. The layout has a center area that can | - |
225 | be occupied by any kind of widget. You can see an image of the | - |
226 | layout below. | - |
227 | | - |
228 | \image mainwindowlayout.png | - |
229 | | - |
230 | \note Creating a main window without a central widget is not supported. | - |
231 | You must have a central widget even if it is just a placeholder. | - |
232 | | - |
233 | \section1 Creating Main Window Components | - |
234 | | - |
235 | A central widget will typically be a standard Qt widget such | - |
236 | as a QTextEdit or a QGraphicsView. Custom widgets can also be | - |
237 | used for advanced applications. You set the central widget with \c | - |
238 | setCentralWidget(). | - |
239 | | - |
240 | Main windows have either a single (SDI) or multiple (MDI) | - |
241 | document interface. You create MDI applications in Qt by using a | - |
242 | QMdiArea as the central widget. | - |
243 | | - |
244 | We will now examine each of the other widgets that can be | - |
245 | added to a main window. We give examples on how to create and add | - |
246 | them. | - |
247 | | - |
248 | \section2 Creating Menus | - |
249 | | - |
250 | Qt implements menus in QMenu and QMainWindow keeps them in a | - |
251 | QMenuBar. \l{QAction}{QAction}s are added to the menus, which | - |
252 | display them as menu items. | - |
253 | | - |
254 | You can add new menus to the main window's menu bar by calling | - |
255 | \c menuBar(), which returns the QMenuBar for the window, and then | - |
256 | add a menu with QMenuBar::addMenu(). | - |
257 | | - |
258 | QMainWindow comes with a default menu bar, but you can also | - |
259 | set one yourself with \c setMenuBar(). If you wish to implement a | - |
260 | custom menu bar (i.e., not use the QMenuBar widget), you can set it | - |
261 | with \c setMenuWidget(). | - |
262 | | - |
263 | An example of how to create menus follows: | - |
264 | | - |
265 | \snippet mainwindows/application/mainwindow.cpp 26 | - |
266 | | - |
267 | The \c createPopupMenu() function creates popup menus when the | - |
268 | main window receives context menu events. The default | - |
269 | implementation generates a menu with the checkable actions from | - |
270 | the dock widgets and toolbars. You can reimplement \c | - |
271 | createPopupMenu() for a custom menu. | - |
272 | | - |
273 | \section2 Creating Toolbars | - |
274 | | - |
275 | Toolbars are implemented in the QToolBar class. You add a | - |
276 | toolbar to a main window with \c addToolBar(). | - |
277 | | - |
278 | You control the initial position of toolbars by assigning them | - |
279 | to a specific Qt::ToolBarArea. You can split an area by inserting | - |
280 | a toolbar break - think of this as a line break in text editing - | - |
281 | with \c addToolBarBreak() or \c insertToolBarBreak(). You can also | - |
282 | restrict placement by the user with QToolBar::setAllowedAreas() | - |
283 | and QToolBar::setMovable(). | - |
284 | | - |
285 | The size of toolbar icons can be retrieved with \c iconSize(). | - |
286 | The sizes are platform dependent; you can set a fixed size with \c | - |
287 | setIconSize(). You can alter the appearance of all tool buttons in | - |
288 | the toolbars with \c setToolButtonStyle(). | - |
289 | | - |
290 | An example of toolbar creation follows: | - |
291 | | - |
292 | \snippet mainwindows/application/mainwindow.cpp 29 | - |
293 | | - |
294 | \section2 Creating Dock Widgets | - |
295 | | - |
296 | Dock widgets are implemented in the QDockWidget class. A dock | - |
297 | widget is a window that can be docked into the main window. You | - |
298 | add dock widgets to a main window with \c addDockWidget(). | - |
299 | | - |
300 | There are four dock widget areas as given by the | - |
301 | Qt::DockWidgetArea enum: left, right, top, and bottom. You can | - |
302 | specify which dock widget area that should occupy the corners | - |
303 | where the areas overlap with \c setCorner(). By default | - |
304 | each area can only contain one row (vertical or horizontal) of | - |
305 | dock widgets, but if you enable nesting with \c | - |
306 | setDockNestingEnabled(), dock widgets can be added in either | - |
307 | direction. | - |
308 | | - |
309 | Two dock widgets may also be stacked on top of each other. A | - |
310 | QTabBar is then used to select which of the widgets that should be | - |
311 | displayed. | - |
312 | | - |
313 | We give an example of how to create and add dock widgets to a | - |
314 | main window: | - |
315 | | - |
316 | \snippet mainwindowsnippet.cpp 0 | - |
317 | | - |
318 | \section2 The Status Bar | - |
319 | | - |
320 | You can set a status bar with \c setStatusBar(), but one is | - |
321 | created the first time \c statusBar() (which returns the main | - |
322 | window's status bar) is called. See QStatusBar for information on | - |
323 | how to use it. | - |
324 | | - |
325 | \section1 Storing State | - |
326 | | - |
327 | QMainWindow can store the state of its layout with \c | - |
328 | saveState(); it can later be retrieved with \c restoreState(). It | - |
329 | is the position and size (relative to the size of the main window) | - |
330 | of the toolbars and dock widgets that are stored. | - |
331 | | - |
332 | \sa QMenuBar, QToolBar, QStatusBar, QDockWidget, {Application | - |
333 | Example}, {Dock Widgets Example}, {MDI Example}, {SDI Example}, | - |
334 | {Menus Example} | - |
335 | */ | - |
336 | | - |
337 | /*! | - |
338 | \fn void QMainWindow::iconSizeChanged(const QSize &iconSize) | - |
339 | | - |
340 | This signal is emitted when the size of the icons used in the | - |
341 | window is changed. The new icon size is passed in \a iconSize. | - |
342 | | - |
343 | You can connect this signal to other components to help maintain | - |
344 | a consistent appearance for your application. | - |
345 | | - |
346 | \sa setIconSize() | - |
347 | */ | - |
348 | | - |
349 | /*! | - |
350 | \fn void QMainWindow::toolButtonStyleChanged(Qt::ToolButtonStyle toolButtonStyle) | - |
351 | | - |
352 | This signal is emitted when the style used for tool buttons in the | - |
353 | window is changed. The new style is passed in \a toolButtonStyle. | - |
354 | | - |
355 | You can connect this signal to other components to help maintain | - |
356 | a consistent appearance for your application. | - |
357 | | - |
358 | \sa setToolButtonStyle() | - |
359 | */ | - |
360 | | - |
361 | /*! | - |
362 | Constructs a QMainWindow with the given \a parent and the specified | - |
363 | widget \a flags. | - |
364 | | - |
365 | QMainWindow sets the Qt::Window flag itself, and will hence | - |
366 | always be created as a top-level widget. | - |
367 | */ | - |
368 | QMainWindow::QMainWindow(QWidget *parent, Qt::WindowFlags flags) | - |
369 | : QWidget(*(new QMainWindowPrivate()), parent, flags | Qt::Window) | - |
370 | { | - |
371 | d_func()->init(); executed (the execution status of this line is deduced): d_func()->init(); | - |
372 | } executed: } Execution Count:44 | 44 |
373 | | - |
374 | | - |
375 | /*! | - |
376 | Destroys the main window. | - |
377 | */ | - |
378 | QMainWindow::~QMainWindow() | - |
379 | { } | - |
380 | | - |
381 | /*! \property QMainWindow::iconSize | - |
382 | \brief size of toolbar icons in this mainwindow. | - |
383 | | - |
384 | The default is the default tool bar icon size of the GUI style. | - |
385 | Note that the icons used must be at least of this size as the | - |
386 | icons are only scaled down. | - |
387 | */ | - |
388 | | - |
389 | /*! | - |
390 | \property QMainWindow::dockOptions | - |
391 | \brief the docking behavior of QMainWindow | - |
392 | \since 4.3 | - |
393 | | - |
394 | The default value is AnimatedDocks | AllowTabbedDocks. | - |
395 | */ | - |
396 | | - |
397 | /*! | - |
398 | \enum QMainWindow::DockOption | - |
399 | \since 4.3 | - |
400 | | - |
401 | This enum contains flags that specify the docking behavior of QMainWindow. | - |
402 | | - |
403 | \value AnimatedDocks Identical to the \l animated property. | - |
404 | | - |
405 | \value AllowNestedDocks Identical to the \l dockNestingEnabled property. | - |
406 | | - |
407 | \value AllowTabbedDocks The user can drop one dock widget "on top" of | - |
408 | another. The two widgets are stacked and a tab | - |
409 | bar appears for selecting which one is visible. | - |
410 | | - |
411 | \value ForceTabbedDocks Each dock area contains a single stack of tabbed | - |
412 | dock widgets. In other words, dock widgets cannot | - |
413 | be placed next to each other in a dock area. If | - |
414 | this option is set, AllowNestedDocks has no effect. | - |
415 | | - |
416 | \value VerticalTabs The two vertical dock areas on the sides of the | - |
417 | main window show their tabs vertically. If this | - |
418 | option is not set, all dock areas show their tabs | - |
419 | at the bottom. Implies AllowTabbedDocks. See also | - |
420 | \l setTabPosition(). | - |
421 | | - |
422 | These options only control how dock widgets may be dropped in a QMainWindow. | - |
423 | They do not re-arrange the dock widgets to conform with the specified | - |
424 | options. For this reason they should be set before any dock widgets | - |
425 | are added to the main window. Exceptions to this are the AnimatedDocks and | - |
426 | VerticalTabs options, which may be set at any time. | - |
427 | */ | - |
428 | | - |
429 | void QMainWindow::setDockOptions(DockOptions opt) | - |
430 | { | - |
431 | Q_D(QMainWindow); never executed (the execution status of this line is deduced): QMainWindowPrivate * const d = d_func(); | - |
432 | d->layout->setDockOptions(opt); never executed (the execution status of this line is deduced): d->layout->setDockOptions(opt); | - |
433 | } | 0 |
434 | | - |
435 | QMainWindow::DockOptions QMainWindow::dockOptions() const | - |
436 | { | - |
437 | Q_D(const QMainWindow); never executed (the execution status of this line is deduced): const QMainWindowPrivate * const d = d_func(); | - |
438 | return d->layout->dockOptions; never executed: return d->layout->dockOptions; | 0 |
439 | } | - |
440 | | - |
441 | QSize QMainWindow::iconSize() const | - |
442 | { return d_func()->iconSize; } never executed: return d_func()->iconSize; | 0 |
443 | | - |
444 | void QMainWindow::setIconSize(const QSize &iconSize) | - |
445 | { | - |
446 | Q_D(QMainWindow); executed (the execution status of this line is deduced): QMainWindowPrivate * const d = d_func(); | - |
447 | QSize sz = iconSize; executed (the execution status of this line is deduced): QSize sz = iconSize; | - |
448 | if (!sz.isValid()) { partially evaluated: !sz.isValid() yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
449 | const int metric = style()->pixelMetric(QStyle::PM_ToolBarIconSize, 0, this); executed (the execution status of this line is deduced): const int metric = style()->pixelMetric(QStyle::PM_ToolBarIconSize, 0, this); | - |
450 | sz = QSize(metric, metric); executed (the execution status of this line is deduced): sz = QSize(metric, metric); | - |
451 | } executed: } Execution Count:1 | 1 |
452 | if (d->iconSize != sz) { partially evaluated: d->iconSize != sz no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
453 | d->iconSize = sz; never executed (the execution status of this line is deduced): d->iconSize = sz; | - |
454 | emit iconSizeChanged(d->iconSize); never executed (the execution status of this line is deduced): iconSizeChanged(d->iconSize); | - |
455 | } | 0 |
456 | d->explicitIconSize = iconSize.isValid(); executed (the execution status of this line is deduced): d->explicitIconSize = iconSize.isValid(); | - |
457 | } executed: } Execution Count:1 | 1 |
458 | | - |
459 | /*! \property QMainWindow::toolButtonStyle | - |
460 | \brief style of toolbar buttons in this mainwindow. | - |
461 | | - |
462 | The default is Qt::ToolButtonIconOnly. | - |
463 | */ | - |
464 | | - |
465 | Qt::ToolButtonStyle QMainWindow::toolButtonStyle() const | - |
466 | { return d_func()->toolButtonStyle; } never executed: return d_func()->toolButtonStyle; | 0 |
467 | | - |
468 | void QMainWindow::setToolButtonStyle(Qt::ToolButtonStyle toolButtonStyle) | - |
469 | { | - |
470 | Q_D(QMainWindow); never executed (the execution status of this line is deduced): QMainWindowPrivate * const d = d_func(); | - |
471 | if (d->toolButtonStyle == toolButtonStyle) never evaluated: d->toolButtonStyle == toolButtonStyle | 0 |
472 | return; | 0 |
473 | d->toolButtonStyle = toolButtonStyle; never executed (the execution status of this line is deduced): d->toolButtonStyle = toolButtonStyle; | - |
474 | emit toolButtonStyleChanged(d->toolButtonStyle); never executed (the execution status of this line is deduced): toolButtonStyleChanged(d->toolButtonStyle); | - |
475 | } | 0 |
476 | | - |
477 | #ifndef QT_NO_MENUBAR | - |
478 | /*! | - |
479 | Returns the menu bar for the main window. This function creates | - |
480 | and returns an empty menu bar if the menu bar does not exist. | - |
481 | | - |
482 | If you want all windows in a Mac application to share one menu | - |
483 | bar, don't use this function to create it, because the menu bar | - |
484 | created here will have this QMainWindow as its parent. Instead, | - |
485 | you must create a menu bar that does not have a parent, which you | - |
486 | can then share among all the Mac windows. Create a parent-less | - |
487 | menu bar this way: | - |
488 | | - |
489 | \snippet code/src_gui_widgets_qmenubar.cpp 1 | - |
490 | | - |
491 | \sa setMenuBar() | - |
492 | */ | - |
493 | QMenuBar *QMainWindow::menuBar() const | - |
494 | { | - |
495 | QMenuBar *menuBar = qobject_cast<QMenuBar *>(layout()->menuBar()); executed (the execution status of this line is deduced): QMenuBar *menuBar = qobject_cast<QMenuBar *>(layout()->menuBar()); | - |
496 | if (!menuBar) { evaluated: !menuBar yes Evaluation Count:14 | yes Evaluation Count:140 |
| 14-140 |
497 | QMainWindow *self = const_cast<QMainWindow *>(this); executed (the execution status of this line is deduced): QMainWindow *self = const_cast<QMainWindow *>(this); | - |
498 | menuBar = new QMenuBar(self); executed (the execution status of this line is deduced): menuBar = new QMenuBar(self); | - |
499 | self->setMenuBar(menuBar); executed (the execution status of this line is deduced): self->setMenuBar(menuBar); | - |
500 | } executed: } Execution Count:14 | 14 |
501 | return menuBar; executed: return menuBar; Execution Count:154 | 154 |
502 | } | - |
503 | | - |
504 | /*! | - |
505 | Sets the menu bar for the main window to \a menuBar. | - |
506 | | - |
507 | Note: QMainWindow takes ownership of the \a menuBar pointer and | - |
508 | deletes it at the appropriate time. | - |
509 | | - |
510 | \sa menuBar() | - |
511 | */ | - |
512 | void QMainWindow::setMenuBar(QMenuBar *menuBar) | - |
513 | { | - |
514 | QLayout *topLayout = layout(); executed (the execution status of this line is deduced): QLayout *topLayout = layout(); | - |
515 | | - |
516 | if (topLayout->menuBar() && topLayout->menuBar() != menuBar) { evaluated: topLayout->menuBar() yes Evaluation Count:2 | yes Evaluation Count:16 |
partially evaluated: topLayout->menuBar() != menuBar yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-16 |
517 | // Reparent corner widgets before we delete the old menu bar. | - |
518 | QMenuBar *oldMenuBar = qobject_cast<QMenuBar *>(topLayout->menuBar()); executed (the execution status of this line is deduced): QMenuBar *oldMenuBar = qobject_cast<QMenuBar *>(topLayout->menuBar()); | - |
519 | if (menuBar) { evaluated: menuBar yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1 |
520 | // TopLeftCorner widget. | - |
521 | QWidget *cornerWidget = oldMenuBar->cornerWidget(Qt::TopLeftCorner); executed (the execution status of this line is deduced): QWidget *cornerWidget = oldMenuBar->cornerWidget(Qt::TopLeftCorner); | - |
522 | if (cornerWidget) partially evaluated: cornerWidget yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
523 | menuBar->setCornerWidget(cornerWidget, Qt::TopLeftCorner); executed: menuBar->setCornerWidget(cornerWidget, Qt::TopLeftCorner); Execution Count:1 | 1 |
524 | // TopRightCorner widget. | - |
525 | cornerWidget = oldMenuBar->cornerWidget(Qt::TopRightCorner); executed (the execution status of this line is deduced): cornerWidget = oldMenuBar->cornerWidget(Qt::TopRightCorner); | - |
526 | if (cornerWidget) partially evaluated: cornerWidget yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
527 | menuBar->setCornerWidget(cornerWidget, Qt::TopRightCorner); executed: menuBar->setCornerWidget(cornerWidget, Qt::TopRightCorner); Execution Count:1 | 1 |
528 | } executed: } Execution Count:1 | 1 |
529 | oldMenuBar->hide(); executed (the execution status of this line is deduced): oldMenuBar->hide(); | - |
530 | oldMenuBar->deleteLater(); executed (the execution status of this line is deduced): oldMenuBar->deleteLater(); | - |
531 | } executed: } Execution Count:2 | 2 |
532 | topLayout->setMenuBar(menuBar); executed (the execution status of this line is deduced): topLayout->setMenuBar(menuBar); | - |
533 | } executed: } Execution Count:18 | 18 |
534 | | - |
535 | /*! | - |
536 | \since 4.2 | - |
537 | | - |
538 | Returns the menu bar for the main window. This function returns | - |
539 | null if a menu bar hasn't been constructed yet. | - |
540 | */ | - |
541 | QWidget *QMainWindow::menuWidget() const | - |
542 | { | - |
543 | QWidget *menuBar = d_func()->layout->menuBar(); executed (the execution status of this line is deduced): QWidget *menuBar = d_func()->layout->menuBar(); | - |
544 | return menuBar; executed: return menuBar; Execution Count:7368 | 7368 |
545 | } | - |
546 | | - |
547 | /*! | - |
548 | \since 4.2 | - |
549 | | - |
550 | Sets the menu bar for the main window to \a menuBar. | - |
551 | | - |
552 | QMainWindow takes ownership of the \a menuBar pointer and | - |
553 | deletes it at the appropriate time. | - |
554 | */ | - |
555 | void QMainWindow::setMenuWidget(QWidget *menuBar) | - |
556 | { | - |
557 | Q_D(QMainWindow); executed (the execution status of this line is deduced): QMainWindowPrivate * const d = d_func(); | - |
558 | if (d->layout->menuBar() && d->layout->menuBar() != menuBar) { partially evaluated: d->layout->menuBar() no Evaluation Count:0 | yes Evaluation Count:1 |
never evaluated: d->layout->menuBar() != menuBar | 0-1 |
559 | d->layout->menuBar()->hide(); never executed (the execution status of this line is deduced): d->layout->menuBar()->hide(); | - |
560 | d->layout->menuBar()->deleteLater(); never executed (the execution status of this line is deduced): d->layout->menuBar()->deleteLater(); | - |
561 | } | 0 |
562 | d->layout->setMenuBar(menuBar); executed (the execution status of this line is deduced): d->layout->setMenuBar(menuBar); | - |
563 | } executed: } Execution Count:1 | 1 |
564 | #endif // QT_NO_MENUBAR | - |
565 | | - |
566 | #ifndef QT_NO_STATUSBAR | - |
567 | /*! | - |
568 | Returns the status bar for the main window. This function creates | - |
569 | and returns an empty status bar if the status bar does not exist. | - |
570 | | - |
571 | \sa setStatusBar() | - |
572 | */ | - |
573 | QStatusBar *QMainWindow::statusBar() const | - |
574 | { | - |
575 | QStatusBar *statusbar = d_func()->layout->statusBar(); executed (the execution status of this line is deduced): QStatusBar *statusbar = d_func()->layout->statusBar(); | - |
576 | if (!statusbar) { evaluated: !statusbar yes Evaluation Count:3 | yes Evaluation Count:1 |
| 1-3 |
577 | QMainWindow *self = const_cast<QMainWindow *>(this); executed (the execution status of this line is deduced): QMainWindow *self = const_cast<QMainWindow *>(this); | - |
578 | statusbar = new QStatusBar(self); executed (the execution status of this line is deduced): statusbar = new QStatusBar(self); | - |
579 | statusbar->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed); executed (the execution status of this line is deduced): statusbar->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed); | - |
580 | self->setStatusBar(statusbar); executed (the execution status of this line is deduced): self->setStatusBar(statusbar); | - |
581 | } executed: } Execution Count:3 | 3 |
582 | return statusbar; executed: return statusbar; Execution Count:4 | 4 |
583 | } | - |
584 | | - |
585 | /*! | - |
586 | Sets the status bar for the main window to \a statusbar. | - |
587 | | - |
588 | Setting the status bar to 0 will remove it from the main window. | - |
589 | Note that QMainWindow takes ownership of the \a statusbar pointer | - |
590 | and deletes it at the appropriate time. | - |
591 | | - |
592 | \sa statusBar() | - |
593 | */ | - |
594 | void QMainWindow::setStatusBar(QStatusBar *statusbar) | - |
595 | { | - |
596 | Q_D(QMainWindow); executed (the execution status of this line is deduced): QMainWindowPrivate * const d = d_func(); | - |
597 | if (d->layout->statusBar() && d->layout->statusBar() != statusbar) { evaluated: d->layout->statusBar() yes Evaluation Count:1 | yes Evaluation Count:4 |
partially evaluated: d->layout->statusBar() != statusbar yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-4 |
598 | d->layout->statusBar()->hide(); executed (the execution status of this line is deduced): d->layout->statusBar()->hide(); | - |
599 | d->layout->statusBar()->deleteLater(); executed (the execution status of this line is deduced): d->layout->statusBar()->deleteLater(); | - |
600 | } executed: } Execution Count:1 | 1 |
601 | d->layout->setStatusBar(statusbar); executed (the execution status of this line is deduced): d->layout->setStatusBar(statusbar); | - |
602 | } executed: } Execution Count:5 | 5 |
603 | #endif // QT_NO_STATUSBAR | - |
604 | | - |
605 | /*! | - |
606 | Returns the central widget for the main window. This function | - |
607 | returns zero if the central widget has not been set. | - |
608 | | - |
609 | \sa setCentralWidget() | - |
610 | */ | - |
611 | QWidget *QMainWindow::centralWidget() const | - |
612 | { return d_func()->layout->centralWidget(); } never executed: return d_func()->layout->centralWidget(); | 0 |
613 | | - |
614 | /*! | - |
615 | Sets the given \a widget to be the main window's central widget. | - |
616 | | - |
617 | Note: QMainWindow takes ownership of the \a widget pointer and | - |
618 | deletes it at the appropriate time. | - |
619 | | - |
620 | \sa centralWidget() | - |
621 | */ | - |
622 | void QMainWindow::setCentralWidget(QWidget *widget) | - |
623 | { | - |
624 | Q_D(QMainWindow); executed (the execution status of this line is deduced): QMainWindowPrivate * const d = d_func(); | - |
625 | if (d->layout->centralWidget() && d->layout->centralWidget() != widget) { partially evaluated: d->layout->centralWidget() no Evaluation Count:0 | yes Evaluation Count:18 |
never evaluated: d->layout->centralWidget() != widget | 0-18 |
626 | d->layout->centralWidget()->hide(); never executed (the execution status of this line is deduced): d->layout->centralWidget()->hide(); | - |
627 | d->layout->centralWidget()->deleteLater(); never executed (the execution status of this line is deduced): d->layout->centralWidget()->deleteLater(); | - |
628 | } | 0 |
629 | d->layout->setCentralWidget(widget); executed (the execution status of this line is deduced): d->layout->setCentralWidget(widget); | - |
630 | } executed: } Execution Count:18 | 18 |
631 | | - |
632 | #ifndef QT_NO_DOCKWIDGET | - |
633 | /*! | - |
634 | Sets the given dock widget \a area to occupy the specified \a | - |
635 | corner. | - |
636 | | - |
637 | \sa corner() | - |
638 | */ | - |
639 | void QMainWindow::setCorner(Qt::Corner corner, Qt::DockWidgetArea area) | - |
640 | { | - |
641 | bool valid = false; never executed (the execution status of this line is deduced): bool valid = false; | - |
642 | switch (corner) { | - |
643 | case Qt::TopLeftCorner: | - |
644 | valid = (area == Qt::TopDockWidgetArea || area == Qt::LeftDockWidgetArea); never evaluated: area == Qt::TopDockWidgetArea never evaluated: area == Qt::LeftDockWidgetArea | 0 |
645 | break; | 0 |
646 | case Qt::TopRightCorner: | - |
647 | valid = (area == Qt::TopDockWidgetArea || area == Qt::RightDockWidgetArea); never evaluated: area == Qt::TopDockWidgetArea never evaluated: area == Qt::RightDockWidgetArea | 0 |
648 | break; | 0 |
649 | case Qt::BottomLeftCorner: | - |
650 | valid = (area == Qt::BottomDockWidgetArea || area == Qt::LeftDockWidgetArea); never evaluated: area == Qt::BottomDockWidgetArea never evaluated: area == Qt::LeftDockWidgetArea | 0 |
651 | break; | 0 |
652 | case Qt::BottomRightCorner: | - |
653 | valid = (area == Qt::BottomDockWidgetArea || area == Qt::RightDockWidgetArea); never evaluated: area == Qt::BottomDockWidgetArea never evaluated: area == Qt::RightDockWidgetArea | 0 |
654 | break; | 0 |
655 | } | - |
656 | if (!valid) | 0 |
657 | qWarning("QMainWindow::setCorner(): 'area' is not valid for 'corner'"); never executed: QMessageLogger("widgets/qmainwindow.cpp", 657, __PRETTY_FUNCTION__).warning("QMainWindow::setCorner(): 'area' is not valid for 'corner'"); | 0 |
658 | else | - |
659 | d_func()->layout->setCorner(corner, area); never executed: d_func()->layout->setCorner(corner, area); | 0 |
660 | } | - |
661 | | - |
662 | /*! | - |
663 | Returns the dock widget area that occupies the specified \a | - |
664 | corner. | - |
665 | | - |
666 | \sa setCorner() | - |
667 | */ | - |
668 | Qt::DockWidgetArea QMainWindow::corner(Qt::Corner corner) const | - |
669 | { return d_func()->layout->corner(corner); } never executed: return d_func()->layout->corner(corner); | 0 |
670 | #endif | - |
671 | | - |
672 | #ifndef QT_NO_TOOLBAR | - |
673 | | - |
674 | static bool checkToolBarArea(Qt::ToolBarArea area, const char *where) | - |
675 | { | - |
676 | switch (area) { | - |
677 | case Qt::LeftToolBarArea: | - |
678 | case Qt::RightToolBarArea: | - |
679 | case Qt::TopToolBarArea: | - |
680 | case Qt::BottomToolBarArea: | - |
681 | return true; executed: return true; Execution Count:2 | 2 |
682 | default: | - |
683 | break; | 0 |
684 | } | - |
685 | qWarning("%s: invalid 'area' argument", where); never executed (the execution status of this line is deduced): QMessageLogger("widgets/qmainwindow.cpp", 685, __PRETTY_FUNCTION__).warning("%s: invalid 'area' argument", where); | - |
686 | return false; never executed: return false; | 0 |
687 | } | - |
688 | | - |
689 | /*! | - |
690 | Adds a toolbar break to the given \a area after all the other | - |
691 | objects that are present. | - |
692 | */ | - |
693 | void QMainWindow::addToolBarBreak(Qt::ToolBarArea area) | - |
694 | { | - |
695 | if (!checkToolBarArea(area, "QMainWindow::addToolBarBreak")) never evaluated: !checkToolBarArea(area, "QMainWindow::addToolBarBreak") | 0 |
696 | return; | 0 |
697 | d_func()->layout->addToolBarBreak(area); never executed (the execution status of this line is deduced): d_func()->layout->addToolBarBreak(area); | - |
698 | } | 0 |
699 | | - |
700 | /*! | - |
701 | Inserts a toolbar break before the toolbar specified by \a before. | - |
702 | */ | - |
703 | void QMainWindow::insertToolBarBreak(QToolBar *before) | - |
704 | { d_func()->layout->insertToolBarBreak(before); } | 0 |
705 | | - |
706 | /*! | - |
707 | Removes a toolbar break previously inserted before the toolbar specified by \a before. | - |
708 | */ | - |
709 | | - |
710 | void QMainWindow::removeToolBarBreak(QToolBar *before) | - |
711 | { | - |
712 | Q_D(QMainWindow); never executed (the execution status of this line is deduced): QMainWindowPrivate * const d = d_func(); | - |
713 | d->layout->removeToolBarBreak(before); never executed (the execution status of this line is deduced): d->layout->removeToolBarBreak(before); | - |
714 | } | 0 |
715 | | - |
716 | /*! | - |
717 | Adds the \a toolbar into the specified \a area in this main | - |
718 | window. The \a toolbar is placed at the end of the current tool | - |
719 | bar block (i.e. line). If the main window already manages \a toolbar | - |
720 | then it will only move the toolbar to \a area. | - |
721 | | - |
722 | \sa insertToolBar(), addToolBarBreak(), insertToolBarBreak() | - |
723 | */ | - |
724 | void QMainWindow::addToolBar(Qt::ToolBarArea area, QToolBar *toolbar) | - |
725 | { | - |
726 | if (!checkToolBarArea(area, "QMainWindow::addToolBar")) partially evaluated: !checkToolBarArea(area, "QMainWindow::addToolBar") no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
727 | return; | 0 |
728 | | - |
729 | Q_D(QMainWindow); executed (the execution status of this line is deduced): QMainWindowPrivate * const d = d_func(); | - |
730 | | - |
731 | disconnect(this, SIGNAL(iconSizeChanged(QSize)), executed (the execution status of this line is deduced): disconnect(this, "2""iconSizeChanged(QSize)", | - |
732 | toolbar, SLOT(_q_updateIconSize(QSize))); executed (the execution status of this line is deduced): toolbar, "1""_q_updateIconSize(QSize)"); | - |
733 | disconnect(this, SIGNAL(toolButtonStyleChanged(Qt::ToolButtonStyle)), executed (the execution status of this line is deduced): disconnect(this, "2""toolButtonStyleChanged(Qt::ToolButtonStyle)", | - |
734 | toolbar, SLOT(_q_updateToolButtonStyle(Qt::ToolButtonStyle))); executed (the execution status of this line is deduced): toolbar, "1""_q_updateToolButtonStyle(Qt::ToolButtonStyle)"); | - |
735 | | - |
736 | if(toolbar->d_func()->state && toolbar->d_func()->state->dragging) { partially evaluated: toolbar->d_func()->state no Evaluation Count:0 | yes Evaluation Count:2 |
never evaluated: toolbar->d_func()->state->dragging | 0-2 |
737 | //removing a toolbar which is dragging will cause crash | - |
738 | #ifndef QT_NO_DOCKWIDGET | - |
739 | bool animated = isAnimated(); never executed (the execution status of this line is deduced): bool animated = isAnimated(); | - |
740 | setAnimated(false); never executed (the execution status of this line is deduced): setAnimated(false); | - |
741 | #endif | - |
742 | toolbar->d_func()->endDrag(); never executed (the execution status of this line is deduced): toolbar->d_func()->endDrag(); | - |
743 | #ifndef QT_NO_DOCKWIDGET | - |
744 | setAnimated(animated); never executed (the execution status of this line is deduced): setAnimated(animated); | - |
745 | #endif | - |
746 | } | 0 |
747 | | - |
748 | if (!d->layout->usesHIToolBar(toolbar)) { partially evaluated: !d->layout->usesHIToolBar(toolbar) yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
749 | d->layout->removeWidget(toolbar); executed (the execution status of this line is deduced): d->layout->removeWidget(toolbar); | - |
750 | } else { executed: } Execution Count:2 | 2 |
751 | d->layout->removeToolBar(toolbar); never executed (the execution status of this line is deduced): d->layout->removeToolBar(toolbar); | - |
752 | } | 0 |
753 | | - |
754 | toolbar->d_func()->_q_updateIconSize(d->iconSize); executed (the execution status of this line is deduced): toolbar->d_func()->_q_updateIconSize(d->iconSize); | - |
755 | toolbar->d_func()->_q_updateToolButtonStyle(d->toolButtonStyle); executed (the execution status of this line is deduced): toolbar->d_func()->_q_updateToolButtonStyle(d->toolButtonStyle); | - |
756 | connect(this, SIGNAL(iconSizeChanged(QSize)), executed (the execution status of this line is deduced): connect(this, "2""iconSizeChanged(QSize)", | - |
757 | toolbar, SLOT(_q_updateIconSize(QSize))); executed (the execution status of this line is deduced): toolbar, "1""_q_updateIconSize(QSize)"); | - |
758 | connect(this, SIGNAL(toolButtonStyleChanged(Qt::ToolButtonStyle)), executed (the execution status of this line is deduced): connect(this, "2""toolButtonStyleChanged(Qt::ToolButtonStyle)", | - |
759 | toolbar, SLOT(_q_updateToolButtonStyle(Qt::ToolButtonStyle))); executed (the execution status of this line is deduced): toolbar, "1""_q_updateToolButtonStyle(Qt::ToolButtonStyle)"); | - |
760 | | - |
761 | d->layout->addToolBar(area, toolbar); executed (the execution status of this line is deduced): d->layout->addToolBar(area, toolbar); | - |
762 | } executed: } Execution Count:2 | 2 |
763 | | - |
764 | /*! \overload | - |
765 | Equivalent of calling addToolBar(Qt::TopToolBarArea, \a toolbar) | - |
766 | */ | - |
767 | void QMainWindow::addToolBar(QToolBar *toolbar) | - |
768 | { addToolBar(Qt::TopToolBarArea, toolbar); } executed: } Execution Count:2 | 2 |
769 | | - |
770 | /*! | - |
771 | \overload | - |
772 | | - |
773 | Creates a QToolBar object, setting its window title to \a title, | - |
774 | and inserts it into the top toolbar area. | - |
775 | | - |
776 | \sa setWindowTitle() | - |
777 | */ | - |
778 | QToolBar *QMainWindow::addToolBar(const QString &title) | - |
779 | { | - |
780 | QToolBar *toolBar = new QToolBar(this); executed (the execution status of this line is deduced): QToolBar *toolBar = new QToolBar(this); | - |
781 | toolBar->setWindowTitle(title); executed (the execution status of this line is deduced): toolBar->setWindowTitle(title); | - |
782 | addToolBar(toolBar); executed (the execution status of this line is deduced): addToolBar(toolBar); | - |
783 | return toolBar; executed: return toolBar; Execution Count:1 | 1 |
784 | } | - |
785 | | - |
786 | /*! | - |
787 | Inserts the \a toolbar into the area occupied by the \a before toolbar | - |
788 | so that it appears before it. For example, in normal left-to-right | - |
789 | layout operation, this means that \a toolbar will appear to the left | - |
790 | of the toolbar specified by \a before in a horizontal toolbar area. | - |
791 | | - |
792 | \sa insertToolBarBreak(), addToolBar(), addToolBarBreak() | - |
793 | */ | - |
794 | void QMainWindow::insertToolBar(QToolBar *before, QToolBar *toolbar) | - |
795 | { | - |
796 | Q_D(QMainWindow); never executed (the execution status of this line is deduced): QMainWindowPrivate * const d = d_func(); | - |
797 | | - |
798 | d->layout->removeToolBar(toolbar); never executed (the execution status of this line is deduced): d->layout->removeToolBar(toolbar); | - |
799 | | - |
800 | toolbar->d_func()->_q_updateIconSize(d->iconSize); never executed (the execution status of this line is deduced): toolbar->d_func()->_q_updateIconSize(d->iconSize); | - |
801 | toolbar->d_func()->_q_updateToolButtonStyle(d->toolButtonStyle); never executed (the execution status of this line is deduced): toolbar->d_func()->_q_updateToolButtonStyle(d->toolButtonStyle); | - |
802 | connect(this, SIGNAL(iconSizeChanged(QSize)), never executed (the execution status of this line is deduced): connect(this, "2""iconSizeChanged(QSize)", | - |
803 | toolbar, SLOT(_q_updateIconSize(QSize))); never executed (the execution status of this line is deduced): toolbar, "1""_q_updateIconSize(QSize)"); | - |
804 | connect(this, SIGNAL(toolButtonStyleChanged(Qt::ToolButtonStyle)), never executed (the execution status of this line is deduced): connect(this, "2""toolButtonStyleChanged(Qt::ToolButtonStyle)", | - |
805 | toolbar, SLOT(_q_updateToolButtonStyle(Qt::ToolButtonStyle))); never executed (the execution status of this line is deduced): toolbar, "1""_q_updateToolButtonStyle(Qt::ToolButtonStyle)"); | - |
806 | | - |
807 | d->layout->insertToolBar(before, toolbar); never executed (the execution status of this line is deduced): d->layout->insertToolBar(before, toolbar); | - |
808 | } | 0 |
809 | | - |
810 | /*! | - |
811 | Removes the \a toolbar from the main window layout and hides | - |
812 | it. Note that the \a toolbar is \e not deleted. | - |
813 | */ | - |
814 | void QMainWindow::removeToolBar(QToolBar *toolbar) | - |
815 | { | - |
816 | if (toolbar) { | 0 |
817 | d_func()->layout->removeToolBar(toolbar); never executed (the execution status of this line is deduced): d_func()->layout->removeToolBar(toolbar); | - |
818 | toolbar->hide(); never executed (the execution status of this line is deduced): toolbar->hide(); | - |
819 | } | 0 |
820 | } | 0 |
821 | | - |
822 | /*! | - |
823 | Returns the Qt::ToolBarArea for \a toolbar. If \a toolbar has not | - |
824 | been added to the main window, this function returns \c | - |
825 | Qt::NoToolBarArea. | - |
826 | | - |
827 | \sa addToolBar(), addToolBarBreak(), Qt::ToolBarArea | - |
828 | */ | - |
829 | Qt::ToolBarArea QMainWindow::toolBarArea(QToolBar *toolbar) const | - |
830 | { return d_func()->layout->toolBarArea(toolbar); } never executed: return d_func()->layout->toolBarArea(toolbar); | 0 |
831 | | - |
832 | /*! | - |
833 | | - |
834 | Returns whether there is a toolbar | - |
835 | break before the \a toolbar. | - |
836 | | - |
837 | \sa addToolBarBreak(), insertToolBarBreak() | - |
838 | */ | - |
839 | bool QMainWindow::toolBarBreak(QToolBar *toolbar) const | - |
840 | { | - |
841 | return d_func()->layout->toolBarBreak(toolbar); never executed: return d_func()->layout->toolBarBreak(toolbar); | 0 |
842 | } | - |
843 | | - |
844 | #endif // QT_NO_TOOLBAR | - |
845 | | - |
846 | #ifndef QT_NO_DOCKWIDGET | - |
847 | | - |
848 | /*! \property QMainWindow::animated | - |
849 | \brief whether manipulating dock widgets and tool bars is animated | - |
850 | \since 4.2 | - |
851 | | - |
852 | When a dock widget or tool bar is dragged over the | - |
853 | main window, the main window adjusts its contents | - |
854 | to indicate where the dock widget or tool bar will | - |
855 | be docked if it is dropped. Setting this property | - |
856 | causes QMainWindow to move its contents in a smooth | - |
857 | animation. Clearing this property causes the contents | - |
858 | to snap into their new positions. | - |
859 | | - |
860 | By default, this property is set. It may be cleared if | - |
861 | the main window contains widgets which are slow at resizing | - |
862 | or repainting themselves. | - |
863 | | - |
864 | Setting this property is identical to setting the AnimatedDocks | - |
865 | option using setDockOptions(). | - |
866 | */ | - |
867 | | - |
868 | bool QMainWindow::isAnimated() const | - |
869 | { | - |
870 | Q_D(const QMainWindow); never executed (the execution status of this line is deduced): const QMainWindowPrivate * const d = d_func(); | - |
871 | return d->layout->dockOptions & AnimatedDocks; never executed: return d->layout->dockOptions & AnimatedDocks; | 0 |
872 | } | - |
873 | | - |
874 | void QMainWindow::setAnimated(bool enabled) | - |
875 | { | - |
876 | Q_D(QMainWindow); never executed (the execution status of this line is deduced): QMainWindowPrivate * const d = d_func(); | - |
877 | | - |
878 | DockOptions opts = d->layout->dockOptions; never executed (the execution status of this line is deduced): DockOptions opts = d->layout->dockOptions; | - |
879 | if (enabled) | 0 |
880 | opts |= AnimatedDocks; never executed: opts |= AnimatedDocks; | 0 |
881 | else | - |
882 | opts &= ~AnimatedDocks; never executed: opts &= ~AnimatedDocks; | 0 |
883 | | - |
884 | d->layout->setDockOptions(opts); never executed (the execution status of this line is deduced): d->layout->setDockOptions(opts); | - |
885 | } | 0 |
886 | | - |
887 | /*! \property QMainWindow::dockNestingEnabled | - |
888 | \brief whether docks can be nested | - |
889 | \since 4.2 | - |
890 | | - |
891 | If this property is false, dock areas can only contain a single row | - |
892 | (horizontal or vertical) of dock widgets. If this property is true, | - |
893 | the area occupied by a dock widget can be split in either direction to contain | - |
894 | more dock widgets. | - |
895 | | - |
896 | Dock nesting is only necessary in applications that contain a lot of | - |
897 | dock widgets. It gives the user greater freedom in organizing their | - |
898 | main window. However, dock nesting leads to more complex | - |
899 | (and less intuitive) behavior when a dock widget is dragged over the | - |
900 | main window, since there are more ways in which a dropped dock widget | - |
901 | may be placed in the dock area. | - |
902 | | - |
903 | Setting this property is identical to setting the AllowNestedDocks option | - |
904 | using setDockOptions(). | - |
905 | */ | - |
906 | | - |
907 | bool QMainWindow::isDockNestingEnabled() const | - |
908 | { | - |
909 | Q_D(const QMainWindow); never executed (the execution status of this line is deduced): const QMainWindowPrivate * const d = d_func(); | - |
910 | return d->layout->dockOptions & AllowNestedDocks; never executed: return d->layout->dockOptions & AllowNestedDocks; | 0 |
911 | } | - |
912 | | - |
913 | void QMainWindow::setDockNestingEnabled(bool enabled) | - |
914 | { | - |
915 | Q_D(QMainWindow); never executed (the execution status of this line is deduced): QMainWindowPrivate * const d = d_func(); | - |
916 | | - |
917 | DockOptions opts = d->layout->dockOptions; never executed (the execution status of this line is deduced): DockOptions opts = d->layout->dockOptions; | - |
918 | if (enabled) | 0 |
919 | opts |= AllowNestedDocks; never executed: opts |= AllowNestedDocks; | 0 |
920 | else | - |
921 | opts &= ~AllowNestedDocks; never executed: opts &= ~AllowNestedDocks; | 0 |
922 | | - |
923 | d->layout->setDockOptions(opts); never executed (the execution status of this line is deduced): d->layout->setDockOptions(opts); | - |
924 | } | 0 |
925 | | - |
926 | #if 0 | - |
927 | /*! \property QMainWindow::verticalTabsEnabled | - |
928 | \brief whether left and right dock areas use vertical tabs | - |
929 | \since 4.2 | - |
930 | | - |
931 | If this property is set to false, dock areas containing tabbed dock widgets | - |
932 | display horizontal tabs, simmilar to Visual Studio. | - |
933 | | - |
934 | If this property is set to true, then the right and left dock areas display vertical | - |
935 | tabs, simmilar to KDevelop. | - |
936 | | - |
937 | This property should be set before any dock widgets are added to the main window. | - |
938 | */ | - |
939 | | - |
940 | bool QMainWindow::verticalTabsEnabled() const | - |
941 | { | - |
942 | return d_func()->layout->verticalTabsEnabled(); | - |
943 | } | - |
944 | | - |
945 | void QMainWindow::setVerticalTabsEnabled(bool enabled) | - |
946 | { | - |
947 | d_func()->layout->setVerticalTabsEnabled(enabled); | - |
948 | } | - |
949 | #endif | - |
950 | | - |
951 | static bool checkDockWidgetArea(Qt::DockWidgetArea area, const char *where) | - |
952 | { | - |
953 | switch (area) { | - |
954 | case Qt::LeftDockWidgetArea: | - |
955 | case Qt::RightDockWidgetArea: | - |
956 | case Qt::TopDockWidgetArea: | - |
957 | case Qt::BottomDockWidgetArea: | - |
958 | return true; executed: return true; Execution Count:35 | 35 |
959 | default: | - |
960 | break; | 0 |
961 | } | - |
962 | qWarning("%s: invalid 'area' argument", where); never executed (the execution status of this line is deduced): QMessageLogger("widgets/qmainwindow.cpp", 962, __PRETTY_FUNCTION__).warning("%s: invalid 'area' argument", where); | - |
963 | return false; never executed: return false; | 0 |
964 | } | - |
965 | | - |
966 | #ifndef QT_NO_TABBAR | - |
967 | /*! | - |
968 | \property QMainWindow::documentMode | - |
969 | \brief whether the tab bar for tabbed dockwidgets is set to document mode. | - |
970 | \since 4.5 | - |
971 | | - |
972 | The default is false. | - |
973 | | - |
974 | \sa QTabBar::documentMode | - |
975 | */ | - |
976 | bool QMainWindow::documentMode() const | - |
977 | { | - |
978 | return d_func()->layout->documentMode(); never executed: return d_func()->layout->documentMode(); | 0 |
979 | } | - |
980 | | - |
981 | void QMainWindow::setDocumentMode(bool enabled) | - |
982 | { | - |
983 | d_func()->layout->setDocumentMode(enabled); never executed (the execution status of this line is deduced): d_func()->layout->setDocumentMode(enabled); | - |
984 | } | 0 |
985 | #endif // QT_NO_TABBAR | - |
986 | | - |
987 | #ifndef QT_NO_TABWIDGET | - |
988 | /*! | - |
989 | \property QMainWindow::tabShape | - |
990 | \brief the tab shape used for tabbed dock widgets. | - |
991 | \since 4.5 | - |
992 | | - |
993 | The default is \l QTabWidget::Rounded. | - |
994 | | - |
995 | \sa setTabPosition() | - |
996 | */ | - |
997 | QTabWidget::TabShape QMainWindow::tabShape() const | - |
998 | { | - |
999 | return d_func()->layout->tabShape(); never executed: return d_func()->layout->tabShape(); | 0 |
1000 | } | - |
1001 | | - |
1002 | void QMainWindow::setTabShape(QTabWidget::TabShape tabShape) | - |
1003 | { | - |
1004 | d_func()->layout->setTabShape(tabShape); never executed (the execution status of this line is deduced): d_func()->layout->setTabShape(tabShape); | - |
1005 | } | 0 |
1006 | | - |
1007 | /*! | - |
1008 | \since 4.5 | - |
1009 | | - |
1010 | Returns the tab position for \a area. | - |
1011 | | - |
1012 | \note The \l VerticalTabs dock option overrides the tab positions returned | - |
1013 | by this function. | - |
1014 | | - |
1015 | \sa setTabPosition(), tabShape() | - |
1016 | */ | - |
1017 | QTabWidget::TabPosition QMainWindow::tabPosition(Qt::DockWidgetArea area) const | - |
1018 | { | - |
1019 | if (!checkDockWidgetArea(area, "QMainWindow::tabPosition")) never evaluated: !checkDockWidgetArea(area, "QMainWindow::tabPosition") | 0 |
1020 | return QTabWidget::South; never executed: return QTabWidget::South; | 0 |
1021 | return d_func()->layout->tabPosition(area); never executed: return d_func()->layout->tabPosition(area); | 0 |
1022 | } | - |
1023 | | - |
1024 | /*! | - |
1025 | \since 4.5 | - |
1026 | | - |
1027 | Sets the tab position for the given dock widget \a areas to the specified | - |
1028 | \a tabPosition. By default, all dock areas show their tabs at the bottom. | - |
1029 | | - |
1030 | \note The \l VerticalTabs dock option overrides the tab positions set by | - |
1031 | this method. | - |
1032 | | - |
1033 | \sa tabPosition(), setTabShape() | - |
1034 | */ | - |
1035 | void QMainWindow::setTabPosition(Qt::DockWidgetAreas areas, QTabWidget::TabPosition tabPosition) | - |
1036 | { | - |
1037 | d_func()->layout->setTabPosition(areas, tabPosition); never executed (the execution status of this line is deduced): d_func()->layout->setTabPosition(areas, tabPosition); | - |
1038 | } | 0 |
1039 | #endif // QT_NO_TABWIDGET | - |
1040 | | - |
1041 | /*! | - |
1042 | Adds the given \a dockwidget to the specified \a area. | - |
1043 | */ | - |
1044 | void QMainWindow::addDockWidget(Qt::DockWidgetArea area, QDockWidget *dockwidget) | - |
1045 | { | - |
1046 | if (!checkDockWidgetArea(area, "QMainWindow::addDockWidget")) partially evaluated: !checkDockWidgetArea(area, "QMainWindow::addDockWidget") no Evaluation Count:0 | yes Evaluation Count:17 |
| 0-17 |
1047 | return; | 0 |
1048 | | - |
1049 | Qt::Orientation orientation = Qt::Vertical; executed (the execution status of this line is deduced): Qt::Orientation orientation = Qt::Vertical; | - |
1050 | switch (area) { | - |
1051 | case Qt::TopDockWidgetArea: | - |
1052 | case Qt::BottomDockWidgetArea: | - |
1053 | orientation = Qt::Horizontal; executed (the execution status of this line is deduced): orientation = Qt::Horizontal; | - |
1054 | break; executed: break; Execution Count:4 | 4 |
1055 | default: | - |
1056 | break; executed: break; Execution Count:13 | 13 |
1057 | } | - |
1058 | d_func()->layout->removeWidget(dockwidget); // in case it was already in here executed (the execution status of this line is deduced): d_func()->layout->removeWidget(dockwidget); | - |
1059 | addDockWidget(area, dockwidget, orientation); executed (the execution status of this line is deduced): addDockWidget(area, dockwidget, orientation); | - |
1060 | | - |
1061 | #ifdef Q_WS_MAC //drawer support | - |
1062 | QMacCocoaAutoReleasePool pool; | - |
1063 | extern bool qt_mac_is_macdrawer(const QWidget *); //qwidget_mac.cpp | - |
1064 | if (qt_mac_is_macdrawer(dockwidget)) { | - |
1065 | extern bool qt_mac_set_drawer_preferred_edge(QWidget *, Qt::DockWidgetArea); //qwidget_mac.cpp | - |
1066 | window()->createWinId(); | - |
1067 | dockwidget->window()->createWinId(); | - |
1068 | qt_mac_set_drawer_preferred_edge(dockwidget, area); | - |
1069 | if (dockwidget->isVisible()) { | - |
1070 | dockwidget->hide(); | - |
1071 | dockwidget->show(); | - |
1072 | } | - |
1073 | } | - |
1074 | #endif | - |
1075 | } executed: } Execution Count:17 | 17 |
1076 | | - |
1077 | /*! | - |
1078 | Restores the state of \a dockwidget if it is created after the call | - |
1079 | to restoreState(). Returns true if the state was restored; otherwise | - |
1080 | returns false. | - |
1081 | | - |
1082 | \sa restoreState(), saveState() | - |
1083 | */ | - |
1084 | | - |
1085 | bool QMainWindow::restoreDockWidget(QDockWidget *dockwidget) | - |
1086 | { | - |
1087 | return d_func()->layout->restoreDockWidget(dockwidget); never executed: return d_func()->layout->restoreDockWidget(dockwidget); | 0 |
1088 | } | - |
1089 | | - |
1090 | /*! | - |
1091 | Adds \a dockwidget into the given \a area in the direction | - |
1092 | specified by the \a orientation. | - |
1093 | */ | - |
1094 | void QMainWindow::addDockWidget(Qt::DockWidgetArea area, QDockWidget *dockwidget, | - |
1095 | Qt::Orientation orientation) | - |
1096 | { | - |
1097 | if (!checkDockWidgetArea(area, "QMainWindow::addDockWidget")) partially evaluated: !checkDockWidgetArea(area, "QMainWindow::addDockWidget") no Evaluation Count:0 | yes Evaluation Count:18 |
| 0-18 |
1098 | return; | 0 |
1099 | | - |
1100 | // add a window to an area, placing done relative to the previous | - |
1101 | d_func()->layout->addDockWidget(area, dockwidget, orientation); executed (the execution status of this line is deduced): d_func()->layout->addDockWidget(area, dockwidget, orientation); | - |
1102 | } executed: } Execution Count:18 | 18 |
1103 | | - |
1104 | /*! | - |
1105 | \fn void QMainWindow::splitDockWidget(QDockWidget *first, QDockWidget *second, Qt::Orientation orientation) | - |
1106 | | - |
1107 | Splits the space covered by the \a first dock widget into two parts, | - |
1108 | moves the \a first dock widget into the first part, and moves the | - |
1109 | \a second dock widget into the second part. | - |
1110 | | - |
1111 | The \a orientation specifies how the space is divided: A Qt::Horizontal | - |
1112 | split places the second dock widget to the right of the first; a | - |
1113 | Qt::Vertical split places the second dock widget below the first. | - |
1114 | | - |
1115 | \e Note: if \a first is currently in a tabbed docked area, \a second will | - |
1116 | be added as a new tab, not as a neighbor of \a first. This is because a | - |
1117 | single tab can contain only one dock widget. | - |
1118 | | - |
1119 | \e Note: The Qt::LayoutDirection influences the order of the dock widgets | - |
1120 | in the two parts of the divided area. When right-to-left layout direction | - |
1121 | is enabled, the placing of the dock widgets will be reversed. | - |
1122 | | - |
1123 | \sa tabifyDockWidget(), addDockWidget(), removeDockWidget() | - |
1124 | */ | - |
1125 | void QMainWindow::splitDockWidget(QDockWidget *after, QDockWidget *dockwidget, | - |
1126 | Qt::Orientation orientation) | - |
1127 | { | - |
1128 | d_func()->layout->splitDockWidget(after, dockwidget, orientation); executed (the execution status of this line is deduced): d_func()->layout->splitDockWidget(after, dockwidget, orientation); | - |
1129 | } executed: } Execution Count:1 | 1 |
1130 | | - |
1131 | /*! | - |
1132 | \fn void QMainWindow::tabifyDockWidget(QDockWidget *first, QDockWidget *second) | - |
1133 | | - |
1134 | Moves \a second dock widget on top of \a first dock widget, creating a tabbed | - |
1135 | docked area in the main window. | - |
1136 | | - |
1137 | \sa tabifiedDockWidgets() | - |
1138 | */ | - |
1139 | void QMainWindow::tabifyDockWidget(QDockWidget *first, QDockWidget *second) | - |
1140 | { | - |
1141 | d_func()->layout->tabifyDockWidget(first, second); executed (the execution status of this line is deduced): d_func()->layout->tabifyDockWidget(first, second); | - |
1142 | } executed: } Execution Count:4 | 4 |
1143 | | - |
1144 | | - |
1145 | /*! | - |
1146 | \fn QList<QDockWidget*> QMainWindow::tabifiedDockWidgets(QDockWidget *dockwidget) const | - |
1147 | | - |
1148 | Returns the dock widgets that are tabified together with \a dockwidget. | - |
1149 | | - |
1150 | \since 4.5 | - |
1151 | \sa tabifyDockWidget() | - |
1152 | */ | - |
1153 | | - |
1154 | QList<QDockWidget*> QMainWindow::tabifiedDockWidgets(QDockWidget *dockwidget) const | - |
1155 | { | - |
1156 | QList<QDockWidget*> ret; never executed (the execution status of this line is deduced): QList<QDockWidget*> ret; | - |
1157 | #if defined(QT_NO_TABBAR) | - |
1158 | Q_UNUSED(dockwidget); | - |
1159 | #else | - |
1160 | const QDockAreaLayoutInfo *info = d_func()->layout->layoutState.dockAreaLayout.info(dockwidget); never executed (the execution status of this line is deduced): const QDockAreaLayoutInfo *info = d_func()->layout->layoutState.dockAreaLayout.info(dockwidget); | - |
1161 | if (info && info->tabbed && info->tabBar) { never evaluated: info never evaluated: info->tabbed never evaluated: info->tabBar | 0 |
1162 | for(int i = 0; i < info->item_list.count(); ++i) { never evaluated: i < info->item_list.count() | 0 |
1163 | const QDockAreaLayoutItem &item = info->item_list.at(i); never executed (the execution status of this line is deduced): const QDockAreaLayoutItem &item = info->item_list.at(i); | - |
1164 | if (item.widgetItem) { never evaluated: item.widgetItem | 0 |
1165 | if (QDockWidget *dock = qobject_cast<QDockWidget*>(item.widgetItem->widget())) { never evaluated: QDockWidget *dock = qobject_cast<QDockWidget*>(item.widgetItem->widget()) | 0 |
1166 | if (dock != dockwidget) { never evaluated: dock != dockwidget | 0 |
1167 | ret += dock; never executed (the execution status of this line is deduced): ret += dock; | - |
1168 | } | 0 |
1169 | } | 0 |
1170 | } | 0 |
1171 | } | 0 |
1172 | } | 0 |
1173 | #endif | - |
1174 | return ret; never executed: return ret; | 0 |
1175 | } | - |
1176 | | - |
1177 | | - |
1178 | /*! | - |
1179 | Removes the \a dockwidget from the main window layout and hides | - |
1180 | it. Note that the \a dockwidget is \e not deleted. | - |
1181 | */ | - |
1182 | void QMainWindow::removeDockWidget(QDockWidget *dockwidget) | - |
1183 | { | - |
1184 | if (dockwidget) { partially evaluated: dockwidget yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
1185 | d_func()->layout->removeWidget(dockwidget); executed (the execution status of this line is deduced): d_func()->layout->removeWidget(dockwidget); | - |
1186 | dockwidget->hide(); executed (the execution status of this line is deduced): dockwidget->hide(); | - |
1187 | } executed: } Execution Count:1 | 1 |
1188 | } executed: } Execution Count:1 | 1 |
1189 | | - |
1190 | /*! | - |
1191 | Returns the Qt::DockWidgetArea for \a dockwidget. If \a dockwidget | - |
1192 | has not been added to the main window, this function returns \c | - |
1193 | Qt::NoDockWidgetArea. | - |
1194 | | - |
1195 | \sa addDockWidget(), splitDockWidget(), Qt::DockWidgetArea | - |
1196 | */ | - |
1197 | Qt::DockWidgetArea QMainWindow::dockWidgetArea(QDockWidget *dockwidget) const | - |
1198 | { return d_func()->layout->dockWidgetArea(dockwidget); } executed: return d_func()->layout->dockWidgetArea(dockwidget); Execution Count:2 | 2 |
1199 | | - |
1200 | #endif // QT_NO_DOCKWIDGET | - |
1201 | | - |
1202 | /*! | - |
1203 | Saves the current state of this mainwindow's toolbars and | - |
1204 | dockwidgets. The \a version number is stored as part of the data. | - |
1205 | | - |
1206 | The \l{QObject::objectName}{objectName} property is used | - |
1207 | to identify each QToolBar and QDockWidget. You should make sure | - |
1208 | that this property is unique for each QToolBar and QDockWidget you | - |
1209 | add to the QMainWindow | - |
1210 | | - |
1211 | To restore the saved state, pass the return value and \a version | - |
1212 | number to restoreState(). | - |
1213 | | - |
1214 | To save the geometry when the window closes, you can | - |
1215 | implement a close event like this: | - |
1216 | | - |
1217 | \snippet code/src_gui_widgets_qmainwindow.cpp 0 | - |
1218 | | - |
1219 | \sa restoreState(), QWidget::saveGeometry(), QWidget::restoreGeometry() | - |
1220 | */ | - |
1221 | QByteArray QMainWindow::saveState(int version) const | - |
1222 | { | - |
1223 | QByteArray data; executed (the execution status of this line is deduced): QByteArray data; | - |
1224 | QDataStream stream(&data, QIODevice::WriteOnly); executed (the execution status of this line is deduced): QDataStream stream(&data, QIODevice::WriteOnly); | - |
1225 | stream << QMainWindowLayout::VersionMarker; executed (the execution status of this line is deduced): stream << QMainWindowLayout::VersionMarker; | - |
1226 | stream << version; executed (the execution status of this line is deduced): stream << version; | - |
1227 | d_func()->layout->saveState(stream); executed (the execution status of this line is deduced): d_func()->layout->saveState(stream); | - |
1228 | return data; executed: return data; Execution Count:2 | 2 |
1229 | } | - |
1230 | | - |
1231 | /*! | - |
1232 | Restores the \a state of this mainwindow's toolbars and | - |
1233 | dockwidgets. The \a version number is compared with that stored | - |
1234 | in \a state. If they do not match, the mainwindow's state is left | - |
1235 | unchanged, and this function returns \c false; otherwise, the state | - |
1236 | is restored, and this function returns \c true. | - |
1237 | | - |
1238 | To restore geometry saved using QSettings, you can use code like | - |
1239 | this: | - |
1240 | | - |
1241 | \snippet code/src_gui_widgets_qmainwindow.cpp 1 | - |
1242 | | - |
1243 | \sa saveState(), QWidget::saveGeometry(), | - |
1244 | QWidget::restoreGeometry(), restoreDockWidget() | - |
1245 | */ | - |
1246 | bool QMainWindow::restoreState(const QByteArray &state, int version) | - |
1247 | { | - |
1248 | if (state.isEmpty()) partially evaluated: state.isEmpty() no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
1249 | return false; never executed: return false; | 0 |
1250 | QByteArray sd = state; executed (the execution status of this line is deduced): QByteArray sd = state; | - |
1251 | QDataStream stream(&sd, QIODevice::ReadOnly); executed (the execution status of this line is deduced): QDataStream stream(&sd, QIODevice::ReadOnly); | - |
1252 | int marker, v; executed (the execution status of this line is deduced): int marker, v; | - |
1253 | stream >> marker; executed (the execution status of this line is deduced): stream >> marker; | - |
1254 | stream >> v; executed (the execution status of this line is deduced): stream >> v; | - |
1255 | if (stream.status() != QDataStream::Ok || marker != QMainWindowLayout::VersionMarker || v != version) partially evaluated: stream.status() != QDataStream::Ok no Evaluation Count:0 | yes Evaluation Count:2 |
partially evaluated: marker != QMainWindowLayout::VersionMarker no Evaluation Count:0 | yes Evaluation Count:2 |
partially evaluated: v != version no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
1256 | return false; never executed: return false; | 0 |
1257 | bool restored = d_func()->layout->restoreState(stream); executed (the execution status of this line is deduced): bool restored = d_func()->layout->restoreState(stream); | - |
1258 | return restored; executed: return restored; Execution Count:2 | 2 |
1259 | } | - |
1260 | | - |
1261 | #if !defined(QT_NO_DOCKWIDGET) && !defined(QT_NO_CURSOR) | - |
1262 | QCursor QMainWindowPrivate::separatorCursor(const QList<int> &path) const | - |
1263 | { | - |
1264 | QDockAreaLayoutInfo *info = layout->layoutState.dockAreaLayout.info(path); never executed (the execution status of this line is deduced): QDockAreaLayoutInfo *info = layout->layoutState.dockAreaLayout.info(path); | - |
1265 | Q_ASSERT(info != 0); never executed (the execution status of this line is deduced): qt_noop(); | - |
1266 | if (path.size() == 1) { // is this the "top-level" separator which separates a dock area never evaluated: path.size() == 1 | 0 |
1267 | // from the central widget? | - |
1268 | switch (path.first()) { | - |
1269 | case QInternal::LeftDock: | - |
1270 | case QInternal::RightDock: | - |
1271 | return Qt::SplitHCursor; never executed: return Qt::SplitHCursor; | 0 |
1272 | case QInternal::TopDock: | - |
1273 | case QInternal::BottomDock: | - |
1274 | return Qt::SplitVCursor; never executed: return Qt::SplitVCursor; | 0 |
1275 | default: | - |
1276 | break; | 0 |
1277 | } | - |
1278 | } | 0 |
1279 | | - |
1280 | // no, it's a splitter inside a dock area, separating two dock widgets | - |
1281 | | - |
1282 | return info->o == Qt::Horizontal never executed: return info->o == Qt::Horizontal ? Qt::SplitHCursor : Qt::SplitVCursor; | 0 |
1283 | ? Qt::SplitHCursor : Qt::SplitVCursor; never executed: return info->o == Qt::Horizontal ? Qt::SplitHCursor : Qt::SplitVCursor; | 0 |
1284 | } | - |
1285 | | - |
1286 | void QMainWindowPrivate::adjustCursor(const QPoint &pos) | - |
1287 | { | - |
1288 | Q_Q(QMainWindow); executed (the execution status of this line is deduced): QMainWindow * const q = q_func(); | - |
1289 | | - |
1290 | hoverPos = pos; executed (the execution status of this line is deduced): hoverPos = pos; | - |
1291 | | - |
1292 | if (pos == QPoint(0, 0)) { evaluated: pos == QPoint(0, 0) yes Evaluation Count:193 | yes Evaluation Count:28 |
| 28-193 |
1293 | if (!hoverSeparator.isEmpty()) partially evaluated: !hoverSeparator.isEmpty() no Evaluation Count:0 | yes Evaluation Count:193 |
| 0-193 |
1294 | q->update(layout->layoutState.dockAreaLayout.separatorRect(hoverSeparator)); never executed: q->update(layout->layoutState.dockAreaLayout.separatorRect(hoverSeparator)); | 0 |
1295 | hoverSeparator.clear(); executed (the execution status of this line is deduced): hoverSeparator.clear(); | - |
1296 | | - |
1297 | if (cursorAdjusted) { partially evaluated: cursorAdjusted no Evaluation Count:0 | yes Evaluation Count:193 |
| 0-193 |
1298 | cursorAdjusted = false; never executed (the execution status of this line is deduced): cursorAdjusted = false; | - |
1299 | if (hasOldCursor) never evaluated: hasOldCursor | 0 |
1300 | q->setCursor(oldCursor); never executed: q->setCursor(oldCursor); | 0 |
1301 | else | - |
1302 | q->unsetCursor(); never executed: q->unsetCursor(); | 0 |
1303 | } | - |
1304 | } else if (layout->movingSeparator.isEmpty()) { // Don't change cursor when moving separator executed: } Execution Count:193 partially evaluated: layout->movingSeparator.isEmpty() yes Evaluation Count:28 | no Evaluation Count:0 |
| 0-193 |
1305 | QList<int> pathToSeparator executed (the execution status of this line is deduced): QList<int> pathToSeparator | - |
1306 | = layout->layoutState.dockAreaLayout.findSeparator(pos); executed (the execution status of this line is deduced): = layout->layoutState.dockAreaLayout.findSeparator(pos); | - |
1307 | | - |
1308 | if (pathToSeparator != hoverSeparator) { partially evaluated: pathToSeparator != hoverSeparator no Evaluation Count:0 | yes Evaluation Count:28 |
| 0-28 |
1309 | if (!hoverSeparator.isEmpty()) never evaluated: !hoverSeparator.isEmpty() | 0 |
1310 | q->update(layout->layoutState.dockAreaLayout.separatorRect(hoverSeparator)); never executed: q->update(layout->layoutState.dockAreaLayout.separatorRect(hoverSeparator)); | 0 |
1311 | | - |
1312 | hoverSeparator = pathToSeparator; never executed (the execution status of this line is deduced): hoverSeparator = pathToSeparator; | - |
1313 | | - |
1314 | if (hoverSeparator.isEmpty()) { never evaluated: hoverSeparator.isEmpty() | 0 |
1315 | if (cursorAdjusted) { never evaluated: cursorAdjusted | 0 |
1316 | cursorAdjusted = false; never executed (the execution status of this line is deduced): cursorAdjusted = false; | - |
1317 | if (hasOldCursor) never evaluated: hasOldCursor | 0 |
1318 | q->setCursor(oldCursor); never executed: q->setCursor(oldCursor); | 0 |
1319 | else | - |
1320 | q->unsetCursor(); never executed: q->unsetCursor(); | 0 |
1321 | } | - |
1322 | } else { | 0 |
1323 | q->update(layout->layoutState.dockAreaLayout.separatorRect(hoverSeparator)); never executed (the execution status of this line is deduced): q->update(layout->layoutState.dockAreaLayout.separatorRect(hoverSeparator)); | - |
1324 | if (!cursorAdjusted) { never evaluated: !cursorAdjusted | 0 |
1325 | oldCursor = q->cursor(); never executed (the execution status of this line is deduced): oldCursor = q->cursor(); | - |
1326 | hasOldCursor = q->testAttribute(Qt::WA_SetCursor); never executed (the execution status of this line is deduced): hasOldCursor = q->testAttribute(Qt::WA_SetCursor); | - |
1327 | } | 0 |
1328 | adjustedCursor = separatorCursor(hoverSeparator); never executed (the execution status of this line is deduced): adjustedCursor = separatorCursor(hoverSeparator); | - |
1329 | q->setCursor(adjustedCursor); never executed (the execution status of this line is deduced): q->setCursor(adjustedCursor); | - |
1330 | cursorAdjusted = true; never executed (the execution status of this line is deduced): cursorAdjusted = true; | - |
1331 | } | 0 |
1332 | } | - |
1333 | } executed: } Execution Count:28 | 28 |
1334 | } | - |
1335 | #endif | - |
1336 | | - |
1337 | /*! \reimp */ | - |
1338 | bool QMainWindow::event(QEvent *event) | - |
1339 | { | - |
1340 | Q_D(QMainWindow); executed (the execution status of this line is deduced): QMainWindowPrivate * const d = d_func(); | - |
1341 | switch (event->type()) { | - |
1342 | | - |
1343 | #ifndef QT_NO_DOCKWIDGET | - |
1344 | case QEvent::Paint: { | - |
1345 | QPainter p(this); executed (the execution status of this line is deduced): QPainter p(this); | - |
1346 | QRegion r = static_cast<QPaintEvent*>(event)->region(); executed (the execution status of this line is deduced): QRegion r = static_cast<QPaintEvent*>(event)->region(); | - |
1347 | d->layout->layoutState.dockAreaLayout.paintSeparators(&p, this, r, d->hoverPos); executed (the execution status of this line is deduced): d->layout->layoutState.dockAreaLayout.paintSeparators(&p, this, r, d->hoverPos); | - |
1348 | break; executed: break; Execution Count:89 | 89 |
1349 | } | - |
1350 | | - |
1351 | #ifndef QT_NO_CURSOR | - |
1352 | case QEvent::HoverMove: { | - |
1353 | d->adjustCursor(static_cast<QHoverEvent*>(event)->pos()); executed (the execution status of this line is deduced): d->adjustCursor(static_cast<QHoverEvent*>(event)->pos()); | - |
1354 | break; executed: break; Execution Count:28 | 28 |
1355 | } | - |
1356 | | - |
1357 | // We don't want QWidget to call update() on the entire QMainWindow | - |
1358 | // on HoverEnter and HoverLeave, hence accept the event (return true). | - |
1359 | case QEvent::HoverEnter: | - |
1360 | return true; executed: return true; Execution Count:23 | 23 |
1361 | case QEvent::HoverLeave: | - |
1362 | d->adjustCursor(QPoint(0, 0)); executed (the execution status of this line is deduced): d->adjustCursor(QPoint(0, 0)); | - |
1363 | return true; executed: return true; Execution Count:6 | 6 |
1364 | case QEvent::ShortcutOverride: // when a menu pops up | - |
1365 | d->adjustCursor(QPoint(0, 0)); executed (the execution status of this line is deduced): d->adjustCursor(QPoint(0, 0)); | - |
1366 | break; executed: break; Execution Count:187 | 187 |
1367 | #endif // QT_NO_CURSOR | - |
1368 | | - |
1369 | case QEvent::MouseButtonPress: { | - |
1370 | QMouseEvent *e = static_cast<QMouseEvent*>(event); executed (the execution status of this line is deduced): QMouseEvent *e = static_cast<QMouseEvent*>(event); | - |
1371 | if (e->button() == Qt::LeftButton && d->layout->startSeparatorMove(e->pos())) { partially evaluated: e->button() == Qt::LeftButton no Evaluation Count:0 | yes Evaluation Count:1 |
never evaluated: d->layout->startSeparatorMove(e->pos()) | 0-1 |
1372 | // The click was on a separator, eat this event | - |
1373 | e->accept(); never executed (the execution status of this line is deduced): e->accept(); | - |
1374 | return true; never executed: return true; | 0 |
1375 | } | - |
1376 | break; executed: break; Execution Count:1 | 1 |
1377 | } | - |
1378 | | - |
1379 | case QEvent::MouseMove: { | - |
1380 | QMouseEvent *e = static_cast<QMouseEvent*>(event); never executed (the execution status of this line is deduced): QMouseEvent *e = static_cast<QMouseEvent*>(event); | - |
1381 | | - |
1382 | #ifndef QT_NO_CURSOR | - |
1383 | d->adjustCursor(e->pos()); never executed (the execution status of this line is deduced): d->adjustCursor(e->pos()); | - |
1384 | #endif | - |
1385 | if (e->buttons() & Qt::LeftButton) { never evaluated: e->buttons() & Qt::LeftButton | 0 |
1386 | if (d->layout->separatorMove(e->pos())) { never evaluated: d->layout->separatorMove(e->pos()) | 0 |
1387 | // We're moving a separator, eat this event | - |
1388 | e->accept(); never executed (the execution status of this line is deduced): e->accept(); | - |
1389 | return true; never executed: return true; | 0 |
1390 | } | - |
1391 | } | 0 |
1392 | | - |
1393 | break; | 0 |
1394 | } | - |
1395 | | - |
1396 | case QEvent::MouseButtonRelease: { | - |
1397 | QMouseEvent *e = static_cast<QMouseEvent*>(event); never executed (the execution status of this line is deduced): QMouseEvent *e = static_cast<QMouseEvent*>(event); | - |
1398 | if (d->layout->endSeparatorMove(e->pos())) { never evaluated: d->layout->endSeparatorMove(e->pos()) | 0 |
1399 | // We've released a separator, eat this event | - |
1400 | e->accept(); never executed (the execution status of this line is deduced): e->accept(); | - |
1401 | return true; never executed: return true; | 0 |
1402 | } | - |
1403 | break; | 0 |
1404 | } | - |
1405 | | - |
1406 | #endif | - |
1407 | | - |
1408 | #ifndef QT_NO_TOOLBAR | - |
1409 | case QEvent::ToolBarChange: { | - |
1410 | d->layout->toggleToolBarsVisible(); never executed (the execution status of this line is deduced): d->layout->toggleToolBarsVisible(); | - |
1411 | return true; never executed: return true; | 0 |
1412 | } | - |
1413 | #endif | - |
1414 | | - |
1415 | #ifndef QT_NO_STATUSTIP | - |
1416 | case QEvent::StatusTip: | - |
1417 | #ifndef QT_NO_STATUSBAR | - |
1418 | if (QStatusBar *sb = d->layout->statusBar()) evaluated: QStatusBar *sb = d->layout->statusBar() yes Evaluation Count:2 | yes Evaluation Count:83 |
| 2-83 |
1419 | sb->showMessage(static_cast<QStatusTipEvent*>(event)->tip()); executed: sb->showMessage(static_cast<QStatusTipEvent*>(event)->tip()); Execution Count:2 | 2 |
1420 | else | - |
1421 | #endif | - |
1422 | static_cast<QStatusTipEvent*>(event)->ignore(); executed: static_cast<QStatusTipEvent*>(event)->ignore(); Execution Count:83 | 83 |
1423 | return true; executed: return true; Execution Count:85 | 85 |
1424 | #endif // QT_NO_STATUSTIP | - |
1425 | | - |
1426 | case QEvent::StyleChange: | - |
1427 | #ifndef QT_NO_DOCKWIDGET | - |
1428 | d->layout->layoutState.dockAreaLayout.styleChangedEvent(); executed (the execution status of this line is deduced): d->layout->layoutState.dockAreaLayout.styleChangedEvent(); | - |
1429 | #endif | - |
1430 | if (!d->explicitIconSize) partially evaluated: !d->explicitIconSize yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
1431 | setIconSize(QSize()); executed: setIconSize(QSize()); Execution Count:1 | 1 |
1432 | break; executed: break; Execution Count:1 | 1 |
1433 | #ifdef Q_WS_MAC | - |
1434 | case QEvent::Show: | - |
1435 | if (unifiedTitleAndToolBarOnMac()) | - |
1436 | d->layout->syncUnifiedToolbarVisibility(); | - |
1437 | d->layout->blockVisiblityCheck = false; | - |
1438 | break; | - |
1439 | case QEvent::WindowStateChange: | - |
1440 | { | - |
1441 | if (isHidden()) { | - |
1442 | // We are coming out of a minimize, leave things as is. | - |
1443 | d->layout->blockVisiblityCheck = true; | - |
1444 | } | - |
1445 | // We need to update the HIToolbar status when we go out of or into fullscreen. | - |
1446 | QWindowStateChangeEvent *wce = static_cast<QWindowStateChangeEvent *>(event); | - |
1447 | if ((windowState() & Qt::WindowFullScreen) || (wce->oldState() & Qt::WindowFullScreen)) { | - |
1448 | d->layout->updateHIToolBarStatus(); | - |
1449 | } | - |
1450 | } | - |
1451 | break; | - |
1452 | #endif // Q_WS_MAC | - |
1453 | #if !defined(QT_NO_DOCKWIDGET) && !defined(QT_NO_CURSOR) | - |
1454 | case QEvent::CursorChange: | - |
1455 | // CursorChange events are triggered as mouse moves to new widgets even | - |
1456 | // if the cursor doesn't actually change, so do not change oldCursor if | - |
1457 | // the "changed" cursor has same shape as adjusted cursor. | - |
1458 | if (d->cursorAdjusted && d->adjustedCursor.shape() != cursor().shape()) { partially evaluated: d->cursorAdjusted no Evaluation Count:0 | yes Evaluation Count:87 |
never evaluated: d->adjustedCursor.shape() != cursor().shape() | 0-87 |
1459 | d->oldCursor = cursor(); never executed (the execution status of this line is deduced): d->oldCursor = cursor(); | - |
1460 | d->hasOldCursor = testAttribute(Qt::WA_SetCursor); never executed (the execution status of this line is deduced): d->hasOldCursor = testAttribute(Qt::WA_SetCursor); | - |
1461 | | - |
1462 | // Ensure our adjusted cursor stays visible | - |
1463 | setCursor(d->adjustedCursor); never executed (the execution status of this line is deduced): setCursor(d->adjustedCursor); | - |
1464 | } | 0 |
1465 | break; executed: break; Execution Count:87 | 87 |
1466 | #endif | - |
1467 | default: | - |
1468 | break; executed: break; Execution Count:1754 | 1754 |
1469 | } | - |
1470 | | - |
1471 | return QWidget::event(event); executed: return QWidget::event(event); Execution Count:2147 | 2147 |
1472 | } | - |
1473 | | - |
1474 | #ifndef QT_NO_TOOLBAR | - |
1475 | | - |
1476 | /*! | - |
1477 | \property QMainWindow::unifiedTitleAndToolBarOnMac | - |
1478 | \brief whether the window uses the unified title and toolbar look on Mac OS X | - |
1479 | \since 4.3 | - |
1480 | \obsolete | - |
1481 | | - |
1482 | This property is not implemented in Qt 5. Setting it has no effect. | - |
1483 | | - |
1484 | A replacement API (QtMacUnifiedToolBar) is available in QtMacExtras at | - |
1485 | http://qt.gitorious.org/qtplayground/qtmacextras | - |
1486 | */ | - |
1487 | void QMainWindow::setUnifiedTitleAndToolBarOnMac(bool set) | - |
1488 | { | - |
1489 | #ifdef Q_WS_MAC | - |
1490 | Q_D(QMainWindow); | - |
1491 | if (!isWindow() || d->useHIToolBar == set || QSysInfo::MacintoshVersion < QSysInfo::MV_10_3) | - |
1492 | return; | - |
1493 | | - |
1494 | d->useHIToolBar = set; | - |
1495 | createWinId(); // We need the hiview for down below. | - |
1496 | | - |
1497 | // Activate the unified toolbar with the raster engine. | - |
1498 | if (windowSurface() && set) { | - |
1499 | d->layout->unifiedSurface = new QUnifiedToolbarSurface(this); | - |
1500 | } | - |
1501 | | - |
1502 | d->layout->updateHIToolBarStatus(); | - |
1503 | | - |
1504 | // Deactivate the unified toolbar with the raster engine. | - |
1505 | if (windowSurface() && !set) { | - |
1506 | if (d->layout->unifiedSurface) { | - |
1507 | delete d->layout->unifiedSurface; | - |
1508 | d->layout->unifiedSurface = 0; | - |
1509 | } | - |
1510 | } | - |
1511 | | - |
1512 | // Enabling the unified toolbar clears the opaque size grip setting, update it. | - |
1513 | d->macUpdateOpaqueSizeGrip(); | - |
1514 | #else | - |
1515 | Q_UNUSED(set) never executed (the execution status of this line is deduced): (void)set; | - |
1516 | #endif | - |
1517 | } | 0 |
1518 | | - |
1519 | bool QMainWindow::unifiedTitleAndToolBarOnMac() const | - |
1520 | { | - |
1521 | #ifdef Q_WS_MAC | - |
1522 | return d_func()->useHIToolBar && !testAttribute(Qt::WA_MacBrushedMetal) && !(windowFlags() & Qt::FramelessWindowHint); | - |
1523 | #endif | - |
1524 | return false; executed: return false; Execution Count:239 | 239 |
1525 | } | - |
1526 | | - |
1527 | #endif // QT_NO_TOOLBAR | - |
1528 | | - |
1529 | /*! | - |
1530 | \internal | - |
1531 | */ | - |
1532 | bool QMainWindow::isSeparator(const QPoint &pos) const | - |
1533 | { | - |
1534 | #ifndef QT_NO_DOCKWIDGET | - |
1535 | Q_D(const QMainWindow); never executed (the execution status of this line is deduced): const QMainWindowPrivate * const d = d_func(); | - |
1536 | return !d->layout->layoutState.dockAreaLayout.findSeparator(pos).isEmpty(); never executed: return !d->layout->layoutState.dockAreaLayout.findSeparator(pos).isEmpty(); | 0 |
1537 | #else | - |
1538 | Q_UNUSED(pos); | - |
1539 | return false; | - |
1540 | #endif | - |
1541 | } | - |
1542 | | - |
1543 | #ifndef QT_NO_CONTEXTMENU | - |
1544 | /*! | - |
1545 | \reimp | - |
1546 | */ | - |
1547 | void QMainWindow::contextMenuEvent(QContextMenuEvent *event) | - |
1548 | { | - |
1549 | event->ignore(); never executed (the execution status of this line is deduced): event->ignore(); | - |
1550 | // only show the context menu for direct QDockWidget and QToolBar | - |
1551 | // children and for the menu bar as well | - |
1552 | QWidget *child = childAt(event->pos()); never executed (the execution status of this line is deduced): QWidget *child = childAt(event->pos()); | - |
1553 | while (child && child != this) { never evaluated: child never evaluated: child != this | 0 |
1554 | #ifndef QT_NO_MENUBAR | - |
1555 | if (QMenuBar *mb = qobject_cast<QMenuBar *>(child)) { never evaluated: QMenuBar *mb = qobject_cast<QMenuBar *>(child) | 0 |
1556 | if (mb->parentWidget() != this) never evaluated: mb->parentWidget() != this | 0 |
1557 | return; | 0 |
1558 | break; | 0 |
1559 | } | - |
1560 | #endif | - |
1561 | #ifndef QT_NO_DOCKWIDGET | - |
1562 | if (QDockWidget *dw = qobject_cast<QDockWidget *>(child)) { never evaluated: QDockWidget *dw = qobject_cast<QDockWidget *>(child) | 0 |
1563 | if (dw->parentWidget() != this) never evaluated: dw->parentWidget() != this | 0 |
1564 | return; | 0 |
1565 | if (dw->widget() never evaluated: dw->widget() | 0 |
1566 | && dw->widget()->geometry().contains(child->mapFrom(this, event->pos()))) { never evaluated: dw->widget()->geometry().contains(child->mapFrom(this, event->pos())) | 0 |
1567 | // ignore the event if the mouse is over the QDockWidget contents | - |
1568 | return; | 0 |
1569 | } | - |
1570 | break; | 0 |
1571 | } | - |
1572 | #endif // QT_NO_DOCKWIDGET | - |
1573 | #ifndef QT_NO_TOOLBAR | - |
1574 | if (QToolBar *tb = qobject_cast<QToolBar *>(child)) { never evaluated: QToolBar *tb = qobject_cast<QToolBar *>(child) | 0 |
1575 | if (tb->parentWidget() != this) never evaluated: tb->parentWidget() != this | 0 |
1576 | return; | 0 |
1577 | break; | 0 |
1578 | } | - |
1579 | #endif | - |
1580 | child = child->parentWidget(); never executed (the execution status of this line is deduced): child = child->parentWidget(); | - |
1581 | } | 0 |
1582 | if (child == this) never evaluated: child == this | 0 |
1583 | return; | 0 |
1584 | | - |
1585 | #ifndef QT_NO_MENU | - |
1586 | QMenu *popup = createPopupMenu(); never executed (the execution status of this line is deduced): QMenu *popup = createPopupMenu(); | - |
1587 | if (popup) { | 0 |
1588 | if (!popup->isEmpty()) { never evaluated: !popup->isEmpty() | 0 |
1589 | popup->setAttribute(Qt::WA_DeleteOnClose); never executed (the execution status of this line is deduced): popup->setAttribute(Qt::WA_DeleteOnClose); | - |
1590 | popup->popup(event->globalPos()); never executed (the execution status of this line is deduced): popup->popup(event->globalPos()); | - |
1591 | event->accept(); never executed (the execution status of this line is deduced): event->accept(); | - |
1592 | } else { | 0 |
1593 | delete popup; never executed (the execution status of this line is deduced): delete popup; | - |
1594 | } | 0 |
1595 | } | - |
1596 | #endif | - |
1597 | } | 0 |
1598 | #endif // QT_NO_CONTEXTMENU | - |
1599 | | - |
1600 | #ifndef QT_NO_MENU | - |
1601 | /*! | - |
1602 | Returns a popup menu containing checkable entries for the toolbars and | - |
1603 | dock widgets present in the main window. If there are no toolbars and | - |
1604 | dock widgets present, this function returns a null pointer. | - |
1605 | | - |
1606 | By default, this function is called by the main window when the user | - |
1607 | activates a context menu, typically by right-clicking on a toolbar or a dock | - |
1608 | widget. | - |
1609 | | - |
1610 | If you want to create a custom popup menu, reimplement this function and | - |
1611 | return a newly-created popup menu. Ownership of the popup menu is transferred | - |
1612 | to the caller. | - |
1613 | | - |
1614 | \sa addDockWidget(), addToolBar(), menuBar() | - |
1615 | */ | - |
1616 | QMenu *QMainWindow::createPopupMenu() | - |
1617 | { | - |
1618 | Q_D(QMainWindow); never executed (the execution status of this line is deduced): QMainWindowPrivate * const d = d_func(); | - |
1619 | QMenu *menu = 0; never executed (the execution status of this line is deduced): QMenu *menu = 0; | - |
1620 | #ifndef QT_NO_DOCKWIDGET | - |
1621 | QList<QDockWidget *> dockwidgets = findChildren<QDockWidget *>(); never executed (the execution status of this line is deduced): QList<QDockWidget *> dockwidgets = findChildren<QDockWidget *>(); | - |
1622 | if (dockwidgets.size()) { never evaluated: dockwidgets.size() | 0 |
1623 | menu = new QMenu(this); never executed (the execution status of this line is deduced): menu = new QMenu(this); | - |
1624 | for (int i = 0; i < dockwidgets.size(); ++i) { never evaluated: i < dockwidgets.size() | 0 |
1625 | QDockWidget *dockWidget = dockwidgets.at(i); never executed (the execution status of this line is deduced): QDockWidget *dockWidget = dockwidgets.at(i); | - |
1626 | if (dockWidget->parentWidget() == this never evaluated: dockWidget->parentWidget() == this | 0 |
1627 | && !d->layout->layoutState.dockAreaLayout.indexOf(dockWidget).isEmpty()) { never evaluated: !d->layout->layoutState.dockAreaLayout.indexOf(dockWidget).isEmpty() | 0 |
1628 | menu->addAction(dockwidgets.at(i)->toggleViewAction()); never executed (the execution status of this line is deduced): menu->addAction(dockwidgets.at(i)->toggleViewAction()); | - |
1629 | } | 0 |
1630 | } | 0 |
1631 | menu->addSeparator(); never executed (the execution status of this line is deduced): menu->addSeparator(); | - |
1632 | } | 0 |
1633 | #endif // QT_NO_DOCKWIDGET | - |
1634 | #ifndef QT_NO_TOOLBAR | - |
1635 | QList<QToolBar *> toolbars = findChildren<QToolBar *>(); never executed (the execution status of this line is deduced): QList<QToolBar *> toolbars = findChildren<QToolBar *>(); | - |
1636 | if (toolbars.size()) { never evaluated: toolbars.size() | 0 |
1637 | if (!menu) | 0 |
1638 | menu = new QMenu(this); never executed: menu = new QMenu(this); | 0 |
1639 | for (int i = 0; i < toolbars.size(); ++i) { never evaluated: i < toolbars.size() | 0 |
1640 | QToolBar *toolBar = toolbars.at(i); never executed (the execution status of this line is deduced): QToolBar *toolBar = toolbars.at(i); | - |
1641 | if (toolBar->parentWidget() == this never evaluated: toolBar->parentWidget() == this | 0 |
1642 | && (!d->layout->layoutState.toolBarAreaLayout.indexOf(toolBar).isEmpty() never evaluated: !d->layout->layoutState.toolBarAreaLayout.indexOf(toolBar).isEmpty() | 0 |
1643 | || (unifiedTitleAndToolBarOnMac() never evaluated: unifiedTitleAndToolBarOnMac() | 0 |
1644 | && toolBarArea(toolBar) == Qt::TopToolBarArea))) { never evaluated: toolBarArea(toolBar) == Qt::TopToolBarArea | 0 |
1645 | menu->addAction(toolbars.at(i)->toggleViewAction()); never executed (the execution status of this line is deduced): menu->addAction(toolbars.at(i)->toggleViewAction()); | - |
1646 | } | 0 |
1647 | } | 0 |
1648 | } | 0 |
1649 | #endif | - |
1650 | Q_UNUSED(d); never executed (the execution status of this line is deduced): (void)d;; | - |
1651 | return menu; never executed: return menu; | 0 |
1652 | } | - |
1653 | #endif // QT_NO_MENU | - |
1654 | | - |
1655 | QT_END_NAMESPACE | - |
1656 | | - |
1657 | #endif // QT_NO_MAINWINDOW | - |
1658 | | - |
| | |