Adapt to changes in tagparser v10

This commit is contained in:
Martchus 2020-12-14 21:19:49 +01:00
parent 28b038e5d8
commit 0a7d05256c
5 changed files with 14 additions and 26 deletions

View File

@ -196,12 +196,7 @@ if (WIDGETS_GUI OR QUICK_GUI)
endif () endif ()
# find tagparser # find tagparser
set(CMAKE_FIND_PACKAGE_SORT_ORDER NATURAL) find_package(tagparser${CONFIGURATION_PACKAGE_SUFFIX} 10.0.0 REQUIRED)
if (CMAKE_VERSION VERSION_LESS 3.19)
find_package(tagparser${CONFIGURATION_PACKAGE_SUFFIX} 9.3.0 REQUIRED)
else ()
find_package(tagparser${CONFIGURATION_PACKAGE_SUFFIX} 9.3.0...10.0.0 REQUIRED)
endif ()
use_tag_parser() use_tag_parser()
# enable experimental JSON export # enable experimental JSON export

View File

@ -18,7 +18,7 @@
#include <tagparser/abstracttrack.h> #include <tagparser/abstracttrack.h>
#include <tagparser/backuphelper.h> #include <tagparser/backuphelper.h>
#include <tagparser/diagnostics.h> #include <tagparser/diagnostics.h>
#include <tagparser/language.h> #include <tagparser/localehelper.h>
#include <tagparser/mediafileinfo.h> #include <tagparser/mediafileinfo.h>
#include <tagparser/progressfeedback.h> #include <tagparser/progressfeedback.h>
#include <tagparser/tag.h> #include <tagparser/tag.h>
@ -199,8 +199,8 @@ void displayFileInfo(const ArgumentOccurrence &, const Argument &filesArg, const
printProperty("ID", track->id(), nullptr, true); printProperty("ID", track->id(), nullptr, true);
printProperty("Name", track->name()); printProperty("Name", track->name());
printProperty("Type", track->mediaTypeName()); printProperty("Type", track->mediaTypeName());
if (isLanguageDefined(track->language())) { if (const auto &language = track->locale().fullOrSomeAbbreviatedName(); !language.empty()) {
printProperty("Language", languageNameFromIsoWithFallback(track->language())); printProperty("Language", language);
} }
const char *fmtName = track->formatName(), *fmtAbbr = track->formatAbbreviation(); const char *fmtName = track->formatName(), *fmtAbbr = track->formatAbbreviation();
printProperty("Format", fmtName); printProperty("Format", fmtName);
@ -662,7 +662,7 @@ void setTagInfo(const SetTagInfoArgs &args)
if (field.denotes("name")) { if (field.denotes("name")) {
track->setName(value); track->setName(value);
} else if (field.denotes("language")) { } else if (field.denotes("language")) {
track->setLanguage(value); track->setLocale(Locale(std::string_view(value), LocaleFormat::Unknown));
} else if (field.denotes("tracknumber")) { } else if (field.denotes("tracknumber")) {
track->setTrackNumber(stringToNumber<std::uint32_t>(value)); track->setTrackNumber(stringToNumber<std::uint32_t>(value));
} else if (field.denotes("enabled")) { } else if (field.denotes("enabled")) {

View File

@ -7,7 +7,7 @@
#include <tagparser/abstractcontainer.h> #include <tagparser/abstractcontainer.h>
#include <tagparser/abstracttrack.h> #include <tagparser/abstracttrack.h>
#include <tagparser/diagnostics.h> #include <tagparser/diagnostics.h>
#include <tagparser/language.h> #include <tagparser/localehelper.h>
#include <tagparser/matroska/matroskacontainer.h> #include <tagparser/matroska/matroskacontainer.h>
#include <tagparser/matroska/matroskaeditionentry.h> #include <tagparser/matroska/matroskaeditionentry.h>
#include <tagparser/mediafileinfo.h> #include <tagparser/mediafileinfo.h>
@ -428,8 +428,8 @@ void FileInfoModel::updateCache()
if (!track->modificationTime().isNull()) { if (!track->modificationTime().isNull()) {
trackHelper.appendRow(tr("Modification time"), track->modificationTime()); trackHelper.appendRow(tr("Modification time"), track->modificationTime());
} }
if (!track->language().empty()) { if (!track->locale().empty()) {
trackHelper.appendRow(tr("Language"), languageNameFromIsoWithFallback(track->language())); trackHelper.appendRow(tr("Language"), track->locale().fullOrSomeAbbreviatedName());
} }
if (!track->compressorName().empty()) { if (!track->compressorName().empty()) {
trackHelper.appendRow(tr("Compressor name"), track->compressorName()); trackHelper.appendRow(tr("Compressor name"), track->compressorName());
@ -533,11 +533,7 @@ void FileInfoModel::updateCache()
ItemHelper chapterHelper(chapterItem); ItemHelper chapterHelper(chapterItem);
chapterHelper.appendRow(tr("ID"), chapter->id()); chapterHelper.appendRow(tr("ID"), chapter->id());
for (const LocaleAwareString &name : chapter->names()) { for (const LocaleAwareString &name : chapter->names()) {
static const string delim(", "); chapterHelper.appendRow(tr("Name (%1)").arg(QString::fromUtf8(name.locale().toString())), name);
const string locale = joinStrings(
initializer_list<string>{ joinStrings(name.languages(), delim, true), joinStrings(name.countries(), delim, true) }, delim,
true);
chapterHelper.appendRow(tr("Name (%1)").arg(QString::fromUtf8(locale.data())), name);
} }
if (!chapter->startTime().isNegative()) { if (!chapter->startTime().isNegative()) {
chapterHelper.appendRow(tr("Start time"), chapter->startTime()); chapterHelper.appendRow(tr("Start time"), chapter->startTime());

View File

@ -6,7 +6,7 @@
#include <tagparser/abstractattachment.h> #include <tagparser/abstractattachment.h>
#include <tagparser/abstractcontainer.h> #include <tagparser/abstractcontainer.h>
#include <tagparser/abstracttrack.h> #include <tagparser/abstracttrack.h>
#include <tagparser/language.h> #include <tagparser/localehelper.h>
#include <tagparser/matroska/matroskacontainer.h> #include <tagparser/matroska/matroskacontainer.h>
#include <tagparser/matroska/matroskaeditionentry.h> #include <tagparser/matroska/matroskaeditionentry.h>
#include <tagparser/mediafileinfo.h> #include <tagparser/mediafileinfo.h>
@ -589,8 +589,8 @@ public:
rowMaker.mkRow(QCoreApplication::translate("HtmlInfo", "Modification time"), rowMaker.mkRow(QCoreApplication::translate("HtmlInfo", "Modification time"),
qstr(track->modificationTime().toString(DateTimeOutputFormat::DateAndTime, true))); qstr(track->modificationTime().toString(DateTimeOutputFormat::DateAndTime, true)));
} }
if (!track->language().empty()) { if (const auto &language = track->locale().fullOrSomeAbbreviatedName(); !language.empty()) {
rowMaker.mkRow(QCoreApplication::translate("HtmlInfo", "Language"), qstr(languageNameFromIsoWithFallback(track->language()))); rowMaker.mkRow(QCoreApplication::translate("HtmlInfo", "Language"), qstr(language));
} }
if (!track->compressorName().empty()) { if (!track->compressorName().empty()) {
rowMaker.mkRow(QCoreApplication::translate("HtmlInfo", "Compressor name"), qstr(track->compressorName())); rowMaker.mkRow(QCoreApplication::translate("HtmlInfo", "Compressor name"), qstr(track->compressorName()));
@ -709,10 +709,7 @@ public:
rowMaker.mkRow(QCoreApplication::translate("HtmlInfo", "ID"), QString::number(chapter.id())); rowMaker.mkRow(QCoreApplication::translate("HtmlInfo", "ID"), QString::number(chapter.id()));
} }
for (const LocaleAwareString &name : chapter.names()) { for (const LocaleAwareString &name : chapter.names()) {
static const string delim(", "); rowMaker.mkRow(QCoreApplication::translate("HtmlInfo", "Name (%1)").arg(qstr(name.locale().toString())), qstr(name));
const string locale = joinStrings(
initializer_list<string>{ joinStrings(name.languages(), delim, true), joinStrings(name.countries(), delim, true) }, delim, true);
rowMaker.mkRow(QCoreApplication::translate("HtmlInfo", "Name (%1)").arg(qstr(locale)), qstr(name));
} }
if (!chapter.startTime().isNegative()) { if (!chapter.startTime().isNegative()) {
rowMaker.mkRow( rowMaker.mkRow(

View File

@ -209,7 +209,7 @@ TAGEDITOR_JS_VALUE TagEditorObject::parseFileInfo(const QString &fileName)
trackObject.setProperty(QStringLiteral("format"), QString::fromUtf8(track.formatName())); trackObject.setProperty(QStringLiteral("format"), QString::fromUtf8(track.formatName()));
trackObject.setProperty(QStringLiteral("formatAbbreviation"), QString::fromUtf8(track.formatAbbreviation())); trackObject.setProperty(QStringLiteral("formatAbbreviation"), QString::fromUtf8(track.formatAbbreviation()));
trackObject.setProperty(QStringLiteral("version"), QString::number(track.version())); trackObject.setProperty(QStringLiteral("version"), QString::number(track.version()));
trackObject.setProperty(QStringLiteral("language"), QString::fromStdString(track.language())); trackObject.setProperty(QStringLiteral("language"), QString::fromStdString(track.locale().someAbbreviatedName()));
trackObject.setProperty(QStringLiteral("description"), QString::fromStdString(track.description())); trackObject.setProperty(QStringLiteral("description"), QString::fromStdString(track.description()));
trackObject.setProperty(QStringLiteral("shortDescription"), QString::fromStdString(track.shortDescription())); trackObject.setProperty(QStringLiteral("shortDescription"), QString::fromStdString(track.shortDescription()));
tracksObject.setProperty(trackIndex, trackObject TAGEDITOR_JS_READONLY); tracksObject.setProperty(trackIndex, trackObject TAGEDITOR_JS_READONLY);