Line | Source Code | Coverage |
---|
1 | /**************************************************************************** | - |
2 | ** | - |
3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). | - |
4 | ** Contact: http://www.qt-project.org/legal | - |
5 | ** | - |
6 | ** This file is part of the QtGui module of the Qt Toolkit. | - |
7 | ** | - |
8 | ** $QT_BEGIN_LICENSE:LGPL$ | - |
9 | ** Commercial License Usage | - |
10 | ** Licensees holding valid commercial Qt licenses may use this file in | - |
11 | ** accordance with the commercial license agreement provided with the | - |
12 | ** Software or, alternatively, in accordance with the terms contained in | - |
13 | ** a written agreement between you and Digia. For licensing terms and | - |
14 | ** conditions see http://qt.digia.com/licensing. For further information | - |
15 | ** use the contact form at http://qt.digia.com/contact-us. | - |
16 | ** | - |
17 | ** GNU Lesser General Public License Usage | - |
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - |
19 | ** General Public License version 2.1 as published by the Free Software | - |
20 | ** Foundation and appearing in the file LICENSE.LGPL included in the | - |
21 | ** packaging of this file. Please review the following information to | - |
22 | ** ensure the GNU Lesser General Public License version 2.1 requirements | - |
23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - |
24 | ** | - |
25 | ** In addition, as a special exception, Digia gives you certain additional | - |
26 | ** rights. These rights are described in the Digia Qt LGPL Exception | - |
27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - |
28 | ** | - |
29 | ** GNU General Public License Usage | - |
30 | ** Alternatively, this file may be used under the terms of the GNU | - |
31 | ** General Public License version 3.0 as published by the Free Software | - |
32 | ** Foundation and appearing in the file LICENSE.GPL included in the | - |
33 | ** packaging of this file. Please review the following information to | - |
34 | ** ensure the GNU General Public License version 3.0 requirements will be | - |
35 | ** met: http://www.gnu.org/copyleft/gpl.html. | - |
36 | ** | - |
37 | ** | - |
38 | ** $QT_END_LICENSE$ | - |
39 | ** | - |
40 | ****************************************************************************/ | - |
41 | | - |
42 | #include "qaction.h" | - |
43 | #include "qactiongroup.h" | - |
44 | | - |
45 | #ifndef QT_NO_ACTION | - |
46 | #include "qaction_p.h" | - |
47 | #include "qapplication.h" | - |
48 | #include "qevent.h" | - |
49 | #include "qlist.h" | - |
50 | #include "qdebug.h" | - |
51 | #include <private/qshortcutmap_p.h> | - |
52 | #include <private/qapplication_p.h> | - |
53 | #include <private/qmenu_p.h> | - |
54 | | - |
55 | #define QAPP_CHECK(functionName) \ | - |
56 | if (!qApp) { \ | - |
57 | qWarning("QAction: Initialize QApplication before calling '" functionName "'."); \ | - |
58 | return; \ | - |
59 | } | - |
60 | | - |
61 | QT_BEGIN_NAMESPACE | - |
62 | | - |
63 | /* | - |
64 | internal: guesses a descriptive text from a text suited for a menu entry | - |
65 | */ | - |
66 | static QString qt_strippedText(QString s) | - |
67 | { | - |
68 | s.remove( QString::fromLatin1("...") ); executed (the execution status of this line is deduced): s.remove( QString::fromLatin1("...") ); | - |
69 | int i = 0; executed (the execution status of this line is deduced): int i = 0; | - |
70 | while (i < s.size()) { evaluated: i < s.size() yes Evaluation Count:235 | yes Evaluation Count:39 |
| 39-235 |
71 | ++i; executed (the execution status of this line is deduced): ++i; | - |
72 | if (s.at(i-1) != QLatin1Char('&')) evaluated: s.at(i-1) != QLatin1Char('&') yes Evaluation Count:233 | yes Evaluation Count:2 |
| 2-233 |
73 | continue; executed: continue; Execution Count:233 | 233 |
74 | if (i < s.size() && s.at(i) == QLatin1Char('&')) partially evaluated: i < s.size() yes Evaluation Count:2 | no Evaluation Count:0 |
evaluated: s.at(i) == QLatin1Char('&') yes Evaluation Count:1 | yes Evaluation Count:1 |
| 0-2 |
75 | ++i; executed: ++i; Execution Count:1 | 1 |
76 | s.remove(i-1,1); executed (the execution status of this line is deduced): s.remove(i-1,1); | - |
77 | } executed: } Execution Count:2 | 2 |
78 | return s.trimmed(); executed: return s.trimmed(); Execution Count:39 | 39 |
79 | } | - |
80 | | - |
81 | | - |
82 | QActionPrivate::QActionPrivate() : group(0), enabled(1), forceDisabled(0), | - |
83 | visible(1), forceInvisible(0), checkable(0), checked(0), separator(0), fontSet(false), | - |
84 | iconVisibleInMenu(-1), | - |
85 | menuRole(QAction::TextHeuristicRole), | - |
86 | priority(QAction::NormalPriority) | - |
87 | { | - |
88 | #ifndef QT_NO_SHORTCUT | - |
89 | shortcutId = 0; executed (the execution status of this line is deduced): shortcutId = 0; | - |
90 | shortcutContext = Qt::WindowShortcut; executed (the execution status of this line is deduced): shortcutContext = Qt::WindowShortcut; | - |
91 | autorepeat = true; executed (the execution status of this line is deduced): autorepeat = true; | - |
92 | #endif | - |
93 | } executed: } Execution Count:3599 | 3599 |
94 | | - |
95 | QActionPrivate::~QActionPrivate() | - |
96 | { | - |
97 | } | - |
98 | | - |
99 | bool QActionPrivate::showStatusText(QWidget *widget, const QString &str) | - |
100 | { | - |
101 | #ifdef QT_NO_STATUSTIP | - |
102 | Q_UNUSED(widget); | - |
103 | Q_UNUSED(str); | - |
104 | #else | - |
105 | if(QObject *object = widget ? widget : parent) { evaluated: widget yes Evaluation Count:74 | yes Evaluation Count:44 |
| 44-74 |
106 | QStatusTipEvent tip(str); executed (the execution status of this line is deduced): QStatusTipEvent tip(str); | - |
107 | QApplication::sendEvent(object, &tip); executed (the execution status of this line is deduced): QApplication::sendEvent(object, &tip); | - |
108 | return true; executed: return true; Execution Count:105 | 105 |
109 | } | - |
110 | #endif | - |
111 | return false; executed: return false; Execution Count:13 | 13 |
112 | } | - |
113 | | - |
114 | void QActionPrivate::sendDataChanged() | - |
115 | { | - |
116 | Q_Q(QAction); executed (the execution status of this line is deduced): QAction * const q = q_func(); | - |
117 | QActionEvent e(QEvent::ActionChanged, q); executed (the execution status of this line is deduced): QActionEvent e(QEvent::ActionChanged, q); | - |
118 | for (int i = 0; i < widgets.size(); ++i) { evaluated: i < widgets.size() yes Evaluation Count:9495 | yes Evaluation Count:9939 |
| 9495-9939 |
119 | QWidget *w = widgets.at(i); executed (the execution status of this line is deduced): QWidget *w = widgets.at(i); | - |
120 | QApplication::sendEvent(w, &e); executed (the execution status of this line is deduced): QApplication::sendEvent(w, &e); | - |
121 | } executed: } Execution Count:9495 | 9495 |
122 | #ifndef QT_NO_GRAPHICSVIEW | - |
123 | for (int i = 0; i < graphicsWidgets.size(); ++i) { partially evaluated: i < graphicsWidgets.size() no Evaluation Count:0 | yes Evaluation Count:9939 |
| 0-9939 |
124 | QGraphicsWidget *w = graphicsWidgets.at(i); never executed (the execution status of this line is deduced): QGraphicsWidget *w = graphicsWidgets.at(i); | - |
125 | QApplication::sendEvent(w, &e); never executed (the execution status of this line is deduced): QApplication::sendEvent(w, &e); | - |
126 | } | 0 |
127 | #endif | - |
128 | QApplication::sendEvent(q, &e); executed (the execution status of this line is deduced): QApplication::sendEvent(q, &e); | - |
129 | | - |
130 | emit q->changed(); executed (the execution status of this line is deduced): q->changed(); | - |
131 | } executed: } Execution Count:9939 | 9939 |
132 | | - |
133 | #ifndef QT_NO_SHORTCUT | - |
134 | void QActionPrivate::redoGrab(QShortcutMap &map) | - |
135 | { | - |
136 | Q_Q(QAction); executed (the execution status of this line is deduced): QAction * const q = q_func(); | - |
137 | if (shortcutId) evaluated: shortcutId yes Evaluation Count:7 | yes Evaluation Count:578 |
| 7-578 |
138 | map.removeShortcut(shortcutId, q); executed: map.removeShortcut(shortcutId, q); Execution Count:7 | 7 |
139 | if (shortcut.isEmpty()) evaluated: shortcut.isEmpty() yes Evaluation Count:1 | yes Evaluation Count:584 |
| 1-584 |
140 | return; executed: return; Execution Count:1 | 1 |
141 | shortcutId = map.addShortcut(q, shortcut, shortcutContext, qWidgetShortcutContextMatcher); executed (the execution status of this line is deduced): shortcutId = map.addShortcut(q, shortcut, shortcutContext, qWidgetShortcutContextMatcher); | - |
142 | if (!enabled) evaluated: !enabled yes Evaluation Count:1 | yes Evaluation Count:583 |
| 1-583 |
143 | map.setShortcutEnabled(false, shortcutId, q); executed: map.setShortcutEnabled(false, shortcutId, q); Execution Count:1 | 1 |
144 | if (!autorepeat) evaluated: !autorepeat yes Evaluation Count:1 | yes Evaluation Count:583 |
| 1-583 |
145 | map.setShortcutAutoRepeat(false, shortcutId, q); executed: map.setShortcutAutoRepeat(false, shortcutId, q); Execution Count:1 | 1 |
146 | } executed: } Execution Count:584 | 584 |
147 | | - |
148 | void QActionPrivate::redoGrabAlternate(QShortcutMap &map) | - |
149 | { | - |
150 | Q_Q(QAction); executed (the execution status of this line is deduced): QAction * const q = q_func(); | - |
151 | for(int i = 0; i < alternateShortcutIds.count(); ++i) { evaluated: i < alternateShortcutIds.count() yes Evaluation Count:1 | yes Evaluation Count:106 |
| 1-106 |
152 | if (const int id = alternateShortcutIds.at(i)) partially evaluated: const int id = alternateShortcutIds.at(i) yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
153 | map.removeShortcut(id, q); executed: map.removeShortcut(id, q); Execution Count:1 | 1 |
154 | } executed: } Execution Count:1 | 1 |
155 | alternateShortcutIds.clear(); executed (the execution status of this line is deduced): alternateShortcutIds.clear(); | - |
156 | if (alternateShortcuts.isEmpty()) evaluated: alternateShortcuts.isEmpty() yes Evaluation Count:103 | yes Evaluation Count:3 |
| 3-103 |
157 | return; executed: return; Execution Count:103 | 103 |
158 | for(int i = 0; i < alternateShortcuts.count(); ++i) { evaluated: i < alternateShortcuts.count() yes Evaluation Count:4 | yes Evaluation Count:3 |
| 3-4 |
159 | const QKeySequence& alternate = alternateShortcuts.at(i); executed (the execution status of this line is deduced): const QKeySequence& alternate = alternateShortcuts.at(i); | - |
160 | if (!alternate.isEmpty()) partially evaluated: !alternate.isEmpty() yes Evaluation Count:4 | no Evaluation Count:0 |
| 0-4 |
161 | alternateShortcutIds.append(map.addShortcut(q, alternate, shortcutContext, qWidgetShortcutContextMatcher)); executed: alternateShortcutIds.append(map.addShortcut(q, alternate, shortcutContext, qWidgetShortcutContextMatcher)); Execution Count:4 | 4 |
162 | else | - |
163 | alternateShortcutIds.append(0); never executed: alternateShortcutIds.append(0); | 0 |
164 | } | - |
165 | if (!enabled) { partially evaluated: !enabled no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-3 |
166 | for(int i = 0; i < alternateShortcutIds.count(); ++i) { never evaluated: i < alternateShortcutIds.count() | 0 |
167 | const int id = alternateShortcutIds.at(i); never executed (the execution status of this line is deduced): const int id = alternateShortcutIds.at(i); | - |
168 | map.setShortcutEnabled(false, id, q); never executed (the execution status of this line is deduced): map.setShortcutEnabled(false, id, q); | - |
169 | } | 0 |
170 | } | 0 |
171 | if (!autorepeat) { evaluated: !autorepeat yes Evaluation Count:1 | yes Evaluation Count:2 |
| 1-2 |
172 | for(int i = 0; i < alternateShortcutIds.count(); ++i) { evaluated: i < alternateShortcutIds.count() yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1 |
173 | const int id = alternateShortcutIds.at(i); executed (the execution status of this line is deduced): const int id = alternateShortcutIds.at(i); | - |
174 | map.setShortcutAutoRepeat(false, id, q); executed (the execution status of this line is deduced): map.setShortcutAutoRepeat(false, id, q); | - |
175 | } executed: } Execution Count:1 | 1 |
176 | } executed: } Execution Count:1 | 1 |
177 | } executed: } Execution Count:3 | 3 |
178 | | - |
179 | void QActionPrivate::setShortcutEnabled(bool enable, QShortcutMap &map) | - |
180 | { | - |
181 | Q_Q(QAction); executed (the execution status of this line is deduced): QAction * const q = q_func(); | - |
182 | if (shortcutId) evaluated: shortcutId yes Evaluation Count:579 | yes Evaluation Count:4765 |
| 579-4765 |
183 | map.setShortcutEnabled(enable, shortcutId, q); executed: map.setShortcutEnabled(enable, shortcutId, q); Execution Count:579 | 579 |
184 | for(int i = 0; i < alternateShortcutIds.count(); ++i) { partially evaluated: i < alternateShortcutIds.count() no Evaluation Count:0 | yes Evaluation Count:5344 |
| 0-5344 |
185 | if (const int id = alternateShortcutIds.at(i)) never evaluated: const int id = alternateShortcutIds.at(i) | 0 |
186 | map.setShortcutEnabled(enable, id, q); never executed: map.setShortcutEnabled(enable, id, q); | 0 |
187 | } | 0 |
188 | } executed: } Execution Count:5344 | 5344 |
189 | #endif // QT_NO_SHORTCUT | - |
190 | | - |
191 | | - |
192 | /*! | - |
193 | \class QAction | - |
194 | \brief The QAction class provides an abstract user interface | - |
195 | action that can be inserted into widgets. | - |
196 | | - |
197 | \ingroup mainwindow-classes | - |
198 | \inmodule QtWidgets | - |
199 | | - |
200 | \omit | - |
201 | * parent and widget are different | - |
202 | * parent does not define context | - |
203 | \endomit | - |
204 | | - |
205 | In applications many common commands can be invoked via menus, | - |
206 | toolbar buttons, and keyboard shortcuts. Since the user expects | - |
207 | each command to be performed in the same way, regardless of the | - |
208 | user interface used, it is useful to represent each command as | - |
209 | an \e action. | - |
210 | | - |
211 | Actions can be added to menus and toolbars, and will | - |
212 | automatically keep them in sync. For example, in a word processor, | - |
213 | if the user presses a Bold toolbar button, the Bold menu item | - |
214 | will automatically be checked. | - |
215 | | - |
216 | Actions can be created as independent objects, but they may | - |
217 | also be created during the construction of menus; the QMenu class | - |
218 | contains convenience functions for creating actions suitable for | - |
219 | use as menu items. | - |
220 | | - |
221 | A QAction may contain an icon, menu text, a shortcut, status text, | - |
222 | "What's This?" text, and a tooltip. Most of these can be set in | - |
223 | the constructor. They can also be set independently with | - |
224 | setIcon(), setText(), setIconText(), setShortcut(), | - |
225 | setStatusTip(), setWhatsThis(), and setToolTip(). For menu items, | - |
226 | it is possible to set an individual font with setFont(). | - |
227 | | - |
228 | Actions are added to widgets using QWidget::addAction() or | - |
229 | QGraphicsWidget::addAction(). Note that an action must be added to a | - |
230 | widget before it can be used; this is also true when the shortcut should | - |
231 | be global (i.e., Qt::ApplicationShortcut as Qt::ShortcutContext). | - |
232 | | - |
233 | Once a QAction has been created it should be added to the relevant | - |
234 | menu and toolbar, then connected to the slot which will perform | - |
235 | the action. For example: | - |
236 | | - |
237 | \snippet mainwindows/application/mainwindow.cpp 19 | - |
238 | \codeline | - |
239 | \snippet mainwindows/application/mainwindow.cpp 28 | - |
240 | \snippet mainwindows/application/mainwindow.cpp 31 | - |
241 | | - |
242 | We recommend that actions are created as children of the window | - |
243 | they are used in. In most cases actions will be children of | - |
244 | the application's main window. | - |
245 | | - |
246 | \sa QMenu, QToolBar, {Application Example} | - |
247 | */ | - |
248 | | - |
249 | /*! | - |
250 | \fn void QAction::trigger() | - |
251 | | - |
252 | This is a convenience slot that calls activate(Trigger). | - |
253 | */ | - |
254 | | - |
255 | /*! | - |
256 | \fn void QAction::hover() | - |
257 | | - |
258 | This is a convenience slot that calls activate(Hover). | - |
259 | */ | - |
260 | | - |
261 | /*! | - |
262 | \enum QAction::MenuRole | - |
263 | | - |
264 | This enum describes how an action should be moved into the application menu on Mac OS X. | - |
265 | | - |
266 | \value NoRole This action should not be put into the application menu | - |
267 | \value TextHeuristicRole This action should be put in the application menu based on the action's text | - |
268 | as described in the QMenuBar documentation. | - |
269 | \value ApplicationSpecificRole This action should be put in the application menu with an application specific role | - |
270 | \value AboutQtRole This action matches handles the "About Qt" menu item. | - |
271 | \value AboutRole This action should be placed where the "About" menu item is in the application menu. The text of | - |
272 | the menu item will be set to "About <application name>". The application name is fetched from the | - |
273 | \c{Info.plist} file in the application's bundle (See \l{Deploying an Application on Mac OS X}). | - |
274 | \value PreferencesRole This action should be placed where the "Preferences..." menu item is in the application menu. | - |
275 | \value QuitRole This action should be placed where the Quit menu item is in the application menu. | - |
276 | | - |
277 | Setting this value only has effect on items that are in the immediate menus | - |
278 | of the menubar, not the submenus of those menus. For example, if you have | - |
279 | File menu in your menubar and the File menu has a submenu, setting the | - |
280 | MenuRole for the actions in that submenu have no effect. They will never be moved. | - |
281 | */ | - |
282 | | - |
283 | /*! | - |
284 | Constructs an action with \a parent. If \a parent is an action | - |
285 | group the action will be automatically inserted into the group. | - |
286 | */ | - |
287 | QAction::QAction(QObject* parent) | - |
288 | : QObject(*(new QActionPrivate), parent) | - |
289 | { | - |
290 | Q_D(QAction); executed (the execution status of this line is deduced): QActionPrivate * const d = d_func(); | - |
291 | d->group = qobject_cast<QActionGroup *>(parent); executed (the execution status of this line is deduced): d->group = qobject_cast<QActionGroup *>(parent); | - |
292 | if (d->group) evaluated: d->group yes Evaluation Count:581 | yes Evaluation Count:1614 |
| 581-1614 |
293 | d->group->addAction(this); executed: d->group->addAction(this); Execution Count:581 | 581 |
294 | } executed: } Execution Count:2195 | 2195 |
295 | | - |
296 | | - |
297 | /*! | - |
298 | Constructs an action with some \a text and \a parent. If \a | - |
299 | parent is an action group the action will be automatically | - |
300 | inserted into the group. | - |
301 | | - |
302 | The action uses a stripped version of \a text (e.g. "\&Menu | - |
303 | Option..." becomes "Menu Option") as descriptive text for | - |
304 | tool buttons. You can override this by setting a specific | - |
305 | description with setText(). The same text will be used for | - |
306 | tooltips unless you specify a different text using | - |
307 | setToolTip(). | - |
308 | | - |
309 | */ | - |
310 | QAction::QAction(const QString &text, QObject* parent) | - |
311 | : QObject(*(new QActionPrivate), parent) | - |
312 | { | - |
313 | Q_D(QAction); executed (the execution status of this line is deduced): QActionPrivate * const d = d_func(); | - |
314 | d->text = text; executed (the execution status of this line is deduced): d->text = text; | - |
315 | d->group = qobject_cast<QActionGroup *>(parent); executed (the execution status of this line is deduced): d->group = qobject_cast<QActionGroup *>(parent); | - |
316 | if (d->group) evaluated: d->group yes Evaluation Count:2 | yes Evaluation Count:1382 |
| 2-1382 |
317 | d->group->addAction(this); executed: d->group->addAction(this); Execution Count:2 | 2 |
318 | } executed: } Execution Count:1384 | 1384 |
319 | | - |
320 | /*! | - |
321 | Constructs an action with an \a icon and some \a text and \a | - |
322 | parent. If \a parent is an action group the action will be | - |
323 | automatically inserted into the group. | - |
324 | | - |
325 | The action uses a stripped version of \a text (e.g. "\&Menu | - |
326 | Option..." becomes "Menu Option") as descriptive text for | - |
327 | tool buttons. You can override this by setting a specific | - |
328 | description with setText(). The same text will be used for | - |
329 | tooltips unless you specify a different text using | - |
330 | setToolTip(). | - |
331 | */ | - |
332 | QAction::QAction(const QIcon &icon, const QString &text, QObject* parent) | - |
333 | : QObject(*(new QActionPrivate), parent) | - |
334 | { | - |
335 | Q_D(QAction); executed (the execution status of this line is deduced): QActionPrivate * const d = d_func(); | - |
336 | d->icon = icon; executed (the execution status of this line is deduced): d->icon = icon; | - |
337 | d->text = text; executed (the execution status of this line is deduced): d->text = text; | - |
338 | d->group = qobject_cast<QActionGroup *>(parent); executed (the execution status of this line is deduced): d->group = qobject_cast<QActionGroup *>(parent); | - |
339 | if (d->group) partially evaluated: d->group no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
340 | d->group->addAction(this); never executed: d->group->addAction(this); | 0 |
341 | } executed: } Execution Count:2 | 2 |
342 | | - |
343 | /*! | - |
344 | \internal | - |
345 | */ | - |
346 | QAction::QAction(QActionPrivate &dd, QObject *parent) | - |
347 | : QObject(dd, parent) | - |
348 | { | - |
349 | Q_D(QAction); executed (the execution status of this line is deduced): QActionPrivate * const d = d_func(); | - |
350 | d->group = qobject_cast<QActionGroup *>(parent); executed (the execution status of this line is deduced): d->group = qobject_cast<QActionGroup *>(parent); | - |
351 | if (d->group) partially evaluated: d->group no Evaluation Count:0 | yes Evaluation Count:18 |
| 0-18 |
352 | d->group->addAction(this); never executed: d->group->addAction(this); | 0 |
353 | } executed: } Execution Count:18 | 18 |
354 | | - |
355 | /*! | - |
356 | Returns the parent widget. | - |
357 | */ | - |
358 | QWidget *QAction::parentWidget() const | - |
359 | { | - |
360 | QObject *ret = parent(); never executed (the execution status of this line is deduced): QObject *ret = parent(); | - |
361 | while (ret && !ret->isWidgetType()) never evaluated: ret never evaluated: !ret->isWidgetType() | 0 |
362 | ret = ret->parent(); never executed: ret = ret->parent(); | 0 |
363 | return (QWidget*)ret; never executed: return (QWidget*)ret; | 0 |
364 | } | - |
365 | | - |
366 | /*! | - |
367 | \since 4.2 | - |
368 | Returns a list of widgets this action has been added to. | - |
369 | | - |
370 | \sa QWidget::addAction(), associatedGraphicsWidgets() | - |
371 | */ | - |
372 | QList<QWidget *> QAction::associatedWidgets() const | - |
373 | { | - |
374 | Q_D(const QAction); executed (the execution status of this line is deduced): const QActionPrivate * const d = d_func(); | - |
375 | return d->widgets; executed: return d->widgets; Execution Count:6 | 6 |
376 | } | - |
377 | | - |
378 | #ifndef QT_NO_GRAPHICSVIEW | - |
379 | /*! | - |
380 | \since 4.5 | - |
381 | Returns a list of widgets this action has been added to. | - |
382 | | - |
383 | \sa QWidget::addAction(), associatedWidgets() | - |
384 | */ | - |
385 | QList<QGraphicsWidget *> QAction::associatedGraphicsWidgets() const | - |
386 | { | - |
387 | Q_D(const QAction); never executed (the execution status of this line is deduced): const QActionPrivate * const d = d_func(); | - |
388 | return d->graphicsWidgets; never executed: return d->graphicsWidgets; | 0 |
389 | } | - |
390 | #endif | - |
391 | | - |
392 | #ifndef QT_NO_SHORTCUT | - |
393 | /*! | - |
394 | \property QAction::shortcut | - |
395 | \brief the action's primary shortcut key | - |
396 | | - |
397 | Valid keycodes for this property can be found in \l Qt::Key and | - |
398 | \l Qt::Modifier. There is no default shortcut key. | - |
399 | */ | - |
400 | void QAction::setShortcut(const QKeySequence &shortcut) | - |
401 | { | - |
402 | QAPP_CHECK("setShortcut"); never executed: return; partially evaluated: !(static_cast<QApplication *>(QCoreApplication::instance())) no Evaluation Count:0 | yes Evaluation Count:1198 |
| 0-1198 |
403 | | - |
404 | Q_D(QAction); executed (the execution status of this line is deduced): QActionPrivate * const d = d_func(); | - |
405 | if (d->shortcut == shortcut) evaluated: d->shortcut == shortcut yes Evaluation Count:719 | yes Evaluation Count:479 |
| 479-719 |
406 | return; executed: return; Execution Count:719 | 719 |
407 | | - |
408 | d->shortcut = shortcut; executed (the execution status of this line is deduced): d->shortcut = shortcut; | - |
409 | d->redoGrab(qApp->d_func()->shortcutMap); executed (the execution status of this line is deduced): d->redoGrab((static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->shortcutMap); | - |
410 | d->sendDataChanged(); executed (the execution status of this line is deduced): d->sendDataChanged(); | - |
411 | } executed: } Execution Count:479 | 479 |
412 | | - |
413 | /*! | - |
414 | \since 4.2 | - |
415 | | - |
416 | Sets \a shortcuts as the list of shortcuts that trigger the | - |
417 | action. The first element of the list is the primary shortcut. | - |
418 | | - |
419 | \sa shortcut | - |
420 | */ | - |
421 | void QAction::setShortcuts(const QList<QKeySequence> &shortcuts) | - |
422 | { | - |
423 | Q_D(QAction); executed (the execution status of this line is deduced): QActionPrivate * const d = d_func(); | - |
424 | | - |
425 | QList <QKeySequence> listCopy = shortcuts; executed (the execution status of this line is deduced): QList <QKeySequence> listCopy = shortcuts; | - |
426 | | - |
427 | QKeySequence primary; executed (the execution status of this line is deduced): QKeySequence primary; | - |
428 | if (!listCopy.isEmpty()) evaluated: !listCopy.isEmpty() yes Evaluation Count:104 | yes Evaluation Count:1 |
| 1-104 |
429 | primary = listCopy.takeFirst(); executed: primary = listCopy.takeFirst(); Execution Count:104 | 104 |
430 | | - |
431 | if (d->shortcut == primary && d->alternateShortcuts == listCopy) partially evaluated: d->shortcut == primary no Evaluation Count:0 | yes Evaluation Count:105 |
never evaluated: d->alternateShortcuts == listCopy | 0-105 |
432 | return; | 0 |
433 | | - |
434 | QAPP_CHECK("setShortcuts"); never executed: return; partially evaluated: !(static_cast<QApplication *>(QCoreApplication::instance())) no Evaluation Count:0 | yes Evaluation Count:105 |
| 0-105 |
435 | | - |
436 | d->shortcut = primary; executed (the execution status of this line is deduced): d->shortcut = primary; | - |
437 | d->alternateShortcuts = listCopy; executed (the execution status of this line is deduced): d->alternateShortcuts = listCopy; | - |
438 | d->redoGrab(qApp->d_func()->shortcutMap); executed (the execution status of this line is deduced): d->redoGrab((static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->shortcutMap); | - |
439 | d->redoGrabAlternate(qApp->d_func()->shortcutMap); executed (the execution status of this line is deduced): d->redoGrabAlternate((static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->shortcutMap); | - |
440 | d->sendDataChanged(); executed (the execution status of this line is deduced): d->sendDataChanged(); | - |
441 | } executed: } Execution Count:105 | 105 |
442 | | - |
443 | /*! | - |
444 | \since 4.2 | - |
445 | | - |
446 | Sets a platform dependent list of shortcuts based on the \a key. | - |
447 | The result of calling this function will depend on the currently running platform. | - |
448 | Note that more than one shortcut can assigned by this action. | - |
449 | If only the primary shortcut is required, use setShortcut instead. | - |
450 | | - |
451 | \sa QKeySequence::keyBindings() | - |
452 | */ | - |
453 | void QAction::setShortcuts(QKeySequence::StandardKey key) | - |
454 | { | - |
455 | QList <QKeySequence> list = QKeySequence::keyBindings(key); executed (the execution status of this line is deduced): QList <QKeySequence> list = QKeySequence::keyBindings(key); | - |
456 | setShortcuts(list); executed (the execution status of this line is deduced): setShortcuts(list); | - |
457 | } executed: } Execution Count:103 | 103 |
458 | | - |
459 | /*! | - |
460 | Returns the primary shortcut. | - |
461 | | - |
462 | \sa setShortcuts() | - |
463 | */ | - |
464 | QKeySequence QAction::shortcut() const | - |
465 | { | - |
466 | Q_D(const QAction); executed (the execution status of this line is deduced): const QActionPrivate * const d = d_func(); | - |
467 | return d->shortcut; executed: return d->shortcut; Execution Count:3824 | 3824 |
468 | } | - |
469 | | - |
470 | /*! | - |
471 | \since 4.2 | - |
472 | | - |
473 | Returns the list of shortcuts, with the primary shortcut as | - |
474 | the first element of the list. | - |
475 | | - |
476 | \sa setShortcuts() | - |
477 | */ | - |
478 | QList<QKeySequence> QAction::shortcuts() const | - |
479 | { | - |
480 | Q_D(const QAction); executed (the execution status of this line is deduced): const QActionPrivate * const d = d_func(); | - |
481 | QList <QKeySequence> shortcuts; executed (the execution status of this line is deduced): QList <QKeySequence> shortcuts; | - |
482 | if (!d->shortcut.isEmpty()) partially evaluated: !d->shortcut.isEmpty() yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
483 | shortcuts << d->shortcut; executed: shortcuts << d->shortcut; Execution Count:2 | 2 |
484 | if (!d->alternateShortcuts.isEmpty()) partially evaluated: !d->alternateShortcuts.isEmpty() yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
485 | shortcuts << d->alternateShortcuts; executed: shortcuts << d->alternateShortcuts; Execution Count:2 | 2 |
486 | return shortcuts; executed: return shortcuts; Execution Count:2 | 2 |
487 | } | - |
488 | | - |
489 | /*! | - |
490 | \property QAction::shortcutContext | - |
491 | \brief the context for the action's shortcut | - |
492 | | - |
493 | Valid values for this property can be found in \l Qt::ShortcutContext. | - |
494 | The default value is Qt::WindowShortcut. | - |
495 | */ | - |
496 | void QAction::setShortcutContext(Qt::ShortcutContext context) | - |
497 | { | - |
498 | Q_D(QAction); never executed (the execution status of this line is deduced): QActionPrivate * const d = d_func(); | - |
499 | if (d->shortcutContext == context) never evaluated: d->shortcutContext == context | 0 |
500 | return; | 0 |
501 | QAPP_CHECK("setShortcutContext"); never executed: return; never evaluated: !(static_cast<QApplication *>(QCoreApplication::instance())) | 0 |
502 | d->shortcutContext = context; never executed (the execution status of this line is deduced): d->shortcutContext = context; | - |
503 | d->redoGrab(qApp->d_func()->shortcutMap); never executed (the execution status of this line is deduced): d->redoGrab((static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->shortcutMap); | - |
504 | d->redoGrabAlternate(qApp->d_func()->shortcutMap); never executed (the execution status of this line is deduced): d->redoGrabAlternate((static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->shortcutMap); | - |
505 | d->sendDataChanged(); never executed (the execution status of this line is deduced): d->sendDataChanged(); | - |
506 | } | 0 |
507 | | - |
508 | Qt::ShortcutContext QAction::shortcutContext() const | - |
509 | { | - |
510 | Q_D(const QAction); never executed (the execution status of this line is deduced): const QActionPrivate * const d = d_func(); | - |
511 | return d->shortcutContext; never executed: return d->shortcutContext; | 0 |
512 | } | - |
513 | | - |
514 | /*! | - |
515 | \property QAction::autoRepeat | - |
516 | \brief whether the action can auto repeat | - |
517 | \since 4.2 | - |
518 | | - |
519 | If true, the action will auto repeat when the keyboard shortcut | - |
520 | combination is held down, provided that keyboard auto repeat is | - |
521 | enabled on the system. | - |
522 | The default value is true. | - |
523 | */ | - |
524 | void QAction::setAutoRepeat(bool on) | - |
525 | { | - |
526 | Q_D(QAction); executed (the execution status of this line is deduced): QActionPrivate * const d = d_func(); | - |
527 | if (d->autorepeat == on) evaluated: d->autorepeat == on yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1 |
528 | return; executed: return; Execution Count:1 | 1 |
529 | QAPP_CHECK("setAutoRepeat"); never executed: return; partially evaluated: !(static_cast<QApplication *>(QCoreApplication::instance())) no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
530 | d->autorepeat = on; executed (the execution status of this line is deduced): d->autorepeat = on; | - |
531 | d->redoGrab(qApp->d_func()->shortcutMap); executed (the execution status of this line is deduced): d->redoGrab((static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->shortcutMap); | - |
532 | d->redoGrabAlternate(qApp->d_func()->shortcutMap); executed (the execution status of this line is deduced): d->redoGrabAlternate((static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->shortcutMap); | - |
533 | d->sendDataChanged(); executed (the execution status of this line is deduced): d->sendDataChanged(); | - |
534 | } executed: } Execution Count:1 | 1 |
535 | | - |
536 | bool QAction::autoRepeat() const | - |
537 | { | - |
538 | Q_D(const QAction); never executed (the execution status of this line is deduced): const QActionPrivate * const d = d_func(); | - |
539 | return d->autorepeat; never executed: return d->autorepeat; | 0 |
540 | } | - |
541 | #endif // QT_NO_SHORTCUT | - |
542 | | - |
543 | /*! | - |
544 | \property QAction::font | - |
545 | \brief the action's font | - |
546 | | - |
547 | The font property is used to render the text set on the | - |
548 | QAction. The font will can be considered a hint as it will not be | - |
549 | consulted in all cases based upon application and style. | - |
550 | | - |
551 | By default, this property contains the application's default font. | - |
552 | | - |
553 | \sa QAction::setText(), QStyle | - |
554 | */ | - |
555 | void QAction::setFont(const QFont &font) | - |
556 | { | - |
557 | Q_D(QAction); executed (the execution status of this line is deduced): QActionPrivate * const d = d_func(); | - |
558 | if (d->font == font) partially evaluated: d->font == font no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
559 | return; | 0 |
560 | | - |
561 | d->fontSet = true; executed (the execution status of this line is deduced): d->fontSet = true; | - |
562 | d->font = font; executed (the execution status of this line is deduced): d->font = font; | - |
563 | d->sendDataChanged(); executed (the execution status of this line is deduced): d->sendDataChanged(); | - |
564 | } executed: } Execution Count:1 | 1 |
565 | | - |
566 | QFont QAction::font() const | - |
567 | { | - |
568 | Q_D(const QAction); executed (the execution status of this line is deduced): const QActionPrivate * const d = d_func(); | - |
569 | return d->font; executed: return d->font; Execution Count:2008 | 2008 |
570 | } | - |
571 | | - |
572 | | - |
573 | /*! | - |
574 | Destroys the object and frees allocated resources. | - |
575 | */ | - |
576 | QAction::~QAction() | - |
577 | { | - |
578 | Q_D(QAction); executed (the execution status of this line is deduced): QActionPrivate * const d = d_func(); | - |
579 | for (int i = d->widgets.size()-1; i >= 0; --i) { evaluated: i >= 0 yes Evaluation Count:62 | yes Evaluation Count:3587 |
| 62-3587 |
580 | QWidget *w = d->widgets.at(i); executed (the execution status of this line is deduced): QWidget *w = d->widgets.at(i); | - |
581 | w->removeAction(this); executed (the execution status of this line is deduced): w->removeAction(this); | - |
582 | } executed: } Execution Count:62 | 62 |
583 | #ifndef QT_NO_GRAPHICSVIEW | - |
584 | for (int i = d->graphicsWidgets.size()-1; i >= 0; --i) { partially evaluated: i >= 0 no Evaluation Count:0 | yes Evaluation Count:3587 |
| 0-3587 |
585 | QGraphicsWidget *w = d->graphicsWidgets.at(i); never executed (the execution status of this line is deduced): QGraphicsWidget *w = d->graphicsWidgets.at(i); | - |
586 | w->removeAction(this); never executed (the execution status of this line is deduced): w->removeAction(this); | - |
587 | } | 0 |
588 | #endif | - |
589 | if (d->group) evaluated: d->group yes Evaluation Count:4 | yes Evaluation Count:3583 |
| 4-3583 |
590 | d->group->removeAction(this); executed: d->group->removeAction(this); Execution Count:4 | 4 |
591 | #ifndef QT_NO_SHORTCUT | - |
592 | if (d->shortcutId && qApp) { evaluated: d->shortcutId yes Evaluation Count:576 | yes Evaluation Count:3011 |
partially evaluated: (static_cast<QApplication *>(QCoreApplication::instance())) yes Evaluation Count:576 | no Evaluation Count:0 |
| 0-3011 |
593 | qApp->d_func()->shortcutMap.removeShortcut(d->shortcutId, this); executed (the execution status of this line is deduced): (static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->shortcutMap.removeShortcut(d->shortcutId, this); | - |
594 | for(int i = 0; i < d->alternateShortcutIds.count(); ++i) { evaluated: i < d->alternateShortcutIds.count() yes Evaluation Count:3 | yes Evaluation Count:576 |
| 3-576 |
595 | const int id = d->alternateShortcutIds.at(i); executed (the execution status of this line is deduced): const int id = d->alternateShortcutIds.at(i); | - |
596 | qApp->d_func()->shortcutMap.removeShortcut(id, this); executed (the execution status of this line is deduced): (static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->shortcutMap.removeShortcut(id, this); | - |
597 | } executed: } Execution Count:3 | 3 |
598 | } executed: } Execution Count:576 | 576 |
599 | #endif | - |
600 | } executed: } Execution Count:3587 | 3587 |
601 | | - |
602 | /*! | - |
603 | Sets this action group to \a group. The action will be automatically | - |
604 | added to the group's list of actions. | - |
605 | | - |
606 | Actions within the group will be mutually exclusive. | - |
607 | | - |
608 | \sa QActionGroup, QAction::actionGroup() | - |
609 | */ | - |
610 | void QAction::setActionGroup(QActionGroup *group) | - |
611 | { | - |
612 | Q_D(QAction); executed (the execution status of this line is deduced): QActionPrivate * const d = d_func(); | - |
613 | if(group == d->group) partially evaluated: group == d->group no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
614 | return; | 0 |
615 | | - |
616 | if(d->group) evaluated: d->group yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1 |
617 | d->group->removeAction(this); executed: d->group->removeAction(this); Execution Count:1 | 1 |
618 | d->group = group; executed (the execution status of this line is deduced): d->group = group; | - |
619 | if(group) evaluated: group yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1 |
620 | group->addAction(this); executed: group->addAction(this); Execution Count:1 | 1 |
621 | } executed: } Execution Count:2 | 2 |
622 | | - |
623 | /*! | - |
624 | Returns the action group for this action. If no action group manages | - |
625 | this action then 0 will be returned. | - |
626 | | - |
627 | \sa QActionGroup, QAction::setActionGroup() | - |
628 | */ | - |
629 | QActionGroup *QAction::actionGroup() const | - |
630 | { | - |
631 | Q_D(const QAction); executed (the execution status of this line is deduced): const QActionPrivate * const d = d_func(); | - |
632 | return d->group; executed: return d->group; Execution Count:23 | 23 |
633 | } | - |
634 | | - |
635 | | - |
636 | /*! | - |
637 | \property QAction::icon | - |
638 | \brief the action's icon | - |
639 | | - |
640 | In toolbars, the icon is used as the tool button icon; in menus, | - |
641 | it is displayed to the left of the menu text. There is no default | - |
642 | icon. | - |
643 | | - |
644 | If a null icon (QIcon::isNull() is passed into this function, | - |
645 | the icon of the action is cleared. | - |
646 | */ | - |
647 | void QAction::setIcon(const QIcon &icon) | - |
648 | { | - |
649 | Q_D(QAction); executed (the execution status of this line is deduced): QActionPrivate * const d = d_func(); | - |
650 | d->icon = icon; executed (the execution status of this line is deduced): d->icon = icon; | - |
651 | d->sendDataChanged(); executed (the execution status of this line is deduced): d->sendDataChanged(); | - |
652 | } executed: } Execution Count:408 | 408 |
653 | | - |
654 | QIcon QAction::icon() const | - |
655 | { | - |
656 | Q_D(const QAction); executed (the execution status of this line is deduced): const QActionPrivate * const d = d_func(); | - |
657 | return d->icon; executed: return d->icon; Execution Count:6458 | 6458 |
658 | } | - |
659 | | - |
660 | #ifndef QT_NO_MENU | - |
661 | /*! | - |
662 | Returns the menu contained by this action. Actions that contain | - |
663 | menus can be used to create menu items with submenus, or inserted | - |
664 | into toolbars to create buttons with popup menus. | - |
665 | | - |
666 | \sa QMenu::addAction() | - |
667 | */ | - |
668 | QMenu *QAction::menu() const | - |
669 | { | - |
670 | Q_D(const QAction); executed (the execution status of this line is deduced): const QActionPrivate * const d = d_func(); | - |
671 | return d->menu; executed: return d->menu; Execution Count:4595 | 4595 |
672 | } | - |
673 | | - |
674 | /*! | - |
675 | Sets the menu contained by this action to the specified \a menu. | - |
676 | */ | - |
677 | void QAction::setMenu(QMenu *menu) | - |
678 | { | - |
679 | Q_D(QAction); executed (the execution status of this line is deduced): QActionPrivate * const d = d_func(); | - |
680 | if (d->menu) evaluated: d->menu yes Evaluation Count:1 | yes Evaluation Count:3 |
| 1-3 |
681 | d->menu->d_func()->setOverrideMenuAction(0); //we reset the default action of any previous menu executed: d->menu->d_func()->setOverrideMenuAction(0); Execution Count:1 | 1 |
682 | d->menu = menu; executed (the execution status of this line is deduced): d->menu = menu; | - |
683 | if (menu) evaluated: menu yes Evaluation Count:3 | yes Evaluation Count:1 |
| 1-3 |
684 | menu->d_func()->setOverrideMenuAction(this); executed: menu->d_func()->setOverrideMenuAction(this); Execution Count:3 | 3 |
685 | d->sendDataChanged(); executed (the execution status of this line is deduced): d->sendDataChanged(); | - |
686 | } executed: } Execution Count:4 | 4 |
687 | #endif // QT_NO_MENU | - |
688 | | - |
689 | /*! | - |
690 | If \a b is true then this action will be considered a separator. | - |
691 | | - |
692 | How a separator is represented depends on the widget it is inserted | - |
693 | into. Under most circumstances the text, submenu, and icon will be | - |
694 | ignored for separator actions. | - |
695 | | - |
696 | \sa QAction::isSeparator() | - |
697 | */ | - |
698 | void QAction::setSeparator(bool b) | - |
699 | { | - |
700 | Q_D(QAction); executed (the execution status of this line is deduced): QActionPrivate * const d = d_func(); | - |
701 | if (d->separator == b) partially evaluated: d->separator == b no Evaluation Count:0 | yes Evaluation Count:127 |
| 0-127 |
702 | return; | 0 |
703 | | - |
704 | d->separator = b; executed (the execution status of this line is deduced): d->separator = b; | - |
705 | d->sendDataChanged(); executed (the execution status of this line is deduced): d->sendDataChanged(); | - |
706 | } executed: } Execution Count:127 | 127 |
707 | | - |
708 | /*! | - |
709 | Returns true if this action is a separator action; otherwise it | - |
710 | returns false. | - |
711 | | - |
712 | \sa QAction::setSeparator() | - |
713 | */ | - |
714 | bool QAction::isSeparator() const | - |
715 | { | - |
716 | Q_D(const QAction); executed (the execution status of this line is deduced): const QActionPrivate * const d = d_func(); | - |
717 | return d->separator; executed: return d->separator; Execution Count:8722 | 8722 |
718 | } | - |
719 | | - |
720 | /*! | - |
721 | \property QAction::text | - |
722 | \brief the action's descriptive text | - |
723 | | - |
724 | If the action is added to a menu, the menu option will consist of | - |
725 | the icon (if there is one), the text, and the shortcut (if there | - |
726 | is one). If the text is not explicitly set in the constructor, or | - |
727 | by using setText(), the action's description icon text will be | - |
728 | used as text. There is no default text. | - |
729 | | - |
730 | \sa iconText | - |
731 | */ | - |
732 | void QAction::setText(const QString &text) | - |
733 | { | - |
734 | Q_D(QAction); executed (the execution status of this line is deduced): QActionPrivate * const d = d_func(); | - |
735 | if (d->text == text) evaluated: d->text == text yes Evaluation Count:130 | yes Evaluation Count:1578 |
| 130-1578 |
736 | return; executed: return; Execution Count:130 | 130 |
737 | | - |
738 | d->text = text; executed (the execution status of this line is deduced): d->text = text; | - |
739 | d->sendDataChanged(); executed (the execution status of this line is deduced): d->sendDataChanged(); | - |
740 | } executed: } Execution Count:1578 | 1578 |
741 | | - |
742 | QString QAction::text() const | - |
743 | { | - |
744 | Q_D(const QAction); executed (the execution status of this line is deduced): const QActionPrivate * const d = d_func(); | - |
745 | QString s = d->text; executed (the execution status of this line is deduced): QString s = d->text; | - |
746 | if(s.isEmpty()) { evaluated: s.isEmpty() yes Evaluation Count:213 | yes Evaluation Count:4947 |
| 213-4947 |
747 | s = d->iconText; executed (the execution status of this line is deduced): s = d->iconText; | - |
748 | s.replace(QLatin1Char('&'), QLatin1String("&&")); executed (the execution status of this line is deduced): s.replace(QLatin1Char('&'), QLatin1String("&&")); | - |
749 | } executed: } Execution Count:213 | 213 |
750 | return s; executed: return s; Execution Count:5160 | 5160 |
751 | } | - |
752 | | - |
753 | | - |
754 | | - |
755 | | - |
756 | | - |
757 | /*! | - |
758 | \property QAction::iconText | - |
759 | \brief the action's descriptive icon text | - |
760 | | - |
761 | If QToolBar::toolButtonStyle is set to a value that permits text to | - |
762 | be displayed, the text defined held in this property appears as a | - |
763 | label in the relevant tool button. | - |
764 | | - |
765 | It also serves as the default text in menus and tooltips if the action | - |
766 | has not been defined with setText() or setToolTip(), and will | - |
767 | also be used in toolbar buttons if no icon has been defined using setIcon(). | - |
768 | | - |
769 | If the icon text is not explicitly set, the action's normal text will be | - |
770 | used for the icon text. | - |
771 | | - |
772 | By default, this property contains an empty string. | - |
773 | | - |
774 | \sa setToolTip(), setStatusTip() | - |
775 | */ | - |
776 | void QAction::setIconText(const QString &text) | - |
777 | { | - |
778 | Q_D(QAction); executed (the execution status of this line is deduced): QActionPrivate * const d = d_func(); | - |
779 | if (d->iconText == text) partially evaluated: d->iconText == text no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-3 |
780 | return; | 0 |
781 | | - |
782 | d->iconText = text; executed (the execution status of this line is deduced): d->iconText = text; | - |
783 | d->sendDataChanged(); executed (the execution status of this line is deduced): d->sendDataChanged(); | - |
784 | } executed: } Execution Count:3 | 3 |
785 | | - |
786 | QString QAction::iconText() const | - |
787 | { | - |
788 | Q_D(const QAction); executed (the execution status of this line is deduced): const QActionPrivate * const d = d_func(); | - |
789 | if (d->iconText.isEmpty()) evaluated: d->iconText.isEmpty() yes Evaluation Count:21 | yes Evaluation Count:3 |
| 3-21 |
790 | return qt_strippedText(d->text); executed: return qt_strippedText(d->text); Execution Count:21 | 21 |
791 | return d->iconText; executed: return d->iconText; Execution Count:3 | 3 |
792 | } | - |
793 | | - |
794 | /*! | - |
795 | \property QAction::toolTip | - |
796 | \brief the action's tooltip | - |
797 | | - |
798 | This text is used for the tooltip. If no tooltip is specified, | - |
799 | the action's text is used. | - |
800 | | - |
801 | By default, this property contains the action's text. | - |
802 | | - |
803 | \sa setStatusTip(), setShortcut() | - |
804 | */ | - |
805 | void QAction::setToolTip(const QString &tooltip) | - |
806 | { | - |
807 | Q_D(QAction); executed (the execution status of this line is deduced): QActionPrivate * const d = d_func(); | - |
808 | if (d->tooltip == tooltip) partially evaluated: d->tooltip == tooltip no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
809 | return; | 0 |
810 | | - |
811 | d->tooltip = tooltip; executed (the execution status of this line is deduced): d->tooltip = tooltip; | - |
812 | d->sendDataChanged(); executed (the execution status of this line is deduced): d->sendDataChanged(); | - |
813 | } executed: } Execution Count:1 | 1 |
814 | | - |
815 | QString QAction::toolTip() const | - |
816 | { | - |
817 | Q_D(const QAction); executed (the execution status of this line is deduced): const QActionPrivate * const d = d_func(); | - |
818 | if (d->tooltip.isEmpty()) { evaluated: d->tooltip.isEmpty() yes Evaluation Count:18 | yes Evaluation Count:1 |
| 1-18 |
819 | if (!d->text.isEmpty()) evaluated: !d->text.isEmpty() yes Evaluation Count:14 | yes Evaluation Count:4 |
| 4-14 |
820 | return qt_strippedText(d->text); executed: return qt_strippedText(d->text); Execution Count:14 | 14 |
821 | return qt_strippedText(d->iconText); executed: return qt_strippedText(d->iconText); Execution Count:4 | 4 |
822 | } | - |
823 | return d->tooltip; executed: return d->tooltip; Execution Count:1 | 1 |
824 | } | - |
825 | | - |
826 | /*! | - |
827 | \property QAction::statusTip | - |
828 | \brief the action's status tip | - |
829 | | - |
830 | The status tip is displayed on all status bars provided by the | - |
831 | action's top-level parent widget. | - |
832 | | - |
833 | By default, this property contains an empty string. | - |
834 | | - |
835 | \sa setToolTip(), showStatusText() | - |
836 | */ | - |
837 | void QAction::setStatusTip(const QString &statustip) | - |
838 | { | - |
839 | Q_D(QAction); executed (the execution status of this line is deduced): QActionPrivate * const d = d_func(); | - |
840 | if (d->statustip == statustip) partially evaluated: d->statustip == statustip no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
841 | return; | 0 |
842 | | - |
843 | d->statustip = statustip; executed (the execution status of this line is deduced): d->statustip = statustip; | - |
844 | d->sendDataChanged(); executed (the execution status of this line is deduced): d->sendDataChanged(); | - |
845 | } executed: } Execution Count:2 | 2 |
846 | | - |
847 | QString QAction::statusTip() const | - |
848 | { | - |
849 | Q_D(const QAction); executed (the execution status of this line is deduced): const QActionPrivate * const d = d_func(); | - |
850 | return d->statustip; executed: return d->statustip; Execution Count:111 | 111 |
851 | } | - |
852 | | - |
853 | /*! | - |
854 | \property QAction::whatsThis | - |
855 | \brief the action's "What's This?" help text | - |
856 | | - |
857 | The "What's This?" text is used to provide a brief description of | - |
858 | the action. The text may contain rich text. There is no default | - |
859 | "What's This?" text. | - |
860 | | - |
861 | \sa QWhatsThis | - |
862 | */ | - |
863 | void QAction::setWhatsThis(const QString &whatsthis) | - |
864 | { | - |
865 | Q_D(QAction); never executed (the execution status of this line is deduced): QActionPrivate * const d = d_func(); | - |
866 | if (d->whatsthis == whatsthis) never evaluated: d->whatsthis == whatsthis | 0 |
867 | return; | 0 |
868 | | - |
869 | d->whatsthis = whatsthis; never executed (the execution status of this line is deduced): d->whatsthis = whatsthis; | - |
870 | d->sendDataChanged(); never executed (the execution status of this line is deduced): d->sendDataChanged(); | - |
871 | } | 0 |
872 | | - |
873 | QString QAction::whatsThis() const | - |
874 | { | - |
875 | Q_D(const QAction); executed (the execution status of this line is deduced): const QActionPrivate * const d = d_func(); | - |
876 | return d->whatsthis; executed: return d->whatsthis; Execution Count:18 | 18 |
877 | } | - |
878 | | - |
879 | /*! | - |
880 | \enum QAction::Priority | - |
881 | \since 4.6 | - |
882 | | - |
883 | This enum defines priorities for actions in user interface. | - |
884 | | - |
885 | \value LowPriority The action should not be prioritized in | - |
886 | the user interface. | - |
887 | | - |
888 | \value NormalPriority | - |
889 | | - |
890 | \value HighPriority The action should be prioritized in | - |
891 | the user interface. | - |
892 | | - |
893 | \sa priority | - |
894 | */ | - |
895 | | - |
896 | | - |
897 | /*! | - |
898 | \property QAction::priority | - |
899 | \since 4.6 | - |
900 | | - |
901 | \brief the actions's priority in the user interface. | - |
902 | | - |
903 | This property can be set to indicate how the action should be prioritized | - |
904 | in the user interface. | - |
905 | | - |
906 | For instance, when toolbars have the Qt::ToolButtonTextBesideIcon | - |
907 | mode set, then actions with LowPriority will not show the text | - |
908 | labels. | - |
909 | */ | - |
910 | void QAction::setPriority(Priority priority) | - |
911 | { | - |
912 | Q_D(QAction); executed (the execution status of this line is deduced): QActionPrivate * const d = d_func(); | - |
913 | if (d->priority == priority) partially evaluated: d->priority == priority no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
914 | return; | 0 |
915 | | - |
916 | d->priority = priority; executed (the execution status of this line is deduced): d->priority = priority; | - |
917 | d->sendDataChanged(); executed (the execution status of this line is deduced): d->sendDataChanged(); | - |
918 | } executed: } Execution Count:2 | 2 |
919 | | - |
920 | QAction::Priority QAction::priority() const | - |
921 | { | - |
922 | Q_D(const QAction); executed (the execution status of this line is deduced): const QActionPrivate * const d = d_func(); | - |
923 | return d->priority; executed: return d->priority; Execution Count:4 | 4 |
924 | } | - |
925 | | - |
926 | /*! | - |
927 | \property QAction::checkable | - |
928 | \brief whether the action is a checkable action | - |
929 | | - |
930 | A checkable action is one which has an on/off state. For example, | - |
931 | in a word processor, a Bold toolbar button may be either on or | - |
932 | off. An action which is not a toggle action is a command action; | - |
933 | a command action is simply executed, e.g. file save. | - |
934 | By default, this property is false. | - |
935 | | - |
936 | In some situations, the state of one toggle action should depend | - |
937 | on the state of others. For example, "Left Align", "Center" and | - |
938 | "Right Align" toggle actions are mutually exclusive. To achieve | - |
939 | exclusive toggling, add the relevant toggle actions to a | - |
940 | QActionGroup with the QActionGroup::exclusive property set to | - |
941 | true. | - |
942 | | - |
943 | \sa QAction::setChecked() | - |
944 | */ | - |
945 | void QAction::setCheckable(bool b) | - |
946 | { | - |
947 | Q_D(QAction); executed (the execution status of this line is deduced): QActionPrivate * const d = d_func(); | - |
948 | if (d->checkable == b) partially evaluated: d->checkable == b no Evaluation Count:0 | yes Evaluation Count:912 |
| 0-912 |
949 | return; | 0 |
950 | | - |
951 | d->checkable = b; executed (the execution status of this line is deduced): d->checkable = b; | - |
952 | d->checked = false; executed (the execution status of this line is deduced): d->checked = false; | - |
953 | d->sendDataChanged(); executed (the execution status of this line is deduced): d->sendDataChanged(); | - |
954 | } executed: } Execution Count:912 | 912 |
955 | | - |
956 | bool QAction::isCheckable() const | - |
957 | { | - |
958 | Q_D(const QAction); executed (the execution status of this line is deduced): const QActionPrivate * const d = d_func(); | - |
959 | return d->checkable; executed: return d->checkable; Execution Count:3891 | 3891 |
960 | } | - |
961 | | - |
962 | /*! | - |
963 | \fn void QAction::toggle() | - |
964 | | - |
965 | This is a convenience function for the \l checked property. | - |
966 | Connect to it to change the checked state to its opposite state. | - |
967 | */ | - |
968 | void QAction::toggle() | - |
969 | { | - |
970 | Q_D(QAction); never executed (the execution status of this line is deduced): QActionPrivate * const d = d_func(); | - |
971 | setChecked(!d->checked); never executed (the execution status of this line is deduced): setChecked(!d->checked); | - |
972 | } | 0 |
973 | | - |
974 | /*! | - |
975 | \property QAction::checked | - |
976 | \brief whether the action is checked. | - |
977 | | - |
978 | Only checkable actions can be checked. By default, this is false | - |
979 | (the action is unchecked). | - |
980 | | - |
981 | \sa checkable | - |
982 | */ | - |
983 | void QAction::setChecked(bool b) | - |
984 | { | - |
985 | Q_D(QAction); executed (the execution status of this line is deduced): QActionPrivate * const d = d_func(); | - |
986 | if (!d->checkable || d->checked == b) partially evaluated: !d->checkable no Evaluation Count:0 | yes Evaluation Count:1099 |
evaluated: d->checked == b yes Evaluation Count:451 | yes Evaluation Count:648 |
| 0-1099 |
987 | return; executed: return; Execution Count:451 | 451 |
988 | | - |
989 | QPointer<QAction> guard(this); executed (the execution status of this line is deduced): QPointer<QAction> guard(this); | - |
990 | d->checked = b; executed (the execution status of this line is deduced): d->checked = b; | - |
991 | d->sendDataChanged(); executed (the execution status of this line is deduced): d->sendDataChanged(); | - |
992 | if (guard) partially evaluated: guard yes Evaluation Count:648 | no Evaluation Count:0 |
| 0-648 |
993 | emit toggled(b); executed: toggled(b); Execution Count:648 | 648 |
994 | } executed: } Execution Count:648 | 648 |
995 | | - |
996 | bool QAction::isChecked() const | - |
997 | { | - |
998 | Q_D(const QAction); executed (the execution status of this line is deduced): const QActionPrivate * const d = d_func(); | - |
999 | return d->checked; executed: return d->checked; Execution Count:687 | 687 |
1000 | } | - |
1001 | | - |
1002 | /*! | - |
1003 | \fn void QAction::setDisabled(bool b) | - |
1004 | | - |
1005 | This is a convenience function for the \l enabled property, that | - |
1006 | is useful for signals--slots connections. If \a b is true the | - |
1007 | action is disabled; otherwise it is enabled. | - |
1008 | */ | - |
1009 | | - |
1010 | /*! | - |
1011 | \property QAction::enabled | - |
1012 | \brief whether the action is enabled | - |
1013 | | - |
1014 | Disabled actions cannot be chosen by the user. They do not | - |
1015 | disappear from menus or toolbars, but they are displayed in a way | - |
1016 | which indicates that they are unavailable. For example, they might | - |
1017 | be displayed using only shades of gray. | - |
1018 | | - |
1019 | \uicontrol{What's This?} help on disabled actions is still available, provided | - |
1020 | that the QAction::whatsThis property is set. | - |
1021 | | - |
1022 | An action will be disabled when all widgets to which it is added | - |
1023 | (with QWidget::addAction()) are disabled or not visible. When an | - |
1024 | action is disabled, it is not possible to trigger it through its | - |
1025 | shortcut. | - |
1026 | | - |
1027 | By default, this property is true (actions are enabled). | - |
1028 | | - |
1029 | \sa text | - |
1030 | */ | - |
1031 | void QAction::setEnabled(bool b) | - |
1032 | { | - |
1033 | Q_D(QAction); executed (the execution status of this line is deduced): QActionPrivate * const d = d_func(); | - |
1034 | if (b == d->enabled && b != d->forceDisabled) evaluated: b == d->enabled yes Evaluation Count:8490 | yes Evaluation Count:1312 |
evaluated: b != d->forceDisabled yes Evaluation Count:8489 | yes Evaluation Count:1 |
| 1-8490 |
1035 | return; executed: return; Execution Count:8489 | 8489 |
1036 | d->forceDisabled = !b; executed (the execution status of this line is deduced): d->forceDisabled = !b; | - |
1037 | if (b && (!d->visible || (d->group && !d->group->isEnabled()))) evaluated: b yes Evaluation Count:369 | yes Evaluation Count:944 |
evaluated: !d->visible yes Evaluation Count:2 | yes Evaluation Count:367 |
evaluated: d->group yes Evaluation Count:4 | yes Evaluation Count:363 |
evaluated: !d->group->isEnabled() yes Evaluation Count:1 | yes Evaluation Count:3 |
| 1-944 |
1038 | return; executed: return; Execution Count:3 | 3 |
1039 | QAPP_CHECK("setEnabled"); never executed: return; partially evaluated: !(static_cast<QApplication *>(QCoreApplication::instance())) no Evaluation Count:0 | yes Evaluation Count:1310 |
| 0-1310 |
1040 | d->enabled = b; executed (the execution status of this line is deduced): d->enabled = b; | - |
1041 | #ifndef QT_NO_SHORTCUT | - |
1042 | d->setShortcutEnabled(b, qApp->d_func()->shortcutMap); executed (the execution status of this line is deduced): d->setShortcutEnabled(b, (static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->shortcutMap); | - |
1043 | #endif | - |
1044 | d->sendDataChanged(); executed (the execution status of this line is deduced): d->sendDataChanged(); | - |
1045 | } executed: } Execution Count:1310 | 1310 |
1046 | | - |
1047 | bool QAction::isEnabled() const | - |
1048 | { | - |
1049 | Q_D(const QAction); executed (the execution status of this line is deduced): const QActionPrivate * const d = d_func(); | - |
1050 | return d->enabled; executed: return d->enabled; Execution Count:2773 | 2773 |
1051 | } | - |
1052 | | - |
1053 | /*! | - |
1054 | \property QAction::visible | - |
1055 | \brief whether the action can be seen (e.g. in menus and toolbars) | - |
1056 | | - |
1057 | If \e visible is true the action can be seen (e.g. in menus and | - |
1058 | toolbars) and chosen by the user; if \e visible is false the | - |
1059 | action cannot be seen or chosen by the user. | - |
1060 | | - |
1061 | Actions which are not visible are \e not grayed out; they do not | - |
1062 | appear at all. | - |
1063 | | - |
1064 | By default, this property is true (actions are visible). | - |
1065 | */ | - |
1066 | void QAction::setVisible(bool b) | - |
1067 | { | - |
1068 | Q_D(QAction); executed (the execution status of this line is deduced): QActionPrivate * const d = d_func(); | - |
1069 | if (b == d->visible && b != d->forceInvisible) evaluated: b == d->visible yes Evaluation Count:612 | yes Evaluation Count:4033 |
evaluated: b != d->forceInvisible yes Evaluation Count:611 | yes Evaluation Count:1 |
| 1-4033 |
1070 | return; executed: return; Execution Count:611 | 611 |
1071 | QAPP_CHECK("setVisible"); never executed: return; partially evaluated: !(static_cast<QApplication *>(QCoreApplication::instance())) no Evaluation Count:0 | yes Evaluation Count:4034 |
| 0-4034 |
1072 | d->forceInvisible = !b; executed (the execution status of this line is deduced): d->forceInvisible = !b; | - |
1073 | d->visible = b; executed (the execution status of this line is deduced): d->visible = b; | - |
1074 | d->enabled = b && !d->forceDisabled && (!d->group || d->group->isEnabled()) ; evaluated: b yes Evaluation Count:2007 | yes Evaluation Count:2027 |
evaluated: !d->forceDisabled yes Evaluation Count:1722 | yes Evaluation Count:285 |
evaluated: !d->group yes Evaluation Count:1719 | yes Evaluation Count:3 |
partially evaluated: d->group->isEnabled() yes Evaluation Count:3 | no Evaluation Count:0 |
| 0-2027 |
1075 | #ifndef QT_NO_SHORTCUT | - |
1076 | d->setShortcutEnabled(d->enabled, qApp->d_func()->shortcutMap); executed (the execution status of this line is deduced): d->setShortcutEnabled(d->enabled, (static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->shortcutMap); | - |
1077 | #endif | - |
1078 | d->sendDataChanged(); executed (the execution status of this line is deduced): d->sendDataChanged(); | - |
1079 | } executed: } Execution Count:4034 | 4034 |
1080 | | - |
1081 | | - |
1082 | bool QAction::isVisible() const | - |
1083 | { | - |
1084 | Q_D(const QAction); executed (the execution status of this line is deduced): const QActionPrivate * const d = d_func(); | - |
1085 | return d->visible; executed: return d->visible; Execution Count:4614 | 4614 |
1086 | } | - |
1087 | | - |
1088 | /*! | - |
1089 | \reimp | - |
1090 | */ | - |
1091 | bool | - |
1092 | QAction::event(QEvent *e) | - |
1093 | { | - |
1094 | #ifndef QT_NO_SHORTCUT | - |
1095 | if (e->type() == QEvent::Shortcut) { evaluated: e->type() == QEvent::Shortcut yes Evaluation Count:13 | yes Evaluation Count:9939 |
| 13-9939 |
1096 | QShortcutEvent *se = static_cast<QShortcutEvent *>(e); executed (the execution status of this line is deduced): QShortcutEvent *se = static_cast<QShortcutEvent *>(e); | - |
1097 | Q_ASSERT_X(se->key() == d_func()->shortcut || d_func()->alternateShortcuts.contains(se->key()), executed (the execution status of this line is deduced): qt_noop(); | - |
1098 | "QAction::event", | - |
1099 | "Received shortcut event from incorrect shortcut"); | - |
1100 | if (se->isAmbiguous()) partially evaluated: se->isAmbiguous() no Evaluation Count:0 | yes Evaluation Count:13 |
| 0-13 |
1101 | qWarning("QAction::eventFilter: Ambiguous shortcut overload: %s", se->key().toString(QKeySequence::NativeText).toLatin1().constData()); never executed: QMessageLogger("kernel/qaction.cpp", 1101, __PRETTY_FUNCTION__).warning("QAction::eventFilter: Ambiguous shortcut overload: %s", se->key().toString(QKeySequence::NativeText).toLatin1().constData()); | 0 |
1102 | else | - |
1103 | activate(Trigger); executed: activate(Trigger); Execution Count:13 | 13 |
1104 | return true; executed: return true; Execution Count:13 | 13 |
1105 | } | - |
1106 | #endif | - |
1107 | return QObject::event(e); executed: return QObject::event(e); Execution Count:9939 | 9939 |
1108 | } | - |
1109 | | - |
1110 | /*! | - |
1111 | Returns the user data as set in QAction::setData. | - |
1112 | | - |
1113 | \sa setData() | - |
1114 | */ | - |
1115 | QVariant | - |
1116 | QAction::data() const | - |
1117 | { | - |
1118 | Q_D(const QAction); never executed (the execution status of this line is deduced): const QActionPrivate * const d = d_func(); | - |
1119 | return d->userData; never executed: return d->userData; | 0 |
1120 | } | - |
1121 | | - |
1122 | /*! | - |
1123 | \fn void QAction::setData(const QVariant &userData) | - |
1124 | | - |
1125 | Sets the action's internal data to the given \a userData. | - |
1126 | | - |
1127 | \sa data() | - |
1128 | */ | - |
1129 | void | - |
1130 | QAction::setData(const QVariant &data) | - |
1131 | { | - |
1132 | Q_D(QAction); executed (the execution status of this line is deduced): QActionPrivate * const d = d_func(); | - |
1133 | d->userData = data; executed (the execution status of this line is deduced): d->userData = data; | - |
1134 | d->sendDataChanged(); executed (the execution status of this line is deduced): d->sendDataChanged(); | - |
1135 | } executed: } Execution Count:324 | 324 |
1136 | | - |
1137 | | - |
1138 | /*! | - |
1139 | Updates the relevant status bar for the \a widget specified by sending a | - |
1140 | QStatusTipEvent to its parent widget. Returns true if an event was sent; | - |
1141 | otherwise returns false. | - |
1142 | | - |
1143 | If a null widget is specified, the event is sent to the action's parent. | - |
1144 | | - |
1145 | \sa statusTip | - |
1146 | */ | - |
1147 | bool | - |
1148 | QAction::showStatusText(QWidget *widget) | - |
1149 | { | - |
1150 | return d_func()->showStatusText(widget, statusTip()); executed: return d_func()->showStatusText(widget, statusTip()); Execution Count:93 | 93 |
1151 | } | - |
1152 | | - |
1153 | /*! | - |
1154 | Sends the relevant signals for ActionEvent \a event. | - |
1155 | | - |
1156 | Action based widgets use this API to cause the QAction | - |
1157 | to emit signals as well as emitting their own. | - |
1158 | */ | - |
1159 | void QAction::activate(ActionEvent event) | - |
1160 | { | - |
1161 | Q_D(QAction); executed (the execution status of this line is deduced): QActionPrivate * const d = d_func(); | - |
1162 | if(event == Trigger) { evaluated: event == Trigger yes Evaluation Count:74 | yes Evaluation Count:93 |
| 74-93 |
1163 | QPointer<QObject> guard = this; executed (the execution status of this line is deduced): QPointer<QObject> guard = this; | - |
1164 | if(d->checkable) { evaluated: d->checkable yes Evaluation Count:12 | yes Evaluation Count:62 |
| 12-62 |
1165 | // the checked action of an exclusive group cannot be unchecked | - |
1166 | if (d->checked && (d->group && d->group->isExclusive() evaluated: d->checked yes Evaluation Count:7 | yes Evaluation Count:5 |
evaluated: d->group yes Evaluation Count:1 | yes Evaluation Count:6 |
partially evaluated: d->group->isExclusive() yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-7 |
1167 | && d->group->checkedAction() == this)) { partially evaluated: d->group->checkedAction() == this yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
1168 | if (!guard.isNull()) partially evaluated: !guard.isNull() yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
1169 | emit triggered(true); executed: triggered(true); Execution Count:1 | 1 |
1170 | return; executed: return; Execution Count:1 | 1 |
1171 | } | - |
1172 | setChecked(!d->checked); executed (the execution status of this line is deduced): setChecked(!d->checked); | - |
1173 | } executed: } Execution Count:11 | 11 |
1174 | if (!guard.isNull()) partially evaluated: !guard.isNull() yes Evaluation Count:73 | no Evaluation Count:0 |
| 0-73 |
1175 | emit triggered(d->checked); executed: triggered(d->checked); Execution Count:73 | 73 |
1176 | } else if(event == Hover) { executed: } Execution Count:73 partially evaluated: event == Hover yes Evaluation Count:93 | no Evaluation Count:0 |
| 0-93 |
1177 | emit hovered(); executed (the execution status of this line is deduced): hovered(); | - |
1178 | } executed: } Execution Count:93 | 93 |
1179 | } | - |
1180 | | - |
1181 | /*! | - |
1182 | \fn void QAction::triggered(bool checked) | - |
1183 | | - |
1184 | This signal is emitted when an action is activated by the user; | - |
1185 | for example, when the user clicks a menu option, toolbar button, | - |
1186 | or presses an action's shortcut key combination, or when trigger() | - |
1187 | was called. Notably, it is \e not emitted when setChecked() or | - |
1188 | toggle() is called. | - |
1189 | | - |
1190 | If the action is checkable, \a checked is true if the action is | - |
1191 | checked, or false if the action is unchecked. | - |
1192 | | - |
1193 | \sa QAction::activate(), QAction::toggled(), checked | - |
1194 | */ | - |
1195 | | - |
1196 | /*! | - |
1197 | \fn void QAction::toggled(bool checked) | - |
1198 | | - |
1199 | This signal is emitted whenever a checkable action changes its | - |
1200 | isChecked() status. This can be the result of a user interaction, | - |
1201 | or because setChecked() was called. | - |
1202 | | - |
1203 | \a checked is true if the action is checked, or false if the | - |
1204 | action is unchecked. | - |
1205 | | - |
1206 | \sa QAction::activate(), QAction::triggered(), checked | - |
1207 | */ | - |
1208 | | - |
1209 | /*! | - |
1210 | \fn void QAction::hovered() | - |
1211 | | - |
1212 | This signal is emitted when an action is highlighted by the user; | - |
1213 | for example, when the user pauses with the cursor over a menu option, | - |
1214 | toolbar button, or presses an action's shortcut key combination. | - |
1215 | | - |
1216 | \sa QAction::activate() | - |
1217 | */ | - |
1218 | | - |
1219 | /*! | - |
1220 | \fn void QAction::changed() | - |
1221 | | - |
1222 | This signal is emitted when an action has changed. If you | - |
1223 | are only interested in actions in a given widget, you can | - |
1224 | watch for QWidget::actionEvent() sent with an | - |
1225 | QEvent::ActionChanged. | - |
1226 | | - |
1227 | \sa QWidget::actionEvent() | - |
1228 | */ | - |
1229 | | - |
1230 | /*! | - |
1231 | \enum QAction::ActionEvent | - |
1232 | | - |
1233 | This enum type is used when calling QAction::activate() | - |
1234 | | - |
1235 | \value Trigger this will cause the QAction::triggered() signal to be emitted. | - |
1236 | | - |
1237 | \value Hover this will cause the QAction::hovered() signal to be emitted. | - |
1238 | */ | - |
1239 | | - |
1240 | /*! | - |
1241 | \property QAction::menuRole | - |
1242 | \brief the action's menu role | - |
1243 | \since 4.2 | - |
1244 | | - |
1245 | This indicates what role the action serves in the application menu on Mac | - |
1246 | OS X. By default all action have the TextHeuristicRole, which means that | - |
1247 | the action is added based on its text (see QMenuBar for more information). | - |
1248 | | - |
1249 | The menu role can only be changed before the actions are put into the menu | - |
1250 | bar in Mac OS X (usually just before the first application window is | - |
1251 | shown). | - |
1252 | */ | - |
1253 | void QAction::setMenuRole(MenuRole menuRole) | - |
1254 | { | - |
1255 | Q_D(QAction); never executed (the execution status of this line is deduced): QActionPrivate * const d = d_func(); | - |
1256 | if (d->menuRole == menuRole) never evaluated: d->menuRole == menuRole | 0 |
1257 | return; | 0 |
1258 | | - |
1259 | d->menuRole = menuRole; never executed (the execution status of this line is deduced): d->menuRole = menuRole; | - |
1260 | d->sendDataChanged(); never executed (the execution status of this line is deduced): d->sendDataChanged(); | - |
1261 | } | 0 |
1262 | | - |
1263 | QAction::MenuRole QAction::menuRole() const | - |
1264 | { | - |
1265 | Q_D(const QAction); never executed (the execution status of this line is deduced): const QActionPrivate * const d = d_func(); | - |
1266 | return d->menuRole; never executed: return d->menuRole; | 0 |
1267 | } | - |
1268 | | - |
1269 | /*! | - |
1270 | \property QAction::iconVisibleInMenu | - |
1271 | \brief Whether or not an action should show an icon in a menu | - |
1272 | \since 4.4 | - |
1273 | | - |
1274 | In some applications, it may make sense to have actions with icons in the | - |
1275 | toolbar, but not in menus. If true, the icon (if valid) is shown in the menu, when it | - |
1276 | is false, it is not shown. | - |
1277 | | - |
1278 | The default is to follow whether the Qt::AA_DontShowIconsInMenus attribute | - |
1279 | is set for the application. Explicitly settings this property overrides | - |
1280 | the presence (or abscence) of the attribute. | - |
1281 | | - |
1282 | For example: | - |
1283 | \snippet code/src_gui_kernel_qaction.cpp 0 | - |
1284 | | - |
1285 | \sa QAction::icon, QApplication::setAttribute() | - |
1286 | */ | - |
1287 | void QAction::setIconVisibleInMenu(bool visible) | - |
1288 | { | - |
1289 | Q_D(QAction); never executed (the execution status of this line is deduced): QActionPrivate * const d = d_func(); | - |
1290 | if (d->iconVisibleInMenu == -1 || visible != bool(d->iconVisibleInMenu)) { never evaluated: d->iconVisibleInMenu == -1 never evaluated: visible != bool(d->iconVisibleInMenu) | 0 |
1291 | int oldValue = d->iconVisibleInMenu; never executed (the execution status of this line is deduced): int oldValue = d->iconVisibleInMenu; | - |
1292 | d->iconVisibleInMenu = visible; never executed (the execution status of this line is deduced): d->iconVisibleInMenu = visible; | - |
1293 | // Only send data changed if we really need to. | - |
1294 | if (oldValue != -1 never evaluated: oldValue != -1 | 0 |
1295 | || (oldValue == -1 never evaluated: oldValue == -1 | 0 |
1296 | && visible == !QApplication::instance()->testAttribute(Qt::AA_DontShowIconsInMenus))) { never evaluated: visible == !QApplication::instance()->testAttribute(Qt::AA_DontShowIconsInMenus) | 0 |
1297 | d->sendDataChanged(); never executed (the execution status of this line is deduced): d->sendDataChanged(); | - |
1298 | } | 0 |
1299 | } | 0 |
1300 | } | 0 |
1301 | | - |
1302 | bool QAction::isIconVisibleInMenu() const | - |
1303 | { | - |
1304 | Q_D(const QAction); executed (the execution status of this line is deduced): const QActionPrivate * const d = d_func(); | - |
1305 | if (d->iconVisibleInMenu == -1) { partially evaluated: d->iconVisibleInMenu == -1 yes Evaluation Count:2008 | no Evaluation Count:0 |
| 0-2008 |
1306 | return !QApplication::instance()->testAttribute(Qt::AA_DontShowIconsInMenus); executed: return !QApplication::instance()->testAttribute(Qt::AA_DontShowIconsInMenus); Execution Count:2008 | 2008 |
1307 | } | - |
1308 | return d->iconVisibleInMenu; never executed: return d->iconVisibleInMenu; | 0 |
1309 | } | - |
1310 | | - |
1311 | QT_END_NAMESPACE | - |
1312 | | - |
1313 | #include "moc_qaction.cpp" | - |
1314 | | - |
1315 | #endif // QT_NO_ACTION | - |
1316 | | - |
| | |