Line | Source Code | Coverage |
---|
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | | - |
6 | | - |
7 | | - |
8 | | - |
9 | | - |
10 | | - |
11 | | - |
12 | | - |
13 | | - |
14 | | - |
15 | class QMenuBarExtension : public QToolButton | - |
16 | { | - |
17 | public: | - |
18 | explicit QMenuBarExtension(QWidget *parent); | - |
19 | | - |
20 | QSize sizeHint() const; | - |
21 | void paintEvent(QPaintEvent *); | - |
22 | }; | - |
23 | | - |
24 | QMenuBarExtension::QMenuBarExtension(QWidget *parent) | - |
25 | : QToolButton(parent) | - |
26 | { | - |
27 | setObjectName(QLatin1String("qt_menubar_ext_button")); | - |
28 | setAutoRaise(true); | - |
29 | | - |
30 | setPopupMode(QToolButton::InstantPopup); | - |
31 | | - |
32 | setIcon(style()->standardIcon(QStyle::SP_ToolBarHorizontalExtensionButton, 0, parentWidget())); | - |
33 | } executed: } Execution Count:23 | 23 |
34 | | - |
35 | void QMenuBarExtension::paintEvent(QPaintEvent *) | - |
36 | { | - |
37 | QStylePainter p(this); | - |
38 | QStyleOptionToolButton opt; | - |
39 | initStyleOption(&opt); | - |
40 | | - |
41 | opt.features &= ~QStyleOptionToolButton::HasMenu; | - |
42 | p.drawComplexControl(QStyle::CC_ToolButton, opt); | - |
43 | } executed: } Execution Count:6 | 6 |
44 | | - |
45 | | - |
46 | QSize QMenuBarExtension::sizeHint() const | - |
47 | { | - |
48 | int ext = style()->pixelMetric(QStyle::PM_ToolBarExtensionExtent, 0, parentWidget()); | - |
49 | return QSize(ext, ext); executed: return QSize(ext, ext); Execution Count:122 | 122 |
50 | } | - |
51 | | - |
52 | | - |
53 | | - |
54 | | - |
55 | | - |
56 | QAction *QMenuBarPrivate::actionAt(QPoint p) const | - |
57 | { | - |
58 | for(int i = 0; i < actions.size(); ++i) { partially evaluated: i < actions.size() yes Evaluation Count:14 | no Evaluation Count:0 |
| 0-14 |
59 | if(actionRect(actions.at(i)).contains(p)) evaluated: actionRect(actions.at(i)).contains(p) yes Evaluation Count:8 | yes Evaluation Count:6 |
| 6-8 |
60 | return actions.at(i); executed: return actions.at(i); Execution Count:8 | 8 |
61 | } executed: } Execution Count:6 | 6 |
62 | return 0; never executed: return 0; | 0 |
63 | } | - |
64 | | - |
65 | QRect QMenuBarPrivate::menuRect(bool extVisible) const | - |
66 | { | - |
67 | const QMenuBar * const q = q_func(); | - |
68 | | - |
69 | int hmargin = q->style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, q); | - |
70 | QRect result = q->rect(); | - |
71 | result.adjust(hmargin, 0, -hmargin, 0); | - |
72 | | - |
73 | if (extVisible) { evaluated: extVisible yes Evaluation Count:60 | yes Evaluation Count:360 |
| 60-360 |
74 | if (q->isRightToLeft()) evaluated: q->isRightToLeft() yes Evaluation Count:2 | yes Evaluation Count:58 |
| 2-58 |
75 | result.setLeft(result.left() + extension->sizeHint().width()); executed: result.setLeft(result.left() + extension->sizeHint().width()); Execution Count:2 | 2 |
76 | else | - |
77 | result.setWidth(result.width() - extension->sizeHint().width()); executed: result.setWidth(result.width() - extension->sizeHint().width()); Execution Count:58 | 58 |
78 | } | - |
79 | | - |
80 | if (leftWidget && leftWidget->isVisible()) { evaluated: leftWidget yes Evaluation Count:184 | yes Evaluation Count:236 |
evaluated: leftWidget->isVisible() yes Evaluation Count:143 | yes Evaluation Count:41 |
| 41-236 |
81 | QSize sz = leftWidget->sizeHint(); | - |
82 | if (q->isRightToLeft()) evaluated: q->isRightToLeft() yes Evaluation Count:4 | yes Evaluation Count:139 |
| 4-139 |
83 | result.setRight(result.right() - sz.width()); executed: result.setRight(result.right() - sz.width()); Execution Count:4 | 4 |
84 | else | - |
85 | result.setLeft(result.left() + sz.width()); executed: result.setLeft(result.left() + sz.width()); Execution Count:139 | 139 |
86 | } | - |
87 | | - |
88 | if (rightWidget && rightWidget->isVisible()) { evaluated: rightWidget yes Evaluation Count:101 | yes Evaluation Count:319 |
evaluated: rightWidget->isVisible() yes Evaluation Count:60 | yes Evaluation Count:41 |
| 41-319 |
89 | QSize sz = rightWidget->sizeHint(); | - |
90 | if (q->isRightToLeft()) evaluated: q->isRightToLeft() yes Evaluation Count:2 | yes Evaluation Count:58 |
| 2-58 |
91 | result.setLeft(result.left() + sz.width()); executed: result.setLeft(result.left() + sz.width()); Execution Count:2 | 2 |
92 | else | - |
93 | result.setRight(result.right() - sz.width()); executed: result.setRight(result.right() - sz.width()); Execution Count:58 | 58 |
94 | } | - |
95 | | - |
96 | return result; executed: return result; Execution Count:420 | 420 |
97 | } | - |
98 | | - |
99 | bool QMenuBarPrivate::isVisible(QAction *action) | - |
100 | { | - |
101 | return !hiddenActions.contains(action); executed: return !hiddenActions.contains(action); Execution Count:69 | 69 |
102 | } | - |
103 | | - |
104 | void QMenuBarPrivate::updateGeometries() | - |
105 | { | - |
106 | QMenuBar * const q = q_func(); | - |
107 | if(!itemsDirty) evaluated: !itemsDirty yes Evaluation Count:394 | yes Evaluation Count:360 |
| 360-394 |
108 | return; executed: return; Execution Count:394 | 394 |
109 | int q_width = q->width()-(q->style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, q)*2); | - |
110 | int q_start = -1; | - |
111 | if(leftWidget || rightWidget) { evaluated: leftWidget yes Evaluation Count:184 | yes Evaluation Count:176 |
partially evaluated: rightWidget no Evaluation Count:0 | yes Evaluation Count:176 |
| 0-184 |
112 | int vmargin = q->style()->pixelMetric(QStyle::PM_MenuBarVMargin, 0, q) | - |
113 | + q->style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, q); | - |
114 | int hmargin = q->style()->pixelMetric(QStyle::PM_MenuBarHMargin, 0, q) | - |
115 | + q->style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, q); | - |
116 | if (leftWidget && leftWidget->isVisible()) { partially evaluated: leftWidget yes Evaluation Count:184 | no Evaluation Count:0 |
evaluated: leftWidget->isVisible() yes Evaluation Count:143 | yes Evaluation Count:41 |
| 0-184 |
117 | QSize sz = leftWidget->sizeHint(); | - |
118 | q_width -= sz.width(); | - |
119 | q_start = sz.width(); | - |
120 | QPoint pos(hmargin, (q->height() - leftWidget->height()) / 2); | - |
121 | QRect vRect = QStyle::visualRect(q->layoutDirection(), q->rect(), QRect(pos, sz)); | - |
122 | leftWidget->setGeometry(vRect); | - |
123 | } executed: } Execution Count:143 | 143 |
124 | if (rightWidget && rightWidget->isVisible()) { evaluated: rightWidget yes Evaluation Count:101 | yes Evaluation Count:83 |
evaluated: rightWidget->isVisible() yes Evaluation Count:60 | yes Evaluation Count:41 |
| 41-101 |
125 | QSize sz = rightWidget->sizeHint(); | - |
126 | q_width -= sz.width(); | - |
127 | QPoint pos(q->width() - sz.width() - hmargin, vmargin); | - |
128 | QRect vRect = QStyle::visualRect(q->layoutDirection(), q->rect(), QRect(pos, sz)); | - |
129 | rightWidget->setGeometry(vRect); | - |
130 | } executed: } Execution Count:60 | 60 |
131 | } executed: } Execution Count:184 | 184 |
132 | | - |
133 | | - |
134 | | - |
135 | | - |
136 | | - |
137 | | - |
138 | | - |
139 | calcActionRects(q_width, q_start); | - |
140 | currentAction = 0; | - |
141 | | - |
142 | if(itemsDirty) { partially evaluated: itemsDirty yes Evaluation Count:360 | no Evaluation Count:0 |
| 0-360 |
143 | for(int j = 0; j < shortcutIndexMap.size(); ++j) evaluated: j < shortcutIndexMap.size() yes Evaluation Count:312 | yes Evaluation Count:360 |
| 312-360 |
144 | q->releaseShortcut(shortcutIndexMap.value(j)); executed: q->releaseShortcut(shortcutIndexMap.value(j)); Execution Count:312 | 312 |
145 | shortcutIndexMap.resize(0); | - |
146 | for(int i = 0; i < actions.count(); i++) evaluated: i < actions.count() yes Evaluation Count:332 | yes Evaluation Count:360 |
| 332-360 |
147 | shortcutIndexMap.append(q->grabShortcut(QKeySequence::mnemonic(actions.at(i)->text()))); executed: shortcutIndexMap.append(q->grabShortcut(QKeySequence::mnemonic(actions.at(i)->text()))); Execution Count:332 | 332 |
148 | } executed: } Execution Count:360 | 360 |
149 | | - |
150 | itemsDirty = false; | - |
151 | | - |
152 | hiddenActions.clear(); | - |
153 | | - |
154 | QRect menuRect = this->menuRect(false); | - |
155 | | - |
156 | | - |
157 | bool hasHiddenActions = false; | - |
158 | for (int i = 0; i < actions.count(); ++i) { evaluated: i < actions.count() yes Evaluation Count:212 | yes Evaluation Count:300 |
| 212-300 |
159 | const QRect &rect = actionRects.at(i); | - |
160 | if (rect.isValid() && !menuRect.contains(rect)) { evaluated: rect.isValid() yes Evaluation Count:207 | yes Evaluation Count:5 |
evaluated: !menuRect.contains(rect) yes Evaluation Count:60 | yes Evaluation Count:147 |
| 5-207 |
161 | hasHiddenActions = true; | - |
162 | break; executed: break; Execution Count:60 | 60 |
163 | } | - |
164 | } executed: } Execution Count:152 | 152 |
165 | | - |
166 | | - |
167 | if (hasHiddenActions) { evaluated: hasHiddenActions yes Evaluation Count:60 | yes Evaluation Count:300 |
| 60-300 |
168 | menuRect = this->menuRect(true); | - |
169 | for (int i = 0; i < actions.count(); ++i) { evaluated: i < actions.count() yes Evaluation Count:243 | yes Evaluation Count:60 |
| 60-243 |
170 | const QRect &rect = actionRects.at(i); | - |
171 | if (rect.isValid() && !menuRect.contains(rect)) { evaluated: rect.isValid() yes Evaluation Count:242 | yes Evaluation Count:1 |
evaluated: !menuRect.contains(rect) yes Evaluation Count:181 | yes Evaluation Count:61 |
| 1-242 |
172 | hiddenActions.append(actions.at(i)); | - |
173 | } executed: } Execution Count:181 | 181 |
174 | } executed: } Execution Count:243 | 243 |
175 | } executed: } Execution Count:60 | 60 |
176 | | - |
177 | if (hiddenActions.count() > 0) { evaluated: hiddenActions.count() > 0 yes Evaluation Count:60 | yes Evaluation Count:300 |
| 60-300 |
178 | QMenu *pop = extension->menu(); | - |
179 | if (!pop) { evaluated: !pop yes Evaluation Count:4 | yes Evaluation Count:56 |
| 4-56 |
180 | pop = new QMenu(q); | - |
181 | extension->setMenu(pop); | - |
182 | } executed: } Execution Count:4 | 4 |
183 | pop->clear(); | - |
184 | pop->addActions(hiddenActions); | - |
185 | | - |
186 | int vmargin = q->style()->pixelMetric(QStyle::PM_MenuBarVMargin, 0, q); | - |
187 | int x = q->isRightToLeft() evaluated: q->isRightToLeft() yes Evaluation Count:2 | yes Evaluation Count:58 |
| 2-58 |
188 | ? menuRect.left() - extension->sizeHint().width() + 1 | - |
189 | : menuRect.right(); | - |
190 | extension->setGeometry(x, vmargin, extension->sizeHint().width(), menuRect.height() - vmargin*2); | - |
191 | extension->show(); | - |
192 | } else { executed: } Execution Count:60 | 60 |
193 | extension->hide(); | - |
194 | } executed: } Execution Count:300 | 300 |
195 | q->updateGeometry(); | - |
196 | } executed: } Execution Count:360 | 360 |
197 | | - |
198 | QRect QMenuBarPrivate::actionRect(QAction *act) const | - |
199 | { | - |
200 | const int index = actions.indexOf(act); | - |
201 | | - |
202 | | - |
203 | const_cast<QMenuBarPrivate*>(this)->updateGeometries(); | - |
204 | | - |
205 | if (index < 0 || index >= actionRects.count()) evaluated: index < 0 yes Evaluation Count:2 | yes Evaluation Count:216 |
partially evaluated: index >= actionRects.count() no Evaluation Count:0 | yes Evaluation Count:216 |
| 0-216 |
206 | return QRect(); executed: return QRect(); Execution Count:2 | 2 |
207 | | - |
208 | return actionRects.at(index); executed: return actionRects.at(index); Execution Count:216 | 216 |
209 | } | - |
210 | | - |
211 | void QMenuBarPrivate::focusFirstAction() | - |
212 | { | - |
213 | if(!currentAction) { evaluated: !currentAction yes Evaluation Count:1 | yes Evaluation Count:34 |
| 1-34 |
214 | updateGeometries(); | - |
215 | int index = 0; | - |
216 | while (index < actions.count() && actionRects.at(index).isNull()) ++index; partially evaluated: index < actions.count() yes Evaluation Count:1 | no Evaluation Count:0 |
partially evaluated: actionRects.at(index).isNull() no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
217 | if (index < actions.count()) partially evaluated: index < actions.count() yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
218 | setCurrentAction(actions.at(index)); executed: setCurrentAction(actions.at(index)); Execution Count:1 | 1 |
219 | } executed: } Execution Count:1 | 1 |
220 | } executed: } Execution Count:35 | 35 |
221 | | - |
222 | void QMenuBarPrivate::setKeyboardMode(bool b) | - |
223 | { | - |
224 | QMenuBar * const q = q_func(); | - |
225 | if (b && !q->style()->styleHint(QStyle::SH_MenuBar_AltKeyNavigation, 0, q)) { evaluated: b yes Evaluation Count:14 | yes Evaluation Count:11 |
partially evaluated: !q->style()->styleHint(QStyle::SH_MenuBar_AltKeyNavigation, 0, q) no Evaluation Count:0 | yes Evaluation Count:14 |
| 0-14 |
226 | setCurrentAction(0); | - |
227 | return; | 0 |
228 | } | - |
229 | keyboardState = b; | - |
230 | if(b) { evaluated: b yes Evaluation Count:14 | yes Evaluation Count:11 |
| 11-14 |
231 | QWidget *fw = QApplication::focusWidget(); | - |
232 | if (fw != q) evaluated: fw != q yes Evaluation Count:5 | yes Evaluation Count:9 |
| 5-9 |
233 | keyboardFocusWidget = fw; executed: keyboardFocusWidget = fw; Execution Count:5 | 5 |
234 | focusFirstAction(); | - |
235 | q->setFocus(Qt::MenuBarFocusReason); | - |
236 | } else { executed: } Execution Count:14 | 14 |
237 | if(!popupState) partially evaluated: !popupState yes Evaluation Count:11 | no Evaluation Count:0 |
| 0-11 |
238 | setCurrentAction(0); executed: setCurrentAction(0); Execution Count:11 | 11 |
239 | if(keyboardFocusWidget) { evaluated: keyboardFocusWidget yes Evaluation Count:1 | yes Evaluation Count:10 |
| 1-10 |
240 | if (QApplication::focusWidget() == q) partially evaluated: QApplication::focusWidget() == q no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
241 | keyboardFocusWidget->setFocus(Qt::MenuBarFocusReason); never executed: keyboardFocusWidget->setFocus(Qt::MenuBarFocusReason); | 0 |
242 | keyboardFocusWidget = 0; | - |
243 | } executed: } Execution Count:1 | 1 |
244 | } executed: } Execution Count:11 | 11 |
245 | q->update(); | - |
246 | } executed: } Execution Count:25 | 25 |
247 | | - |
248 | void QMenuBarPrivate::popupAction(QAction *action, bool activateFirst) | - |
249 | { | - |
250 | QMenuBar * const q = q_func(); | - |
251 | if(!action || !action->menu() || closePopupMode) partially evaluated: !action no Evaluation Count:0 | yes Evaluation Count:34 |
evaluated: !action->menu() yes Evaluation Count:8 | yes Evaluation Count:26 |
partially evaluated: closePopupMode no Evaluation Count:0 | yes Evaluation Count:26 |
| 0-34 |
252 | return; executed: return; Execution Count:8 | 8 |
253 | popupState = true; | - |
254 | if (action->isEnabled() && action->menu()->isEnabled()) { evaluated: action->isEnabled() yes Evaluation Count:25 | yes Evaluation Count:1 |
partially evaluated: action->menu()->isEnabled() yes Evaluation Count:25 | no Evaluation Count:0 |
| 0-25 |
255 | closePopupMode = 0; | - |
256 | activeMenu = action->menu(); | - |
257 | activeMenu->d_func()->causedPopup.widget = q; | - |
258 | activeMenu->d_func()->causedPopup.action = action; | - |
259 | | - |
260 | QRect adjustedActionRect = actionRect(action); | - |
261 | QPoint pos(q->mapToGlobal(QPoint(adjustedActionRect.left(), adjustedActionRect.bottom() + 1))); | - |
262 | QSize popup_size = activeMenu->sizeHint(); | - |
263 | | - |
264 | | - |
265 | QRect screenRect = QApplication::desktop()->screenGeometry(pos + QPoint(adjustedActionRect.width() / 2, 0)); | - |
266 | pos = QPoint(qMax(pos.x(), screenRect.x()), qMax(pos.y(), screenRect.y())); | - |
267 | | - |
268 | const bool fitUp = (q->mapToGlobal(adjustedActionRect.topLeft()).y() >= popup_size.height()); | - |
269 | const bool fitDown = (pos.y() + popup_size.height() <= screenRect.bottom()); | - |
270 | const bool rtl = q->isRightToLeft(); | - |
271 | const int actionWidth = adjustedActionRect.width(); | - |
272 | | - |
273 | if (!fitUp && !fitDown) { evaluated: !fitUp yes Evaluation Count:3 | yes Evaluation Count:22 |
evaluated: !fitDown yes Evaluation Count:1 | yes Evaluation Count:2 |
| 1-22 |
274 | bool shouldShiftToRight = !rtl; | - |
275 | if (rtl && popup_size.width() > pos.x()) partially evaluated: rtl no Evaluation Count:0 | yes Evaluation Count:1 |
never evaluated: popup_size.width() > pos.x() | 0-1 |
276 | shouldShiftToRight = true; never executed: shouldShiftToRight = true; | 0 |
277 | else if (actionWidth + popup_size.width() + pos.x() > screenRect.right()) partially evaluated: actionWidth + popup_size.width() + pos.x() > screenRect.right() no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
278 | shouldShiftToRight = false; never executed: shouldShiftToRight = false; | 0 |
279 | | - |
280 | if (shouldShiftToRight) { partially evaluated: shouldShiftToRight yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
281 | pos.rx() += actionWidth + (rtl ? popup_size.width() : 0); partially evaluated: rtl no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
282 | } else { executed: } Execution Count:1 | 1 |
283 | | - |
284 | if (!rtl) | 0 |
285 | pos.rx() -= popup_size.width(); never executed: pos.rx() -= popup_size.width(); | 0 |
286 | } | 0 |
287 | } else if (rtl) { evaluated: rtl yes Evaluation Count:3 | yes Evaluation Count:21 |
| 3-21 |
288 | pos.rx() += actionWidth; | - |
289 | } executed: } Execution Count:3 | 3 |
290 | | - |
291 | if(!defaultPopDown || (fitUp && !fitDown)) partially evaluated: !defaultPopDown no Evaluation Count:0 | yes Evaluation Count:25 |
evaluated: fitUp yes Evaluation Count:22 | yes Evaluation Count:3 |
evaluated: !fitDown yes Evaluation Count:1 | yes Evaluation Count:21 |
| 0-25 |
292 | pos.setY(qMax(screenRect.y(), q->mapToGlobal(QPoint(0, adjustedActionRect.top()-popup_size.height())).y())); executed: pos.setY(qMax(screenRect.y(), q->mapToGlobal(QPoint(0, adjustedActionRect.top()-popup_size.height())).y())); Execution Count:1 | 1 |
293 | activeMenu->popup(pos); | - |
294 | if(activateFirst) evaluated: activateFirst yes Evaluation Count:16 | yes Evaluation Count:9 |
| 9-16 |
295 | activeMenu->d_func()->setFirstActionActive(); executed: activeMenu->d_func()->setFirstActionActive(); Execution Count:16 | 16 |
296 | } executed: } Execution Count:25 | 25 |
297 | q->update(actionRect(action)); | - |
298 | } executed: } Execution Count:26 | 26 |
299 | | - |
300 | void QMenuBarPrivate::setCurrentAction(QAction *action, bool popup, bool activateFirst) | - |
301 | { | - |
302 | if(currentAction == action && popup == popupState) evaluated: currentAction == action yes Evaluation Count:24 | yes Evaluation Count:59 |
evaluated: popup == popupState yes Evaluation Count:23 | yes Evaluation Count:1 |
| 1-59 |
303 | return; executed: return; Execution Count:23 | 23 |
304 | | - |
305 | autoReleaseTimer.stop(); | - |
306 | | - |
307 | doChildEffects = (popup && !activeMenu); evaluated: popup yes Evaluation Count:34 | yes Evaluation Count:26 |
evaluated: !activeMenu yes Evaluation Count:25 | yes Evaluation Count:9 |
| 9-34 |
308 | QMenuBar * const q = q_func(); | - |
309 | QWidget *fw = 0; | - |
310 | if(QMenu *menu = activeMenu) { evaluated: QMenu *menu = activeMenu yes Evaluation Count:20 | yes Evaluation Count:40 |
| 20-40 |
311 | activeMenu = 0; | - |
312 | if (popup) { evaluated: popup yes Evaluation Count:9 | yes Evaluation Count:11 |
| 9-11 |
313 | fw = q->window()->focusWidget(); | - |
314 | q->setFocus(Qt::NoFocusReason); | - |
315 | } executed: } Execution Count:9 | 9 |
316 | menu->hide(); | - |
317 | } executed: } Execution Count:20 | 20 |
318 | | - |
319 | if(currentAction) evaluated: currentAction yes Evaluation Count:28 | yes Evaluation Count:32 |
| 28-32 |
320 | q->update(actionRect(currentAction)); executed: q->update(actionRect(currentAction)); Execution Count:28 | 28 |
321 | | - |
322 | popupState = popup; | - |
323 | | - |
324 | QAction *previousAction = currentAction; | - |
325 | | - |
326 | currentAction = action; | - |
327 | if (action) { evaluated: action yes Evaluation Count:37 | yes Evaluation Count:23 |
| 23-37 |
328 | activateAction(action, QAction::Hover); | - |
329 | if(popup) evaluated: popup yes Evaluation Count:33 | yes Evaluation Count:4 |
| 4-33 |
330 | popupAction(action, activateFirst); executed: popupAction(action, activateFirst); Execution Count:33 | 33 |
331 | q->update(actionRect(action)); | - |
332 | | - |
333 | } else if (previousAction) { partially evaluated: previousAction yes Evaluation Count:23 | no Evaluation Count:0 |
executed: } Execution Count:37 | 0-37 |
334 | QString empty; | - |
335 | QStatusTipEvent tip(empty); | - |
336 | QApplication::sendEvent(q, &tip); | - |
337 | | - |
338 | } executed: } Execution Count:23 | 23 |
339 | if (fw) evaluated: fw yes Evaluation Count:7 | yes Evaluation Count:53 |
| 7-53 |
340 | fw->setFocus(Qt::NoFocusReason); executed: fw->setFocus(Qt::NoFocusReason); Execution Count:7 | 7 |
341 | } executed: } Execution Count:60 | 60 |
342 | | - |
343 | void QMenuBarPrivate::calcActionRects(int max_width, int start) const | - |
344 | { | - |
345 | const QMenuBar * const q = q_func(); | - |
346 | | - |
347 | if(!itemsDirty) evaluated: !itemsDirty yes Evaluation Count:4 | yes Evaluation Count:360 |
| 4-360 |
348 | return; executed: return; Execution Count:4 | 4 |
349 | | - |
350 | | - |
351 | actionRects.resize(actions.count()); | - |
352 | actionRects.fill(QRect()); | - |
353 | | - |
354 | const QStyle *style = q->style(); | - |
355 | | - |
356 | const int itemSpacing = style->pixelMetric(QStyle::PM_MenuBarItemSpacing, 0, q); | - |
357 | int max_item_height = 0, separator = -1, separator_start = 0, separator_len = 0; | - |
358 | | - |
359 | | - |
360 | const QFontMetrics fm = q->fontMetrics(); | - |
361 | const int hmargin = style->pixelMetric(QStyle::PM_MenuBarHMargin, 0, q), | - |
362 | vmargin = style->pixelMetric(QStyle::PM_MenuBarVMargin, 0, q), | - |
363 | icone = style->pixelMetric(QStyle::PM_SmallIconSize, 0, q); | - |
364 | for(int i = 0; i < actions.count(); i++) { evaluated: i < actions.count() yes Evaluation Count:332 | yes Evaluation Count:360 |
| 332-360 |
365 | QAction *action = actions.at(i); | - |
366 | if(!action->isVisible()) evaluated: !action->isVisible() yes Evaluation Count:1 | yes Evaluation Count:331 |
| 1-331 |
367 | continue; executed: continue; Execution Count:1 | 1 |
368 | | - |
369 | QSize sz; | - |
370 | | - |
371 | | - |
372 | if(action->isSeparator()) { evaluated: action->isSeparator() yes Evaluation Count:3 | yes Evaluation Count:328 |
| 3-328 |
373 | if (style->styleHint(QStyle::SH_DrawMenuBarSeparator, 0, q)) partially evaluated: style->styleHint(QStyle::SH_DrawMenuBarSeparator, 0, q) no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-3 |
374 | separator = i; never executed: separator = i; | 0 |
375 | continue; executed: continue; Execution Count:3 | 3 |
376 | } else { | - |
377 | const QString s = action->text(); | - |
378 | QIcon is = action->icon(); | - |
379 | | - |
380 | if (!is.isNull()) partially evaluated: !is.isNull() no Evaluation Count:0 | yes Evaluation Count:328 |
| 0-328 |
381 | sz = sz.expandedTo(QSize(icone, icone)); never executed: sz = sz.expandedTo(QSize(icone, icone)); | 0 |
382 | else if (!s.isEmpty()) evaluated: !s.isEmpty() yes Evaluation Count:327 | yes Evaluation Count:1 |
| 1-327 |
383 | sz = fm.size(Qt::TextShowMnemonic, s); executed: sz = fm.size(Qt::TextShowMnemonic, s); Execution Count:327 | 327 |
384 | } | - |
385 | | - |
386 | | - |
387 | QStyleOptionMenuItem opt; | - |
388 | q->initStyleOption(&opt, action); | - |
389 | sz = q->style()->sizeFromContents(QStyle::CT_MenuBarItem, &opt, sz, q); | - |
390 | | - |
391 | if(!sz.isEmpty()) { evaluated: !sz.isEmpty() yes Evaluation Count:327 | yes Evaluation Count:1 |
| 1-327 |
392 | { | - |
393 | int iWidth = sz.width() + itemSpacing; | - |
394 | if(separator == -1) partially evaluated: separator == -1 yes Evaluation Count:327 | no Evaluation Count:0 |
| 0-327 |
395 | separator_start += iWidth; executed: separator_start += iWidth; Execution Count:327 | 327 |
396 | else | - |
397 | separator_len += iWidth; never executed: separator_len += iWidth; | 0 |
398 | } | - |
399 | | - |
400 | max_item_height = qMax(max_item_height, sz.height()); | - |
401 | | - |
402 | actionRects[i] = QRect(0, 0, sz.width(), sz.height()); | - |
403 | } executed: } Execution Count:327 | 327 |
404 | } executed: } Execution Count:328 | 328 |
405 | | - |
406 | | - |
407 | const int fw = q->style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, q); | - |
408 | int x = fw + ((start == -1) ? hmargin : start) + itemSpacing; evaluated: (start == -1) yes Evaluation Count:217 | yes Evaluation Count:143 |
| 143-217 |
409 | int y = fw + vmargin; | - |
410 | for(int i = 0; i < actions.count(); i++) { evaluated: i < actions.count() yes Evaluation Count:332 | yes Evaluation Count:360 |
| 332-360 |
411 | QRect &rect = actionRects[i]; | - |
412 | if (rect.isNull()) evaluated: rect.isNull() yes Evaluation Count:5 | yes Evaluation Count:327 |
| 5-327 |
413 | continue; executed: continue; Execution Count:5 | 5 |
414 | | - |
415 | | - |
416 | rect.setHeight(max_item_height); | - |
417 | | - |
418 | | - |
419 | if(separator != -1 && i >= separator) { partially evaluated: separator != -1 no Evaluation Count:0 | yes Evaluation Count:327 |
never evaluated: i >= separator | 0-327 |
420 | int left = (max_width - separator_len - hmargin - itemSpacing) + (x - separator_start - hmargin); | - |
421 | if(left < separator_start) { never evaluated: left < separator_start | 0 |
422 | separator_start = x = hmargin; | - |
423 | y += max_item_height; | - |
424 | } | 0 |
425 | rect.moveLeft(left); | - |
426 | } else { | 0 |
427 | rect.moveLeft(x); | - |
428 | } executed: } Execution Count:327 | 327 |
429 | rect.moveTop(y); | - |
430 | | - |
431 | | - |
432 | x += rect.width() + itemSpacing; | - |
433 | | - |
434 | | - |
435 | rect = QStyle::visualRect(q->layoutDirection(), q->rect(), rect); | - |
436 | } executed: } Execution Count:327 | 327 |
437 | } executed: } Execution Count:360 | 360 |
438 | | - |
439 | void QMenuBarPrivate::activateAction(QAction *action, QAction::ActionEvent action_e) | - |
440 | { | - |
441 | QMenuBar * const q = q_func(); | - |
442 | if (!action || !action->isEnabled()) partially evaluated: !action no Evaluation Count:0 | yes Evaluation Count:39 |
evaluated: !action->isEnabled() yes Evaluation Count:1 | yes Evaluation Count:38 |
| 0-39 |
443 | return; executed: return; Execution Count:1 | 1 |
444 | action->activate(action_e); | - |
445 | if (action_e == QAction::Hover) evaluated: action_e == QAction::Hover yes Evaluation Count:36 | yes Evaluation Count:2 |
| 2-36 |
446 | action->showStatusText(q); executed: action->showStatusText(q); Execution Count:36 | 36 |
447 | | - |
448 | | - |
449 | | - |
450 | | - |
451 | | - |
452 | } executed: } Execution Count:38 | 38 |
453 | | - |
454 | | - |
455 | void QMenuBarPrivate::_q_actionTriggered() | - |
456 | { | - |
457 | QMenuBar * const q = q_func(); | - |
458 | if (QAction *action = qobject_cast<QAction *>(q->sender())) { partially evaluated: QAction *action = qobject_cast<QAction *>(q->sender()) yes Evaluation Count:3 | no Evaluation Count:0 |
| 0-3 |
459 | q->triggered(action); | - |
460 | } executed: } Execution Count:3 | 3 |
461 | } executed: } Execution Count:3 | 3 |
462 | | - |
463 | void QMenuBarPrivate::_q_actionHovered() | - |
464 | { | - |
465 | QMenuBar * const q = q_func(); | - |
466 | if (QAction *action = qobject_cast<QAction *>(q->sender())) { partially evaluated: QAction *action = qobject_cast<QAction *>(q->sender()) yes Evaluation Count:35 | no Evaluation Count:0 |
| 0-35 |
467 | q->hovered(action); | - |
468 | | - |
469 | if (QAccessible::isActive()) { evaluated: QAccessible::isActive() yes Evaluation Count:5 | yes Evaluation Count:30 |
| 5-30 |
470 | int actionIndex = actions.indexOf(action); | - |
471 | QAccessibleEvent focusEvent(q, QAccessible::Focus); | - |
472 | focusEvent.setChild(actionIndex); | - |
473 | QAccessible::updateAccessibility(&focusEvent); | - |
474 | QAccessibleEvent selectionEvent(q, QAccessible::Selection); | - |
475 | selectionEvent.setChild(actionIndex); | - |
476 | QAccessible::updateAccessibility(&selectionEvent); | - |
477 | } executed: } Execution Count:5 | 5 |
478 | | - |
479 | } executed: } Execution Count:35 | 35 |
480 | } executed: } Execution Count:35 | 35 |
481 | void QMenuBar::initStyleOption(QStyleOptionMenuItem *option, const QAction *action) const | - |
482 | { | - |
483 | if (!option || !action) partially evaluated: !option no Evaluation Count:0 | yes Evaluation Count:374 |
partially evaluated: !action no Evaluation Count:0 | yes Evaluation Count:374 |
| 0-374 |
484 | return; | 0 |
485 | const QMenuBarPrivate * const d = d_func(); | - |
486 | option->palette = palette(); | - |
487 | option->state = QStyle::State_None; | - |
488 | if (isEnabled() && action->isEnabled()) partially evaluated: isEnabled() yes Evaluation Count:374 | no Evaluation Count:0 |
evaluated: action->isEnabled() yes Evaluation Count:373 | yes Evaluation Count:1 |
| 0-374 |
489 | option->state |= QStyle::State_Enabled; executed: option->state |= QStyle::State_Enabled; Execution Count:373 | 373 |
490 | else | - |
491 | option->palette.setCurrentColorGroup(QPalette::Disabled); executed: option->palette.setCurrentColorGroup(QPalette::Disabled); Execution Count:1 | 1 |
492 | option->fontMetrics = fontMetrics(); | - |
493 | if (d->currentAction && d->currentAction == action) { evaluated: d->currentAction yes Evaluation Count:23 | yes Evaluation Count:351 |
evaluated: d->currentAction == action yes Evaluation Count:14 | yes Evaluation Count:9 |
| 9-351 |
494 | option->state |= QStyle::State_Selected; | - |
495 | if (d->popupState && !d->closePopupMode) evaluated: d->popupState yes Evaluation Count:12 | yes Evaluation Count:2 |
partially evaluated: !d->closePopupMode yes Evaluation Count:12 | no Evaluation Count:0 |
| 0-12 |
496 | option->state |= QStyle::State_Sunken; executed: option->state |= QStyle::State_Sunken; Execution Count:12 | 12 |
497 | } executed: } Execution Count:14 | 14 |
498 | if (hasFocus() || d->currentAction) evaluated: hasFocus() yes Evaluation Count:47 | yes Evaluation Count:327 |
evaluated: d->currentAction yes Evaluation Count:10 | yes Evaluation Count:317 |
| 10-327 |
499 | option->state |= QStyle::State_HasFocus; executed: option->state |= QStyle::State_HasFocus; Execution Count:57 | 57 |
500 | option->menuRect = rect(); | - |
501 | option->menuItemType = QStyleOptionMenuItem::Normal; | - |
502 | option->checkType = QStyleOptionMenuItem::NotCheckable; | - |
503 | option->text = action->text(); | - |
504 | option->icon = action->icon(); | - |
505 | } executed: } Execution Count:374 | 374 |
506 | void QMenuBarPrivate::init() | - |
507 | { | - |
508 | QMenuBar * const q = q_func(); | - |
509 | q->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum); | - |
510 | q->setAttribute(Qt::WA_CustomWhatsThis); | - |
511 | | - |
512 | platformMenuBar = QGuiApplicationPrivate::platformTheme()->createPlatformMenuBar(); | - |
513 | | - |
514 | if (platformMenuBar) partially evaluated: platformMenuBar no Evaluation Count:0 | yes Evaluation Count:23 |
| 0-23 |
515 | q->hide(); never executed: q->hide(); | 0 |
516 | q->setBackgroundRole(QPalette::Button); | - |
517 | oldWindow = oldParent = 0; | - |
518 | handleReparent(); | - |
519 | q->setMouseTracking(q->style()->styleHint(QStyle::SH_MenuBar_MouseTracking, 0, q)); | - |
520 | | - |
521 | extension = new QMenuBarExtension(q); | - |
522 | extension->setFocusPolicy(Qt::NoFocus); | - |
523 | extension->hide(); | - |
524 | } executed: } Execution Count:23 | 23 |
525 | | - |
526 | | - |
527 | QAction *QMenuBarPrivate::getNextAction(const int _start, const int increment) const | - |
528 | { | - |
529 | const QMenuBar * const q = q_func(); | - |
530 | const_cast<QMenuBarPrivate*>(this)->updateGeometries(); | - |
531 | bool allowActiveAndDisabled = q->style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, 0, q); | - |
532 | const int start = (_start == -1 && increment == -1) ? actions.count() : _start; evaluated: _start == -1 yes Evaluation Count:2 | yes Evaluation Count:8 |
partially evaluated: increment == -1 no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-8 |
533 | const int end = increment == -1 ? 0 : actions.count() - 1; evaluated: increment == -1 yes Evaluation Count:3 | yes Evaluation Count:7 |
| 3-7 |
534 | | - |
535 | for (int i = start; i != end;) { evaluated: i != end yes Evaluation Count:9 | yes Evaluation Count:2 |
| 2-9 |
536 | i += increment; | - |
537 | QAction *current = actions.at(i); | - |
538 | if (!actionRects.at(i).isNull() && (allowActiveAndDisabled || current->isEnabled())) evaluated: !actionRects.at(i).isNull() yes Evaluation Count:8 | yes Evaluation Count:1 |
partially evaluated: allowActiveAndDisabled yes Evaluation Count:8 | no Evaluation Count:0 |
never evaluated: current->isEnabled() | 0-8 |
539 | return current; executed: return current; Execution Count:8 | 8 |
540 | } executed: } Execution Count:1 | 1 |
541 | | - |
542 | if (_start != -1) partially evaluated: _start != -1 yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
543 | return getNextAction(-1, increment); executed: return getNextAction(-1, increment); Execution Count:2 | 2 |
544 | | - |
545 | return 0; never executed: return 0; | 0 |
546 | } | - |
547 | | - |
548 | | - |
549 | | - |
550 | | - |
551 | QMenuBar::QMenuBar(QWidget *parent) : QWidget(*new QMenuBarPrivate, parent, 0) | - |
552 | { | - |
553 | QMenuBarPrivate * const d = d_func(); | - |
554 | d->init(); | - |
555 | } executed: } Execution Count:23 | 23 |
556 | | - |
557 | | - |
558 | | - |
559 | | - |
560 | | - |
561 | QMenuBar::~QMenuBar() | - |
562 | { | - |
563 | QMenuBarPrivate * const d = d_func(); | - |
564 | delete d->platformMenuBar; | - |
565 | d->platformMenuBar = 0; | - |
566 | | - |
567 | | - |
568 | | - |
569 | | - |
570 | | - |
571 | } executed: } Execution Count:23 | 23 |
572 | QAction *QMenuBar::addAction(const QString &text) | - |
573 | { | - |
574 | QAction *ret = new QAction(text, this); | - |
575 | addAction(ret); | - |
576 | return ret; executed: return ret; Execution Count:20 | 20 |
577 | } | - |
578 | QAction *QMenuBar::addAction(const QString &text, const QObject *receiver, const char* member) | - |
579 | { | - |
580 | QAction *ret = new QAction(text, this); | - |
581 | QObject::connect(ret, "2""triggered(bool)", receiver, member); | - |
582 | addAction(ret); | - |
583 | return ret; executed: return ret; Execution Count:8 | 8 |
584 | } | - |
585 | | - |
586 | | - |
587 | | - |
588 | | - |
589 | | - |
590 | | - |
591 | | - |
592 | QMenu *QMenuBar::addMenu(const QString &title) | - |
593 | { | - |
594 | QMenu *menu = new QMenu(title, this); | - |
595 | addAction(menu->menuAction()); | - |
596 | return menu; executed: return menu; Execution Count:40 | 40 |
597 | } | - |
598 | | - |
599 | | - |
600 | | - |
601 | | - |
602 | | - |
603 | | - |
604 | | - |
605 | QMenu *QMenuBar::addMenu(const QIcon &icon, const QString &title) | - |
606 | { | - |
607 | QMenu *menu = new QMenu(title, this); | - |
608 | menu->setIcon(icon); | - |
609 | addAction(menu->menuAction()); | - |
610 | return menu; never executed: return menu; | 0 |
611 | } | - |
612 | QAction *QMenuBar::addMenu(QMenu *menu) | - |
613 | { | - |
614 | QAction *action = menu->menuAction(); | - |
615 | addAction(action); | - |
616 | return action; executed: return action; Execution Count:27 | 27 |
617 | } | - |
618 | | - |
619 | | - |
620 | | - |
621 | | - |
622 | QAction *QMenuBar::addSeparator() | - |
623 | { | - |
624 | QAction *ret = new QAction(this); | - |
625 | ret->setSeparator(true); | - |
626 | addAction(ret); | - |
627 | return ret; executed: return ret; Execution Count:1 | 1 |
628 | } | - |
629 | QAction *QMenuBar::insertSeparator(QAction *before) | - |
630 | { | - |
631 | QAction *action = new QAction(this); | - |
632 | action->setSeparator(true); | - |
633 | insertAction(before, action); | - |
634 | return action; never executed: return action; | 0 |
635 | } | - |
636 | | - |
637 | | - |
638 | | - |
639 | | - |
640 | | - |
641 | | - |
642 | | - |
643 | QAction *QMenuBar::insertMenu(QAction *before, QMenu *menu) | - |
644 | { | - |
645 | QAction *action = menu->menuAction(); | - |
646 | insertAction(before, action); | - |
647 | return action; never executed: return action; | 0 |
648 | } | - |
649 | | - |
650 | | - |
651 | | - |
652 | | - |
653 | | - |
654 | QAction *QMenuBar::activeAction() const | - |
655 | { | - |
656 | const QMenuBarPrivate * const d = d_func(); | - |
657 | return d->currentAction; executed: return d->currentAction; Execution Count:16 | 16 |
658 | } | - |
659 | | - |
660 | | - |
661 | | - |
662 | | - |
663 | | - |
664 | | - |
665 | void QMenuBar::setActiveAction(QAction *act) | - |
666 | { | - |
667 | QMenuBarPrivate * const d = d_func(); | - |
668 | d->setCurrentAction(act, true, false); | - |
669 | } executed: } Execution Count:11 | 11 |
670 | void QMenuBar::clear() | - |
671 | { | - |
672 | QList<QAction*> acts = actions(); | - |
673 | for(int i = 0; i < acts.size(); i++) evaluated: i < acts.size() yes Evaluation Count:61 | yes Evaluation Count:23 |
| 23-61 |
674 | removeAction(acts[i]); executed: removeAction(acts[i]); Execution Count:61 | 61 |
675 | } executed: } Execution Count:23 | 23 |
676 | void QMenuBar::setDefaultUp(bool b) | - |
677 | { | - |
678 | QMenuBarPrivate * const d = d_func(); | - |
679 | d->defaultPopDown = !b; | - |
680 | } | 0 |
681 | | - |
682 | bool QMenuBar::isDefaultUp() const | - |
683 | { | - |
684 | const QMenuBarPrivate * const d = d_func(); | - |
685 | return !d->defaultPopDown; never executed: return !d->defaultPopDown; | 0 |
686 | } | - |
687 | | - |
688 | | - |
689 | | - |
690 | | - |
691 | void QMenuBar::resizeEvent(QResizeEvent *) | - |
692 | { | - |
693 | QMenuBarPrivate * const d = d_func(); | - |
694 | d->itemsDirty = true; | - |
695 | d->updateGeometries(); | - |
696 | } executed: } Execution Count:40 | 40 |
697 | | - |
698 | | - |
699 | | - |
700 | | - |
701 | void QMenuBar::paintEvent(QPaintEvent *e) | - |
702 | { | - |
703 | QMenuBarPrivate * const d = d_func(); | - |
704 | QPainter p(this); | - |
705 | QRegion emptyArea(rect()); | - |
706 | | - |
707 | | - |
708 | for (int i = 0; i < d->actions.count(); ++i) { evaluated: i < d->actions.count() yes Evaluation Count:67 | yes Evaluation Count:52 |
| 52-67 |
709 | QAction *action = d->actions.at(i); | - |
710 | QRect adjustedActionRect = d->actionRect(action); | - |
711 | if (adjustedActionRect.isEmpty() || !d->isVisible(action)) evaluated: adjustedActionRect.isEmpty() yes Evaluation Count:3 | yes Evaluation Count:64 |
evaluated: !d->isVisible(action) yes Evaluation Count:12 | yes Evaluation Count:52 |
| 3-64 |
712 | continue; executed: continue; Execution Count:15 | 15 |
713 | if(!e->rect().intersects(adjustedActionRect)) evaluated: !e->rect().intersects(adjustedActionRect) yes Evaluation Count:6 | yes Evaluation Count:46 |
| 6-46 |
714 | continue; executed: continue; Execution Count:6 | 6 |
715 | | - |
716 | emptyArea -= adjustedActionRect; | - |
717 | QStyleOptionMenuItem opt; | - |
718 | initStyleOption(&opt, action); | - |
719 | opt.rect = adjustedActionRect; | - |
720 | p.setClipRect(adjustedActionRect); | - |
721 | style()->drawControl(QStyle::CE_MenuBarItem, &opt, &p, this); | - |
722 | } executed: } Execution Count:46 | 46 |
723 | | - |
724 | if(int fw = style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, this)) { partially evaluated: int fw = style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, this) no Evaluation Count:0 | yes Evaluation Count:52 |
| 0-52 |
725 | QRegion borderReg; | - |
726 | borderReg += QRect(0, 0, fw, height()); | - |
727 | borderReg += QRect(width()-fw, 0, fw, height()); | - |
728 | borderReg += QRect(0, 0, width(), fw); | - |
729 | borderReg += QRect(0, height()-fw, width(), fw); | - |
730 | p.setClipRegion(borderReg); | - |
731 | emptyArea -= borderReg; | - |
732 | QStyleOptionFrame frame; | - |
733 | frame.rect = rect(); | - |
734 | frame.palette = palette(); | - |
735 | frame.state = QStyle::State_None; | - |
736 | frame.lineWidth = style()->pixelMetric(QStyle::PM_MenuBarPanelWidth); | - |
737 | frame.midLineWidth = 0; | - |
738 | style()->drawPrimitive(QStyle::PE_PanelMenuBar, &frame, &p, this); | - |
739 | } | 0 |
740 | p.setClipRegion(emptyArea); | - |
741 | QStyleOptionMenuItem menuOpt; | - |
742 | menuOpt.palette = palette(); | - |
743 | menuOpt.state = QStyle::State_None; | - |
744 | menuOpt.menuItemType = QStyleOptionMenuItem::EmptyArea; | - |
745 | menuOpt.checkType = QStyleOptionMenuItem::NotCheckable; | - |
746 | menuOpt.rect = rect(); | - |
747 | menuOpt.menuRect = rect(); | - |
748 | style()->drawControl(QStyle::CE_MenuBarEmptyArea, &menuOpt, &p, this); | - |
749 | } executed: } Execution Count:52 | 52 |
750 | | - |
751 | | - |
752 | | - |
753 | | - |
754 | void QMenuBar::setVisible(bool visible) | - |
755 | { | - |
756 | | - |
757 | | - |
758 | | - |
759 | | - |
760 | | - |
761 | | - |
762 | | - |
763 | QWidget::setVisible(visible); | - |
764 | } executed: } Execution Count:57 | 57 |
765 | | - |
766 | | - |
767 | | - |
768 | | - |
769 | void QMenuBar::mousePressEvent(QMouseEvent *e) | - |
770 | { | - |
771 | QMenuBarPrivate * const d = d_func(); | - |
772 | if(e->button() != Qt::LeftButton) partially evaluated: e->button() != Qt::LeftButton no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
773 | return; | 0 |
774 | | - |
775 | d->mouseDown = true; | - |
776 | | - |
777 | QAction *action = d->actionAt(e->pos()); | - |
778 | if (!action || !d->isVisible(action)) { partially evaluated: !action no Evaluation Count:0 | yes Evaluation Count:4 |
partially evaluated: !d->isVisible(action) no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
779 | d->setCurrentAction(0); | - |
780 | | - |
781 | if (QWhatsThis::inWhatsThisMode()) never evaluated: QWhatsThis::inWhatsThisMode() | 0 |
782 | QWhatsThis::showText(e->globalPos(), d->whatsThis, this); never executed: QWhatsThis::showText(e->globalPos(), d->whatsThis, this); | 0 |
783 | | - |
784 | return; | 0 |
785 | } | - |
786 | | - |
787 | if(d->currentAction == action && d->popupState) { partially evaluated: d->currentAction == action no Evaluation Count:0 | yes Evaluation Count:4 |
never evaluated: d->popupState | 0-4 |
788 | if(QMenu *menu = d->activeMenu) { never evaluated: QMenu *menu = d->activeMenu | 0 |
789 | d->activeMenu = 0; | - |
790 | menu->hide(); | - |
791 | } | 0 |
792 | } else { | 0 |
793 | d->setCurrentAction(action, true); | - |
794 | } executed: } Execution Count:4 | 4 |
795 | } | - |
796 | | - |
797 | | - |
798 | | - |
799 | | - |
800 | void QMenuBar::mouseReleaseEvent(QMouseEvent *e) | - |
801 | { | - |
802 | QMenuBarPrivate * const d = d_func(); | - |
803 | if(e->button() != Qt::LeftButton || !d->mouseDown) partially evaluated: e->button() != Qt::LeftButton no Evaluation Count:0 | yes Evaluation Count:4 |
evaluated: !d->mouseDown yes Evaluation Count:1 | yes Evaluation Count:3 |
| 0-4 |
804 | return; executed: return; Execution Count:1 | 1 |
805 | | - |
806 | d->mouseDown = false; | - |
807 | QAction *action = d->actionAt(e->pos()); | - |
808 | if((d->closePopupMode && action == d->currentAction) || !action || !action->menu()) { partially evaluated: d->closePopupMode no Evaluation Count:0 | yes Evaluation Count:3 |
never evaluated: action == d->currentAction partially evaluated: !action no Evaluation Count:0 | yes Evaluation Count:3 |
evaluated: !action->menu() yes Evaluation Count:1 | yes Evaluation Count:2 |
| 0-3 |
809 | | - |
810 | | - |
811 | d->setCurrentAction(action, false); | - |
812 | if(action) partially evaluated: action yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
813 | d->activateAction(action, QAction::Trigger); executed: d->activateAction(action, QAction::Trigger); Execution Count:1 | 1 |
814 | } executed: } Execution Count:1 | 1 |
815 | d->closePopupMode = 0; | - |
816 | } executed: } Execution Count:3 | 3 |
817 | | - |
818 | | - |
819 | | - |
820 | | - |
821 | void QMenuBar::keyPressEvent(QKeyEvent *e) | - |
822 | { | - |
823 | QMenuBarPrivate * const d = d_func(); | - |
824 | d->updateGeometries(); | - |
825 | int key = e->key(); | - |
826 | if(isRightToLeft()) { partially evaluated: isRightToLeft() no Evaluation Count:0 | yes Evaluation Count:23 |
| 0-23 |
827 | if(key == Qt::Key_Left) never evaluated: key == Qt::Key_Left | 0 |
828 | key = Qt::Key_Right; never executed: key = Qt::Key_Right; | 0 |
829 | else if(key == Qt::Key_Right) never evaluated: key == Qt::Key_Right | 0 |
830 | key = Qt::Key_Left; never executed: key = Qt::Key_Left; | 0 |
831 | } | - |
832 | if(key == Qt::Key_Tab) partially evaluated: key == Qt::Key_Tab no Evaluation Count:0 | yes Evaluation Count:23 |
| 0-23 |
833 | key = Qt::Key_Right; never executed: key = Qt::Key_Right; | 0 |
834 | else if(key == Qt::Key_Backtab) partially evaluated: key == Qt::Key_Backtab no Evaluation Count:0 | yes Evaluation Count:23 |
| 0-23 |
835 | key = Qt::Key_Left; never executed: key = Qt::Key_Left; | 0 |
836 | | - |
837 | bool key_consumed = false; | - |
838 | switch(key) { | - |
839 | case Qt::Key_Up: | - |
840 | case Qt::Key_Down: | - |
841 | case Qt::Key_Enter: | - |
842 | case Qt::Key_Space: | - |
843 | case Qt::Key_Return: { | - |
844 | if(!style()->styleHint(QStyle::SH_MenuBar_AltKeyNavigation, 0, this) || !d->currentAction) partially evaluated: !style()->styleHint(QStyle::SH_MenuBar_AltKeyNavigation, 0, this) no Evaluation Count:0 | yes Evaluation Count:1 |
partially evaluated: !d->currentAction no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
845 | break; | 0 |
846 | if(d->currentAction->menu()) { partially evaluated: d->currentAction->menu() yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
847 | d->popupAction(d->currentAction, true); | - |
848 | } else if(key == Qt::Key_Enter || key == Qt::Key_Return || key == Qt::Key_Space) { executed: } Execution Count:1 never evaluated: key == Qt::Key_Enter never evaluated: key == Qt::Key_Return never evaluated: key == Qt::Key_Space | 0-1 |
849 | d->activateAction(d->currentAction, QAction::Trigger); | - |
850 | d->setCurrentAction(d->currentAction, false); | - |
851 | d->setKeyboardMode(false); | - |
852 | } | 0 |
853 | key_consumed = true; | - |
854 | break; } executed: break; Execution Count:1 | 1 |
855 | | - |
856 | case Qt::Key_Right: | - |
857 | case Qt::Key_Left: { | - |
858 | if(d->currentAction) { partially evaluated: d->currentAction yes Evaluation Count:8 | no Evaluation Count:0 |
| 0-8 |
859 | int index = d->actions.indexOf(d->currentAction); | - |
860 | if (QAction *nextAction = d->getNextAction(index, key == Qt::Key_Left ? -1 : +1)) { partially evaluated: QAction *nextAction = d->getNextAction(index, key == Qt::Key_Left ? -1 : +1) yes Evaluation Count:8 | no Evaluation Count:0 |
| 0-8 |
861 | d->setCurrentAction(nextAction, d->popupState, true); | - |
862 | key_consumed = true; | - |
863 | } executed: } Execution Count:8 | 8 |
864 | } executed: } Execution Count:8 | 8 |
865 | break; } executed: break; Execution Count:8 | 8 |
866 | | - |
867 | case Qt::Key_Escape: | - |
868 | d->setCurrentAction(0); | - |
869 | d->setKeyboardMode(false); | - |
870 | key_consumed = true; | - |
871 | break; executed: break; Execution Count:1 | 1 |
872 | | - |
873 | default: | - |
874 | key_consumed = false; | - |
875 | } executed: } Execution Count:13 | 13 |
876 | | - |
877 | if(!key_consumed && evaluated: !key_consumed yes Evaluation Count:13 | yes Evaluation Count:10 |
| 10-13 |
878 | (!e->modifiers() || evaluated: !e->modifiers() yes Evaluation Count:1 | yes Evaluation Count:12 |
| 1-12 |
879 | (e->modifiers()&(Qt::MetaModifier|Qt::AltModifier))) && e->text().length()==1 && !d->popupState) { evaluated: (e->modifiers()&(Qt::MetaModifier|Qt::AltModifier)) yes Evaluation Count:6 | yes Evaluation Count:6 |
evaluated: e->text().length()==1 yes Evaluation Count:1 | yes Evaluation Count:6 |
partially evaluated: !d->popupState no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-6 |
880 | int clashCount = 0; | - |
881 | QAction *first = 0, *currentSelected = 0, *firstAfterCurrent = 0; | - |
882 | { | - |
883 | QChar c = e->text()[0].toUpper(); | - |
884 | for(int i = 0; i < d->actions.size(); ++i) { never evaluated: i < d->actions.size() | 0 |
885 | if (d->actionRects.at(i).isNull()) never evaluated: d->actionRects.at(i).isNull() | 0 |
886 | continue; never executed: continue; | 0 |
887 | QAction *act = d->actions.at(i); | - |
888 | QString s = act->text(); | - |
889 | if(!s.isEmpty()) { never evaluated: !s.isEmpty() | 0 |
890 | int ampersand = s.indexOf(QLatin1Char('&')); | - |
891 | if(ampersand >= 0) { never evaluated: ampersand >= 0 | 0 |
892 | if(s[ampersand+1].toUpper() == c) { never evaluated: s[ampersand+1].toUpper() == c | 0 |
893 | clashCount++; | - |
894 | if(!first) | 0 |
895 | first = act; never executed: first = act; | 0 |
896 | if(act == d->currentAction) never evaluated: act == d->currentAction | 0 |
897 | currentSelected = act; never executed: currentSelected = act; | 0 |
898 | else if (!firstAfterCurrent && currentSelected) never evaluated: !firstAfterCurrent never evaluated: currentSelected | 0 |
899 | firstAfterCurrent = act; never executed: firstAfterCurrent = act; | 0 |
900 | } | - |
901 | } | 0 |
902 | } | 0 |
903 | } | 0 |
904 | } | - |
905 | QAction *next_action = 0; | - |
906 | if(clashCount >= 1) { never evaluated: clashCount >= 1 | 0 |
907 | if(clashCount == 1 || !d->currentAction || (currentSelected && !firstAfterCurrent)) never evaluated: clashCount == 1 never evaluated: !d->currentAction never evaluated: currentSelected never evaluated: !firstAfterCurrent | 0 |
908 | next_action = first; never executed: next_action = first; | 0 |
909 | else | - |
910 | next_action = firstAfterCurrent; never executed: next_action = firstAfterCurrent; | 0 |
911 | } | - |
912 | if(next_action) { never evaluated: next_action | 0 |
913 | key_consumed = true; | - |
914 | d->setCurrentAction(next_action, true, true); | - |
915 | } | 0 |
916 | } | 0 |
917 | if(key_consumed) evaluated: key_consumed yes Evaluation Count:10 | yes Evaluation Count:13 |
| 10-13 |
918 | e->accept(); executed: e->accept(); Execution Count:10 | 10 |
919 | else | - |
920 | e->ignore(); executed: e->ignore(); Execution Count:13 | 13 |
921 | } | - |
922 | | - |
923 | | - |
924 | | - |
925 | | - |
926 | void QMenuBar::mouseMoveEvent(QMouseEvent *e) | - |
927 | { | - |
928 | QMenuBarPrivate * const d = d_func(); | - |
929 | if (!(e->buttons() & Qt::LeftButton)) partially evaluated: !(e->buttons() & Qt::LeftButton) yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
930 | d->mouseDown = false; executed: d->mouseDown = false; Execution Count:1 | 1 |
931 | bool popupState = d->popupState || d->mouseDown; partially evaluated: d->popupState yes Evaluation Count:1 | no Evaluation Count:0 |
never evaluated: d->mouseDown | 0-1 |
932 | QAction *action = d->actionAt(e->pos()); | - |
933 | if ((action && d->isVisible(action)) || !popupState) partially evaluated: action yes Evaluation Count:1 | no Evaluation Count:0 |
partially evaluated: d->isVisible(action) yes Evaluation Count:1 | no Evaluation Count:0 |
never evaluated: !popupState | 0-1 |
934 | d->setCurrentAction(action, popupState); executed: d->setCurrentAction(action, popupState); Execution Count:1 | 1 |
935 | } executed: } Execution Count:1 | 1 |
936 | | - |
937 | | - |
938 | | - |
939 | | - |
940 | void QMenuBar::leaveEvent(QEvent *) | - |
941 | { | - |
942 | QMenuBarPrivate * const d = d_func(); | - |
943 | if((!hasFocus() && !d->popupState) || never evaluated: !hasFocus() never evaluated: !d->popupState | 0 |
944 | (d->currentAction && d->currentAction->menu() == 0)) never evaluated: d->currentAction never evaluated: d->currentAction->menu() == 0 | 0 |
945 | d->setCurrentAction(0); never executed: d->setCurrentAction(0); | 0 |
946 | } | 0 |
947 | | - |
948 | QPlatformMenu *getPlatformMenu(QAction *action) | - |
949 | { | - |
950 | if (!action || !action->menu()) never evaluated: !action->menu() | 0 |
951 | return 0; never executed: return 0; | 0 |
952 | | - |
953 | return action->menu()->platformMenu(); never executed: return action->menu()->platformMenu(); | 0 |
954 | } | - |
955 | | - |
956 | | - |
957 | | - |
958 | | - |
959 | void QMenuBar::actionEvent(QActionEvent *e) | - |
960 | { | - |
961 | QMenuBarPrivate * const d = d_func(); | - |
962 | d->itemsDirty = true; | - |
963 | | - |
964 | if (d->platformMenuBar) { partially evaluated: d->platformMenuBar no Evaluation Count:0 | yes Evaluation Count:185 |
| 0-185 |
965 | | - |
966 | QPlatformMenuBar *nativeMenuBar = d->platformMenuBar; | - |
967 | | - |
968 | | - |
969 | | - |
970 | if (!nativeMenuBar) never evaluated: !nativeMenuBar | 0 |
971 | return; | 0 |
972 | | - |
973 | if (e->type() == QEvent::ActionAdded) { never evaluated: e->type() == QEvent::ActionAdded | 0 |
974 | QPlatformMenu *menu = getPlatformMenu(e->action()); | - |
975 | if (menu) { | 0 |
976 | QPlatformMenu* beforeMenu = __null; | - |
977 | for (int beforeIndex = d->indexOf(e->action()) + 1; | - |
978 | !beforeMenu && (beforeIndex < actions().size()); never evaluated: !beforeMenu never evaluated: (beforeIndex < actions().size()) | 0 |
979 | ++beforeIndex) | - |
980 | { | - |
981 | beforeMenu = getPlatformMenu(actions().at(beforeIndex)); | - |
982 | } | 0 |
983 | | - |
984 | menu->setTag(reinterpret_cast<quintptr>(e->action())); | - |
985 | menu->setText(e->action()->text()); | - |
986 | d->platformMenuBar->insertMenu(menu, beforeMenu); | - |
987 | } | 0 |
988 | } else if (e->type() == QEvent::ActionRemoved) { never evaluated: e->type() == QEvent::ActionRemoved | 0 |
989 | QPlatformMenu *menu = getPlatformMenu(e->action()); | - |
990 | if (menu) | 0 |
991 | d->platformMenuBar->removeMenu(menu); never executed: d->platformMenuBar->removeMenu(menu); | 0 |
992 | } else if (e->type() == QEvent::ActionChanged) { never evaluated: e->type() == QEvent::ActionChanged | 0 |
993 | QPlatformMenu* cur = d->platformMenuBar->menuForTag(reinterpret_cast<quintptr>(e->action())); | - |
994 | QPlatformMenu *menu = getPlatformMenu(e->action()); | - |
995 | | - |
996 | | - |
997 | | - |
998 | if (menu != cur) { never evaluated: menu != cur | 0 |
999 | if (cur) | 0 |
1000 | d->platformMenuBar->removeMenu(cur); never executed: d->platformMenuBar->removeMenu(cur); | 0 |
1001 | if (menu) { | 0 |
1002 | menu->setTag(reinterpret_cast<quintptr>(e->action())); | - |
1003 | | - |
1004 | QPlatformMenu* beforeMenu = __null; | - |
1005 | for (int beforeIndex = d->indexOf(e->action()) + 1; | - |
1006 | !beforeMenu && (beforeIndex < actions().size()); never evaluated: !beforeMenu never evaluated: (beforeIndex < actions().size()) | 0 |
1007 | ++beforeIndex) | - |
1008 | { | - |
1009 | beforeMenu = getPlatformMenu(actions().at(beforeIndex)); | - |
1010 | } | 0 |
1011 | d->platformMenuBar->insertMenu(menu, beforeMenu); | - |
1012 | } | 0 |
1013 | } else if (menu) { | 0 |
1014 | menu->setText(e->action()->text()); | - |
1015 | menu->setVisible(e->action()->isVisible()); | - |
1016 | menu->setEnabled(e->action()->isEnabled()); | - |
1017 | d->platformMenuBar->syncMenu(menu); | - |
1018 | } | 0 |
1019 | } | - |
1020 | } | - |
1021 | | - |
1022 | if(e->type() == QEvent::ActionAdded) { evaluated: e->type() == QEvent::ActionAdded yes Evaluation Count:97 | yes Evaluation Count:88 |
| 88-97 |
1023 | connect(e->action(), "2""triggered()", this, "1""_q_actionTriggered()"); | - |
1024 | connect(e->action(), "2""hovered()", this, "1""_q_actionHovered()"); | - |
1025 | } else if(e->type() == QEvent::ActionRemoved) { executed: } Execution Count:97 evaluated: e->type() == QEvent::ActionRemoved yes Evaluation Count:76 | yes Evaluation Count:12 |
| 12-97 |
1026 | e->action()->disconnect(this); | - |
1027 | } executed: } Execution Count:76 | 76 |
1028 | if (isVisible()) { evaluated: isVisible() yes Evaluation Count:73 | yes Evaluation Count:112 |
| 73-112 |
1029 | d->updateGeometries(); | - |
1030 | update(); | - |
1031 | } executed: } Execution Count:73 | 73 |
1032 | } executed: } Execution Count:185 | 185 |
1033 | | - |
1034 | | - |
1035 | | - |
1036 | | - |
1037 | void QMenuBar::focusInEvent(QFocusEvent *) | - |
1038 | { | - |
1039 | QMenuBarPrivate * const d = d_func(); | - |
1040 | if(d->keyboardState) evaluated: d->keyboardState yes Evaluation Count:21 | yes Evaluation Count:10 |
| 10-21 |
1041 | d->focusFirstAction(); executed: d->focusFirstAction(); Execution Count:21 | 21 |
1042 | } executed: } Execution Count:31 | 31 |
1043 | | - |
1044 | | - |
1045 | | - |
1046 | | - |
1047 | void QMenuBar::focusOutEvent(QFocusEvent *) | - |
1048 | { | - |
1049 | QMenuBarPrivate * const d = d_func(); | - |
1050 | if(!d->popupState) { evaluated: !d->popupState yes Evaluation Count:6 | yes Evaluation Count:27 |
| 6-27 |
1051 | d->setCurrentAction(0); | - |
1052 | d->setKeyboardMode(false); | - |
1053 | } executed: } Execution Count:6 | 6 |
1054 | } executed: } Execution Count:33 | 33 |
1055 | | - |
1056 | | - |
1057 | | - |
1058 | | - |
1059 | void QMenuBar::timerEvent (QTimerEvent *e) | - |
1060 | { | - |
1061 | QMenuBarPrivate * const d = d_func(); | - |
1062 | if (e->timerId() == d->autoReleaseTimer.timerId()) { partially evaluated: e->timerId() == d->autoReleaseTimer.timerId() yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
1063 | d->autoReleaseTimer.stop(); | - |
1064 | d->setCurrentAction(0); | - |
1065 | } executed: } Execution Count:1 | 1 |
1066 | QWidget::timerEvent(e); | - |
1067 | } executed: } Execution Count:1 | 1 |
1068 | | - |
1069 | | - |
1070 | void QMenuBarPrivate::handleReparent() | - |
1071 | { | - |
1072 | QMenuBar * const q = q_func(); | - |
1073 | QWidget *newParent = q->parentWidget(); | - |
1074 | | - |
1075 | | - |
1076 | | - |
1077 | | - |
1078 | if (oldParent != newParent) { evaluated: oldParent != newParent yes Evaluation Count:18 | yes Evaluation Count:7 |
| 7-18 |
1079 | if (oldParent) partially evaluated: oldParent no Evaluation Count:0 | yes Evaluation Count:18 |
| 0-18 |
1080 | oldParent->removeEventFilter(q); never executed: oldParent->removeEventFilter(q); | 0 |
1081 | if (newParent) partially evaluated: newParent yes Evaluation Count:18 | no Evaluation Count:0 |
| 0-18 |
1082 | newParent->installEventFilter(q); executed: newParent->installEventFilter(q); Execution Count:18 | 18 |
1083 | } executed: } Execution Count:18 | 18 |
1084 | | - |
1085 | | - |
1086 | QWidget *newWindow = newParent ? newParent->window() : 0; evaluated: newParent yes Evaluation Count:18 | yes Evaluation Count:7 |
| 7-18 |
1087 | | - |
1088 | if (oldWindow != newWindow) { evaluated: oldWindow != newWindow yes Evaluation Count:18 | yes Evaluation Count:7 |
| 7-18 |
1089 | if (oldParent && oldParent != oldWindow) partially evaluated: oldParent no Evaluation Count:0 | yes Evaluation Count:18 |
never evaluated: oldParent != oldWindow | 0-18 |
1090 | oldWindow->removeEventFilter(q); never executed: oldWindow->removeEventFilter(q); | 0 |
1091 | | - |
1092 | if (newParent && newParent != newWindow) partially evaluated: newParent yes Evaluation Count:18 | no Evaluation Count:0 |
partially evaluated: newParent != newWindow no Evaluation Count:0 | yes Evaluation Count:18 |
| 0-18 |
1093 | newWindow->installEventFilter(q); never executed: newWindow->installEventFilter(q); | 0 |
1094 | } executed: } Execution Count:18 | 18 |
1095 | | - |
1096 | oldParent = newParent; | - |
1097 | oldWindow = newWindow; | - |
1098 | | - |
1099 | if (platformMenuBar) { partially evaluated: platformMenuBar no Evaluation Count:0 | yes Evaluation Count:25 |
| 0-25 |
1100 | if (newWindow) { never evaluated: newWindow | 0 |
1101 | | - |
1102 | | - |
1103 | | - |
1104 | newWindow->createWinId(); | - |
1105 | platformMenuBar->handleReparent(newWindow->windowHandle()); | - |
1106 | } else { | 0 |
1107 | platformMenuBar->handleReparent(0); | - |
1108 | } | 0 |
1109 | } | - |
1110 | | - |
1111 | | - |
1112 | | - |
1113 | | - |
1114 | | - |
1115 | } executed: } Execution Count:25 | 25 |
1116 | | - |
1117 | | - |
1118 | | - |
1119 | | - |
1120 | void QMenuBar::changeEvent(QEvent *e) | - |
1121 | { | - |
1122 | QMenuBarPrivate * const d = d_func(); | - |
1123 | if(e->type() == QEvent::StyleChange) { evaluated: e->type() == QEvent::StyleChange yes Evaluation Count:1 | yes Evaluation Count:65 |
| 1-65 |
1124 | d->itemsDirty = true; | - |
1125 | setMouseTracking(style()->styleHint(QStyle::SH_MenuBar_MouseTracking, 0, this)); | - |
1126 | if(parentWidget()) partially evaluated: parentWidget() no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
1127 | resize(parentWidget()->width(), heightForWidth(parentWidget()->width())); never executed: resize(parentWidget()->width(), heightForWidth(parentWidget()->width())); | 0 |
1128 | d->updateGeometries(); | - |
1129 | } else if (e->type() == QEvent::ParentChange) { executed: } Execution Count:1 evaluated: e->type() == QEvent::ParentChange yes Evaluation Count:2 | yes Evaluation Count:63 |
| 1-63 |
1130 | d->handleReparent(); | - |
1131 | } else if (e->type() == QEvent::FontChange executed: } Execution Count:2 partially evaluated: e->type() == QEvent::FontChange no Evaluation Count:0 | yes Evaluation Count:63 |
| 0-63 |
1132 | || e->type() == QEvent::ApplicationFontChange) { partially evaluated: e->type() == QEvent::ApplicationFontChange no Evaluation Count:0 | yes Evaluation Count:63 |
| 0-63 |
1133 | d->itemsDirty = true; | - |
1134 | d->updateGeometries(); | - |
1135 | } | 0 |
1136 | | - |
1137 | QWidget::changeEvent(e); | - |
1138 | } executed: } Execution Count:66 | 66 |
1139 | | - |
1140 | | - |
1141 | | - |
1142 | | - |
1143 | bool QMenuBar::event(QEvent *e) | - |
1144 | { | - |
1145 | QMenuBarPrivate * const d = d_func(); | - |
1146 | switch (e->type()) { | - |
1147 | case QEvent::KeyPress: { | - |
1148 | QKeyEvent *ke = (QKeyEvent*)e; | - |
1149 | | - |
1150 | | - |
1151 | | - |
1152 | | - |
1153 | | - |
1154 | | - |
1155 | if(ke->key() == Qt::Key_Tab || ke->key() == Qt::Key_Backtab) { partially evaluated: ke->key() == Qt::Key_Tab no Evaluation Count:0 | yes Evaluation Count:23 |
partially evaluated: ke->key() == Qt::Key_Backtab no Evaluation Count:0 | yes Evaluation Count:23 |
| 0-23 |
1156 | keyPressEvent(ke); | - |
1157 | return true; never executed: return true; | 0 |
1158 | } | - |
1159 | | - |
1160 | } break; executed: break; Execution Count:23 | 23 |
1161 | | - |
1162 | case QEvent::Shortcut: { | - |
1163 | QShortcutEvent *se = static_cast<QShortcutEvent *>(e); | - |
1164 | int shortcutId = se->shortcutId(); | - |
1165 | for(int j = 0; j < d->shortcutIndexMap.size(); ++j) { evaluated: j < d->shortcutIndexMap.size() yes Evaluation Count:26 | yes Evaluation Count:12 |
| 12-26 |
1166 | if (shortcutId == d->shortcutIndexMap.value(j)) evaluated: shortcutId == d->shortcutIndexMap.value(j) yes Evaluation Count:12 | yes Evaluation Count:14 |
| 12-14 |
1167 | d->_q_internalShortcutActivated(j); executed: d->_q_internalShortcutActivated(j); Execution Count:12 | 12 |
1168 | } executed: } Execution Count:26 | 26 |
1169 | } break; executed: break; Execution Count:12 | 12 |
1170 | | - |
1171 | case QEvent::Show: | - |
1172 | d->_q_updateLayout(); | - |
1173 | break; executed: break; Execution Count:35 | 35 |
1174 | case QEvent::ShortcutOverride: { | - |
1175 | QKeyEvent *kev = static_cast<QKeyEvent*>(e); | - |
1176 | | - |
1177 | if (kev->key() == Qt::Key_Escape && d->currentAction) { evaluated: kev->key() == Qt::Key_Escape yes Evaluation Count:2 | yes Evaluation Count:32 |
evaluated: d->currentAction yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1-32 |
1178 | e->accept(); | - |
1179 | return true; executed: return true; Execution Count:1 | 1 |
1180 | } | - |
1181 | } | - |
1182 | break; executed: break; Execution Count:33 | 33 |
1183 | | - |
1184 | | - |
1185 | | - |
1186 | case QEvent::QueryWhatsThis: | - |
1187 | e->setAccepted(d->whatsThis.size()); | - |
1188 | if (QAction *action = d->actionAt(static_cast<QHelpEvent*>(e)->pos())) { never evaluated: QAction *action = d->actionAt(static_cast<QHelpEvent*>(e)->pos()) | 0 |
1189 | if (action->whatsThis().size() || action->menu()) never evaluated: action->whatsThis().size() never evaluated: action->menu() | 0 |
1190 | e->accept(); never executed: e->accept(); | 0 |
1191 | } | 0 |
1192 | return true; never executed: return true; | 0 |
1193 | | - |
1194 | case QEvent::LayoutDirectionChange: | - |
1195 | d->_q_updateLayout(); | - |
1196 | break; executed: break; Execution Count:10 | 10 |
1197 | default: | - |
1198 | break; executed: break; Execution Count:1261 | 1261 |
1199 | } | - |
1200 | return QWidget::event(e); executed: return QWidget::event(e); Execution Count:1374 | 1374 |
1201 | } | - |
1202 | | - |
1203 | | - |
1204 | | - |
1205 | | - |
1206 | bool QMenuBar::eventFilter(QObject *object, QEvent *event) | - |
1207 | { | - |
1208 | QMenuBarPrivate * const d = d_func(); | - |
1209 | if (object == parent() && object) { evaluated: object == parent() yes Evaluation Count:1142 | yes Evaluation Count:607 |
partially evaluated: object yes Evaluation Count:1142 | no Evaluation Count:0 |
| 0-1142 |
1210 | if (event->type() == QEvent::ParentChange) partially evaluated: event->type() == QEvent::ParentChange no Evaluation Count:0 | yes Evaluation Count:1142 |
| 0-1142 |
1211 | d->handleReparent(); never executed: d->handleReparent(); | 0 |
1212 | } executed: } Execution Count:1142 | 1142 |
1213 | if (object == d->leftWidget || object == d->rightWidget) { evaluated: object == d->leftWidget yes Evaluation Count:227 | yes Evaluation Count:1522 |
evaluated: object == d->rightWidget yes Evaluation Count:219 | yes Evaluation Count:1303 |
| 219-1522 |
1214 | switch (event->type()) { | - |
1215 | case QEvent::ShowToParent: | - |
1216 | case QEvent::HideToParent: | - |
1217 | d->_q_updateLayout(); | - |
1218 | break; executed: break; Execution Count:84 | 84 |
1219 | default: | - |
1220 | break; executed: break; Execution Count:362 | 362 |
1221 | } | - |
1222 | } executed: } Execution Count:446 | 446 |
1223 | | - |
1224 | if (style()->styleHint(QStyle::SH_MenuBar_AltKeyNavigation, 0, this)) { partially evaluated: style()->styleHint(QStyle::SH_MenuBar_AltKeyNavigation, 0, this) yes Evaluation Count:1749 | no Evaluation Count:0 |
| 0-1749 |
1225 | if (d->altPressed) { evaluated: d->altPressed yes Evaluation Count:267 | yes Evaluation Count:1482 |
| 267-1482 |
1226 | switch (event->type()) { | - |
1227 | case QEvent::KeyPress: | - |
1228 | case QEvent::KeyRelease: | - |
1229 | { | - |
1230 | QKeyEvent *kev = static_cast<QKeyEvent*>(event); | - |
1231 | if (kev->key() == Qt::Key_Alt || kev->key() == Qt::Key_Meta) { evaluated: kev->key() == Qt::Key_Alt yes Evaluation Count:43 | yes Evaluation Count:3 |
partially evaluated: kev->key() == Qt::Key_Meta no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-43 |
1232 | if (event->type() == QEvent::KeyPress) evaluated: event->type() == QEvent::KeyPress yes Evaluation Count:42 | yes Evaluation Count:1 |
| 1-42 |
1233 | break; executed: break; Execution Count:42 | 42 |
1234 | d->setKeyboardMode(!d->keyboardState); | - |
1235 | } executed: } Execution Count:1 | 1 |
1236 | } | - |
1237 | | - |
1238 | case QEvent::MouseButtonPress: code before this statement executed: case QEvent::MouseButtonPress: Execution Count:4 | 4 |
1239 | case QEvent::MouseButtonRelease: | - |
1240 | case QEvent::MouseMove: | - |
1241 | case QEvent::FocusIn: | - |
1242 | case QEvent::FocusOut: | - |
1243 | case QEvent::ActivationChange: | - |
1244 | d->altPressed = false; | - |
1245 | (static_cast<QApplication *>(QCoreApplication::instance()))->removeEventFilter(this); | - |
1246 | break; executed: break; Execution Count:19 | 19 |
1247 | default: | - |
1248 | break; executed: break; Execution Count:206 | 206 |
1249 | } | - |
1250 | } else if (isVisible()) { executed: } Execution Count:267 evaluated: isVisible() yes Evaluation Count:1238 | yes Evaluation Count:244 |
| 244-1238 |
1251 | if (event->type() == QEvent::ShortcutOverride) { evaluated: event->type() == QEvent::ShortcutOverride yes Evaluation Count:43 | yes Evaluation Count:1195 |
| 43-1195 |
1252 | QKeyEvent *kev = static_cast<QKeyEvent*>(event); | - |
1253 | if ((kev->key() == Qt::Key_Alt || kev->key() == Qt::Key_Meta) evaluated: kev->key() == Qt::Key_Alt yes Evaluation Count:18 | yes Evaluation Count:25 |
partially evaluated: kev->key() == Qt::Key_Meta no Evaluation Count:0 | yes Evaluation Count:25 |
| 0-25 |
1254 | && kev->modifiers() == Qt::AltModifier) { partially evaluated: kev->modifiers() == Qt::AltModifier yes Evaluation Count:18 | no Evaluation Count:0 |
| 0-18 |
1255 | d->altPressed = true; | - |
1256 | (static_cast<QApplication *>(QCoreApplication::instance()))->installEventFilter(this); | - |
1257 | } executed: } Execution Count:18 | 18 |
1258 | } executed: } Execution Count:43 | 43 |
1259 | } executed: } Execution Count:1238 | 1238 |
1260 | } | - |
1261 | | - |
1262 | return false; executed: return false; Execution Count:1749 | 1749 |
1263 | } | - |
1264 | | - |
1265 | | - |
1266 | | - |
1267 | | - |
1268 | | - |
1269 | | - |
1270 | | - |
1271 | QAction *QMenuBar::actionAt(const QPoint &pt) const | - |
1272 | { | - |
1273 | const QMenuBarPrivate * const d = d_func(); | - |
1274 | return d->actionAt(pt); never executed: return d->actionAt(pt); | 0 |
1275 | } | - |
1276 | | - |
1277 | | - |
1278 | | - |
1279 | | - |
1280 | | - |
1281 | | - |
1282 | QRect QMenuBar::actionGeometry(QAction *act) const | - |
1283 | { | - |
1284 | const QMenuBarPrivate * const d = d_func(); | - |
1285 | return d->actionRect(act); executed: return d->actionRect(act); Execution Count:21 | 21 |
1286 | } | - |
1287 | | - |
1288 | | - |
1289 | | - |
1290 | | - |
1291 | QSize QMenuBar::minimumSizeHint() const | - |
1292 | { | - |
1293 | const QMenuBarPrivate * const d = d_func(); | - |
1294 | | - |
1295 | | - |
1296 | | - |
1297 | const bool as_gui_menubar = true; | - |
1298 | | - |
1299 | | - |
1300 | ensurePolished(); | - |
1301 | QSize ret(0, 0); | - |
1302 | const_cast<QMenuBarPrivate*>(d)->updateGeometries(); | - |
1303 | const int hmargin = style()->pixelMetric(QStyle::PM_MenuBarHMargin, 0, this); | - |
1304 | const int vmargin = style()->pixelMetric(QStyle::PM_MenuBarVMargin, 0, this); | - |
1305 | int fw = style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, this); | - |
1306 | int spaceBelowMenuBar = style()->styleHint(QStyle::SH_MainWindow_SpaceBelowMenuBar, 0, this); | - |
1307 | if(as_gui_menubar) { never evaluated: as_gui_menubar | 0 |
1308 | int w = parentWidget() ? parentWidget()->width() : QApplication::desktop()->width(); never evaluated: parentWidget() | 0 |
1309 | d->calcActionRects(w - (2 * fw), 0); | - |
1310 | for (int i = 0; ret.isNull() && i < d->actions.count(); ++i) never evaluated: ret.isNull() never evaluated: i < d->actions.count() | 0 |
1311 | ret = d->actionRects.at(i).size(); never executed: ret = d->actionRects.at(i).size(); | 0 |
1312 | if (!d->extension->isHidden()) never evaluated: !d->extension->isHidden() | 0 |
1313 | ret += QSize(d->extension->sizeHint().width(), 0); never executed: ret += QSize(d->extension->sizeHint().width(), 0); | 0 |
1314 | ret += QSize(2*fw + hmargin, 2*fw + vmargin); | - |
1315 | } | 0 |
1316 | int margin = 2*vmargin + 2*fw + spaceBelowMenuBar; | - |
1317 | if(d->leftWidget) { never evaluated: d->leftWidget | 0 |
1318 | QSize sz = d->leftWidget->minimumSizeHint(); | - |
1319 | ret.setWidth(ret.width() + sz.width()); | - |
1320 | if(sz.height() + margin > ret.height()) never evaluated: sz.height() + margin > ret.height() | 0 |
1321 | ret.setHeight(sz.height() + margin); never executed: ret.setHeight(sz.height() + margin); | 0 |
1322 | } | 0 |
1323 | if(d->rightWidget) { never evaluated: d->rightWidget | 0 |
1324 | QSize sz = d->rightWidget->minimumSizeHint(); | - |
1325 | ret.setWidth(ret.width() + sz.width()); | - |
1326 | if(sz.height() + margin > ret.height()) never evaluated: sz.height() + margin > ret.height() | 0 |
1327 | ret.setHeight(sz.height() + margin); never executed: ret.setHeight(sz.height() + margin); | 0 |
1328 | } | 0 |
1329 | if(as_gui_menubar) { never evaluated: as_gui_menubar | 0 |
1330 | QStyleOptionMenuItem opt; | - |
1331 | opt.rect = rect(); | - |
1332 | opt.menuRect = rect(); | - |
1333 | opt.state = QStyle::State_None; | - |
1334 | opt.menuItemType = QStyleOptionMenuItem::Normal; | - |
1335 | opt.checkType = QStyleOptionMenuItem::NotCheckable; | - |
1336 | opt.palette = palette(); | - |
1337 | return (style()->sizeFromContents(QStyle::CT_MenuBar, &opt, | 0 |
1338 | ret.expandedTo(QApplication::globalStrut()), | 0 |
1339 | this)); never executed: return (style()->sizeFromContents(QStyle::CT_MenuBar, &opt, ret.expandedTo(QApplication::globalStrut()), this)); | 0 |
1340 | } | - |
1341 | return ret; never executed: return ret; | 0 |
1342 | } | - |
1343 | | - |
1344 | | - |
1345 | | - |
1346 | | - |
1347 | QSize QMenuBar::sizeHint() const | - |
1348 | { | - |
1349 | const QMenuBarPrivate * const d = d_func(); | - |
1350 | | - |
1351 | | - |
1352 | | - |
1353 | const bool as_gui_menubar = true; | - |
1354 | | - |
1355 | | - |
1356 | | - |
1357 | ensurePolished(); | - |
1358 | QSize ret(0, 0); | - |
1359 | const_cast<QMenuBarPrivate*>(d)->updateGeometries(); | - |
1360 | const int hmargin = style()->pixelMetric(QStyle::PM_MenuBarHMargin, 0, this); | - |
1361 | const int vmargin = style()->pixelMetric(QStyle::PM_MenuBarVMargin, 0, this); | - |
1362 | int fw = style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, this); | - |
1363 | int spaceBelowMenuBar = style()->styleHint(QStyle::SH_MainWindow_SpaceBelowMenuBar, 0, this); | - |
1364 | if(as_gui_menubar) { partially evaluated: as_gui_menubar yes Evaluation Count:4 | no Evaluation Count:0 |
| 0-4 |
1365 | const int w = parentWidget() ? parentWidget()->width() : QApplication::desktop()->width(); partially evaluated: parentWidget() no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
1366 | d->calcActionRects(w - (2 * fw), 0); | - |
1367 | for (int i = 0; i < d->actionRects.count(); ++i) { evaluated: i < d->actionRects.count() yes Evaluation Count:13 | yes Evaluation Count:4 |
| 4-13 |
1368 | const QRect &actionRect = d->actionRects.at(i); | - |
1369 | ret = ret.expandedTo(QSize(actionRect.x() + actionRect.width(), actionRect.y() + actionRect.height())); | - |
1370 | } executed: } Execution Count:13 | 13 |
1371 | | - |
1372 | | - |
1373 | ret += QSize(fw + hmargin, fw + vmargin); | - |
1374 | } executed: } Execution Count:4 | 4 |
1375 | int margin = 2*vmargin + 2*fw + spaceBelowMenuBar; | - |
1376 | if(d->leftWidget) { partially evaluated: d->leftWidget no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
1377 | QSize sz = d->leftWidget->sizeHint(); | - |
1378 | ret.setWidth(ret.width() + sz.width()); | - |
1379 | if(sz.height() + margin > ret.height()) never evaluated: sz.height() + margin > ret.height() | 0 |
1380 | ret.setHeight(sz.height() + margin); never executed: ret.setHeight(sz.height() + margin); | 0 |
1381 | } | 0 |
1382 | if(d->rightWidget) { partially evaluated: d->rightWidget no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
1383 | QSize sz = d->rightWidget->sizeHint(); | - |
1384 | ret.setWidth(ret.width() + sz.width()); | - |
1385 | if(sz.height() + margin > ret.height()) never evaluated: sz.height() + margin > ret.height() | 0 |
1386 | ret.setHeight(sz.height() + margin); never executed: ret.setHeight(sz.height() + margin); | 0 |
1387 | } | 0 |
1388 | if(as_gui_menubar) { partially evaluated: as_gui_menubar yes Evaluation Count:4 | no Evaluation Count:0 |
| 0-4 |
1389 | QStyleOptionMenuItem opt; | - |
1390 | opt.rect = rect(); | - |
1391 | opt.menuRect = rect(); | - |
1392 | opt.state = QStyle::State_None; | - |
1393 | opt.menuItemType = QStyleOptionMenuItem::Normal; | - |
1394 | opt.checkType = QStyleOptionMenuItem::NotCheckable; | - |
1395 | opt.palette = palette(); | - |
1396 | return (style()->sizeFromContents(QStyle::CT_MenuBar, &opt, | 4 |
1397 | ret.expandedTo(QApplication::globalStrut()), | 4 |
1398 | this)); executed: return (style()->sizeFromContents(QStyle::CT_MenuBar, &opt, ret.expandedTo(QApplication::globalStrut()), this)); Execution Count:4 | 4 |
1399 | } | - |
1400 | return ret; never executed: return ret; | 0 |
1401 | } | - |
1402 | | - |
1403 | | - |
1404 | | - |
1405 | | - |
1406 | int QMenuBar::heightForWidth(int) const | - |
1407 | { | - |
1408 | const QMenuBarPrivate * const d = d_func(); | - |
1409 | | - |
1410 | | - |
1411 | | - |
1412 | const bool as_gui_menubar = true; | - |
1413 | | - |
1414 | | - |
1415 | const_cast<QMenuBarPrivate*>(d)->updateGeometries(); | - |
1416 | int height = 0; | - |
1417 | const int vmargin = style()->pixelMetric(QStyle::PM_MenuBarVMargin, 0, this); | - |
1418 | int fw = style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, this); | - |
1419 | int spaceBelowMenuBar = style()->styleHint(QStyle::SH_MainWindow_SpaceBelowMenuBar, 0, this); | - |
1420 | if(as_gui_menubar) { partially evaluated: as_gui_menubar yes Evaluation Count:153 | no Evaluation Count:0 |
| 0-153 |
1421 | for (int i = 0; i < d->actionRects.count(); ++i) evaluated: i < d->actionRects.count() yes Evaluation Count:91 | yes Evaluation Count:153 |
| 91-153 |
1422 | height = qMax(height, d->actionRects.at(i).height()); executed: height = qMax(height, d->actionRects.at(i).height()); Execution Count:91 | 91 |
1423 | if (height) evaluated: height yes Evaluation Count:38 | yes Evaluation Count:115 |
| 38-115 |
1424 | height += spaceBelowMenuBar; executed: height += spaceBelowMenuBar; Execution Count:38 | 38 |
1425 | height += 2*fw; | - |
1426 | height += 2*vmargin; | - |
1427 | } executed: } Execution Count:153 | 153 |
1428 | int margin = 2*vmargin + 2*fw + spaceBelowMenuBar; | - |
1429 | if(d->leftWidget) evaluated: d->leftWidget yes Evaluation Count:63 | yes Evaluation Count:90 |
| 63-90 |
1430 | height = qMax(d->leftWidget->sizeHint().height() + margin, height); executed: height = qMax(d->leftWidget->sizeHint().height() + margin, height); Execution Count:63 | 63 |
1431 | if(d->rightWidget) evaluated: d->rightWidget yes Evaluation Count:63 | yes Evaluation Count:90 |
| 63-90 |
1432 | height = qMax(d->rightWidget->sizeHint().height() + margin, height); executed: height = qMax(d->rightWidget->sizeHint().height() + margin, height); Execution Count:63 | 63 |
1433 | if(as_gui_menubar) { partially evaluated: as_gui_menubar yes Evaluation Count:153 | no Evaluation Count:0 |
| 0-153 |
1434 | QStyleOptionMenuItem opt; | - |
1435 | opt.init(this); | - |
1436 | opt.menuRect = rect(); | - |
1437 | opt.state = QStyle::State_None; | - |
1438 | opt.menuItemType = QStyleOptionMenuItem::Normal; | - |
1439 | opt.checkType = QStyleOptionMenuItem::NotCheckable; | - |
1440 | return style()->sizeFromContents(QStyle::CT_MenuBar, &opt, QSize(0, height), this).height(); executed: return style()->sizeFromContents(QStyle::CT_MenuBar, &opt, QSize(0, height), this).height(); Execution Count:153 | 153 |
1441 | } | - |
1442 | return height; never executed: return height; | 0 |
1443 | } | - |
1444 | | - |
1445 | | - |
1446 | | - |
1447 | | - |
1448 | void QMenuBarPrivate::_q_internalShortcutActivated(int id) | - |
1449 | { | - |
1450 | QMenuBar * const q = q_func(); | - |
1451 | QAction *act = actions.at(id); | - |
1452 | setCurrentAction(act, true, true); | - |
1453 | if (act && !act->menu()) { partially evaluated: act yes Evaluation Count:12 | no Evaluation Count:0 |
evaluated: !act->menu() yes Evaluation Count:1 | yes Evaluation Count:11 |
| 0-12 |
1454 | activateAction(act, QAction::Trigger); | - |
1455 | | - |
1456 | autoReleaseTimer.start(100, q); | - |
1457 | } else if (act && q->style()->styleHint(QStyle::SH_MenuBar_AltKeyNavigation, 0, q)) { executed: } Execution Count:1 partially evaluated: act yes Evaluation Count:11 | no Evaluation Count:0 |
partially evaluated: q->style()->styleHint(QStyle::SH_MenuBar_AltKeyNavigation, 0, q) yes Evaluation Count:11 | no Evaluation Count:0 |
| 0-11 |
1458 | | - |
1459 | setKeyboardMode(true); | - |
1460 | } executed: } Execution Count:11 | 11 |
1461 | } | - |
1462 | | - |
1463 | void QMenuBarPrivate::_q_updateLayout() | - |
1464 | { | - |
1465 | QMenuBar * const q = q_func(); | - |
1466 | itemsDirty = true; | - |
1467 | if (q->isVisible()) { evaluated: q->isVisible() yes Evaluation Count:231 | yes Evaluation Count:22 |
| 22-231 |
1468 | updateGeometries(); | - |
1469 | q->update(); | - |
1470 | } executed: } Execution Count:231 | 231 |
1471 | } executed: } Execution Count:253 | 253 |
1472 | void QMenuBar::setCornerWidget(QWidget *w, Qt::Corner corner) | - |
1473 | { | - |
1474 | QMenuBarPrivate * const d = d_func(); | - |
1475 | switch (corner) { | - |
1476 | case Qt::TopLeftCorner: | - |
1477 | if (d->leftWidget) evaluated: d->leftWidget yes Evaluation Count:29 | yes Evaluation Count:33 |
| 29-33 |
1478 | d->leftWidget->removeEventFilter(this); executed: d->leftWidget->removeEventFilter(this); Execution Count:29 | 29 |
1479 | d->leftWidget = w; | - |
1480 | break; executed: break; Execution Count:62 | 62 |
1481 | case Qt::TopRightCorner: | - |
1482 | if (d->rightWidget) evaluated: d->rightWidget yes Evaluation Count:29 | yes Evaluation Count:33 |
| 29-33 |
1483 | d->rightWidget->removeEventFilter(this); executed: d->rightWidget->removeEventFilter(this); Execution Count:29 | 29 |
1484 | d->rightWidget = w; | - |
1485 | break; executed: break; Execution Count:62 | 62 |
1486 | default: | - |
1487 | QMessageLogger("widgets/qmenubar.cpp", 1767, __PRETTY_FUNCTION__).warning("QMenuBar::setCornerWidget: Only TopLeftCorner and TopRightCorner are supported"); | - |
1488 | return; | 0 |
1489 | } | - |
1490 | | - |
1491 | if (w) { evaluated: w yes Evaluation Count:72 | yes Evaluation Count:52 |
| 52-72 |
1492 | w->setParent(this); | - |
1493 | w->installEventFilter(this); | - |
1494 | } executed: } Execution Count:72 | 72 |
1495 | | - |
1496 | d->_q_updateLayout(); | - |
1497 | } executed: } Execution Count:124 | 124 |
1498 | QWidget *QMenuBar::cornerWidget(Qt::Corner corner) const | - |
1499 | { | - |
1500 | const QMenuBarPrivate * const d = d_func(); | - |
1501 | QWidget *w = 0; | - |
1502 | switch(corner) { | - |
1503 | case Qt::TopLeftCorner: | - |
1504 | w = d->leftWidget; | - |
1505 | break; executed: break; Execution Count:210 | 210 |
1506 | case Qt::TopRightCorner: | - |
1507 | w = d->rightWidget; | - |
1508 | break; executed: break; Execution Count:270 | 270 |
1509 | default: | - |
1510 | QMessageLogger("widgets/qmenubar.cpp", 1798, __PRETTY_FUNCTION__).warning("QMenuBar::cornerWidget: Only TopLeftCorner and TopRightCorner are supported"); | - |
1511 | break; | 0 |
1512 | } | - |
1513 | | - |
1514 | return w; executed: return w; Execution Count:480 | 480 |
1515 | } | - |
1516 | void QMenuBar::setNativeMenuBar(bool nativeMenuBar) | - |
1517 | { | - |
1518 | QMenuBarPrivate * const d = d_func(); | - |
1519 | if (d->nativeMenuBar == -1 || (nativeMenuBar != bool(d->nativeMenuBar))) { partially evaluated: d->nativeMenuBar == -1 yes Evaluation Count:3 | no Evaluation Count:0 |
never evaluated: (nativeMenuBar != bool(d->nativeMenuBar)) | 0-3 |
1520 | d->nativeMenuBar = nativeMenuBar; | - |
1521 | | - |
1522 | if (!d->nativeMenuBar) { partially evaluated: !d->nativeMenuBar yes Evaluation Count:3 | no Evaluation Count:0 |
| 0-3 |
1523 | delete d->platformMenuBar; | - |
1524 | d->platformMenuBar = 0; | - |
1525 | } else { executed: } Execution Count:3 | 3 |
1526 | if (!d->platformMenuBar) never evaluated: !d->platformMenuBar | 0 |
1527 | d->platformMenuBar = QGuiApplicationPrivate::platformTheme()->createPlatformMenuBar(); never executed: d->platformMenuBar = QGuiApplicationPrivate::platformTheme()->createPlatformMenuBar(); | 0 |
1528 | } | 0 |
1529 | | - |
1530 | updateGeometry(); | - |
1531 | if (!d->nativeMenuBar && parentWidget()) partially evaluated: !d->nativeMenuBar yes Evaluation Count:3 | no Evaluation Count:0 |
evaluated: parentWidget() yes Evaluation Count:1 | yes Evaluation Count:2 |
| 0-3 |
1532 | setVisible(true); executed: setVisible(true); Execution Count:1 | 1 |
1533 | } executed: } Execution Count:3 | 3 |
1534 | } executed: } Execution Count:3 | 3 |
1535 | | - |
1536 | bool QMenuBar::isNativeMenuBar() const | - |
1537 | { | - |
1538 | const QMenuBarPrivate * const d = d_func(); | - |
1539 | if (d->nativeMenuBar == -1) { never evaluated: d->nativeMenuBar == -1 | 0 |
1540 | return !QApplication::instance()->testAttribute(Qt::AA_DontUseNativeMenuBar); never executed: return !QApplication::instance()->testAttribute(Qt::AA_DontUseNativeMenuBar); | 0 |
1541 | } | - |
1542 | return d->nativeMenuBar; never executed: return d->nativeMenuBar; | 0 |
1543 | } | - |
1544 | | - |
1545 | | - |
1546 | | - |
1547 | | - |
1548 | QPlatformMenuBar *QMenuBar::platformMenuBar() | - |
1549 | { | - |
1550 | const QMenuBarPrivate * const d = d_func(); | - |
1551 | return d->platformMenuBar; never executed: return d->platformMenuBar; | 0 |
1552 | } | - |
1553 | | - |
1554 | | - |
1555 | | - |
| | |