From 7848b285b6f2fb193e8578069e2882e68cd6e1af Mon Sep 17 00:00:00 2001 From: Martchus Date: Wed, 31 Jan 2018 21:02:24 +0100 Subject: [PATCH] Fix some warnings --- cli/helper.cpp | 14 ++++++++------ cli/mainfeatures.cpp | 1 + gui/fileinfomodel.cpp | 20 ++++++++++---------- misc/htmlinfo.cpp | 10 +++++----- misc/utility.cpp | 2 +- 5 files changed, 25 insertions(+), 22 deletions(-) diff --git a/cli/helper.cpp b/cli/helper.cpp index 597b4f0..eacdb65 100644 --- a/cli/helper.cpp +++ b/cli/helper.cpp @@ -181,13 +181,15 @@ void printNotifications(const MediaFileInfo &fileInfo, const char *head, bool be void printProperty(const char *propName, const char *value, const char *suffix, Indentation indentation) { - if(*value) { - cout << indentation << propName << Indentation(30 - strlen(propName)) << value; - if(suffix) { - cout << ' ' << suffix; - } - cout << '\n'; + if(!*value) { + return; } + const auto propLen(strlen(propName)); + cout << indentation << propName << Indentation(static_cast(propLen < 30 ? 30 - propLen : 1)) << value; + if(suffix) { + cout << ' ' << suffix; + } + cout << '\n'; } void printProperty(const char *propName, ElementPosition elementPosition, const char *suffix, Indentation indentation) diff --git a/cli/mainfeatures.cpp b/cli/mainfeatures.cpp index 621441d..7082e99 100644 --- a/cli/mainfeatures.cpp +++ b/cli/mainfeatures.cpp @@ -903,6 +903,7 @@ void exportToJson(const ArgumentOccurrence &, const Argument &filesArg, const Ar #else VAR_UNUSED(filesArg); + VAR_UNUSED(prettyArg); cerr << Phrases::Error << "JSON export has not been enabled when building the tag editor." << Phrases::EndFlush; #endif } diff --git a/gui/fileinfomodel.cpp b/gui/fileinfomodel.cpp index 9d27d1d..b870a15 100644 --- a/gui/fileinfomodel.cpp +++ b/gui/fileinfomodel.cpp @@ -146,7 +146,7 @@ void addNotifications(Media::NotificationList *notifications, QStandardItem *par } -template void addElementNode(ElementType *element, QStandardItem *parent) +template void addElementNode(const ElementType *element, QStandardItem *parent) { while(element) { if(element->isParsed()) { @@ -335,7 +335,7 @@ void FileInfoModel::updateCache() if(!tags.empty()) { auto *tagsItem = defaultItem(tr("Tags")); setItem(++currentRow, tagsItem); - setItem(currentRow, 1, defaultItem(tr("%1 tag(s) assigned", 0, tags.size()).arg(tags.size()))); + setItem(currentRow, 1, defaultItem(tr("%1 tag(s) assigned", nullptr, static_cast(tags.size())).arg(tags.size()))); for(const Tag *tag : tags) { auto *tagItem = defaultItem(tag->typeName()); @@ -357,9 +357,9 @@ void FileInfoModel::updateCache() setItem(++currentRow, tracksItem); const string summary(m_file->technicalSummary()); if(summary.empty()) { - setItem(currentRow, 1, defaultItem(tr("%1 track(s) contained", 0, tracks.size()).arg(tracks.size()))); + setItem(currentRow, 1, defaultItem(tr("%1 track(s) contained", nullptr, static_cast(tracks.size())).arg(tracks.size()))); } else { - setItem(currentRow, 1, defaultItem(tr("%1 track(s): ", 0, tracks.size()).arg(tracks.size()) + QString::fromUtf8(summary.data(), summary.size()))); + setItem(currentRow, 1, defaultItem(tr("%1 track(s): ", nullptr, static_cast(tracks.size())).arg(tracks.size()) + QString::fromUtf8(summary.data(), summary.size()))); } size_t number = 0; @@ -375,7 +375,7 @@ void FileInfoModel::updateCache() if(track->format() != GeneralMediaFormat::Unknown && strcmp(fmtName, fmtAbbr)) { // format name and abbreviation differ trackHelper.appendRow(tr("Abbreviation"), fmtAbbr); } - if(track->version()) { + if(track->version() > 0) { switch(track->format().general) { case GeneralMediaFormat::Mpeg4Video: case GeneralMediaFormat::Avc: @@ -458,7 +458,7 @@ void FileInfoModel::updateCache() if(!attachments.empty()) { auto *attachmentsItem = defaultItem(tr("Attachments")); setItem(++currentRow, attachmentsItem); - setItem(currentRow, 1, defaultItem(tr("%1 attachment(s) present", 0, attachments.size()).arg(attachments.size()))); + setItem(currentRow, 1, defaultItem(tr("%1 attachment(s) present", nullptr, attachments.size()).arg(attachments.size()))); size_t number = 0; for(const AbstractAttachment *attachment : attachments) { @@ -521,7 +521,7 @@ void FileInfoModel::updateCache() if(!editionEntries.empty()) { auto *editionsItem = defaultItem(tr("Editions")); setItem(++currentRow, editionsItem); - setItem(currentRow, 1, defaultItem(tr("%1 edition(s) present", 0, editionEntries.size()).arg(editionEntries.size()))); + setItem(currentRow, 1, defaultItem(tr("%1 edition(s) present", nullptr, editionEntries.size()).arg(editionEntries.size()))); size_t editionNumber = 0; for(const auto &edition : editionEntries) { auto *editionItem = defaultItem(tr("Edition #%1").arg(++editionNumber)); @@ -551,7 +551,7 @@ void FileInfoModel::updateCache() if(!chapters.empty()) { auto *chaptersItem = defaultItem(tr("Chapters")); setItem(++currentRow, chaptersItem); - setItem(currentRow, 1, defaultItem(tr("%1 chapter(s) present", 0, chapters.size()).arg(chapters.size()))); + setItem(currentRow, 1, defaultItem(tr("%1 chapter(s) present", nullptr, chapters.size()).arg(chapters.size()))); for(const AbstractChapter *chapter : chapters) { addChapter(chapter, chaptersItem); } @@ -570,12 +570,12 @@ void FileInfoModel::updateCache() switch(m_file->containerFormat()) { case ContainerFormat::Mp4: case ContainerFormat::QuickTime: - addElementNode(static_cast(container)->firstElement(), structureItem); + addElementNode(static_cast(container)->firstElement(), structureItem); break; case ContainerFormat::Matroska: case ContainerFormat::Webm: case ContainerFormat::Ebml: - addElementNode(static_cast(container)->firstElement(), structureItem); + addElementNode(static_cast(container)->firstElement(), structureItem); break; default: ; diff --git a/misc/htmlinfo.cpp b/misc/htmlinfo.cpp index ef281a6..705ba1b 100644 --- a/misc/htmlinfo.cpp +++ b/misc/htmlinfo.cpp @@ -933,7 +933,7 @@ public: startTableSection(); const QString moreId(QStringLiteral("tagsMore")); m_rowMaker.startRow(QCoreApplication::translate("HtmlInfo", "Tags")); - m_writer.writeCharacters(QCoreApplication::translate("HtmlInfo", "%1 tag(s) assigned", 0, static_cast(tags.size())).arg(tags.size())); + m_writer.writeCharacters(QCoreApplication::translate("HtmlInfo", "%1 tag(s) assigned", nullptr, static_cast(tags.size())).arg(tags.size())); mkSpace(); mkDetailsLink(moreId, QCoreApplication::translate("HtmlInfo", "show details")); m_rowMaker.endRow(); @@ -962,7 +962,7 @@ public: startTableSection(); const QString moreId(QStringLiteral("tracksMore")); m_rowMaker.startRow(QCoreApplication::translate("HtmlInfo", "Tracks")); - m_writer.writeCharacters(QCoreApplication::translate("HtmlInfo", "file has %1 track(s)", 0, static_cast(tracks.size())).arg(tracks.size())); + m_writer.writeCharacters(QCoreApplication::translate("HtmlInfo", "file has %1 track(s)", nullptr, static_cast(tracks.size())).arg(tracks.size())); const string summary(m_file.technicalSummary()); if(!summary.empty()) { m_writer.writeCharacters(QStringLiteral(": ")); @@ -989,7 +989,7 @@ public: startTableSection(); const QString moreId(QStringLiteral("attachmentsMore")); m_rowMaker.startRow(QCoreApplication::translate("HtmlInfo", "Attachments")); - m_writer.writeCharacters(QCoreApplication::translate("HtmlInfo", "%1 attachment(s) assigned", 0, static_cast(attachments.size())).arg(attachments.size())); + m_writer.writeCharacters(QCoreApplication::translate("HtmlInfo", "%1 attachment(s) assigned", nullptr, static_cast(attachments.size())).arg(attachments.size())); mkSpace(); mkDetailsLink(moreId, QCoreApplication::translate("HtmlInfo", "show details")); m_rowMaker.endRow(); @@ -1012,7 +1012,7 @@ public: startTableSection(); const QString moreId(QStringLiteral("editionsMore")); m_rowMaker.startRow(QCoreApplication::translate("HtmlInfo", "Editions/chapters")); - m_writer.writeCharacters(QCoreApplication::translate("HtmlInfo", "file has %1 edition(s)", 0, static_cast(editionEntries.size())).arg(editionEntries.size())); + m_writer.writeCharacters(QCoreApplication::translate("HtmlInfo", "file has %1 edition(s)", nullptr, static_cast(editionEntries.size())).arg(editionEntries.size())); mkSpace(); mkDetailsLink(moreId, QCoreApplication::translate("HtmlInfo", "show details")); m_rowMaker.endRow(); @@ -1030,7 +1030,7 @@ public: startTableSection(); const QString moreId(QStringLiteral("chaptersMore")); m_rowMaker.startRow(QCoreApplication::translate("HtmlInfo", "chapters")); - m_writer.writeCharacters(QCoreApplication::translate("HtmlInfo", "file has %1 chapter(s)", 0, static_cast(chapterCount)).arg(chapterCount)); + m_writer.writeCharacters(QCoreApplication::translate("HtmlInfo", "file has %1 chapter(s)", nullptr, static_cast(chapterCount)).arg(chapterCount)); mkSpace(); mkDetailsLink(moreId, QCoreApplication::translate("HtmlInfo", "show details")); m_rowMaker.endRow(); diff --git a/misc/utility.cpp b/misc/utility.cpp index 226ad13..855ab00 100644 --- a/misc/utility.cpp +++ b/misc/utility.cpp @@ -99,7 +99,7 @@ string qstringToString(const QString &value, TagTextEncoding textEncoding) codec = QTextCodec::codecForLocale(); } const auto encodedString = codec->fromUnicode(value); - return string(encodedString.data(), encodedString.size()); + return string(encodedString.data(), static_cast(encodedString.size())); } return string(); }