| 468 | } |
| 469 | |
| 470 | QVariant TimerModel::data(const QModelIndex &index, int role) const |
| 471 | { |
| 472 | if (!m_sourceModel || !index.isValid()) |
| 473 | return QVariant(); |
| 474 | |
| 475 | if (role == Qt::DisplayRole) { |
| 476 | const TimerIdInfo *const timerInfo = findTimerInfo(index); |
| 477 | |
| 478 | if (!timerInfo) |
| 479 | return QVariant(); |
| 480 | |
| 481 | switch (index.column()) { |
| 482 | case ObjectNameColumn: |
| 483 | return timerInfo->objectName; |
| 484 | case StateColumn: |
| 485 | return int(timerInfo->state); |
| 486 | case TotalWakeupsColumn: |
| 487 | return timerInfo->totalWakeups; |
| 488 | case WakeupsPerSecColumn: |
| 489 | return timerInfo->wakeupsPerSec; |
| 490 | case TimePerWakeupColumn: |
| 491 | return timerInfo->timePerWakeup; |
| 492 | case MaxTimePerWakeupColumn: |
| 493 | return timerInfo->maxWakeupTime; |
| 494 | case TimerIdColumn: |
| 495 | return timerInfo->timerId; |
| 496 | case ColumnCount: |
| 497 | break; |
| 498 | } |
| 499 | } else if (role == TimerIntervalRole && index.column() == StateColumn) { |
| 500 | const TimerIdInfo *const timerInfo = findTimerInfo(index); |
| 501 | |
| 502 | if (timerInfo) { |
| 503 | return timerInfo->interval; |
| 504 | } |
| 505 | } else if (index.column() == 0) { |
| 506 | auto timerInfo = findTimerInfo(index); |
| 507 | if (!timerInfo) |
| 508 | return QVariant(); |
| 509 | auto object = timerInfo->lastReceiverObject.data(); |
| 510 | if (!object) |
| 511 | return QVariant(); |
| 512 | |
| 513 | switch (role) { |
| 514 | case ObjectModel::ObjectIdRole: { |
| 515 | Q_ASSERT(index.row() >= m_sourceModel->rowCount() || object == index.internalPointer()); |
| 516 | return QVariant::fromValue(ObjectId(object)); |
| 517 | } |
| 518 | case ObjectModel::CreationLocationRole: { |
| 519 | const auto loc = ObjectDataProvider::creationLocation(object); |
| 520 | return loc.isValid() ? QVariant::fromValue(loc) : QVariant(); |
| 521 | } |
| 522 | case ObjectModel::DeclarationLocationRole: { |
| 523 | const auto loc = ObjectDataProvider::declarationLocation(object); |
| 524 | return loc.isValid() ? QVariant::fromValue(loc) : QVariant(); |
| 525 | } |
| 526 | case TimerTypeRole: |
| 527 | return int(timerInfo->type); |
no test coverage detected