| Line | Source | Count |
| 1 | | - |
| 2 | | - |
| 3 | | - |
| 4 | | - |
| 5 | | - |
| 6 | | - |
| 7 | | - |
| 8 | | - |
| 9 | | - |
| 10 | | - |
| 11 | | - |
| 12 | | - |
| 13 | | - |
| 14 | | - |
| 15 | static QString qt_strippedText(QString s) | - |
| 16 | { | - |
| 17 | s.remove( QString::fromLatin1("...") ); | - |
| 18 | for (int i = 0; i < s.size(); ++i) { | - |
| 19 | if (s.at(i) == QLatin1Char('&')) | - |
| 20 | s.remove(i, 1); | - |
| 21 | } | - |
| 22 | return s.trimmed(); | - |
| 23 | } | - |
| 24 | | - |
| 25 | | - |
| 26 | QActionPrivate::QActionPrivate() : group(0), enabled(1), forceDisabled(0), | - |
| 27 | visible(1), forceInvisible(0), checkable(0), checked(0), separator(0), fontSet(false), | - |
| 28 | iconVisibleInMenu(-1), | - |
| 29 | menuRole(QAction::TextHeuristicRole), | - |
| 30 | priority(QAction::NormalPriority) | - |
| 31 | { | - |
| 32 | | - |
| 33 | shortcutId = 0; | - |
| 34 | shortcutContext = Qt::WindowShortcut; | - |
| 35 | autorepeat = true; | - |
| 36 | | - |
| 37 | } | - |
| 38 | | - |
| 39 | QActionPrivate::~QActionPrivate() | - |
| 40 | { | - |
| 41 | } | - |
| 42 | | - |
| 43 | bool QActionPrivate::showStatusText(QWidget *widget, const QString &str) | - |
| 44 | { | - |
| 45 | | - |
| 46 | | - |
| 47 | | - |
| 48 | | - |
| 49 | if(QObject *object = widget ? widget : parent) { | - |
| 50 | QStatusTipEvent tip(str); | - |
| 51 | QApplication::sendEvent(object, &tip); | - |
| 52 | return true; | - |
| 53 | } | - |
| 54 | | - |
| 55 | return false; | - |
| 56 | } | - |
| 57 | | - |
| 58 | void QActionPrivate::sendDataChanged() | - |
| 59 | { | - |
| 60 | QAction * const q = q_func(); | - |
| 61 | QActionEvent e(QEvent::ActionChanged, q); | - |
| 62 | for (int i = 0; i < widgets.size(); ++i) { | - |
| 63 | QWidget *w = widgets.at(i); | - |
| 64 | QApplication::sendEvent(w, &e); | - |
| 65 | } | - |
| 66 | | - |
| 67 | for (int i = 0; i < graphicsWidgets.size(); ++i) { | - |
| 68 | QGraphicsWidget *w = graphicsWidgets.at(i); | - |
| 69 | QApplication::sendEvent(w, &e); | - |
| 70 | } | - |
| 71 | | - |
| 72 | QApplication::sendEvent(q, &e); | - |
| 73 | | - |
| 74 | q->changed(); | - |
| 75 | } | - |
| 76 | | - |
| 77 | | - |
| 78 | void QActionPrivate::redoGrab(QShortcutMap &map) | - |
| 79 | { | - |
| 80 | QAction * const q = q_func(); | - |
| 81 | if (shortcutId) | - |
| 82 | map.removeShortcut(shortcutId, q); | - |
| 83 | if (shortcut.isEmpty()) | - |
| 84 | return; | - |
| 85 | shortcutId = map.addShortcut(q, shortcut, shortcutContext, qWidgetShortcutContextMatcher); | - |
| 86 | if (!enabled) | - |
| 87 | map.setShortcutEnabled(false, shortcutId, q); | - |
| 88 | if (!autorepeat) | - |
| 89 | map.setShortcutAutoRepeat(false, shortcutId, q); | - |
| 90 | } | - |
| 91 | | - |
| 92 | void QActionPrivate::redoGrabAlternate(QShortcutMap &map) | - |
| 93 | { | - |
| 94 | QAction * const q = q_func(); | - |
| 95 | for(int i = 0; i < alternateShortcutIds.count(); ++i) { | - |
| 96 | if (const int id = alternateShortcutIds.at(i)) | - |
| 97 | map.removeShortcut(id, q); | - |
| 98 | } | - |
| 99 | alternateShortcutIds.clear(); | - |
| 100 | if (alternateShortcuts.isEmpty()) | - |
| 101 | return; | - |
| 102 | for(int i = 0; i < alternateShortcuts.count(); ++i) { | - |
| 103 | const QKeySequence& alternate = alternateShortcuts.at(i); | - |
| 104 | if (!alternate.isEmpty()) | - |
| 105 | alternateShortcutIds.append(map.addShortcut(q, alternate, shortcutContext, qWidgetShortcutContextMatcher)); | - |
| 106 | else | - |
| 107 | alternateShortcutIds.append(0); | - |
| 108 | } | - |
| 109 | if (!enabled) { | - |
| 110 | for(int i = 0; i < alternateShortcutIds.count(); ++i) { | - |
| 111 | const int id = alternateShortcutIds.at(i); | - |
| 112 | map.setShortcutEnabled(false, id, q); | - |
| 113 | } | - |
| 114 | } | - |
| 115 | if (!autorepeat) { | - |
| 116 | for(int i = 0; i < alternateShortcutIds.count(); ++i) { | - |
| 117 | const int id = alternateShortcutIds.at(i); | - |
| 118 | map.setShortcutAutoRepeat(false, id, q); | - |
| 119 | } | - |
| 120 | } | - |
| 121 | } | - |
| 122 | | - |
| 123 | void QActionPrivate::setShortcutEnabled(bool enable, QShortcutMap &map) | - |
| 124 | { | - |
| 125 | QAction * const q = q_func(); | - |
| 126 | if (shortcutId) | - |
| 127 | map.setShortcutEnabled(enable, shortcutId, q); | - |
| 128 | for(int i = 0; i < alternateShortcutIds.count(); ++i) { | - |
| 129 | if (const int id = alternateShortcutIds.at(i)) | - |
| 130 | map.setShortcutEnabled(enable, id, q); | - |
| 131 | } | - |
| 132 | } | - |
| 133 | QAction::QAction(QObject* parent) | - |
| 134 | : QObject(*(new QActionPrivate), parent) | - |
| 135 | { | - |
| 136 | QActionPrivate * const d = d_func(); | - |
| 137 | d->group = qobject_cast<QActionGroup *>(parent); | - |
| 138 | if (d->group) | - |
| 139 | d->group->addAction(this); | - |
| 140 | } | - |
| 141 | QAction::QAction(const QString &text, QObject* parent) | - |
| 142 | : QObject(*(new QActionPrivate), parent) | - |
| 143 | { | - |
| 144 | QActionPrivate * const d = d_func(); | - |
| 145 | d->text = text; | - |
| 146 | d->group = qobject_cast<QActionGroup *>(parent); | - |
| 147 | if (d->group) | - |
| 148 | d->group->addAction(this); | - |
| 149 | } | - |
| 150 | QAction::QAction(const QIcon &icon, const QString &text, QObject* parent) | - |
| 151 | : QObject(*(new QActionPrivate), parent) | - |
| 152 | { | - |
| 153 | QActionPrivate * const d = d_func(); | - |
| 154 | d->icon = icon; | - |
| 155 | d->text = text; | - |
| 156 | d->group = qobject_cast<QActionGroup *>(parent); | - |
| 157 | if (d->group) | - |
| 158 | d->group->addAction(this); | - |
| 159 | } | - |
| 160 | | - |
| 161 | | - |
| 162 | | - |
| 163 | | - |
| 164 | QAction::QAction(QActionPrivate &dd, QObject *parent) | - |
| 165 | : QObject(dd, parent) | - |
| 166 | { | - |
| 167 | QActionPrivate * const d = d_func(); | - |
| 168 | d->group = qobject_cast<QActionGroup *>(parent); | - |
| 169 | if (d->group) | - |
| 170 | d->group->addAction(this); | - |
| 171 | } | - |
| 172 | | - |
| 173 | | - |
| 174 | | - |
| 175 | | - |
| 176 | QWidget *QAction::parentWidget() const | - |
| 177 | { | - |
| 178 | QObject *ret = parent(); | - |
| 179 | while (ret && !ret->isWidgetType()) | - |
| 180 | ret = ret->parent(); | - |
| 181 | return (QWidget*)ret; | - |
| 182 | } | - |
| 183 | | - |
| 184 | | - |
| 185 | | - |
| 186 | | - |
| 187 | | - |
| 188 | | - |
| 189 | | - |
| 190 | QList<QWidget *> QAction::associatedWidgets() const | - |
| 191 | { | - |
| 192 | const QActionPrivate * const d = d_func(); | - |
| 193 | return d->widgets; | - |
| 194 | } | - |
| 195 | QList<QGraphicsWidget *> QAction::associatedGraphicsWidgets() const | - |
| 196 | { | - |
| 197 | const QActionPrivate * const d = d_func(); | - |
| 198 | return d->graphicsWidgets; | - |
| 199 | } | - |
| 200 | void QAction::setShortcut(const QKeySequence &shortcut) | - |
| 201 | { | - |
| 202 | if (!((__builtin_expect(!!(!(static_cast<QApplication *>(QCoreApplication::instance())))()))), false)) { QMessageLogger(__FILE__, 390396, __PRETTY_FUNCTION__).warning("QAction: Initialize QApplication before calling '" "setShortcut" "'."); return; }; | - |
| 203 | | - |
| 204 | QActionPrivate * const d = d_func(); | - |
| 205 | if (d->shortcut == shortcut) | - |
| 206 | return; | - |
| 207 | | - |
| 208 | d->shortcut = shortcut; | - |
| 209 | d->redoGrab((static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->shortcutMap); | - |
| 210 | d->sendDataChanged(); | - |
| 211 | } | - |
| 212 | void QAction::setShortcuts(const QList<QKeySequence> &shortcuts) | - |
| 213 | { | - |
| 214 | QActionPrivate * const d = d_func(); | - |
| 215 | | - |
| 216 | QList <QKeySequence> listCopy = shortcuts; | - |
| 217 | | - |
| 218 | QKeySequence primary; | - |
| 219 | if (!listCopy.isEmpty()) | - |
| 220 | primary = listCopy.takeFirst(); | - |
| 221 | | - |
| 222 | if (d->shortcut == primary && d->alternateShortcuts == listCopy) | - |
| 223 | return; | - |
| 224 | | - |
| 225 | if (!((__builtin_expect(!!(!(static_cast<QApplication *>(QCoreApplication::instance())))()))), false)) { QMessageLogger(__FILE__, 422428, __PRETTY_FUNCTION__).warning("QAction: Initialize QApplication before calling '" "setShortcuts" "'."); return; }; | - |
| 226 | | - |
| 227 | d->shortcut = primary; | - |
| 228 | d->alternateShortcuts = listCopy; | - |
| 229 | d->redoGrab((static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->shortcutMap); | - |
| 230 | d->redoGrabAlternate((static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->shortcutMap); | - |
| 231 | d->sendDataChanged(); | - |
| 232 | } | - |
| 233 | void QAction::setShortcuts(QKeySequence::StandardKey key) | - |
| 234 | { | - |
| 235 | QList <QKeySequence> list = QKeySequence::keyBindings(key); | - |
| 236 | setShortcuts(list); | - |
| 237 | } | - |
| 238 | | - |
| 239 | | - |
| 240 | | - |
| 241 | | - |
| 242 | | - |
| 243 | | - |
| 244 | QKeySequence QAction::shortcut() const | - |
| 245 | { | - |
| 246 | const QActionPrivate * const d = d_func(); | - |
| 247 | return d->shortcut; | - |
| 248 | } | - |
| 249 | QList<QKeySequence> QAction::shortcuts() const | - |
| 250 | { | - |
| 251 | const QActionPrivate * const d = d_func(); | - |
| 252 | QList <QKeySequence> shortcuts; | - |
| 253 | if (!d->shortcut.isEmpty()) | - |
| 254 | shortcuts << d->shortcut; | - |
| 255 | if (!d->alternateShortcuts.isEmpty()) | - |
| 256 | shortcuts << d->alternateShortcuts; | - |
| 257 | return shortcuts; | - |
| 258 | } | - |
| 259 | void QAction::setShortcutContext(Qt::ShortcutContext context) | - |
| 260 | { | - |
| 261 | QActionPrivate * const d = d_func(); | - |
| 262 | if (d->shortcutContext == context) | - |
| 263 | return; | - |
| 264 | if (!((__builtin_expect(!!(!(static_cast<QApplication *>(QCoreApplication::instance())))()))), false)) { QMessageLogger(__FILE__, 489495, __PRETTY_FUNCTION__).warning("QAction: Initialize QApplication before calling '" "setShortcutContext" "'."); return; }; | - |
| 265 | d->shortcutContext = context; | - |
| 266 | d->redoGrab((static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->shortcutMap); | - |
| 267 | d->redoGrabAlternate((static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->shortcutMap); | - |
| 268 | d->sendDataChanged(); | - |
| 269 | } | - |
| 270 | | - |
| 271 | Qt::ShortcutContext QAction::shortcutContext() const | - |
| 272 | { | - |
| 273 | const QActionPrivate * const d = d_func(); | - |
| 274 | return d->shortcutContext; | - |
| 275 | } | - |
| 276 | void QAction::setAutoRepeat(bool on) | - |
| 277 | { | - |
| 278 | QActionPrivate * const d = d_func(); | - |
| 279 | if (d->autorepeat == on) | - |
| 280 | return; | - |
| 281 | if (!((__builtin_expect(!!(!(static_cast<QApplication *>(QCoreApplication::instance())))()))), false)) { QMessageLogger(__FILE__, 517523, __PRETTY_FUNCTION__).warning("QAction: Initialize QApplication before calling '" "setAutoRepeat" "'."); return; }; | - |
| 282 | d->autorepeat = on; | - |
| 283 | d->redoGrab((static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->shortcutMap); | - |
| 284 | d->redoGrabAlternate((static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->shortcutMap); | - |
| 285 | d->sendDataChanged(); | - |
| 286 | } | - |
| 287 | | - |
| 288 | bool QAction::autoRepeat() const | - |
| 289 | { | - |
| 290 | const QActionPrivate * const d = d_func(); | - |
| 291 | return d->autorepeat; | - |
| 292 | } | - |
| 293 | void QAction::setFont(const QFont &font) | - |
| 294 | { | - |
| 295 | QActionPrivate * const d = d_func(); | - |
| 296 | if (d->font == font) | - |
| 297 | return; | - |
| 298 | | - |
| 299 | d->fontSet = true; | - |
| 300 | d->font = font; | - |
| 301 | d->sendDataChanged(); | - |
| 302 | } | - |
| 303 | | - |
| 304 | QFont QAction::font() const | - |
| 305 | { | - |
| 306 | const QActionPrivate * const d = d_func(); | - |
| 307 | return d->font; | - |
| 308 | } | - |
| 309 | | - |
| 310 | | - |
| 311 | | - |
| 312 | | - |
| 313 | | - |
| 314 | QAction::~QAction() | - |
| 315 | { | - |
| 316 | QActionPrivate * const d = d_func(); | - |
| 317 | for (int i = d->widgets.size()-1; i >= 0; --i) { | - |
| 318 | QWidget *w = d->widgets.at(i); | - |
| 319 | w->removeAction(this); | - |
| 320 | } | - |
| 321 | | - |
| 322 | for (int i = d->graphicsWidgets.size()-1; i >= 0; --i) { | - |
| 323 | QGraphicsWidget *w = d->graphicsWidgets.at(i); | - |
| 324 | w->removeAction(this); | - |
| 325 | } | - |
| 326 | | - |
| 327 | if (d->group) | - |
| 328 | d->group->removeAction(this); | - |
| 329 | | - |
| 330 | if (d->shortcutId && (static_cast<QApplication *>(QCoreApplication::instance()))) { | - |
| 331 | (static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->shortcutMap.removeShortcut(d->shortcutId, this); | - |
| 332 | for(int i = 0; i < d->alternateShortcutIds.count(); ++i) { | - |
| 333 | const int id = d->alternateShortcutIds.at(i); | - |
| 334 | (static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->shortcutMap.removeShortcut(id, this); | - |
| 335 | } | - |
| 336 | } | - |
| 337 | | - |
| 338 | } | - |
| 339 | void QAction::setActionGroup(QActionGroup *group) | - |
| 340 | { | - |
| 341 | QActionPrivate * const d = d_func(); | - |
| 342 | if(group == d->group| TRUE | never evaluated | | FALSE | never evaluated |
) | 0 |
| 343 | return; never executed: return; | 0 |
| 344 | | - |
| 345 | if(d->group| TRUE | never evaluated | | FALSE | never evaluated |
) | 0 |
| 346 | d->group->removeAction(this); never executed: d->group->removeAction(this); | 0 |
| 347 | d->group = group; | - |
| 348 | if(group| TRUE | never evaluated | | FALSE | never evaluated |
) | 0 |
| 349 | group->addAction(this); never executed: group->addAction(this); | 0 |
| 350 | d->sendDataChanged(); | - |
| 351 | } never executed: end of block | 0 |
| 352 | | - |
| 353 | | - |
| 354 | | - |
| 355 | | - |
| 356 | | - |
| 357 | | - |
| 358 | | - |
| 359 | QActionGroup *QAction::actionGroup() const | - |
| 360 | { | - |
| 361 | const QActionPrivate * const d = d_func(); | - |
| 362 | return d->group; | - |
| 363 | } | - |
| 364 | void QAction::setIcon(const QIcon &icon) | - |
| 365 | { | - |
| 366 | QActionPrivate * const d = d_func(); | - |
| 367 | d->icon = icon; | - |
| 368 | d->sendDataChanged(); | - |
| 369 | } | - |
| 370 | | - |
| 371 | QIcon QAction::icon() const | - |
| 372 | { | - |
| 373 | const QActionPrivate * const d = d_func(); | - |
| 374 | return d->icon; | - |
| 375 | } | - |
| 376 | QMenu *QAction::menu() const | - |
| 377 | { | - |
| 378 | const QActionPrivate * const d = d_func(); | - |
| 379 | return d->menu; | - |
| 380 | } | - |
| 381 | | - |
| 382 | | - |
| 383 | | - |
| 384 | | - |
| 385 | void QAction::setMenu(QMenu *menu) | - |
| 386 | { | - |
| 387 | QActionPrivate * const d = d_func(); | - |
| 388 | if (d->menu) | - |
| 389 | d->menu->d_func()->setOverrideMenuAction(0); | - |
| 390 | d->menu = menu; | - |
| 391 | if (menu) | - |
| 392 | menu->d_func()->setOverrideMenuAction(this); | - |
| 393 | d->sendDataChanged(); | - |
| 394 | } | - |
| 395 | void QAction::setSeparator(bool b) | - |
| 396 | { | - |
| 397 | QActionPrivate * const d = d_func(); | - |
| 398 | if (d->separator == b) | - |
| 399 | return; | - |
| 400 | | - |
| 401 | d->separator = b; | - |
| 402 | d->sendDataChanged(); | - |
| 403 | } | - |
| 404 | | - |
| 405 | | - |
| 406 | | - |
| 407 | | - |
| 408 | | - |
| 409 | | - |
| 410 | | - |
| 411 | bool QAction::isSeparator() const | - |
| 412 | { | - |
| 413 | const QActionPrivate * const d = d_func(); | - |
| 414 | return d->separator; | - |
| 415 | } | - |
| 416 | void QAction::setText(const QString &text) | - |
| 417 | { | - |
| 418 | QActionPrivate * const d = d_func(); | - |
| 419 | if (d->text == text) | - |
| 420 | return; | - |
| 421 | | - |
| 422 | d->text = text; | - |
| 423 | d->sendDataChanged(); | - |
| 424 | } | - |
| 425 | | - |
| 426 | QString QAction::text() const | - |
| 427 | { | - |
| 428 | const QActionPrivate * const d = d_func(); | - |
| 429 | QString s = d->text; | - |
| 430 | if(s.isEmpty()) { | - |
| 431 | s = d->iconText; | - |
| 432 | s.replace(QLatin1Char('&'), QLatin1String("&&")); | - |
| 433 | } | - |
| 434 | return s; | - |
| 435 | } | - |
| 436 | void QAction::setIconText(const QString &text) | - |
| 437 | { | - |
| 438 | QActionPrivate * const d = d_func(); | - |
| 439 | if (d->iconText == text) | - |
| 440 | return; | - |
| 441 | | - |
| 442 | d->iconText = text; | - |
| 443 | d->sendDataChanged(); | - |
| 444 | } | - |
| 445 | | - |
| 446 | QString QAction::iconText() const | - |
| 447 | { | - |
| 448 | const QActionPrivate * const d = d_func(); | - |
| 449 | if (d->iconText.isEmpty()) | - |
| 450 | return qt_strippedText(d->text); | - |
| 451 | return d->iconText; | - |
| 452 | } | - |
| 453 | void QAction::setToolTip(const QString &tooltip) | - |
| 454 | { | - |
| 455 | QActionPrivate * const d = d_func(); | - |
| 456 | if (d->tooltip == tooltip) | - |
| 457 | return; | - |
| 458 | | - |
| 459 | d->tooltip = tooltip; | - |
| 460 | d->sendDataChanged(); | - |
| 461 | } | - |
| 462 | | - |
| 463 | QString QAction::toolTip() const | - |
| 464 | { | - |
| 465 | const QActionPrivate * const d = d_func(); | - |
| 466 | if (d->tooltip.isEmpty()) { | - |
| 467 | if (!d->text.isEmpty()) | - |
| 468 | return qt_strippedText(d->text); | - |
| 469 | return qt_strippedText(d->iconText); | - |
| 470 | } | - |
| 471 | return d->tooltip; | - |
| 472 | } | - |
| 473 | void QAction::setStatusTip(const QString &statustip) | - |
| 474 | { | - |
| 475 | QActionPrivate * const d = d_func(); | - |
| 476 | if (d->statustip == statustip) | - |
| 477 | return; | - |
| 478 | | - |
| 479 | d->statustip = statustip; | - |
| 480 | d->sendDataChanged(); | - |
| 481 | } | - |
| 482 | | - |
| 483 | QString QAction::statusTip() const | - |
| 484 | { | - |
| 485 | const QActionPrivate * const d = d_func(); | - |
| 486 | return d->statustip; | - |
| 487 | } | - |
| 488 | void QAction::setWhatsThis(const QString &whatsthis) | - |
| 489 | { | - |
| 490 | QActionPrivate * const d = d_func(); | - |
| 491 | if (d->whatsthis == whatsthis) | - |
| 492 | return; | - |
| 493 | | - |
| 494 | d->whatsthis = whatsthis; | - |
| 495 | d->sendDataChanged(); | - |
| 496 | } | - |
| 497 | | - |
| 498 | QString QAction::whatsThis() const | - |
| 499 | { | - |
| 500 | const QActionPrivate * const d = d_func(); | - |
| 501 | return d->whatsthis; | - |
| 502 | } | - |
| 503 | void QAction::setPriority(Priority priority) | - |
| 504 | { | - |
| 505 | QActionPrivate * const d = d_func(); | - |
| 506 | if (d->priority == priority) | - |
| 507 | return; | - |
| 508 | | - |
| 509 | d->priority = priority; | - |
| 510 | d->sendDataChanged(); | - |
| 511 | } | - |
| 512 | | - |
| 513 | QAction::Priority QAction::priority() const | - |
| 514 | { | - |
| 515 | const QActionPrivate * const d = d_func(); | - |
| 516 | return d->priority; | - |
| 517 | } | - |
| 518 | void QAction::setCheckable(bool b) | - |
| 519 | { | - |
| 520 | QActionPrivate * const d = d_func(); | - |
| 521 | if (d->checkable == b) | - |
| 522 | return; | - |
| 523 | | - |
| 524 | d->checkable = b; | - |
| 525 | d->checked = false; | - |
| 526 | d->sendDataChanged(); | - |
| 527 | } | - |
| 528 | | - |
| 529 | bool QAction::isCheckable() const | - |
| 530 | { | - |
| 531 | const QActionPrivate * const d = d_func(); | - |
| 532 | return d->checkable; | - |
| 533 | } | - |
| 534 | | - |
| 535 | | - |
| 536 | | - |
| 537 | | - |
| 538 | | - |
| 539 | | - |
| 540 | | - |
| 541 | void QAction::toggle() | - |
| 542 | { | - |
| 543 | QActionPrivate * const d = d_func(); | - |
| 544 | setChecked(!d->checked); | - |
| 545 | } | - |
| 546 | void QAction::setChecked(bool b) | - |
| 547 | { | - |
| 548 | QActionPrivate * const d = d_func(); | - |
| 549 | if (!d->checkable || d->checked == b) | - |
| 550 | return; | - |
| 551 | | - |
| 552 | QPointer<QAction> guard(this); | - |
| 553 | d->checked = b; | - |
| 554 | d->sendDataChanged(); | - |
| 555 | if (guard) | - |
| 556 | toggled(b); | - |
| 557 | } | - |
| 558 | | - |
| 559 | bool QAction::isChecked() const | - |
| 560 | { | - |
| 561 | const QActionPrivate * const d = d_func(); | - |
| 562 | return d->checked; | - |
| 563 | } | - |
| 564 | void QAction::setEnabled(bool b) | - |
| 565 | { | - |
| 566 | QActionPrivate * const d = d_func(); | - |
| 567 | if (b == d->enabled && b != d->forceDisabled) | - |
| 568 | return; | - |
| 569 | d->forceDisabled = !b; | - |
| 570 | if (b && (!d->visible || (d->group && !d->group->isEnabled()))) | - |
| 571 | return; | - |
| 572 | if (!((__builtin_expect(!!(!(static_cast<QApplication *>(QCoreApplication::instance())))()))), false)) { QMessageLogger(__FILE__, 10271034, __PRETTY_FUNCTION__).warning("QAction: Initialize QApplication before calling '" "setEnabled" "'."); return; }; | - |
| 573 | d->enabled = b; | - |
| 574 | | - |
| 575 | d->setShortcutEnabled(b, (static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->shortcutMap); | - |
| 576 | | - |
| 577 | d->sendDataChanged(); | - |
| 578 | } | - |
| 579 | | - |
| 580 | bool QAction::isEnabled() const | - |
| 581 | { | - |
| 582 | const QActionPrivate * const d = d_func(); | - |
| 583 | return d->enabled; | - |
| 584 | } | - |
| 585 | void QAction::setVisible(bool b) | - |
| 586 | { | - |
| 587 | QActionPrivate * const d = d_func(); | - |
| 588 | if (b == d->visible && b != d->forceInvisible) | - |
| 589 | return; | - |
| 590 | if (!((__builtin_expect(!!(!(static_cast<QApplication *>(QCoreApplication::instance())))()))), false)) { QMessageLogger(__FILE__, 10591066, __PRETTY_FUNCTION__).warning("QAction: Initialize QApplication before calling '" "setVisible" "'."); return; }; | - |
| 591 | d->forceInvisible = !b; | - |
| 592 | d->visible = b; | - |
| 593 | d->enabled = b && !d->forceDisabled && (!d->group || d->group->isEnabled()) ; | - |
| 594 | | - |
| 595 | d->setShortcutEnabled(d->enabled, (static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->shortcutMap); | - |
| 596 | | - |
| 597 | d->sendDataChanged(); | - |
| 598 | } | - |
| 599 | | - |
| 600 | | - |
| 601 | bool QAction::isVisible() const | - |
| 602 | { | - |
| 603 | const QActionPrivate * const d = d_func(); | - |
| 604 | return d->visible; | - |
| 605 | } | - |
| 606 | | - |
| 607 | | - |
| 608 | | - |
| 609 | | - |
| 610 | bool | - |
| 611 | QAction::event(QEvent *e) | - |
| 612 | { | - |
| 613 | | - |
| 614 | if (e->type() == QEvent::Shortcut) { | - |
| 615 | QShortcutEvent *se = static_cast<QShortcutEvent *>(e); | - |
| 616 | ((!(se->key() == d_func()->shortcut || d_func()->alternateShortcuts.contains(se->key()))) ? qt_assert_x("QAction::event", "Received shortcut event from incorrect shortcut", | - |
| 617 | | - |
| 618 | __FILE__ | - |
| 619 | , | - |
| 620 | | - |
| 621 | 10871094 | - |
| 622 | ) : qt_noop()) | - |
| 623 | | - |
| 624 | ; | - |
| 625 | if (se->isAmbiguous()) | - |
| 626 | QMessageLogger(__FILE__, 10891096, __PRETTY_FUNCTION__).warning("QAction::eventFilter: Ambiguous shortcut overload: %s", se->key().toString(QKeySequence::NativeText).toLatin1().constData()); | - |
| 627 | else | - |
| 628 | activate(Trigger); | - |
| 629 | return true; | - |
| 630 | } | - |
| 631 | | - |
| 632 | return QObject::event(e); | - |
| 633 | } | - |
| 634 | | - |
| 635 | | - |
| 636 | | - |
| 637 | | - |
| 638 | | - |
| 639 | | - |
| 640 | QVariant | - |
| 641 | QAction::data() const | - |
| 642 | { | - |
| 643 | const QActionPrivate * const d = d_func(); | - |
| 644 | return d->userData; | - |
| 645 | } | - |
| 646 | void | - |
| 647 | QAction::setData(const QVariant &data) | - |
| 648 | { | - |
| 649 | QActionPrivate * const d = d_func(); | - |
| 650 | d->userData = data; | - |
| 651 | d->sendDataChanged(); | - |
| 652 | } | - |
| 653 | bool | - |
| 654 | QAction::showStatusText(QWidget *widget) | - |
| 655 | { | - |
| 656 | return d_func()->showStatusText(widget, statusTip()); | - |
| 657 | } | - |
| 658 | | - |
| 659 | | - |
| 660 | | - |
| 661 | | - |
| 662 | | - |
| 663 | | - |
| 664 | | - |
| 665 | void QAction::activate(ActionEvent event) | - |
| 666 | { | - |
| 667 | QActionPrivate * const d = d_func(); | - |
| 668 | if(event == Trigger) { | - |
| 669 | QPointer<QObject> guard = this; | - |
| 670 | if(d->checkable) { | - |
| 671 | | - |
| 672 | if (d->checked && (d->group && d->group->isExclusive() | - |
| 673 | && d->group->checkedAction() == this)) { | - |
| 674 | if (!guard.isNull()) | - |
| 675 | triggered(true); | - |
| 676 | return; | - |
| 677 | } | - |
| 678 | setChecked(!d->checked); | - |
| 679 | } | - |
| 680 | if (!guard.isNull()) | - |
| 681 | triggered(d->checked); | - |
| 682 | } else if(event == Hover) { | - |
| 683 | hovered(); | - |
| 684 | } | - |
| 685 | } | - |
| 686 | void QAction::setMenuRole(MenuRole menuRole) | - |
| 687 | { | - |
| 688 | QActionPrivate * const d = d_func(); | - |
| 689 | if (d->menuRole == menuRole) | - |
| 690 | return; | - |
| 691 | | - |
| 692 | d->menuRole = menuRole; | - |
| 693 | d->sendDataChanged(); | - |
| 694 | } | - |
| 695 | | - |
| 696 | QAction::MenuRole QAction::menuRole() const | - |
| 697 | { | - |
| 698 | const QActionPrivate * const d = d_func(); | - |
| 699 | return d->menuRole; | - |
| 700 | } | - |
| 701 | void QAction::setIconVisibleInMenu(bool visible) | - |
| 702 | { | - |
| 703 | QActionPrivate * const d = d_func(); | - |
| 704 | if (d->iconVisibleInMenu == -1 || visible != bool(d->iconVisibleInMenu)) { | - |
| 705 | int oldValue = d->iconVisibleInMenu; | - |
| 706 | d->iconVisibleInMenu = visible; | - |
| 707 | | - |
| 708 | if (oldValue != -1 | - |
| 709 | || (oldValue == -1 | - |
| 710 | && visible == !QApplication::instance()->testAttribute(Qt::AA_DontShowIconsInMenus))) { | - |
| 711 | d->sendDataChanged(); | - |
| 712 | } | - |
| 713 | } | - |
| 714 | } | - |
| 715 | | - |
| 716 | bool QAction::isIconVisibleInMenu() const | - |
| 717 | { | - |
| 718 | const QActionPrivate * const d = d_func(); | - |
| 719 | if (d->iconVisibleInMenu == -1) { | - |
| 720 | return !QApplication::instance()->testAttribute(Qt::AA_DontShowIconsInMenus); | - |
| 721 | } | - |
| 722 | return d->iconVisibleInMenu; | - |
| 723 | } | - |
| 724 | | - |
| 725 | | - |
| 726 | __attribute__((visibility("default"))) QDebug operator<<(QDebug d, const QAction *action) | - |
| 727 | { | - |
| 728 | QDebugStateSaver saver(d); | - |
| 729 | d.nospace(); | - |
| 730 | d << "QAction(" << static_cast<const void *>(action); | - |
| 731 | if (action) { | - |
| 732 | d << " text=" << action->text(); | - |
| 733 | if (!action->toolTip().isEmpty()) | - |
| 734 | d << " toolTip=" << action->toolTip(); | - |
| 735 | if (action->isCheckable()) | - |
| 736 | d << " checked=" << action->isChecked(); | - |
| 737 | if (!action->shortcut().isEmpty()) | - |
| 738 | d << " shortcut=" << action->shortcut(); | - |
| 739 | d << " menuRole="; | - |
| 740 | QtDebugUtils::formatQEnum(d, action->menuRole()); | - |
| 741 | d << " visible=" << action->isVisible(); | - |
| 742 | } else { | - |
| 743 | d << '0'; | - |
| 744 | } | - |
| 745 | d << ')'; | - |
| 746 | return d; | - |
| 747 | } | - |
| 748 | | - |
| 749 | | - |
| 750 | | - |
| 751 | | - |
| | |