Disable automatic conversions from 8-bit strings
This commit is contained in:
@@ -30,6 +30,7 @@
|
||||
#include <QXmlStreamWriter>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/settings.h"
|
||||
#include "utilities/xmlutils.h"
|
||||
#include "utilities/timeconstants.h"
|
||||
#include "settings/playlistsettingspage.h"
|
||||
@@ -72,23 +73,23 @@ Song XSPFParser::ParseTrack(QXmlStreamReader *reader, const QDir &dir, const boo
|
||||
QXmlStreamReader::TokenType type = reader->readNext();
|
||||
QString name = reader->name().toString();
|
||||
switch (type) {
|
||||
case QXmlStreamReader::StartElement: {
|
||||
if (name == "location") {
|
||||
case QXmlStreamReader::StartElement:{
|
||||
if (name == QStringLiteral("location")) {
|
||||
location = QUrl::fromPercentEncoding(reader->readElementText().toUtf8());
|
||||
}
|
||||
else if (name == "title") {
|
||||
else if (name == QStringLiteral("title")) {
|
||||
title = reader->readElementText();
|
||||
}
|
||||
else if (name == "creator") {
|
||||
else if (name == QStringLiteral("creator")) {
|
||||
artist = reader->readElementText();
|
||||
}
|
||||
else if (name == "album") {
|
||||
else if (name == QStringLiteral("album")) {
|
||||
album = reader->readElementText();
|
||||
}
|
||||
else if (name == "image") {
|
||||
else if (name == QStringLiteral("image")) {
|
||||
art = QUrl::fromPercentEncoding(reader->readElementText().toUtf8());
|
||||
}
|
||||
else if (name == "duration") { // in milliseconds.
|
||||
else if (name == QStringLiteral("duration")) { // in milliseconds.
|
||||
const QString duration = reader->readElementText();
|
||||
bool ok = false;
|
||||
nanosec = duration.toInt(&ok) * kNsecPerMsec;
|
||||
@@ -96,7 +97,7 @@ Song XSPFParser::ParseTrack(QXmlStreamReader *reader, const QDir &dir, const boo
|
||||
nanosec = -1;
|
||||
}
|
||||
}
|
||||
else if (name == "trackNum") {
|
||||
else if (name == QStringLiteral("trackNum")) {
|
||||
const QString track_num_str = reader->readElementText();
|
||||
bool ok = false;
|
||||
track_num = track_num_str.toInt(&ok);
|
||||
@@ -104,13 +105,13 @@ Song XSPFParser::ParseTrack(QXmlStreamReader *reader, const QDir &dir, const boo
|
||||
track_num = -1;
|
||||
}
|
||||
}
|
||||
else if (name == "info") {
|
||||
else if (name == QStringLiteral("info")) {
|
||||
// TODO: Do something with extra info?
|
||||
}
|
||||
break;
|
||||
}
|
||||
case QXmlStreamReader::EndElement: {
|
||||
if (name == "track") {
|
||||
case QXmlStreamReader::EndElement:{
|
||||
if (name == QStringLiteral("track")) {
|
||||
goto return_song;
|
||||
}
|
||||
}
|
||||
@@ -143,44 +144,44 @@ void XSPFParser::Save(const SongList &songs, QIODevice *device, const QDir &dir,
|
||||
writer.setAutoFormattingIndent(2);
|
||||
writer.writeStartDocument();
|
||||
StreamElement playlist(QStringLiteral("playlist"), &writer);
|
||||
writer.writeAttribute("version", "1");
|
||||
writer.writeDefaultNamespace("http://xspf.org/ns/0/");
|
||||
writer.writeAttribute(QStringLiteral("version"), QStringLiteral("1"));
|
||||
writer.writeDefaultNamespace(QStringLiteral("http://xspf.org/ns/0/"));
|
||||
|
||||
QSettings s;
|
||||
Settings s;
|
||||
s.beginGroup(PlaylistSettingsPage::kSettingsGroup);
|
||||
bool write_metadata = s.value("write_metadata", true).toBool();
|
||||
s.endGroup();
|
||||
|
||||
StreamElement tracklist(QStringLiteral("trackList"), &writer);
|
||||
for (const Song &song : songs) {
|
||||
QString filename_or_url = QUrl::toPercentEncoding(URLOrFilename(song.url(), dir, path_type), "/ ");
|
||||
QString filename_or_url = QString::fromLatin1(QUrl::toPercentEncoding(URLOrFilename(song.url(), dir, path_type), "/ "));
|
||||
|
||||
StreamElement track(QStringLiteral("track"), &writer);
|
||||
writer.writeTextElement("location", filename_or_url);
|
||||
writer.writeTextElement(QStringLiteral("location"), filename_or_url);
|
||||
|
||||
if (write_metadata || (song.is_stream() && !song.is_radio())) {
|
||||
writer.writeTextElement("title", song.title());
|
||||
writer.writeTextElement(QStringLiteral("title"), song.title());
|
||||
if (!song.artist().isEmpty()) {
|
||||
writer.writeTextElement("creator", song.artist());
|
||||
writer.writeTextElement(QStringLiteral("creator"), song.artist());
|
||||
}
|
||||
if (!song.album().isEmpty()) {
|
||||
writer.writeTextElement("album", song.album());
|
||||
writer.writeTextElement(QStringLiteral("album"), song.album());
|
||||
}
|
||||
if (song.length_nanosec() != -1) {
|
||||
writer.writeTextElement("duration", QString::number(song.length_nanosec() / kNsecPerMsec));
|
||||
writer.writeTextElement(QStringLiteral("duration"), QString::number(song.length_nanosec() / kNsecPerMsec));
|
||||
}
|
||||
}
|
||||
|
||||
if ((write_metadata || song.has_cue() || (song.is_stream() && !song.is_radio())) && song.track() > 0) {
|
||||
writer.writeTextElement("trackNum", QString::number(song.track()));
|
||||
writer.writeTextElement(QStringLiteral("trackNum"), QString::number(song.track()));
|
||||
}
|
||||
|
||||
if (write_metadata || (song.is_stream() && !song.is_radio())) {
|
||||
const QUrl cover_url = song.art_manual().isEmpty() || !song.art_manual().isValid() ? song.art_automatic() : song.art_manual();
|
||||
// Ignore images that are in our resource bundle.
|
||||
if (!cover_url.isEmpty() && cover_url.isValid()) {
|
||||
const QString cover_filename = QUrl::toPercentEncoding(URLOrFilename(cover_url, dir, path_type), "/ ");
|
||||
writer.writeTextElement("image", cover_filename);
|
||||
const QString cover_filename = QString::fromLatin1(QUrl::toPercentEncoding(URLOrFilename(cover_url, dir, path_type), "/ "));
|
||||
writer.writeTextElement(QStringLiteral("image"), cover_filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user