widgets/qmenu.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4 -
5 -
6 -
7 -
8 -
9 -
10 -
11 -
12 -
13 -
14QMenu *QMenuPrivate::mouseDown = 0; -
15int QMenuPrivate::sloppyDelayTimer = 0; -
16 -
17 -
18 -
19class QTornOffMenu : public QMenu -
20{ -
21 public: template <typename T> inline void qt_check_for_QOBJECT_macro(const T &_q_argument) const { int i = qYouForgotTheQ_OBJECT_Macro(this, &_q_argument); i = i + 1; } static const QMetaObject staticMetaObject; virtual const QMetaObject *metaObject() const; virtual void *qt_metacast(const char *); static inline QString tr(const char *s, const char *c = 0, int n = -1) { return staticMetaObject.tr(s, c, n); } __attribute__ ((__deprecated__)) static inline QString trUtf8(const char *s, const char *c = 0, int n = -1) { return staticMetaObject.tr(s, c, n); } virtual int qt_metacall(QMetaObject::Call, int, void **); private: __attribute__((visibility("hidden"))) static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **); struct QPrivateSignal {}; -
22 class QTornOffMenuPrivate : public QMenuPrivate -
23 { -
24 inline QMenu* q_func() { return static_cast<QMenu *>(q_ptr); } inline const QMenu* q_func() const { return static_cast<const QMenu *>(q_ptr); } friend class QMenu; -
25 public: -
26 QTornOffMenuPrivate(QMenu *p) : causedMenu(p) { -
27 tornoff = 1; -
28 causedPopup.widget = 0; -
29 causedPopup.action = ((QTornOffMenu*)p)->d_func()->causedPopup.action; -
30 causedStack = ((QTornOffMenu*)p)->d_func()->calcCausedStack(); -
31 }
executed: }
Execution Count:1
1
32 QList<QPointer<QWidget> > calcCausedStack() const { return causedStack; }
never executed: return causedStack;
0
33 QPointer<QMenu> causedMenu; -
34 QList<QPointer<QWidget> > causedStack; -
35 }; -
36public: -
37 QTornOffMenu(QMenu *p) : QMenu(*(new QTornOffMenuPrivate(p))) -
38 { -
39 QTornOffMenuPrivate * const d = d_func(); -
40 -
41 QWidget *parentWidget = d->causedStack.isEmpty() ? p : d->causedStack.last();
partially evaluated: d->causedStack.isEmpty()
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
42 if (parentWidget->parentWidget())
partially evaluated: parentWidget->parentWidget()
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
43 parentWidget = parentWidget->parentWidget();
executed: parentWidget = parentWidget->parentWidget();
Execution Count:1
1
44 setParent(parentWidget, Qt::Window | Qt::Tool); -
45 setAttribute(Qt::WA_DeleteOnClose, true); -
46 setAttribute(Qt::WA_X11NetWmWindowTypeMenu, true); -
47 setWindowTitle(p->windowTitle()); -
48 setEnabled(p->isEnabled()); -
49 -
50 -
51 QList<QAction*> items = p->actions(); -
52 for(int i = 0; i < items.count(); i++)
evaluated: i < items.count()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1
1-2
53 addAction(items.at(i));
executed: addAction(items.at(i));
Execution Count:2
2
54 }
executed: }
Execution Count:1
1
55 void syncWithMenu(QMenu *menu, QActionEvent *act) -
56 { -
57 QTornOffMenuPrivate * const d = d_func(); -
58 if(menu != d->causedMenu)
never evaluated: menu != d->causedMenu
0
59 return;
never executed: return;
0
60 if (act->type() == QEvent::ActionAdded) {
never evaluated: act->type() == QEvent::ActionAdded
0
61 insertAction(act->before(), act->action()); -
62 } else if (act->type() == QEvent::ActionRemoved)
never evaluated: act->type() == QEvent::ActionRemoved
never executed: }
0
63 removeAction(act->action());
never executed: removeAction(act->action());
0
64 } -
65 void actionEvent(QActionEvent *e) -
66 { -
67 QMenu::actionEvent(e); -
68 setFixedSize(sizeHint()); -
69 }
executed: }
Execution Count:4
4
70public : -
71 void onTrigger(QAction *action) { d_func()->activateAction(action, QAction::Trigger, false); }
never executed: }
0
72 void onHovered(QAction *action) { d_func()->activateAction(action, QAction::Hover, false); }
never executed: }
0
73private: -
74 inline QTornOffMenuPrivate* d_func() { return reinterpret_cast<QTornOffMenuPrivate *>(qGetPtrHelper(d_ptr)); } inline const QTornOffMenuPrivate* d_func() const { return reinterpret_cast<const QTornOffMenuPrivate *>(qGetPtrHelper(d_ptr)); } friend class QTornOffMenuPrivate;
executed: return reinterpret_cast<QTornOffMenuPrivate *>(qGetPtrHelper(d_ptr));
Execution Count:3
never executed: return reinterpret_cast<const QTornOffMenuPrivate *>(qGetPtrHelper(d_ptr));
0-3
75 friend class QMenuPrivate; -
76}; -
77 -
78void QMenuPrivate::init() -
79{ -
80 QMenu * const q = q_func(); -
81 -
82 q->setAttribute(Qt::WA_CustomWhatsThis); -
83 -
84 q->setAttribute(Qt::WA_X11NetWmWindowTypePopupMenu); -
85 defaultMenuAction = menuAction = new QAction(q); -
86 menuAction->d_func()->menu = q; -
87 q->setMouseTracking(q->style()->styleHint(QStyle::SH_Menu_MouseTracking, 0, q)); -
88 if (q->style()->styleHint(QStyle::SH_Menu_Scrollable, 0, q)) {
partially evaluated: q->style()->styleHint(QStyle::SH_Menu_Scrollable, 0, q)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:272
0-272
89 scroll = new QMenuPrivate::QMenuScroller; -
90 scroll->scrollFlags = QMenuPrivate::QMenuScroller::ScrollNone; -
91 }
never executed: }
0
92 -
93 platformMenu = QGuiApplicationPrivate::platformTheme()->createPlatformMenu(); -
94 if (platformMenu) {
partially evaluated: platformMenu
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:272
0-272
95 QObject::connect(platformMenu, "2""aboutToShow()", q, "2""aboutToShow()"); -
96 QObject::connect(platformMenu, "2""aboutToHide()", q, "2""aboutToHide()"); -
97 }
never executed: }
0
98}
executed: }
Execution Count:272
272
99 -
100int QMenuPrivate::scrollerHeight() const -
101{ -
102 const QMenu * const q = q_func(); -
103 return qMax(QApplication::globalStrut().height(), q->style()->pixelMetric(QStyle::PM_MenuScrollerHeight, 0, q));
never executed: return qMax(QApplication::globalStrut().height(), q->style()->pixelMetric(QStyle::PM_MenuScrollerHeight, 0, q));
0
104} -
105 -
106 -
107QRect QMenuPrivate::popupGeometry(const QWidget *widget) const -
108{ -
109 if (QGuiApplicationPrivate::platformTheme() &&
partially evaluated: QGuiApplicationPrivate::platformTheme()
TRUEFALSE
yes
Evaluation Count:782
no
Evaluation Count:0
0-782
110 QGuiApplicationPrivate::platformTheme()->themeHint(QPlatformTheme::UseFullScreenForPopupMenu).toBool()) {
partially evaluated: QGuiApplicationPrivate::platformTheme()->themeHint(QPlatformTheme::UseFullScreenForPopupMenu).toBool()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:782
0-782
111 return QApplication::desktop()->screenGeometry(widget);
never executed: return QApplication::desktop()->screenGeometry(widget);
0
112 } else { -
113 return QApplication::desktop()->availableGeometry(widget);
executed: return QApplication::desktop()->availableGeometry(widget);
Execution Count:782
782
114 } -
115} -
116 -
117 -
118QRect QMenuPrivate::popupGeometry(int screen) const -
119{ -
120 if (QGuiApplicationPrivate::platformTheme() &&
partially evaluated: QGuiApplicationPrivate::platformTheme()
TRUEFALSE
yes
Evaluation Count:61
no
Evaluation Count:0
0-61
121 QGuiApplicationPrivate::platformTheme()->themeHint(QPlatformTheme::UseFullScreenForPopupMenu).toBool()) {
partially evaluated: QGuiApplicationPrivate::platformTheme()->themeHint(QPlatformTheme::UseFullScreenForPopupMenu).toBool()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:61
0-61
122 return QApplication::desktop()->screenGeometry(screen);
never executed: return QApplication::desktop()->screenGeometry(screen);
0
123 } else { -
124 return QApplication::desktop()->availableGeometry(screen);
executed: return QApplication::desktop()->availableGeometry(screen);
Execution Count:61
61
125 } -
126} -
127 -
128QList<QPointer<QWidget> > QMenuPrivate::calcCausedStack() const -
129{ -
130 QList<QPointer<QWidget> > ret; -
131 for(QWidget *widget = causedPopup.widget; widget; ) {
evaluated: widget
TRUEFALSE
yes
Evaluation Count:33
yes
Evaluation Count:42
33-42
132 ret.append(widget); -
133 if (QTornOffMenu *qtmenu = qobject_cast<QTornOffMenu*>(widget))
partially evaluated: QTornOffMenu *qtmenu = qobject_cast<QTornOffMenu*>(widget)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:33
0-33
134 ret += qtmenu->d_func()->causedStack;
never executed: ret += qtmenu->d_func()->causedStack;
0
135 if (QMenu *qmenu = qobject_cast<QMenu*>(widget))
evaluated: QMenu *qmenu = qobject_cast<QMenu*>(widget)
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:28
5-28
136 widget = qmenu->d_func()->causedPopup.widget;
executed: widget = qmenu->d_func()->causedPopup.widget;
Execution Count:5
5
137 else -
138 break;
executed: break;
Execution Count:28
28
139 } -
140 return ret;
executed: return ret;
Execution Count:70
70
141} -
142 -
143void QMenuPrivate::updateActionRects() const -
144{ -
145 const QMenu * const q = q_func(); -
146 updateActionRects(popupGeometry(q)); -
147}
executed: }
Execution Count:782
782
148 -
149void QMenuPrivate::updateActionRects(const QRect &screen) const -
150{ -
151 const QMenu * const q = q_func(); -
152 if (!itemsDirty)
evaluated: !itemsDirty
TRUEFALSE
yes
Evaluation Count:518
yes
Evaluation Count:264
264-518
153 return;
executed: return;
Execution Count:518
518
154 -
155 q->ensurePolished(); -
156 -
157 -
158 actionRects.resize(actions.count()); -
159 actionRects.fill(QRect()); -
160 -
161 int lastVisibleAction = getLastVisibleAction(); -
162 -
163 int max_column_width = 0, -
164 dh = screen.height(), -
165 y = 0; -
166 QStyle *style = q->style(); -
167 QStyleOption opt; -
168 opt.init(q); -
169 const int hmargin = style->pixelMetric(QStyle::PM_MenuHMargin, &opt, q), -
170 vmargin = style->pixelMetric(QStyle::PM_MenuVMargin, &opt, q), -
171 icone = style->pixelMetric(QStyle::PM_SmallIconSize, &opt, q); -
172 const int fw = style->pixelMetric(QStyle::PM_MenuPanelWidth, &opt, q); -
173 const int deskFw = style->pixelMetric(QStyle::PM_MenuDesktopFrameWidth, &opt, q); -
174 const int tearoffHeight = tearoff ? style->pixelMetric(QStyle::PM_MenuTearoffHeight, &opt, q) : 0;
evaluated: tearoff
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:261
3-261
175 -
176 -
177 tabWidth = 0; -
178 maxIconWidth = 0; -
179 hasCheckableItems = false; -
180 ncols = 1; -
181 sloppyAction = 0; -
182 -
183 for (int i = 0; i < actions.count(); ++i) {
evaluated: i < actions.count()
TRUEFALSE
yes
Evaluation Count:1927
yes
Evaluation Count:264
264-1927
184 QAction *action = actions.at(i); -
185 if (action->isSeparator() || !action->isVisible() || widgetItems.contains(action))
evaluated: action->isSeparator()
TRUEFALSE
yes
Evaluation Count:56
yes
Evaluation Count:1871
partially evaluated: !action->isVisible()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1871
evaluated: widgetItems.contains(action)
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:1865
0-1871
186 continue;
executed: continue;
Execution Count:62
62
187 -
188 hasCheckableItems |= action->isCheckable(); -
189 QIcon is = action->icon(); -
190 if (!is.isNull()) {
evaluated: !is.isNull()
TRUEFALSE
yes
Evaluation Count:28
yes
Evaluation Count:1837
28-1837
191 maxIconWidth = qMax<uint>(maxIconWidth, icone + 4); -
192 }
executed: }
Execution Count:28
28
193 }
executed: }
Execution Count:1865
1865
194 -
195 -
196 QFontMetrics qfm = q->fontMetrics(); -
197 bool previousWasSeparator = true; -
198 for(int i = 0; i <= lastVisibleAction; i++) {
evaluated: i <= lastVisibleAction
TRUEFALSE
yes
Evaluation Count:1921
yes
Evaluation Count:264
264-1921
199 QAction *action = actions.at(i); -
200 -
201 if (!action->isVisible() ||
partially evaluated: !action->isVisible()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1921
0-1921
202 (collapsibleSeparators && previousWasSeparator && action->isSeparator()))
partially evaluated: collapsibleSeparators
TRUEFALSE
yes
Evaluation Count:1921
no
Evaluation Count:0
evaluated: previousWasSeparator
TRUEFALSE
yes
Evaluation Count:290
yes
Evaluation Count:1631
partially evaluated: action->isSeparator()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:290
0-1921
203 continue;
never executed: continue;
0
204 -
205 previousWasSeparator = action->isSeparator(); -
206 -
207 -
208 QStyleOptionMenuItem opt; -
209 q->initStyleOption(&opt, action); -
210 const QFontMetrics &fm = opt.fontMetrics; -
211 -
212 QSize sz; -
213 if (QWidget *w = widgetItems.value(action)) {
evaluated: QWidget *w = widgetItems.value(action)
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:1915
6-1915
214 sz = w->sizeHint().expandedTo(w->minimumSize()).expandedTo(w->minimumSizeHint()).boundedTo(w->maximumSize()); -
215 } else {
executed: }
Execution Count:6
6
216 -
217 if (action->isSeparator()) {
evaluated: action->isSeparator()
TRUEFALSE
yes
Evaluation Count:50
yes
Evaluation Count:1865
50-1865
218 sz = QSize(2, 2); -
219 } else {
executed: }
Execution Count:50
50
220 QString s = action->text(); -
221 int t = s.indexOf(QLatin1Char('\t')); -
222 if (t != -1) {
evaluated: t != -1
TRUEFALSE
yes
Evaluation Count:24
yes
Evaluation Count:1841
24-1841
223 tabWidth = qMax(int(tabWidth), qfm.width(s.mid(t+1))); -
224 s = s.left(t); -
225 -
226 } else {
executed: }
Execution Count:24
24
227 QKeySequence seq = action->shortcut(); -
228 if (!seq.isEmpty())
evaluated: !seq.isEmpty()
TRUEFALSE
yes
Evaluation Count:95
yes
Evaluation Count:1746
95-1746
229 tabWidth = qMax(int(tabWidth), qfm.width(seq.toString(QKeySequence::NativeText)));
executed: tabWidth = qMax(int(tabWidth), qfm.width(seq.toString(QKeySequence::NativeText)));
Execution Count:95
95
230 -
231 }
executed: }
Execution Count:1841
1841
232 sz.setWidth(fm.boundingRect(QRect(), Qt::TextSingleLine | Qt::TextShowMnemonic, s).width()); -
233 sz.setHeight(qMax(fm.height(), qfm.height())); -
234 -
235 QIcon is = action->icon(); -
236 if (!is.isNull()) {
evaluated: !is.isNull()
TRUEFALSE
yes
Evaluation Count:28
yes
Evaluation Count:1837
28-1837
237 QSize is_sz = QSize(icone, icone); -
238 if (is_sz.height() > sz.height())
partially evaluated: is_sz.height() > sz.height()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:28
0-28
239 sz.setHeight(is_sz.height());
never executed: sz.setHeight(is_sz.height());
0
240 }
executed: }
Execution Count:28
28
241 }
executed: }
Execution Count:1865
1865
242 sz = style->sizeFromContents(QStyle::CT_MenuItem, &opt, sz, q); -
243 }
executed: }
Execution Count:1915
1915
244 -
245 -
246 if (!sz.isEmpty()) {
partially evaluated: !sz.isEmpty()
TRUEFALSE
yes
Evaluation Count:1921
no
Evaluation Count:0
0-1921
247 max_column_width = qMax(max_column_width, sz.width()); -
248 -
249 if (!scroll &&
partially evaluated: !scroll
TRUEFALSE
yes
Evaluation Count:1921
no
Evaluation Count:0
0-1921
250 y+sz.height()+vmargin > dh - (deskFw * 2)) {
evaluated: y+sz.height()+vmargin > dh - (deskFw * 2)
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1919
2-1919
251 ncols++; -
252 y = vmargin; -
253 }
executed: }
Execution Count:2
2
254 y += sz.height(); -
255 -
256 actionRects[i] = QRect(0, 0, sz.width(), sz.height()); -
257 }
executed: }
Execution Count:1921
1921
258 }
executed: }
Execution Count:1921
1921
259 -
260 max_column_width += tabWidth; -
261 const int sfcMargin = style->sizeFromContents(QStyle::CT_Menu, &opt, QApplication::globalStrut(), q).width() - QApplication::globalStrut().width(); -
262 const int min_column_width = q->minimumWidth() - (sfcMargin + leftmargin + rightmargin + 2 * (fw + hmargin)); -
263 max_column_width = qMax(min_column_width, max_column_width); -
264 -
265 -
266 const int base_y = vmargin + fw + topmargin + -
267 (scroll ? scroll->scrollOffset : 0) +
partially evaluated: scroll
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:264
0-264
268 tearoffHeight; -
269 int x = hmargin + fw + leftmargin; -
270 y = base_y; -
271 -
272 for(int i = 0; i < actions.count(); i++) {
evaluated: i < actions.count()
TRUEFALSE
yes
Evaluation Count:1927
yes
Evaluation Count:264
264-1927
273 QRect &rect = actionRects[i]; -
274 if (rect.isNull())
evaluated: rect.isNull()
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:1921
6-1921
275 continue;
executed: continue;
Execution Count:6
6
276 if (!scroll &&
partially evaluated: !scroll
TRUEFALSE
yes
Evaluation Count:1921
no
Evaluation Count:0
0-1921
277 y+rect.height() > dh - deskFw * 2) {
evaluated: y+rect.height() > dh - deskFw * 2
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1919
2-1919
278 x += max_column_width + hmargin; -
279 y = base_y; -
280 }
executed: }
Execution Count:2
2
281 rect.translate(x, y); -
282 rect.setWidth(max_column_width); -
283 -
284 -
285 if (QWidget *widget = widgetItems.value(actions.at(i))) {
evaluated: QWidget *widget = widgetItems.value(actions.at(i))
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:1915
6-1915
286 widget->setGeometry(rect); -
287 widget->setVisible(actions.at(i)->isVisible()); -
288 }
executed: }
Execution Count:6
6
289 -
290 y += rect.height(); -
291 }
executed: }
Execution Count:1921
1921
292 itemsDirty = 0; -
293}
executed: }
Execution Count:264
264
294 -
295QSize QMenuPrivate::adjustMenuSizeForScreen(const QRect &screen) -
296{ -
297 QMenu * const q = q_func(); -
298 QSize ret = screen.size(); -
299 itemsDirty = true; -
300 updateActionRects(screen); -
301 const int fw = q->style()->pixelMetric(QStyle::PM_MenuPanelWidth, 0, q); -
302 ret.setWidth(actionRects.at(getLastVisibleAction()).right() + fw); -
303 return ret;
never executed: return ret;
0
304} -
305 -
306int QMenuPrivate::getLastVisibleAction() const -
307{ -
308 -
309 int lastVisibleAction = actions.count() - 1; -
310 for (;lastVisibleAction >= 0; --lastVisibleAction) {
evaluated: lastVisibleAction >= 0
TRUEFALSE
yes
Evaluation Count:246
yes
Evaluation Count:24
24-246
311 const QAction *action = actions.at(lastVisibleAction); -
312 if (action->isVisible()) {
partially evaluated: action->isVisible()
TRUEFALSE
yes
Evaluation Count:246
no
Evaluation Count:0
0-246
313 -
314 if (action->isSeparator() && collapsibleSeparators)
evaluated: action->isSeparator()
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:240
partially evaluated: collapsibleSeparators
TRUEFALSE
yes
Evaluation Count:6
no
Evaluation Count:0
0-240
315 continue;
executed: continue;
Execution Count:6
6
316 break;
executed: break;
Execution Count:240
240
317 } -
318 }
never executed: }
0
319 return lastVisibleAction;
executed: return lastVisibleAction;
Execution Count:264
264
320} -
321 -
322 -
323QRect QMenuPrivate::actionRect(QAction *act) const -
324{ -
325 int index = actions.indexOf(act); -
326 if (index == -1)
evaluated: index == -1
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:128
2-128
327 return QRect();
executed: return QRect();
Execution Count:2
2
328 -
329 updateActionRects(); -
330 -
331 -
332 return actionRects.at(index);
executed: return actionRects.at(index);
Execution Count:128
128
333} -
334 -
335 -
336 -
337 -
338 -
339void QMenuPrivate::hideUpToMenuBar() -
340{ -
341 QMenu * const q = q_func(); -
342 bool fadeMenus = q->style()->styleHint(QStyle::SH_Menu_FadeOutOnHide); -
343 if (!tornoff) {
partially evaluated: !tornoff
TRUEFALSE
yes
Evaluation Count:12
no
Evaluation Count:0
0-12
344 QWidget *caused = causedPopup.widget; -
345 hideMenu(q); -
346 while(caused) {
evaluated: caused
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:12
5-12
347 -
348 if (QMenuBar *mb = qobject_cast<QMenuBar*>(caused)) {
evaluated: QMenuBar *mb = qobject_cast<QMenuBar*>(caused)
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:1
1-4
349 mb->d_func()->setCurrentAction(0); -
350 mb->d_func()->setKeyboardMode(false); -
351 caused = 0; -
352 } else
executed: }
Execution Count:4
4
353 -
354 if (QMenu *m = qobject_cast<QMenu*>(caused)) {
partially evaluated: QMenu *m = qobject_cast<QMenu*>(caused)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
355 caused = m->d_func()->causedPopup.widget; -
356 if (!m->d_func()->tornoff)
never evaluated: !m->d_func()->tornoff
0
357 hideMenu(m, fadeMenus);
never executed: hideMenu(m, fadeMenus);
0
358 if (!fadeMenus)
never evaluated: !fadeMenus
0
359 m->d_func()->setCurrentAction(0);
never executed: m->d_func()->setCurrentAction(0);
0
360 } else { caused = 0;
never executed: }
0
361 }
executed: }
Execution Count:1
1
362 } -
363 }
executed: }
Execution Count:12
12
364 setCurrentAction(0); -
365}
executed: }
Execution Count:12
12
366 -
367void QMenuPrivate::hideMenu(QMenu *menu, bool justRegister) -
368{ -
369 if (!menu)
partially evaluated: !menu
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:20
0-20
370 return;
never executed: return;
0
371 -
372 menu->blockSignals(true); -
373 aboutToHide = true; -
374 -
375 if (menu->style()->styleHint(QStyle::SH_Menu_FlashTriggeredItem)
partially evaluated: menu->style()->styleHint(QStyle::SH_Menu_FlashTriggeredItem)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:20
0-20
376 && currentAction && currentAction == actionAboutToTrigger
never evaluated: currentAction
never evaluated: currentAction == actionAboutToTrigger
0
377 && menu->actions().contains(currentAction)) {
never evaluated: menu->actions().contains(currentAction)
0
378 QEventLoop eventLoop; -
379 QAction *activeAction = currentAction; -
380 -
381 menu->setActiveAction(0); -
382 QTimer::singleShot(60, &eventLoop, "1""quit()"); -
383 eventLoop.exec(); -
384 -
385 -
386 menu->setActiveAction(activeAction); -
387 QTimer::singleShot(20, &eventLoop, "1""quit()"); -
388 eventLoop.exec(); -
389 }
never executed: }
0
390 -
391 -
392 if (menu->style()->styleHint(QStyle::SH_Menu_FadeOutOnHide)) {
partially evaluated: menu->style()->styleHint(QStyle::SH_Menu_FadeOutOnHide)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:20
0-20
393 }
never executed: }
0
394 aboutToHide = false; -
395 menu->blockSignals(false); -
396 -
397 if (!justRegister)
partially evaluated: !justRegister
TRUEFALSE
yes
Evaluation Count:20
no
Evaluation Count:0
0-20
398 menu->close();
executed: menu->close();
Execution Count:20
20
399}
executed: }
Execution Count:20
20
400 -
401void QMenuPrivate::popupAction(QAction *action, int delay, bool activateFirst) -
402{ -
403 QMenu * const q = q_func(); -
404 if (action && action->isEnabled()) {
partially evaluated: action
TRUEFALSE
yes
Evaluation Count:18
no
Evaluation Count:0
evaluated: action->isEnabled()
TRUEFALSE
yes
Evaluation Count:17
yes
Evaluation Count:1
0-18
405 if (!delay)
evaluated: !delay
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:5
5-12
406 q->internalDelayedPopup();
executed: q->internalDelayedPopup();
Execution Count:12
12
407 else if (!menuDelayTimer.isActive() && (!action->menu() || !action->menu()->isVisible()))
partially evaluated: !menuDelayTimer.isActive()
TRUEFALSE
yes
Evaluation Count:5
no
Evaluation Count:0
evaluated: !action->menu()
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:1
partially evaluated: !action->menu()->isVisible()
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-5
408 menuDelayTimer.start(delay, q);
executed: menuDelayTimer.start(delay, q);
Execution Count:5
5
409 if (activateFirst && action->menu())
evaluated: activateFirst
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:14
partially evaluated: action->menu()
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-14
410 action->menu()->d_func()->setFirstActionActive();
executed: action->menu()->d_func()->setFirstActionActive();
Execution Count:3
3
411 } else if (QMenu *menu = activeMenu) {
partially evaluated: QMenu *menu = activeMenu
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
executed: }
Execution Count:17
0-17
412 activeMenu = 0; -
413 hideMenu(menu); -
414 }
never executed: }
0
415} -
416 -
417void QMenuPrivate::setSyncAction() -
418{ -
419 QMenu * const q = q_func(); -
420 QAction *current = currentAction; -
421 if(current && (!current->isEnabled() || current->menu() || current->isSeparator()))
partially evaluated: current
TRUEFALSE
yes
Evaluation Count:14
no
Evaluation Count:0
evaluated: !current->isEnabled()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:13
evaluated: current->menu()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:12
partially evaluated: current->isSeparator()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:12
0-14
422 current = 0;
executed: current = 0;
Execution Count:2
2
423 for(QWidget *caused = q; caused;) {
evaluated: caused
TRUEFALSE
yes
Evaluation Count:19
yes
Evaluation Count:9
9-19
424 if (QMenu *m = qobject_cast<QMenu*>(caused)) {
evaluated: QMenu *m = qobject_cast<QMenu*>(caused)
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:5
5-14
425 caused = m->d_func()->causedPopup.widget; -
426 if (m->d_func()->eventLoop)
evaluated: m->d_func()->eventLoop
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:13
1-13
427 m->d_func()->syncAction = current;
executed: m->d_func()->syncAction = current;
Execution Count:1
1
428 } else {
executed: }
Execution Count:14
14
429 break;
executed: break;
Execution Count:5
5
430 } -
431 } -
432}
executed: }
Execution Count:14
14
433 -
434 -
435void QMenuPrivate::setFirstActionActive() -
436{ -
437 QMenu * const q = q_func(); -
438 updateActionRects(); -
439 for(int i = 0, saccum = 0; i < actions.count(); i++) {
partially evaluated: i < actions.count()
TRUEFALSE
yes
Evaluation Count:19
no
Evaluation Count:0
0-19
440 const QRect &rect = actionRects.at(i); -
441 if (rect.isNull())
partially evaluated: rect.isNull()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:19
0-19
442 continue;
never executed: continue;
0
443 if (scroll && scroll->scrollFlags & QMenuScroller::ScrollUp) {
partially evaluated: scroll
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:19
never evaluated: scroll->scrollFlags & QMenuScroller::ScrollUp
0-19
444 saccum -= rect.height(); -
445 if (saccum > scroll->scrollOffset - scrollerHeight())
never evaluated: saccum > scroll->scrollOffset - scrollerHeight()
0
446 continue;
never executed: continue;
0
447 }
never executed: }
0
448 QAction *act = actions.at(i); -
449 if (!act->isSeparator() &&
partially evaluated: !act->isSeparator()
TRUEFALSE
yes
Evaluation Count:19
no
Evaluation Count:0
0-19
450 (q->style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, 0, q)
partially evaluated: q->style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, 0, q)
TRUEFALSE
yes
Evaluation Count:19
no
Evaluation Count:0
0-19
451 || act->isEnabled())) {
never evaluated: act->isEnabled()
0
452 setCurrentAction(act); -
453 break;
executed: break;
Execution Count:19
19
454 } -
455 }
never executed: }
0
456}
executed: }
Execution Count:19
19
457 -
458 -
459void QMenuPrivate::setCurrentAction(QAction *action, int popup, SelectionReason reason, bool activateFirst) -
460{ -
461 QMenu * const q = q_func(); -
462 tearoffHighlighted = 0; -
463 -
464 -
465 if (reason != SelectedFromKeyboard && action == currentAction && !(action && action->menu() && action->menu() != activeMenu)) {
evaluated: reason != SelectedFromKeyboard
TRUEFALSE
yes
Evaluation Count:101
yes
Evaluation Count:19
evaluated: action == currentAction
TRUEFALSE
yes
Evaluation Count:39
yes
Evaluation Count:62
evaluated: action
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:38
partially evaluated: action->menu()
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
partially evaluated: action->menu() != activeMenu
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-101
466 if (QMenu *menu = qobject_cast<QMenu*>(causedPopup.widget)) {
partially evaluated: QMenu *menu = qobject_cast<QMenu*>(causedPopup.widget)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:38
0-38
467 if (causedPopup.action && menu->d_func()->activeMenu == q)
never evaluated: causedPopup.action
never evaluated: menu->d_func()->activeMenu == q
0
468 menu->d_func()->setCurrentAction(causedPopup.action, 0, reason, false);
never executed: menu->d_func()->setCurrentAction(causedPopup.action, 0, reason, false);
0
469 }
never executed: }
0
470 return;
executed: return;
Execution Count:38
38
471 } -
472 -
473 if (currentAction)
evaluated: currentAction
TRUEFALSE
yes
Evaluation Count:43
yes
Evaluation Count:39
39-43
474 q->update(actionRect(currentAction));
executed: q->update(actionRect(currentAction));
Execution Count:43
43
475 -
476 sloppyAction = 0; -
477 if (!sloppyRegion.isEmpty())
partially evaluated: !sloppyRegion.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:82
0-82
478 sloppyRegion = QRegion();
never executed: sloppyRegion = QRegion();
0
479 QMenu *hideActiveMenu = activeMenu; -
480 -
481 QAction *previousAction = currentAction; -
482 -
483 -
484 currentAction = action; -
485 if (action) {
evaluated: action
TRUEFALSE
yes
Evaluation Count:57
yes
Evaluation Count:25
25-57
486 if (!action->isSeparator()) {
partially evaluated: !action->isSeparator()
TRUEFALSE
yes
Evaluation Count:57
no
Evaluation Count:0
0-57
487 activateAction(action, QAction::Hover); -
488 if (popup != -1) {
evaluated: popup != -1
TRUEFALSE
yes
Evaluation Count:19
yes
Evaluation Count:38
19-38
489 hideActiveMenu = 0; -
490 -
491 -
492 -
493 if (q->isVisible())
evaluated: q->isVisible()
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:5
5-14
494 popupAction(currentAction, popup, activateFirst);
executed: popupAction(currentAction, popup, activateFirst);
Execution Count:14
14
495 }
executed: }
Execution Count:19
19
496 q->update(actionRect(action)); -
497 -
498 if (reason == SelectedFromKeyboard) {
evaluated: reason == SelectedFromKeyboard
TRUEFALSE
yes
Evaluation Count:19
yes
Evaluation Count:38
19-38
499 QWidget *widget = widgetItems.value(action); -
500 if (widget) {
evaluated: widget
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:18
1-18
501 if (widget->focusPolicy() != Qt::NoFocus)
partially evaluated: widget->focusPolicy() != Qt::NoFocus
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
502 widget->setFocus(Qt::TabFocusReason);
executed: widget->setFocus(Qt::TabFocusReason);
Execution Count:1
1
503 } else {
executed: }
Execution Count:1
1
504 -
505 -
506 -
507 if (!q->hasFocus()) {
evaluated: !q->hasFocus()
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:9
9
508 q->setFocus(Qt::PopupFocusReason); -
509 }
executed: }
Execution Count:9
9
510 }
executed: }
Execution Count:18
18
511 } -
512 } else {
executed: }
Execution Count:57
57
513 if (popup != -1)
never evaluated: popup != -1
0
514 hideActiveMenu = 0;
never executed: hideActiveMenu = 0;
0
515 }
never executed: }
0
516 -
517 } else if (previousAction) {
partially evaluated: previousAction
TRUEFALSE
yes
Evaluation Count:25
no
Evaluation Count:0
0-25
518 previousAction->d_func()->showStatusText(topCausedWidget(), QString()); -
519 -
520 }
executed: }
Execution Count:25
25
521 if (hideActiveMenu) {
evaluated: hideActiveMenu
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:81
1-81
522 activeMenu = 0; -
523 -
524 -
525 qFadeEffect(0); -
526 qScrollEffect(0); -
527 -
528 hideMenu(hideActiveMenu); -
529 }
executed: }
Execution Count:1
1
530}
executed: }
Execution Count:82
82
531 -
532 -
533QWidget *QMenuPrivate::topCausedWidget() const -
534{ -
535 QWidget* top = causedPopup.widget; -
536 while (QMenu* m = qobject_cast<QMenu *>(top))
evaluated: QMenu* m = qobject_cast<QMenu *>(top)
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:147
13-147
537 top = m->d_func()->causedPopup.widget;
executed: top = m->d_func()->causedPopup.widget;
Execution Count:13
13
538 return top;
executed: return top;
Execution Count:147
147
539} -
540 -
541QAction *QMenuPrivate::actionAt(QPoint p) const -
542{ -
543 if (!q_func()->rect().contains(p))
partially evaluated: !q_func()->rect().contains(p)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:24
0-24
544 return 0;
never executed: return 0;
0
545 -
546 for(int i = 0; i < actionRects.count(); i++) {
evaluated: i < actionRects.count()
TRUEFALSE
yes
Evaluation Count:63
yes
Evaluation Count:12
12-63
547 if (actionRects.at(i).contains(p))
evaluated: actionRects.at(i).contains(p)
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:51
12-51
548 return actions.at(i);
executed: return actions.at(i);
Execution Count:12
12
549 }
executed: }
Execution Count:51
51
550 return 0;
executed: return 0;
Execution Count:12
12
551} -
552 -
553void QMenuPrivate::setOverrideMenuAction(QAction *a) -
554{ -
555 QMenu * const q = q_func(); -
556 QObject::disconnect(menuAction, "2""destroyed()", q, "1""_q_overrideMenuActionDestroyed()"); -
557 if (a) {
evaluated: a
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:1
1-3
558 menuAction = a; -
559 QObject::connect(a, "2""destroyed()", q, "1""_q_overrideMenuActionDestroyed()"); -
560 } else {
executed: }
Execution Count:3
3
561 menuAction = defaultMenuAction; -
562 }
executed: }
Execution Count:1
1
563} -
564 -
565void QMenuPrivate::_q_overrideMenuActionDestroyed() -
566{ -
567 menuAction=defaultMenuAction; -
568}
executed: }
Execution Count:1
1
569 -
570 -
571void QMenuPrivate::updateLayoutDirection() -
572{ -
573 QMenu * const q = q_func(); -
574 -
575 -
576 -
577 if (!q->testAttribute(Qt::WA_SetLayoutDirection)) {
partially evaluated: !q->testAttribute(Qt::WA_SetLayoutDirection)
TRUEFALSE
yes
Evaluation Count:295
no
Evaluation Count:0
0-295
578 if (QWidget *w = causedPopup.widget)
evaluated: QWidget *w = causedPopup.widget
TRUEFALSE
yes
Evaluation Count:46
yes
Evaluation Count:249
46-249
579 setLayoutDirection_helper(w->layoutDirection());
executed: setLayoutDirection_helper(w->layoutDirection());
Execution Count:46
46
580 else if (QWidget *w = q->parentWidget())
evaluated: QWidget *w = q->parentWidget()
TRUEFALSE
yes
Evaluation Count:214
yes
Evaluation Count:35
35-214
581 setLayoutDirection_helper(w->layoutDirection());
executed: setLayoutDirection_helper(w->layoutDirection());
Execution Count:214
214
582 else -
583 setLayoutDirection_helper(QApplication::layoutDirection());
executed: setLayoutDirection_helper(QApplication::layoutDirection());
Execution Count:35
35
584 } -
585}
executed: }
Execution Count:295
295
586 -
587 -
588 -
589 -
590 -
591QAction *QMenu::menuAction() const -
592{ -
593 return d_func()->menuAction;
executed: return d_func()->menuAction;
Execution Count:183
183
594} -
595QString QMenu::title() const -
596{ -
597 return d_func()->menuAction->text();
executed: return d_func()->menuAction->text();
Execution Count:3
3
598} -
599 -
600void QMenu::setTitle(const QString &text) -
601{ -
602 d_func()->menuAction->setText(text); -
603}
executed: }
Execution Count:8
8
604QIcon QMenu::icon() const -
605{ -
606 return d_func()->menuAction->icon();
never executed: return d_func()->menuAction->icon();
0
607} -
608 -
609void QMenu::setIcon(const QIcon &icon) -
610{ -
611 d_func()->menuAction->setIcon(icon); -
612}
never executed: }
0
613 -
614 -
615 -
616void QMenuPrivate::scrollMenu(QAction *action, QMenuScroller::ScrollLocation location, bool active) -
617{ -
618 QMenu * const q = q_func(); -
619 if (!scroll || !scroll->scrollFlags)
never evaluated: !scroll
never evaluated: !scroll->scrollFlags
0
620 return;
never executed: return;
0
621 updateActionRects(); -
622 int newOffset = 0; -
623 const int topScroll = (scroll->scrollFlags & QMenuScroller::ScrollUp) ? scrollerHeight() : 0;
never evaluated: (scroll->scrollFlags & QMenuScroller::ScrollUp)
0
624 const int botScroll = (scroll->scrollFlags & QMenuScroller::ScrollDown) ? scrollerHeight() : 0;
never evaluated: (scroll->scrollFlags & QMenuScroller::ScrollDown)
0
625 const int vmargin = q->style()->pixelMetric(QStyle::PM_MenuVMargin, 0, q); -
626 const int fw = q->style()->pixelMetric(QStyle::PM_MenuPanelWidth, 0, q); -
627 -
628 if (location == QMenuScroller::ScrollTop) {
never evaluated: location == QMenuScroller::ScrollTop
0
629 for(int i = 0, saccum = 0; i < actions.count(); i++) {
never evaluated: i < actions.count()
0
630 if (actions.at(i) == action) {
never evaluated: actions.at(i) == action
0
631 newOffset = topScroll - saccum; -
632 break;
never executed: break;
0
633 } -
634 saccum += actionRects.at(i).height(); -
635 }
never executed: }
0
636 } else {
never executed: }
0
637 for(int i = 0, saccum = 0; i < actions.count(); i++) {
never evaluated: i < actions.count()
0
638 saccum += actionRects.at(i).height(); -
639 if (actions.at(i) == action) {
never evaluated: actions.at(i) == action
0
640 if (location == QMenuScroller::ScrollCenter)
never evaluated: location == QMenuScroller::ScrollCenter
0
641 newOffset = ((q->height() / 2) - botScroll) - (saccum - topScroll);
never executed: newOffset = ((q->height() / 2) - botScroll) - (saccum - topScroll);
0
642 else -
643 newOffset = (q->height() - botScroll) - saccum;
never executed: newOffset = (q->height() - botScroll) - saccum;
0
644 break;
never executed: break;
0
645 } -
646 }
never executed: }
0
647 if(newOffset)
never evaluated: newOffset
0
648 newOffset -= fw * 2;
never executed: newOffset -= fw * 2;
0
649 }
never executed: }
0
650 -
651 -
652 uint newScrollFlags = QMenuScroller::ScrollNone; -
653 if (newOffset < 0)
never evaluated: newOffset < 0
0
654 newScrollFlags |= QMenuScroller::ScrollUp;
never executed: newScrollFlags |= QMenuScroller::ScrollUp;
0
655 int saccum = newOffset; -
656 for(int i = 0; i < actionRects.count(); i++) {
never evaluated: i < actionRects.count()
0
657 saccum += actionRects.at(i).height(); -
658 if (saccum > q->height()) {
never evaluated: saccum > q->height()
0
659 newScrollFlags |= QMenuScroller::ScrollDown; -
660 break;
never executed: break;
0
661 } -
662 }
never executed: }
0
663 -
664 if (!(newScrollFlags & QMenuScroller::ScrollDown) && (scroll->scrollFlags & QMenuScroller::ScrollDown)) {
never evaluated: !(newScrollFlags & QMenuScroller::ScrollDown)
never evaluated: (scroll->scrollFlags & QMenuScroller::ScrollDown)
0
665 newOffset = q->height() - (saccum - newOffset) - fw*2 - vmargin; -
666 }
never executed: }
0
667 -
668 if (!(newScrollFlags & QMenuScroller::ScrollUp) && (scroll->scrollFlags & QMenuScroller::ScrollUp)) {
never evaluated: !(newScrollFlags & QMenuScroller::ScrollUp)
never evaluated: (scroll->scrollFlags & QMenuScroller::ScrollUp)
0
669 newOffset = 0; -
670 }
never executed: }
0
671 -
672 if (newScrollFlags & QMenuScroller::ScrollUp)
never evaluated: newScrollFlags & QMenuScroller::ScrollUp
0
673 newOffset -= vmargin;
never executed: newOffset -= vmargin;
0
674 -
675 QRect screen = popupGeometry(q); -
676 const int desktopFrame = q->style()->pixelMetric(QStyle::PM_MenuDesktopFrameWidth, 0, q); -
677 if (q->height() < screen.height()-(desktopFrame*2)-1) {
never evaluated: q->height() < screen.height()-(desktopFrame*2)-1
0
678 QRect geom = q->geometry(); -
679 if (newOffset > scroll->scrollOffset && (scroll->scrollFlags & newScrollFlags & QMenuScroller::ScrollUp)) {
never evaluated: newOffset > scroll->scrollOffset
never evaluated: (scroll->scrollFlags & newScrollFlags & QMenuScroller::ScrollUp)
0
680 const int newHeight = geom.height()-(newOffset-scroll->scrollOffset); -
681 if(newHeight > geom.height())
never evaluated: newHeight > geom.height()
0
682 geom.setHeight(newHeight);
never executed: geom.setHeight(newHeight);
0
683 } else if(scroll->scrollFlags & newScrollFlags & QMenuScroller::ScrollDown) {
never executed: }
never evaluated: scroll->scrollFlags & newScrollFlags & QMenuScroller::ScrollDown
0
684 int newTop = geom.top() + (newOffset-scroll->scrollOffset); -
685 if (newTop < desktopFrame+screen.top())
never evaluated: newTop < desktopFrame+screen.top()
0
686 newTop = desktopFrame+screen.top();
never executed: newTop = desktopFrame+screen.top();
0
687 if (newTop < geom.top()) {
never evaluated: newTop < geom.top()
0
688 geom.setTop(newTop); -
689 newOffset = 0; -
690 newScrollFlags &= ~QMenuScroller::ScrollUp; -
691 }
never executed: }
0
692 }
never executed: }
0
693 if (geom.bottom() > screen.bottom() - desktopFrame)
never evaluated: geom.bottom() > screen.bottom() - desktopFrame
0
694 geom.setBottom(screen.bottom() - desktopFrame);
never executed: geom.setBottom(screen.bottom() - desktopFrame);
0
695 if (geom.top() < desktopFrame+screen.top())
never evaluated: geom.top() < desktopFrame+screen.top()
0
696 geom.setTop(desktopFrame+screen.top());
never executed: geom.setTop(desktopFrame+screen.top());
0
697 if (geom != q->geometry()) {
never evaluated: geom != q->geometry()
0
698 -
699 -
700 -
701 -
702 -
703 q->setGeometry(geom); -
704 }
never executed: }
0
705 }
never executed: }
0
706 -
707 -
708 const int delta = qMin(0, newOffset) - scroll->scrollOffset; -
709 if (!itemsDirty && delta) {
never evaluated: !itemsDirty
never evaluated: delta
0
710 -
711 for (int i = 0; i < actionRects.count(); ++i) {
never evaluated: i < actionRects.count()
0
712 QRect &current = actionRects[i]; -
713 current.moveTop(current.top() + delta); -
714 -
715 -
716 if (QWidget *w = widgetItems.value(actions.at(i)))
never evaluated: QWidget *w = widgetItems.value(actions.at(i))
0
717 w->setGeometry(current);
never executed: w->setGeometry(current);
0
718 }
never executed: }
0
719 }
never executed: }
0
720 scroll->scrollOffset += delta; -
721 scroll->scrollFlags = newScrollFlags; -
722 if (active)
never evaluated: active
0
723 setCurrentAction(action);
never executed: setCurrentAction(action);
0
724 -
725 q->update(); -
726}
never executed: }
0
727 -
728void QMenuPrivate::scrollMenu(QMenuScroller::ScrollLocation location, bool active) -
729{ -
730 QMenu * const q = q_func(); -
731 updateActionRects(); -
732 if(location == QMenuScroller::ScrollBottom) {
never evaluated: location == QMenuScroller::ScrollBottom
0
733 for(int i = actions.size()-1; i >= 0; --i) {
never evaluated: i >= 0
0
734 QAction *act = actions.at(i); -
735 if (actionRects.at(i).isNull())
never evaluated: actionRects.at(i).isNull()
0
736 continue;
never executed: continue;
0
737 if (!act->isSeparator() &&
never evaluated: !act->isSeparator()
0
738 (q->style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, 0, q)
never evaluated: q->style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, 0, q)
0
739 || act->isEnabled())) {
never evaluated: act->isEnabled()
0
740 if(scroll->scrollFlags & QMenuPrivate::QMenuScroller::ScrollDown)
never evaluated: scroll->scrollFlags & QMenuPrivate::QMenuScroller::ScrollDown
0
741 scrollMenu(act, QMenuPrivate::QMenuScroller::ScrollBottom, active);
never executed: scrollMenu(act, QMenuPrivate::QMenuScroller::ScrollBottom, active);
0
742 else if(active)
never evaluated: active
0
743 setCurrentAction(act, -1, QMenuPrivate::SelectedFromKeyboard);
never executed: setCurrentAction(act, -1, QMenuPrivate::SelectedFromKeyboard);
0
744 break;
never executed: break;
0
745 } -
746 }
never executed: }
0
747 } else if(location == QMenuScroller::ScrollTop) {
never executed: }
never evaluated: location == QMenuScroller::ScrollTop
0
748 for(int i = 0; i < actions.size(); ++i) {
never evaluated: i < actions.size()
0
749 QAction *act = actions.at(i); -
750 if (actionRects.at(i).isNull())
never evaluated: actionRects.at(i).isNull()
0
751 continue;
never executed: continue;
0
752 if (!act->isSeparator() &&
never evaluated: !act->isSeparator()
0
753 (q->style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, 0, q)
never evaluated: q->style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, 0, q)
0
754 || act->isEnabled())) {
never evaluated: act->isEnabled()
0
755 if(scroll->scrollFlags & QMenuPrivate::QMenuScroller::ScrollUp)
never evaluated: scroll->scrollFlags & QMenuPrivate::QMenuScroller::ScrollUp
0
756 scrollMenu(act, QMenuPrivate::QMenuScroller::ScrollTop, active);
never executed: scrollMenu(act, QMenuPrivate::QMenuScroller::ScrollTop, active);
0
757 else if(active)
never evaluated: active
0
758 setCurrentAction(act, -1, QMenuPrivate::SelectedFromKeyboard);
never executed: setCurrentAction(act, -1, QMenuPrivate::SelectedFromKeyboard);
0
759 break;
never executed: break;
0
760 } -
761 }
never executed: }
0
762 }
never executed: }
0
763} -
764 -
765 -
766void QMenuPrivate::scrollMenu(QMenuScroller::ScrollDirection direction, bool page, bool active) -
767{ -
768 QMenu * const q = q_func(); -
769 if (!scroll || !(scroll->scrollFlags & direction))
never evaluated: !scroll
never evaluated: !(scroll->scrollFlags & direction)
0
770 return;
never executed: return;
0
771 updateActionRects(); -
772 const int topScroll = (scroll->scrollFlags & QMenuScroller::ScrollUp) ? scrollerHeight() : 0;
never evaluated: (scroll->scrollFlags & QMenuScroller::ScrollUp)
0
773 const int botScroll = (scroll->scrollFlags & QMenuScroller::ScrollDown) ? scrollerHeight() : 0;
never evaluated: (scroll->scrollFlags & QMenuScroller::ScrollDown)
0
774 const int vmargin = q->style()->pixelMetric(QStyle::PM_MenuVMargin, 0, q); -
775 const int fw = q->style()->pixelMetric(QStyle::PM_MenuPanelWidth, 0, q); -
776 const int offset = topScroll ? topScroll-vmargin : 0;
never evaluated: topScroll
0
777 if (direction == QMenuScroller::ScrollUp) {
never evaluated: direction == QMenuScroller::ScrollUp
0
778 for(int i = 0, saccum = 0; i < actions.count(); i++) {
never evaluated: i < actions.count()
0
779 saccum -= actionRects.at(i).height(); -
780 if (saccum <= scroll->scrollOffset-offset) {
never evaluated: saccum <= scroll->scrollOffset-offset
0
781 scrollMenu(actions.at(i), page ? QMenuScroller::ScrollBottom : QMenuScroller::ScrollTop, active); -
782 break;
never executed: break;
0
783 } -
784 }
never executed: }
0
785 } else if (direction == QMenuScroller::ScrollDown) {
never executed: }
never evaluated: direction == QMenuScroller::ScrollDown
0
786 bool scrolled = false; -
787 for(int i = 0, saccum = 0; i < actions.count(); i++) {
never evaluated: i < actions.count()
0
788 const int iHeight = actionRects.at(i).height(); -
789 saccum -= iHeight; -
790 if (saccum <= scroll->scrollOffset-offset) {
never evaluated: saccum <= scroll->scrollOffset-offset
0
791 const int scrollerArea = q->height() - botScroll - fw*2; -
792 int visible = (scroll->scrollOffset-offset) - saccum; -
793 for(i++ ; i < actions.count(); i++) {
never evaluated: i < actions.count()
0
794 visible += actionRects.at(i).height(); -
795 if (visible > scrollerArea - topScroll) {
never evaluated: visible > scrollerArea - topScroll
0
796 scrolled = true; -
797 scrollMenu(actions.at(i), page ? QMenuScroller::ScrollTop : QMenuScroller::ScrollBottom, active); -
798 break;
never executed: break;
0
799 } -
800 }
never executed: }
0
801 break;
never executed: break;
0
802 } -
803 }
never executed: }
0
804 if(!scrolled) {
never evaluated: !scrolled
0
805 scroll->scrollFlags &= ~QMenuScroller::ScrollDown; -
806 q->update(); -
807 }
never executed: }
0
808 }
never executed: }
0
809} -
810 -
811 -
812 -
813bool QMenuPrivate::mouseEventTaken(QMouseEvent *e) -
814{ -
815 QMenu * const q = q_func(); -
816 QPoint pos = q->mapFromGlobal(e->globalPos()); -
817 if (scroll && !activeMenu) {
partially evaluated: scroll
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:16
never evaluated: !activeMenu
0-16
818 bool isScroll = false; -
819 if (pos.x() >= 0 && pos.x() < q->width()) {
never evaluated: pos.x() >= 0
never evaluated: pos.x() < q->width()
0
820 for(int dir = QMenuScroller::ScrollUp; dir <= QMenuScroller::ScrollDown; dir = dir << 1) {
never evaluated: dir <= QMenuScroller::ScrollDown
0
821 if (scroll->scrollFlags & dir) {
never evaluated: scroll->scrollFlags & dir
0
822 if (dir == QMenuScroller::ScrollUp)
never evaluated: dir == QMenuScroller::ScrollUp
0
823 isScroll = (pos.y() <= scrollerHeight());
never executed: isScroll = (pos.y() <= scrollerHeight());
0
824 else if (dir == QMenuScroller::ScrollDown)
never evaluated: dir == QMenuScroller::ScrollDown
0
825 isScroll = (pos.y() >= q->height() - scrollerHeight());
never executed: isScroll = (pos.y() >= q->height() - scrollerHeight());
0
826 if (isScroll) {
never evaluated: isScroll
0
827 scroll->scrollDirection = dir; -
828 break;
never executed: break;
0
829 } -
830 }
never executed: }
0
831 }
never executed: }
0
832 }
never executed: }
0
833 if (isScroll) {
never evaluated: isScroll
0
834 scroll->scrollTimer.start(50, q); -
835 return true;
never executed: return true;
0
836 } else { -
837 scroll->scrollTimer.stop(); -
838 }
never executed: }
0
839 } -
840 -
841 if (tearoff) {
evaluated: tearoff
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:14
2-14
842 QRect tearRect(0, 0, q->width(), q->style()->pixelMetric(QStyle::PM_MenuTearoffHeight, 0, q)); -
843 if (scroll && scroll->scrollFlags & QMenuPrivate::QMenuScroller::ScrollUp)
partially evaluated: scroll
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
never evaluated: scroll->scrollFlags & QMenuPrivate::QMenuScroller::ScrollUp
0-2
844 tearRect.translate(0, scrollerHeight());
never executed: tearRect.translate(0, scrollerHeight());
0
845 q->update(tearRect); -
846 if (tearRect.contains(pos) && hasMouseMoved(e->globalPos())) {
partially evaluated: tearRect.contains(pos)
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
partially evaluated: hasMouseMoved(e->globalPos())
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
847 setCurrentAction(0); -
848 tearoffHighlighted = 1; -
849 if (e->type() == QEvent::MouseButtonRelease) {
evaluated: e->type() == QEvent::MouseButtonRelease
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
850 if (!tornPopup)
partially evaluated: !tornPopup
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
851 tornPopup = new QTornOffMenu(q);
executed: tornPopup = new QTornOffMenu(q);
Execution Count:1
1
852 tornPopup->setGeometry(q->geometry()); -
853 tornPopup->show(); -
854 hideUpToMenuBar(); -
855 }
executed: }
Execution Count:1
1
856 return true;
executed: return true;
Execution Count:2
2
857 } -
858 tearoffHighlighted = 0; -
859 }
never executed: }
0
860 -
861 if (q->frameGeometry().contains(e->globalPos()))
evaluated: q->frameGeometry().contains(e->globalPos())
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:1
1-13
862 return false;
executed: return false;
Execution Count:13
13
863 -
864 for(QWidget *caused = causedPopup.widget; caused;) {
partially evaluated: caused
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
865 bool passOnEvent = false; -
866 QWidget *next_widget = 0; -
867 QPoint cpos = caused->mapFromGlobal(e->globalPos()); -
868 -
869 if (QMenuBar *mb = qobject_cast<QMenuBar*>(caused)) {
partially evaluated: QMenuBar *mb = qobject_cast<QMenuBar*>(caused)
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
870 passOnEvent = mb->rect().contains(cpos); -
871 } else
executed: }
Execution Count:1
1
872 -
873 if (QMenu *m = qobject_cast<QMenu*>(caused)) {
never evaluated: QMenu *m = qobject_cast<QMenu*>(caused)
0
874 passOnEvent = m->rect().contains(cpos); -
875 next_widget = m->d_func()->causedPopup.widget; -
876 }
never executed: }
0
877 if (passOnEvent) {
partially evaluated: passOnEvent
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
878 if(e->type() != QEvent::MouseButtonRelease || mouseDown == caused) {
partially evaluated: e->type() != QEvent::MouseButtonRelease
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
never evaluated: mouseDown == caused
0-1
879 QMouseEvent new_e(e->type(), cpos, caused->mapTo(caused->topLevelWidget(), cpos), e->screenPos(), -
880 e->button(), e->buttons(), e->modifiers()); -
881 QApplication::sendEvent(caused, &new_e); -
882 return true;
executed: return true;
Execution Count:1
1
883 } -
884 }
never executed: }
0
885 if (!next_widget)
never evaluated: !next_widget
0
886 break;
never executed: break;
0
887 caused = next_widget; -
888 }
never executed: }
0
889 return false;
never executed: return false;
0
890} -
891 -
892void QMenuPrivate::activateCausedStack(const QList<QPointer<QWidget> > &causedStack, QAction *action, QAction::ActionEvent action_e, bool self) -
893{ -
894 QBoolBlocker guard(activationRecursionGuard); -
895 if(self)
evaluated: self
TRUEFALSE
yes
Evaluation Count:69
yes
Evaluation Count:14
14-69
896 action->activate(action_e);
executed: action->activate(action_e);
Execution Count:69
69
897 -
898 for(int i = 0; i < causedStack.size(); ++i) {
evaluated: i < causedStack.size()
TRUEFALSE
yes
Evaluation Count:45
yes
Evaluation Count:47
45-47
899 QPointer<QWidget> widget = causedStack.at(i); -
900 if (!widget)
partially evaluated: !widget
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:45
0-45
901 continue;
never executed: continue;
0
902 -
903 if (QMenu *qmenu = qobject_cast<QMenu*>(widget)) {
evaluated: QMenu *qmenu = qobject_cast<QMenu*>(widget)
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:39
6-39
904 widget = qmenu->d_func()->causedPopup.widget; -
905 if (action_e == QAction::Trigger) {
evaluated: action_e == QAction::Trigger
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:5
1-5
906 qmenu->triggered(action); -
907 } else if (action_e == QAction::Hover) {
executed: }
Execution Count:1
partially evaluated: action_e == QAction::Hover
TRUEFALSE
yes
Evaluation Count:5
no
Evaluation Count:0
0-5
908 qmenu->hovered(action); -
909 }
executed: }
Execution Count:5
5
910 -
911 } else if (QMenuBar *qmenubar = qobject_cast<QMenuBar*>(widget)) {
evaluated: QMenuBar *qmenubar = qobject_cast<QMenuBar*>(widget)
TRUEFALSE
yes
Evaluation Count:36
yes
Evaluation Count:3
3-36
912 if (action_e == QAction::Trigger) {
evaluated: action_e == QAction::Trigger
TRUEFALSE
yes
Evaluation Count:15
yes
Evaluation Count:21
15-21
913 qmenubar->triggered(action); -
914 } else if (action_e == QAction::Hover) {
executed: }
Execution Count:15
partially evaluated: action_e == QAction::Hover
TRUEFALSE
yes
Evaluation Count:21
no
Evaluation Count:0
0-21
915 qmenubar->hovered(action); -
916 }
executed: }
Execution Count:21
21
917 break;
executed: break;
Execution Count:36
36
918 -
919 } -
920 } -
921}
executed: }
Execution Count:83
83
922 -
923void QMenuPrivate::activateAction(QAction *action, QAction::ActionEvent action_e, bool self) -
924{ -
925 QMenu * const q = q_func(); -
926 -
927 bool inWhatsThisMode = QWhatsThis::inWhatsThisMode(); -
928 -
929 if (!action || !q->isEnabled()
partially evaluated: !action
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:70
partially evaluated: !q->isEnabled()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:70
0-70
930 || (action_e == QAction::Trigger
evaluated: action_e == QAction::Trigger
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:57
13-57
931 -
932 && !inWhatsThisMode
partially evaluated: !inWhatsThisMode
TRUEFALSE
yes
Evaluation Count:13
no
Evaluation Count:0
0-13
933 -
934 && (action->isSeparator() ||!action->isEnabled())))
partially evaluated: action->isSeparator()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:13
evaluated: !action->isEnabled()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:12
0-13
935 return;
executed: return;
Execution Count:1
1
936 -
937 -
938 -
939 -
940 const QList<QPointer<QWidget> > causedStack = calcCausedStack(); -
941 if (action_e == QAction::Trigger) {
evaluated: action_e == QAction::Trigger
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:57
12-57
942 -
943 if (!inWhatsThisMode)
partially evaluated: !inWhatsThisMode
TRUEFALSE
yes
Evaluation Count:12
no
Evaluation Count:0
0-12
944 actionAboutToTrigger = action;
executed: actionAboutToTrigger = action;
Execution Count:12
12
945 -
946 -
947 if (q->testAttribute(Qt::WA_DontShowOnScreen)) {
partially evaluated: q->testAttribute(Qt::WA_DontShowOnScreen)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:12
0-12
948 hideUpToMenuBar(); -
949 } else {
never executed: }
0
950 for(QWidget *widget = QApplication::activePopupWidget(); widget; ) {
evaluated: widget
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:12
11-12
951 if (QMenu *qmenu = qobject_cast<QMenu*>(widget)) {
partially evaluated: QMenu *qmenu = qobject_cast<QMenu*>(widget)
TRUEFALSE
yes
Evaluation Count:11
no
Evaluation Count:0
0-11
952 if(qmenu == q)
partially evaluated: qmenu == q
TRUEFALSE
yes
Evaluation Count:11
no
Evaluation Count:0
0-11
953 hideUpToMenuBar();
executed: hideUpToMenuBar();
Execution Count:11
11
954 widget = qmenu->d_func()->causedPopup.widget; -
955 } else {
executed: }
Execution Count:11
11
956 break;
never executed: break;
0
957 } -
958 } -
959 }
executed: }
Execution Count:12
12
960 -
961 -
962 if (inWhatsThisMode) {
partially evaluated: inWhatsThisMode
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:12
0-12
963 QString s = action->whatsThis(); -
964 if (s.isEmpty())
never evaluated: s.isEmpty()
0
965 s = whatsThis;
never executed: s = whatsThis;
0
966 QWhatsThis::showText(q->mapToGlobal(actionRect(action).center()), s, q); -
967 return;
never executed: return;
0
968 } -
969 -
970 }
executed: }
Execution Count:12
12
971 -
972 -
973 activateCausedStack(causedStack, action, action_e, self); -
974 -
975 -
976 if (action_e == QAction::Hover) {
evaluated: action_e == QAction::Hover
TRUEFALSE
yes
Evaluation Count:57
yes
Evaluation Count:12
12-57
977 -
978 if (QAccessible::isActive()) {
evaluated: QAccessible::isActive()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:56
1-56
979 int actionIndex = indexOf(action); -
980 QAccessibleEvent focusEvent(q, QAccessible::Focus); -
981 focusEvent.setChild(actionIndex); -
982 QAccessible::updateAccessibility(&focusEvent); -
983 QAccessibleEvent selectionEvent(q, QAccessible::Selection); -
984 focusEvent.setChild(actionIndex); -
985 QAccessible::updateAccessibility(&selectionEvent); -
986 }
executed: }
Execution Count:1
1
987 -
988 action->showStatusText(topCausedWidget()); -
989 } else {
executed: }
Execution Count:57
57
990 actionAboutToTrigger = 0; -
991 }
executed: }
Execution Count:12
12
992} -
993 -
994void QMenuPrivate::_q_actionTriggered() -
995{ -
996 QMenu * const q = q_func(); -
997 if (QAction *action = qobject_cast<QAction *>(q->sender())) {
partially evaluated: QAction *action = qobject_cast<QAction *>(q->sender())
TRUEFALSE
yes
Evaluation Count:27
no
Evaluation Count:0
0-27
998 QPointer<QAction> actionGuard = action; -
999 q->triggered(action); -
1000 if (!activationRecursionGuard && actionGuard) {
evaluated: !activationRecursionGuard
TRUEFALSE
yes
Evaluation Count:15
yes
Evaluation Count:12
evaluated: actionGuard
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:1
1-15
1001 -
1002 -
1003 QList< QPointer<QWidget> > list; -
1004 for(QWidget *widget = q->parentWidget(); widget; ) {
evaluated: widget
TRUEFALSE
yes
Evaluation Count:25
yes
Evaluation Count:1
1-25
1005 if (qobject_cast<QMenu*>(widget)
evaluated: qobject_cast<QMenu*>(widget)
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:24
1-24
1006 -
1007 || qobject_cast<QMenuBar*>(widget)
evaluated: qobject_cast<QMenuBar*>(widget)
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:13
11-13
1008 -
1009 ) { -
1010 list.append(widget); -
1011 widget = widget->parentWidget(); -
1012 } else {
executed: }
Execution Count:12
12
1013 break;
executed: break;
Execution Count:13
13
1014 } -
1015 } -
1016 activateCausedStack(list, action, QAction::Trigger, false); -
1017 }
executed: }
Execution Count:14
14
1018 }
executed: }
Execution Count:27
27
1019}
executed: }
Execution Count:27
27
1020 -
1021void QMenuPrivate::_q_actionHovered() -
1022{ -
1023 QMenu * const q = q_func(); -
1024 if (QAction * action = qobject_cast<QAction *>(q->sender())) {
partially evaluated: QAction * action = qobject_cast<QAction *>(q->sender())
TRUEFALSE
yes
Evaluation Count:71
no
Evaluation Count:0
0-71
1025 q->hovered(action); -
1026 }
executed: }
Execution Count:71
71
1027}
executed: }
Execution Count:71
71
1028 -
1029bool QMenuPrivate::hasMouseMoved(const QPoint &globalPos) -
1030{ -
1031 -
1032 -
1033 -
1034 return motions > 6 || 2
1035 QApplication::startDragDistance() < (mousePopupPos - globalPos).manhattanLength();
executed: return motions > 6 || QApplication::startDragDistance() < (mousePopupPos - globalPos).manhattanLength();
Execution Count:2
2
1036} -
1037void QMenu::initStyleOption(QStyleOptionMenuItem *option, const QAction *action) const -
1038{ -
1039 if (!option || !action)
partially evaluated: !option
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2008
partially evaluated: !action
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2008
0-2008
1040 return;
never executed: return;
0
1041 -
1042 const QMenuPrivate * const d = d_func(); -
1043 option->initFrom(this); -
1044 option->palette = palette(); -
1045 option->state = QStyle::State_None; -
1046 -
1047 if (window()->isActiveWindow())
evaluated: window()->isActiveWindow()
TRUEFALSE
yes
Evaluation Count:1360
yes
Evaluation Count:648
648-1360
1048 option->state |= QStyle::State_Active;
executed: option->state |= QStyle::State_Active;
Execution Count:1360
1360
1049 if (isEnabled() && action->isEnabled()
partially evaluated: isEnabled()
TRUEFALSE
yes
Evaluation Count:2008
no
Evaluation Count:0
evaluated: action->isEnabled()
TRUEFALSE
yes
Evaluation Count:1954
yes
Evaluation Count:54
0-2008
1050 && (!action->menu() || action->menu()->isEnabled()))
evaluated: !action->menu()
TRUEFALSE
yes
Evaluation Count:1846
yes
Evaluation Count:108
partially evaluated: action->menu()->isEnabled()
TRUEFALSE
yes
Evaluation Count:108
no
Evaluation Count:0
0-1846
1051 option->state |= QStyle::State_Enabled;
executed: option->state |= QStyle::State_Enabled;
Execution Count:1954
1954
1052 else -
1053 option->palette.setCurrentColorGroup(QPalette::Disabled);
executed: option->palette.setCurrentColorGroup(QPalette::Disabled);
Execution Count:54
54
1054 -
1055 option->font = action->font().resolve(font()); -
1056 option->fontMetrics = QFontMetrics(option->font); -
1057 -
1058 if (d->currentAction && d->currentAction == action && !d->currentAction->isSeparator()) {
evaluated: d->currentAction
TRUEFALSE
yes
Evaluation Count:38
yes
Evaluation Count:1970
evaluated: d->currentAction == action
TRUEFALSE
yes
Evaluation Count:16
yes
Evaluation Count:22
partially evaluated: !d->currentAction->isSeparator()
TRUEFALSE
yes
Evaluation Count:16
no
Evaluation Count:0
0-1970
1059 option->state |= QStyle::State_Selected -
1060 | (d->mouseDown ? QStyle::State_Sunken : QStyle::State_None); -
1061 }
executed: }
Execution Count:16
16
1062 -
1063 option->menuHasCheckableItems = d->hasCheckableItems; -
1064 if (!action->isCheckable()) {
evaluated: !action->isCheckable()
TRUEFALSE
yes
Evaluation Count:1988
yes
Evaluation Count:20
20-1988
1065 option->checkType = QStyleOptionMenuItem::NotCheckable; -
1066 } else {
executed: }
Execution Count:1988
1988
1067 option->checkType = (action->actionGroup() && action->actionGroup()->isExclusive())
partially evaluated: action->actionGroup()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:20
never evaluated: action->actionGroup()->isExclusive()
0-20
1068 ? QStyleOptionMenuItem::Exclusive : QStyleOptionMenuItem::NonExclusive; -
1069 option->checked = action->isChecked(); -
1070 }
executed: }
Execution Count:20
20
1071 if (action->menu())
evaluated: action->menu()
TRUEFALSE
yes
Evaluation Count:108
yes
Evaluation Count:1900
108-1900
1072 option->menuItemType = QStyleOptionMenuItem::SubMenu;
executed: option->menuItemType = QStyleOptionMenuItem::SubMenu;
Execution Count:108
108
1073 else if (action->isSeparator())
evaluated: action->isSeparator()
TRUEFALSE
yes
Evaluation Count:59
yes
Evaluation Count:1841
59-1841
1074 option->menuItemType = QStyleOptionMenuItem::Separator;
executed: option->menuItemType = QStyleOptionMenuItem::Separator;
Execution Count:59
59
1075 else if (d->defaultAction == action)
partially evaluated: d->defaultAction == action
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1841
0-1841
1076 option->menuItemType = QStyleOptionMenuItem::DefaultItem;
never executed: option->menuItemType = QStyleOptionMenuItem::DefaultItem;
0
1077 else -
1078 option->menuItemType = QStyleOptionMenuItem::Normal;
executed: option->menuItemType = QStyleOptionMenuItem::Normal;
Execution Count:1841
1841
1079 if (action->isIconVisibleInMenu())
partially evaluated: action->isIconVisibleInMenu()
TRUEFALSE
yes
Evaluation Count:2008
no
Evaluation Count:0
0-2008
1080 option->icon = action->icon();
executed: option->icon = action->icon();
Execution Count:2008
2008
1081 QString textAndAccel = action->text(); -
1082 -
1083 if (textAndAccel.indexOf(QLatin1Char('\t')) == -1) {
evaluated: textAndAccel.indexOf(QLatin1Char('\t')) == -1
TRUEFALSE
yes
Evaluation Count:1976
yes
Evaluation Count:32
32-1976
1084 QKeySequence seq = action->shortcut(); -
1085 if (!seq.isEmpty())
evaluated: !seq.isEmpty()
TRUEFALSE
yes
Evaluation Count:100
yes
Evaluation Count:1876
100-1876
1086 textAndAccel += QLatin1Char('\t') + seq.toString(QKeySequence::NativeText);
executed: textAndAccel += QLatin1Char('\t') + seq.toString(QKeySequence::NativeText);
Execution Count:100
100
1087 }
executed: }
Execution Count:1976
1976
1088 -
1089 option->text = textAndAccel; -
1090 option->tabWidth = d->tabWidth; -
1091 option->maxIconWidth = d->maxIconWidth; -
1092 option->menuRect = rect(); -
1093}
executed: }
Execution Count:2008
2008
1094QMenu::QMenu(QWidget *parent) -
1095 : QWidget(*new QMenuPrivate, parent, Qt::Popup) -
1096{ -
1097 QMenuPrivate * const d = d_func(); -
1098 d->init(); -
1099}
executed: }
Execution Count:194
194
1100QMenu::QMenu(const QString &title, QWidget *parent) -
1101 : QWidget(*new QMenuPrivate, parent, Qt::Popup) -
1102{ -
1103 QMenuPrivate * const d = d_func(); -
1104 d->init(); -
1105 d->menuAction->setText(title); -
1106}
executed: }
Execution Count:77
77
1107 -
1108 -
1109 -
1110QMenu::QMenu(QMenuPrivate &dd, QWidget *parent) -
1111 : QWidget(dd, parent, Qt::Popup) -
1112{ -
1113 QMenuPrivate * const d = d_func(); -
1114 d->init(); -
1115}
executed: }
Execution Count:1
1
1116 -
1117 -
1118 -
1119 -
1120QMenu::~QMenu() -
1121{ -
1122 QMenuPrivate * const d = d_func(); -
1123 if (!d->widgetItems.isEmpty()) {
evaluated: !d->widgetItems.isEmpty()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:270
2-270
1124 QHash<QAction *, QWidget *>::iterator it = d->widgetItems.begin(); -
1125 for (; it != d->widgetItems.end(); ++it) {
evaluated: it != d->widgetItems.end()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:2
2
1126 if (QWidget *widget = it.value()) {
partially evaluated: QWidget *widget = it.value()
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
1127 QWidgetAction *action = static_cast<QWidgetAction *>(it.key()); -
1128 action->releaseWidget(widget); -
1129 *it = 0; -
1130 }
executed: }
Execution Count:2
2
1131 }
executed: }
Execution Count:2
2
1132 }
executed: }
Execution Count:2
2
1133 -
1134 if (d->eventLoop)
evaluated: d->eventLoop
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:270
2-270
1135 d->eventLoop->exit();
executed: d->eventLoop->exit();
Execution Count:2
2
1136 hideTearOffMenu(); -
1137}
executed: }
Execution Count:272
272
1138QAction *QMenu::addAction(const QString &text) -
1139{ -
1140 QAction *ret = new QAction(text, this); -
1141 addAction(ret); -
1142 return ret;
executed: return ret;
Execution Count:551
551
1143} -
1144QAction *QMenu::addAction(const QIcon &icon, const QString &text) -
1145{ -
1146 QAction *ret = new QAction(icon, text, this); -
1147 addAction(ret); -
1148 return ret;
never executed: return ret;
0
1149} -
1150QAction *QMenu::addAction(const QString &text, const QObject *receiver, const char* member, const QKeySequence &shortcut) -
1151{ -
1152 QAction *action = new QAction(text, this); -
1153 -
1154 -
1155 -
1156 action->setShortcut(shortcut); -
1157 -
1158 QObject::connect(action, "2""triggered(bool)", receiver, member); -
1159 addAction(action); -
1160 return action;
executed: return action;
Execution Count:783
783
1161} -
1162QAction *QMenu::addAction(const QIcon &icon, const QString &text, const QObject *receiver, -
1163 const char* member, const QKeySequence &shortcut) -
1164{ -
1165 QAction *action = new QAction(icon, text, this); -
1166 -
1167 -
1168 -
1169 action->setShortcut(shortcut); -
1170 -
1171 QObject::connect(action, "2""triggered(bool)", receiver, member); -
1172 addAction(action); -
1173 return action;
executed: return action;
Execution Count:1
1
1174} -
1175QAction *QMenu::addMenu(QMenu *menu) -
1176{ -
1177 QAction *action = menu->menuAction(); -
1178 addAction(action); -
1179 return action;
executed: return action;
Execution Count:8
8
1180} -
1181 -
1182 -
1183 -
1184 -
1185 -
1186 -
1187 -
1188QMenu *QMenu::addMenu(const QString &title) -
1189{ -
1190 QMenu *menu = new QMenu(title, this); -
1191 addAction(menu->menuAction()); -
1192 return menu;
executed: return menu;
Execution Count:3
3
1193} -
1194 -
1195 -
1196 -
1197 -
1198 -
1199 -
1200 -
1201QMenu *QMenu::addMenu(const QIcon &icon, const QString &title) -
1202{ -
1203 QMenu *menu = new QMenu(title, this); -
1204 menu->setIcon(icon); -
1205 addAction(menu->menuAction()); -
1206 return menu;
never executed: return menu;
0
1207} -
1208QAction *QMenu::addSeparator() -
1209{ -
1210 QAction *action = new QAction(this); -
1211 action->setSeparator(true); -
1212 addAction(action); -
1213 return action;
executed: return action;
Execution Count:123
123
1214} -
1215 -
1216 -
1217 -
1218 -
1219 -
1220 -
1221 -
1222QAction *QMenu::insertMenu(QAction *before, QMenu *menu) -
1223{ -
1224 QAction *action = menu->menuAction(); -
1225 insertAction(before, action); -
1226 return action;
never executed: return action;
0
1227} -
1228QAction *QMenu::insertSeparator(QAction *before) -
1229{ -
1230 QAction *action = new QAction(this); -
1231 action->setSeparator(true); -
1232 insertAction(before, action); -
1233 return action;
never executed: return action;
0
1234} -
1235void QMenu::setDefaultAction(QAction *act) -
1236{ -
1237 d_func()->defaultAction = act; -
1238}
executed: }
Execution Count:2
2
1239 -
1240 -
1241 -
1242 -
1243 -
1244 -
1245QAction *QMenu::defaultAction() const -
1246{ -
1247 return d_func()->defaultAction;
executed: return d_func()->defaultAction;
Execution Count:2
2
1248} -
1249void QMenu::setTearOffEnabled(bool b) -
1250{ -
1251 QMenuPrivate * const d = d_func(); -
1252 if (d->tearoff == b)
partially evaluated: d->tearoff == b
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
1253 return;
never executed: return;
0
1254 if (!b)
partially evaluated: !b
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
1255 hideTearOffMenu();
never executed: hideTearOffMenu();
0
1256 d->tearoff = b; -
1257 -
1258 d->itemsDirty = true; -
1259 if (isVisible())
partially evaluated: isVisible()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
1260 resize(sizeHint());
never executed: resize(sizeHint());
0
1261}
executed: }
Execution Count:1
1
1262 -
1263bool QMenu::isTearOffEnabled() const -
1264{ -
1265 return d_func()->tearoff;
executed: return d_func()->tearoff;
Execution Count:2
2
1266} -
1267bool QMenu::isTearOffMenuVisible() const -
1268{ -
1269 if (d_func()->tornPopup)
evaluated: d_func()->tornPopup
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:1
1-4
1270 return d_func()->tornPopup->isVisible();
executed: return d_func()->tornPopup->isVisible();
Execution Count:4
4
1271 return false;
executed: return false;
Execution Count:1
1
1272} -
1273 -
1274 -
1275 -
1276 -
1277 -
1278 -
1279 -
1280void QMenu::hideTearOffMenu() -
1281{ -
1282 if (QWidget *w = d_func()->tornPopup)
evaluated: QWidget *w = d_func()->tornPopup
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:271
2-271
1283 w->close();
executed: w->close();
Execution Count:2
2
1284}
executed: }
Execution Count:273
273
1285 -
1286 -
1287 -
1288 -
1289 -
1290void QMenu::setActiveAction(QAction *act) -
1291{ -
1292 QMenuPrivate * const d = d_func(); -
1293 d->setCurrentAction(act, 0); -
1294 if (d->scroll)
partially evaluated: d->scroll
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:12
0-12
1295 d->scrollMenu(act, QMenuPrivate::QMenuScroller::ScrollCenter);
never executed: d->scrollMenu(act, QMenuPrivate::QMenuScroller::ScrollCenter);
0
1296}
executed: }
Execution Count:12
12
1297 -
1298 -
1299 -
1300 -
1301 -
1302 -
1303QAction *QMenu::activeAction() const -
1304{ -
1305 return d_func()->currentAction;
executed: return d_func()->currentAction;
Execution Count:133
133
1306} -
1307bool QMenu::isEmpty() const -
1308{ -
1309 bool ret = true; -
1310 for(int i = 0; ret && i < actions().count(); ++i) {
evaluated: ret
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:2
partially evaluated: i < actions().count()
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
1311 const QAction *action = actions().at(i); -
1312 if (!action->isSeparator() && action->isVisible()) {
partially evaluated: !action->isSeparator()
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
partially evaluated: action->isVisible()
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
1313 ret = false; -
1314 }
executed: }
Execution Count:2
2
1315 }
executed: }
Execution Count:2
2
1316 return ret;
executed: return ret;
Execution Count:2
2
1317} -
1318 -
1319 -
1320 -
1321 -
1322 -
1323 -
1324 -
1325void QMenu::clear() -
1326{ -
1327 QList<QAction*> acts = actions(); -
1328 -
1329 for(int i = 0; i < acts.size(); i++) {
evaluated: i < acts.size()
TRUEFALSE
yes
Evaluation Count:214
yes
Evaluation Count:100
100-214
1330 removeAction(acts[i]); -
1331 if (acts[i]->parent() == this && acts[i]->d_func()->widgets.isEmpty())
evaluated: acts[i]->parent() == this
TRUEFALSE
yes
Evaluation Count:23
yes
Evaluation Count:191
partially evaluated: acts[i]->d_func()->widgets.isEmpty()
TRUEFALSE
yes
Evaluation Count:23
no
Evaluation Count:0
0-191
1332 delete acts[i];
executed: delete acts[i];
Execution Count:23
23
1333 }
executed: }
Execution Count:214
214
1334}
executed: }
Execution Count:100
100
1335int QMenu::columnCount() const -
1336{ -
1337 return d_func()->ncols;
executed: return d_func()->ncols;
Execution Count:33
33
1338} -
1339 -
1340 -
1341 -
1342 -
1343QAction *QMenu::actionAt(const QPoint &pt) const -
1344{ -
1345 if (QAction *ret = d_func()->actionAt(pt))
never evaluated: QAction *ret = d_func()->actionAt(pt)
0
1346 return ret;
never executed: return ret;
0
1347 return 0;
never executed: return 0;
0
1348} -
1349 -
1350 -
1351 -
1352 -
1353QRect QMenu::actionGeometry(QAction *act) const -
1354{ -
1355 return d_func()->actionRect(act);
executed: return d_func()->actionRect(act);
Execution Count:12
12
1356} -
1357 -
1358 -
1359 -
1360 -
1361QSize QMenu::sizeHint() const -
1362{ -
1363 const QMenuPrivate * const d = d_func(); -
1364 d->updateActionRects(); -
1365 -
1366 QSize s; -
1367 for (int i = 0; i < d->actionRects.count(); ++i) {
evaluated: i < d->actionRects.count()
TRUEFALSE
yes
Evaluation Count:1542
yes
Evaluation Count:246
246-1542
1368 const QRect &rect = d->actionRects.at(i); -
1369 if (rect.isNull())
evaluated: rect.isNull()
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:1535
7-1535
1370 continue;
executed: continue;
Execution Count:7
7
1371 if (rect.bottom() >= s.height())
evaluated: rect.bottom() >= s.height()
TRUEFALSE
yes
Evaluation Count:1534
yes
Evaluation Count:1
1-1534
1372 s.setHeight(rect.y() + rect.height());
executed: s.setHeight(rect.y() + rect.height());
Execution Count:1534
1534
1373 if (rect.right() >= s.width())
evaluated: rect.right() >= s.width()
TRUEFALSE
yes
Evaluation Count:222
yes
Evaluation Count:1313
222-1313
1374 s.setWidth(rect.x() + rect.width());
executed: s.setWidth(rect.x() + rect.width());
Execution Count:222
222
1375 }
executed: }
Execution Count:1535
1535
1376 -
1377 -
1378 -
1379 QStyleOption opt(0); -
1380 opt.init(this); -
1381 const int fw = style()->pixelMetric(QStyle::PM_MenuPanelWidth, &opt, this); -
1382 s.rwidth() += style()->pixelMetric(QStyle::PM_MenuHMargin, &opt, this) + fw + d->rightmargin; -
1383 s.rheight() += style()->pixelMetric(QStyle::PM_MenuVMargin, &opt, this) + fw + d->bottommargin; -
1384 -
1385 return style()->sizeFromContents(QStyle::CT_Menu, &opt, 246
1386 s.expandedTo(QApplication::globalStrut()), this);
executed: return style()->sizeFromContents(QStyle::CT_Menu, &opt, s.expandedTo(QApplication::globalStrut()), this);
Execution Count:246
246
1387} -
1388void QMenu::popup(const QPoint &p, QAction *atAction) -
1389{ -
1390 QMenuPrivate * const d = d_func(); -
1391 if (d->scroll) {
partially evaluated: d->scroll
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:61
0-61
1392 if (d->scroll->scrollOffset)
never evaluated: d->scroll->scrollOffset
0
1393 d->itemsDirty = 1;
never executed: d->itemsDirty = 1;
0
1394 d->scroll->scrollOffset = 0; -
1395 d->scroll->scrollFlags = QMenuPrivate::QMenuScroller::ScrollNone; -
1396 }
never executed: }
0
1397 d->tearoffHighlighted = 0; -
1398 d->motions = 0; -
1399 d->doChildEffects = true; -
1400 d->updateLayoutDirection(); -
1401 -
1402 -
1403 -
1404 -
1405 setAttribute(Qt::WA_X11NetWmWindowTypeDropDownMenu, qobject_cast<QMenuBar *>(d->topCausedWidget()) != 0); -
1406 -
1407 -
1408 ensurePolished(); -
1409 aboutToShow(); -
1410 const bool actionListChanged = d->itemsDirty; -
1411 d->updateActionRects(); -
1412 QPoint pos; -
1413 QPushButton *causedButton = qobject_cast<QPushButton*>(d->causedPopup.widget); -
1414 if (actionListChanged && causedButton)
evaluated: actionListChanged
TRUEFALSE
yes
Evaluation Count:23
yes
Evaluation Count:38
evaluated: causedButton
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:21
2-38
1415 pos = QPushButtonPrivate::get(causedButton)->adjustedMenuPosition();
executed: pos = QPushButtonPrivate::get(causedButton)->adjustedMenuPosition();
Execution Count:2
2
1416 else -
1417 pos = p;
executed: pos = p;
Execution Count:59
59
1418 -
1419 QSize size = sizeHint(); -
1420 QRect screen; -
1421 -
1422 bool isEmbedded = !bypassGraphicsProxyWidget(this) && d->nearestGraphicsProxyWidget(this);
partially evaluated: !bypassGraphicsProxyWidget(this)
TRUEFALSE
yes
Evaluation Count:61
no
Evaluation Count:0
partially evaluated: d->nearestGraphicsProxyWidget(this)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:61
0-61
1423 if (isEmbedded)
partially evaluated: isEmbedded
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:61
0-61
1424 screen = d->popupGeometry(this);
never executed: screen = d->popupGeometry(this);
0
1425 else -
1426 -
1427 screen = d->popupGeometry(QApplication::desktop()->screenNumber(p));
executed: screen = d->popupGeometry(QApplication::desktop()->screenNumber(p));
Execution Count:61
61
1428 const int desktopFrame = style()->pixelMetric(QStyle::PM_MenuDesktopFrameWidth, 0, this); -
1429 bool adjustToDesktop = !window()->testAttribute(Qt::WA_DontShowOnScreen); -
1430 -
1431 -
1432 if (size.height() > screen.height() || size.width() > screen.width()) {
partially evaluated: size.height() > screen.height()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:61
partially evaluated: size.width() > screen.width()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:61
0-61
1433 size = d->adjustMenuSizeForScreen(screen); -
1434 adjustToDesktop = true; -
1435 }
never executed: }
0
1436 -
1437 if (d->ncols >1 && size.height() < screen.height()) {
partially evaluated: d->ncols >1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:61
never evaluated: size.height() < screen.height()
0-61
1438 size = d->adjustMenuSizeForScreen(screen); -
1439 adjustToDesktop = true; -
1440 }
never executed: }
0
1441 if (d->ncols > 1) {
partially evaluated: d->ncols > 1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:61
0-61
1442 pos.setY(screen.top() + desktopFrame); -
1443 } else if (atAction) {
never executed: }
partially evaluated: atAction
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:61
0-61
1444 for (int i = 0, above_height = 0; i < d->actions.count(); i++) {
never evaluated: i < d->actions.count()
0
1445 QAction *action = d->actions.at(i); -
1446 if (action == atAction) {
never evaluated: action == atAction
0
1447 int newY = pos.y() - above_height; -
1448 if (d->scroll && newY < desktopFrame) {
never evaluated: d->scroll
never evaluated: newY < desktopFrame
0
1449 d->scroll->scrollFlags = d->scroll->scrollFlags -
1450 | QMenuPrivate::QMenuScroller::ScrollUp; -
1451 d->scroll->scrollOffset = newY; -
1452 newY = desktopFrame; -
1453 }
never executed: }
0
1454 pos.setY(newY); -
1455 -
1456 if (d->scroll && d->scroll->scrollFlags != QMenuPrivate::QMenuScroller::ScrollNone
never evaluated: d->scroll
never evaluated: d->scroll->scrollFlags != QMenuPrivate::QMenuScroller::ScrollNone
0
1457 && !style()->styleHint(QStyle::SH_Menu_FillScreenWithScroll, 0, this)) {
never evaluated: !style()->styleHint(QStyle::SH_Menu_FillScreenWithScroll, 0, this)
0
1458 int below_height = above_height + d->scroll->scrollOffset; -
1459 for (int i2 = i; i2 < d->actionRects.count(); i2++)
never evaluated: i2 < d->actionRects.count()
0
1460 below_height += d->actionRects.at(i2).height();
never executed: below_height += d->actionRects.at(i2).height();
0
1461 size.setHeight(below_height); -
1462 }
never executed: }
0
1463 break;
never executed: break;
0
1464 } else { -
1465 above_height += d->actionRects.at(i).height(); -
1466 }
never executed: }
0
1467 } -
1468 }
never executed: }
0
1469 -
1470 QPoint mouse = QCursor::pos(); -
1471 d->mousePopupPos = mouse; -
1472 const bool snapToMouse = !d->causedPopup.widget && (QRect(p.x() - 3, p.y() - 3, 6, 6).contains(mouse));
evaluated: !d->causedPopup.widget
TRUEFALSE
yes
Evaluation Count:23
yes
Evaluation Count:38
evaluated: (QRect(p.x() - 3, p.y() - 3, 6, 6).contains(mouse))
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:20
3-38
1473 -
1474 const QSize menuSize(sizeHint()); -
1475 if (adjustToDesktop) {
partially evaluated: adjustToDesktop
TRUEFALSE
yes
Evaluation Count:61
no
Evaluation Count:0
0-61
1476 -
1477 if (isRightToLeft()) {
evaluated: isRightToLeft()
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:56
5-56
1478 if (snapToMouse)
partially evaluated: snapToMouse
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5
0-5
1479 pos.setX(mouse.x() - size.width());
never executed: pos.setX(mouse.x() - size.width());
0
1480 -
1481 -
1482 -
1483 if (qobject_cast<QMenuBar*>(d->causedPopup.widget))
evaluated: qobject_cast<QMenuBar*>(d->causedPopup.widget)
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:2
2-3
1484 pos.rx() -= size.width();
executed: pos.rx() -= size.width();
Execution Count:3
3
1485 -
1486 -
1487 if (pos.x() < screen.left() + desktopFrame)
evaluated: pos.x() < screen.left() + desktopFrame
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:4
1-4
1488 pos.setX(qMax(p.x(), screen.left() + desktopFrame));
executed: pos.setX(qMax(p.x(), screen.left() + desktopFrame));
Execution Count:1
1
1489 if (pos.x() + size.width() - 1 > screen.right() - desktopFrame)
partially evaluated: pos.x() + size.width() - 1 > screen.right() - desktopFrame
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5
0-5
1490 pos.setX(qMax(p.x() - size.width(), screen.right() - desktopFrame - size.width() + 1));
never executed: pos.setX(qMax(p.x() - size.width(), screen.right() - desktopFrame - size.width() + 1));
0
1491 } else {
executed: }
Execution Count:5
5
1492 if (pos.x() + size.width() - 1 > screen.right() - desktopFrame)
partially evaluated: pos.x() + size.width() - 1 > screen.right() - desktopFrame
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:56
0-56
1493 pos.setX(screen.right() - desktopFrame - size.width() + 1);
never executed: pos.setX(screen.right() - desktopFrame - size.width() + 1);
0
1494 if (pos.x() < screen.left() + desktopFrame)
partially evaluated: pos.x() < screen.left() + desktopFrame
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:56
0-56
1495 pos.setX(screen.left() + desktopFrame);
never executed: pos.setX(screen.left() + desktopFrame);
0
1496 }
executed: }
Execution Count:56
56
1497 if (pos.y() + size.height() - 1 > screen.bottom() - desktopFrame) {
evaluated: pos.y() + size.height() - 1 > screen.bottom() - desktopFrame
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:60
1-60
1498 if(snapToMouse)
partially evaluated: snapToMouse
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
1499 pos.setY(qMin(mouse.y() - (size.height() + desktopFrame), screen.bottom()-desktopFrame-size.height()+1));
never executed: pos.setY(qMin(mouse.y() - (size.height() + desktopFrame), screen.bottom()-desktopFrame-size.height()+1));
0
1500 else -
1501 pos.setY(qMax(p.y() - (size.height() + desktopFrame), screen.bottom()-desktopFrame-size.height()+1));
executed: pos.setY(qMax(p.y() - (size.height() + desktopFrame), screen.bottom()-desktopFrame-size.height()+1));
Execution Count:1
1
1502 } else if (pos.y() < screen.top() + desktopFrame) {
partially evaluated: pos.y() < screen.top() + desktopFrame
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:60
0-60
1503 pos.setY(screen.top() + desktopFrame); -
1504 }
never executed: }
0
1505 -
1506 if (pos.y() < screen.top() + desktopFrame)
partially evaluated: pos.y() < screen.top() + desktopFrame
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:61
0-61
1507 pos.setY(screen.top() + desktopFrame);
never executed: pos.setY(screen.top() + desktopFrame);
0
1508 if (pos.y() + menuSize.height() - 1 > screen.bottom() - desktopFrame) {
partially evaluated: pos.y() + menuSize.height() - 1 > screen.bottom() - desktopFrame
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:61
0-61
1509 if (d->scroll) {
never evaluated: d->scroll
0
1510 d->scroll->scrollFlags |= uint(QMenuPrivate::QMenuScroller::ScrollDown); -
1511 int y = qMax(screen.y(),pos.y()); -
1512 size.setHeight(screen.bottom() - (desktopFrame * 2) - y); -
1513 } else {
never executed: }
0
1514 -
1515 pos.setY(screen.bottom() - size.height() + 1); -
1516 }
never executed: }
0
1517 } -
1518 }
executed: }
Execution Count:61
61
1519 const int subMenuOffset = style()->pixelMetric(QStyle::PM_SubMenuOverlap, 0, this); -
1520 QMenu *caused = qobject_cast<QMenu*>(d_func()->causedPopup.widget); -
1521 if (caused && caused->geometry().width() + menuSize.width() + subMenuOffset < screen.width()) {
evaluated: caused
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:54
partially evaluated: caused->geometry().width() + menuSize.width() + subMenuOffset < screen.width()
TRUEFALSE
yes
Evaluation Count:7
no
Evaluation Count:0
0-54
1522 QRect parentActionRect(caused->d_func()->actionRect(caused->d_func()->currentAction)); -
1523 const QPoint actionTopLeft = caused->mapToGlobal(parentActionRect.topLeft()); -
1524 parentActionRect.moveTopLeft(actionTopLeft); -
1525 if (isRightToLeft()) {
partially evaluated: isRightToLeft()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7
0-7
1526 if ((pos.x() + menuSize.width() > parentActionRect.left() - subMenuOffset)
never evaluated: (pos.x() + menuSize.width() > parentActionRect.left() - subMenuOffset)
0
1527 && (pos.x() < parentActionRect.right()))
never evaluated: (pos.x() < parentActionRect.right())
0
1528 { -
1529 pos.rx() = parentActionRect.left() - menuSize.width(); -
1530 if (pos.x() < screen.x())
never evaluated: pos.x() < screen.x()
0
1531 pos.rx() = parentActionRect.right();
never executed: pos.rx() = parentActionRect.right();
0
1532 if (pos.x() + menuSize.width() > screen.x() + screen.width())
never evaluated: pos.x() + menuSize.width() > screen.x() + screen.width()
0
1533 pos.rx() = screen.x();
never executed: pos.rx() = screen.x();
0
1534 }
never executed: }
0
1535 } else {
never executed: }
0
1536 if ((pos.x() < parentActionRect.right() + subMenuOffset)
partially evaluated: (pos.x() < parentActionRect.right() + subMenuOffset)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7
0-7
1537 && (pos.x() + menuSize.width() > parentActionRect.left()))
never evaluated: (pos.x() + menuSize.width() > parentActionRect.left())
0
1538 { -
1539 pos.rx() = parentActionRect.right(); -
1540 if (pos.x() + menuSize.width() > screen.x() + screen.width())
never evaluated: pos.x() + menuSize.width() > screen.x() + screen.width()
0
1541 pos.rx() = parentActionRect.left() - menuSize.width();
never executed: pos.rx() = parentActionRect.left() - menuSize.width();
0
1542 if (pos.x() < screen.x())
never evaluated: pos.x() < screen.x()
0
1543 pos.rx() = screen.x() + screen.width() - menuSize.width();
never executed: pos.rx() = screen.x() + screen.width() - menuSize.width();
0
1544 }
never executed: }
0
1545 }
executed: }
Execution Count:7
7
1546 } -
1547 setGeometry(QRect(pos, size)); -
1548 -
1549 int hGuess = isRightToLeft() ? QEffects::LeftScroll : QEffects::RightScroll;
evaluated: isRightToLeft()
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:56
5-56
1550 int vGuess = QEffects::DownScroll; -
1551 if (isRightToLeft()) {
evaluated: isRightToLeft()
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:56
5-56
1552 if ((snapToMouse && (pos.x() + size.width() / 2 > mouse.x())) ||
partially evaluated: snapToMouse
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5
never evaluated: (pos.x() + size.width() / 2 > mouse.x())
0-5
1553 (qobject_cast<QMenu*>(d->causedPopup.widget) && pos.x() + size.width() / 2 > d->causedPopup.widget->x()))
partially evaluated: qobject_cast<QMenu*>(d->causedPopup.widget)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5
never evaluated: pos.x() + size.width() / 2 > d->causedPopup.widget->x()
0-5
1554 hGuess = QEffects::RightScroll;
never executed: hGuess = QEffects::RightScroll;
0
1555 } else {
executed: }
Execution Count:5
5
1556 if ((snapToMouse && (pos.x() + size.width() / 2 < mouse.x())) ||
evaluated: snapToMouse
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:53
partially evaluated: (pos.x() + size.width() / 2 < mouse.x())
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-53
1557 (qobject_cast<QMenu*>(d->causedPopup.widget) && pos.x() + size.width() / 2 < d->causedPopup.widget->x()))
evaluated: qobject_cast<QMenu*>(d->causedPopup.widget)
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:49
partially evaluated: pos.x() + size.width() / 2 < d->causedPopup.widget->x()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7
0-49
1558 hGuess = QEffects::LeftScroll;
never executed: hGuess = QEffects::LeftScroll;
0
1559 }
executed: }
Execution Count:56
56
1560 -
1561 -
1562 if ((snapToMouse && (pos.y() + size.height() / 2 < mouse.y())) ||
evaluated: snapToMouse
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:58
partially evaluated: (pos.y() + size.height() / 2 < mouse.y())
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-58
1563 (qobject_cast<QMenuBar*>(d->causedPopup.widget) &&
evaluated: qobject_cast<QMenuBar*>(d->causedPopup.widget)
TRUEFALSE
yes
Evaluation Count:25
yes
Evaluation Count:36
25-36
1564 pos.y() + size.width() / 2 < d->causedPopup.widget->mapToGlobal(d->causedPopup.widget->pos()).y()))
evaluated: pos.y() + size.width() / 2 < d->causedPopup.widget->mapToGlobal(d->causedPopup.widget->pos()).y()
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:22
3-22
1565 vGuess = QEffects::UpScroll;
executed: vGuess = QEffects::UpScroll;
Execution Count:3
3
1566 -
1567 if (QApplication::isEffectEnabled(Qt::UI_AnimateMenu)) {
partially evaluated: QApplication::isEffectEnabled(Qt::UI_AnimateMenu)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:61
0-61
1568 bool doChildEffects = true; -
1569 -
1570 if (QMenuBar *mb = qobject_cast<QMenuBar*>(d->causedPopup.widget)) {
never evaluated: QMenuBar *mb = qobject_cast<QMenuBar*>(d->causedPopup.widget)
0
1571 doChildEffects = mb->d_func()->doChildEffects; -
1572 mb->d_func()->doChildEffects = false; -
1573 } else
never executed: }
0
1574 -
1575 if (QMenu *m = qobject_cast<QMenu*>(d->causedPopup.widget)) {
never evaluated: QMenu *m = qobject_cast<QMenu*>(d->causedPopup.widget)
0
1576 doChildEffects = m->d_func()->doChildEffects; -
1577 m->d_func()->doChildEffects = false; -
1578 }
never executed: }
0
1579 -
1580 if (doChildEffects) {
never evaluated: doChildEffects
0
1581 if (QApplication::isEffectEnabled(Qt::UI_FadeMenu))
never evaluated: QApplication::isEffectEnabled(Qt::UI_FadeMenu)
0
1582 qFadeEffect(this);
never executed: qFadeEffect(this);
0
1583 else if (d->causedPopup.widget)
never evaluated: d->causedPopup.widget
0
1584 qScrollEffect(this, qobject_cast<QMenu*>(d->causedPopup.widget) ? hGuess : vGuess);
never executed: qScrollEffect(this, qobject_cast<QMenu*>(d->causedPopup.widget) ? hGuess : vGuess);
0
1585 else -
1586 qScrollEffect(this, hGuess | vGuess);
never executed: qScrollEffect(this, hGuess | vGuess);
0
1587 } else { -
1588 -
1589 qFadeEffect(0); -
1590 qScrollEffect(0); -
1591 -
1592 show(); -
1593 }
never executed: }
0
1594 } else -
1595 -
1596 { -
1597 show(); -
1598 }
executed: }
Execution Count:61
61
1599 -
1600 -
1601 QAccessibleEvent event(this, QAccessible::PopupMenuStart); -
1602 QAccessible::updateAccessibility(&event); -
1603 -
1604}
executed: }
Execution Count:61
61
1605QAction *QMenu::exec() -
1606{ -
1607 return exec(pos());
executed: return exec(pos());
Execution Count:1
1
1608} -
1609QAction *QMenu::exec(const QPoint &p, QAction *action) -
1610{ -
1611 QMenuPrivate * const d = d_func(); -
1612 createWinId(); -
1613 QEventLoop eventLoop; -
1614 d->eventLoop = &eventLoop; -
1615 popup(p, action); -
1616 -
1617 QPointer<QObject> guard = this; -
1618 (void) eventLoop.exec(); -
1619 if (guard.isNull())
evaluated: guard.isNull()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:8
2-8
1620 return 0;
executed: return 0;
Execution Count:2
2
1621 -
1622 action = d->syncAction; -
1623 d->syncAction = 0; -
1624 d->eventLoop = 0; -
1625 return action;
executed: return action;
Execution Count:8
8
1626} -
1627QAction *QMenu::exec(QList<QAction*> actions, const QPoint &pos, QAction *at, QWidget *parent) -
1628{ -
1629 QMenu menu(parent); -
1630 menu.addActions(actions); -
1631 return menu.exec(pos, at);
never executed: return menu.exec(pos, at);
0
1632} -
1633 -
1634 -
1635 -
1636 -
1637void QMenu::hideEvent(QHideEvent *) -
1638{ -
1639 QMenuPrivate * const d = d_func(); -
1640 aboutToHide(); -
1641 if (d->eventLoop)
evaluated: d->eventLoop
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:39
8-39
1642 d->eventLoop->exit();
executed: d->eventLoop->exit();
Execution Count:8
8
1643 d->setCurrentAction(0); -
1644 -
1645 QAccessibleEvent event(this, QAccessible::PopupMenuEnd); -
1646 QAccessible::updateAccessibility(&event); -
1647 -
1648 -
1649 if (QMenuBar *mb = qobject_cast<QMenuBar*>(d->causedPopup.widget))
evaluated: QMenuBar *mb = qobject_cast<QMenuBar*>(d->causedPopup.widget)
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:27
20-27
1650 mb->d_func()->setCurrentAction(0);
executed: mb->d_func()->setCurrentAction(0);
Execution Count:20
20
1651 -
1652 d->mouseDown = 0; -
1653 d->hasHadMouse = false; -
1654 d->causedPopup.widget = 0; -
1655 d->causedPopup.action = 0; -
1656 if (d->scroll)
partially evaluated: d->scroll
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:47
0-47
1657 d->scroll->scrollTimer.stop();
never executed: d->scroll->scrollTimer.stop();
0
1658}
executed: }
Execution Count:47
47
1659 -
1660 -
1661 -
1662 -
1663void QMenu::paintEvent(QPaintEvent *e) -
1664{ -
1665 QMenuPrivate * const d = d_func(); -
1666 d->updateActionRects(); -
1667 QPainter p(this); -
1668 QRegion emptyArea = QRegion(rect()); -
1669 -
1670 QStyleOptionMenuItem menuOpt; -
1671 menuOpt.initFrom(this); -
1672 menuOpt.state = QStyle::State_None; -
1673 menuOpt.checkType = QStyleOptionMenuItem::NotCheckable; -
1674 menuOpt.maxIconWidth = 0; -
1675 menuOpt.tabWidth = 0; -
1676 style()->drawPrimitive(QStyle::PE_PanelMenu, &menuOpt, &p, this); -
1677 -
1678 -
1679 for (int i = 0; i < d->actions.count(); ++i) {
evaluated: i < d->actions.count()
TRUEFALSE
yes
Evaluation Count:90
yes
Evaluation Count:39
39-90
1680 QAction *action = d->actions.at(i); -
1681 QRect adjustedActionRect = d->actionRects.at(i); -
1682 if (!e->rect().intersects(adjustedActionRect)
evaluated: !e->rect().intersects(adjustedActionRect)
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:88
2-88
1683 || d->widgetItems.value(action))
evaluated: d->widgetItems.value(action)
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:87
1-87
1684 continue;
executed: continue;
Execution Count:3
3
1685 -
1686 QRegion adjustedActionReg(adjustedActionRect); -
1687 emptyArea -= adjustedActionReg; -
1688 p.setClipRegion(adjustedActionReg); -
1689 -
1690 QStyleOptionMenuItem opt; -
1691 initStyleOption(&opt, action); -
1692 opt.rect = adjustedActionRect; -
1693 style()->drawControl(QStyle::CE_MenuItem, &opt, &p, this); -
1694 }
executed: }
Execution Count:87
87
1695 -
1696 const int fw = style()->pixelMetric(QStyle::PM_MenuPanelWidth, 0, this); -
1697 -
1698 if (d->scroll) {
partially evaluated: d->scroll
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:39
0-39
1699 menuOpt.menuItemType = QStyleOptionMenuItem::Scroller; -
1700 menuOpt.state |= QStyle::State_Enabled; -
1701 if (d->scroll->scrollFlags & QMenuPrivate::QMenuScroller::ScrollUp) {
never evaluated: d->scroll->scrollFlags & QMenuPrivate::QMenuScroller::ScrollUp
0
1702 menuOpt.rect.setRect(fw, fw, width() - (fw * 2), d->scrollerHeight()); -
1703 emptyArea -= QRegion(menuOpt.rect); -
1704 p.setClipRect(menuOpt.rect); -
1705 style()->drawControl(QStyle::CE_MenuScroller, &menuOpt, &p, this); -
1706 }
never executed: }
0
1707 if (d->scroll->scrollFlags & QMenuPrivate::QMenuScroller::ScrollDown) {
never evaluated: d->scroll->scrollFlags & QMenuPrivate::QMenuScroller::ScrollDown
0
1708 menuOpt.rect.setRect(fw, height() - d->scrollerHeight() - fw, width() - (fw * 2), -
1709 d->scrollerHeight()); -
1710 emptyArea -= QRegion(menuOpt.rect); -
1711 menuOpt.state |= QStyle::State_DownArrow; -
1712 p.setClipRect(menuOpt.rect); -
1713 style()->drawControl(QStyle::CE_MenuScroller, &menuOpt, &p, this); -
1714 }
never executed: }
0
1715 }
never executed: }
0
1716 -
1717 if (d->tearoff) {
evaluated: d->tearoff
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:38
1-38
1718 menuOpt.menuItemType = QStyleOptionMenuItem::TearOff; -
1719 menuOpt.rect.setRect(fw, fw, width() - (fw * 2), -
1720 style()->pixelMetric(QStyle::PM_MenuTearoffHeight, 0, this)); -
1721 if (d->scroll && d->scroll->scrollFlags & QMenuPrivate::QMenuScroller::ScrollUp)
partially evaluated: d->scroll
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
never evaluated: d->scroll->scrollFlags & QMenuPrivate::QMenuScroller::ScrollUp
0-1
1722 menuOpt.rect.translate(0, d->scrollerHeight());
never executed: menuOpt.rect.translate(0, d->scrollerHeight());
0
1723 emptyArea -= QRegion(menuOpt.rect); -
1724 p.setClipRect(menuOpt.rect); -
1725 menuOpt.state = QStyle::State_None; -
1726 if (d->tearoffHighlighted)
partially evaluated: d->tearoffHighlighted
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
1727 menuOpt.state |= QStyle::State_Selected;
never executed: menuOpt.state |= QStyle::State_Selected;
0
1728 style()->drawControl(QStyle::CE_MenuTearoff, &menuOpt, &p, this); -
1729 }
executed: }
Execution Count:1
1
1730 -
1731 if (fw) {
partially evaluated: fw
TRUEFALSE
yes
Evaluation Count:39
no
Evaluation Count:0
0-39
1732 QRegion borderReg; -
1733 borderReg += QRect(0, 0, fw, height()); -
1734 borderReg += QRect(width()-fw, 0, fw, height()); -
1735 borderReg += QRect(0, 0, width(), fw); -
1736 borderReg += QRect(0, height()-fw, width(), fw); -
1737 p.setClipRegion(borderReg); -
1738 emptyArea -= borderReg; -
1739 QStyleOptionFrame frame; -
1740 frame.rect = rect(); -
1741 frame.palette = palette(); -
1742 frame.state = QStyle::State_None; -
1743 frame.lineWidth = style()->pixelMetric(QStyle::PM_MenuPanelWidth); -
1744 frame.midLineWidth = 0; -
1745 style()->drawPrimitive(QStyle::PE_FrameMenu, &frame, &p, this); -
1746 }
executed: }
Execution Count:39
39
1747 -
1748 -
1749 p.setClipRegion(emptyArea); -
1750 menuOpt.state = QStyle::State_None; -
1751 menuOpt.menuItemType = QStyleOptionMenuItem::EmptyArea; -
1752 menuOpt.checkType = QStyleOptionMenuItem::NotCheckable; -
1753 menuOpt.rect = rect(); -
1754 menuOpt.menuRect = rect(); -
1755 style()->drawControl(QStyle::CE_MenuEmptyArea, &menuOpt, &p, this); -
1756}
executed: }
Execution Count:39
39
1757 -
1758 -
1759 -
1760 -
1761 -
1762void QMenu::wheelEvent(QWheelEvent *e) -
1763{ -
1764 QMenuPrivate * const d = d_func(); -
1765 if (d->scroll && rect().contains(e->pos()))
never evaluated: d->scroll
never evaluated: rect().contains(e->pos())
0
1766 d->scrollMenu(e->delta() > 0 ? 0
1767 QMenuPrivate::QMenuScroller::ScrollUp : QMenuPrivate::QMenuScroller::ScrollDown);
never executed: d->scrollMenu(e->delta() > 0 ? QMenuPrivate::QMenuScroller::ScrollUp : QMenuPrivate::QMenuScroller::ScrollDown);
0
1768}
never executed: }
0
1769 -
1770 -
1771 -
1772 -
1773 -
1774void QMenu::mousePressEvent(QMouseEvent *e) -
1775{ -
1776 QMenuPrivate * const d = d_func(); -
1777 if (d->aboutToHide || d->mouseEventTaken(e))
partially evaluated: d->aboutToHide
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7
evaluated: d->mouseEventTaken(e)
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:6
0-7
1778 return;
executed: return;
Execution Count:1
1
1779 if (!rect().contains(e->pos())) {
partially evaluated: !rect().contains(e->pos())
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6
0-6
1780 if (d->noReplayFor
never evaluated: d->noReplayFor
0
1781 && QRect(d->noReplayFor->mapToGlobal(QPoint()), d->noReplayFor->size()).contains(e->globalPos()))
never evaluated: QRect(d->noReplayFor->mapToGlobal(QPoint()), d->noReplayFor->size()).contains(e->globalPos())
0
1782 setAttribute(Qt::WA_NoMouseReplay);
never executed: setAttribute(Qt::WA_NoMouseReplay);
0
1783 if (d->eventLoop)
never evaluated: d->eventLoop
0
1784 d->syncAction = 0;
never executed: d->syncAction = 0;
0
1785 d->hideUpToMenuBar(); -
1786 return;
never executed: return;
0
1787 } -
1788 d->mouseDown = this; -
1789 -
1790 QAction *action = d->actionAt(e->pos()); -
1791 d->setCurrentAction(action, 20); -
1792 update(); -
1793}
executed: }
Execution Count:6
6
1794 -
1795 -
1796 -
1797 -
1798void QMenu::mouseReleaseEvent(QMouseEvent *e) -
1799{ -
1800 QMenuPrivate * const d = d_func(); -
1801 if (d->aboutToHide || d->mouseEventTaken(e))
partially evaluated: d->aboutToHide
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7
evaluated: d->mouseEventTaken(e)
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:6
0-7
1802 return;
executed: return;
Execution Count:1
1
1803 if(d->mouseDown != this) {
partially evaluated: d->mouseDown != this
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6
0-6
1804 d->mouseDown = 0; -
1805 return;
never executed: return;
0
1806 } -
1807 -
1808 d->mouseDown = 0; -
1809 d->setSyncAction(); -
1810 QAction *action = d->actionAt(e->pos()); -
1811 -
1812 if (action && action == d->currentAction) {
partially evaluated: action
TRUEFALSE
yes
Evaluation Count:6
no
Evaluation Count:0
partially evaluated: action == d->currentAction
TRUEFALSE
yes
Evaluation Count:6
no
Evaluation Count:0
0-6
1813 if (!action->menu()){
evaluated: !action->menu()
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:1
1-5
1814 -
1815 -
1816 -
1817 -
1818 d->activateAction(action, QAction::Trigger); -
1819 }
executed: }
Execution Count:5
5
1820 } else if (d->hasMouseMoved(e->globalPos())) {
executed: }
Execution Count:6
never evaluated: d->hasMouseMoved(e->globalPos())
0-6
1821 d->hideUpToMenuBar(); -
1822 }
never executed: }
0
1823} -
1824 -
1825 -
1826 -
1827 -
1828void QMenu::changeEvent(QEvent *e) -
1829{ -
1830 QMenuPrivate * const d = d_func(); -
1831 if (e->type() == QEvent::StyleChange || e->type() == QEvent::FontChange ||
partially evaluated: e->type() == QEvent::StyleChange
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:435
partially evaluated: e->type() == QEvent::FontChange
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:435
0-435
1832 e->type() == QEvent::LayoutDirectionChange) {
evaluated: e->type() == QEvent::LayoutDirectionChange
TRUEFALSE
yes
Evaluation Count:138
yes
Evaluation Count:297
138-297
1833 d->itemsDirty = 1; -
1834 setMouseTracking(style()->styleHint(QStyle::SH_Menu_MouseTracking, 0, this)); -
1835 if (isVisible())
partially evaluated: isVisible()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:138
0-138
1836 resize(sizeHint());
never executed: resize(sizeHint());
0
1837 if (!style()->styleHint(QStyle::SH_Menu_Scrollable, 0, this)) {
partially evaluated: !style()->styleHint(QStyle::SH_Menu_Scrollable, 0, this)
TRUEFALSE
yes
Evaluation Count:138
no
Evaluation Count:0
0-138
1838 delete d->scroll; -
1839 d->scroll = 0; -
1840 } else if (!d->scroll) {
executed: }
Execution Count:138
never evaluated: !d->scroll
0-138
1841 d->scroll = new QMenuPrivate::QMenuScroller; -
1842 d->scroll->scrollFlags = QMenuPrivate::QMenuScroller::ScrollNone; -
1843 }
never executed: }
0
1844 } else if (e->type() == QEvent::EnabledChange) {
evaluated: e->type() == QEvent::EnabledChange
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:283
14-283
1845 if (d->tornPopup)
partially evaluated: d->tornPopup
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:14
0-14
1846 d->tornPopup->setEnabled(isEnabled());
never executed: d->tornPopup->setEnabled(isEnabled());
0
1847 d->menuAction->setEnabled(isEnabled()); -
1848 if (d->platformMenu)
partially evaluated: d->platformMenu
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:14
0-14
1849 d->platformMenu->setEnabled(isEnabled());
never executed: d->platformMenu->setEnabled(isEnabled());
0
1850 }
executed: }
Execution Count:14
14
1851 QWidget::changeEvent(e); -
1852}
executed: }
Execution Count:435
435
1853 -
1854 -
1855 -
1856 -
1857 -
1858bool -
1859QMenu::event(QEvent *e) -
1860{ -
1861 QMenuPrivate * const d = d_func(); -
1862 switch (e->type()) { -
1863 case QEvent::Polish: -
1864 d->updateLayoutDirection(); -
1865 break;
executed: break;
Execution Count:234
234
1866 case QEvent::ShortcutOverride: { -
1867 QKeyEvent *kev = static_cast<QKeyEvent*>(e); -
1868 if (kev->key() == Qt::Key_Up || kev->key() == Qt::Key_Down
evaluated: kev->key() == Qt::Key_Up
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:37
evaluated: kev->key() == Qt::Key_Down
TRUEFALSE
yes
Evaluation Count:15
yes
Evaluation Count:22
4-37
1869 || kev->key() == Qt::Key_Left || kev->key() == Qt::Key_Right
evaluated: kev->key() == Qt::Key_Left
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:20
evaluated: kev->key() == Qt::Key_Right
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:17
2-20
1870 || kev->key() == Qt::Key_Enter || kev->key() == Qt::Key_Return
evaluated: kev->key() == Qt::Key_Enter
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:11
evaluated: kev->key() == Qt::Key_Return
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:10
1-11
1871 || kev->key() == Qt::Key_Escape) {
evaluated: kev->key() == Qt::Key_Escape
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:4
4-6
1872 e->accept(); -
1873 return true;
executed: return true;
Execution Count:37
37
1874 } -
1875 } -
1876 break;
executed: break;
Execution Count:4
4
1877 case QEvent::KeyPress: { -
1878 QKeyEvent *ke = (QKeyEvent*)e; -
1879 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:40
partially evaluated: ke->key() == Qt::Key_Backtab
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:40
0-40
1880 keyPressEvent(ke); -
1881 return true;
never executed: return true;
0
1882 } -
1883 } break;
executed: break;
Execution Count:40
40
1884 case QEvent::ContextMenu: -
1885 if(d->menuDelayTimer.isActive()) {
never evaluated: d->menuDelayTimer.isActive()
0
1886 d->menuDelayTimer.stop(); -
1887 internalDelayedPopup(); -
1888 }
never executed: }
0
1889 break;
never executed: break;
0
1890 case QEvent::Resize: { -
1891 QStyleHintReturnMask menuMask; -
1892 QStyleOption option; -
1893 option.initFrom(this); -
1894 if (style()->styleHint(QStyle::SH_Menu_Mask, &option, this, &menuMask)) {
partially evaluated: style()->styleHint(QStyle::SH_Menu_Mask, &option, this, &menuMask)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:136
0-136
1895 setMask(menuMask.region); -
1896 }
never executed: }
0
1897 d->itemsDirty = 1; -
1898 d->updateActionRects(); -
1899 break; }
executed: break;
Execution Count:136
136
1900 case QEvent::Show: -
1901 d->mouseDown = 0; -
1902 d->updateActionRects(); -
1903 if (d->currentAction)
evaluated: d->currentAction
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:70
3-70
1904 d->popupAction(d->currentAction, 0, false);
executed: d->popupAction(d->currentAction, 0, false);
Execution Count:3
3
1905 break;
executed: break;
Execution Count:73
73
1906 -
1907 case QEvent::QueryWhatsThis: -
1908 e->setAccepted(d->whatsThis.size()); -
1909 if (QAction *action = d->actionAt(static_cast<QHelpEvent*>(e)->pos())) {
never evaluated: QAction *action = d->actionAt(static_cast<QHelpEvent*>(e)->pos())
0
1910 if (action->whatsThis().size() || action->menu())
never evaluated: action->whatsThis().size()
never evaluated: action->menu()
0
1911 e->accept();
never executed: e->accept();
0
1912 }
never executed: }
0
1913 return true;
never executed: return true;
0
1914 -
1915 default: -
1916 break;
executed: break;
Execution Count:11071
11071
1917 } -
1918 return QWidget::event(e);
executed: return QWidget::event(e);
Execution Count:11558
11558
1919} -
1920 -
1921 -
1922 -
1923 -
1924bool QMenu::focusNextPrevChild(bool next) -
1925{ -
1926 setFocus(); -
1927 QKeyEvent ev(QEvent::KeyPress, next ? Qt::Key_Tab : Qt::Key_Backtab, Qt::NoModifier); -
1928 keyPressEvent(&ev); -
1929 return true;
executed: return true;
Execution Count:1
1
1930} -
1931 -
1932 -
1933 -
1934 -
1935void QMenu::keyPressEvent(QKeyEvent *e) -
1936{ -
1937 QMenuPrivate * const d = d_func(); -
1938 d->updateActionRects(); -
1939 int key = e->key(); -
1940 if (isRightToLeft()) {
partially evaluated: isRightToLeft()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:41
0-41
1941 if (key == Qt::Key_Left)
never evaluated: key == Qt::Key_Left
0
1942 key = Qt::Key_Right;
never executed: key = Qt::Key_Right;
0
1943 else if (key == Qt::Key_Right)
never evaluated: key == Qt::Key_Right
0
1944 key = Qt::Key_Left;
never executed: key = Qt::Key_Left;
0
1945 } -
1946 -
1947 if (key == Qt::Key_Tab)
evaluated: key == Qt::Key_Tab
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:40
1-40
1948 key = Qt::Key_Down;
executed: key = Qt::Key_Down;
Execution Count:1
1
1949 if (key == Qt::Key_Backtab)
partially evaluated: key == Qt::Key_Backtab
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:41
0-41
1950 key = Qt::Key_Up;
never executed: key = Qt::Key_Up;
0
1951 -
1952 -
1953 bool key_consumed = false; -
1954 switch(key) { -
1955 case Qt::Key_Home: -
1956 key_consumed = true; -
1957 if (d->scroll)
never evaluated: d->scroll
0
1958 d->scrollMenu(QMenuPrivate::QMenuScroller::ScrollTop, true);
never executed: d->scrollMenu(QMenuPrivate::QMenuScroller::ScrollTop, true);
0
1959 break;
never executed: break;
0
1960 case Qt::Key_End: -
1961 key_consumed = true; -
1962 if (d->scroll)
never evaluated: d->scroll
0
1963 d->scrollMenu(QMenuPrivate::QMenuScroller::ScrollBottom, true);
never executed: d->scrollMenu(QMenuPrivate::QMenuScroller::ScrollBottom, true);
0
1964 break;
never executed: break;
0
1965 case Qt::Key_PageUp: -
1966 key_consumed = true; -
1967 if (d->currentAction && d->scroll) {
never evaluated: d->currentAction
never evaluated: d->scroll
0
1968 if(d->scroll->scrollFlags & QMenuPrivate::QMenuScroller::ScrollUp)
never evaluated: d->scroll->scrollFlags & QMenuPrivate::QMenuScroller::ScrollUp
0
1969 d->scrollMenu(QMenuPrivate::QMenuScroller::ScrollUp, true, true);
never executed: d->scrollMenu(QMenuPrivate::QMenuScroller::ScrollUp, true, true);
0
1970 else -
1971 d->scrollMenu(QMenuPrivate::QMenuScroller::ScrollTop, true);
never executed: d->scrollMenu(QMenuPrivate::QMenuScroller::ScrollTop, true);
0
1972 } -
1973 break;
never executed: break;
0
1974 case Qt::Key_PageDown: -
1975 key_consumed = true; -
1976 if (d->currentAction && d->scroll) {
never evaluated: d->currentAction
never evaluated: d->scroll
0
1977 if(d->scroll->scrollFlags & QMenuPrivate::QMenuScroller::ScrollDown)
never evaluated: d->scroll->scrollFlags & QMenuPrivate::QMenuScroller::ScrollDown
0
1978 d->scrollMenu(QMenuPrivate::QMenuScroller::ScrollDown, true, true);
never executed: d->scrollMenu(QMenuPrivate::QMenuScroller::ScrollDown, true, true);
0
1979 else -
1980 d->scrollMenu(QMenuPrivate::QMenuScroller::ScrollBottom, true);
never executed: d->scrollMenu(QMenuPrivate::QMenuScroller::ScrollBottom, true);
0
1981 } -
1982 break;
never executed: break;
0
1983 case Qt::Key_Up: -
1984 case Qt::Key_Down: { -
1985 key_consumed = true; -
1986 QAction *nextAction = 0; -
1987 QMenuPrivate::QMenuScroller::ScrollLocation scroll_loc = QMenuPrivate::QMenuScroller::ScrollStay; -
1988 if (!d->currentAction) {
evaluated: !d->currentAction
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:17
2-17
1989 if(key == Qt::Key_Down) {
partially evaluated: key == Qt::Key_Down
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
1990 for(int i = 0; i < d->actions.count(); ++i) {
partially evaluated: i < d->actions.count()
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
1991 QAction *act = d->actions.at(i); -
1992 if (d->actionRects.at(i).isNull())
partially evaluated: d->actionRects.at(i).isNull()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
1993 continue;
never executed: continue;
0
1994 if (!act->isSeparator() &&
partially evaluated: !act->isSeparator()
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
1995 (style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, 0, this)
partially evaluated: style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, 0, this)
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
1996 || act->isEnabled())) {
never evaluated: act->isEnabled()
0
1997 nextAction = act; -
1998 break;
executed: break;
Execution Count:2
2
1999 } -
2000 }
never executed: }
0
2001 } else {
executed: }
Execution Count:2
2
2002 for(int i = d->actions.count()-1; i >= 0; --i) {
never evaluated: i >= 0
0
2003 QAction *act = d->actions.at(i); -
2004 if (d->actionRects.at(i).isNull())
never evaluated: d->actionRects.at(i).isNull()
0
2005 continue;
never executed: continue;
0
2006 if (!act->isSeparator() &&
never evaluated: !act->isSeparator()
0
2007 (style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, 0, this)
never evaluated: style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, 0, this)
0
2008 || act->isEnabled())) {
never evaluated: act->isEnabled()
0
2009 nextAction = act; -
2010 break;
never executed: break;
0
2011 } -
2012 }
never executed: }
0
2013 }
never executed: }
0
2014 } else { -
2015 for(int i = 0, y = 0; !nextAction && i < d->actions.count(); i++) {
partially evaluated: !nextAction
TRUEFALSE
yes
Evaluation Count:35
no
Evaluation Count:0
partially evaluated: i < d->actions.count()
TRUEFALSE
yes
Evaluation Count:35
no
Evaluation Count:0
0-35
2016 QAction *act = d->actions.at(i); -
2017 if (act == d->currentAction) {
evaluated: act == d->currentAction
TRUEFALSE
yes
Evaluation Count:17
yes
Evaluation Count:18
17-18
2018 if (key == Qt::Key_Up) {
evaluated: key == Qt::Key_Up
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:13
4-13
2019 for(int next_i = i-1; true; next_i--) {
partially evaluated: true
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
2020 if (next_i == -1) {
partially evaluated: next_i == -1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
2021 if(!style()->styleHint(QStyle::SH_Menu_SelectionWrap, 0, this))
never evaluated: !style()->styleHint(QStyle::SH_Menu_SelectionWrap, 0, this)
0
2022 break;
never executed: break;
0
2023 if (d->scroll)
never evaluated: d->scroll
0
2024 scroll_loc = QMenuPrivate::QMenuScroller::ScrollBottom;
never executed: scroll_loc = QMenuPrivate::QMenuScroller::ScrollBottom;
0
2025 next_i = d->actionRects.count()-1; -
2026 }
never executed: }
0
2027 QAction *next = d->actions.at(next_i); -
2028 if (next == d->currentAction)
partially evaluated: next == d->currentAction
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
2029 break;
never executed: break;
0
2030 if (d->actionRects.at(next_i).isNull())
partially evaluated: d->actionRects.at(next_i).isNull()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
2031 continue;
never executed: continue;
0
2032 if (next->isSeparator() ||
partially evaluated: next->isSeparator()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
2033 (!next->isEnabled() &&
partially evaluated: !next->isEnabled()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
2034 !style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, 0, this)))
never evaluated: !style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, 0, this)
0
2035 continue;
never executed: continue;
0
2036 nextAction = next; -
2037 if (d->scroll && (d->scroll->scrollFlags & QMenuPrivate::QMenuScroller::ScrollUp)) {
partially evaluated: d->scroll
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
never evaluated: (d->scroll->scrollFlags & QMenuPrivate::QMenuScroller::ScrollUp)
0-4
2038 int topVisible = d->scrollerHeight(); -
2039 if (d->tearoff)
never evaluated: d->tearoff
0
2040 topVisible += style()->pixelMetric(QStyle::PM_MenuTearoffHeight, 0, this);
never executed: topVisible += style()->pixelMetric(QStyle::PM_MenuTearoffHeight, 0, this);
0
2041 if (((y + d->scroll->scrollOffset) - topVisible) <= d->actionRects.at(next_i).height())
never evaluated: ((y + d->scroll->scrollOffset) - topVisible) <= d->actionRects.at(next_i).height()
0
2042 scroll_loc = QMenuPrivate::QMenuScroller::ScrollTop;
never executed: scroll_loc = QMenuPrivate::QMenuScroller::ScrollTop;
0
2043 }
never executed: }
0
2044 break;
executed: break;
Execution Count:4
4
2045 } -
2046 if (!nextAction && d->tearoff)
partially evaluated: !nextAction
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
never evaluated: d->tearoff
0-4
2047 d->tearoffHighlighted = 1;
never executed: d->tearoffHighlighted = 1;
0
2048 } else {
executed: }
Execution Count:4
4
2049 y += d->actionRects.at(i).height(); -
2050 for(int next_i = i+1; true; next_i++) {
partially evaluated: true
TRUEFALSE
yes
Evaluation Count:14
no
Evaluation Count:0
0-14
2051 if (next_i == d->actionRects.count()) {
partially evaluated: next_i == d->actionRects.count()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:14
0-14
2052 if(!style()->styleHint(QStyle::SH_Menu_SelectionWrap, 0, this))
never evaluated: !style()->styleHint(QStyle::SH_Menu_SelectionWrap, 0, this)
0
2053 break;
never executed: break;
0
2054 if (d->scroll)
never evaluated: d->scroll
0
2055 scroll_loc = QMenuPrivate::QMenuScroller::ScrollTop;
never executed: scroll_loc = QMenuPrivate::QMenuScroller::ScrollTop;
0
2056 next_i = 0; -
2057 }
never executed: }
0
2058 QAction *next = d->actions.at(next_i); -
2059 if (next == d->currentAction)
partially evaluated: next == d->currentAction
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:14
0-14
2060 break;
never executed: break;
0
2061 if (d->actionRects.at(next_i).isNull())
partially evaluated: d->actionRects.at(next_i).isNull()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:14
0-14
2062 continue;
never executed: continue;
0
2063 if (next->isSeparator() ||
evaluated: next->isSeparator()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:13
1-13
2064 (!next->isEnabled() &&
evaluated: !next->isEnabled()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:12
1-12
2065 !style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, 0, this)))
partially evaluated: !style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, 0, this)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
2066 continue;
executed: continue;
Execution Count:1
1
2067 nextAction = next; -
2068 if (d->scroll && (d->scroll->scrollFlags & QMenuPrivate::QMenuScroller::ScrollDown)) {
partially evaluated: d->scroll
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:13
never evaluated: (d->scroll->scrollFlags & QMenuPrivate::QMenuScroller::ScrollDown)
0-13
2069 int bottomVisible = height() - d->scrollerHeight(); -
2070 if (d->scroll->scrollFlags & QMenuPrivate::QMenuScroller::ScrollUp)
never evaluated: d->scroll->scrollFlags & QMenuPrivate::QMenuScroller::ScrollUp
0
2071 bottomVisible -= d->scrollerHeight();
never executed: bottomVisible -= d->scrollerHeight();
0
2072 if (d->tearoff)
never evaluated: d->tearoff
0
2073 bottomVisible -= style()->pixelMetric(QStyle::PM_MenuTearoffHeight, 0, this);
never executed: bottomVisible -= style()->pixelMetric(QStyle::PM_MenuTearoffHeight, 0, this);
0
2074 if ((y + d->scroll->scrollOffset + d->actionRects.at(next_i).height()) > bottomVisible)
never evaluated: (y + d->scroll->scrollOffset + d->actionRects.at(next_i).height()) > bottomVisible
0
2075 scroll_loc = QMenuPrivate::QMenuScroller::ScrollBottom;
never executed: scroll_loc = QMenuPrivate::QMenuScroller::ScrollBottom;
0
2076 }
never executed: }
0
2077 break;
executed: break;
Execution Count:13
13
2078 } -
2079 }
executed: }
Execution Count:13
13
2080 break;
executed: break;
Execution Count:17
17
2081 } -
2082 y += d->actionRects.at(i).height(); -
2083 }
executed: }
Execution Count:18
18
2084 }
executed: }
Execution Count:17
17
2085 if (nextAction) {
partially evaluated: nextAction
TRUEFALSE
yes
Evaluation Count:19
no
Evaluation Count:0
0-19
2086 if (d->scroll && scroll_loc != QMenuPrivate::QMenuScroller::ScrollStay) {
partially evaluated: d->scroll
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:19
never evaluated: scroll_loc != QMenuPrivate::QMenuScroller::ScrollStay
0-19
2087 d->scroll->scrollTimer.stop(); -
2088 d->scrollMenu(nextAction, scroll_loc); -
2089 }
never executed: }
0
2090 d->setCurrentAction(nextAction, -1, QMenuPrivate::SelectedFromKeyboard); -
2091 }
executed: }
Execution Count:19
19
2092 break; }
executed: break;
Execution Count:19
19
2093 -
2094 case Qt::Key_Right: -
2095 if (d->currentAction && d->currentAction->isEnabled() && d->currentAction->menu()) {
partially evaluated: d->currentAction
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
evaluated: d->currentAction->isEnabled()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1
evaluated: d->currentAction->menu()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
0-3
2096 d->popupAction(d->currentAction, 0, true); -
2097 key_consumed = true; -
2098 break;
executed: break;
Execution Count:1
1
2099 } -
2100 -
2101 case Qt::Key_Left: { -
2102 if (d->currentAction && !d->scroll) {
partially evaluated: d->currentAction
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
partially evaluated: !d->scroll
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
2103 QAction *nextAction = 0; -
2104 if (key == Qt::Key_Left) {
evaluated: key == Qt::Key_Left
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:2
2
2105 QRect actionR = d->actionRect(d->currentAction); -
2106 for(int x = actionR.left()-1; !nextAction && x >= 0; x--)
partially evaluated: !nextAction
TRUEFALSE
yes
Evaluation Count:8
no
Evaluation Count:0
evaluated: x >= 0
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:2
0-8
2107 nextAction = d->actionAt(QPoint(x, actionR.center().y()));
executed: nextAction = d->actionAt(QPoint(x, actionR.center().y()));
Execution Count:6
6
2108 } else {
executed: }
Execution Count:2
2
2109 QRect actionR = d->actionRect(d->currentAction); -
2110 for(int x = actionR.right()+1; !nextAction && x < width(); x++)
partially evaluated: !nextAction
TRUEFALSE
yes
Evaluation Count:8
no
Evaluation Count:0
evaluated: x < width()
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:2
0-8
2111 nextAction = d->actionAt(QPoint(x, actionR.center().y()));
executed: nextAction = d->actionAt(QPoint(x, actionR.center().y()));
Execution Count:6
6
2112 }
executed: }
Execution Count:2
2
2113 if (nextAction) {
partially evaluated: nextAction
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
2114 d->setCurrentAction(nextAction, -1, QMenuPrivate::SelectedFromKeyboard); -
2115 key_consumed = true; -
2116 }
never executed: }
0
2117 }
executed: }
Execution Count:4
4
2118 if (!key_consumed && key == Qt::Key_Left && qobject_cast<QMenu*>(d->causedPopup.widget)) {
partially evaluated: !key_consumed
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
evaluated: key == Qt::Key_Left
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:2
partially evaluated: qobject_cast<QMenu*>(d->causedPopup.widget)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-4
2119 QPointer<QWidget> caused = d->causedPopup.widget; -
2120 d->hideMenu(this); -
2121 if (caused)
never evaluated: caused
0
2122 caused->setFocus();
never executed: caused->setFocus();
0
2123 key_consumed = true; -
2124 }
never executed: }
0
2125 break; }
executed: break;
Execution Count:4
4
2126 -
2127 case Qt::Key_Alt: -
2128 if (d->tornoff)
partially evaluated: d->tornoff
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
2129 break;
never executed: break;
0
2130 -
2131 key_consumed = true; -
2132 if (style()->styleHint(QStyle::SH_MenuBar_AltKeyNavigation, 0, this))
partially evaluated: style()->styleHint(QStyle::SH_MenuBar_AltKeyNavigation, 0, this)
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
2133 { -
2134 d->hideMenu(this); -
2135 -
2136 if (QMenuBar *mb = qobject_cast<QMenuBar*>(QApplication::focusWidget())) {
partially evaluated: QMenuBar *mb = qobject_cast<QMenuBar*>(QApplication::focusWidget())
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
2137 mb->d_func()->setKeyboardMode(false); -
2138 }
never executed: }
0
2139 -
2140 }
executed: }
Execution Count:1
1
2141 break;
executed: break;
Execution Count:1
1
2142 -
2143 case Qt::Key_Escape: -
2144 -
2145 -
2146 -
2147 key_consumed = true; -
2148 if (d->tornoff) {
partially evaluated: d->tornoff
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6
0-6
2149 close(); -
2150 return;
never executed: return;
0
2151 } -
2152 { -
2153 QPointer<QWidget> caused = d->causedPopup.widget; -
2154 d->hideMenu(this); -
2155 -
2156 if (QMenuBar *mb = qobject_cast<QMenuBar*>(caused)) {
evaluated: QMenuBar *mb = qobject_cast<QMenuBar*>(caused)
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:4
2-4
2157 mb->d_func()->setCurrentAction(d->menuAction); -
2158 mb->d_func()->setKeyboardMode(true); -
2159 }
executed: }
Execution Count:2
2
2160 -
2161 } -
2162 break;
executed: break;
Execution Count:6
6
2163 -
2164 case Qt::Key_Space: -
2165 if (!style()->styleHint(QStyle::SH_Menu_SpaceActivatesItem, 0, this))
never evaluated: !style()->styleHint(QStyle::SH_Menu_SpaceActivatesItem, 0, this)
0
2166 break;
never executed: break;
0
2167 -
2168 -
2169 -
2170 -
2171 case Qt::Key_Return: -
2172 case Qt::Key_Enter: { -
2173 if (!d->currentAction) {
partially evaluated: !d->currentAction
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7
0-7
2174 d->setFirstActionActive(); -
2175 key_consumed = true; -
2176 break;
never executed: break;
0
2177 } -
2178 -
2179 d->setSyncAction(); -
2180 -
2181 if (d->currentAction->menu())
partially evaluated: d->currentAction->menu()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7
0-7
2182 d->popupAction(d->currentAction, 0, true);
never executed: d->popupAction(d->currentAction, 0, true);
0
2183 else -
2184 d->activateAction(d->currentAction, QAction::Trigger);
executed: d->activateAction(d->currentAction, QAction::Trigger);
Execution Count:7
7
2185 key_consumed = true; -
2186 break; }
executed: break;
Execution Count:7
7
2187 -
2188 -
2189 case Qt::Key_F1: -
2190 if (!d->currentAction || d->currentAction->whatsThis().isNull())
never evaluated: !d->currentAction
never evaluated: d->currentAction->whatsThis().isNull()
0
2191 break;
never executed: break;
0
2192 QWhatsThis::enterWhatsThisMode(); -
2193 d->activateAction(d->currentAction, QAction::Trigger); -
2194 return;
never executed: return;
0
2195 -
2196 default: -
2197 key_consumed = false; -
2198 }
executed: }
Execution Count:3
3
2199 -
2200 if (!key_consumed) {
evaluated: !key_consumed
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:34
7-34
2201 if ((!e->modifiers() || e->modifiers() == Qt::AltModifier || e->modifiers() == Qt::ShiftModifier) &&
evaluated: !e->modifiers()
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:1
partially evaluated: e->modifiers() == Qt::AltModifier
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
never evaluated: e->modifiers() == Qt::ShiftModifier
0-6
2202 e->text().length()==1) {
evaluated: e->text().length()==1
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:4
3-4
2203 bool activateAction = false; -
2204 QAction *nextAction = 0; -
2205 if (style()->styleHint(QStyle::SH_Menu_KeyboardSearch, 0, this) && !e->modifiers()) {
partially evaluated: style()->styleHint(QStyle::SH_Menu_KeyboardSearch, 0, this)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
never evaluated: !e->modifiers()
0-3
2206 int best_match_count = 0; -
2207 d->searchBufferTimer.start(2000, this); -
2208 d->searchBuffer += e->text(); -
2209 for(int i = 0; i < d->actions.size(); ++i) {
never evaluated: i < d->actions.size()
0
2210 int match_count = 0; -
2211 if (d->actionRects.at(i).isNull())
never evaluated: d->actionRects.at(i).isNull()
0
2212 continue;
never executed: continue;
0
2213 QAction *act = d->actions.at(i); -
2214 const QString act_text = act->text(); -
2215 for(int c = 0; c < d->searchBuffer.size(); ++c) {
never evaluated: c < d->searchBuffer.size()
0
2216 if(act_text.indexOf(d->searchBuffer.at(c), 0, Qt::CaseInsensitive) != -1)
never evaluated: act_text.indexOf(d->searchBuffer.at(c), 0, Qt::CaseInsensitive) != -1
0
2217 ++match_count;
never executed: ++match_count;
0
2218 }
never executed: }
0
2219 if(match_count > best_match_count) {
never evaluated: match_count > best_match_count
0
2220 best_match_count = match_count; -
2221 nextAction = act; -
2222 }
never executed: }
0
2223 }
never executed: }
0
2224 }
never executed: }
0
2225 -
2226 else { -
2227 int clashCount = 0; -
2228 QAction *first = 0, *currentSelected = 0, *firstAfterCurrent = 0; -
2229 QChar c = e->text().at(0).toUpper(); -
2230 for(int i = 0; i < d->actions.size(); ++i) {
evaluated: i < d->actions.size()
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:3
3-11
2231 if (d->actionRects.at(i).isNull())
partially evaluated: d->actionRects.at(i).isNull()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:11
0-11
2232 continue;
never executed: continue;
0
2233 QAction *act = d->actions.at(i); -
2234 QKeySequence sequence = QKeySequence::mnemonic(act->text()); -
2235 int key = sequence[0] & 0xffff; -
2236 if (key == c.unicode()) {
evaluated: key == c.unicode()
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:8
3-8
2237 clashCount++; -
2238 if (!first)
partially evaluated: !first
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
2239 first = act;
executed: first = act;
Execution Count:3
3
2240 if (act == d->currentAction)
evaluated: act == d->currentAction
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2
1-2
2241 currentSelected = act;
executed: currentSelected = act;
Execution Count:1
1
2242 else if (!firstAfterCurrent && currentSelected)
partially evaluated: !firstAfterCurrent
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
partially evaluated: currentSelected
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
2243 firstAfterCurrent = act;
never executed: firstAfterCurrent = act;
0
2244 } -
2245 }
executed: }
Execution Count:11
11
2246 if (clashCount == 1)
partially evaluated: clashCount == 1
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
2247 activateAction = true;
executed: activateAction = true;
Execution Count:3
3
2248 if (clashCount >= 1) {
partially evaluated: clashCount >= 1
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
2249 if (clashCount == 1 || !currentSelected || !firstAfterCurrent)
partially evaluated: clashCount == 1
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
never evaluated: !currentSelected
never evaluated: !firstAfterCurrent
0-3
2250 nextAction = first;
executed: nextAction = first;
Execution Count:3
3
2251 else -
2252 nextAction = firstAfterCurrent;
never executed: nextAction = firstAfterCurrent;
0
2253 } -
2254 }
executed: }
Execution Count:3
3
2255 -
2256 if (nextAction) {
partially evaluated: nextAction
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
2257 key_consumed = true; -
2258 if(d->scroll)
partially evaluated: d->scroll
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
2259 d->scrollMenu(nextAction, QMenuPrivate::QMenuScroller::ScrollCenter, false);
never executed: d->scrollMenu(nextAction, QMenuPrivate::QMenuScroller::ScrollCenter, false);
0
2260 d->setCurrentAction(nextAction, 0, QMenuPrivate::SelectedFromElsewhere, true); -
2261 if (!nextAction->menu() && activateAction) {
evaluated: !nextAction->menu()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2
partially evaluated: activateAction
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-2
2262 d->setSyncAction(); -
2263 d->activateAction(nextAction, QAction::Trigger); -
2264 }
executed: }
Execution Count:1
1
2265 }
executed: }
Execution Count:3
3
2266 }
executed: }
Execution Count:3
3
2267 if (!key_consumed) {
evaluated: !key_consumed
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:3
3-4
2268 -
2269 if (QMenuBar *mb = qobject_cast<QMenuBar*>(d->topCausedWidget())) {
partially evaluated: QMenuBar *mb = qobject_cast<QMenuBar*>(d->topCausedWidget())
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
2270 QAction *oldAct = mb->d_func()->currentAction; -
2271 QApplication::sendEvent(mb, e); -
2272 if (mb->d_func()->currentAction != oldAct)
partially evaluated: mb->d_func()->currentAction != oldAct
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
2273 key_consumed = true;
executed: key_consumed = true;
Execution Count:4
4
2274 }
executed: }
Execution Count:4
4
2275 -
2276 }
executed: }
Execution Count:4
4
2277 -
2278 -
2279 -
2280 -
2281 -
2282 }
executed: }
Execution Count:7
7
2283 if (key_consumed)
partially evaluated: key_consumed
TRUEFALSE
yes
Evaluation Count:41
no
Evaluation Count:0
0-41
2284 e->accept();
executed: e->accept();
Execution Count:41
41
2285 else -
2286 e->ignore();
never executed: e->ignore();
0
2287} -
2288 -
2289 -
2290 -
2291 -
2292void QMenu::mouseMoveEvent(QMouseEvent *e) -
2293{ -
2294 QMenuPrivate * const d = d_func(); -
2295 if (!isVisible() || d->aboutToHide || d->mouseEventTaken(e))
partially evaluated: !isVisible()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
partially evaluated: d->aboutToHide
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
evaluated: d->mouseEventTaken(e)
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
0-2
2296 return;
executed: return;
Execution Count:1
1
2297 d->motions++; -
2298 if (d->motions == 0)
partially evaluated: d->motions == 0
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
2299 return;
executed: return;
Execution Count:1
1
2300 d->hasHadMouse = d->hasHadMouse || rect().contains(e->pos());
never evaluated: d->hasHadMouse
never evaluated: rect().contains(e->pos())
0
2301 -
2302 QAction *action = d->actionAt(e->pos()); -
2303 if (!action) {
never evaluated: !action
0
2304 if (d->hasHadMouse
never evaluated: d->hasHadMouse
0
2305 && (!d->currentAction
never evaluated: !d->currentAction
0
2306 || !(d->currentAction->menu() && d->currentAction->menu()->isVisible())))
never evaluated: d->currentAction->menu()
never evaluated: d->currentAction->menu()->isVisible()
0
2307 d->setCurrentAction(0);
never executed: d->setCurrentAction(0);
0
2308 return;
never executed: return;
0
2309 } else if(e->buttons()) {
never evaluated: e->buttons()
0
2310 d->mouseDown = this; -
2311 }
never executed: }
0
2312 if (d->sloppyRegion.contains(e->pos())) {
never evaluated: d->sloppyRegion.contains(e->pos())
0
2313 d->sloppyAction = action; -
2314 QMenuPrivate::sloppyDelayTimer = startTimer(style()->styleHint(QStyle::SH_Menu_SubMenuPopupDelay, 0, this)*6); -
2315 } else if (action != d->currentAction) {
never executed: }
never evaluated: action != d->currentAction
0
2316 d->setCurrentAction(action, style()->styleHint(QStyle::SH_Menu_SubMenuPopupDelay, 0, this)); -
2317 }
never executed: }
0
2318} -
2319 -
2320 -
2321 -
2322 -
2323void QMenu::enterEvent(QEvent *) -
2324{ -
2325 d_func()->motions = -1; -
2326}
executed: }
Execution Count:7
7
2327 -
2328 -
2329 -
2330 -
2331void QMenu::leaveEvent(QEvent *) -
2332{ -
2333 QMenuPrivate * const d = d_func(); -
2334 d->sloppyAction = 0; -
2335 if (!d->sloppyRegion.isEmpty())
partially evaluated: !d->sloppyRegion.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:15
0-15
2336 d->sloppyRegion = QRegion();
never executed: d->sloppyRegion = QRegion();
0
2337 if (!d->activeMenu && d->currentAction)
partially evaluated: !d->activeMenu
TRUEFALSE
yes
Evaluation Count:15
no
Evaluation Count:0
evaluated: d->currentAction
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:14
0-15
2338 setActiveAction(0);
executed: setActiveAction(0);
Execution Count:1
1
2339}
executed: }
Execution Count:15
15
2340 -
2341 -
2342 -
2343 -
2344void -
2345QMenu::timerEvent(QTimerEvent *e) -
2346{ -
2347 QMenuPrivate * const d = d_func(); -
2348 if (d->scroll && d->scroll->scrollTimer.timerId() == e->timerId()) {
partially evaluated: d->scroll
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
never evaluated: d->scroll->scrollTimer.timerId() == e->timerId()
0-2
2349 d->scrollMenu((QMenuPrivate::QMenuScroller::ScrollDirection)d->scroll->scrollDirection); -
2350 if (d->scroll->scrollFlags == QMenuPrivate::QMenuScroller::ScrollNone)
never evaluated: d->scroll->scrollFlags == QMenuPrivate::QMenuScroller::ScrollNone
0
2351 d->scroll->scrollTimer.stop();
never executed: d->scroll->scrollTimer.stop();
0
2352 } else if(d->menuDelayTimer.timerId() == e->timerId()) {
never executed: }
partially evaluated: d->menuDelayTimer.timerId() == e->timerId()
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
2353 d->menuDelayTimer.stop(); -
2354 internalDelayedPopup(); -
2355 } else if(QMenuPrivate::sloppyDelayTimer == e->timerId()) {
executed: }
Execution Count:2
never evaluated: QMenuPrivate::sloppyDelayTimer == e->timerId()
0-2
2356 killTimer(QMenuPrivate::sloppyDelayTimer); -
2357 QMenuPrivate::sloppyDelayTimer = 0; -
2358 internalSetSloppyAction(); -
2359 } else if(d->searchBufferTimer.timerId() == e->timerId()) {
never executed: }
never evaluated: d->searchBufferTimer.timerId() == e->timerId()
0
2360 d->searchBuffer.clear(); -
2361 }
never executed: }
0
2362} -
2363 -
2364void copyActionToPlatformItem(const QAction *action, QPlatformMenuItem* item) -
2365{ -
2366 item->setText(action->text()); -
2367 item->setIsSeparator(action->isSeparator()); -
2368 if (action->isIconVisibleInMenu())
never evaluated: action->isIconVisibleInMenu()
0
2369 item->setIcon(action->icon());
never executed: item->setIcon(action->icon());
0
2370 item->setVisible(action->isVisible()); -
2371 item->setShortcut(action->shortcut()); -
2372 item->setChecked(action->isChecked()); -
2373 item->setFont(action->font()); -
2374 item->setRole((QPlatformMenuItem::MenuRole) action->menuRole()); -
2375 item->setEnabled(action->isEnabled()); -
2376 -
2377 if (action->menu()) {
never evaluated: action->menu()
0
2378 item->setMenu(action->menu()->platformMenu()); -
2379 } else {
never executed: }
0
2380 item->setMenu(0); -
2381 }
never executed: }
0
2382} -
2383 -
2384 -
2385 -
2386 -
2387void QMenu::actionEvent(QActionEvent *e) -
2388{ -
2389 QMenuPrivate * const d = d_func(); -
2390 d->itemsDirty = 1; -
2391 setAttribute(Qt::WA_Resized, false); -
2392 if (d->tornPopup)
partially evaluated: d->tornPopup
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7730
0-7730
2393 d->tornPopup->syncWithMenu(this, e);
never executed: d->tornPopup->syncWithMenu(this, e);
0
2394 if (e->type() == QEvent::ActionAdded) {
evaluated: e->type() == QEvent::ActionAdded
TRUEFALSE
yes
Evaluation Count:1701
yes
Evaluation Count:6029
1701-6029
2395 if(!d->tornoff) {
evaluated: !d->tornoff
TRUEFALSE
yes
Evaluation Count:1699
yes
Evaluation Count:2
2-1699
2396 connect(e->action(), "2""triggered()", this, "1""_q_actionTriggered()"); -
2397 connect(e->action(), "2""hovered()", this, "1""_q_actionHovered()"); -
2398 }
executed: }
Execution Count:1699
1699
2399 if (QWidgetAction *wa = qobject_cast<QWidgetAction *>(e->action())) {
evaluated: QWidgetAction *wa = qobject_cast<QWidgetAction *>(e->action())
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:1698
3-1698
2400 QWidget *widget = wa->requestWidget(this); -
2401 if (widget)
partially evaluated: widget
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
2402 d->widgetItems.insert(wa, widget);
executed: d->widgetItems.insert(wa, widget);
Execution Count:3
3
2403 }
executed: }
Execution Count:3
3
2404 } else if (e->type() == QEvent::ActionRemoved) {
executed: }
Execution Count:1701
evaluated: e->type() == QEvent::ActionRemoved
TRUEFALSE
yes
Evaluation Count:244
yes
Evaluation Count:5785
244-5785
2405 e->action()->disconnect(this); -
2406 if (e->action() == d->currentAction)
evaluated: e->action() == d->currentAction
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:239
5-239
2407 d->currentAction = 0;
executed: d->currentAction = 0;
Execution Count:5
5
2408 if (QWidgetAction *wa = qobject_cast<QWidgetAction *>(e->action())) {
partially evaluated: QWidgetAction *wa = qobject_cast<QWidgetAction *>(e->action())
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:244
0-244
2409 if (QWidget *widget = d->widgetItems.value(wa))
never evaluated: QWidget *widget = d->widgetItems.value(wa)
0
2410 wa->releaseWidget(widget);
never executed: wa->releaseWidget(widget);
0
2411 }
never executed: }
0
2412 d->widgetItems.remove(e->action()); -
2413 }
executed: }
Execution Count:244
244
2414 -
2415 if (d->platformMenu) {
partially evaluated: d->platformMenu
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7730
0-7730
2416 if (e->type() == QEvent::ActionAdded) {
never evaluated: e->type() == QEvent::ActionAdded
0
2417 QPlatformMenuItem *menuItem = -
2418 QGuiApplicationPrivate::platformTheme()->createPlatformMenuItem(); -
2419 menuItem->setTag(reinterpret_cast<quintptr>(e->action())); -
2420 QObject::connect(menuItem, "2""activated()", e->action(), "1""trigger()"); -
2421 copyActionToPlatformItem(e->action(), menuItem); -
2422 QPlatformMenuItem* beforeItem = d->platformMenu->menuItemForTag(reinterpret_cast<quintptr>(e->before())); -
2423 d->platformMenu->insertMenuItem(menuItem, beforeItem); -
2424 } else if (e->type() == QEvent::ActionRemoved) {
never executed: }
never evaluated: e->type() == QEvent::ActionRemoved
0
2425 QPlatformMenuItem *menuItem = d->platformMenu->menuItemForTag(reinterpret_cast<quintptr>(e->action())); -
2426 d->platformMenu->removeMenuItem(menuItem); -
2427 } else if (e->type() == QEvent::ActionChanged) {
never executed: }
never evaluated: e->type() == QEvent::ActionChanged
0
2428 QPlatformMenuItem *menuItem = d->platformMenu->menuItemForTag(reinterpret_cast<quintptr>(e->action())); -
2429 copyActionToPlatformItem(e->action(), menuItem); -
2430 d->platformMenu->syncMenuItem(menuItem); -
2431 }
never executed: }
0
2432 -
2433 d->platformMenu->syncSeparatorsCollapsible(d->collapsibleSeparators); -
2434 }
never executed: }
0
2435 if (isVisible()) {
evaluated: isVisible()
TRUEFALSE
yes
Evaluation Count:39
yes
Evaluation Count:7691
39-7691
2436 d->updateActionRects(); -
2437 resize(sizeHint()); -
2438 update(); -
2439 }
executed: }
Execution Count:39
39
2440}
executed: }
Execution Count:7730
7730
2441 -
2442 -
2443 -
2444 -
2445void QMenu::internalSetSloppyAction() -
2446{ -
2447 if (d_func()->sloppyAction)
never evaluated: d_func()->sloppyAction
0
2448 d_func()->setCurrentAction(d_func()->sloppyAction, 0);
never executed: d_func()->setCurrentAction(d_func()->sloppyAction, 0);
0
2449}
never executed: }
0
2450 -
2451 -
2452 -
2453 -
2454void QMenu::internalDelayedPopup() -
2455{ -
2456 QMenuPrivate * const d = d_func(); -
2457 -
2458 -
2459 if (QMenu *menu = d->activeMenu) {
partially evaluated: QMenu *menu = d->activeMenu
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:14
0-14
2460 d->activeMenu = 0; -
2461 d->hideMenu(menu); -
2462 }
never executed: }
0
2463 -
2464 if (!d->currentAction || !d->currentAction->isEnabled() || !d->currentAction->menu() ||
evaluated: !d->currentAction
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:13
partially evaluated: !d->currentAction->isEnabled()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:13
evaluated: !d->currentAction->menu()
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:7
0-13
2465 !d->currentAction->menu()->isEnabled() || d->currentAction->menu()->isVisible())
partially evaluated: !d->currentAction->menu()->isEnabled()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7
partially evaluated: d->currentAction->menu()->isVisible()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7
0-7
2466 return;
executed: return;
Execution Count:7
7
2467 -
2468 -
2469 d->activeMenu = d->currentAction->menu(); -
2470 d->activeMenu->d_func()->causedPopup.widget = this; -
2471 d->activeMenu->d_func()->causedPopup.action = d->currentAction; -
2472 -
2473 int subMenuOffset = style()->pixelMetric(QStyle::PM_SubMenuOverlap, 0, this); -
2474 const QRect actionRect(d->actionRect(d->currentAction)); -
2475 const QSize menuSize(d->activeMenu->sizeHint()); -
2476 const QPoint rightPos(mapToGlobal(QPoint(actionRect.right() + subMenuOffset + 1, actionRect.top()))); -
2477 -
2478 QPoint pos(rightPos); -
2479 -
2480 -
2481 if (style()->styleHint(QStyle::SH_Menu_SloppySubMenus, 0, this)) {
partially evaluated: style()->styleHint(QStyle::SH_Menu_SloppySubMenus, 0, this)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7
0-7
2482 QPoint cur = QCursor::pos(); -
2483 if (actionRect.contains(mapFromGlobal(cur))) {
never evaluated: actionRect.contains(mapFromGlobal(cur))
0
2484 QPoint pts[4]; -
2485 pts[0] = QPoint(cur.x(), cur.y() - 2); -
2486 pts[3] = QPoint(cur.x(), cur.y() + 2); -
2487 if (pos.x() >= cur.x()) {
never evaluated: pos.x() >= cur.x()
0
2488 pts[1] = QPoint(geometry().right(), pos.y()); -
2489 pts[2] = QPoint(geometry().right(), pos.y() + menuSize.height()); -
2490 } else {
never executed: }
0
2491 pts[1] = QPoint(pos.x() + menuSize.width(), pos.y()); -
2492 pts[2] = QPoint(pos.x() + menuSize.width(), pos.y() + menuSize.height()); -
2493 }
never executed: }
0
2494 QPolygon points(4); -
2495 for(int i = 0; i < 4; i++)
never evaluated: i < 4
0
2496 points.setPoint(i, mapFromGlobal(pts[i]));
never executed: points.setPoint(i, mapFromGlobal(pts[i]));
0
2497 d->sloppyRegion = QRegion(points); -
2498 }
never executed: }
0
2499 }
never executed: }
0
2500 -
2501 -
2502 d->activeMenu->popup(pos); -
2503}
executed: }
Execution Count:7
7
2504void QMenu::setNoReplayFor(QWidget *noReplayFor) -
2505{ -
2506 -
2507 -
2508 -
2509 (void)noReplayFor;; -
2510 -
2511}
executed: }
Execution Count:6
6
2512 -
2513 -
2514 -
2515QPlatformMenu *QMenu::platformMenu() -
2516{ -
2517 -
2518 return d_func()->platformMenu;
never executed: return d_func()->platformMenu;
0
2519} -
2520bool QMenu::separatorsCollapsible() const -
2521{ -
2522 const QMenuPrivate * const d = d_func(); -
2523 return d->collapsibleSeparators;
never executed: return d->collapsibleSeparators;
0
2524} -
2525 -
2526void QMenu::setSeparatorsCollapsible(bool collapse) -
2527{ -
2528 QMenuPrivate * const d = d_func(); -
2529 if (d->collapsibleSeparators == collapse)
never evaluated: d->collapsibleSeparators == collapse
0
2530 return;
never executed: return;
0
2531 -
2532 d->collapsibleSeparators = collapse; -
2533 d->itemsDirty = 1; -
2534 if (isVisible()) {
never evaluated: isVisible()
0
2535 d->updateActionRects(); -
2536 update(); -
2537 }
never executed: }
0
2538 if (d->platformMenu)
never evaluated: d->platformMenu
0
2539 d->platformMenu->syncSeparatorsCollapsible(collapse);
never executed: d->platformMenu->syncSeparatorsCollapsible(collapse);
0
2540}
never executed: }
0
2541 -
2542 -
2543 -
2544 -
2545 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial