widgets/qmenubar.cpp

Source codeSwitch to Preprocessed file
LineSource CodeCoverage
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#include <qmenubar.h> -
43 -
44#include <qstyle.h> -
45#include <qlayout.h> -
46#include <qapplication.h> -
47#include <qdesktopwidget.h> -
48#ifndef QT_NO_ACCESSIBILITY -
49# include <qaccessible.h> -
50#endif -
51#include <qpainter.h> -
52#include <qstylepainter.h> -
53#include <qevent.h> -
54#include <qmainwindow.h> -
55#include <qtoolbar.h> -
56#include <qtoolbutton.h> -
57#include <qwhatsthis.h> -
58#include <qpa/qplatformtheme.h> -
59#include "private/qguiapplication_p.h" -
60#include "qpa/qplatformintegration.h" -
61 -
62#ifndef QT_NO_MENUBAR -
63 -
64 -
65#include "qmenu_p.h" -
66#include "qmenubar_p.h" -
67#include "qdebug.h" -
68 -
69#ifdef Q_OS_WINCE -
70extern bool qt_wince_is_mobile(); //defined in qguifunctions_wce.cpp -
71#endif -
72 -
73QT_BEGIN_NAMESPACE -
74 -
75class QMenuBarExtension : public QToolButton -
76{ -
77public: -
78 explicit QMenuBarExtension(QWidget *parent); -
79 -
80 QSize sizeHint() const; -
81 void paintEvent(QPaintEvent *); -
82}; -
83 -
84QMenuBarExtension::QMenuBarExtension(QWidget *parent) -
85 : QToolButton(parent) -
86{ -
87 setObjectName(QLatin1String("qt_menubar_ext_button"));
executed (the execution status of this line is deduced): setObjectName(QLatin1String("qt_menubar_ext_button"));
-
88 setAutoRaise(true);
executed (the execution status of this line is deduced): setAutoRaise(true);
-
89#ifndef QT_NO_MENU -
90 setPopupMode(QToolButton::InstantPopup);
executed (the execution status of this line is deduced): setPopupMode(QToolButton::InstantPopup);
-
91#endif -
92 setIcon(style()->standardIcon(QStyle::SP_ToolBarHorizontalExtensionButton, 0, parentWidget()));
executed (the execution status of this line is deduced): setIcon(style()->standardIcon(QStyle::SP_ToolBarHorizontalExtensionButton, 0, parentWidget()));
-
93}
executed: }
Execution Count:23
23
94 -
95void QMenuBarExtension::paintEvent(QPaintEvent *) -
96{ -
97 QStylePainter p(this);
executed (the execution status of this line is deduced): QStylePainter p(this);
-
98 QStyleOptionToolButton opt;
executed (the execution status of this line is deduced): QStyleOptionToolButton opt;
-
99 initStyleOption(&opt);
executed (the execution status of this line is deduced): initStyleOption(&opt);
-
100 // We do not need to draw both extension arrows -
101 opt.features &= ~QStyleOptionToolButton::HasMenu;
executed (the execution status of this line is deduced): opt.features &= ~QStyleOptionToolButton::HasMenu;
-
102 p.drawComplexControl(QStyle::CC_ToolButton, opt);
executed (the execution status of this line is deduced): p.drawComplexControl(QStyle::CC_ToolButton, opt);
-
103}
executed: }
Execution Count:6
6
104 -
105 -
106QSize QMenuBarExtension::sizeHint() const -
107{ -
108 int ext = style()->pixelMetric(QStyle::PM_ToolBarExtensionExtent, 0, parentWidget());
executed (the execution status of this line is deduced): int ext = style()->pixelMetric(QStyle::PM_ToolBarExtensionExtent, 0, parentWidget());
-
109 return QSize(ext, ext);
executed: return QSize(ext, ext);
Execution Count:122
122
110} -
111 -
112 -
113/*! -
114 \internal -
115*/ -
116QAction *QMenuBarPrivate::actionAt(QPoint p) const -
117{ -
118 for(int i = 0; i < actions.size(); ++i) {
partially evaluated: i < actions.size()
TRUEFALSE
yes
Evaluation Count:14
no
Evaluation Count:0
0-14
119 if(actionRect(actions.at(i)).contains(p))
evaluated: actionRect(actions.at(i)).contains(p)
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:6
6-8
120 return actions.at(i);
executed: return actions.at(i);
Execution Count:8
8
121 }
executed: }
Execution Count:6
6
122 return 0;
never executed: return 0;
0
123} -
124 -
125QRect QMenuBarPrivate::menuRect(bool extVisible) const -
126{ -
127 Q_Q(const QMenuBar);
executed (the execution status of this line is deduced): const QMenuBar * const q = q_func();
-
128 -
129 int hmargin = q->style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, q);
executed (the execution status of this line is deduced): int hmargin = q->style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, q);
-
130 QRect result = q->rect();
executed (the execution status of this line is deduced): QRect result = q->rect();
-
131 result.adjust(hmargin, 0, -hmargin, 0);
executed (the execution status of this line is deduced): result.adjust(hmargin, 0, -hmargin, 0);
-
132 -
133 if (extVisible) {
evaluated: extVisible
TRUEFALSE
yes
Evaluation Count:60
yes
Evaluation Count:360
60-360
134 if (q->isRightToLeft())
evaluated: q->isRightToLeft()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:58
2-58
135 result.setLeft(result.left() + extension->sizeHint().width());
executed: result.setLeft(result.left() + extension->sizeHint().width());
Execution Count:2
2
136 else -
137 result.setWidth(result.width() - extension->sizeHint().width());
executed: result.setWidth(result.width() - extension->sizeHint().width());
Execution Count:58
58
138 } -
139 -
140 if (leftWidget && leftWidget->isVisible()) {
evaluated: leftWidget
TRUEFALSE
yes
Evaluation Count:184
yes
Evaluation Count:236
evaluated: leftWidget->isVisible()
TRUEFALSE
yes
Evaluation Count:143
yes
Evaluation Count:41
41-236
141 QSize sz = leftWidget->sizeHint();
executed (the execution status of this line is deduced): QSize sz = leftWidget->sizeHint();
-
142 if (q->isRightToLeft())
evaluated: q->isRightToLeft()
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:139
4-139
143 result.setRight(result.right() - sz.width());
executed: result.setRight(result.right() - sz.width());
Execution Count:4
4
144 else -
145 result.setLeft(result.left() + sz.width());
executed: result.setLeft(result.left() + sz.width());
Execution Count:139
139
146 } -
147 -
148 if (rightWidget && rightWidget->isVisible()) {
evaluated: rightWidget
TRUEFALSE
yes
Evaluation Count:101
yes
Evaluation Count:319
evaluated: rightWidget->isVisible()
TRUEFALSE
yes
Evaluation Count:60
yes
Evaluation Count:41
41-319
149 QSize sz = rightWidget->sizeHint();
executed (the execution status of this line is deduced): QSize sz = rightWidget->sizeHint();
-
150 if (q->isRightToLeft())
evaluated: q->isRightToLeft()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:58
2-58
151 result.setLeft(result.left() + sz.width());
executed: result.setLeft(result.left() + sz.width());
Execution Count:2
2
152 else -
153 result.setRight(result.right() - sz.width());
executed: result.setRight(result.right() - sz.width());
Execution Count:58
58
154 } -
155 -
156 return result;
executed: return result;
Execution Count:420
420
157} -
158 -
159bool QMenuBarPrivate::isVisible(QAction *action) -
160{ -
161 return !hiddenActions.contains(action);
executed: return !hiddenActions.contains(action);
Execution Count:69
69
162} -
163 -
164void QMenuBarPrivate::updateGeometries() -
165{ -
166 Q_Q(QMenuBar);
executed (the execution status of this line is deduced): QMenuBar * const q = q_func();
-
167 if(!itemsDirty)
evaluated: !itemsDirty
TRUEFALSE
yes
Evaluation Count:394
yes
Evaluation Count:360
360-394
168 return;
executed: return;
Execution Count:394
394
169 int q_width = q->width()-(q->style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, q)*2);
executed (the execution status of this line is deduced): int q_width = q->width()-(q->style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, q)*2);
-
170 int q_start = -1;
executed (the execution status of this line is deduced): int q_start = -1;
-
171 if(leftWidget || rightWidget) {
evaluated: leftWidget
TRUEFALSE
yes
Evaluation Count:184
yes
Evaluation Count:176
partially evaluated: rightWidget
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:176
0-184
172 int vmargin = q->style()->pixelMetric(QStyle::PM_MenuBarVMargin, 0, q)
executed (the execution status of this line is deduced): int vmargin = q->style()->pixelMetric(QStyle::PM_MenuBarVMargin, 0, q)
-
173 + q->style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, q);
executed (the execution status of this line is deduced): + q->style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, q);
-
174 int hmargin = q->style()->pixelMetric(QStyle::PM_MenuBarHMargin, 0, q)
executed (the execution status of this line is deduced): int hmargin = q->style()->pixelMetric(QStyle::PM_MenuBarHMargin, 0, q)
-
175 + q->style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, q);
executed (the execution status of this line is deduced): + q->style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, q);
-
176 if (leftWidget && leftWidget->isVisible()) {
partially evaluated: leftWidget
TRUEFALSE
yes
Evaluation Count:184
no
Evaluation Count:0
evaluated: leftWidget->isVisible()
TRUEFALSE
yes
Evaluation Count:143
yes
Evaluation Count:41
0-184
177 QSize sz = leftWidget->sizeHint();
executed (the execution status of this line is deduced): QSize sz = leftWidget->sizeHint();
-
178 q_width -= sz.width();
executed (the execution status of this line is deduced): q_width -= sz.width();
-
179 q_start = sz.width();
executed (the execution status of this line is deduced): q_start = sz.width();
-
180 QPoint pos(hmargin, (q->height() - leftWidget->height()) / 2);
executed (the execution status of this line is deduced): QPoint pos(hmargin, (q->height() - leftWidget->height()) / 2);
-
181 QRect vRect = QStyle::visualRect(q->layoutDirection(), q->rect(), QRect(pos, sz));
executed (the execution status of this line is deduced): QRect vRect = QStyle::visualRect(q->layoutDirection(), q->rect(), QRect(pos, sz));
-
182 leftWidget->setGeometry(vRect);
executed (the execution status of this line is deduced): leftWidget->setGeometry(vRect);
-
183 }
executed: }
Execution Count:143
143
184 if (rightWidget && rightWidget->isVisible()) {
evaluated: rightWidget
TRUEFALSE
yes
Evaluation Count:101
yes
Evaluation Count:83
evaluated: rightWidget->isVisible()
TRUEFALSE
yes
Evaluation Count:60
yes
Evaluation Count:41
41-101
185 QSize sz = rightWidget->sizeHint();
executed (the execution status of this line is deduced): QSize sz = rightWidget->sizeHint();
-
186 q_width -= sz.width();
executed (the execution status of this line is deduced): q_width -= sz.width();
-
187 QPoint pos(q->width() - sz.width() - hmargin, vmargin);
executed (the execution status of this line is deduced): QPoint pos(q->width() - sz.width() - hmargin, vmargin);
-
188 QRect vRect = QStyle::visualRect(q->layoutDirection(), q->rect(), QRect(pos, sz));
executed (the execution status of this line is deduced): QRect vRect = QStyle::visualRect(q->layoutDirection(), q->rect(), QRect(pos, sz));
-
189 rightWidget->setGeometry(vRect);
executed (the execution status of this line is deduced): rightWidget->setGeometry(vRect);
-
190 }
executed: }
Execution Count:60
60
191 }
executed: }
Execution Count:184
184
192 -
193#ifdef Q_OS_MAC -
194 if(q->isNativeMenuBar()) {//nothing to see here folks, move along.. -
195 itemsDirty = false; -
196 return; -
197 } -
198#endif -
199 calcActionRects(q_width, q_start);
executed (the execution status of this line is deduced): calcActionRects(q_width, q_start);
-
200 currentAction = 0;
executed (the execution status of this line is deduced): currentAction = 0;
-
201#ifndef QT_NO_SHORTCUT -
202 if(itemsDirty) {
partially evaluated: itemsDirty
TRUEFALSE
yes
Evaluation Count:360
no
Evaluation Count:0
0-360
203 for(int j = 0; j < shortcutIndexMap.size(); ++j)
evaluated: j < shortcutIndexMap.size()
TRUEFALSE
yes
Evaluation Count:312
yes
Evaluation Count:360
312-360
204 q->releaseShortcut(shortcutIndexMap.value(j));
executed: q->releaseShortcut(shortcutIndexMap.value(j));
Execution Count:312
312
205 shortcutIndexMap.resize(0); // faster than clear
executed (the execution status of this line is deduced): shortcutIndexMap.resize(0);
-
206 for(int i = 0; i < actions.count(); i++)
evaluated: i < actions.count()
TRUEFALSE
yes
Evaluation Count:332
yes
Evaluation Count:360
332-360
207 shortcutIndexMap.append(q->grabShortcut(QKeySequence::mnemonic(actions.at(i)->text())));
executed: shortcutIndexMap.append(q->grabShortcut(QKeySequence::mnemonic(actions.at(i)->text())));
Execution Count:332
332
208 }
executed: }
Execution Count:360
360
209#endif -
210 itemsDirty = false;
executed (the execution status of this line is deduced): itemsDirty = false;
-
211 -
212 hiddenActions.clear();
executed (the execution status of this line is deduced): hiddenActions.clear();
-
213 //this is the menu rectangle without any extension -
214 QRect menuRect = this->menuRect(false);
executed (the execution status of this line is deduced): QRect menuRect = this->menuRect(false);
-
215 -
216 //we try to see if the actions will fit there -
217 bool hasHiddenActions = false;
executed (the execution status of this line is deduced): bool hasHiddenActions = false;
-
218 for (int i = 0; i < actions.count(); ++i) {
evaluated: i < actions.count()
TRUEFALSE
yes
Evaluation Count:212
yes
Evaluation Count:300
212-300
219 const QRect &rect = actionRects.at(i);
executed (the execution status of this line is deduced): const QRect &rect = actionRects.at(i);
-
220 if (rect.isValid() && !menuRect.contains(rect)) {
evaluated: rect.isValid()
TRUEFALSE
yes
Evaluation Count:207
yes
Evaluation Count:5
evaluated: !menuRect.contains(rect)
TRUEFALSE
yes
Evaluation Count:60
yes
Evaluation Count:147
5-207
221 hasHiddenActions = true;
executed (the execution status of this line is deduced): hasHiddenActions = true;
-
222 break;
executed: break;
Execution Count:60
60
223 } -
224 }
executed: }
Execution Count:152
152
225 -
226 //...and if not, determine the ones that fit on the menu with the extension visible -
227 if (hasHiddenActions) {
evaluated: hasHiddenActions
TRUEFALSE
yes
Evaluation Count:60
yes
Evaluation Count:300
60-300
228 menuRect = this->menuRect(true);
executed (the execution status of this line is deduced): menuRect = this->menuRect(true);
-
229 for (int i = 0; i < actions.count(); ++i) {
evaluated: i < actions.count()
TRUEFALSE
yes
Evaluation Count:243
yes
Evaluation Count:60
60-243
230 const QRect &rect = actionRects.at(i);
executed (the execution status of this line is deduced): const QRect &rect = actionRects.at(i);
-
231 if (rect.isValid() && !menuRect.contains(rect)) {
evaluated: rect.isValid()
TRUEFALSE
yes
Evaluation Count:242
yes
Evaluation Count:1
evaluated: !menuRect.contains(rect)
TRUEFALSE
yes
Evaluation Count:181
yes
Evaluation Count:61
1-242
232 hiddenActions.append(actions.at(i));
executed (the execution status of this line is deduced): hiddenActions.append(actions.at(i));
-
233 }
executed: }
Execution Count:181
181
234 }
executed: }
Execution Count:243
243
235 }
executed: }
Execution Count:60
60
236 -
237 if (hiddenActions.count() > 0) {
evaluated: hiddenActions.count() > 0
TRUEFALSE
yes
Evaluation Count:60
yes
Evaluation Count:300
60-300
238 QMenu *pop = extension->menu();
executed (the execution status of this line is deduced): QMenu *pop = extension->menu();
-
239 if (!pop) {
evaluated: !pop
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:56
4-56
240 pop = new QMenu(q);
executed (the execution status of this line is deduced): pop = new QMenu(q);
-
241 extension->setMenu(pop);
executed (the execution status of this line is deduced): extension->setMenu(pop);
-
242 }
executed: }
Execution Count:4
4
243 pop->clear();
executed (the execution status of this line is deduced): pop->clear();
-
244 pop->addActions(hiddenActions);
executed (the execution status of this line is deduced): pop->addActions(hiddenActions);
-
245 -
246 int vmargin = q->style()->pixelMetric(QStyle::PM_MenuBarVMargin, 0, q);
executed (the execution status of this line is deduced): int vmargin = q->style()->pixelMetric(QStyle::PM_MenuBarVMargin, 0, q);
-
247 int x = q->isRightToLeft()
evaluated: q->isRightToLeft()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:58
2-58
248 ? menuRect.left() - extension->sizeHint().width() + 1
executed (the execution status of this line is deduced): ? menuRect.left() - extension->sizeHint().width() + 1
-
249 : menuRect.right();
executed (the execution status of this line is deduced): : menuRect.right();
-
250 extension->setGeometry(x, vmargin, extension->sizeHint().width(), menuRect.height() - vmargin*2);
executed (the execution status of this line is deduced): extension->setGeometry(x, vmargin, extension->sizeHint().width(), menuRect.height() - vmargin*2);
-
251 extension->show();
executed (the execution status of this line is deduced): extension->show();
-
252 } else {
executed: }
Execution Count:60
60
253 extension->hide();
executed (the execution status of this line is deduced): extension->hide();
-
254 }
executed: }
Execution Count:300
300
255 q->updateGeometry();
executed (the execution status of this line is deduced): q->updateGeometry();
-
256}
executed: }
Execution Count:360
360
257 -
258QRect QMenuBarPrivate::actionRect(QAction *act) const -
259{ -
260 const int index = actions.indexOf(act);
executed (the execution status of this line is deduced): const int index = actions.indexOf(act);
-
261 -
262 //makes sure the geometries are up-to-date -
263 const_cast<QMenuBarPrivate*>(this)->updateGeometries();
executed (the execution status of this line is deduced): const_cast<QMenuBarPrivate*>(this)->updateGeometries();
-
264 -
265 if (index < 0 || index >= actionRects.count())
evaluated: index < 0
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:216
partially evaluated: index >= actionRects.count()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:216
0-216
266 return QRect(); // that can happen in case of native menubar
executed: return QRect();
Execution Count:2
2
267 -
268 return actionRects.at(index);
executed: return actionRects.at(index);
Execution Count:216
216
269} -
270 -
271void QMenuBarPrivate::focusFirstAction() -
272{ -
273 if(!currentAction) {
evaluated: !currentAction
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:34
1-34
274 updateGeometries();
executed (the execution status of this line is deduced): updateGeometries();
-
275 int index = 0;
executed (the execution status of this line is deduced): int index = 0;
-
276 while (index < actions.count() && actionRects.at(index).isNull()) ++index;
never executed: ++index;
partially evaluated: index < actions.count()
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
partially evaluated: actionRects.at(index).isNull()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
277 if (index < actions.count())
partially evaluated: index < actions.count()
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
278 setCurrentAction(actions.at(index));
executed: setCurrentAction(actions.at(index));
Execution Count:1
1
279 }
executed: }
Execution Count:1
1
280}
executed: }
Execution Count:35
35
281 -
282void QMenuBarPrivate::setKeyboardMode(bool b) -
283{ -
284 Q_Q(QMenuBar);
executed (the execution status of this line is deduced): QMenuBar * const q = q_func();
-
285 if (b && !q->style()->styleHint(QStyle::SH_MenuBar_AltKeyNavigation, 0, q)) {
evaluated: b
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:11
partially evaluated: !q->style()->styleHint(QStyle::SH_MenuBar_AltKeyNavigation, 0, q)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:14
0-14
286 setCurrentAction(0);
never executed (the execution status of this line is deduced): setCurrentAction(0);
-
287 return;
never executed: return;
0
288 } -
289 keyboardState = b;
executed (the execution status of this line is deduced): keyboardState = b;
-
290 if(b) {
evaluated: b
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:11
11-14
291 QWidget *fw = QApplication::focusWidget();
executed (the execution status of this line is deduced): QWidget *fw = QApplication::focusWidget();
-
292 if (fw != q)
evaluated: fw != q
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:9
5-9
293 keyboardFocusWidget = fw;
executed: keyboardFocusWidget = fw;
Execution Count:5
5
294 focusFirstAction();
executed (the execution status of this line is deduced): focusFirstAction();
-
295 q->setFocus(Qt::MenuBarFocusReason);
executed (the execution status of this line is deduced): q->setFocus(Qt::MenuBarFocusReason);
-
296 } else {
executed: }
Execution Count:14
14
297 if(!popupState)
partially evaluated: !popupState
TRUEFALSE
yes
Evaluation Count:11
no
Evaluation Count:0
0-11
298 setCurrentAction(0);
executed: setCurrentAction(0);
Execution Count:11
11
299 if(keyboardFocusWidget) {
evaluated: keyboardFocusWidget
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:10
1-10
300 if (QApplication::focusWidget() == q)
partially evaluated: QApplication::focusWidget() == q
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
301 keyboardFocusWidget->setFocus(Qt::MenuBarFocusReason);
never executed: keyboardFocusWidget->setFocus(Qt::MenuBarFocusReason);
0
302 keyboardFocusWidget = 0;
executed (the execution status of this line is deduced): keyboardFocusWidget = 0;
-
303 }
executed: }
Execution Count:1
1
304 }
executed: }
Execution Count:11
11
305 q->update();
executed (the execution status of this line is deduced): q->update();
-
306}
executed: }
Execution Count:25
25
307 -
308void QMenuBarPrivate::popupAction(QAction *action, bool activateFirst) -
309{ -
310 Q_Q(QMenuBar);
executed (the execution status of this line is deduced): QMenuBar * const q = q_func();
-
311 if(!action || !action->menu() || closePopupMode)
partially evaluated: !action
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:34
evaluated: !action->menu()
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:26
partially evaluated: closePopupMode
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:26
0-34
312 return;
executed: return;
Execution Count:8
8
313 popupState = true;
executed (the execution status of this line is deduced): popupState = true;
-
314 if (action->isEnabled() && action->menu()->isEnabled()) {
evaluated: action->isEnabled()
TRUEFALSE
yes
Evaluation Count:25
yes
Evaluation Count:1
partially evaluated: action->menu()->isEnabled()
TRUEFALSE
yes
Evaluation Count:25
no
Evaluation Count:0
0-25
315 closePopupMode = 0;
executed (the execution status of this line is deduced): closePopupMode = 0;
-
316 activeMenu = action->menu();
executed (the execution status of this line is deduced): activeMenu = action->menu();
-
317 activeMenu->d_func()->causedPopup.widget = q;
executed (the execution status of this line is deduced): activeMenu->d_func()->causedPopup.widget = q;
-
318 activeMenu->d_func()->causedPopup.action = action;
executed (the execution status of this line is deduced): activeMenu->d_func()->causedPopup.action = action;
-
319 -
320 QRect adjustedActionRect = actionRect(action);
executed (the execution status of this line is deduced): QRect adjustedActionRect = actionRect(action);
-
321 QPoint pos(q->mapToGlobal(QPoint(adjustedActionRect.left(), adjustedActionRect.bottom() + 1)));
executed (the execution status of this line is deduced): QPoint pos(q->mapToGlobal(QPoint(adjustedActionRect.left(), adjustedActionRect.bottom() + 1)));
-
322 QSize popup_size = activeMenu->sizeHint();
executed (the execution status of this line is deduced): QSize popup_size = activeMenu->sizeHint();
-
323 -
324 //we put the popup menu on the screen containing the bottom-center of the action rect -
325 QRect screenRect = QApplication::desktop()->screenGeometry(pos + QPoint(adjustedActionRect.width() / 2, 0));
executed (the execution status of this line is deduced): QRect screenRect = QApplication::desktop()->screenGeometry(pos + QPoint(adjustedActionRect.width() / 2, 0));
-
326 pos = QPoint(qMax(pos.x(), screenRect.x()), qMax(pos.y(), screenRect.y()));
executed (the execution status of this line is deduced): pos = QPoint(qMax(pos.x(), screenRect.x()), qMax(pos.y(), screenRect.y()));
-
327 -
328 const bool fitUp = (q->mapToGlobal(adjustedActionRect.topLeft()).y() >= popup_size.height());
executed (the execution status of this line is deduced): const bool fitUp = (q->mapToGlobal(adjustedActionRect.topLeft()).y() >= popup_size.height());
-
329 const bool fitDown = (pos.y() + popup_size.height() <= screenRect.bottom());
executed (the execution status of this line is deduced): const bool fitDown = (pos.y() + popup_size.height() <= screenRect.bottom());
-
330 const bool rtl = q->isRightToLeft();
executed (the execution status of this line is deduced): const bool rtl = q->isRightToLeft();
-
331 const int actionWidth = adjustedActionRect.width();
executed (the execution status of this line is deduced): const int actionWidth = adjustedActionRect.width();
-
332 -
333 if (!fitUp && !fitDown) { //we should shift the menu
evaluated: !fitUp
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:22
evaluated: !fitDown
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2
1-22
334 bool shouldShiftToRight = !rtl;
executed (the execution status of this line is deduced): bool shouldShiftToRight = !rtl;
-
335 if (rtl && popup_size.width() > pos.x())
partially evaluated: rtl
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
never evaluated: popup_size.width() > pos.x()
0-1
336 shouldShiftToRight = true;
never executed: shouldShiftToRight = true;
0
337 else if (actionWidth + popup_size.width() + pos.x() > screenRect.right())
partially evaluated: actionWidth + popup_size.width() + pos.x() > screenRect.right()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
338 shouldShiftToRight = false;
never executed: shouldShiftToRight = false;
0
339 -
340 if (shouldShiftToRight) {
partially evaluated: shouldShiftToRight
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
341 pos.rx() += actionWidth + (rtl ? popup_size.width() : 0);
partially evaluated: rtl
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
342 } else {
executed: }
Execution Count:1
1
343 //shift to left -
344 if (!rtl)
never evaluated: !rtl
0
345 pos.rx() -= popup_size.width();
never executed: pos.rx() -= popup_size.width();
0
346 }
never executed: }
0
347 } else if (rtl) {
evaluated: rtl
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:21
3-21
348 pos.rx() += actionWidth;
executed (the execution status of this line is deduced): pos.rx() += actionWidth;
-
349 }
executed: }
Execution Count:3
3
350 -
351 if(!defaultPopDown || (fitUp && !fitDown))
partially evaluated: !defaultPopDown
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:25
evaluated: fitUp
TRUEFALSE
yes
Evaluation Count:22
yes
Evaluation Count:3
evaluated: !fitDown
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:21
0-25
352 pos.setY(qMax(screenRect.y(), q->mapToGlobal(QPoint(0, adjustedActionRect.top()-popup_size.height())).y()));
executed: pos.setY(qMax(screenRect.y(), q->mapToGlobal(QPoint(0, adjustedActionRect.top()-popup_size.height())).y()));
Execution Count:1
1
353 activeMenu->popup(pos);
executed (the execution status of this line is deduced): activeMenu->popup(pos);
-
354 if(activateFirst)
evaluated: activateFirst
TRUEFALSE
yes
Evaluation Count:16
yes
Evaluation Count:9
9-16
355 activeMenu->d_func()->setFirstActionActive();
executed: activeMenu->d_func()->setFirstActionActive();
Execution Count:16
16
356 }
executed: }
Execution Count:25
25
357 q->update(actionRect(action));
executed (the execution status of this line is deduced): q->update(actionRect(action));
-
358}
executed: }
Execution Count:26
26
359 -
360void QMenuBarPrivate::setCurrentAction(QAction *action, bool popup, bool activateFirst) -
361{ -
362 if(currentAction == action && popup == popupState)
evaluated: currentAction == action
TRUEFALSE
yes
Evaluation Count:24
yes
Evaluation Count:59
evaluated: popup == popupState
TRUEFALSE
yes
Evaluation Count:23
yes
Evaluation Count:1
1-59
363 return;
executed: return;
Execution Count:23
23
364 -
365 autoReleaseTimer.stop();
executed (the execution status of this line is deduced): autoReleaseTimer.stop();
-
366 -
367 doChildEffects = (popup && !activeMenu);
evaluated: popup
TRUEFALSE
yes
Evaluation Count:34
yes
Evaluation Count:26
evaluated: !activeMenu
TRUEFALSE
yes
Evaluation Count:25
yes
Evaluation Count:9
9-34
368 Q_Q(QMenuBar);
executed (the execution status of this line is deduced): QMenuBar * const q = q_func();
-
369 QWidget *fw = 0;
executed (the execution status of this line is deduced): QWidget *fw = 0;
-
370 if(QMenu *menu = activeMenu) {
evaluated: QMenu *menu = activeMenu
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:40
20-40
371 activeMenu = 0;
executed (the execution status of this line is deduced): activeMenu = 0;
-
372 if (popup) {
evaluated: popup
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:11
9-11
373 fw = q->window()->focusWidget();
executed (the execution status of this line is deduced): fw = q->window()->focusWidget();
-
374 q->setFocus(Qt::NoFocusReason);
executed (the execution status of this line is deduced): q->setFocus(Qt::NoFocusReason);
-
375 }
executed: }
Execution Count:9
9
376 menu->hide();
executed (the execution status of this line is deduced): menu->hide();
-
377 }
executed: }
Execution Count:20
20
378 -
379 if(currentAction)
evaluated: currentAction
TRUEFALSE
yes
Evaluation Count:28
yes
Evaluation Count:32
28-32
380 q->update(actionRect(currentAction));
executed: q->update(actionRect(currentAction));
Execution Count:28
28
381 -
382 popupState = popup;
executed (the execution status of this line is deduced): popupState = popup;
-
383#ifndef QT_NO_STATUSTIP -
384 QAction *previousAction = currentAction;
executed (the execution status of this line is deduced): QAction *previousAction = currentAction;
-
385#endif -
386 currentAction = action;
executed (the execution status of this line is deduced): currentAction = action;
-
387 if (action) {
evaluated: action
TRUEFALSE
yes
Evaluation Count:37
yes
Evaluation Count:23
23-37
388 activateAction(action, QAction::Hover);
executed (the execution status of this line is deduced): activateAction(action, QAction::Hover);
-
389 if(popup)
evaluated: popup
TRUEFALSE
yes
Evaluation Count:33
yes
Evaluation Count:4
4-33
390 popupAction(action, activateFirst);
executed: popupAction(action, activateFirst);
Execution Count:33
33
391 q->update(actionRect(action));
executed (the execution status of this line is deduced): q->update(actionRect(action));
-
392#ifndef QT_NO_STATUSTIP -
393 } else if (previousAction) {
executed: }
Execution Count:37
partially evaluated: previousAction
TRUEFALSE
yes
Evaluation Count:23
no
Evaluation Count:0
0-37
394 QString empty;
executed (the execution status of this line is deduced): QString empty;
-
395 QStatusTipEvent tip(empty);
executed (the execution status of this line is deduced): QStatusTipEvent tip(empty);
-
396 QApplication::sendEvent(q, &tip);
executed (the execution status of this line is deduced): QApplication::sendEvent(q, &tip);
-
397#endif -
398 }
executed: }
Execution Count:23
23
399 if (fw)
evaluated: fw
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:53
7-53
400 fw->setFocus(Qt::NoFocusReason);
executed: fw->setFocus(Qt::NoFocusReason);
Execution Count:7
7
401}
executed: }
Execution Count:60
60
402 -
403void QMenuBarPrivate::calcActionRects(int max_width, int start) const -
404{ -
405 Q_Q(const QMenuBar);
executed (the execution status of this line is deduced): const QMenuBar * const q = q_func();
-
406 -
407 if(!itemsDirty)
evaluated: !itemsDirty
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:360
4-360
408 return;
executed: return;
Execution Count:4
4
409 -
410 //let's reinitialize the buffer -
411 actionRects.resize(actions.count());
executed (the execution status of this line is deduced): actionRects.resize(actions.count());
-
412 actionRects.fill(QRect());
executed (the execution status of this line is deduced): actionRects.fill(QRect());
-
413 -
414 const QStyle *style = q->style();
executed (the execution status of this line is deduced): const QStyle *style = q->style();
-
415 -
416 const int itemSpacing = style->pixelMetric(QStyle::PM_MenuBarItemSpacing, 0, q);
executed (the execution status of this line is deduced): const int itemSpacing = style->pixelMetric(QStyle::PM_MenuBarItemSpacing, 0, q);
-
417 int max_item_height = 0, separator = -1, separator_start = 0, separator_len = 0;
executed (the execution status of this line is deduced): int max_item_height = 0, separator = -1, separator_start = 0, separator_len = 0;
-
418 -
419 //calculate size -
420 const QFontMetrics fm = q->fontMetrics();
executed (the execution status of this line is deduced): const QFontMetrics fm = q->fontMetrics();
-
421 const int hmargin = style->pixelMetric(QStyle::PM_MenuBarHMargin, 0, q),
executed (the execution status of this line is deduced): const int hmargin = style->pixelMetric(QStyle::PM_MenuBarHMargin, 0, q),
-
422 vmargin = style->pixelMetric(QStyle::PM_MenuBarVMargin, 0, q),
executed (the execution status of this line is deduced): vmargin = style->pixelMetric(QStyle::PM_MenuBarVMargin, 0, q),
-
423 icone = style->pixelMetric(QStyle::PM_SmallIconSize, 0, q);
executed (the execution status of this line is deduced): icone = style->pixelMetric(QStyle::PM_SmallIconSize, 0, q);
-
424 for(int i = 0; i < actions.count(); i++) {
evaluated: i < actions.count()
TRUEFALSE
yes
Evaluation Count:332
yes
Evaluation Count:360
332-360
425 QAction *action = actions.at(i);
executed (the execution status of this line is deduced): QAction *action = actions.at(i);
-
426 if(!action->isVisible())
evaluated: !action->isVisible()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:331
1-331
427 continue;
executed: continue;
Execution Count:1
1
428 -
429 QSize sz;
executed (the execution status of this line is deduced): QSize sz;
-
430 -
431 //calc what I think the size is.. -
432 if(action->isSeparator()) {
evaluated: action->isSeparator()
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:328
3-328
433 if (style->styleHint(QStyle::SH_DrawMenuBarSeparator, 0, q))
partially evaluated: style->styleHint(QStyle::SH_DrawMenuBarSeparator, 0, q)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
434 separator = i;
never executed: separator = i;
0
435 continue; //we don't really position these!
executed: continue;
Execution Count:3
3
436 } else { -
437 const QString s = action->text();
executed (the execution status of this line is deduced): const QString s = action->text();
-
438 QIcon is = action->icon();
executed (the execution status of this line is deduced): QIcon is = action->icon();
-
439 // If an icon is set, only the icon is visible -
440 if (!is.isNull())
partially evaluated: !is.isNull()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:328
0-328
441 sz = sz.expandedTo(QSize(icone, icone));
never executed: sz = sz.expandedTo(QSize(icone, icone));
0
442 else if (!s.isEmpty())
evaluated: !s.isEmpty()
TRUEFALSE
yes
Evaluation Count:327
yes
Evaluation Count:1
1-327
443 sz = fm.size(Qt::TextShowMnemonic, s);
executed: sz = fm.size(Qt::TextShowMnemonic, s);
Execution Count:327
327
444 } -
445 -
446 //let the style modify the above size.. -
447 QStyleOptionMenuItem opt;
executed (the execution status of this line is deduced): QStyleOptionMenuItem opt;
-
448 q->initStyleOption(&opt, action);
executed (the execution status of this line is deduced): q->initStyleOption(&opt, action);
-
449 sz = q->style()->sizeFromContents(QStyle::CT_MenuBarItem, &opt, sz, q);
executed (the execution status of this line is deduced): sz = q->style()->sizeFromContents(QStyle::CT_MenuBarItem, &opt, sz, q);
-
450 -
451 if(!sz.isEmpty()) {
evaluated: !sz.isEmpty()
TRUEFALSE
yes
Evaluation Count:327
yes
Evaluation Count:1
1-327
452 { //update the separator state -
453 int iWidth = sz.width() + itemSpacing;
executed (the execution status of this line is deduced): int iWidth = sz.width() + itemSpacing;
-
454 if(separator == -1)
partially evaluated: separator == -1
TRUEFALSE
yes
Evaluation Count:327
no
Evaluation Count:0
0-327
455 separator_start += iWidth;
executed: separator_start += iWidth;
Execution Count:327
327
456 else -
457 separator_len += iWidth;
never executed: separator_len += iWidth;
0
458 } -
459 //maximum height -
460 max_item_height = qMax(max_item_height, sz.height());
executed (the execution status of this line is deduced): max_item_height = qMax(max_item_height, sz.height());
-
461 //append -
462 actionRects[i] = QRect(0, 0, sz.width(), sz.height());
executed (the execution status of this line is deduced): actionRects[i] = QRect(0, 0, sz.width(), sz.height());
-
463 }
executed: }
Execution Count:327
327
464 }
executed: }
Execution Count:328
328
465 -
466 //calculate position -
467 const int fw = q->style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, q);
executed (the execution status of this line is deduced): const int fw = q->style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, q);
-
468 int x = fw + ((start == -1) ? hmargin : start) + itemSpacing;
evaluated: (start == -1)
TRUEFALSE
yes
Evaluation Count:217
yes
Evaluation Count:143
143-217
469 int y = fw + vmargin;
executed (the execution status of this line is deduced): int y = fw + vmargin;
-
470 for(int i = 0; i < actions.count(); i++) {
evaluated: i < actions.count()
TRUEFALSE
yes
Evaluation Count:332
yes
Evaluation Count:360
332-360
471 QRect &rect = actionRects[i];
executed (the execution status of this line is deduced): QRect &rect = actionRects[i];
-
472 if (rect.isNull())
evaluated: rect.isNull()
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:327
5-327
473 continue;
executed: continue;
Execution Count:5
5
474 -
475 //resize -
476 rect.setHeight(max_item_height);
executed (the execution status of this line is deduced): rect.setHeight(max_item_height);
-
477 -
478 //move -
479 if(separator != -1 && i >= separator) { //after the separator
partially evaluated: separator != -1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:327
never evaluated: i >= separator
0-327
480 int left = (max_width - separator_len - hmargin - itemSpacing) + (x - separator_start - hmargin);
never executed (the execution status of this line is deduced): int left = (max_width - separator_len - hmargin - itemSpacing) + (x - separator_start - hmargin);
-
481 if(left < separator_start) { //wrap
never evaluated: left < separator_start
0
482 separator_start = x = hmargin;
never executed (the execution status of this line is deduced): separator_start = x = hmargin;
-
483 y += max_item_height;
never executed (the execution status of this line is deduced): y += max_item_height;
-
484 }
never executed: }
0
485 rect.moveLeft(left);
never executed (the execution status of this line is deduced): rect.moveLeft(left);
-
486 } else {
never executed: }
0
487 rect.moveLeft(x);
executed (the execution status of this line is deduced): rect.moveLeft(x);
-
488 }
executed: }
Execution Count:327
327
489 rect.moveTop(y);
executed (the execution status of this line is deduced): rect.moveTop(y);
-
490 -
491 //keep moving along.. -
492 x += rect.width() + itemSpacing;
executed (the execution status of this line is deduced): x += rect.width() + itemSpacing;
-
493 -
494 //make sure we follow the layout direction -
495 rect = QStyle::visualRect(q->layoutDirection(), q->rect(), rect);
executed (the execution status of this line is deduced): rect = QStyle::visualRect(q->layoutDirection(), q->rect(), rect);
-
496 }
executed: }
Execution Count:327
327
497}
executed: }
Execution Count:360
360
498 -
499void QMenuBarPrivate::activateAction(QAction *action, QAction::ActionEvent action_e) -
500{ -
501 Q_Q(QMenuBar);
executed (the execution status of this line is deduced): QMenuBar * const q = q_func();
-
502 if (!action || !action->isEnabled())
partially evaluated: !action
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:39
evaluated: !action->isEnabled()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:38
0-39
503 return;
executed: return;
Execution Count:1
1
504 action->activate(action_e);
executed (the execution status of this line is deduced): action->activate(action_e);
-
505 if (action_e == QAction::Hover)
evaluated: action_e == QAction::Hover
TRUEFALSE
yes
Evaluation Count:36
yes
Evaluation Count:2
2-36
506 action->showStatusText(q);
executed: action->showStatusText(q);
Execution Count:36
36
507 -
508// if(action_e == QAction::Trigger) -
509// emit q->activated(action); -
510// else if(action_e == QAction::Hover) -
511// emit q->highlighted(action); -
512}
executed: }
Execution Count:38
38
513 -
514 -
515void QMenuBarPrivate::_q_actionTriggered() -
516{ -
517 Q_Q(QMenuBar);
executed (the execution status of this line is deduced): QMenuBar * const q = q_func();
-
518 if (QAction *action = qobject_cast<QAction *>(q->sender())) {
partially evaluated: QAction *action = qobject_cast<QAction *>(q->sender())
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
519 emit q->triggered(action);
executed (the execution status of this line is deduced): q->triggered(action);
-
520 }
executed: }
Execution Count:3
3
521}
executed: }
Execution Count:3
3
522 -
523void QMenuBarPrivate::_q_actionHovered() -
524{ -
525 Q_Q(QMenuBar);
executed (the execution status of this line is deduced): QMenuBar * const q = q_func();
-
526 if (QAction *action = qobject_cast<QAction *>(q->sender())) {
partially evaluated: QAction *action = qobject_cast<QAction *>(q->sender())
TRUEFALSE
yes
Evaluation Count:35
no
Evaluation Count:0
0-35
527 emit q->hovered(action);
executed (the execution status of this line is deduced): q->hovered(action);
-
528#ifndef QT_NO_ACCESSIBILITY -
529 if (QAccessible::isActive()) {
evaluated: QAccessible::isActive()
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:30
5-30
530 int actionIndex = actions.indexOf(action);
executed (the execution status of this line is deduced): int actionIndex = actions.indexOf(action);
-
531 QAccessibleEvent focusEvent(q, QAccessible::Focus);
executed (the execution status of this line is deduced): QAccessibleEvent focusEvent(q, QAccessible::Focus);
-
532 focusEvent.setChild(actionIndex);
executed (the execution status of this line is deduced): focusEvent.setChild(actionIndex);
-
533 QAccessible::updateAccessibility(&focusEvent);
executed (the execution status of this line is deduced): QAccessible::updateAccessibility(&focusEvent);
-
534 QAccessibleEvent selectionEvent(q, QAccessible::Selection);
executed (the execution status of this line is deduced): QAccessibleEvent selectionEvent(q, QAccessible::Selection);
-
535 selectionEvent.setChild(actionIndex);
executed (the execution status of this line is deduced): selectionEvent.setChild(actionIndex);
-
536 QAccessible::updateAccessibility(&selectionEvent);
executed (the execution status of this line is deduced): QAccessible::updateAccessibility(&selectionEvent);
-
537 }
executed: }
Execution Count:5
5
538#endif //QT_NO_ACCESSIBILITY -
539 }
executed: }
Execution Count:35
35
540}
executed: }
Execution Count:35
35
541 -
542/*! -
543 Initialize \a option with the values from the menu bar and information from \a action. This method -
544 is useful for subclasses when they need a QStyleOptionMenuItem, but don't want -
545 to fill in all the information themselves. -
546 -
547 \sa QStyleOption::initFrom(), QMenu::initStyleOption() -
548*/ -
549void QMenuBar::initStyleOption(QStyleOptionMenuItem *option, const QAction *action) const -
550{ -
551 if (!option || !action)
partially evaluated: !option
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:374
partially evaluated: !action
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:374
0-374
552 return;
never executed: return;
0
553 Q_D(const QMenuBar);
executed (the execution status of this line is deduced): const QMenuBarPrivate * const d = d_func();
-
554 option->palette = palette();
executed (the execution status of this line is deduced): option->palette = palette();
-
555 option->state = QStyle::State_None;
executed (the execution status of this line is deduced): option->state = QStyle::State_None;
-
556 if (isEnabled() && action->isEnabled())
partially evaluated: isEnabled()
TRUEFALSE
yes
Evaluation Count:374
no
Evaluation Count:0
evaluated: action->isEnabled()
TRUEFALSE
yes
Evaluation Count:373
yes
Evaluation Count:1
0-374
557 option->state |= QStyle::State_Enabled;
executed: option->state |= QStyle::State_Enabled;
Execution Count:373
373
558 else -
559 option->palette.setCurrentColorGroup(QPalette::Disabled);
executed: option->palette.setCurrentColorGroup(QPalette::Disabled);
Execution Count:1
1
560 option->fontMetrics = fontMetrics();
executed (the execution status of this line is deduced): option->fontMetrics = fontMetrics();
-
561 if (d->currentAction && d->currentAction == action) {
evaluated: d->currentAction
TRUEFALSE
yes
Evaluation Count:23
yes
Evaluation Count:351
evaluated: d->currentAction == action
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:9
9-351
562 option->state |= QStyle::State_Selected;
executed (the execution status of this line is deduced): option->state |= QStyle::State_Selected;
-
563 if (d->popupState && !d->closePopupMode)
evaluated: d->popupState
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:2
partially evaluated: !d->closePopupMode
TRUEFALSE
yes
Evaluation Count:12
no
Evaluation Count:0
0-12
564 option->state |= QStyle::State_Sunken;
executed: option->state |= QStyle::State_Sunken;
Execution Count:12
12
565 }
executed: }
Execution Count:14
14
566 if (hasFocus() || d->currentAction)
evaluated: hasFocus()
TRUEFALSE
yes
Evaluation Count:47
yes
Evaluation Count:327
evaluated: d->currentAction
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:317
10-327
567 option->state |= QStyle::State_HasFocus;
executed: option->state |= QStyle::State_HasFocus;
Execution Count:57
57
568 option->menuRect = rect();
executed (the execution status of this line is deduced): option->menuRect = rect();
-
569 option->menuItemType = QStyleOptionMenuItem::Normal;
executed (the execution status of this line is deduced): option->menuItemType = QStyleOptionMenuItem::Normal;
-
570 option->checkType = QStyleOptionMenuItem::NotCheckable;
executed (the execution status of this line is deduced): option->checkType = QStyleOptionMenuItem::NotCheckable;
-
571 option->text = action->text();
executed (the execution status of this line is deduced): option->text = action->text();
-
572 option->icon = action->icon();
executed (the execution status of this line is deduced): option->icon = action->icon();
-
573}
executed: }
Execution Count:374
374
574 -
575/*! -
576 \class QMenuBar -
577 \brief The QMenuBar class provides a horizontal menu bar. -
578 -
579 \ingroup mainwindow-classes -
580 \inmodule QtWidgets -
581 -
582 A menu bar consists of a list of pull-down menu items. You add -
583 menu items with addMenu(). For example, asuming that \c menubar -
584 is a pointer to a QMenuBar and \c fileMenu is a pointer to a -
585 QMenu, the following statement inserts the menu into the menu bar: -
586 \snippet code/src_gui_widgets_qmenubar.cpp 0 -
587 -
588 The ampersand in the menu item's text sets Alt+F as a shortcut for -
589 this menu. (You can use "\&\&" to get a real ampersand in the menu -
590 bar.) -
591 -
592 There is no need to lay out a menu bar. It automatically sets its -
593 own geometry to the top of the parent widget and changes it -
594 appropriately whenever the parent is resized. -
595 -
596 \section1 Usage -
597 -
598 In most main window style applications you would use the -
599 \l{QMainWindow::}{menuBar()} function provided in QMainWindow, -
600 adding \l{QMenu}s to the menu bar and adding \l{QAction}s to the -
601 pop-up menus. -
602 -
603 Example (from the \l{mainwindows/menus}{Menus} example): -
604 -
605 \snippet mainwindows/menus/mainwindow.cpp 9 -
606 -
607 Menu items may be removed with removeAction(). -
608 -
609 Widgets can be added to menus by using instances of the QWidgetAction -
610 class to hold them. These actions can then be inserted into menus -
611 in the usual way; see the QMenu documentation for more details. -
612 -
613 \section1 Platform Dependent Look and Feel -
614 -
615 Different platforms have different requirements for the appearance -
616 of menu bars and their behavior when the user interacts with them. -
617 For example, Windows systems are often configured so that the -
618 underlined character mnemonics that indicate keyboard shortcuts -
619 for items in the menu bar are only shown when the \uicontrol{Alt} key is -
620 pressed. -
621 -
622 \section1 QMenuBar on Mac OS X -
623 -
624 QMenuBar on Mac OS X is a wrapper for using the system-wide menu bar. -
625 If you have multiple menu bars in one dialog the outermost menu bar -
626 (normally inside a widget with widget flag Qt::Window) will -
627 be used for the system-wide menu bar. -
628 -
629 Qt for Mac OS X also provides a menu bar merging feature to make -
630 QMenuBar conform more closely to accepted Mac OS X menu bar layout. -
631 The merging functionality is based on string matching the title of -
632 a QMenu entry. These strings are translated (using QObject::tr()) -
633 in the "QMenuBar" context. If an entry is moved its slots will still -
634 fire as if it was in the original place. The table below outlines -
635 the strings looked for and where the entry is placed if matched: -
636 -
637 \table -
638 \header \li String matches \li Placement \li Notes -
639 \row \li about.* -
640 \li Application Menu | About <application name> -
641 \li The application name is fetched from the \c {Info.plist} file -
642 (see note below). If this entry is not found no About item -
643 will appear in the Application Menu. -
644 \row \li config, options, setup, settings or preferences -
645 \li Application Menu | Preferences -
646 \li If this entry is not found the Settings item will be disabled -
647 \row \li quit or exit -
648 \li Application Menu | Quit <application name> -
649 \li If this entry is not found a default Quit item will be -
650 created to call QApplication::quit() -
651 \endtable -
652 -
653 You can override this behavior by using the QAction::menuRole() -
654 property. -
655 -
656 If you want all windows in a Mac application to share one menu -
657 bar, you must create a menu bar that does not have a parent. -
658 Create a parent-less menu bar this way: -
659 -
660 \snippet code/src_gui_widgets_qmenubar.cpp 1 -
661 -
662 \b{Note:} Do \e{not} call QMainWindow::menuBar() to create the -
663 shared menu bar, because that menu bar will have the QMainWindow -
664 as its parent. That menu bar would only be displayed for the -
665 parent QMainWindow. -
666 -
667 \b{Note:} The text used for the application name in the menu -
668 bar is obtained from the value set in the \c{Info.plist} file in -
669 the application's bundle. See \l{Deploying an Application on -
670 Mac OS X} for more information. -
671 -
672 \section1 QMenuBar on Windows CE -
673 -
674 QMenuBar on Windows CE is a wrapper for using the system-wide menu bar, -
675 similar to the Mac. This feature is activated for Windows Mobile -
676 and integrates QMenuBar with the native soft keys. The left soft -
677 key can be controlled with QMenuBar::setDefaultAction() and the -
678 right soft key can be used to access the menu bar. -
679 -
680 The hovered() signal is not supported for the native menu -
681 integration. Also, it is not possible to display an icon in a -
682 native menu on Windows Mobile. -
683 -
684 \section1 Examples -
685 -
686 The \l{mainwindows/menus}{Menus} example shows how to use QMenuBar -
687 and QMenu. The other \l{Main Window Examples}{main window -
688 application examples} also provide menus using these classes. -
689 -
690 \sa QMenu, QShortcut, QAction, -
691 {http://developer.apple.com/documentation/UserExperience/Conceptual/AppleHIGuidelines/XHIGIntro/XHIGIntro.html}{Introduction to Apple Human Interface Guidelines}, -
692 {fowler}{GUI Design Handbook: Menu Bar}, {Menus Example} -
693*/ -
694 -
695 -
696void QMenuBarPrivate::init() -
697{ -
698 Q_Q(QMenuBar);
executed (the execution status of this line is deduced): QMenuBar * const q = q_func();
-
699 q->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum);
executed (the execution status of this line is deduced): q->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum);
-
700 q->setAttribute(Qt::WA_CustomWhatsThis);
executed (the execution status of this line is deduced): q->setAttribute(Qt::WA_CustomWhatsThis);
-
701 -
702 platformMenuBar = QGuiApplicationPrivate::platformTheme()->createPlatformMenuBar();
executed (the execution status of this line is deduced): platformMenuBar = QGuiApplicationPrivate::platformTheme()->createPlatformMenuBar();
-
703 -
704 if (platformMenuBar)
partially evaluated: platformMenuBar
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:23
0-23
705 q->hide();
never executed: q->hide();
0
706#ifdef Q_OS_WINCE -
707 if (qt_wince_is_mobile()) { -
708 wceCreateMenuBar(q->parentWidget()); -
709 if(wce_menubar) -
710 q->hide(); -
711 } -
712 else { -
713 QApplication::setAttribute(Qt::AA_DontUseNativeMenuBar, true); -
714 } -
715#endif -
716 q->setBackgroundRole(QPalette::Button);
executed (the execution status of this line is deduced): q->setBackgroundRole(QPalette::Button);
-
717 oldWindow = oldParent = 0;
executed (the execution status of this line is deduced): oldWindow = oldParent = 0;
-
718 handleReparent();
executed (the execution status of this line is deduced): handleReparent();
-
719 q->setMouseTracking(q->style()->styleHint(QStyle::SH_MenuBar_MouseTracking, 0, q));
executed (the execution status of this line is deduced): q->setMouseTracking(q->style()->styleHint(QStyle::SH_MenuBar_MouseTracking, 0, q));
-
720 -
721 extension = new QMenuBarExtension(q);
executed (the execution status of this line is deduced): extension = new QMenuBarExtension(q);
-
722 extension->setFocusPolicy(Qt::NoFocus);
executed (the execution status of this line is deduced): extension->setFocusPolicy(Qt::NoFocus);
-
723 extension->hide();
executed (the execution status of this line is deduced): extension->hide();
-
724}
executed: }
Execution Count:23
23
725 -
726//Gets the next action for keyboard navigation -
727QAction *QMenuBarPrivate::getNextAction(const int _start, const int increment) const -
728{ -
729 Q_Q(const QMenuBar);
executed (the execution status of this line is deduced): const QMenuBar * const q = q_func();
-
730 const_cast<QMenuBarPrivate*>(this)->updateGeometries();
executed (the execution status of this line is deduced): const_cast<QMenuBarPrivate*>(this)->updateGeometries();
-
731 bool allowActiveAndDisabled = q->style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, 0, q);
executed (the execution status of this line is deduced): bool allowActiveAndDisabled = q->style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, 0, q);
-
732 const int start = (_start == -1 && increment == -1) ? actions.count() : _start;
evaluated: _start == -1
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:8
partially evaluated: increment == -1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-8
733 const int end = increment == -1 ? 0 : actions.count() - 1;
evaluated: increment == -1
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:7
3-7
734 -
735 for (int i = start; i != end;) {
evaluated: i != end
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:2
2-9
736 i += increment;
executed (the execution status of this line is deduced): i += increment;
-
737 QAction *current = actions.at(i);
executed (the execution status of this line is deduced): QAction *current = actions.at(i);
-
738 if (!actionRects.at(i).isNull() && (allowActiveAndDisabled || current->isEnabled()))
evaluated: !actionRects.at(i).isNull()
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:1
partially evaluated: allowActiveAndDisabled
TRUEFALSE
yes
Evaluation Count:8
no
Evaluation Count:0
never evaluated: current->isEnabled()
0-8
739 return current;
executed: return current;
Execution Count:8
8
740 }
executed: }
Execution Count:1
1
741 -
742 if (_start != -1) //let's try from the beginning or the end
partially evaluated: _start != -1
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
743 return getNextAction(-1, increment);
executed: return getNextAction(-1, increment);
Execution Count:2
2
744 -
745 return 0;
never executed: return 0;
0
746} -
747 -
748/*! -
749 Constructs a menu bar with parent \a parent. -
750*/ -
751QMenuBar::QMenuBar(QWidget *parent) : QWidget(*new QMenuBarPrivate, parent, 0) -
752{ -
753 Q_D(QMenuBar);
executed (the execution status of this line is deduced): QMenuBarPrivate * const d = d_func();
-
754 d->init();
executed (the execution status of this line is deduced): d->init();
-
755}
executed: }
Execution Count:23
23
756 -
757 -
758/*! -
759 Destroys the menu bar. -
760*/ -
761QMenuBar::~QMenuBar() -
762{ -
763 Q_D(QMenuBar);
executed (the execution status of this line is deduced): QMenuBarPrivate * const d = d_func();
-
764 delete d->platformMenuBar;
executed (the execution status of this line is deduced): delete d->platformMenuBar;
-
765 d->platformMenuBar = 0;
executed (the execution status of this line is deduced): d->platformMenuBar = 0;
-
766 -
767#ifdef Q_OS_WINCE -
768 if (qt_wince_is_mobile()) -
769 d->wceDestroyMenuBar(); -
770#endif -
771}
executed: }
Execution Count:23
23
772 -
773/*! -
774 \overload -
775 -
776 This convenience function creates a new action with \a text. -
777 The function adds the newly created action to the menu's -
778 list of actions, and returns it. -
779 -
780 \sa QWidget::addAction(), QWidget::actions() -
781*/ -
782QAction *QMenuBar::addAction(const QString &text) -
783{ -
784 QAction *ret = new QAction(text, this);
executed (the execution status of this line is deduced): QAction *ret = new QAction(text, this);
-
785 addAction(ret);
executed (the execution status of this line is deduced): addAction(ret);
-
786 return ret;
executed: return ret;
Execution Count:20
20
787} -
788 -
789/*! -
790 \overload -
791 -
792 This convenience function creates a new action with the given \a -
793 text. The action's triggered() signal is connected to the \a -
794 receiver's \a member slot. The function adds the newly created -
795 action to the menu's list of actions and returns it. -
796 -
797 \sa QWidget::addAction(), QWidget::actions() -
798*/ -
799QAction *QMenuBar::addAction(const QString &text, const QObject *receiver, const char* member) -
800{ -
801 QAction *ret = new QAction(text, this);
executed (the execution status of this line is deduced): QAction *ret = new QAction(text, this);
-
802 QObject::connect(ret, SIGNAL(triggered(bool)), receiver, member);
executed (the execution status of this line is deduced): QObject::connect(ret, "2""triggered(bool)", receiver, member);
-
803 addAction(ret);
executed (the execution status of this line is deduced): addAction(ret);
-
804 return ret;
executed: return ret;
Execution Count:8
8
805} -
806 -
807/*! -
808 Appends a new QMenu with \a title to the menu bar. The menu bar -
809 takes ownership of the menu. Returns the new menu. -
810 -
811 \sa QWidget::addAction(), QMenu::menuAction() -
812*/ -
813QMenu *QMenuBar::addMenu(const QString &title) -
814{ -
815 QMenu *menu = new QMenu(title, this);
executed (the execution status of this line is deduced): QMenu *menu = new QMenu(title, this);
-
816 addAction(menu->menuAction());
executed (the execution status of this line is deduced): addAction(menu->menuAction());
-
817 return menu;
executed: return menu;
Execution Count:40
40
818} -
819 -
820/*! -
821 Appends a new QMenu with \a icon and \a title to the menu bar. The menu bar -
822 takes ownership of the menu. Returns the new menu. -
823 -
824 \sa QWidget::addAction(), QMenu::menuAction() -
825*/ -
826QMenu *QMenuBar::addMenu(const QIcon &icon, const QString &title) -
827{ -
828 QMenu *menu = new QMenu(title, this);
never executed (the execution status of this line is deduced): QMenu *menu = new QMenu(title, this);
-
829 menu->setIcon(icon);
never executed (the execution status of this line is deduced): menu->setIcon(icon);
-
830 addAction(menu->menuAction());
never executed (the execution status of this line is deduced): addAction(menu->menuAction());
-
831 return menu;
never executed: return menu;
0
832} -
833 -
834/*! -
835 Appends \a menu to the menu bar. Returns the menu's menuAction(). -
836 -
837 \note The returned QAction object can be used to hide the corresponding -
838 menu. -
839 -
840 \sa QWidget::addAction(), QMenu::menuAction() -
841*/ -
842QAction *QMenuBar::addMenu(QMenu *menu) -
843{ -
844 QAction *action = menu->menuAction();
executed (the execution status of this line is deduced): QAction *action = menu->menuAction();
-
845 addAction(action);
executed (the execution status of this line is deduced): addAction(action);
-
846 return action;
executed: return action;
Execution Count:27
27
847} -
848 -
849/*! -
850 Appends a separator to the menu. -
851*/ -
852QAction *QMenuBar::addSeparator() -
853{ -
854 QAction *ret = new QAction(this);
executed (the execution status of this line is deduced): QAction *ret = new QAction(this);
-
855 ret->setSeparator(true);
executed (the execution status of this line is deduced): ret->setSeparator(true);
-
856 addAction(ret);
executed (the execution status of this line is deduced): addAction(ret);
-
857 return ret;
executed: return ret;
Execution Count:1
1
858} -
859 -
860/*! -
861 This convenience function creates a new separator action, i.e. an -
862 action with QAction::isSeparator() returning true. The function inserts -
863 the newly created action into this menu bar's list of actions before -
864 action \a before and returns it. -
865 -
866 \sa QWidget::insertAction(), addSeparator() -
867*/ -
868QAction *QMenuBar::insertSeparator(QAction *before) -
869{ -
870 QAction *action = new QAction(this);
never executed (the execution status of this line is deduced): QAction *action = new QAction(this);
-
871 action->setSeparator(true);
never executed (the execution status of this line is deduced): action->setSeparator(true);
-
872 insertAction(before, action);
never executed (the execution status of this line is deduced): insertAction(before, action);
-
873 return action;
never executed: return action;
0
874} -
875 -
876/*! -
877 This convenience function inserts \a menu before action \a before -
878 and returns the menus menuAction(). -
879 -
880 \sa QWidget::insertAction(), addMenu() -
881*/ -
882QAction *QMenuBar::insertMenu(QAction *before, QMenu *menu) -
883{ -
884 QAction *action = menu->menuAction();
never executed (the execution status of this line is deduced): QAction *action = menu->menuAction();
-
885 insertAction(before, action);
never executed (the execution status of this line is deduced): insertAction(before, action);
-
886 return action;
never executed: return action;
0
887} -
888 -
889/*! -
890 Returns the QAction that is currently highlighted. A null pointer -
891 will be returned if no action is currently selected. -
892*/ -
893QAction *QMenuBar::activeAction() const -
894{ -
895 Q_D(const QMenuBar);
executed (the execution status of this line is deduced): const QMenuBarPrivate * const d = d_func();
-
896 return d->currentAction;
executed: return d->currentAction;
Execution Count:16
16
897} -
898 -
899/*! -
900 \since 4.1 -
901 -
902 Sets the currently highlighted action to \a act. -
903*/ -
904void QMenuBar::setActiveAction(QAction *act) -
905{ -
906 Q_D(QMenuBar);
executed (the execution status of this line is deduced): QMenuBarPrivate * const d = d_func();
-
907 d->setCurrentAction(act, true, false);
executed (the execution status of this line is deduced): d->setCurrentAction(act, true, false);
-
908}
executed: }
Execution Count:11
11
909 -
910 -
911/*! -
912 Removes all the actions from the menu bar. -
913 -
914 \note On Mac OS X, menu items that have been merged to the system -
915 menu bar are not removed by this function. One way to handle this -
916 would be to remove the extra actions yourself. You can set the -
917 \l{QAction::MenuRole}{menu role} on the different menus, so that -
918 you know ahead of time which menu items get merged and which do -
919 not. Then decide what to recreate or remove yourself. -
920 -
921 \sa removeAction() -
922*/ -
923void QMenuBar::clear() -
924{ -
925 QList<QAction*> acts = actions();
executed (the execution status of this line is deduced): QList<QAction*> acts = actions();
-
926 for(int i = 0; i < acts.size(); i++)
evaluated: i < acts.size()
TRUEFALSE
yes
Evaluation Count:61
yes
Evaluation Count:23
23-61
927 removeAction(acts[i]);
executed: removeAction(acts[i]);
Execution Count:61
61
928}
executed: }
Execution Count:23
23
929 -
930/*! -
931 \property QMenuBar::defaultUp -
932 \brief the popup orientation -
933 -
934 The default popup orientation. By default, menus pop "down" the -
935 screen. By setting the property to true, the menu will pop "up". -
936 You might call this for menus that are \e below the document to -
937 which they refer. -
938 -
939 If the menu would not fit on the screen, the other direction is -
940 used automatically. -
941*/ -
942void QMenuBar::setDefaultUp(bool b) -
943{ -
944 Q_D(QMenuBar);
never executed (the execution status of this line is deduced): QMenuBarPrivate * const d = d_func();
-
945 d->defaultPopDown = !b;
never executed (the execution status of this line is deduced): d->defaultPopDown = !b;
-
946}
never executed: }
0
947 -
948bool QMenuBar::isDefaultUp() const -
949{ -
950 Q_D(const QMenuBar);
never executed (the execution status of this line is deduced): const QMenuBarPrivate * const d = d_func();
-
951 return !d->defaultPopDown;
never executed: return !d->defaultPopDown;
0
952} -
953 -
954/*! -
955 \reimp -
956*/ -
957void QMenuBar::resizeEvent(QResizeEvent *) -
958{ -
959 Q_D(QMenuBar);
executed (the execution status of this line is deduced): QMenuBarPrivate * const d = d_func();
-
960 d->itemsDirty = true;
executed (the execution status of this line is deduced): d->itemsDirty = true;
-
961 d->updateGeometries();
executed (the execution status of this line is deduced): d->updateGeometries();
-
962}
executed: }
Execution Count:40
40
963 -
964/*! -
965 \reimp -
966*/ -
967void QMenuBar::paintEvent(QPaintEvent *e) -
968{ -
969 Q_D(QMenuBar);
executed (the execution status of this line is deduced): QMenuBarPrivate * const d = d_func();
-
970 QPainter p(this);
executed (the execution status of this line is deduced): QPainter p(this);
-
971 QRegion emptyArea(rect());
executed (the execution status of this line is deduced): QRegion emptyArea(rect());
-
972 -
973 //draw the items -
974 for (int i = 0; i < d->actions.count(); ++i) {
evaluated: i < d->actions.count()
TRUEFALSE
yes
Evaluation Count:67
yes
Evaluation Count:52
52-67
975 QAction *action = d->actions.at(i);
executed (the execution status of this line is deduced): QAction *action = d->actions.at(i);
-
976 QRect adjustedActionRect = d->actionRect(action);
executed (the execution status of this line is deduced): QRect adjustedActionRect = d->actionRect(action);
-
977 if (adjustedActionRect.isEmpty() || !d->isVisible(action))
evaluated: adjustedActionRect.isEmpty()
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:64
evaluated: !d->isVisible(action)
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:52
3-64
978 continue;
executed: continue;
Execution Count:15
15
979 if(!e->rect().intersects(adjustedActionRect))
evaluated: !e->rect().intersects(adjustedActionRect)
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:46
6-46
980 continue;
executed: continue;
Execution Count:6
6
981 -
982 emptyArea -= adjustedActionRect;
executed (the execution status of this line is deduced): emptyArea -= adjustedActionRect;
-
983 QStyleOptionMenuItem opt;
executed (the execution status of this line is deduced): QStyleOptionMenuItem opt;
-
984 initStyleOption(&opt, action);
executed (the execution status of this line is deduced): initStyleOption(&opt, action);
-
985 opt.rect = adjustedActionRect;
executed (the execution status of this line is deduced): opt.rect = adjustedActionRect;
-
986 p.setClipRect(adjustedActionRect);
executed (the execution status of this line is deduced): p.setClipRect(adjustedActionRect);
-
987 style()->drawControl(QStyle::CE_MenuBarItem, &opt, &p, this);
executed (the execution status of this line is deduced): style()->drawControl(QStyle::CE_MenuBarItem, &opt, &p, this);
-
988 }
executed: }
Execution Count:46
46
989 //draw border -
990 if(int fw = style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, this)) {
partially evaluated: int fw = style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, this)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:52
0-52
991 QRegion borderReg;
never executed (the execution status of this line is deduced): QRegion borderReg;
-
992 borderReg += QRect(0, 0, fw, height()); //left
never executed (the execution status of this line is deduced): borderReg += QRect(0, 0, fw, height());
-
993 borderReg += QRect(width()-fw, 0, fw, height()); //right
never executed (the execution status of this line is deduced): borderReg += QRect(width()-fw, 0, fw, height());
-
994 borderReg += QRect(0, 0, width(), fw); //top
never executed (the execution status of this line is deduced): borderReg += QRect(0, 0, width(), fw);
-
995 borderReg += QRect(0, height()-fw, width(), fw); //bottom
never executed (the execution status of this line is deduced): borderReg += QRect(0, height()-fw, width(), fw);
-
996 p.setClipRegion(borderReg);
never executed (the execution status of this line is deduced): p.setClipRegion(borderReg);
-
997 emptyArea -= borderReg;
never executed (the execution status of this line is deduced): emptyArea -= borderReg;
-
998 QStyleOptionFrame frame;
never executed (the execution status of this line is deduced): QStyleOptionFrame frame;
-
999 frame.rect = rect();
never executed (the execution status of this line is deduced): frame.rect = rect();
-
1000 frame.palette = palette();
never executed (the execution status of this line is deduced): frame.palette = palette();
-
1001 frame.state = QStyle::State_None;
never executed (the execution status of this line is deduced): frame.state = QStyle::State_None;
-
1002 frame.lineWidth = style()->pixelMetric(QStyle::PM_MenuBarPanelWidth);
never executed (the execution status of this line is deduced): frame.lineWidth = style()->pixelMetric(QStyle::PM_MenuBarPanelWidth);
-
1003 frame.midLineWidth = 0;
never executed (the execution status of this line is deduced): frame.midLineWidth = 0;
-
1004 style()->drawPrimitive(QStyle::PE_PanelMenuBar, &frame, &p, this);
never executed (the execution status of this line is deduced): style()->drawPrimitive(QStyle::PE_PanelMenuBar, &frame, &p, this);
-
1005 }
never executed: }
0
1006 p.setClipRegion(emptyArea);
executed (the execution status of this line is deduced): p.setClipRegion(emptyArea);
-
1007 QStyleOptionMenuItem menuOpt;
executed (the execution status of this line is deduced): QStyleOptionMenuItem menuOpt;
-
1008 menuOpt.palette = palette();
executed (the execution status of this line is deduced): menuOpt.palette = palette();
-
1009 menuOpt.state = QStyle::State_None;
executed (the execution status of this line is deduced): menuOpt.state = QStyle::State_None;
-
1010 menuOpt.menuItemType = QStyleOptionMenuItem::EmptyArea;
executed (the execution status of this line is deduced): menuOpt.menuItemType = QStyleOptionMenuItem::EmptyArea;
-
1011 menuOpt.checkType = QStyleOptionMenuItem::NotCheckable;
executed (the execution status of this line is deduced): menuOpt.checkType = QStyleOptionMenuItem::NotCheckable;
-
1012 menuOpt.rect = rect();
executed (the execution status of this line is deduced): menuOpt.rect = rect();
-
1013 menuOpt.menuRect = rect();
executed (the execution status of this line is deduced): menuOpt.menuRect = rect();
-
1014 style()->drawControl(QStyle::CE_MenuBarEmptyArea, &menuOpt, &p, this);
executed (the execution status of this line is deduced): style()->drawControl(QStyle::CE_MenuBarEmptyArea, &menuOpt, &p, this);
-
1015}
executed: }
Execution Count:52
52
1016 -
1017/*! -
1018 \reimp -
1019*/ -
1020void QMenuBar::setVisible(bool visible) -
1021{ -
1022#if defined(Q_OS_MAC) || defined(Q_OS_WINCE) -
1023 if (isNativeMenuBar()) { -
1024 if (!visible) -
1025 QWidget::setVisible(false); -
1026 return; -
1027 } -
1028#endif -
1029 QWidget::setVisible(visible);
executed (the execution status of this line is deduced): QWidget::setVisible(visible);
-
1030}
executed: }
Execution Count:57
57
1031 -
1032/*! -
1033 \reimp -
1034*/ -
1035void QMenuBar::mousePressEvent(QMouseEvent *e) -
1036{ -
1037 Q_D(QMenuBar);
executed (the execution status of this line is deduced): QMenuBarPrivate * const d = d_func();
-
1038 if(e->button() != Qt::LeftButton)
partially evaluated: e->button() != Qt::LeftButton
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
1039 return;
never executed: return;
0
1040 -
1041 d->mouseDown = true;
executed (the execution status of this line is deduced): d->mouseDown = true;
-
1042 -
1043 QAction *action = d->actionAt(e->pos());
executed (the execution status of this line is deduced): QAction *action = d->actionAt(e->pos());
-
1044 if (!action || !d->isVisible(action)) {
partially evaluated: !action
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
partially evaluated: !d->isVisible(action)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
1045 d->setCurrentAction(0);
never executed (the execution status of this line is deduced): d->setCurrentAction(0);
-
1046#ifndef QT_NO_WHATSTHIS -
1047 if (QWhatsThis::inWhatsThisMode())
never evaluated: QWhatsThis::inWhatsThisMode()
0
1048 QWhatsThis::showText(e->globalPos(), d->whatsThis, this);
never executed: QWhatsThis::showText(e->globalPos(), d->whatsThis, this);
0
1049#endif -
1050 return;
never executed: return;
0
1051 } -
1052 -
1053 if(d->currentAction == action && d->popupState) {
partially evaluated: d->currentAction == action
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
never evaluated: d->popupState
0-4
1054 if(QMenu *menu = d->activeMenu) {
never evaluated: QMenu *menu = d->activeMenu
0
1055 d->activeMenu = 0;
never executed (the execution status of this line is deduced): d->activeMenu = 0;
-
1056 menu->hide();
never executed (the execution status of this line is deduced): menu->hide();
-
1057 }
never executed: }
0
1058 } else {
never executed: }
0
1059 d->setCurrentAction(action, true);
executed (the execution status of this line is deduced): d->setCurrentAction(action, true);
-
1060 }
executed: }
Execution Count:4
4
1061} -
1062 -
1063/*! -
1064 \reimp -
1065*/ -
1066void QMenuBar::mouseReleaseEvent(QMouseEvent *e) -
1067{ -
1068 Q_D(QMenuBar);
executed (the execution status of this line is deduced): QMenuBarPrivate * const d = d_func();
-
1069 if(e->button() != Qt::LeftButton || !d->mouseDown)
partially evaluated: e->button() != Qt::LeftButton
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
evaluated: !d->mouseDown
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:3
0-4
1070 return;
executed: return;
Execution Count:1
1
1071 -
1072 d->mouseDown = false;
executed (the execution status of this line is deduced): d->mouseDown = false;
-
1073 QAction *action = d->actionAt(e->pos());
executed (the execution status of this line is deduced): QAction *action = d->actionAt(e->pos());
-
1074 if((d->closePopupMode && action == d->currentAction) || !action || !action->menu()) {
partially evaluated: d->closePopupMode
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
never evaluated: action == d->currentAction
partially evaluated: !action
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
evaluated: !action->menu()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2
0-3
1075 //we set the current action before activating -
1076 //so that we let the leave event set the current back to 0 -
1077 d->setCurrentAction(action, false);
executed (the execution status of this line is deduced): d->setCurrentAction(action, false);
-
1078 if(action)
partially evaluated: action
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
1079 d->activateAction(action, QAction::Trigger);
executed: d->activateAction(action, QAction::Trigger);
Execution Count:1
1
1080 }
executed: }
Execution Count:1
1
1081 d->closePopupMode = 0;
executed (the execution status of this line is deduced): d->closePopupMode = 0;
-
1082}
executed: }
Execution Count:3
3
1083 -
1084/*! -
1085 \reimp -
1086*/ -
1087void QMenuBar::keyPressEvent(QKeyEvent *e) -
1088{ -
1089 Q_D(QMenuBar);
executed (the execution status of this line is deduced): QMenuBarPrivate * const d = d_func();
-
1090 d->updateGeometries();
executed (the execution status of this line is deduced): d->updateGeometries();
-
1091 int key = e->key();
executed (the execution status of this line is deduced): int key = e->key();
-
1092 if(isRightToLeft()) { // in reverse mode open/close key for submenues are reversed
partially evaluated: isRightToLeft()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:23
0-23
1093 if(key == Qt::Key_Left)
never evaluated: key == Qt::Key_Left
0
1094 key = Qt::Key_Right;
never executed: key = Qt::Key_Right;
0
1095 else if(key == Qt::Key_Right)
never evaluated: key == Qt::Key_Right
0
1096 key = Qt::Key_Left;
never executed: key = Qt::Key_Left;
0
1097 } -
1098 if(key == Qt::Key_Tab) //means right
partially evaluated: key == Qt::Key_Tab
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:23
0-23
1099 key = Qt::Key_Right;
never executed: key = Qt::Key_Right;
0
1100 else if(key == Qt::Key_Backtab) //means left
partially evaluated: key == Qt::Key_Backtab
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:23
0-23
1101 key = Qt::Key_Left;
never executed: key = Qt::Key_Left;
0
1102 -
1103 bool key_consumed = false;
executed (the execution status of this line is deduced): bool key_consumed = false;
-
1104 switch(key) { -
1105 case Qt::Key_Up: -
1106 case Qt::Key_Down: -
1107 case Qt::Key_Enter: -
1108 case Qt::Key_Space: -
1109 case Qt::Key_Return: { -
1110 if(!style()->styleHint(QStyle::SH_MenuBar_AltKeyNavigation, 0, this) || !d->currentAction)
partially evaluated: !style()->styleHint(QStyle::SH_MenuBar_AltKeyNavigation, 0, this)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
partially evaluated: !d->currentAction
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
1111 break;
never executed: break;
0
1112 if(d->currentAction->menu()) {
partially evaluated: d->currentAction->menu()
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
1113 d->popupAction(d->currentAction, true);
executed (the execution status of this line is deduced): d->popupAction(d->currentAction, true);
-
1114 } else if(key == Qt::Key_Enter || key == Qt::Key_Return || key == Qt::Key_Space) {
executed: }
Execution Count:1
never evaluated: key == Qt::Key_Enter
never evaluated: key == Qt::Key_Return
never evaluated: key == Qt::Key_Space
0-1
1115 d->activateAction(d->currentAction, QAction::Trigger);
never executed (the execution status of this line is deduced): d->activateAction(d->currentAction, QAction::Trigger);
-
1116 d->setCurrentAction(d->currentAction, false);
never executed (the execution status of this line is deduced): d->setCurrentAction(d->currentAction, false);
-
1117 d->setKeyboardMode(false);
never executed (the execution status of this line is deduced): d->setKeyboardMode(false);
-
1118 }
never executed: }
0
1119 key_consumed = true;
executed (the execution status of this line is deduced): key_consumed = true;
-
1120 break; }
executed: break;
Execution Count:1
1
1121 -
1122 case Qt::Key_Right: -
1123 case Qt::Key_Left: { -
1124 if(d->currentAction) {
partially evaluated: d->currentAction
TRUEFALSE
yes
Evaluation Count:8
no
Evaluation Count:0
0-8
1125 int index = d->actions.indexOf(d->currentAction);
executed (the execution status of this line is deduced): int index = d->actions.indexOf(d->currentAction);
-
1126 if (QAction *nextAction = d->getNextAction(index, key == Qt::Key_Left ? -1 : +1)) {
partially evaluated: QAction *nextAction = d->getNextAction(index, key == Qt::Key_Left ? -1 : +1)
TRUEFALSE
yes
Evaluation Count:8
no
Evaluation Count:0
0-8
1127 d->setCurrentAction(nextAction, d->popupState, true);
executed (the execution status of this line is deduced): d->setCurrentAction(nextAction, d->popupState, true);
-
1128 key_consumed = true;
executed (the execution status of this line is deduced): key_consumed = true;
-
1129 }
executed: }
Execution Count:8
8
1130 }
executed: }
Execution Count:8
8
1131 break; }
executed: break;
Execution Count:8
8
1132 -
1133 case Qt::Key_Escape: -
1134 d->setCurrentAction(0);
executed (the execution status of this line is deduced): d->setCurrentAction(0);
-
1135 d->setKeyboardMode(false);
executed (the execution status of this line is deduced): d->setKeyboardMode(false);
-
1136 key_consumed = true;
executed (the execution status of this line is deduced): key_consumed = true;
-
1137 break;
executed: break;
Execution Count:1
1
1138 -
1139 default: -
1140 key_consumed = false;
executed (the execution status of this line is deduced): key_consumed = false;
-
1141 }
executed: }
Execution Count:13
13
1142 -
1143 if(!key_consumed &&
evaluated: !key_consumed
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:10
10-13
1144 (!e->modifiers() ||
evaluated: !e->modifiers()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:12
1-12
1145 (e->modifiers()&(Qt::MetaModifier|Qt::AltModifier))) && e->text().length()==1 && !d->popupState) {
evaluated: (e->modifiers()&(Qt::MetaModifier|Qt::AltModifier))
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:6
evaluated: e->text().length()==1
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:6
partially evaluated: !d->popupState
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-6
1146 int clashCount = 0;
never executed (the execution status of this line is deduced): int clashCount = 0;
-
1147 QAction *first = 0, *currentSelected = 0, *firstAfterCurrent = 0;
never executed (the execution status of this line is deduced): QAction *first = 0, *currentSelected = 0, *firstAfterCurrent = 0;
-
1148 { -
1149 QChar c = e->text()[0].toUpper();
never executed (the execution status of this line is deduced): QChar c = e->text()[0].toUpper();
-
1150 for(int i = 0; i < d->actions.size(); ++i) {
never evaluated: i < d->actions.size()
0
1151 if (d->actionRects.at(i).isNull())
never evaluated: d->actionRects.at(i).isNull()
0
1152 continue;
never executed: continue;
0
1153 QAction *act = d->actions.at(i);
never executed (the execution status of this line is deduced): QAction *act = d->actions.at(i);
-
1154 QString s = act->text();
never executed (the execution status of this line is deduced): QString s = act->text();
-
1155 if(!s.isEmpty()) {
never evaluated: !s.isEmpty()
0
1156 int ampersand = s.indexOf(QLatin1Char('&'));
never executed (the execution status of this line is deduced): int ampersand = s.indexOf(QLatin1Char('&'));
-
1157 if(ampersand >= 0) {
never evaluated: ampersand >= 0
0
1158 if(s[ampersand+1].toUpper() == c) {
never evaluated: s[ampersand+1].toUpper() == c
0
1159 clashCount++;
never executed (the execution status of this line is deduced): clashCount++;
-
1160 if(!first)
never evaluated: !first
0
1161 first = act;
never executed: first = act;
0
1162 if(act == d->currentAction)
never evaluated: act == d->currentAction
0
1163 currentSelected = act;
never executed: currentSelected = act;
0
1164 else if (!firstAfterCurrent && currentSelected)
never evaluated: !firstAfterCurrent
never evaluated: currentSelected
0
1165 firstAfterCurrent = act;
never executed: firstAfterCurrent = act;
0
1166 } -
1167 }
never executed: }
0
1168 }
never executed: }
0
1169 }
never executed: }
0
1170 } -
1171 QAction *next_action = 0;
never executed (the execution status of this line is deduced): QAction *next_action = 0;
-
1172 if(clashCount >= 1) {
never evaluated: clashCount >= 1
0
1173 if(clashCount == 1 || !d->currentAction || (currentSelected && !firstAfterCurrent))
never evaluated: clashCount == 1
never evaluated: !d->currentAction
never evaluated: currentSelected
never evaluated: !firstAfterCurrent
0
1174 next_action = first;
never executed: next_action = first;
0
1175 else -
1176 next_action = firstAfterCurrent;
never executed: next_action = firstAfterCurrent;
0
1177 } -
1178 if(next_action) {
never evaluated: next_action
0
1179 key_consumed = true;
never executed (the execution status of this line is deduced): key_consumed = true;
-
1180 d->setCurrentAction(next_action, true, true);
never executed (the execution status of this line is deduced): d->setCurrentAction(next_action, true, true);
-
1181 }
never executed: }
0
1182 }
never executed: }
0
1183 if(key_consumed)
evaluated: key_consumed
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:13
10-13
1184 e->accept();
executed: e->accept();
Execution Count:10
10
1185 else -
1186 e->ignore();
executed: e->ignore();
Execution Count:13
13
1187} -
1188 -
1189/*! -
1190 \reimp -
1191*/ -
1192void QMenuBar::mouseMoveEvent(QMouseEvent *e) -
1193{ -
1194 Q_D(QMenuBar);
executed (the execution status of this line is deduced): QMenuBarPrivate * const d = d_func();
-
1195 if (!(e->buttons() & Qt::LeftButton))
partially evaluated: !(e->buttons() & Qt::LeftButton)
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
1196 d->mouseDown = false;
executed: d->mouseDown = false;
Execution Count:1
1
1197 bool popupState = d->popupState || d->mouseDown;
partially evaluated: d->popupState
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
never evaluated: d->mouseDown
0-1
1198 QAction *action = d->actionAt(e->pos());
executed (the execution status of this line is deduced): QAction *action = d->actionAt(e->pos());
-
1199 if ((action && d->isVisible(action)) || !popupState)
partially evaluated: action
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
partially evaluated: d->isVisible(action)
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
never evaluated: !popupState
0-1
1200 d->setCurrentAction(action, popupState);
executed: d->setCurrentAction(action, popupState);
Execution Count:1
1
1201}
executed: }
Execution Count:1
1
1202 -
1203/*! -
1204 \reimp -
1205*/ -
1206void QMenuBar::leaveEvent(QEvent *) -
1207{ -
1208 Q_D(QMenuBar);
never executed (the execution status of this line is deduced): QMenuBarPrivate * const d = d_func();
-
1209 if((!hasFocus() && !d->popupState) ||
never evaluated: !hasFocus()
never evaluated: !d->popupState
0
1210 (d->currentAction && d->currentAction->menu() == 0))
never evaluated: d->currentAction
never evaluated: d->currentAction->menu() == 0
0
1211 d->setCurrentAction(0);
never executed: d->setCurrentAction(0);
0
1212}
never executed: }
0
1213 -
1214QPlatformMenu *getPlatformMenu(QAction *action) -
1215{ -
1216 if (!action || !action->menu())
never evaluated: !action
never evaluated: !action->menu()
0
1217 return 0;
never executed: return 0;
0
1218 -
1219 return action->menu()->platformMenu();
never executed: return action->menu()->platformMenu();
0
1220} -
1221 -
1222/*! -
1223 \reimp -
1224*/ -
1225void QMenuBar::actionEvent(QActionEvent *e) -
1226{ -
1227 Q_D(QMenuBar);
executed (the execution status of this line is deduced): QMenuBarPrivate * const d = d_func();
-
1228 d->itemsDirty = true;
executed (the execution status of this line is deduced): d->itemsDirty = true;
-
1229 -
1230 if (d->platformMenuBar) {
partially evaluated: d->platformMenuBar
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:185
0-185
1231#if !defined(Q_OS_WINCE) -
1232 QPlatformMenuBar *nativeMenuBar = d->platformMenuBar;
never executed (the execution status of this line is deduced): QPlatformMenuBar *nativeMenuBar = d->platformMenuBar;
-
1233#else -
1234 QMenuBarPrivate::QWceMenuBarPrivate *nativeMenuBar = d->wce_menubar; -
1235#endif -
1236 if (!nativeMenuBar)
never evaluated: !nativeMenuBar
0
1237 return;
never executed: return;
0
1238 -
1239 if (e->type() == QEvent::ActionAdded) {
never evaluated: e->type() == QEvent::ActionAdded
0
1240 QPlatformMenu *menu = getPlatformMenu(e->action());
never executed (the execution status of this line is deduced): QPlatformMenu *menu = getPlatformMenu(e->action());
-
1241 if (menu) {
never evaluated: menu
0
1242 QPlatformMenu* beforeMenu = NULL;
never executed (the execution status of this line is deduced): QPlatformMenu* beforeMenu = __null;
-
1243 for (int beforeIndex = d->indexOf(e->action()) + 1;
never executed (the execution status of this line is deduced): for (int beforeIndex = d->indexOf(e->action()) + 1;
-
1244 !beforeMenu && (beforeIndex < actions().size());
never evaluated: !beforeMenu
never evaluated: (beforeIndex < actions().size())
0
1245 ++beforeIndex)
never executed (the execution status of this line is deduced): ++beforeIndex)
-
1246 { -
1247 beforeMenu = getPlatformMenu(actions().at(beforeIndex));
never executed (the execution status of this line is deduced): beforeMenu = getPlatformMenu(actions().at(beforeIndex));
-
1248 }
never executed: }
0
1249 -
1250 menu->setTag(reinterpret_cast<quintptr>(e->action()));
never executed (the execution status of this line is deduced): menu->setTag(reinterpret_cast<quintptr>(e->action()));
-
1251 menu->setText(e->action()->text());
never executed (the execution status of this line is deduced): menu->setText(e->action()->text());
-
1252 d->platformMenuBar->insertMenu(menu, beforeMenu);
never executed (the execution status of this line is deduced): d->platformMenuBar->insertMenu(menu, beforeMenu);
-
1253 }
never executed: }
0
1254 } else if (e->type() == QEvent::ActionRemoved) {
never executed: }
never evaluated: e->type() == QEvent::ActionRemoved
0
1255 QPlatformMenu *menu = getPlatformMenu(e->action());
never executed (the execution status of this line is deduced): QPlatformMenu *menu = getPlatformMenu(e->action());
-
1256 if (menu)
never evaluated: menu
0
1257 d->platformMenuBar->removeMenu(menu);
never executed: d->platformMenuBar->removeMenu(menu);
0
1258 } else if (e->type() == QEvent::ActionChanged) {
never executed: }
never evaluated: e->type() == QEvent::ActionChanged
0
1259 QPlatformMenu* cur = d->platformMenuBar->menuForTag(reinterpret_cast<quintptr>(e->action()));
never executed (the execution status of this line is deduced): QPlatformMenu* cur = d->platformMenuBar->menuForTag(reinterpret_cast<quintptr>(e->action()));
-
1260 QPlatformMenu *menu = getPlatformMenu(e->action());
never executed (the execution status of this line is deduced): QPlatformMenu *menu = getPlatformMenu(e->action());
-
1261 -
1262 // the menu associated with the action can change, need to -
1263 // remove and/or insert the new platform menu -
1264 if (menu != cur) {
never evaluated: menu != cur
0
1265 if (cur)
never evaluated: cur
0
1266 d->platformMenuBar->removeMenu(cur);
never executed: d->platformMenuBar->removeMenu(cur);
0
1267 if (menu) {
never evaluated: menu
0
1268 menu->setTag(reinterpret_cast<quintptr>(e->action()));
never executed (the execution status of this line is deduced): menu->setTag(reinterpret_cast<quintptr>(e->action()));
-
1269 -
1270 QPlatformMenu* beforeMenu = NULL;
never executed (the execution status of this line is deduced): QPlatformMenu* beforeMenu = __null;
-
1271 for (int beforeIndex = d->indexOf(e->action()) + 1;
never executed (the execution status of this line is deduced): for (int beforeIndex = d->indexOf(e->action()) + 1;
-
1272 !beforeMenu && (beforeIndex < actions().size());
never evaluated: !beforeMenu
never evaluated: (beforeIndex < actions().size())
0
1273 ++beforeIndex)
never executed (the execution status of this line is deduced): ++beforeIndex)
-
1274 { -
1275 beforeMenu = getPlatformMenu(actions().at(beforeIndex));
never executed (the execution status of this line is deduced): beforeMenu = getPlatformMenu(actions().at(beforeIndex));
-
1276 }
never executed: }
0
1277 d->platformMenuBar->insertMenu(menu, beforeMenu);
never executed (the execution status of this line is deduced): d->platformMenuBar->insertMenu(menu, beforeMenu);
-
1278 }
never executed: }
0
1279 } else if (menu) {
never executed: }
never evaluated: menu
0
1280 menu->setText(e->action()->text());
never executed (the execution status of this line is deduced): menu->setText(e->action()->text());
-
1281 menu->setVisible(e->action()->isVisible());
never executed (the execution status of this line is deduced): menu->setVisible(e->action()->isVisible());
-
1282 menu->setEnabled(e->action()->isEnabled());
never executed (the execution status of this line is deduced): menu->setEnabled(e->action()->isEnabled());
-
1283 d->platformMenuBar->syncMenu(menu);
never executed (the execution status of this line is deduced): d->platformMenuBar->syncMenu(menu);
-
1284 }
never executed: }
0
1285 } -
1286 } -
1287 -
1288 if(e->type() == QEvent::ActionAdded) {
evaluated: e->type() == QEvent::ActionAdded
TRUEFALSE
yes
Evaluation Count:97
yes
Evaluation Count:88
88-97
1289 connect(e->action(), SIGNAL(triggered()), this, SLOT(_q_actionTriggered()));
executed (the execution status of this line is deduced): connect(e->action(), "2""triggered()", this, "1""_q_actionTriggered()");
-
1290 connect(e->action(), SIGNAL(hovered()), this, SLOT(_q_actionHovered()));
executed (the execution status of this line is deduced): connect(e->action(), "2""hovered()", this, "1""_q_actionHovered()");
-
1291 } else if(e->type() == QEvent::ActionRemoved) {
executed: }
Execution Count:97
evaluated: e->type() == QEvent::ActionRemoved
TRUEFALSE
yes
Evaluation Count:76
yes
Evaluation Count:12
12-97
1292 e->action()->disconnect(this);
executed (the execution status of this line is deduced): e->action()->disconnect(this);
-
1293 }
executed: }
Execution Count:76
76
1294 if (isVisible()) {
evaluated: isVisible()
TRUEFALSE
yes
Evaluation Count:73
yes
Evaluation Count:112
73-112
1295 d->updateGeometries();
executed (the execution status of this line is deduced): d->updateGeometries();
-
1296 update();
executed (the execution status of this line is deduced): update();
-
1297 }
executed: }
Execution Count:73
73
1298}
executed: }
Execution Count:185
185
1299 -
1300/*! -
1301 \reimp -
1302*/ -
1303void QMenuBar::focusInEvent(QFocusEvent *) -
1304{ -
1305 Q_D(QMenuBar);
executed (the execution status of this line is deduced): QMenuBarPrivate * const d = d_func();
-
1306 if(d->keyboardState)
evaluated: d->keyboardState
TRUEFALSE
yes
Evaluation Count:21
yes
Evaluation Count:10
10-21
1307 d->focusFirstAction();
executed: d->focusFirstAction();
Execution Count:21
21
1308}
executed: }
Execution Count:31
31
1309 -
1310/*! -
1311 \reimp -
1312*/ -
1313void QMenuBar::focusOutEvent(QFocusEvent *) -
1314{ -
1315 Q_D(QMenuBar);
executed (the execution status of this line is deduced): QMenuBarPrivate * const d = d_func();
-
1316 if(!d->popupState) {
evaluated: !d->popupState
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:27
6-27
1317 d->setCurrentAction(0);
executed (the execution status of this line is deduced): d->setCurrentAction(0);
-
1318 d->setKeyboardMode(false);
executed (the execution status of this line is deduced): d->setKeyboardMode(false);
-
1319 }
executed: }
Execution Count:6
6
1320}
executed: }
Execution Count:33
33
1321 -
1322/*! -
1323 \reimp -
1324 */ -
1325void QMenuBar::timerEvent (QTimerEvent *e) -
1326{ -
1327 Q_D(QMenuBar);
executed (the execution status of this line is deduced): QMenuBarPrivate * const d = d_func();
-
1328 if (e->timerId() == d->autoReleaseTimer.timerId()) {
partially evaluated: e->timerId() == d->autoReleaseTimer.timerId()
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
1329 d->autoReleaseTimer.stop();
executed (the execution status of this line is deduced): d->autoReleaseTimer.stop();
-
1330 d->setCurrentAction(0);
executed (the execution status of this line is deduced): d->setCurrentAction(0);
-
1331 }
executed: }
Execution Count:1
1
1332 QWidget::timerEvent(e);
executed (the execution status of this line is deduced): QWidget::timerEvent(e);
-
1333}
executed: }
Execution Count:1
1
1334 -
1335 -
1336void QMenuBarPrivate::handleReparent() -
1337{ -
1338 Q_Q(QMenuBar);
executed (the execution status of this line is deduced): QMenuBar * const q = q_func();
-
1339 QWidget *newParent = q->parentWidget();
executed (the execution status of this line is deduced): QWidget *newParent = q->parentWidget();
-
1340 //Note: if parent is reparented, then window may change even if parent doesn't -
1341 -
1342 // we need to install an event filter on parent, and remove the old one -
1343 -
1344 if (oldParent != newParent) {
evaluated: oldParent != newParent
TRUEFALSE
yes
Evaluation Count:18
yes
Evaluation Count:7
7-18
1345 if (oldParent)
partially evaluated: oldParent
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:18
0-18
1346 oldParent->removeEventFilter(q);
never executed: oldParent->removeEventFilter(q);
0
1347 if (newParent)
partially evaluated: newParent
TRUEFALSE
yes
Evaluation Count:18
no
Evaluation Count:0
0-18
1348 newParent->installEventFilter(q);
executed: newParent->installEventFilter(q);
Execution Count:18
18
1349 }
executed: }
Execution Count:18
18
1350 -
1351 //we also need event filter on top-level (for shortcuts) -
1352 QWidget *newWindow = newParent ? newParent->window() : 0;
evaluated: newParent
TRUEFALSE
yes
Evaluation Count:18
yes
Evaluation Count:7
7-18
1353 -
1354 if (oldWindow != newWindow) {
evaluated: oldWindow != newWindow
TRUEFALSE
yes
Evaluation Count:18
yes
Evaluation Count:7
7-18
1355 if (oldParent && oldParent != oldWindow)
partially evaluated: oldParent
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:18
never evaluated: oldParent != oldWindow
0-18
1356 oldWindow->removeEventFilter(q);
never executed: oldWindow->removeEventFilter(q);
0
1357 -
1358 if (newParent && newParent != newWindow)
partially evaluated: newParent
TRUEFALSE
yes
Evaluation Count:18
no
Evaluation Count:0
partially evaluated: newParent != newWindow
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:18
0-18
1359 newWindow->installEventFilter(q);
never executed: newWindow->installEventFilter(q);
0
1360 }
executed: }
Execution Count:18
18
1361 -
1362 oldParent = newParent;
executed (the execution status of this line is deduced): oldParent = newParent;
-
1363 oldWindow = newWindow;
executed (the execution status of this line is deduced): oldWindow = newWindow;
-
1364 -
1365 if (platformMenuBar) {
partially evaluated: platformMenuBar
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:25
0-25
1366 if (newWindow) {
never evaluated: newWindow
0
1367 // force the underlying platform window to be created, since -
1368 // the platform menubar needs it (and we have no other way to -
1369 // discover when the platform window is created) -
1370 newWindow->createWinId();
never executed (the execution status of this line is deduced): newWindow->createWinId();
-
1371 platformMenuBar->handleReparent(newWindow->windowHandle());
never executed (the execution status of this line is deduced): platformMenuBar->handleReparent(newWindow->windowHandle());
-
1372 } else {
never executed: }
0
1373 platformMenuBar->handleReparent(0);
never executed (the execution status of this line is deduced): platformMenuBar->handleReparent(0);
-
1374 }
never executed: }
0
1375 } -
1376 -
1377#ifdef Q_OS_WINCE -
1378 if (qt_wince_is_mobile() && wce_menubar) -
1379 wce_menubar->rebuild(); -
1380#endif -
1381}
executed: }
Execution Count:25
25
1382 -
1383/*! -
1384 \reimp -
1385*/ -
1386void QMenuBar::changeEvent(QEvent *e) -
1387{ -
1388 Q_D(QMenuBar);
executed (the execution status of this line is deduced): QMenuBarPrivate * const d = d_func();
-
1389 if(e->type() == QEvent::StyleChange) {
evaluated: e->type() == QEvent::StyleChange
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:65
1-65
1390 d->itemsDirty = true;
executed (the execution status of this line is deduced): d->itemsDirty = true;
-
1391 setMouseTracking(style()->styleHint(QStyle::SH_MenuBar_MouseTracking, 0, this));
executed (the execution status of this line is deduced): setMouseTracking(style()->styleHint(QStyle::SH_MenuBar_MouseTracking, 0, this));
-
1392 if(parentWidget())
partially evaluated: parentWidget()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
1393 resize(parentWidget()->width(), heightForWidth(parentWidget()->width()));
never executed: resize(parentWidget()->width(), heightForWidth(parentWidget()->width()));
0
1394 d->updateGeometries();
executed (the execution status of this line is deduced): d->updateGeometries();
-
1395 } else if (e->type() == QEvent::ParentChange) {
executed: }
Execution Count:1
evaluated: e->type() == QEvent::ParentChange
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:63
1-63
1396 d->handleReparent();
executed (the execution status of this line is deduced): d->handleReparent();
-
1397 } else if (e->type() == QEvent::FontChange
executed: }
Execution Count:2
partially evaluated: e->type() == QEvent::FontChange
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:63
0-63
1398 || e->type() == QEvent::ApplicationFontChange) {
partially evaluated: e->type() == QEvent::ApplicationFontChange
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:63
0-63
1399 d->itemsDirty = true;
never executed (the execution status of this line is deduced): d->itemsDirty = true;
-
1400 d->updateGeometries();
never executed (the execution status of this line is deduced): d->updateGeometries();
-
1401 }
never executed: }
0
1402 -
1403 QWidget::changeEvent(e);
executed (the execution status of this line is deduced): QWidget::changeEvent(e);
-
1404}
executed: }
Execution Count:66
66
1405 -
1406/*! -
1407 \reimp -
1408*/ -
1409bool QMenuBar::event(QEvent *e) -
1410{ -
1411 Q_D(QMenuBar);
executed (the execution status of this line is deduced): QMenuBarPrivate * const d = d_func();
-
1412 switch (e->type()) { -
1413 case QEvent::KeyPress: { -
1414 QKeyEvent *ke = (QKeyEvent*)e;
executed (the execution status of this line is deduced): QKeyEvent *ke = (QKeyEvent*)e;
-
1415#if 0 -
1416 if(!d->keyboardState) { //all keypresses.. -
1417 d->setCurrentAction(0); -
1418 return ; -
1419 } -
1420#endif -
1421 if(ke->key() == Qt::Key_Tab || ke->key() == Qt::Key_Backtab) {
partially evaluated: ke->key() == Qt::Key_Tab
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:23
partially evaluated: ke->key() == Qt::Key_Backtab
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:23
0-23
1422 keyPressEvent(ke);
never executed (the execution status of this line is deduced): keyPressEvent(ke);
-
1423 return true;
never executed: return true;
0
1424 } -
1425 -
1426 } break;
executed: break;
Execution Count:23
23
1427#ifndef QT_NO_SHORTCUT -
1428 case QEvent::Shortcut: { -
1429 QShortcutEvent *se = static_cast<QShortcutEvent *>(e);
executed (the execution status of this line is deduced): QShortcutEvent *se = static_cast<QShortcutEvent *>(e);
-
1430 int shortcutId = se->shortcutId();
executed (the execution status of this line is deduced): int shortcutId = se->shortcutId();
-
1431 for(int j = 0; j < d->shortcutIndexMap.size(); ++j) {
evaluated: j < d->shortcutIndexMap.size()
TRUEFALSE
yes
Evaluation Count:26
yes
Evaluation Count:12
12-26
1432 if (shortcutId == d->shortcutIndexMap.value(j))
evaluated: shortcutId == d->shortcutIndexMap.value(j)
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:14
12-14
1433 d->_q_internalShortcutActivated(j);
executed: d->_q_internalShortcutActivated(j);
Execution Count:12
12
1434 }
executed: }
Execution Count:26
26
1435 } break;
executed: break;
Execution Count:12
12
1436#endif -
1437 case QEvent::Show: -
1438 d->_q_updateLayout();
executed (the execution status of this line is deduced): d->_q_updateLayout();
-
1439 break;
executed: break;
Execution Count:35
35
1440 case QEvent::ShortcutOverride: { -
1441 QKeyEvent *kev = static_cast<QKeyEvent*>(e);
executed (the execution status of this line is deduced): QKeyEvent *kev = static_cast<QKeyEvent*>(e);
-
1442 //we only filter out escape if there is a current action -
1443 if (kev->key() == Qt::Key_Escape && d->currentAction) {
evaluated: kev->key() == Qt::Key_Escape
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:32
evaluated: d->currentAction
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1-32
1444 e->accept();
executed (the execution status of this line is deduced): e->accept();
-
1445 return true;
executed: return true;
Execution Count:1
1
1446 } -
1447 } -
1448 break;
executed: break;
Execution Count:33
33
1449 -
1450 -
1451#ifndef QT_NO_WHATSTHIS -
1452 case QEvent::QueryWhatsThis: -
1453 e->setAccepted(d->whatsThis.size());
never executed (the execution status of this line is deduced): e->setAccepted(d->whatsThis.size());
-
1454 if (QAction *action = d->actionAt(static_cast<QHelpEvent*>(e)->pos())) {
never evaluated: QAction *action = d->actionAt(static_cast<QHelpEvent*>(e)->pos())
0
1455 if (action->whatsThis().size() || action->menu())
never evaluated: action->whatsThis().size()
never evaluated: action->menu()
0
1456 e->accept();
never executed: e->accept();
0
1457 }
never executed: }
0
1458 return true;
never executed: return true;
0
1459#endif -
1460 case QEvent::LayoutDirectionChange: -
1461 d->_q_updateLayout();
executed (the execution status of this line is deduced): d->_q_updateLayout();
-
1462 break;
executed: break;
Execution Count:10
10
1463 default: -
1464 break;
executed: break;
Execution Count:1261
1261
1465 } -
1466 return QWidget::event(e);
executed: return QWidget::event(e);
Execution Count:1374
1374
1467} -
1468 -
1469/*! -
1470 \reimp -
1471*/ -
1472bool QMenuBar::eventFilter(QObject *object, QEvent *event) -
1473{ -
1474 Q_D(QMenuBar);
executed (the execution status of this line is deduced): QMenuBarPrivate * const d = d_func();
-
1475 if (object == parent() && object) {
evaluated: object == parent()
TRUEFALSE
yes
Evaluation Count:1142
yes
Evaluation Count:607
partially evaluated: object
TRUEFALSE
yes
Evaluation Count:1142
no
Evaluation Count:0
0-1142
1476 if (event->type() == QEvent::ParentChange) //GrandparentChange
partially evaluated: event->type() == QEvent::ParentChange
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1142
0-1142
1477 d->handleReparent();
never executed: d->handleReparent();
0
1478 }
executed: }
Execution Count:1142
1142
1479 if (object == d->leftWidget || object == d->rightWidget) {
evaluated: object == d->leftWidget
TRUEFALSE
yes
Evaluation Count:227
yes
Evaluation Count:1522
evaluated: object == d->rightWidget
TRUEFALSE
yes
Evaluation Count:219
yes
Evaluation Count:1303
219-1522
1480 switch (event->type()) { -
1481 case QEvent::ShowToParent: -
1482 case QEvent::HideToParent: -
1483 d->_q_updateLayout();
executed (the execution status of this line is deduced): d->_q_updateLayout();
-
1484 break;
executed: break;
Execution Count:84
84
1485 default: -
1486 break;
executed: break;
Execution Count:362
362
1487 } -
1488 }
executed: }
Execution Count:446
446
1489 -
1490 if (style()->styleHint(QStyle::SH_MenuBar_AltKeyNavigation, 0, this)) {
partially evaluated: style()->styleHint(QStyle::SH_MenuBar_AltKeyNavigation, 0, this)
TRUEFALSE
yes
Evaluation Count:1749
no
Evaluation Count:0
0-1749
1491 if (d->altPressed) {
evaluated: d->altPressed
TRUEFALSE
yes
Evaluation Count:267
yes
Evaluation Count:1482
267-1482
1492 switch (event->type()) { -
1493 case QEvent::KeyPress: -
1494 case QEvent::KeyRelease: -
1495 { -
1496 QKeyEvent *kev = static_cast<QKeyEvent*>(event);
executed (the execution status of this line is deduced): QKeyEvent *kev = static_cast<QKeyEvent*>(event);
-
1497 if (kev->key() == Qt::Key_Alt || kev->key() == Qt::Key_Meta) {
evaluated: kev->key() == Qt::Key_Alt
TRUEFALSE
yes
Evaluation Count:43
yes
Evaluation Count:3
partially evaluated: kev->key() == Qt::Key_Meta
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-43
1498 if (event->type() == QEvent::KeyPress) // Alt-press does not interest us, we have the shortcut-override event
evaluated: event->type() == QEvent::KeyPress
TRUEFALSE
yes
Evaluation Count:42
yes
Evaluation Count:1
1-42
1499 break;
executed: break;
Execution Count:42
42
1500 d->setKeyboardMode(!d->keyboardState);
executed (the execution status of this line is deduced): d->setKeyboardMode(!d->keyboardState);
-
1501 }
executed: }
Execution Count:1
1
1502 } -
1503 // fall through -
1504 case QEvent::MouseButtonPress:
code before this statement executed: case QEvent::MouseButtonPress:
Execution Count:4
4
1505 case QEvent::MouseButtonRelease: -
1506 case QEvent::MouseMove: -
1507 case QEvent::FocusIn: -
1508 case QEvent::FocusOut: -
1509 case QEvent::ActivationChange: -
1510 d->altPressed = false;
executed (the execution status of this line is deduced): d->altPressed = false;
-
1511 qApp->removeEventFilter(this);
executed (the execution status of this line is deduced): (static_cast<QApplication *>(QCoreApplication::instance()))->removeEventFilter(this);
-
1512 break;
executed: break;
Execution Count:19
19
1513 default: -
1514 break;
executed: break;
Execution Count:206
206
1515 } -
1516 } else if (isVisible()) {
executed: }
Execution Count:267
evaluated: isVisible()
TRUEFALSE
yes
Evaluation Count:1238
yes
Evaluation Count:244
244-1238
1517 if (event->type() == QEvent::ShortcutOverride) {
evaluated: event->type() == QEvent::ShortcutOverride
TRUEFALSE
yes
Evaluation Count:43
yes
Evaluation Count:1195
43-1195
1518 QKeyEvent *kev = static_cast<QKeyEvent*>(event);
executed (the execution status of this line is deduced): QKeyEvent *kev = static_cast<QKeyEvent*>(event);
-
1519 if ((kev->key() == Qt::Key_Alt || kev->key() == Qt::Key_Meta)
evaluated: kev->key() == Qt::Key_Alt
TRUEFALSE
yes
Evaluation Count:18
yes
Evaluation Count:25
partially evaluated: kev->key() == Qt::Key_Meta
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:25
0-25
1520 && kev->modifiers() == Qt::AltModifier) {
partially evaluated: kev->modifiers() == Qt::AltModifier
TRUEFALSE
yes
Evaluation Count:18
no
Evaluation Count:0
0-18
1521 d->altPressed = true;
executed (the execution status of this line is deduced): d->altPressed = true;
-
1522 qApp->installEventFilter(this);
executed (the execution status of this line is deduced): (static_cast<QApplication *>(QCoreApplication::instance()))->installEventFilter(this);
-
1523 }
executed: }
Execution Count:18
18
1524 }
executed: }
Execution Count:43
43
1525 }
executed: }
Execution Count:1238
1238
1526 } -
1527 -
1528 return false;
executed: return false;
Execution Count:1749
1749
1529} -
1530 -
1531/*! -
1532 Returns the QAction at \a pt. Returns 0 if there is no action at \a pt or if -
1533the location has a separator. -
1534 -
1535 \sa addAction(), addSeparator() -
1536*/ -
1537QAction *QMenuBar::actionAt(const QPoint &pt) const -
1538{ -
1539 Q_D(const QMenuBar);
never executed (the execution status of this line is deduced): const QMenuBarPrivate * const d = d_func();
-
1540 return d->actionAt(pt);
never executed: return d->actionAt(pt);
0
1541} -
1542 -
1543/*! -
1544 Returns the geometry of action \a act as a QRect. -
1545 -
1546 \sa actionAt() -
1547*/ -
1548QRect QMenuBar::actionGeometry(QAction *act) const -
1549{ -
1550 Q_D(const QMenuBar);
executed (the execution status of this line is deduced): const QMenuBarPrivate * const d = d_func();
-
1551 return d->actionRect(act);
executed: return d->actionRect(act);
Execution Count:21
21
1552} -
1553 -
1554/*! -
1555 \reimp -
1556*/ -
1557QSize QMenuBar::minimumSizeHint() const -
1558{ -
1559 Q_D(const QMenuBar);
never executed (the execution status of this line is deduced): const QMenuBarPrivate * const d = d_func();
-
1560#if defined(Q_OS_MAC) || defined(Q_OS_WINCE) -
1561 const bool as_gui_menubar = !isNativeMenuBar(); -
1562#else -
1563 const bool as_gui_menubar = true;
never executed (the execution status of this line is deduced): const bool as_gui_menubar = true;
-
1564#endif -
1565 -
1566 ensurePolished();
never executed (the execution status of this line is deduced): ensurePolished();
-
1567 QSize ret(0, 0);
never executed (the execution status of this line is deduced): QSize ret(0, 0);
-
1568 const_cast<QMenuBarPrivate*>(d)->updateGeometries();
never executed (the execution status of this line is deduced): const_cast<QMenuBarPrivate*>(d)->updateGeometries();
-
1569 const int hmargin = style()->pixelMetric(QStyle::PM_MenuBarHMargin, 0, this);
never executed (the execution status of this line is deduced): const int hmargin = style()->pixelMetric(QStyle::PM_MenuBarHMargin, 0, this);
-
1570 const int vmargin = style()->pixelMetric(QStyle::PM_MenuBarVMargin, 0, this);
never executed (the execution status of this line is deduced): const int vmargin = style()->pixelMetric(QStyle::PM_MenuBarVMargin, 0, this);
-
1571 int fw = style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, this);
never executed (the execution status of this line is deduced): int fw = style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, this);
-
1572 int spaceBelowMenuBar = style()->styleHint(QStyle::SH_MainWindow_SpaceBelowMenuBar, 0, this);
never executed (the execution status of this line is deduced): int spaceBelowMenuBar = style()->styleHint(QStyle::SH_MainWindow_SpaceBelowMenuBar, 0, this);
-
1573 if(as_gui_menubar) {
never evaluated: as_gui_menubar
0
1574 int w = parentWidget() ? parentWidget()->width() : QApplication::desktop()->width();
never evaluated: parentWidget()
0
1575 d->calcActionRects(w - (2 * fw), 0);
never executed (the execution status of this line is deduced): d->calcActionRects(w - (2 * fw), 0);
-
1576 for (int i = 0; ret.isNull() && i < d->actions.count(); ++i)
never evaluated: ret.isNull()
never evaluated: i < d->actions.count()
0
1577 ret = d->actionRects.at(i).size();
never executed: ret = d->actionRects.at(i).size();
0
1578 if (!d->extension->isHidden())
never evaluated: !d->extension->isHidden()
0
1579 ret += QSize(d->extension->sizeHint().width(), 0);
never executed: ret += QSize(d->extension->sizeHint().width(), 0);
0
1580 ret += QSize(2*fw + hmargin, 2*fw + vmargin);
never executed (the execution status of this line is deduced): ret += QSize(2*fw + hmargin, 2*fw + vmargin);
-
1581 }
never executed: }
0
1582 int margin = 2*vmargin + 2*fw + spaceBelowMenuBar;
never executed (the execution status of this line is deduced): int margin = 2*vmargin + 2*fw + spaceBelowMenuBar;
-
1583 if(d->leftWidget) {
never evaluated: d->leftWidget
0
1584 QSize sz = d->leftWidget->minimumSizeHint();
never executed (the execution status of this line is deduced): QSize sz = d->leftWidget->minimumSizeHint();
-
1585 ret.setWidth(ret.width() + sz.width());
never executed (the execution status of this line is deduced): ret.setWidth(ret.width() + sz.width());
-
1586 if(sz.height() + margin > ret.height())
never evaluated: sz.height() + margin > ret.height()
0
1587 ret.setHeight(sz.height() + margin);
never executed: ret.setHeight(sz.height() + margin);
0
1588 }
never executed: }
0
1589 if(d->rightWidget) {
never evaluated: d->rightWidget
0
1590 QSize sz = d->rightWidget->minimumSizeHint();
never executed (the execution status of this line is deduced): QSize sz = d->rightWidget->minimumSizeHint();
-
1591 ret.setWidth(ret.width() + sz.width());
never executed (the execution status of this line is deduced): ret.setWidth(ret.width() + sz.width());
-
1592 if(sz.height() + margin > ret.height())
never evaluated: sz.height() + margin > ret.height()
0
1593 ret.setHeight(sz.height() + margin);
never executed: ret.setHeight(sz.height() + margin);
0
1594 }
never executed: }
0
1595 if(as_gui_menubar) {
never evaluated: as_gui_menubar
0
1596 QStyleOptionMenuItem opt;
never executed (the execution status of this line is deduced): QStyleOptionMenuItem opt;
-
1597 opt.rect = rect();
never executed (the execution status of this line is deduced): opt.rect = rect();
-
1598 opt.menuRect = rect();
never executed (the execution status of this line is deduced): opt.menuRect = rect();
-
1599 opt.state = QStyle::State_None;
never executed (the execution status of this line is deduced): opt.state = QStyle::State_None;
-
1600 opt.menuItemType = QStyleOptionMenuItem::Normal;
never executed (the execution status of this line is deduced): opt.menuItemType = QStyleOptionMenuItem::Normal;
-
1601 opt.checkType = QStyleOptionMenuItem::NotCheckable;
never executed (the execution status of this line is deduced): opt.checkType = QStyleOptionMenuItem::NotCheckable;
-
1602 opt.palette = palette();
never executed (the execution status of this line is deduced): opt.palette = palette();
-
1603 return (style()->sizeFromContents(QStyle::CT_MenuBar, &opt,
never executed: return (style()->sizeFromContents(QStyle::CT_MenuBar, &opt, ret.expandedTo(QApplication::globalStrut()), this));
0
1604 ret.expandedTo(QApplication::globalStrut()),
never executed: return (style()->sizeFromContents(QStyle::CT_MenuBar, &opt, ret.expandedTo(QApplication::globalStrut()), this));
0
1605 this));
never executed: return (style()->sizeFromContents(QStyle::CT_MenuBar, &opt, ret.expandedTo(QApplication::globalStrut()), this));
0
1606 } -
1607 return ret;
never executed: return ret;
0
1608} -
1609 -
1610/*! -
1611 \reimp -
1612*/ -
1613QSize QMenuBar::sizeHint() const -
1614{ -
1615 Q_D(const QMenuBar);
executed (the execution status of this line is deduced): const QMenuBarPrivate * const d = d_func();
-
1616#if defined(Q_OS_MAC) || defined(Q_OS_WINCE) -
1617 const bool as_gui_menubar = !isNativeMenuBar(); -
1618#else -
1619 const bool as_gui_menubar = true;
executed (the execution status of this line is deduced): const bool as_gui_menubar = true;
-
1620#endif -
1621 -
1622 -
1623 ensurePolished();
executed (the execution status of this line is deduced): ensurePolished();
-
1624 QSize ret(0, 0);
executed (the execution status of this line is deduced): QSize ret(0, 0);
-
1625 const_cast<QMenuBarPrivate*>(d)->updateGeometries();
executed (the execution status of this line is deduced): const_cast<QMenuBarPrivate*>(d)->updateGeometries();
-
1626 const int hmargin = style()->pixelMetric(QStyle::PM_MenuBarHMargin, 0, this);
executed (the execution status of this line is deduced): const int hmargin = style()->pixelMetric(QStyle::PM_MenuBarHMargin, 0, this);
-
1627 const int vmargin = style()->pixelMetric(QStyle::PM_MenuBarVMargin, 0, this);
executed (the execution status of this line is deduced): const int vmargin = style()->pixelMetric(QStyle::PM_MenuBarVMargin, 0, this);
-
1628 int fw = style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, this);
executed (the execution status of this line is deduced): int fw = style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, this);
-
1629 int spaceBelowMenuBar = style()->styleHint(QStyle::SH_MainWindow_SpaceBelowMenuBar, 0, this);
executed (the execution status of this line is deduced): int spaceBelowMenuBar = style()->styleHint(QStyle::SH_MainWindow_SpaceBelowMenuBar, 0, this);
-
1630 if(as_gui_menubar) {
partially evaluated: as_gui_menubar
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
1631 const int w = parentWidget() ? parentWidget()->width() : QApplication::desktop()->width();
partially evaluated: parentWidget()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
1632 d->calcActionRects(w - (2 * fw), 0);
executed (the execution status of this line is deduced): d->calcActionRects(w - (2 * fw), 0);
-
1633 for (int i = 0; i < d->actionRects.count(); ++i) {
evaluated: i < d->actionRects.count()
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:4
4-13
1634 const QRect &actionRect = d->actionRects.at(i);
executed (the execution status of this line is deduced): const QRect &actionRect = d->actionRects.at(i);
-
1635 ret = ret.expandedTo(QSize(actionRect.x() + actionRect.width(), actionRect.y() + actionRect.height()));
executed (the execution status of this line is deduced): ret = ret.expandedTo(QSize(actionRect.x() + actionRect.width(), actionRect.y() + actionRect.height()));
-
1636 }
executed: }
Execution Count:13
13
1637 //the action geometries already contain the top and left -
1638 //margins. So we only need to add those from right and bottom. -
1639 ret += QSize(fw + hmargin, fw + vmargin);
executed (the execution status of this line is deduced): ret += QSize(fw + hmargin, fw + vmargin);
-
1640 }
executed: }
Execution Count:4
4
1641 int margin = 2*vmargin + 2*fw + spaceBelowMenuBar;
executed (the execution status of this line is deduced): int margin = 2*vmargin + 2*fw + spaceBelowMenuBar;
-
1642 if(d->leftWidget) {
partially evaluated: d->leftWidget
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
1643 QSize sz = d->leftWidget->sizeHint();
never executed (the execution status of this line is deduced): QSize sz = d->leftWidget->sizeHint();
-
1644 ret.setWidth(ret.width() + sz.width());
never executed (the execution status of this line is deduced): ret.setWidth(ret.width() + sz.width());
-
1645 if(sz.height() + margin > ret.height())
never evaluated: sz.height() + margin > ret.height()
0
1646 ret.setHeight(sz.height() + margin);
never executed: ret.setHeight(sz.height() + margin);
0
1647 }
never executed: }
0
1648 if(d->rightWidget) {
partially evaluated: d->rightWidget
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
1649 QSize sz = d->rightWidget->sizeHint();
never executed (the execution status of this line is deduced): QSize sz = d->rightWidget->sizeHint();
-
1650 ret.setWidth(ret.width() + sz.width());
never executed (the execution status of this line is deduced): ret.setWidth(ret.width() + sz.width());
-
1651 if(sz.height() + margin > ret.height())
never evaluated: sz.height() + margin > ret.height()
0
1652 ret.setHeight(sz.height() + margin);
never executed: ret.setHeight(sz.height() + margin);
0
1653 }
never executed: }
0
1654 if(as_gui_menubar) {
partially evaluated: as_gui_menubar
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
1655 QStyleOptionMenuItem opt;
executed (the execution status of this line is deduced): QStyleOptionMenuItem opt;
-
1656 opt.rect = rect();
executed (the execution status of this line is deduced): opt.rect = rect();
-
1657 opt.menuRect = rect();
executed (the execution status of this line is deduced): opt.menuRect = rect();
-
1658 opt.state = QStyle::State_None;
executed (the execution status of this line is deduced): opt.state = QStyle::State_None;
-
1659 opt.menuItemType = QStyleOptionMenuItem::Normal;
executed (the execution status of this line is deduced): opt.menuItemType = QStyleOptionMenuItem::Normal;
-
1660 opt.checkType = QStyleOptionMenuItem::NotCheckable;
executed (the execution status of this line is deduced): opt.checkType = QStyleOptionMenuItem::NotCheckable;
-
1661 opt.palette = palette();
executed (the execution status of this line is deduced): opt.palette = palette();
-
1662 return (style()->sizeFromContents(QStyle::CT_MenuBar, &opt,
executed: return (style()->sizeFromContents(QStyle::CT_MenuBar, &opt, ret.expandedTo(QApplication::globalStrut()), this));
Execution Count:4
4
1663 ret.expandedTo(QApplication::globalStrut()),
executed: return (style()->sizeFromContents(QStyle::CT_MenuBar, &opt, ret.expandedTo(QApplication::globalStrut()), this));
Execution Count:4
4
1664 this));
executed: return (style()->sizeFromContents(QStyle::CT_MenuBar, &opt, ret.expandedTo(QApplication::globalStrut()), this));
Execution Count:4
4
1665 } -
1666 return ret;
never executed: return ret;
0
1667} -
1668 -
1669/*! -
1670 \reimp -
1671*/ -
1672int QMenuBar::heightForWidth(int) const -
1673{ -
1674 Q_D(const QMenuBar);
executed (the execution status of this line is deduced): const QMenuBarPrivate * const d = d_func();
-
1675#if defined(Q_OS_MAC) || defined(Q_OS_WINCE) -
1676 const bool as_gui_menubar = !isNativeMenuBar(); -
1677#else -
1678 const bool as_gui_menubar = true;
executed (the execution status of this line is deduced): const bool as_gui_menubar = true;
-
1679#endif -
1680 -
1681 const_cast<QMenuBarPrivate*>(d)->updateGeometries();
executed (the execution status of this line is deduced): const_cast<QMenuBarPrivate*>(d)->updateGeometries();
-
1682 int height = 0;
executed (the execution status of this line is deduced): int height = 0;
-
1683 const int vmargin = style()->pixelMetric(QStyle::PM_MenuBarVMargin, 0, this);
executed (the execution status of this line is deduced): const int vmargin = style()->pixelMetric(QStyle::PM_MenuBarVMargin, 0, this);
-
1684 int fw = style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, this);
executed (the execution status of this line is deduced): int fw = style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, this);
-
1685 int spaceBelowMenuBar = style()->styleHint(QStyle::SH_MainWindow_SpaceBelowMenuBar, 0, this);
executed (the execution status of this line is deduced): int spaceBelowMenuBar = style()->styleHint(QStyle::SH_MainWindow_SpaceBelowMenuBar, 0, this);
-
1686 if(as_gui_menubar) {
partially evaluated: as_gui_menubar
TRUEFALSE
yes
Evaluation Count:153
no
Evaluation Count:0
0-153
1687 for (int i = 0; i < d->actionRects.count(); ++i)
evaluated: i < d->actionRects.count()
TRUEFALSE
yes
Evaluation Count:91
yes
Evaluation Count:153
91-153
1688 height = qMax(height, d->actionRects.at(i).height());
executed: height = qMax(height, d->actionRects.at(i).height());
Execution Count:91
91
1689 if (height) //there is at least one non-null item
evaluated: height
TRUEFALSE
yes
Evaluation Count:38
yes
Evaluation Count:115
38-115
1690 height += spaceBelowMenuBar;
executed: height += spaceBelowMenuBar;
Execution Count:38
38
1691 height += 2*fw;
executed (the execution status of this line is deduced): height += 2*fw;
-
1692 height += 2*vmargin;
executed (the execution status of this line is deduced): height += 2*vmargin;
-
1693 }
executed: }
Execution Count:153
153
1694 int margin = 2*vmargin + 2*fw + spaceBelowMenuBar;
executed (the execution status of this line is deduced): int margin = 2*vmargin + 2*fw + spaceBelowMenuBar;
-
1695 if(d->leftWidget)
evaluated: d->leftWidget
TRUEFALSE
yes
Evaluation Count:63
yes
Evaluation Count:90
63-90
1696 height = qMax(d->leftWidget->sizeHint().height() + margin, height);
executed: height = qMax(d->leftWidget->sizeHint().height() + margin, height);
Execution Count:63
63
1697 if(d->rightWidget)
evaluated: d->rightWidget
TRUEFALSE
yes
Evaluation Count:63
yes
Evaluation Count:90
63-90
1698 height = qMax(d->rightWidget->sizeHint().height() + margin, height);
executed: height = qMax(d->rightWidget->sizeHint().height() + margin, height);
Execution Count:63
63
1699 if(as_gui_menubar) {
partially evaluated: as_gui_menubar
TRUEFALSE
yes
Evaluation Count:153
no
Evaluation Count:0
0-153
1700 QStyleOptionMenuItem opt;
executed (the execution status of this line is deduced): QStyleOptionMenuItem opt;
-
1701 opt.init(this);
executed (the execution status of this line is deduced): opt.init(this);
-
1702 opt.menuRect = rect();
executed (the execution status of this line is deduced): opt.menuRect = rect();
-
1703 opt.state = QStyle::State_None;
executed (the execution status of this line is deduced): opt.state = QStyle::State_None;
-
1704 opt.menuItemType = QStyleOptionMenuItem::Normal;
executed (the execution status of this line is deduced): opt.menuItemType = QStyleOptionMenuItem::Normal;
-
1705 opt.checkType = QStyleOptionMenuItem::NotCheckable;
executed (the execution status of this line is deduced): opt.checkType = QStyleOptionMenuItem::NotCheckable;
-
1706 return style()->sizeFromContents(QStyle::CT_MenuBar, &opt, QSize(0, height), this).height(); //not pretty..
executed: return style()->sizeFromContents(QStyle::CT_MenuBar, &opt, QSize(0, height), this).height();
Execution Count:153
153
1707 } -
1708 return height;
never executed: return height;
0
1709} -
1710 -
1711/*! -
1712 \internal -
1713*/ -
1714void QMenuBarPrivate::_q_internalShortcutActivated(int id) -
1715{ -
1716 Q_Q(QMenuBar);
executed (the execution status of this line is deduced): QMenuBar * const q = q_func();
-
1717 QAction *act = actions.at(id);
executed (the execution status of this line is deduced): QAction *act = actions.at(id);
-
1718 setCurrentAction(act, true, true);
executed (the execution status of this line is deduced): setCurrentAction(act, true, true);
-
1719 if (act && !act->menu()) {
partially evaluated: act
TRUEFALSE
yes
Evaluation Count:12
no
Evaluation Count:0
evaluated: !act->menu()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:11
0-12
1720 activateAction(act, QAction::Trigger);
executed (the execution status of this line is deduced): activateAction(act, QAction::Trigger);
-
1721 //100 is the same as the default value in QPushButton::animateClick -
1722 autoReleaseTimer.start(100, q);
executed (the execution status of this line is deduced): autoReleaseTimer.start(100, q);
-
1723 } else if (act && q->style()->styleHint(QStyle::SH_MenuBar_AltKeyNavigation, 0, q)) {
executed: }
Execution Count:1
partially evaluated: act
TRUEFALSE
yes
Evaluation Count:11
no
Evaluation Count:0
partially evaluated: q->style()->styleHint(QStyle::SH_MenuBar_AltKeyNavigation, 0, q)
TRUEFALSE
yes
Evaluation Count:11
no
Evaluation Count:0
0-11
1724 // When we open a menu using a shortcut, we should end up in keyboard state -
1725 setKeyboardMode(true);
executed (the execution status of this line is deduced): setKeyboardMode(true);
-
1726 }
executed: }
Execution Count:11
11
1727} -
1728 -
1729void QMenuBarPrivate::_q_updateLayout() -
1730{ -
1731 Q_Q(QMenuBar);
executed (the execution status of this line is deduced): QMenuBar * const q = q_func();
-
1732 itemsDirty = true;
executed (the execution status of this line is deduced): itemsDirty = true;
-
1733 if (q->isVisible()) {
evaluated: q->isVisible()
TRUEFALSE
yes
Evaluation Count:231
yes
Evaluation Count:22
22-231
1734 updateGeometries();
executed (the execution status of this line is deduced): updateGeometries();
-
1735 q->update();
executed (the execution status of this line is deduced): q->update();
-
1736 }
executed: }
Execution Count:231
231
1737}
executed: }
Execution Count:253
253
1738 -
1739/*! -
1740 \fn void QMenuBar::setCornerWidget(QWidget *widget, Qt::Corner corner) -
1741 -
1742 This sets the given \a widget to be shown directly on the left of the first -
1743 menu item, or on the right of the last menu item, depending on \a corner. -
1744 -
1745 The menu bar takes ownership of \a widget, reparenting it into the menu bar. -
1746 However, if the \a corner already contains a widget, this previous widget -
1747 will no longer be managed and will still be a visible child of the menu bar. -
1748 -
1749 \note Using a corner other than Qt::TopRightCorner or Qt::TopLeftCorner -
1750 will result in a warning. -
1751*/ -
1752void QMenuBar::setCornerWidget(QWidget *w, Qt::Corner corner) -
1753{ -
1754 Q_D(QMenuBar);
executed (the execution status of this line is deduced): QMenuBarPrivate * const d = d_func();
-
1755 switch (corner) { -
1756 case Qt::TopLeftCorner: -
1757 if (d->leftWidget)
evaluated: d->leftWidget
TRUEFALSE
yes
Evaluation Count:29
yes
Evaluation Count:33
29-33
1758 d->leftWidget->removeEventFilter(this);
executed: d->leftWidget->removeEventFilter(this);
Execution Count:29
29
1759 d->leftWidget = w;
executed (the execution status of this line is deduced): d->leftWidget = w;
-
1760 break;
executed: break;
Execution Count:62
62
1761 case Qt::TopRightCorner: -
1762 if (d->rightWidget)
evaluated: d->rightWidget
TRUEFALSE
yes
Evaluation Count:29
yes
Evaluation Count:33
29-33
1763 d->rightWidget->removeEventFilter(this);
executed: d->rightWidget->removeEventFilter(this);
Execution Count:29
29
1764 d->rightWidget = w;
executed (the execution status of this line is deduced): d->rightWidget = w;
-
1765 break;
executed: break;
Execution Count:62
62
1766 default: -
1767 qWarning("QMenuBar::setCornerWidget: Only TopLeftCorner and TopRightCorner are supported");
never executed (the execution status of this line is deduced): QMessageLogger("widgets/qmenubar.cpp", 1767, __PRETTY_FUNCTION__).warning("QMenuBar::setCornerWidget: Only TopLeftCorner and TopRightCorner are supported");
-
1768 return;
never executed: return;
0
1769 } -
1770 -
1771 if (w) {
evaluated: w
TRUEFALSE
yes
Evaluation Count:72
yes
Evaluation Count:52
52-72
1772 w->setParent(this);
executed (the execution status of this line is deduced): w->setParent(this);
-
1773 w->installEventFilter(this);
executed (the execution status of this line is deduced): w->installEventFilter(this);
-
1774 }
executed: }
Execution Count:72
72
1775 -
1776 d->_q_updateLayout();
executed (the execution status of this line is deduced): d->_q_updateLayout();
-
1777}
executed: }
Execution Count:124
124
1778 -
1779/*! -
1780 Returns the widget on the left of the first or on the right of the last menu -
1781 item, depending on \a corner. -
1782 -
1783 \note Using a corner other than Qt::TopRightCorner or Qt::TopLeftCorner -
1784 will result in a warning. -
1785*/ -
1786QWidget *QMenuBar::cornerWidget(Qt::Corner corner) const -
1787{ -
1788 Q_D(const QMenuBar);
executed (the execution status of this line is deduced): const QMenuBarPrivate * const d = d_func();
-
1789 QWidget *w = 0;
executed (the execution status of this line is deduced): QWidget *w = 0;
-
1790 switch(corner) { -
1791 case Qt::TopLeftCorner: -
1792 w = d->leftWidget;
executed (the execution status of this line is deduced): w = d->leftWidget;
-
1793 break;
executed: break;
Execution Count:210
210
1794 case Qt::TopRightCorner: -
1795 w = d->rightWidget;
executed (the execution status of this line is deduced): w = d->rightWidget;
-
1796 break;
executed: break;
Execution Count:270
270
1797 default: -
1798 qWarning("QMenuBar::cornerWidget: Only TopLeftCorner and TopRightCorner are supported");
never executed (the execution status of this line is deduced): QMessageLogger("widgets/qmenubar.cpp", 1798, __PRETTY_FUNCTION__).warning("QMenuBar::cornerWidget: Only TopLeftCorner and TopRightCorner are supported");
-
1799 break;
never executed: break;
0
1800 } -
1801 -
1802 return w;
executed: return w;
Execution Count:480
480
1803} -
1804 -
1805/*! -
1806 \property QMenuBar::nativeMenuBar -
1807 \brief Whether or not a menubar will be used as a native menubar on platforms that support it -
1808 \since 4.6 -
1809 -
1810 This property specifies whether or not the menubar should be used as a native menubar on platforms -
1811 that support it. The currently supported platforms are Mac OS X and Windows CE. On these platforms -
1812 if this property is true, the menubar is used in the native menubar and is not in the window of -
1813 its parent, if false the menubar remains in the window. On other platforms the value of this -
1814 attribute has no effect. -
1815 -
1816 The default is to follow whether the Qt::AA_DontUseNativeMenuBar attribute -
1817 is set for the application. Explicitly settings this property overrides -
1818 the presence (or abscence) of the attribute. -
1819*/ -
1820 -
1821void QMenuBar::setNativeMenuBar(bool nativeMenuBar) -
1822{ -
1823 Q_D(QMenuBar);
executed (the execution status of this line is deduced): QMenuBarPrivate * const d = d_func();
-
1824 if (d->nativeMenuBar == -1 || (nativeMenuBar != bool(d->nativeMenuBar))) {
partially evaluated: d->nativeMenuBar == -1
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
never evaluated: (nativeMenuBar != bool(d->nativeMenuBar))
0-3
1825 d->nativeMenuBar = nativeMenuBar;
executed (the execution status of this line is deduced): d->nativeMenuBar = nativeMenuBar;
-
1826 -
1827 if (!d->nativeMenuBar) {
partially evaluated: !d->nativeMenuBar
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
1828 delete d->platformMenuBar;
executed (the execution status of this line is deduced): delete d->platformMenuBar;
-
1829 d->platformMenuBar = 0;
executed (the execution status of this line is deduced): d->platformMenuBar = 0;
-
1830 } else {
executed: }
Execution Count:3
3
1831 if (!d->platformMenuBar)
never evaluated: !d->platformMenuBar
0
1832 d->platformMenuBar = QGuiApplicationPrivate::platformTheme()->createPlatformMenuBar();
never executed: d->platformMenuBar = QGuiApplicationPrivate::platformTheme()->createPlatformMenuBar();
0
1833 }
never executed: }
0
1834 -
1835 updateGeometry();
executed (the execution status of this line is deduced): updateGeometry();
-
1836 if (!d->nativeMenuBar && parentWidget())
partially evaluated: !d->nativeMenuBar
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
evaluated: parentWidget()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2
0-3
1837 setVisible(true);
executed: setVisible(true);
Execution Count:1
1
1838 }
executed: }
Execution Count:3
3
1839}
executed: }
Execution Count:3
3
1840 -
1841bool QMenuBar::isNativeMenuBar() const -
1842{ -
1843 Q_D(const QMenuBar);
never executed (the execution status of this line is deduced): const QMenuBarPrivate * const d = d_func();
-
1844 if (d->nativeMenuBar == -1) {
never evaluated: d->nativeMenuBar == -1
0
1845 return !QApplication::instance()->testAttribute(Qt::AA_DontUseNativeMenuBar);
never executed: return !QApplication::instance()->testAttribute(Qt::AA_DontUseNativeMenuBar);
0
1846 } -
1847 return d->nativeMenuBar;
never executed: return d->nativeMenuBar;
0
1848} -
1849 -
1850/*! -
1851 \internal -
1852*/ -
1853QPlatformMenuBar *QMenuBar::platformMenuBar() -
1854{ -
1855 Q_D(const QMenuBar);
never executed (the execution status of this line is deduced): const QMenuBarPrivate * const d = d_func();
-
1856 return d->platformMenuBar;
never executed: return d->platformMenuBar;
0
1857} -
1858 -
1859/*! -
1860 \since 4.4 -
1861 -
1862 Sets the default action to \a act. -
1863 -
1864 The default action is assigned to the left soft key. The menu is assigned -
1865 to the right soft key. -
1866 -
1867 Currently there is only support for the default action on Windows -
1868 Mobile. On all other platforms this method is not available. -
1869 -
1870 \sa defaultAction() -
1871*/ -
1872 -
1873#ifdef Q_OS_WINCE -
1874void QMenuBar::setDefaultAction(QAction *act) -
1875{ -
1876 Q_D(QMenuBar); -
1877 if (d->defaultAction == act) -
1878 return; -
1879 if (qt_wince_is_mobile()) -
1880 if (d->defaultAction) { -
1881 disconnect(d->defaultAction, SIGNAL(changed()), this, SLOT(_q_updateDefaultAction())); -
1882 disconnect(d->defaultAction, SIGNAL(destroyed()), this, SLOT(_q_updateDefaultAction())); -
1883 } -
1884 d->defaultAction = act; -
1885 if (qt_wince_is_mobile()) -
1886 if (d->defaultAction) { -
1887 connect(d->defaultAction, SIGNAL(changed()), this, SLOT(_q_updateDefaultAction())); -
1888 connect(d->defaultAction, SIGNAL(destroyed()), this, SLOT(_q_updateDefaultAction())); -
1889 } -
1890 if (d->wce_menubar) { -
1891 d->wce_menubar->rebuild(); -
1892 } -
1893} -
1894 -
1895/*! -
1896 \since 4.4 -
1897 -
1898 Returns the current default action. -
1899 -
1900 \sa setDefaultAction() -
1901*/ -
1902QAction *QMenuBar::defaultAction() const -
1903{ -
1904 return d_func()->defaultAction; -
1905} -
1906#endif -
1907 -
1908/*! -
1909 \fn void QMenuBar::triggered(QAction *action) -
1910 -
1911 This signal is emitted when an action in a menu belonging to this menubar -
1912 is triggered as a result of a mouse click; \a action is the action that -
1913 caused the signal to be emitted. -
1914 -
1915 \note QMenuBar has to have ownership of the QMenu in order this signal to work. -
1916 -
1917 Normally, you connect each menu action to a single slot using -
1918 QAction::triggered(), but sometimes you will want to connect -
1919 several items to a single slot (most often if the user selects -
1920 from an array). This signal is useful in such cases. -
1921 -
1922 \sa hovered(), QAction::triggered() -
1923*/ -
1924 -
1925/*! -
1926 \fn void QMenuBar::hovered(QAction *action) -
1927 -
1928 This signal is emitted when a menu action is highlighted; \a action -
1929 is the action that caused the event to be sent. -
1930 -
1931 Often this is used to update status information. -
1932 -
1933 \sa triggered(), QAction::hovered() -
1934*/ -
1935 -
1936/*! -
1937 \fn void QMenuBar::addAction(QAction *action) -
1938 \overload -
1939 -
1940 Appends the action \a action to the menu bar's list of actions. -
1941 -
1942 \sa QMenu::addAction(), QWidget::addAction(), QWidget::actions() -
1943*/ -
1944 -
1945// for private slots -
1946 -
1947 -
1948QT_END_NAMESPACE -
1949 -
1950#include <moc_qmenubar.cpp> -
1951 -
1952#endif // QT_NO_MENUBAR -
1953 -
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial