| 275 | } |
| 276 | |
| 277 | QVariant AccountList::data(const QModelIndex &index, int role) const |
| 278 | { |
| 279 | if (!index.isValid()) |
| 280 | return QVariant(); |
| 281 | |
| 282 | if (index.row() > count()) |
| 283 | return QVariant(); |
| 284 | |
| 285 | MinecraftAccountPtr account = at(index.row()); |
| 286 | |
| 287 | switch (role) |
| 288 | { |
| 289 | case Qt::DisplayRole: |
| 290 | switch (index.column()) |
| 291 | { |
| 292 | case ProfileNameColumn: { |
| 293 | return account->profileName(); |
| 294 | } |
| 295 | |
| 296 | case NameColumn: |
| 297 | return account->accountDisplayString(); |
| 298 | |
| 299 | case TypeColumn: { |
| 300 | auto typeStr = account->typeString(); |
| 301 | typeStr[0] = typeStr[0].toUpper(); |
| 302 | return typeStr; |
| 303 | } |
| 304 | |
| 305 | case StatusColumn: { |
| 306 | switch(account->accountState()) { |
| 307 | case AccountState::Unchecked: { |
| 308 | return tr("Unchecked", "Account status"); |
| 309 | } |
| 310 | case AccountState::Offline: { |
| 311 | return tr("Offline", "Account status"); |
| 312 | } |
| 313 | case AccountState::Online: { |
| 314 | return tr("Ready", "Account status"); |
| 315 | } |
| 316 | case AccountState::Working: { |
| 317 | return tr("Working", "Account status"); |
| 318 | } |
| 319 | case AccountState::Errored: { |
| 320 | return tr("Errored", "Account status"); |
| 321 | } |
| 322 | case AccountState::Expired: { |
| 323 | return tr("Expired", "Account status"); |
| 324 | } |
| 325 | case AccountState::Disabled: { |
| 326 | return tr("Disabled", "Account status"); |
| 327 | } |
| 328 | case AccountState::Gone: { |
| 329 | return tr("Gone", "Account status"); |
| 330 | } |
| 331 | case AccountState::Queued: { |
| 332 | qWarning() << "Unhandled account state Queued"; |
| 333 | [[fallthrough]]; |
| 334 | } |
nothing calls this directly
no test coverage detected