| Line | Source | Count |
| 1 | | - |
| 2 | | - |
| 3 | | - |
| 4 | | - |
| 5 | | - |
| 6 | | - |
| 7 | | - |
| 8 | | - |
| 9 | | - |
| 10 | | - |
| 11 | | - |
| 12 | | - |
| 13 | | - |
| 14 | | - |
| 15 | | - |
| 16 | | - |
| 17 | | - |
| 18 | | - |
| 19 | | - |
| 20 | | - |
| 21 | | - |
| 22 | | - |
| 23 | | - |
| 24 | | - |
| 25 | | - |
| 26 | | - |
| 27 | | - |
| 28 | | - |
| 29 | | - |
| 30 | | - |
| 31 | | - |
| 32 | | - |
| 33 | | - |
| 34 | | - |
| 35 | | - |
| 36 | | - |
| 37 | | - |
| 38 | | - |
| 39 | | - |
| 40 | #include "qaction.h" | - |
| 41 | #include "qactiongroup.h" | - |
| 42 | | - |
| 43 | #ifndef QT_NO_ACTION | - |
| 44 | #include "qaction_p.h" | - |
| 45 | #include "qapplication.h" | - |
| 46 | #include "qevent.h" | - |
| 47 | #include "qlist.h" | - |
| 48 | #include <private/qshortcutmap_p.h> | - |
| 49 | #include <private/qapplication_p.h> | - |
| 50 | #include <private/qmenu_p.h> | - |
| 51 | #include <private/qdebug_p.h> | - |
| 52 | | - |
| 53 | #define QAPP_CHECK(functionName) \ | - |
| 54 | if (Q_UNLIKELY(!qApp))) { \ | - |
| 55 | qWarning("QAction: Initialize QApplication before calling '" functionName "'."); \ | - |
| 56 | return; \ | - |
| 57 | } | - |
| 58 | | - |
| 59 | QT_BEGIN_NAMESPACE | - |
| 60 | | - |
| 61 | | - |
| 62 | | - |
| 63 | | - |
| 64 | static QString qt_strippedText(QString s) | - |
| 65 | { | - |
| 66 | s.remove( QString::fromLatin1("...") ); | - |
| 67 | for (int i = 0; i < s.size(); ++i) { | - |
| 68 | if (s.at(i) == QLatin1Char('&')) | - |
| 69 | s.remove(i, 1); | - |
| 70 | } | - |
| 71 | return s.trimmed(); | - |
| 72 | } | - |
| 73 | | - |
| 74 | | - |
| 75 | QActionPrivate::QActionPrivate() : group(0), enabled(1), forceDisabled(0), | - |
| 76 | visible(1), forceInvisible(0), checkable(0), checked(0), separator(0), fontSet(false), | - |
| 77 | iconVisibleInMenu(-1), | - |
| 78 | menuRole(QAction::TextHeuristicRole), | - |
| 79 | priority(QAction::NormalPriority) | - |
| 80 | { | - |
| 81 | #ifndef QT_NO_SHORTCUT | - |
| 82 | shortcutId = 0; | - |
| 83 | shortcutContext = Qt::WindowShortcut; | - |
| 84 | autorepeat = true; | - |
| 85 | #endif | - |
| 86 | } | - |
| 87 | | - |
| 88 | QActionPrivate::~QActionPrivate() | - |
| 89 | { | - |
| 90 | } | - |
| 91 | | - |
| 92 | bool QActionPrivate::showStatusText(QWidget *widget, const QString &str) | - |
| 93 | { | - |
| 94 | #ifdef QT_NO_STATUSTIP | - |
| 95 | Q_UNUSED(widget); | - |
| 96 | Q_UNUSED(str); | - |
| 97 | #else | - |
| 98 | if(QObject *object = widget ? widget : parent) { | - |
| 99 | QStatusTipEvent tip(str); | - |
| 100 | QApplication::sendEvent(object, &tip); | - |
| 101 | return true; | - |
| 102 | } | - |
| 103 | #endif | - |
| 104 | return false; | - |
| 105 | } | - |
| 106 | | - |
| 107 | void QActionPrivate::sendDataChanged() | - |
| 108 | { | - |
| 109 | Q_Q(QAction); | - |
| 110 | QActionEvent e(QEvent::ActionChanged, q); | - |
| 111 | for (int i = 0; i < widgets.size(); ++i) { | - |
| 112 | QWidget *w = widgets.at(i); | - |
| 113 | QApplication::sendEvent(w, &e); | - |
| 114 | } | - |
| 115 | #ifndef QT_NO_GRAPHICSVIEW | - |
| 116 | for (int i = 0; i < graphicsWidgets.size(); ++i) { | - |
| 117 | QGraphicsWidget *w = graphicsWidgets.at(i); | - |
| 118 | QApplication::sendEvent(w, &e); | - |
| 119 | } | - |
| 120 | #endif | - |
| 121 | QApplication::sendEvent(q, &e); | - |
| 122 | | - |
| 123 | emit q->changed(); | - |
| 124 | } | - |
| 125 | | - |
| 126 | #ifndef QT_NO_SHORTCUT | - |
| 127 | void QActionPrivate::redoGrab(QShortcutMap &map) | - |
| 128 | { | - |
| 129 | Q_Q(QAction); | - |
| 130 | if (shortcutId) | - |
| 131 | map.removeShortcut(shortcutId, q); | - |
| 132 | if (shortcut.isEmpty()) | - |
| 133 | return; | - |
| 134 | shortcutId = map.addShortcut(q, shortcut, shortcutContext, qWidgetShortcutContextMatcher); | - |
| 135 | if (!enabled) | - |
| 136 | map.setShortcutEnabled(false, shortcutId, q); | - |
| 137 | if (!autorepeat) | - |
| 138 | map.setShortcutAutoRepeat(false, shortcutId, q); | - |
| 139 | } | - |
| 140 | | - |
| 141 | void QActionPrivate::redoGrabAlternate(QShortcutMap &map) | - |
| 142 | { | - |
| 143 | Q_Q(QAction); | - |
| 144 | for(int i = 0; i < alternateShortcutIds.count(); ++i) { | - |
| 145 | if (const int id = alternateShortcutIds.at(i)) | - |
| 146 | map.removeShortcut(id, q); | - |
| 147 | } | - |
| 148 | alternateShortcutIds.clear(); | - |
| 149 | if (alternateShortcuts.isEmpty()) | - |
| 150 | return; | - |
| 151 | for(int i = 0; i < alternateShortcuts.count(); ++i) { | - |
| 152 | const QKeySequence& alternate = alternateShortcuts.at(i); | - |
| 153 | if (!alternate.isEmpty()) | - |
| 154 | alternateShortcutIds.append(map.addShortcut(q, alternate, shortcutContext, qWidgetShortcutContextMatcher)); | - |
| 155 | else | - |
| 156 | alternateShortcutIds.append(0); | - |
| 157 | } | - |
| 158 | if (!enabled) { | - |
| 159 | for(int i = 0; i < alternateShortcutIds.count(); ++i) { | - |
| 160 | const int id = alternateShortcutIds.at(i); | - |
| 161 | map.setShortcutEnabled(false, id, q); | - |
| 162 | } | - |
| 163 | } | - |
| 164 | if (!autorepeat) { | - |
| 165 | for(int i = 0; i < alternateShortcutIds.count(); ++i) { | - |
| 166 | const int id = alternateShortcutIds.at(i); | - |
| 167 | map.setShortcutAutoRepeat(false, id, q); | - |
| 168 | } | - |
| 169 | } | - |
| 170 | } | - |
| 171 | | - |
| 172 | void QActionPrivate::setShortcutEnabled(bool enable, QShortcutMap &map) | - |
| 173 | { | - |
| 174 | Q_Q(QAction); | - |
| 175 | if (shortcutId) | - |
| 176 | map.setShortcutEnabled(enable, shortcutId, q); | - |
| 177 | for(int i = 0; i < alternateShortcutIds.count(); ++i) { | - |
| 178 | if (const int id = alternateShortcutIds.at(i)) | - |
| 179 | map.setShortcutEnabled(enable, id, q); | - |
| 180 | } | - |
| 181 | } | - |
| 182 | #endif // QT_NO_SHORTCUT | - |
| 183 | | - |
| 184 | | - |
| 185 | | - |
| 186 | | - |
| 187 | | - |
| 188 | | - |
| 189 | | - |
| 190 | | - |
| 191 | | - |
| 192 | | - |
| 193 | | - |
| 194 | | - |
| 195 | | - |
| 196 | | - |
| 197 | | - |
| 198 | | - |
| 199 | | - |
| 200 | | - |
| 201 | | - |
| 202 | | - |
| 203 | | - |
| 204 | | - |
| 205 | | - |
| 206 | | - |
| 207 | | - |
| 208 | | - |
| 209 | | - |
| 210 | | - |
| 211 | | - |
| 212 | | - |
| 213 | | - |
| 214 | | - |
| 215 | | - |
| 216 | | - |
| 217 | | - |
| 218 | | - |
| 219 | | - |
| 220 | | - |
| 221 | | - |
| 222 | | - |
| 223 | | - |
| 224 | | - |
| 225 | | - |
| 226 | | - |
| 227 | | - |
| 228 | | - |
| 229 | | - |
| 230 | | - |
| 231 | | - |
| 232 | | - |
| 233 | | - |
| 234 | | - |
| 235 | | - |
| 236 | | - |
| 237 | | - |
| 238 | | - |
| 239 | | - |
| 240 | | - |
| 241 | | - |
| 242 | | - |
| 243 | | - |
| 244 | | - |
| 245 | | - |
| 246 | | - |
| 247 | | - |
| 248 | | - |
| 249 | | - |
| 250 | | - |
| 251 | | - |
| 252 | | - |
| 253 | | - |
| 254 | | - |
| 255 | | - |
| 256 | | - |
| 257 | | - |
| 258 | | - |
| 259 | | - |
| 260 | | - |
| 261 | | - |
| 262 | | - |
| 263 | | - |
| 264 | | - |
| 265 | | - |
| 266 | | - |
| 267 | | - |
| 268 | | - |
| 269 | | - |
| 270 | | - |
| 271 | | - |
| 272 | | - |
| 273 | | - |
| 274 | | - |
| 275 | | - |
| 276 | | - |
| 277 | | - |
| 278 | | - |
| 279 | | - |
| 280 | | - |
| 281 | QAction::QAction(QObject* parent) | - |
| 282 | : QObject(*(new QActionPrivate), parent) | - |
| 283 | { | - |
| 284 | Q_D(QAction); | - |
| 285 | d->group = qobject_cast<QActionGroup *>(parent); | - |
| 286 | if (d->group) | - |
| 287 | d->group->addAction(this); | - |
| 288 | } | - |
| 289 | | - |
| 290 | | - |
| 291 | | - |
| 292 | | - |
| 293 | | - |
| 294 | | - |
| 295 | | - |
| 296 | | - |
| 297 | | - |
| 298 | | - |
| 299 | | - |
| 300 | | - |
| 301 | | - |
| 302 | | - |
| 303 | | - |
| 304 | QAction::QAction(const QString &text, QObject* parent) | - |
| 305 | : QObject(*(new QActionPrivate), parent) | - |
| 306 | { | - |
| 307 | Q_D(QAction); | - |
| 308 | d->text = text; | - |
| 309 | d->group = qobject_cast<QActionGroup *>(parent); | - |
| 310 | if (d->group) | - |
| 311 | d->group->addAction(this); | - |
| 312 | } | - |
| 313 | | - |
| 314 | | - |
| 315 | | - |
| 316 | | - |
| 317 | | - |
| 318 | | - |
| 319 | | - |
| 320 | | - |
| 321 | | - |
| 322 | | - |
| 323 | | - |
| 324 | | - |
| 325 | | - |
| 326 | QAction::QAction(const QIcon &icon, const QString &text, QObject* parent) | - |
| 327 | : QObject(*(new QActionPrivate), parent) | - |
| 328 | { | - |
| 329 | Q_D(QAction); | - |
| 330 | d->icon = icon; | - |
| 331 | d->text = text; | - |
| 332 | d->group = qobject_cast<QActionGroup *>(parent); | - |
| 333 | if (d->group) | - |
| 334 | d->group->addAction(this); | - |
| 335 | } | - |
| 336 | | - |
| 337 | | - |
| 338 | | - |
| 339 | | - |
| 340 | QAction::QAction(QActionPrivate &dd, QObject *parent) | - |
| 341 | : QObject(dd, parent) | - |
| 342 | { | - |
| 343 | Q_D(QAction); | - |
| 344 | d->group = qobject_cast<QActionGroup *>(parent); | - |
| 345 | if (d->group) | - |
| 346 | d->group->addAction(this); | - |
| 347 | } | - |
| 348 | | - |
| 349 | | - |
| 350 | | - |
| 351 | | - |
| 352 | QWidget *QAction::parentWidget() const | - |
| 353 | { | - |
| 354 | QObject *ret = parent(); | - |
| 355 | while (ret && !ret->isWidgetType()) | - |
| 356 | ret = ret->parent(); | - |
| 357 | return (QWidget*)ret; | - |
| 358 | } | - |
| 359 | | - |
| 360 | | - |
| 361 | | - |
| 362 | | - |
| 363 | | - |
| 364 | | - |
| 365 | | - |
| 366 | QList<QWidget *> QAction::associatedWidgets() const | - |
| 367 | { | - |
| 368 | Q_D(const QAction); | - |
| 369 | return d->widgets; | - |
| 370 | } | - |
| 371 | | - |
| 372 | #ifndef QT_NO_GRAPHICSVIEW | - |
| 373 | | - |
| 374 | | - |
| 375 | | - |
| 376 | | - |
| 377 | | - |
| 378 | | - |
| 379 | QList<QGraphicsWidget *> QAction::associatedGraphicsWidgets() const | - |
| 380 | { | - |
| 381 | Q_D(const QAction); | - |
| 382 | return d->graphicsWidgets; | - |
| 383 | } | - |
| 384 | #endif | - |
| 385 | | - |
| 386 | #ifndef QT_NO_SHORTCUT | - |
| 387 | | - |
| 388 | | - |
| 389 | | - |
| 390 | | - |
| 391 | | - |
| 392 | | - |
| 393 | | - |
| 394 | void QAction::setShortcut(const QKeySequence &shortcut) | - |
| 395 | { | - |
| 396 | QAPP_CHECK("setShortcut"); | - |
| 397 | | - |
| 398 | Q_D(QAction); | - |
| 399 | if (d->shortcut == shortcut) | - |
| 400 | return; | - |
| 401 | | - |
| 402 | d->shortcut = shortcut; | - |
| 403 | d->redoGrab(qApp->d_func()->shortcutMap); | - |
| 404 | d->sendDataChanged(); | - |
| 405 | } | - |
| 406 | | - |
| 407 | | - |
| 408 | | - |
| 409 | | - |
| 410 | | - |
| 411 | | - |
| 412 | | - |
| 413 | | - |
| 414 | | - |
| 415 | void QAction::setShortcuts(const QList<QKeySequence> &shortcuts) | - |
| 416 | { | - |
| 417 | Q_D(QAction); | - |
| 418 | | - |
| 419 | QList <QKeySequence> listCopy = shortcuts; | - |
| 420 | | - |
| 421 | QKeySequence primary; | - |
| 422 | if (!listCopy.isEmpty()) | - |
| 423 | primary = listCopy.takeFirst(); | - |
| 424 | | - |
| 425 | if (d->shortcut == primary && d->alternateShortcuts == listCopy) | - |
| 426 | return; | - |
| 427 | | - |
| 428 | QAPP_CHECK("setShortcuts"); | - |
| 429 | | - |
| 430 | d->shortcut = primary; | - |
| 431 | d->alternateShortcuts = listCopy; | - |
| 432 | d->redoGrab(qApp->d_func()->shortcutMap); | - |
| 433 | d->redoGrabAlternate(qApp->d_func()->shortcutMap); | - |
| 434 | d->sendDataChanged(); | - |
| 435 | } | - |
| 436 | | - |
| 437 | | - |
| 438 | | - |
| 439 | | - |
| 440 | | - |
| 441 | | - |
| 442 | | - |
| 443 | | - |
| 444 | | - |
| 445 | | - |
| 446 | | - |
| 447 | void QAction::setShortcuts(QKeySequence::StandardKey key) | - |
| 448 | { | - |
| 449 | QList <QKeySequence> list = QKeySequence::keyBindings(key); | - |
| 450 | setShortcuts(list); | - |
| 451 | } | - |
| 452 | | - |
| 453 | | - |
| 454 | | - |
| 455 | | - |
| 456 | | - |
| 457 | | - |
| 458 | QKeySequence QAction::shortcut() const | - |
| 459 | { | - |
| 460 | Q_D(const QAction); | - |
| 461 | return d->shortcut; | - |
| 462 | } | - |
| 463 | | - |
| 464 | | - |
| 465 | | - |
| 466 | | - |
| 467 | | - |
| 468 | | - |
| 469 | | - |
| 470 | | - |
| 471 | | - |
| 472 | QList<QKeySequence> QAction::shortcuts() const | - |
| 473 | { | - |
| 474 | Q_D(const QAction); | - |
| 475 | QList <QKeySequence> shortcuts; | - |
| 476 | if (!d->shortcut.isEmpty()) | - |
| 477 | shortcuts << d->shortcut; | - |
| 478 | if (!d->alternateShortcuts.isEmpty()) | - |
| 479 | shortcuts << d->alternateShortcuts; | - |
| 480 | return shortcuts; | - |
| 481 | } | - |
| 482 | | - |
| 483 | | - |
| 484 | | - |
| 485 | | - |
| 486 | | - |
| 487 | | - |
| 488 | | - |
| 489 | | - |
| 490 | void QAction::setShortcutContext(Qt::ShortcutContext context) | - |
| 491 | { | - |
| 492 | Q_D(QAction); | - |
| 493 | if (d->shortcutContext == context) | - |
| 494 | return; | - |
| 495 | QAPP_CHECK("setShortcutContext"); | - |
| 496 | d->shortcutContext = context; | - |
| 497 | d->redoGrab(qApp->d_func()->shortcutMap); | - |
| 498 | d->redoGrabAlternate(qApp->d_func()->shortcutMap); | - |
| 499 | d->sendDataChanged(); | - |
| 500 | } | - |
| 501 | | - |
| 502 | Qt::ShortcutContext QAction::shortcutContext() const | - |
| 503 | { | - |
| 504 | Q_D(const QAction); | - |
| 505 | return d->shortcutContext; | - |
| 506 | } | - |
| 507 | | - |
| 508 | | - |
| 509 | | - |
| 510 | | - |
| 511 | | - |
| 512 | | - |
| 513 | | - |
| 514 | | - |
| 515 | | - |
| 516 | | - |
| 517 | | - |
| 518 | void QAction::setAutoRepeat(bool on) | - |
| 519 | { | - |
| 520 | Q_D(QAction); | - |
| 521 | if (d->autorepeat == on) | - |
| 522 | return; | - |
| 523 | QAPP_CHECK("setAutoRepeat"); | - |
| 524 | d->autorepeat = on; | - |
| 525 | d->redoGrab(qApp->d_func()->shortcutMap); | - |
| 526 | d->redoGrabAlternate(qApp->d_func()->shortcutMap); | - |
| 527 | d->sendDataChanged(); | - |
| 528 | } | - |
| 529 | | - |
| 530 | bool QAction::autoRepeat() const | - |
| 531 | { | - |
| 532 | Q_D(const QAction); | - |
| 533 | return d->autorepeat; | - |
| 534 | } | - |
| 535 | #endif // QT_NO_SHORTCUT | - |
| 536 | | - |
| 537 | | - |
| 538 | | - |
| 539 | | - |
| 540 | | - |
| 541 | | - |
| 542 | | - |
| 543 | | - |
| 544 | | - |
| 545 | | - |
| 546 | | - |
| 547 | | - |
| 548 | | - |
| 549 | void QAction::setFont(const QFont &font) | - |
| 550 | { | - |
| 551 | Q_D(QAction); | - |
| 552 | if (d->font == font) | - |
| 553 | return; | - |
| 554 | | - |
| 555 | d->fontSet = true; | - |
| 556 | d->font = font; | - |
| 557 | d->sendDataChanged(); | - |
| 558 | } | - |
| 559 | | - |
| 560 | QFont QAction::font() const | - |
| 561 | { | - |
| 562 | Q_D(const QAction); | - |
| 563 | return d->font; | - |
| 564 | } | - |
| 565 | | - |
| 566 | | - |
| 567 | | - |
| 568 | | - |
| 569 | | - |
| 570 | QAction::~QAction() | - |
| 571 | { | - |
| 572 | Q_D(QAction); | - |
| 573 | for (int i = d->widgets.size()-1; i >= 0; --i) { | - |
| 574 | QWidget *w = d->widgets.at(i); | - |
| 575 | w->removeAction(this); | - |
| 576 | } | - |
| 577 | #ifndef QT_NO_GRAPHICSVIEW | - |
| 578 | for (int i = d->graphicsWidgets.size()-1; i >= 0; --i) { | - |
| 579 | QGraphicsWidget *w = d->graphicsWidgets.at(i); | - |
| 580 | w->removeAction(this); | - |
| 581 | } | - |
| 582 | #endif | - |
| 583 | if (d->group) | - |
| 584 | d->group->removeAction(this); | - |
| 585 | #ifndef QT_NO_SHORTCUT | - |
| 586 | if (d->shortcutId && qApp) { | - |
| 587 | qApp->d_func()->shortcutMap.removeShortcut(d->shortcutId, this); | - |
| 588 | for(int i = 0; i < d->alternateShortcutIds.count(); ++i) { | - |
| 589 | const int id = d->alternateShortcutIds.at(i); | - |
| 590 | qApp->d_func()->shortcutMap.removeShortcut(id, this); | - |
| 591 | } | - |
| 592 | } | - |
| 593 | #endif | - |
| 594 | } | - |
| 595 | | - |
| 596 | | - |
| 597 | | - |
| 598 | | - |
| 599 | | - |
| 600 | | - |
| 601 | | - |
| 602 | | - |
| 603 | | - |
| 604 | void QAction::setActionGroup(QActionGroup *group) | - |
| 605 | { | - |
| 606 | Q_D(QAction); | - |
| 607 | if(group == d->group)| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 608 | return; never executed: return; | 0 |
| 609 | | - |
| 610 | if(d->group)| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 611 | d->group->removeAction(this); never executed: d->group->removeAction(this); | 0 |
| 612 | d->group = group; | - |
| 613 | if(group)| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 614 | group->addAction(this); never executed: group->addAction(this); | 0 |
| 615 | d->sendDataChanged(); | - |
| 616 | } never executed: end of block | 0 |
| 617 | | - |
| 618 | | - |
| 619 | | - |
| 620 | | - |
| 621 | | - |
| 622 | | - |
| 623 | | - |
| 624 | QActionGroup *QAction::actionGroup() const | - |
| 625 | { | - |
| 626 | Q_D(const QAction); | - |
| 627 | return d->group; | - |
| 628 | } | - |
| 629 | | - |
| 630 | | - |
| 631 | | - |
| 632 | | - |
| 633 | | - |
| 634 | | - |
| 635 | | - |
| 636 | | - |
| 637 | | - |
| 638 | | - |
| 639 | | - |
| 640 | | - |
| 641 | | - |
| 642 | void QAction::setIcon(const QIcon &icon) | - |
| 643 | { | - |
| 644 | Q_D(QAction); | - |
| 645 | d->icon = icon; | - |
| 646 | d->sendDataChanged(); | - |
| 647 | } | - |
| 648 | | - |
| 649 | QIcon QAction::icon() const | - |
| 650 | { | - |
| 651 | Q_D(const QAction); | - |
| 652 | return d->icon; | - |
| 653 | } | - |
| 654 | | - |
| 655 | #ifndef QT_NO_MENU | - |
| 656 | | - |
| 657 | | - |
| 658 | | - |
| 659 | | - |
| 660 | | - |
| 661 | | - |
| 662 | | - |
| 663 | QMenu *QAction::menu() const | - |
| 664 | { | - |
| 665 | Q_D(const QAction); | - |
| 666 | return d->menu; | - |
| 667 | } | - |
| 668 | | - |
| 669 | | - |
| 670 | | - |
| 671 | | - |
| 672 | void QAction::setMenu(QMenu *menu) | - |
| 673 | { | - |
| 674 | Q_D(QAction); | - |
| 675 | if (d->menu) | - |
| 676 | d->menu->d_func()->setOverrideMenuAction(0); | - |
| 677 | d->menu = menu; | - |
| 678 | if (menu) | - |
| 679 | menu->d_func()->setOverrideMenuAction(this); | - |
| 680 | d->sendDataChanged(); | - |
| 681 | } | - |
| 682 | #endif // QT_NO_MENU | - |
| 683 | | - |
| 684 | | - |
| 685 | | - |
| 686 | | - |
| 687 | | - |
| 688 | | - |
| 689 | | - |
| 690 | | - |
| 691 | | - |
| 692 | | - |
| 693 | void QAction::setSeparator(bool b) | - |
| 694 | { | - |
| 695 | Q_D(QAction); | - |
| 696 | if (d->separator == b) | - |
| 697 | return; | - |
| 698 | | - |
| 699 | d->separator = b; | - |
| 700 | d->sendDataChanged(); | - |
| 701 | } | - |
| 702 | | - |
| 703 | | - |
| 704 | | - |
| 705 | | - |
| 706 | | - |
| 707 | | - |
| 708 | | - |
| 709 | bool QAction::isSeparator() const | - |
| 710 | { | - |
| 711 | Q_D(const QAction); | - |
| 712 | return d->separator; | - |
| 713 | } | - |
| 714 | | - |
| 715 | | - |
| 716 | | - |
| 717 | | - |
| 718 | | - |
| 719 | | - |
| 720 | | - |
| 721 | | - |
| 722 | | - |
| 723 | | - |
| 724 | | - |
| 725 | | - |
| 726 | | - |
| 727 | void QAction::setText(const QString &text) | - |
| 728 | { | - |
| 729 | Q_D(QAction); | - |
| 730 | if (d->text == text) | - |
| 731 | return; | - |
| 732 | | - |
| 733 | d->text = text; | - |
| 734 | d->sendDataChanged(); | - |
| 735 | } | - |
| 736 | | - |
| 737 | QString QAction::text() const | - |
| 738 | { | - |
| 739 | Q_D(const QAction); | - |
| 740 | QString s = d->text; | - |
| 741 | if(s.isEmpty()) { | - |
| 742 | s = d->iconText; | - |
| 743 | s.replace(QLatin1Char('&'), QLatin1String("&&")); | - |
| 744 | } | - |
| 745 | return s; | - |
| 746 | } | - |
| 747 | | - |
| 748 | | - |
| 749 | | - |
| 750 | | - |
| 751 | | - |
| 752 | | - |
| 753 | | - |
| 754 | | - |
| 755 | | - |
| 756 | | - |
| 757 | | - |
| 758 | | - |
| 759 | | - |
| 760 | | - |
| 761 | | - |
| 762 | | - |
| 763 | | - |
| 764 | | - |
| 765 | | - |
| 766 | | - |
| 767 | | - |
| 768 | | - |
| 769 | | - |
| 770 | | - |
| 771 | void QAction::setIconText(const QString &text) | - |
| 772 | { | - |
| 773 | Q_D(QAction); | - |
| 774 | if (d->iconText == text) | - |
| 775 | return; | - |
| 776 | | - |
| 777 | d->iconText = text; | - |
| 778 | d->sendDataChanged(); | - |
| 779 | } | - |
| 780 | | - |
| 781 | QString QAction::iconText() const | - |
| 782 | { | - |
| 783 | Q_D(const QAction); | - |
| 784 | if (d->iconText.isEmpty()) | - |
| 785 | return qt_strippedText(d->text); | - |
| 786 | return d->iconText; | - |
| 787 | } | - |
| 788 | | - |
| 789 | | - |
| 790 | | - |
| 791 | | - |
| 792 | | - |
| 793 | | - |
| 794 | | - |
| 795 | | - |
| 796 | | - |
| 797 | | - |
| 798 | | - |
| 799 | | - |
| 800 | void QAction::setToolTip(const QString &tooltip) | - |
| 801 | { | - |
| 802 | Q_D(QAction); | - |
| 803 | if (d->tooltip == tooltip) | - |
| 804 | return; | - |
| 805 | | - |
| 806 | d->tooltip = tooltip; | - |
| 807 | d->sendDataChanged(); | - |
| 808 | } | - |
| 809 | | - |
| 810 | QString QAction::toolTip() const | - |
| 811 | { | - |
| 812 | Q_D(const QAction); | - |
| 813 | if (d->tooltip.isEmpty()) { | - |
| 814 | if (!d->text.isEmpty()) | - |
| 815 | return qt_strippedText(d->text); | - |
| 816 | return qt_strippedText(d->iconText); | - |
| 817 | } | - |
| 818 | return d->tooltip; | - |
| 819 | } | - |
| 820 | | - |
| 821 | | - |
| 822 | | - |
| 823 | | - |
| 824 | | - |
| 825 | | - |
| 826 | | - |
| 827 | | - |
| 828 | | - |
| 829 | | - |
| 830 | | - |
| 831 | | - |
| 832 | void QAction::setStatusTip(const QString &statustip) | - |
| 833 | { | - |
| 834 | Q_D(QAction); | - |
| 835 | if (d->statustip == statustip) | - |
| 836 | return; | - |
| 837 | | - |
| 838 | d->statustip = statustip; | - |
| 839 | d->sendDataChanged(); | - |
| 840 | } | - |
| 841 | | - |
| 842 | QString QAction::statusTip() const | - |
| 843 | { | - |
| 844 | Q_D(const QAction); | - |
| 845 | return d->statustip; | - |
| 846 | } | - |
| 847 | | - |
| 848 | | - |
| 849 | | - |
| 850 | | - |
| 851 | | - |
| 852 | | - |
| 853 | | - |
| 854 | | - |
| 855 | | - |
| 856 | | - |
| 857 | | - |
| 858 | void QAction::setWhatsThis(const QString &whatsthis) | - |
| 859 | { | - |
| 860 | Q_D(QAction); | - |
| 861 | if (d->whatsthis == whatsthis) | - |
| 862 | return; | - |
| 863 | | - |
| 864 | d->whatsthis = whatsthis; | - |
| 865 | d->sendDataChanged(); | - |
| 866 | } | - |
| 867 | | - |
| 868 | QString QAction::whatsThis() const | - |
| 869 | { | - |
| 870 | Q_D(const QAction); | - |
| 871 | return d->whatsthis; | - |
| 872 | } | - |
| 873 | | - |
| 874 | | - |
| 875 | | - |
| 876 | | - |
| 877 | | - |
| 878 | | - |
| 879 | | - |
| 880 | | - |
| 881 | | - |
| 882 | | - |
| 883 | | - |
| 884 | | - |
| 885 | | - |
| 886 | | - |
| 887 | | - |
| 888 | | - |
| 889 | | - |
| 890 | | - |
| 891 | | - |
| 892 | | - |
| 893 | | - |
| 894 | | - |
| 895 | | - |
| 896 | | - |
| 897 | | - |
| 898 | | - |
| 899 | | - |
| 900 | | - |
| 901 | | - |
| 902 | | - |
| 903 | | - |
| 904 | | - |
| 905 | void QAction::setPriority(Priority priority) | - |
| 906 | { | - |
| 907 | Q_D(QAction); | - |
| 908 | if (d->priority == priority) | - |
| 909 | return; | - |
| 910 | | - |
| 911 | d->priority = priority; | - |
| 912 | d->sendDataChanged(); | - |
| 913 | } | - |
| 914 | | - |
| 915 | QAction::Priority QAction::priority() const | - |
| 916 | { | - |
| 917 | Q_D(const QAction); | - |
| 918 | return d->priority; | - |
| 919 | } | - |
| 920 | | - |
| 921 | | - |
| 922 | | - |
| 923 | | - |
| 924 | | - |
| 925 | | - |
| 926 | | - |
| 927 | | - |
| 928 | | - |
| 929 | | - |
| 930 | | - |
| 931 | | - |
| 932 | | - |
| 933 | | - |
| 934 | | - |
| 935 | | - |
| 936 | | - |
| 937 | | - |
| 938 | | - |
| 939 | | - |
| 940 | void QAction::setCheckable(bool b) | - |
| 941 | { | - |
| 942 | Q_D(QAction); | - |
| 943 | if (d->checkable == b) | - |
| 944 | return; | - |
| 945 | | - |
| 946 | d->checkable = b; | - |
| 947 | d->checked = false; | - |
| 948 | d->sendDataChanged(); | - |
| 949 | } | - |
| 950 | | - |
| 951 | bool QAction::isCheckable() const | - |
| 952 | { | - |
| 953 | Q_D(const QAction); | - |
| 954 | return d->checkable; | - |
| 955 | } | - |
| 956 | | - |
| 957 | | - |
| 958 | | - |
| 959 | | - |
| 960 | | - |
| 961 | | - |
| 962 | | - |
| 963 | void QAction::toggle() | - |
| 964 | { | - |
| 965 | Q_D(QAction); | - |
| 966 | setChecked(!d->checked); | - |
| 967 | } | - |
| 968 | | - |
| 969 | | - |
| 970 | | - |
| 971 | | - |
| 972 | | - |
| 973 | | - |
| 974 | | - |
| 975 | | - |
| 976 | | - |
| 977 | | - |
| 978 | void QAction::setChecked(bool b) | - |
| 979 | { | - |
| 980 | Q_D(QAction); | - |
| 981 | if (!d->checkable || d->checked == b) | - |
| 982 | return; | - |
| 983 | | - |
| 984 | QPointer<QAction> guard(this); | - |
| 985 | d->checked = b; | - |
| 986 | d->sendDataChanged(); | - |
| 987 | if (guard) | - |
| 988 | emit toggled(b); | - |
| 989 | } | - |
| 990 | | - |
| 991 | bool QAction::isChecked() const | - |
| 992 | { | - |
| 993 | Q_D(const QAction); | - |
| 994 | return d->checked; | - |
| 995 | } | - |
| 996 | | - |
| 997 | | - |
| 998 | | - |
| 999 | | - |
| 1000 | | - |
| 1001 | | - |
| 1002 | | - |
| 1003 | | - |
| 1004 | | - |
| 1005 | | - |
| 1006 | | - |
| 1007 | | - |
| 1008 | | - |
| 1009 | | - |
| 1010 | | - |
| 1011 | | - |
| 1012 | | - |
| 1013 | | - |
| 1014 | | - |
| 1015 | | - |
| 1016 | | - |
| 1017 | | - |
| 1018 | | - |
| 1019 | | - |
| 1020 | | - |
| 1021 | | - |
| 1022 | | - |
| 1023 | | - |
| 1024 | | - |
| 1025 | | - |
| 1026 | void QAction::setEnabled(bool b) | - |
| 1027 | { | - |
| 1028 | Q_D(QAction); | - |
| 1029 | if (b == d->enabled && b != d->forceDisabled) | - |
| 1030 | return; | - |
| 1031 | d->forceDisabled = !b; | - |
| 1032 | if (b && (!d->visible || (d->group && !d->group->isEnabled()))) | - |
| 1033 | return; | - |
| 1034 | QAPP_CHECK("setEnabled"); | - |
| 1035 | d->enabled = b; | - |
| 1036 | #ifndef QT_NO_SHORTCUT | - |
| 1037 | d->setShortcutEnabled(b, qApp->d_func()->shortcutMap); | - |
| 1038 | #endif | - |
| 1039 | d->sendDataChanged(); | - |
| 1040 | } | - |
| 1041 | | - |
| 1042 | bool QAction::isEnabled() const | - |
| 1043 | { | - |
| 1044 | Q_D(const QAction); | - |
| 1045 | return d->enabled; | - |
| 1046 | } | - |
| 1047 | | - |
| 1048 | | - |
| 1049 | | - |
| 1050 | | - |
| 1051 | | - |
| 1052 | | - |
| 1053 | | - |
| 1054 | | - |
| 1055 | | - |
| 1056 | | - |
| 1057 | | - |
| 1058 | | - |
| 1059 | | - |
| 1060 | | - |
| 1061 | void QAction::setVisible(bool b) | - |
| 1062 | { | - |
| 1063 | Q_D(QAction); | - |
| 1064 | if (b == d->visible && b != d->forceInvisible) | - |
| 1065 | return; | - |
| 1066 | QAPP_CHECK("setVisible"); | - |
| 1067 | d->forceInvisible = !b; | - |
| 1068 | d->visible = b; | - |
| 1069 | d->enabled = b && !d->forceDisabled && (!d->group || d->group->isEnabled()) ; | - |
| 1070 | #ifndef QT_NO_SHORTCUT | - |
| 1071 | d->setShortcutEnabled(d->enabled, qApp->d_func()->shortcutMap); | - |
| 1072 | #endif | - |
| 1073 | d->sendDataChanged(); | - |
| 1074 | } | - |
| 1075 | | - |
| 1076 | | - |
| 1077 | bool QAction::isVisible() const | - |
| 1078 | { | - |
| 1079 | Q_D(const QAction); | - |
| 1080 | return d->visible; | - |
| 1081 | } | - |
| 1082 | | - |
| 1083 | | - |
| 1084 | | - |
| 1085 | | - |
| 1086 | bool | - |
| 1087 | QAction::event(QEvent *e) | - |
| 1088 | { | - |
| 1089 | #ifndef QT_NO_SHORTCUT | - |
| 1090 | if (e->type() == QEvent::Shortcut) { | - |
| 1091 | QShortcutEvent *se = static_cast<QShortcutEvent *>(e); | - |
| 1092 | Q_ASSERT_X(se->key() == d_func()->shortcut || d_func()->alternateShortcuts.contains(se->key()), | - |
| 1093 | "QAction::event", | - |
| 1094 | "Received shortcut event from incorrect shortcut"); | - |
| 1095 | if (se->isAmbiguous()) | - |
| 1096 | qWarning("QAction::eventFilter: Ambiguous shortcut overload: %s", se->key().toString(QKeySequence::NativeText).toLatin1().constData()); | - |
| 1097 | else | - |
| 1098 | activate(Trigger); | - |
| 1099 | return true; | - |
| 1100 | } | - |
| 1101 | #endif | - |
| 1102 | return QObject::event(e); | - |
| 1103 | } | - |
| 1104 | | - |
| 1105 | | - |
| 1106 | | - |
| 1107 | | - |
| 1108 | | - |
| 1109 | | - |
| 1110 | QVariant | - |
| 1111 | QAction::data() const | - |
| 1112 | { | - |
| 1113 | Q_D(const QAction); | - |
| 1114 | return d->userData; | - |
| 1115 | } | - |
| 1116 | | - |
| 1117 | | - |
| 1118 | | - |
| 1119 | | - |
| 1120 | | - |
| 1121 | | - |
| 1122 | | - |
| 1123 | | - |
| 1124 | void | - |
| 1125 | QAction::setData(const QVariant &data) | - |
| 1126 | { | - |
| 1127 | Q_D(QAction); | - |
| 1128 | d->userData = data; | - |
| 1129 | d->sendDataChanged(); | - |
| 1130 | } | - |
| 1131 | | - |
| 1132 | | - |
| 1133 | | - |
| 1134 | | - |
| 1135 | | - |
| 1136 | | - |
| 1137 | | - |
| 1138 | | - |
| 1139 | | - |
| 1140 | | - |
| 1141 | | - |
| 1142 | bool | - |
| 1143 | QAction::showStatusText(QWidget *widget) | - |
| 1144 | { | - |
| 1145 | return d_func()->showStatusText(widget, statusTip()); | - |
| 1146 | } | - |
| 1147 | | - |
| 1148 | | - |
| 1149 | | - |
| 1150 | | - |
| 1151 | | - |
| 1152 | | - |
| 1153 | | - |
| 1154 | void QAction::activate(ActionEvent event) | - |
| 1155 | { | - |
| 1156 | Q_D(QAction); | - |
| 1157 | if(event == Trigger) { | - |
| 1158 | QPointer<QObject> guard = this; | - |
| 1159 | if(d->checkable) { | - |
| 1160 | | - |
| 1161 | if (d->checked && (d->group && d->group->isExclusive() | - |
| 1162 | && d->group->checkedAction() == this)) { | - |
| 1163 | if (!guard.isNull()) | - |
| 1164 | emit triggered(true); | - |
| 1165 | return; | - |
| 1166 | } | - |
| 1167 | setChecked(!d->checked); | - |
| 1168 | } | - |
| 1169 | if (!guard.isNull()) | - |
| 1170 | emit triggered(d->checked); | - |
| 1171 | } else if(event == Hover) { | - |
| 1172 | emit hovered(); | - |
| 1173 | } | - |
| 1174 | } | - |
| 1175 | | - |
| 1176 | | - |
| 1177 | | - |
| 1178 | | - |
| 1179 | | - |
| 1180 | | - |
| 1181 | | - |
| 1182 | | - |
| 1183 | | - |
| 1184 | | - |
| 1185 | | - |
| 1186 | | - |
| 1187 | | - |
| 1188 | | - |
| 1189 | | - |
| 1190 | | - |
| 1191 | | - |
| 1192 | | - |
| 1193 | | - |
| 1194 | | - |
| 1195 | | - |
| 1196 | | - |
| 1197 | | - |
| 1198 | | - |
| 1199 | | - |
| 1200 | | - |
| 1201 | | - |
| 1202 | | - |
| 1203 | | - |
| 1204 | | - |
| 1205 | | - |
| 1206 | | - |
| 1207 | | - |
| 1208 | | - |
| 1209 | | - |
| 1210 | | - |
| 1211 | | - |
| 1212 | | - |
| 1213 | | - |
| 1214 | | - |
| 1215 | | - |
| 1216 | | - |
| 1217 | | - |
| 1218 | | - |
| 1219 | | - |
| 1220 | | - |
| 1221 | | - |
| 1222 | | - |
| 1223 | | - |
| 1224 | | - |
| 1225 | | - |
| 1226 | | - |
| 1227 | | - |
| 1228 | | - |
| 1229 | | - |
| 1230 | | - |
| 1231 | | - |
| 1232 | | - |
| 1233 | | - |
| 1234 | | - |
| 1235 | | - |
| 1236 | | - |
| 1237 | | - |
| 1238 | | - |
| 1239 | | - |
| 1240 | | - |
| 1241 | | - |
| 1242 | | - |
| 1243 | | - |
| 1244 | | - |
| 1245 | | - |
| 1246 | | - |
| 1247 | | - |
| 1248 | void QAction::setMenuRole(MenuRole menuRole) | - |
| 1249 | { | - |
| 1250 | Q_D(QAction); | - |
| 1251 | if (d->menuRole == menuRole) | - |
| 1252 | return; | - |
| 1253 | | - |
| 1254 | d->menuRole = menuRole; | - |
| 1255 | d->sendDataChanged(); | - |
| 1256 | } | - |
| 1257 | | - |
| 1258 | QAction::MenuRole QAction::menuRole() const | - |
| 1259 | { | - |
| 1260 | Q_D(const QAction); | - |
| 1261 | return d->menuRole; | - |
| 1262 | } | - |
| 1263 | | - |
| 1264 | | - |
| 1265 | | - |
| 1266 | | - |
| 1267 | | - |
| 1268 | | - |
| 1269 | | - |
| 1270 | | - |
| 1271 | | - |
| 1272 | | - |
| 1273 | | - |
| 1274 | | - |
| 1275 | | - |
| 1276 | | - |
| 1277 | | - |
| 1278 | | - |
| 1279 | | - |
| 1280 | | - |
| 1281 | | - |
| 1282 | void QAction::setIconVisibleInMenu(bool visible) | - |
| 1283 | { | - |
| 1284 | Q_D(QAction); | - |
| 1285 | if (d->iconVisibleInMenu == -1 || visible != bool(d->iconVisibleInMenu)) { | - |
| 1286 | int oldValue = d->iconVisibleInMenu; | - |
| 1287 | d->iconVisibleInMenu = visible; | - |
| 1288 | | - |
| 1289 | if (oldValue != -1 | - |
| 1290 | || (oldValue == -1 | - |
| 1291 | && visible == !QApplication::instance()->testAttribute(Qt::AA_DontShowIconsInMenus))) { | - |
| 1292 | d->sendDataChanged(); | - |
| 1293 | } | - |
| 1294 | } | - |
| 1295 | } | - |
| 1296 | | - |
| 1297 | bool QAction::isIconVisibleInMenu() const | - |
| 1298 | { | - |
| 1299 | Q_D(const QAction); | - |
| 1300 | if (d->iconVisibleInMenu == -1) { | - |
| 1301 | return !QApplication::instance()->testAttribute(Qt::AA_DontShowIconsInMenus); | - |
| 1302 | } | - |
| 1303 | return d->iconVisibleInMenu; | - |
| 1304 | } | - |
| 1305 | | - |
| 1306 | #ifndef QT_NO_DEBUG_STREAM | - |
| 1307 | Q_WIDGETS_EXPORT QDebug operator<<(QDebug d, const QAction *action) | - |
| 1308 | { | - |
| 1309 | QDebugStateSaver saver(d); | - |
| 1310 | d.nospace(); | - |
| 1311 | d << "QAction(" << static_cast<const void *>(action); | - |
| 1312 | if (action) { | - |
| 1313 | d << " text=" << action->text(); | - |
| 1314 | if (!action->toolTip().isEmpty()) | - |
| 1315 | d << " toolTip=" << action->toolTip(); | - |
| 1316 | if (action->isCheckable()) | - |
| 1317 | d << " checked=" << action->isChecked(); | - |
| 1318 | if (!action->shortcut().isEmpty()) | - |
| 1319 | d << " shortcut=" << action->shortcut(); | - |
| 1320 | d << " menuRole="; | - |
| 1321 | QtDebugUtils::formatQEnum(d, action->menuRole()); | - |
| 1322 | d << " visible=" << action->isVisible(); | - |
| 1323 | } else { | - |
| 1324 | d << '0'; | - |
| 1325 | } | - |
| 1326 | d << ')'; | - |
| 1327 | return d; | - |
| 1328 | } | - |
| 1329 | #endif // QT_NO_DEBUG_STREAM | - |
| 1330 | | - |
| 1331 | QT_END_NAMESPACE | - |
| 1332 | | - |
| 1333 | #include "moc_qaction.cpp" | - |
| 1334 | | - |
| 1335 | #endif // QT_NO_ACTION | - |
| | |