Replace QStringLiteral with QLatin1String

This commit is contained in:
Jonas Kvinge
2024-06-12 20:30:36 +02:00
parent 20595a11bc
commit 5451c110b1
64 changed files with 367 additions and 366 deletions

View File

@@ -93,20 +93,20 @@ Song ASXParser::ParseTrack(QXmlStreamReader *reader, const QDir &dir, const bool
switch (type) {
case QXmlStreamReader::StartElement:{
const QString name = reader->name().toString().toLower();
if (name == QStringLiteral("ref")) {
ref = reader->attributes().value(QStringLiteral("href")).toString();
if (name == QLatin1String("ref")) {
ref = reader->attributes().value(QLatin1String("href")).toString();
}
else if (name == QStringLiteral("title")) {
else if (name == QLatin1String("title")) {
title = reader->readElementText();
}
else if (name == QStringLiteral("author")) {
else if (name == QLatin1String("author")) {
artist = reader->readElementText();
}
break;
}
case QXmlStreamReader::EndElement:{
const QString name = reader->name().toString().toLower();
if (name == QStringLiteral("entry")) {
if (name == QLatin1String("entry")) {
goto return_song;
}
break;
@@ -138,16 +138,16 @@ void ASXParser::Save(const SongList &songs, QIODevice *device, const QDir&, cons
writer.writeStartDocument();
{
StreamElement asx(QStringLiteral("asx"), &writer);
writer.writeAttribute(QStringLiteral("version"), QStringLiteral("3.0"));
writer.writeAttribute(QLatin1String("version"), QLatin1String("3.0"));
for (const Song &song : songs) {
StreamElement entry(QStringLiteral("entry"), &writer);
writer.writeTextElement(QStringLiteral("title"), song.title());
writer.writeTextElement(QLatin1String("title"), song.title());
{
StreamElement ref(QStringLiteral("ref"), &writer);
writer.writeAttribute(QStringLiteral("href"), song.url().toString());
writer.writeAttribute(QLatin1String("href"), song.url().toString());
}
if (!song.artist().isEmpty()) {
writer.writeTextElement(QStringLiteral("author"), song.artist());
writer.writeTextElement(QLatin1String("author"), song.artist());
}
}
}

View File

@@ -69,8 +69,8 @@ void WplParser::ParseSeq(const QDir &dir, QXmlStreamReader *reader, SongList *so
QString name = reader->name().toString();
switch (type) {
case QXmlStreamReader::StartElement:{
if (name == QStringLiteral("media")) {
QString src = reader->attributes().value(QStringLiteral("src")).toString();
if (name == QLatin1String("media")) {
QString src = reader->attributes().value(QLatin1String("src")).toString();
if (!src.isEmpty()) {
Song song = LoadSong(src, 0, 0, dir, collection_search);
if (song.is_valid()) {
@@ -84,7 +84,7 @@ void WplParser::ParseSeq(const QDir &dir, QXmlStreamReader *reader, SongList *so
break;
}
case QXmlStreamReader::EndElement:{
if (name == QStringLiteral("seq")) {
if (name == QLatin1String("seq")) {
return;
}
break;
@@ -101,14 +101,14 @@ void WplParser::Save(const SongList &songs, QIODevice *device, const QDir &dir,
QXmlStreamWriter writer(device);
writer.setAutoFormatting(true);
writer.setAutoFormattingIndent(2);
writer.writeProcessingInstruction(QStringLiteral("wpl"), QStringLiteral("version=\"1.0\""));
writer.writeProcessingInstruction(QLatin1String("wpl"), QLatin1String("version=\"1.0\""));
StreamElement smil(QStringLiteral("smil"), &writer);
{
StreamElement head(QStringLiteral("head"), &writer);
WriteMeta(QStringLiteral("Generator"), QStringLiteral("Strawberry -- ") + QLatin1String(STRAWBERRY_VERSION_DISPLAY), &writer);
WriteMeta(QStringLiteral("ItemCount"), QString::number(songs.count()), &writer);
WriteMeta(QLatin1String("Generator"), QLatin1String("Strawberry -- ") + QLatin1String(STRAWBERRY_VERSION_DISPLAY), &writer);
WriteMeta(QLatin1String("ItemCount"), QString::number(songs.count()), &writer);
}
{
@@ -116,8 +116,8 @@ void WplParser::Save(const SongList &songs, QIODevice *device, const QDir &dir,
{
StreamElement seq(QStringLiteral("seq"), &writer);
for (const Song &song : songs) {
writer.writeStartElement(QStringLiteral("media"));
writer.writeAttribute(QStringLiteral("src"), URLOrFilename(song.url(), dir, path_type));
writer.writeStartElement(QLatin1String("media"));
writer.writeAttribute(QLatin1String("src"), URLOrFilename(song.url(), dir, path_type));
writer.writeEndElement();
}
}
@@ -126,9 +126,9 @@ void WplParser::Save(const SongList &songs, QIODevice *device, const QDir &dir,
void WplParser::WriteMeta(const QString &name, const QString &content, QXmlStreamWriter *writer) {
writer->writeStartElement(QStringLiteral("meta"));
writer->writeAttribute(QStringLiteral("name"), name);
writer->writeAttribute(QStringLiteral("content"), content);
writer->writeStartElement(QLatin1String("meta"));
writer->writeAttribute(QLatin1String("name"), name);
writer->writeAttribute(QLatin1String("content"), content);
writer->writeEndElement();
}

View File

@@ -74,22 +74,22 @@ Song XSPFParser::ParseTrack(QXmlStreamReader *reader, const QDir &dir, const boo
QString name = reader->name().toString();
switch (type) {
case QXmlStreamReader::StartElement:{
if (name == QStringLiteral("location")) {
if (name == QLatin1String("location")) {
location = QUrl::fromPercentEncoding(reader->readElementText().toUtf8());
}
else if (name == QStringLiteral("title")) {
else if (name == QLatin1String("title")) {
title = reader->readElementText();
}
else if (name == QStringLiteral("creator")) {
else if (name == QLatin1String("creator")) {
artist = reader->readElementText();
}
else if (name == QStringLiteral("album")) {
else if (name == QLatin1String("album")) {
album = reader->readElementText();
}
else if (name == QStringLiteral("image")) {
else if (name == QLatin1String("image")) {
art = QUrl::fromPercentEncoding(reader->readElementText().toUtf8());
}
else if (name == QStringLiteral("duration")) { // in milliseconds.
else if (name == QLatin1String("duration")) { // in milliseconds.
const QString duration = reader->readElementText();
bool ok = false;
nanosec = duration.toInt(&ok) * kNsecPerMsec;
@@ -97,7 +97,7 @@ Song XSPFParser::ParseTrack(QXmlStreamReader *reader, const QDir &dir, const boo
nanosec = -1;
}
}
else if (name == QStringLiteral("trackNum")) {
else if (name == QLatin1String("trackNum")) {
const QString track_num_str = reader->readElementText();
bool ok = false;
track_num = track_num_str.toInt(&ok);
@@ -105,13 +105,13 @@ Song XSPFParser::ParseTrack(QXmlStreamReader *reader, const QDir &dir, const boo
track_num = -1;
}
}
else if (name == QStringLiteral("info")) {
else if (name == QLatin1String("info")) {
// TODO: Do something with extra info?
}
break;
}
case QXmlStreamReader::EndElement:{
if (name == QStringLiteral("track")) {
if (name == QLatin1String("track")) {
goto return_song;
}
}
@@ -144,8 +144,8 @@ void XSPFParser::Save(const SongList &songs, QIODevice *device, const QDir &dir,
writer.setAutoFormattingIndent(2);
writer.writeStartDocument();
StreamElement playlist(QStringLiteral("playlist"), &writer);
writer.writeAttribute(QStringLiteral("version"), QStringLiteral("1"));
writer.writeDefaultNamespace(QStringLiteral("http://xspf.org/ns/0/"));
writer.writeAttribute(QLatin1String("version"), QLatin1String("1"));
writer.writeDefaultNamespace(QLatin1String("http://xspf.org/ns/0/"));
Settings s;
s.beginGroup(PlaylistSettingsPage::kSettingsGroup);
@@ -157,23 +157,23 @@ void XSPFParser::Save(const SongList &songs, QIODevice *device, const QDir &dir,
QString filename_or_url = QString::fromLatin1(QUrl::toPercentEncoding(URLOrFilename(song.url(), dir, path_type), "/ "));
StreamElement track(QStringLiteral("track"), &writer);
writer.writeTextElement(QStringLiteral("location"), filename_or_url);
writer.writeTextElement(QLatin1String("location"), filename_or_url);
if (write_metadata || (song.is_stream() && !song.is_radio())) {
writer.writeTextElement(QStringLiteral("title"), song.title());
writer.writeTextElement(QLatin1String("title"), song.title());
if (!song.artist().isEmpty()) {
writer.writeTextElement(QStringLiteral("creator"), song.artist());
writer.writeTextElement(QLatin1String("creator"), song.artist());
}
if (!song.album().isEmpty()) {
writer.writeTextElement(QStringLiteral("album"), song.album());
writer.writeTextElement(QLatin1String("album"), song.album());
}
if (song.length_nanosec() != -1) {
writer.writeTextElement(QStringLiteral("duration"), QString::number(song.length_nanosec() / kNsecPerMsec));
writer.writeTextElement(QLatin1String("duration"), QString::number(song.length_nanosec() / kNsecPerMsec));
}
}
if ((write_metadata || song.has_cue() || (song.is_stream() && !song.is_radio())) && song.track() > 0) {
writer.writeTextElement(QStringLiteral("trackNum"), QString::number(song.track()));
writer.writeTextElement(QLatin1String("trackNum"), QString::number(song.track()));
}
if (write_metadata || (song.is_stream() && !song.is_radio())) {
@@ -181,7 +181,7 @@ void XSPFParser::Save(const SongList &songs, QIODevice *device, const QDir &dir,
// Ignore images that are in our resource bundle.
if (!cover_url.isEmpty() && cover_url.isValid()) {
const QString cover_filename = QString::fromLatin1(QUrl::toPercentEncoding(URLOrFilename(cover_url, dir, path_type), "/ "));
writer.writeTextElement(QStringLiteral("image"), cover_filename);
writer.writeTextElement(QLatin1String("image"), cover_filename);
}
}
}