| 503 | } |
| 504 | |
| 505 | QVariant PackProfile::data(const QModelIndex& index, int role) const |
| 506 | { |
| 507 | if (!index.isValid()) |
| 508 | return QVariant(); |
| 509 | |
| 510 | int row = index.row(); |
| 511 | int column = index.column(); |
| 512 | |
| 513 | if (row < 0 || row >= d->components.size()) |
| 514 | return QVariant(); |
| 515 | |
| 516 | auto patch = d->components.at(row); |
| 517 | |
| 518 | switch (role) { |
| 519 | case Qt::CheckStateRole: { |
| 520 | switch (column) { |
| 521 | case NameColumn: { |
| 522 | return patch->isEnabled() ? Qt::Checked : Qt::Unchecked; |
| 523 | } |
| 524 | default: |
| 525 | return QVariant(); |
| 526 | } |
| 527 | } |
| 528 | case Qt::DisplayRole: { |
| 529 | switch (column) { |
| 530 | case NameColumn: |
| 531 | return patch->getName(); |
| 532 | case VersionColumn: { |
| 533 | if (patch->isCustom()) { |
| 534 | return QString("%1 (Custom)").arg(patch->getVersion()); |
| 535 | } else { |
| 536 | return patch->getVersion(); |
| 537 | } |
| 538 | } |
| 539 | default: |
| 540 | return QVariant(); |
| 541 | } |
| 542 | } |
| 543 | case Qt::DecorationRole: { |
| 544 | if (column == NameColumn) { |
| 545 | auto severity = patch->getProblemSeverity(); |
| 546 | switch (severity) { |
| 547 | case ProblemSeverity::Warning: |
| 548 | return "warning"; |
| 549 | case ProblemSeverity::Error: |
| 550 | return "error"; |
| 551 | default: |
| 552 | return QVariant(); |
| 553 | } |
| 554 | } |
| 555 | return QVariant(); |
| 556 | } |
| 557 | } |
| 558 | return QVariant(); |
| 559 | } |
| 560 | |
| 561 | bool PackProfile::setData(const QModelIndex& index, [[maybe_unused]] const QVariant& value, int role) |
| 562 | { |
nothing calls this directly
no test coverage detected