Reduce indentation in `FileInfoModel::updateCache()`
This commit is contained in:
parent
ea6e670600
commit
60187d54c8
|
@ -278,368 +278,358 @@ void FileInfoModel::updateCache()
|
||||||
{
|
{
|
||||||
beginResetModel();
|
beginResetModel();
|
||||||
clear();
|
clear();
|
||||||
if (m_file) {
|
if (!m_file) {
|
||||||
// get diag
|
endResetModel();
|
||||||
Diagnostics &diag = m_diagReparsing ? *m_diagReparsing : *m_diag;
|
return;
|
||||||
|
}
|
||||||
|
// get diag
|
||||||
|
Diagnostics &diag = m_diagReparsing ? *m_diagReparsing : *m_diag;
|
||||||
|
|
||||||
// get container
|
// get container
|
||||||
auto *const container = m_file->container();
|
auto *const container = m_file->container();
|
||||||
|
|
||||||
// get root item from model
|
// get root item from model
|
||||||
QStandardItem *rootItem = invisibleRootItem();
|
QStandardItem *rootItem = invisibleRootItem();
|
||||||
ItemHelper rootHelper(rootItem);
|
ItemHelper rootHelper(rootItem);
|
||||||
|
|
||||||
// add general information
|
// add general information
|
||||||
rootHelper.appendRow(tr("Path"), fromNativeFileName(m_file->path().data()));
|
rootHelper.appendRow(tr("Path"), fromNativeFileName(m_file->path().data()));
|
||||||
rootHelper.appendRow(tr("Size"), dataSizeToString(m_file->size()));
|
rootHelper.appendRow(tr("Size"), dataSizeToString(m_file->size()));
|
||||||
const TimeSpan duration = m_file->duration();
|
const TimeSpan duration = m_file->duration();
|
||||||
if (!duration.isNull()) {
|
if (!duration.isNull()) {
|
||||||
rootHelper.appendRow(tr("Duration"), duration);
|
rootHelper.appendRow(tr("Duration"), duration);
|
||||||
rootHelper.appendRow(tr("Overall avg. bitrate"), bitrateToString(m_file->overallAverageBitrate()));
|
rootHelper.appendRow(tr("Overall avg. bitrate"), bitrateToString(m_file->overallAverageBitrate()));
|
||||||
|
}
|
||||||
|
rootHelper.appendRow(tr("Mime-type"), m_file->mimeType());
|
||||||
|
|
||||||
|
// 3 columns
|
||||||
|
setItem(0, 2, new QStandardItem);
|
||||||
|
|
||||||
|
int currentRow;
|
||||||
|
|
||||||
|
// add container item (last top-level-item which is always present)
|
||||||
|
auto *const containerItem = defaultItem(tr("Container"));
|
||||||
|
ItemHelper containerHelper(containerItem);
|
||||||
|
setItem(currentRow = rowCount(), containerItem);
|
||||||
|
|
||||||
|
// -> add container name
|
||||||
|
QString containerName;
|
||||||
|
const auto containerFormatName = m_file->containerFormatName();
|
||||||
|
if (const auto subversion = m_file->containerFormatSubversion(); !subversion.empty()) {
|
||||||
|
containerName = qstringFromStdStringView(containerFormatName) % QChar(' ') % qstringFromStdStringView(subversion);
|
||||||
|
} else {
|
||||||
|
containerName = qstringFromStdStringView(containerFormatName);
|
||||||
|
}
|
||||||
|
setItem(currentRow, 1, defaultItem(containerName));
|
||||||
|
|
||||||
|
// container details
|
||||||
|
if (container) {
|
||||||
|
size_t segmentIndex = 0;
|
||||||
|
for (const auto &title : container->titles()) {
|
||||||
|
if (segmentIndex) {
|
||||||
|
containerHelper.appendRow(tr("Title (segment %1)").arg(++segmentIndex), title);
|
||||||
|
} else {
|
||||||
|
++segmentIndex;
|
||||||
|
containerHelper.appendRow(tr("Title"), title);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
rootHelper.appendRow(tr("Mime-type"), m_file->mimeType());
|
containerHelper.appendRow(tr("Version"), container->version());
|
||||||
|
containerHelper.appendRow(tr("Read version"), container->readVersion());
|
||||||
|
containerHelper.appendRow(tr("Document type"), container->documentType());
|
||||||
|
containerHelper.appendRow(tr("Document version"), container->doctypeVersion());
|
||||||
|
containerHelper.appendRow(tr("Document read version"), container->doctypeReadVersion());
|
||||||
|
containerHelper.appendRow(tr("Tag position"), Utility::elementPositionToQString(container->determineTagPosition(diag)));
|
||||||
|
containerHelper.appendRow(tr("Index position"), Utility::elementPositionToQString(container->determineIndexPosition(diag)));
|
||||||
|
}
|
||||||
|
containerHelper.appendRow(tr("Padding size"), m_file->paddingSize());
|
||||||
|
|
||||||
// 3 columns
|
// tags
|
||||||
setItem(0, 2, new QStandardItem);
|
if (const auto tags = m_file->parsedTags(); !tags.empty()) {
|
||||||
|
auto *tagsItem = defaultItem(tr("Tags"));
|
||||||
|
setItem(++currentRow, tagsItem);
|
||||||
|
setItem(currentRow, 1, defaultItem(tr("%1 tag(s) assigned", nullptr, trQuandity(tags.size())).arg(tags.size())));
|
||||||
|
|
||||||
int currentRow;
|
for (const Tag *const tag : tags) {
|
||||||
|
auto *const tagItem = defaultItem(tag->typeName());
|
||||||
|
ItemHelper tagHelper(tagItem);
|
||||||
|
tagHelper.appendRow(tr("Version"), tag->version());
|
||||||
|
if (tag->supportsTarget() && !tag->target().isEmpty()) {
|
||||||
|
tagHelper.appendRow(tr("Target level"), tag->targetString());
|
||||||
|
}
|
||||||
|
tagHelper.appendRow(tr("Size"), dataSizeToString(tag->size(), true));
|
||||||
|
tagHelper.appendRow(tr("Field count"), tag->fieldCount());
|
||||||
|
tagsItem->appendRow(tagItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// add container item (last top-level-item which is always present)
|
// tracks
|
||||||
auto *const containerItem = defaultItem(tr("Container"));
|
if (const auto tracks = m_file->tracks(); !tracks.empty()) {
|
||||||
ItemHelper containerHelper(containerItem);
|
auto *tracksItem = defaultItem(tr("Tracks"));
|
||||||
setItem(currentRow = rowCount(), containerItem);
|
setItem(++currentRow, tracksItem);
|
||||||
|
const string summary(m_file->technicalSummary());
|
||||||
// -> add container name
|
if (summary.empty()) {
|
||||||
QString containerName;
|
setItem(currentRow, 1, defaultItem(tr("%1 track(s) contained", nullptr, trQuandity(tracks.size())).arg(tracks.size())));
|
||||||
const auto containerFormatName = m_file->containerFormatName();
|
|
||||||
if (const auto subversion = m_file->containerFormatSubversion(); !subversion.empty()) {
|
|
||||||
containerName = qstringFromStdStringView(containerFormatName) % QChar(' ') % qstringFromStdStringView(subversion);
|
|
||||||
} else {
|
} else {
|
||||||
containerName = qstringFromStdStringView(containerFormatName);
|
setItem(currentRow, 1,
|
||||||
|
defaultItem(tr("%1 track(s): ", nullptr, trQuandity(tracks.size())).arg(tracks.size())
|
||||||
|
+ QString::fromUtf8(summary.data(), trQuandity(summary.size()))));
|
||||||
}
|
}
|
||||||
setItem(currentRow, 1, defaultItem(containerName));
|
|
||||||
|
|
||||||
// container details
|
size_t number = 0;
|
||||||
if (container) {
|
for (const AbstractTrack *const track : tracks) {
|
||||||
size_t segmentIndex = 0;
|
auto *const trackItem = defaultItem(tr("Track #%1").arg(++number));
|
||||||
for (const auto &title : container->titles()) {
|
ItemHelper trackHelper(trackItem);
|
||||||
if (segmentIndex) {
|
trackHelper.appendRow(tr("ID"), track->id());
|
||||||
containerHelper.appendRow(tr("Title (segment %1)").arg(++segmentIndex), title);
|
trackHelper.appendRow(tr("Number"), track->trackNumber());
|
||||||
} else {
|
trackHelper.appendRow(tr("Name"), track->name());
|
||||||
++segmentIndex;
|
trackHelper.appendRow(tr("Type"), track->mediaTypeName());
|
||||||
containerHelper.appendRow(tr("Title"), title);
|
const auto fmtName = track->formatName(), fmtAbbr = track->formatAbbreviation();
|
||||||
|
trackHelper.appendRow(tr("Format"), fmtName);
|
||||||
|
if (track->format() != GeneralMediaFormat::Unknown && fmtName != fmtAbbr) {
|
||||||
|
trackHelper.appendRow(tr("Abbreviation"), fmtAbbr);
|
||||||
|
}
|
||||||
|
if (track->version() > 0) {
|
||||||
|
switch (track->format().general) {
|
||||||
|
case GeneralMediaFormat::Mpeg4Video:
|
||||||
|
case GeneralMediaFormat::Avc:
|
||||||
|
trackHelper.appendRow(tr("Level"), QChar('L') + QString::number(track->version()));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
trackHelper.appendRow(tr("Version"), QString::number(track->version()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
containerHelper.appendRow(tr("Version"), container->version());
|
const auto fmtName2 = track->format().extensionName();
|
||||||
containerHelper.appendRow(tr("Read version"), container->readVersion());
|
if (!fmtName.empty()) {
|
||||||
containerHelper.appendRow(tr("Document type"), container->documentType());
|
trackHelper.appendRow(tr("Extension"), fmtName2);
|
||||||
containerHelper.appendRow(tr("Document version"), container->doctypeVersion());
|
|
||||||
containerHelper.appendRow(tr("Document read version"), container->doctypeReadVersion());
|
|
||||||
containerHelper.appendRow(tr("Tag position"), Utility::elementPositionToQString(container->determineTagPosition(diag)));
|
|
||||||
containerHelper.appendRow(tr("Index position"), Utility::elementPositionToQString(container->determineIndexPosition(diag)));
|
|
||||||
}
|
|
||||||
containerHelper.appendRow(tr("Padding size"), m_file->paddingSize());
|
|
||||||
|
|
||||||
// tags
|
|
||||||
{
|
|
||||||
const auto tags = m_file->parsedTags();
|
|
||||||
if (!tags.empty()) {
|
|
||||||
auto *tagsItem = defaultItem(tr("Tags"));
|
|
||||||
setItem(++currentRow, tagsItem);
|
|
||||||
setItem(currentRow, 1, defaultItem(tr("%1 tag(s) assigned", nullptr, trQuandity(tags.size())).arg(tags.size())));
|
|
||||||
|
|
||||||
for (const Tag *const tag : tags) {
|
|
||||||
auto *const tagItem = defaultItem(tag->typeName());
|
|
||||||
ItemHelper tagHelper(tagItem);
|
|
||||||
tagHelper.appendRow(tr("Version"), tag->version());
|
|
||||||
if (tag->supportsTarget() && !tag->target().isEmpty()) {
|
|
||||||
tagHelper.appendRow(tr("Target level"), tag->targetString());
|
|
||||||
}
|
|
||||||
tagHelper.appendRow(tr("Size"), dataSizeToString(tag->size(), true));
|
|
||||||
tagHelper.appendRow(tr("Field count"), tag->fieldCount());
|
|
||||||
tagsItem->appendRow(tagItem);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if (!track->formatId().empty()) {
|
||||||
|
trackHelper.appendRow(tr("Format/codec ID"), track->formatId());
|
||||||
|
}
|
||||||
|
if (track->size()) {
|
||||||
|
trackHelper.appendRow(tr("Size"), dataSizeToString(track->size(), true));
|
||||||
|
}
|
||||||
|
if (!track->duration().isNull()) {
|
||||||
|
trackHelper.appendRow(tr("Duration"), track->duration());
|
||||||
|
}
|
||||||
|
if (track->bitrate() > 0.0) {
|
||||||
|
trackHelper.appendRow(tr("Avg. bitrate"), bitrateToString(track->bitrate()));
|
||||||
|
}
|
||||||
|
if (track->maxBitrate() > 0.0) {
|
||||||
|
trackHelper.appendRow(tr("Max. bitrate"), bitrateToString(track->maxBitrate()));
|
||||||
|
}
|
||||||
|
if (!track->creationTime().isNull()) {
|
||||||
|
trackHelper.appendRow(tr("Creation time"), track->creationTime());
|
||||||
|
}
|
||||||
|
if (!track->modificationTime().isNull()) {
|
||||||
|
trackHelper.appendRow(tr("Modification time"), track->modificationTime());
|
||||||
|
}
|
||||||
|
if (!track->locale().empty()) {
|
||||||
|
trackHelper.appendRow(tr("Language"), track->locale().fullOrSomeAbbreviatedName());
|
||||||
|
}
|
||||||
|
if (!track->compressorName().empty()) {
|
||||||
|
trackHelper.appendRow(tr("Compressor name"), track->compressorName());
|
||||||
|
}
|
||||||
|
if (track->samplingFrequency()) {
|
||||||
|
trackHelper.appendRow(tr("Sampling frequency"),
|
||||||
|
track->extensionSamplingFrequency() ? QString::number(track->extensionSamplingFrequency()) % QStringLiteral(" Hz / ")
|
||||||
|
% QString::number(track->samplingFrequency()) % QStringLiteral(" Hz")
|
||||||
|
: QString::number(track->samplingFrequency()) + QStringLiteral(" Hz"));
|
||||||
|
}
|
||||||
|
if (track->sampleCount()) {
|
||||||
|
trackHelper.appendRow(track->mediaType() == MediaType::Video ? tr("Frame count") : tr("Sample count"), track->sampleCount());
|
||||||
|
}
|
||||||
|
if (track->bitsPerSample()) {
|
||||||
|
trackHelper.appendRow(tr("Bits per sample"), track->bitsPerSample());
|
||||||
|
}
|
||||||
|
if (track->quality()) {
|
||||||
|
trackHelper.appendRow(tr("Quality"), track->quality());
|
||||||
|
}
|
||||||
|
if (!track->pixelSize().isNull()) {
|
||||||
|
trackHelper.appendRow(tr("Pixel size"), track->pixelSize());
|
||||||
|
}
|
||||||
|
if (!track->displaySize().isNull()) {
|
||||||
|
trackHelper.appendRow(tr("Display size"), track->displaySize());
|
||||||
|
}
|
||||||
|
if (track->pixelAspectRatio().isValid()) {
|
||||||
|
trackHelper.appendRow(tr("Pixel Aspect Ratio"), track->pixelAspectRatio().toString());
|
||||||
|
}
|
||||||
|
if (!track->cropping().isNull()) {
|
||||||
|
trackHelper.appendRow(tr("Cropping"), track->cropping());
|
||||||
|
}
|
||||||
|
if (!track->resolution().isNull()) {
|
||||||
|
trackHelper.appendRow(tr("Resolution"), track->resolution());
|
||||||
|
}
|
||||||
|
if (const auto cc = track->channelConfigString(); !cc.empty()) {
|
||||||
|
const auto ecc = track->extensionChannelConfigString();
|
||||||
|
trackHelper.appendRow(tr("Channel config"),
|
||||||
|
!ecc.empty() ? qstringFromStdStringView(ecc) % QStringLiteral(" / ") % qstringFromStdStringView(cc)
|
||||||
|
: qstringFromStdStringView(cc));
|
||||||
|
} else {
|
||||||
|
trackHelper.appendRow(tr("Channel count"), track->channelCount());
|
||||||
|
}
|
||||||
|
trackHelper.appendRow(tr("Bit depth"), track->depth());
|
||||||
|
trackHelper.appendRow(tr("Frames per second"), track->fps());
|
||||||
|
trackHelper.appendRow(tr("Chroma format"), track->chromaFormat());
|
||||||
|
QStringList labels;
|
||||||
|
if (track->isInterlaced()) {
|
||||||
|
labels << tr("interlaced");
|
||||||
|
}
|
||||||
|
if (!track->isEnabled()) {
|
||||||
|
labels << tr("disabled");
|
||||||
|
}
|
||||||
|
if (track->isDefault()) {
|
||||||
|
labels << tr("default");
|
||||||
|
}
|
||||||
|
if (track->isForced()) {
|
||||||
|
labels << tr("forced");
|
||||||
|
}
|
||||||
|
if (track->hasLacing()) {
|
||||||
|
labels << tr("has lacing");
|
||||||
|
}
|
||||||
|
if (track->isEncrypted()) {
|
||||||
|
labels << tr("encrypted");
|
||||||
|
}
|
||||||
|
if (!labels.isEmpty()) {
|
||||||
|
trackHelper.appendRow(tr("Labeled as"), labels.join(QStringLiteral(", ")));
|
||||||
|
}
|
||||||
|
tracksItem->appendRow(trackItem);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// tracks
|
// attachments
|
||||||
{
|
if (const auto attachments = m_file->attachments(); !attachments.empty()) {
|
||||||
const auto tracks = m_file->tracks();
|
auto *attachmentsItem = defaultItem(tr("Attachments"));
|
||||||
if (!tracks.empty()) {
|
setItem(++currentRow, attachmentsItem);
|
||||||
auto *tracksItem = defaultItem(tr("Tracks"));
|
setItem(currentRow, 1, defaultItem(tr("%1 attachment(s) present", nullptr, trQuandity(attachments.size())).arg(attachments.size())));
|
||||||
setItem(++currentRow, tracksItem);
|
|
||||||
const string summary(m_file->technicalSummary());
|
size_t number = 0;
|
||||||
if (summary.empty()) {
|
for (const AbstractAttachment *const attachment : attachments) {
|
||||||
setItem(currentRow, 1, defaultItem(tr("%1 track(s) contained", nullptr, trQuandity(tracks.size())).arg(tracks.size())));
|
auto *const attachmentItem = defaultItem(tr("Attachment #%1").arg(++number));
|
||||||
} else {
|
ItemHelper attachHelper(attachmentItem);
|
||||||
setItem(currentRow, 1,
|
attachHelper.appendRow(tr("ID"), attachment->id());
|
||||||
defaultItem(tr("%1 track(s): ", nullptr, trQuandity(tracks.size())).arg(tracks.size())
|
attachHelper.appendRow(tr("Name"), attachment->name());
|
||||||
+ QString::fromUtf8(summary.data(), trQuandity(summary.size()))));
|
attachHelper.appendRow(tr("Size"), dataSizeToString(static_cast<std::uint64_t>(attachment->data()->size())));
|
||||||
|
attachHelper.appendRow(tr("Mime-type"), attachment->mimeType());
|
||||||
|
attachHelper.appendRow(tr("Description"), attachment->description());
|
||||||
|
attachmentsItem->appendRow(attachmentItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// chapters/editions
|
||||||
|
{
|
||||||
|
size_t number = 0;
|
||||||
|
function<void(const AbstractChapter *, QStandardItem *)> addChapter;
|
||||||
|
addChapter = [&addChapter, &number](const AbstractChapter *chapter, QStandardItem *parent) {
|
||||||
|
auto *chapterItem = defaultItem(tr("Chapter #%1").arg(++number));
|
||||||
|
ItemHelper chapterHelper(chapterItem);
|
||||||
|
chapterHelper.appendRow(tr("ID"), chapter->id());
|
||||||
|
for (const LocaleAwareString &name : chapter->names()) {
|
||||||
|
chapterHelper.appendRow(tr("Name (%1)").arg(QString::fromStdString(name.locale().toString())), name);
|
||||||
|
}
|
||||||
|
if (!chapter->startTime().isNegative()) {
|
||||||
|
chapterHelper.appendRow(tr("Start time"), chapter->startTime());
|
||||||
|
}
|
||||||
|
if (!chapter->endTime().isNegative()) {
|
||||||
|
chapterHelper.appendRow(tr("End time"), chapter->endTime());
|
||||||
|
}
|
||||||
|
QStringList labels;
|
||||||
|
if (chapter->isHidden()) {
|
||||||
|
labels << tr("hidden");
|
||||||
|
}
|
||||||
|
if (!chapter->isEnabled()) {
|
||||||
|
labels << tr("disabled");
|
||||||
|
}
|
||||||
|
if (!labels.empty()) {
|
||||||
|
chapterHelper.appendRow(tr("Labeled as"), labels.join(QStringLiteral(", ")));
|
||||||
|
}
|
||||||
|
if (!chapter->tracks().empty()) {
|
||||||
|
QStringList trackIds;
|
||||||
|
for (const auto id : chapter->tracks()) {
|
||||||
|
trackIds << QString::number(id);
|
||||||
}
|
}
|
||||||
|
chapterHelper.appendRow(tr("Tracks"), trackIds.join(QStringLiteral(", ")));
|
||||||
|
}
|
||||||
|
for (size_t i = 0, nestedChapters = chapter->nestedChapterCount(); i < nestedChapters; ++i) {
|
||||||
|
addChapter(chapter->nestedChapter(i), chapterItem);
|
||||||
|
}
|
||||||
|
parent->appendRow(chapterItem);
|
||||||
|
};
|
||||||
|
|
||||||
size_t number = 0;
|
if (m_file->containerFormat() == ContainerFormat::Matroska) {
|
||||||
for (const AbstractTrack *const track : tracks) {
|
const auto &editionEntries = static_cast<const MatroskaContainer *>(container)->editionEntires();
|
||||||
auto *const trackItem = defaultItem(tr("Track #%1").arg(++number));
|
if (!editionEntries.empty()) {
|
||||||
ItemHelper trackHelper(trackItem);
|
auto *editionsItem = defaultItem(tr("Editions"));
|
||||||
trackHelper.appendRow(tr("ID"), track->id());
|
setItem(++currentRow, editionsItem);
|
||||||
trackHelper.appendRow(tr("Number"), track->trackNumber());
|
setItem(
|
||||||
trackHelper.appendRow(tr("Name"), track->name());
|
currentRow, 1, defaultItem(tr("%1 edition(s) present", nullptr, trQuandity(editionEntries.size())).arg(editionEntries.size())));
|
||||||
trackHelper.appendRow(tr("Type"), track->mediaTypeName());
|
size_t editionNumber = 0;
|
||||||
const auto fmtName = track->formatName(), fmtAbbr = track->formatAbbreviation();
|
for (const auto &edition : editionEntries) {
|
||||||
trackHelper.appendRow(tr("Format"), fmtName);
|
auto *editionItem = defaultItem(tr("Edition #%1").arg(++editionNumber));
|
||||||
if (track->format() != GeneralMediaFormat::Unknown && fmtName != fmtAbbr) {
|
ItemHelper editionHelper(editionItem);
|
||||||
trackHelper.appendRow(tr("Abbreviation"), fmtAbbr);
|
editionHelper.appendRow(tr("ID"), edition->id());
|
||||||
}
|
|
||||||
if (track->version() > 0) {
|
|
||||||
switch (track->format().general) {
|
|
||||||
case GeneralMediaFormat::Mpeg4Video:
|
|
||||||
case GeneralMediaFormat::Avc:
|
|
||||||
trackHelper.appendRow(tr("Level"), QChar('L') + QString::number(track->version()));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
trackHelper.appendRow(tr("Version"), QString::number(track->version()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const auto fmtName2 = track->format().extensionName();
|
|
||||||
if (!fmtName.empty()) {
|
|
||||||
trackHelper.appendRow(tr("Extension"), fmtName2);
|
|
||||||
}
|
|
||||||
if (!track->formatId().empty()) {
|
|
||||||
trackHelper.appendRow(tr("Format/codec ID"), track->formatId());
|
|
||||||
}
|
|
||||||
if (track->size()) {
|
|
||||||
trackHelper.appendRow(tr("Size"), dataSizeToString(track->size(), true));
|
|
||||||
}
|
|
||||||
if (!track->duration().isNull()) {
|
|
||||||
trackHelper.appendRow(tr("Duration"), track->duration());
|
|
||||||
}
|
|
||||||
if (track->bitrate() > 0.0) {
|
|
||||||
trackHelper.appendRow(tr("Avg. bitrate"), bitrateToString(track->bitrate()));
|
|
||||||
}
|
|
||||||
if (track->maxBitrate() > 0.0) {
|
|
||||||
trackHelper.appendRow(tr("Max. bitrate"), bitrateToString(track->maxBitrate()));
|
|
||||||
}
|
|
||||||
if (!track->creationTime().isNull()) {
|
|
||||||
trackHelper.appendRow(tr("Creation time"), track->creationTime());
|
|
||||||
}
|
|
||||||
if (!track->modificationTime().isNull()) {
|
|
||||||
trackHelper.appendRow(tr("Modification time"), track->modificationTime());
|
|
||||||
}
|
|
||||||
if (!track->locale().empty()) {
|
|
||||||
trackHelper.appendRow(tr("Language"), track->locale().fullOrSomeAbbreviatedName());
|
|
||||||
}
|
|
||||||
if (!track->compressorName().empty()) {
|
|
||||||
trackHelper.appendRow(tr("Compressor name"), track->compressorName());
|
|
||||||
}
|
|
||||||
if (track->samplingFrequency()) {
|
|
||||||
trackHelper.appendRow(tr("Sampling frequency"),
|
|
||||||
track->extensionSamplingFrequency() ? QString::number(track->extensionSamplingFrequency()) % QStringLiteral(" Hz / ")
|
|
||||||
% QString::number(track->samplingFrequency()) % QStringLiteral(" Hz")
|
|
||||||
: QString::number(track->samplingFrequency()) + QStringLiteral(" Hz"));
|
|
||||||
}
|
|
||||||
if (track->sampleCount()) {
|
|
||||||
trackHelper.appendRow(track->mediaType() == MediaType::Video ? tr("Frame count") : tr("Sample count"), track->sampleCount());
|
|
||||||
}
|
|
||||||
if (track->bitsPerSample()) {
|
|
||||||
trackHelper.appendRow(tr("Bits per sample"), track->bitsPerSample());
|
|
||||||
}
|
|
||||||
if (track->quality()) {
|
|
||||||
trackHelper.appendRow(tr("Quality"), track->quality());
|
|
||||||
}
|
|
||||||
if (!track->pixelSize().isNull()) {
|
|
||||||
trackHelper.appendRow(tr("Pixel size"), track->pixelSize());
|
|
||||||
}
|
|
||||||
if (!track->displaySize().isNull()) {
|
|
||||||
trackHelper.appendRow(tr("Display size"), track->displaySize());
|
|
||||||
}
|
|
||||||
if (track->pixelAspectRatio().isValid()) {
|
|
||||||
trackHelper.appendRow(tr("Pixel Aspect Ratio"), track->pixelAspectRatio().toString());
|
|
||||||
}
|
|
||||||
if (!track->cropping().isNull()) {
|
|
||||||
trackHelper.appendRow(tr("Cropping"), track->cropping());
|
|
||||||
}
|
|
||||||
if (!track->resolution().isNull()) {
|
|
||||||
trackHelper.appendRow(tr("Resolution"), track->resolution());
|
|
||||||
}
|
|
||||||
if (const auto cc = track->channelConfigString(); !cc.empty()) {
|
|
||||||
const auto ecc = track->extensionChannelConfigString();
|
|
||||||
trackHelper.appendRow(tr("Channel config"),
|
|
||||||
!ecc.empty() ? qstringFromStdStringView(ecc) % QStringLiteral(" / ") % qstringFromStdStringView(cc)
|
|
||||||
: qstringFromStdStringView(cc));
|
|
||||||
} else {
|
|
||||||
trackHelper.appendRow(tr("Channel count"), track->channelCount());
|
|
||||||
}
|
|
||||||
trackHelper.appendRow(tr("Bit depth"), track->depth());
|
|
||||||
trackHelper.appendRow(tr("Frames per second"), track->fps());
|
|
||||||
trackHelper.appendRow(tr("Chroma format"), track->chromaFormat());
|
|
||||||
QStringList labels;
|
QStringList labels;
|
||||||
if (track->isInterlaced()) {
|
if (edition->isHidden()) {
|
||||||
labels << tr("interlaced");
|
labels << tr("hidden");
|
||||||
}
|
}
|
||||||
if (!track->isEnabled()) {
|
if (edition->isDefault()) {
|
||||||
labels << tr("disabled");
|
|
||||||
}
|
|
||||||
if (track->isDefault()) {
|
|
||||||
labels << tr("default");
|
labels << tr("default");
|
||||||
}
|
}
|
||||||
if (track->isForced()) {
|
if (edition->isOrdered()) {
|
||||||
labels << tr("forced");
|
labels << tr("ordered");
|
||||||
}
|
|
||||||
if (track->hasLacing()) {
|
|
||||||
labels << tr("has lacing");
|
|
||||||
}
|
|
||||||
if (track->isEncrypted()) {
|
|
||||||
labels << tr("encrypted");
|
|
||||||
}
|
}
|
||||||
if (!labels.isEmpty()) {
|
if (!labels.isEmpty()) {
|
||||||
trackHelper.appendRow(tr("Labeled as"), labels.join(QStringLiteral(", ")));
|
editionHelper.appendRow(tr("Labeled as"), labels.join(QStringLiteral(", ")));
|
||||||
}
|
}
|
||||||
tracksItem->appendRow(trackItem);
|
for (const auto &chapter : edition->chapters()) {
|
||||||
|
addChapter(chapter.get(), editionItem);
|
||||||
|
}
|
||||||
|
editionsItem->appendRow(editionItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else if (const auto chapters = m_file->chapters(); !chapters.empty()) {
|
||||||
|
auto *chaptersItem = defaultItem(tr("Chapters"));
|
||||||
// attachments
|
setItem(++currentRow, chaptersItem);
|
||||||
{
|
setItem(currentRow, 1, defaultItem(tr("%1 chapter(s) present", nullptr, trQuandity(chapters.size())).arg(chapters.size())));
|
||||||
const auto attachments = m_file->attachments();
|
for (const AbstractChapter *chapter : chapters) {
|
||||||
if (!attachments.empty()) {
|
addChapter(chapter, chaptersItem);
|
||||||
auto *attachmentsItem = defaultItem(tr("Attachments"));
|
|
||||||
setItem(++currentRow, attachmentsItem);
|
|
||||||
setItem(currentRow, 1, defaultItem(tr("%1 attachment(s) present", nullptr, trQuandity(attachments.size())).arg(attachments.size())));
|
|
||||||
|
|
||||||
size_t number = 0;
|
|
||||||
for (const AbstractAttachment *const attachment : attachments) {
|
|
||||||
auto *const attachmentItem = defaultItem(tr("Attachment #%1").arg(++number));
|
|
||||||
ItemHelper attachHelper(attachmentItem);
|
|
||||||
attachHelper.appendRow(tr("ID"), attachment->id());
|
|
||||||
attachHelper.appendRow(tr("Name"), attachment->name());
|
|
||||||
attachHelper.appendRow(tr("Size"), dataSizeToString(static_cast<std::uint64_t>(attachment->data()->size())));
|
|
||||||
attachHelper.appendRow(tr("Mime-type"), attachment->mimeType());
|
|
||||||
attachHelper.appendRow(tr("Description"), attachment->description());
|
|
||||||
attachmentsItem->appendRow(attachmentItem);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// chapters/editions
|
// structure
|
||||||
{
|
switch (m_file->containerFormat()) {
|
||||||
size_t number = 0;
|
case ContainerFormat::Mp4:
|
||||||
function<void(const AbstractChapter *, QStandardItem *)> addChapter;
|
case ContainerFormat::QuickTime:
|
||||||
addChapter = [&addChapter, &number](const AbstractChapter *chapter, QStandardItem *parent) {
|
case ContainerFormat::Matroska:
|
||||||
auto *chapterItem = defaultItem(tr("Chapter #%1").arg(++number));
|
case ContainerFormat::Webm:
|
||||||
ItemHelper chapterHelper(chapterItem);
|
case ContainerFormat::Ebml: {
|
||||||
chapterHelper.appendRow(tr("ID"), chapter->id());
|
auto *structureItem = defaultItem(tr("Structure"));
|
||||||
for (const LocaleAwareString &name : chapter->names()) {
|
|
||||||
chapterHelper.appendRow(tr("Name (%1)").arg(QString::fromStdString(name.locale().toString())), name);
|
|
||||||
}
|
|
||||||
if (!chapter->startTime().isNegative()) {
|
|
||||||
chapterHelper.appendRow(tr("Start time"), chapter->startTime());
|
|
||||||
}
|
|
||||||
if (!chapter->endTime().isNegative()) {
|
|
||||||
chapterHelper.appendRow(tr("End time"), chapter->endTime());
|
|
||||||
}
|
|
||||||
QStringList labels;
|
|
||||||
if (chapter->isHidden()) {
|
|
||||||
labels << tr("hidden");
|
|
||||||
}
|
|
||||||
if (!chapter->isEnabled()) {
|
|
||||||
labels << tr("disabled");
|
|
||||||
}
|
|
||||||
if (!labels.empty()) {
|
|
||||||
chapterHelper.appendRow(tr("Labeled as"), labels.join(QStringLiteral(", ")));
|
|
||||||
}
|
|
||||||
if (!chapter->tracks().empty()) {
|
|
||||||
QStringList trackIds;
|
|
||||||
for (const auto id : chapter->tracks()) {
|
|
||||||
trackIds << QString::number(id);
|
|
||||||
}
|
|
||||||
chapterHelper.appendRow(tr("Tracks"), trackIds.join(QStringLiteral(", ")));
|
|
||||||
}
|
|
||||||
for (size_t i = 0, nestedChapters = chapter->nestedChapterCount(); i < nestedChapters; ++i) {
|
|
||||||
addChapter(chapter->nestedChapter(i), chapterItem);
|
|
||||||
}
|
|
||||||
parent->appendRow(chapterItem);
|
|
||||||
};
|
|
||||||
|
|
||||||
if (m_file->containerFormat() == ContainerFormat::Matroska) {
|
|
||||||
const auto &editionEntries = static_cast<const MatroskaContainer *>(container)->editionEntires();
|
|
||||||
if (!editionEntries.empty()) {
|
|
||||||
auto *editionsItem = defaultItem(tr("Editions"));
|
|
||||||
setItem(++currentRow, editionsItem);
|
|
||||||
setItem(currentRow, 1,
|
|
||||||
defaultItem(tr("%1 edition(s) present", nullptr, trQuandity(editionEntries.size())).arg(editionEntries.size())));
|
|
||||||
size_t editionNumber = 0;
|
|
||||||
for (const auto &edition : editionEntries) {
|
|
||||||
auto *editionItem = defaultItem(tr("Edition #%1").arg(++editionNumber));
|
|
||||||
ItemHelper editionHelper(editionItem);
|
|
||||||
editionHelper.appendRow(tr("ID"), edition->id());
|
|
||||||
QStringList labels;
|
|
||||||
if (edition->isHidden()) {
|
|
||||||
labels << tr("hidden");
|
|
||||||
}
|
|
||||||
if (edition->isDefault()) {
|
|
||||||
labels << tr("default");
|
|
||||||
}
|
|
||||||
if (edition->isOrdered()) {
|
|
||||||
labels << tr("ordered");
|
|
||||||
}
|
|
||||||
if (!labels.isEmpty()) {
|
|
||||||
editionHelper.appendRow(tr("Labeled as"), labels.join(QStringLiteral(", ")));
|
|
||||||
}
|
|
||||||
for (const auto &chapter : edition->chapters()) {
|
|
||||||
addChapter(chapter.get(), editionItem);
|
|
||||||
}
|
|
||||||
editionsItem->appendRow(editionItem);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
const auto chapters = m_file->chapters();
|
|
||||||
if (!chapters.empty()) {
|
|
||||||
auto *chaptersItem = defaultItem(tr("Chapters"));
|
|
||||||
setItem(++currentRow, chaptersItem);
|
|
||||||
setItem(currentRow, 1, defaultItem(tr("%1 chapter(s) present", nullptr, trQuandity(chapters.size())).arg(chapters.size())));
|
|
||||||
for (const AbstractChapter *chapter : chapters) {
|
|
||||||
addChapter(chapter, chaptersItem);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// structure
|
|
||||||
switch (m_file->containerFormat()) {
|
switch (m_file->containerFormat()) {
|
||||||
case ContainerFormat::Mp4:
|
case ContainerFormat::Mp4:
|
||||||
case ContainerFormat::QuickTime:
|
case ContainerFormat::QuickTime:
|
||||||
|
addElementNode(static_cast<const Mp4Container *>(container)->firstElement(), structureItem);
|
||||||
|
break;
|
||||||
case ContainerFormat::Matroska:
|
case ContainerFormat::Matroska:
|
||||||
case ContainerFormat::Webm:
|
case ContainerFormat::Webm:
|
||||||
case ContainerFormat::Ebml: {
|
case ContainerFormat::Ebml:
|
||||||
auto *structureItem = defaultItem(tr("Structure"));
|
addElementNode(static_cast<const MatroskaContainer *>(container)->firstElement(), structureItem);
|
||||||
switch (m_file->containerFormat()) {
|
break;
|
||||||
case ContainerFormat::Mp4:
|
|
||||||
case ContainerFormat::QuickTime:
|
|
||||||
addElementNode(static_cast<const Mp4Container *>(container)->firstElement(), structureItem);
|
|
||||||
break;
|
|
||||||
case ContainerFormat::Matroska:
|
|
||||||
case ContainerFormat::Webm:
|
|
||||||
case ContainerFormat::Ebml:
|
|
||||||
addElementNode(static_cast<const MatroskaContainer *>(container)->firstElement(), structureItem);
|
|
||||||
break;
|
|
||||||
default:;
|
|
||||||
}
|
|
||||||
setItem(++currentRow, structureItem);
|
|
||||||
setItem(currentRow, 1, defaultItem(QString()));
|
|
||||||
} break;
|
|
||||||
default:;
|
default:;
|
||||||
}
|
}
|
||||||
|
setItem(++currentRow, structureItem);
|
||||||
|
setItem(currentRow, 1, defaultItem(QString()));
|
||||||
|
} break;
|
||||||
|
default:;
|
||||||
|
}
|
||||||
|
|
||||||
// notifications
|
// notifications
|
||||||
auto *const diagItem = defaultItem(tr("Diagnostic messages"));
|
auto *const diagItem = defaultItem(tr("Diagnostic messages"));
|
||||||
addDiagMessages(m_diag, diagItem);
|
addDiagMessages(m_diag, diagItem);
|
||||||
setItem(++currentRow, diagItem);
|
setItem(++currentRow, diagItem);
|
||||||
if (m_diagReparsing) {
|
if (m_diagReparsing) {
|
||||||
auto *diagReparsingItem = defaultItem(tr("Diagnostic messages from reparsing"));
|
auto *diagReparsingItem = defaultItem(tr("Diagnostic messages from reparsing"));
|
||||||
addDiagMessages(m_diagReparsing, diagReparsingItem);
|
addDiagMessages(m_diagReparsing, diagReparsingItem);
|
||||||
setItem(++currentRow, diagReparsingItem);
|
setItem(++currentRow, diagReparsingItem);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
endResetModel();
|
endResetModel();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue