* Display information about selected files. * @param tagMask tag bits (1 for tag 1, 2 for tag 2) */
| 473 | * @param tagMask tag bits (1 for tag 1, 2 for tag 2) |
| 474 | */ |
| 475 | void Kid3Cli::writeFileInformation(int tagMask) |
| 476 | { |
| 477 | QVariantMap map; |
| 478 | if (!m_detailInfo.isEmpty()) { |
| 479 | map.insert(QLatin1String("format"), m_detailInfo.trimmed()); |
| 480 | } |
| 481 | if (!m_filename.isEmpty()) { |
| 482 | map.insert(QLatin1String("fileNameChanged"), m_fileNameChanged); |
| 483 | map.insert(QLatin1String("fileName"), m_filename); |
| 484 | } |
| 485 | FOR_TAGS_IN_MASK(tagNr, tagMask) { |
| 486 | FrameTableModel* ft = m_app->frameModel(tagNr); |
| 487 | QVariantList frames; |
| 488 | for (int row = 0; row < ft->rowCount(); ++row) { |
| 489 | QString name = |
| 490 | ft->index(row, FrameTableModel::CI_Enable).data().toString(); |
| 491 | if (QString value = |
| 492 | ft->index(row, FrameTableModel::CI_Value).data().toString(); |
| 493 | !(tagNr == Frame::Tag_1 ? value.isEmpty() : value.isNull())) { |
| 494 | QVariant background = ft->index(row, FrameTableModel::CI_Enable) |
| 495 | .data(Qt::BackgroundRole); |
| 496 | CoreTaggedFileIconProvider* colorProvider = |
| 497 | m_app->getPlatformTools()->iconProvider(); |
| 498 | bool changed = colorProvider && |
| 499 | colorProvider->contextForColor(background) == ColorContext::Marked; |
| 500 | frames.append(QVariantMap{ |
| 501 | {QLatin1String("changed"), changed}, |
| 502 | {QLatin1String("name"), name}, |
| 503 | {QLatin1String("value"), value}, |
| 504 | }); |
| 505 | } |
| 506 | } |
| 507 | if (!frames.isEmpty()) { |
| 508 | map.insert(QLatin1String("tag") + Frame::tagNumberToString(tagNr), |
| 509 | QVariantMap{ |
| 510 | {QLatin1String("format"), m_tagFormat[tagNr]}, |
| 511 | {QLatin1String("frames"), frames} |
| 512 | }); |
| 513 | } |
| 514 | } |
| 515 | writeResult(QVariantMap{{QLatin1String("taggedFile"), map}}); |
| 516 | } |
| 517 | |
| 518 | /** |
| 519 | * Write currently active tag mask. |
no test coverage detected