Replace QLatin1String with operator _L1

This commit is contained in:
Jonas Kvinge
2024-09-07 04:24:14 +02:00
parent e3e6a22172
commit 4270b12cd1
185 changed files with 2429 additions and 2139 deletions

View File

@@ -61,6 +61,8 @@
#include "logging.h"
using namespace Qt::StringLiterals;
namespace logging {
static Level sDefaultLevel = Level_Debug;
@@ -159,7 +161,7 @@ static void MessageHandler(QtMsgType type, const QMessageLogContext&, const QStr
break;
}
const QStringList lines = message.split(QLatin1Char('\n'));
const QStringList lines = message.split(u'\n');
for (const QString &line : lines) {
BufferedDebug d = CreateLogger<BufferedDebug>(level, QStringLiteral("unknown"), -1, nullptr);
d << line.toLocal8Bit().constData();
@@ -196,9 +198,9 @@ void SetLevels(const QString &levels) {
if (!sClassLevels) return;
const QStringList items = levels.split(QLatin1Char(','));
const QStringList items = levels.split(u',');
for (const QString &item : items) {
const QStringList class_level = item.split(QLatin1Char(':'));
const QStringList class_level = item.split(u':');
QString class_name;
bool ok = false;
@@ -216,7 +218,7 @@ void SetLevels(const QString &levels) {
continue;
}
if (class_name.isEmpty() || class_name == QLatin1Char('*')) {
if (class_name.isEmpty() || class_name == u'*') {
sDefaultLevel = static_cast<Level>(level);
}
else {
@@ -230,9 +232,9 @@ static QString ParsePrettyFunction(const char *pretty_function) {
// Get the class name out of the function name.
QString class_name = QLatin1String(pretty_function);
const qint64 paren = class_name.indexOf(QLatin1Char('('));
const qint64 paren = class_name.indexOf(u'(');
if (paren != -1) {
const qint64 colons = class_name.lastIndexOf(QLatin1String("::"), paren);
const qint64 colons = class_name.lastIndexOf("::"_L1, paren);
if (colons != -1) {
class_name = class_name.left(colons);
}
@@ -241,7 +243,7 @@ static QString ParsePrettyFunction(const char *pretty_function) {
}
}
const qint64 space = class_name.lastIndexOf(QLatin1Char(' '));
const qint64 space = class_name.lastIndexOf(u' ');
if (space != -1) {
class_name = class_name.mid(space + 1);
}

View File

@@ -31,6 +31,8 @@
#include "core/logging.h"
#include "tagreaderbase.h"
using namespace Qt::StringLiterals;
TagReaderBase::TagReaderBase() = default;
TagReaderBase::~TagReaderBase() = default;
@@ -142,11 +144,11 @@ TagReaderBase::Cover TagReaderBase::LoadCoverFromRequest(const QString &song_fil
if (cover_mime_type.isEmpty()) {
cover_mime_type = QMimeDatabase().mimeTypeForData(cover_data).name();
}
if (cover_mime_type == QLatin1String("image/jpeg")) {
if (cover_mime_type == "image/jpeg"_L1) {
qLog(Debug) << "Using cover from JPEG data for" << song_filename;
return Cover(cover_data, cover_mime_type);
}
if (cover_mime_type == QLatin1String("image/png")) {
if (cover_mime_type == "image/png"_L1) {
qLog(Debug) << "Using cover from PNG data for" << song_filename;
return Cover(cover_data, cover_mime_type);
}

View File

@@ -34,19 +34,21 @@
#include "tagreaderbase.h"
#include "tagreadertaglib.h"
using namespace Qt::StringLiterals;
#undef TStringToQString
#undef QStringToTString
bool GME::IsSupportedFormat(const QFileInfo &fileinfo) {
return fileinfo.exists() && (fileinfo.completeSuffix().endsWith(QLatin1String("spc"), Qt::CaseInsensitive) || fileinfo.completeSuffix().endsWith(QLatin1String("vgm")), Qt::CaseInsensitive);
return fileinfo.exists() && (fileinfo.completeSuffix().endsWith("spc"_L1, Qt::CaseInsensitive) || fileinfo.completeSuffix().endsWith("vgm"_L1), Qt::CaseInsensitive);
}
TagReaderBase::Result GME::ReadFile(const QFileInfo &fileinfo, spb::tagreader::SongMetadata *song) {
if (fileinfo.completeSuffix().endsWith(QLatin1String("spc")), Qt::CaseInsensitive) {
if (fileinfo.completeSuffix().endsWith("spc"_L1), Qt::CaseInsensitive) {
return SPC::Read(fileinfo, song);
}
if (fileinfo.completeSuffix().endsWith(QLatin1String("vgm"), Qt::CaseInsensitive)) {
if (fileinfo.completeSuffix().endsWith("vgm"_L1, Qt::CaseInsensitive)) {
return VGM::Read(fileinfo, song);
}
@@ -239,7 +241,7 @@ TagReaderBase::Result GME::VGM::Read(const QFileInfo &fileinfo, spb::tagreader::
QTextStream fileTagStream(gd3Data, QIODevice::ReadOnly);
// Stored as 16 bit UTF string, two bytes per letter.
fileTagStream.setEncoding(QStringConverter::Utf16);
QStringList strings = fileTagStream.readLine(0).split(QLatin1Char('\0'));
QStringList strings = fileTagStream.readLine(0).split(u'\0');
if (strings.count() < 10) {
return TagReaderBase::Result::ErrorCode::FileParseError;
}

View File

@@ -97,6 +97,8 @@
#include "core/messagehandler.h"
#include "utilities/timeconstants.h"
using namespace Qt::StringLiterals;
#undef TStringToQString
#undef QStringToTString
@@ -443,7 +445,7 @@ TagReaderBase::Result TagReaderTagLib::ReadFile(const QString &filename, spb::ta
}
if (!disc.isEmpty()) {
const qint64 i = disc.indexOf(QLatin1Char('/'));
const qint64 i = disc.indexOf(u'/');
if (i != -1) {
// disc.right( i ).toInt() is total number of discs, we don't use this at the moment
song->set_disc(disc.left(i).toInt());
@@ -457,7 +459,7 @@ TagReaderBase::Result TagReaderTagLib::ReadFile(const QString &filename, spb::ta
// well, it wasn't set, but if the artist is VA assume it's a compilation
const QString albumartist = QString::fromStdString(song->albumartist());
const QString artist = QString::fromStdString(song->artist());
if (artist.compare(QLatin1String("various artists")) == 0 || albumartist.compare(QLatin1String("various artists")) == 0) {
if (artist.compare("various artists"_L1) == 0 || albumartist.compare("various artists"_L1) == 0) {
song->set_compilation(true);
}
}
@@ -529,7 +531,7 @@ void TagReaderTagLib::ParseID3v2Tags(TagLib::ID3v2::Tag *tag, QString *disc, QSt
for (uint i = 0; i < map[kID3v2_CommercialFrame].size(); ++i) {
const TagLib::ID3v2::CommentsFrame *frame = dynamic_cast<const TagLib::ID3v2::CommentsFrame*>(map[kID3v2_CommercialFrame][i]);
if (frame && TagLibStringToQString(frame->description()) != QLatin1String("iTunNORM")) {
if (frame && TagLibStringToQString(frame->description()) != "iTunNORM"_L1) {
AssignTagLibStringToStdString(frame->text(), song->mutable_comment());
break;
}
@@ -937,7 +939,7 @@ TagReaderBase::Result TagReaderTagLib::WriteFile(const QString &filename, const
save_tags_options << QStringLiteral("embedded cover");
}
qLog(Debug) << "Saving" << save_tags_options.join(QLatin1String(", ")) << "to" << filename;
qLog(Debug) << "Saving" << save_tags_options.join(", "_L1) << "to" << filename;
const Cover cover = LoadCoverFromRequest(filename, request);
@@ -1501,10 +1503,10 @@ void TagReaderTagLib::SetEmbeddedArt(TagLib::MP4::File *aac_file, TagLib::MP4::T
}
else {
TagLib::MP4::CoverArt::Format cover_format = TagLib::MP4::CoverArt::Format::JPEG;
if (mime_type == QLatin1String("image/jpeg")) {
if (mime_type == "image/jpeg"_L1) {
cover_format = TagLib::MP4::CoverArt::Format::JPEG;
}
else if (mime_type == QLatin1String("image/png")) {
else if (mime_type == "image/png"_L1) {
cover_format = TagLib::MP4::CoverArt::Format::PNG;
}
else {