MCPcopy Create free account
hub / github.com/FreesmTeam/FreesmLauncher / data

Method data

launcher/minecraft/PackProfile.cpp:505–559  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

503}
504
505QVariant 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
561bool PackProfile::setData(const QModelIndex& index, [[maybe_unused]] const QVariant& value, int role)
562{

Callers

nothing calls this directly

Calls 9

QStringClass · 0.85
isEnabledMethod · 0.80
getNameMethod · 0.80
isCustomMethod · 0.80
isValidMethod · 0.45
sizeMethod · 0.45
atMethod · 0.45
getVersionMethod · 0.45
getProblemSeverityMethod · 0.45

Tested by

no test coverage detected