Reduce indentation in `FileInfoModel::updateCache()`

This commit is contained in:
Martchus 2021-08-08 00:16:18 +02:00
parent ea6e670600
commit 60187d54c8
1 changed files with 315 additions and 325 deletions

View File

@ -278,7 +278,10 @@ void FileInfoModel::updateCache()
{
beginResetModel();
clear();
if (m_file) {
if (!m_file) {
endResetModel();
return;
}
// get diag
Diagnostics &diag = m_diagReparsing ? *m_diagReparsing : *m_diag;
@ -341,9 +344,7 @@ void FileInfoModel::updateCache()
containerHelper.appendRow(tr("Padding size"), m_file->paddingSize());
// tags
{
const auto tags = m_file->parsedTags();
if (!tags.empty()) {
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())));
@ -360,12 +361,9 @@ void FileInfoModel::updateCache()
tagsItem->appendRow(tagItem);
}
}
}
// tracks
{
const auto tracks = m_file->tracks();
if (!tracks.empty()) {
if (const auto tracks = m_file->tracks(); !tracks.empty()) {
auto *tracksItem = defaultItem(tr("Tracks"));
setItem(++currentRow, tracksItem);
const string summary(m_file->technicalSummary());
@ -497,12 +495,9 @@ void FileInfoModel::updateCache()
tracksItem->appendRow(trackItem);
}
}
}
// attachments
{
const auto attachments = m_file->attachments();
if (!attachments.empty()) {
if (const auto attachments = m_file->attachments(); !attachments.empty()) {
auto *attachmentsItem = defaultItem(tr("Attachments"));
setItem(++currentRow, attachmentsItem);
setItem(currentRow, 1, defaultItem(tr("%1 attachment(s) present", nullptr, trQuandity(attachments.size())).arg(attachments.size())));
@ -519,7 +514,6 @@ void FileInfoModel::updateCache()
attachmentsItem->appendRow(attachmentItem);
}
}
}
// chapters/editions
{
@ -566,8 +560,8 @@ void FileInfoModel::updateCache()
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())));
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));
@ -592,9 +586,7 @@ void FileInfoModel::updateCache()
editionsItem->appendRow(editionItem);
}
}
} else {
const auto chapters = m_file->chapters();
if (!chapters.empty()) {
} else if (const auto chapters = m_file->chapters(); !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())));
@ -603,7 +595,6 @@ void FileInfoModel::updateCache()
}
}
}
}
// structure
switch (m_file->containerFormat()) {
@ -640,7 +631,6 @@ void FileInfoModel::updateCache()
addDiagMessages(m_diagReparsing, diagReparsingItem);
setItem(++currentRow, diagReparsingItem);
}
}
endResetModel();
}