Use QStringLiteral

This commit is contained in:
Jonas Kvinge 2024-04-09 23:20:26 +02:00
parent 3cfffa5fbb
commit 58944993b8
233 changed files with 3885 additions and 3885 deletions

View File

@ -158,7 +158,7 @@ static void MessageHandler(QtMsgType type, const QMessageLogContext&, const QStr
}
for (const QString &line : message.split('\n')) {
BufferedDebug d = CreateLogger<BufferedDebug>(level, "unknown", -1, nullptr);
BufferedDebug d = CreateLogger<BufferedDebug>(level, QStringLiteral("unknown"), -1, nullptr);
d << line.toLocal8Bit().constData();
if (d.buf_) {
d.buf_->close();
@ -228,7 +228,7 @@ static QString ParsePrettyFunction(const char *pretty_function) {
QString class_name = pretty_function;
const qint64 paren = class_name.indexOf('(');
if (paren != -1) {
const qint64 colons = class_name.lastIndexOf("::", paren);
const qint64 colons = class_name.lastIndexOf(QLatin1String("::"), paren);
if (colons != -1) {
class_name = class_name.left(colons);
}
@ -284,7 +284,7 @@ static T CreateLogger(Level level, const QString &class_name, int line, const ch
}
T ret(type);
ret.nospace() << QDateTime::currentDateTime().toString("hh:mm:ss.zzz").toLatin1().constData() << level_name << function_line.leftJustified(32).toLatin1().constData();
ret.nospace() << QDateTime::currentDateTime().toString(QStringLiteral("hh:mm:ss.zzz")).toLatin1().constData() << level_name << function_line.leftJustified(32).toLatin1().constData();
return ret.space();
@ -310,7 +310,7 @@ QString CXXDemangle(const QString &mangled_function) {
QString LinuxDemangle(const QString &symbol);
QString LinuxDemangle(const QString &symbol) {
QRegularExpression regex("\\(([^+]+)");
QRegularExpression regex(QStringLiteral("\\(([^+]+)"));
QRegularExpressionMatch match = regex.match(symbol);
if (!match.hasMatch()) {
return symbol;
@ -392,7 +392,7 @@ namespace {
template<typename T>
QString print_duration(T duration, const std::string &unit) {
return QString("%1%2").arg(duration.count()).arg(unit.c_str());
return QStringLiteral("%1%2").arg(duration.count()).arg(unit.c_str());
}
} // namespace

View File

@ -171,7 +171,7 @@ WorkerPool<HandlerType>::WorkerPool(QObject *parent)
local_server_name_ = qApp->applicationName().toLower();
if (local_server_name_.isEmpty()) {
local_server_name_ = "workerpool";
local_server_name_ = QStringLiteral("workerpool");
}
}
@ -243,8 +243,8 @@ void WorkerPool<HandlerType>::DoStart() {
QStringList search_path;
search_path << QCoreApplication::applicationDirPath();
#if defined(Q_OS_UNIX)
search_path << "/usr/libexec";
search_path << "/usr/local/libexec";
search_path << QStringLiteral("/usr/libexec");
search_path << QStringLiteral("/usr/local/libexec");
#endif
#if defined(Q_OS_MACOS)
search_path << QDir::cleanPath(QCoreApplication::applicationDirPath() + "/../PlugIns");
@ -294,7 +294,7 @@ void WorkerPool<HandlerType>::StartOneWorker(Worker *worker) {
// Create a server, find an unused name and start listening
forever {
const quint32 unique_number = QRandomGenerator::global()->bounded(static_cast<quint32>(quint64(this) & 0xFFFFFFFF));
const QString name = QString("%1_%2").arg(local_server_name_).arg(unique_number);
const QString name = QStringLiteral("%1_%2").arg(local_server_name_).arg(unique_number);
if (worker->local_server_->listen(name)) {
break;

View File

@ -135,7 +135,7 @@ TagReaderBase::Cover TagReaderBase::LoadCoverFromRequest(const QString &song_fil
cover_image.save(&buffer, "JPEG");
buffer.close();
}
return Cover(cover_data, "image/jpeg");
return Cover(cover_data, QStringLiteral("image/jpeg"));
}
return Cover();

View File

@ -36,16 +36,16 @@
#include "tagreadertaglib.h"
bool GME::IsSupportedFormat(const QFileInfo &file_info) {
return file_info.exists() && (file_info.completeSuffix().endsWith("spc", Qt::CaseInsensitive) || file_info.completeSuffix().endsWith("vgm"), Qt::CaseInsensitive);
return file_info.exists() && (file_info.completeSuffix().endsWith(QLatin1String("spc"), Qt::CaseInsensitive) || file_info.completeSuffix().endsWith(QLatin1String("vgm")), Qt::CaseInsensitive);
}
bool GME::ReadFile(const QFileInfo &file_info, spb::tagreader::SongMetadata *song_info) {
if (file_info.completeSuffix().endsWith("spc"), Qt::CaseInsensitive) {
if (file_info.completeSuffix().endsWith(QLatin1String("spc")), Qt::CaseInsensitive) {
SPC::Read(file_info, song_info);
return true;
}
if (file_info.completeSuffix().endsWith("vgm", Qt::CaseInsensitive)) {
if (file_info.completeSuffix().endsWith(QLatin1String("vgm"), Qt::CaseInsensitive)) {
VGM::Read(file_info, song_info);
return true;
}
@ -75,7 +75,7 @@ void GME::SPC::Read(const QFileInfo &file_info, spb::tagreader::SongMetadata *so
qLog(Debug) << "Reading tags from SPC file" << file_info.fileName();
// Check for header -- more reliable than file name alone.
if (!file.read(33).startsWith(QString("SNES-SPC700").toLatin1())) return;
if (!file.read(33).startsWith(QStringLiteral("SNES-SPC700").toLatin1())) return;
// First order of business -- get any tag values that exist within the core file information.
// These only allow for a certain number of bytes per field,
@ -125,7 +125,7 @@ void GME::SPC::Read(const QFileInfo &file_info, spb::tagreader::SongMetadata *so
// Check for XID6 data -- this is infrequently used, but being able to fill in data from this is ideal before trying to rely on APETAG values.
// XID6 format follows EA's binary file format standard named "IFF"
file.seek(XID6_OFFSET);
if (has_id6 && file.read(4) == QString("xid6").toLatin1()) {
if (has_id6 && file.read(4) == QStringLiteral("xid6").toLatin1()) {
QByteArray xid6_head_data = file.read(4);
if (xid6_head_data.size() >= 4) {
qint64 xid6_size = xid6_head_data[0] | (xid6_head_data[1] << 8) | (xid6_head_data[2] << 16) | xid6_head_data[3];
@ -195,7 +195,7 @@ void GME::VGM::Read(const QFileInfo &file_info, spb::tagreader::SongMetadata *so
qLog(Debug) << "Reading tags from VGM file" << file_info.fileName();
if (!file.read(4).startsWith(QString("Vgm ").toLatin1())) return;
if (!file.read(4).startsWith(QStringLiteral("Vgm ").toLatin1())) return;
file.seek(GD3_TAG_PTR);
QByteArray gd3_head = file.read(4);

View File

@ -677,7 +677,7 @@ bool TagReaderTagLib::ReadFile(const QString &filename, spb::tagreader::SongMeta
// well, it wasn't set, but if the artist is VA assume it's a compilation
const QString albumartist = QString::fromUtf8(song->albumartist().data(), static_cast<qint64>(song->albumartist().size()));
const QString artist = QString::fromUtf8(song->artist().data(), static_cast<qint64>(song->artist().size()));
if (artist.compare("various artists") == 0 || albumartist.compare("various artists") == 0) {
if (artist.compare(QLatin1String("various artists")) == 0 || albumartist.compare(QLatin1String("various artists")) == 0) {
song->set_compilation(true);
}
}
@ -824,7 +824,7 @@ void TagReaderTagLib::SetVorbisComments(TagLib::Ogg::XiphComment *vorbis_comment
vorbis_comment->addField("PERFORMER", StdStringToTaglibString(song.performer()), true);
vorbis_comment->addField("GROUPING", StdStringToTaglibString(song.grouping()), true);
vorbis_comment->addField("DISCNUMBER", QStringToTaglibString(song.disc() <= 0 ? QString() : QString::number(song.disc())), true);
vorbis_comment->addField("COMPILATION", QStringToTaglibString(song.compilation() ? "1" : QString()), true);
vorbis_comment->addField("COMPILATION", QStringToTaglibString(song.compilation() ? QStringLiteral("1") : QString()), true);
// Try to be coherent, the two forms are used but the first one is preferred
@ -849,19 +849,19 @@ bool TagReaderTagLib::SaveFile(const spb::tagreader::SaveFileRequest &request) c
QStringList save_tags_options;
if (save_tags) {
save_tags_options << "tags";
save_tags_options << QStringLiteral("tags");
}
if (save_playcount) {
save_tags_options << "playcount";
save_tags_options << QStringLiteral("playcount");
}
if (save_rating) {
save_tags_options << "rating";
save_tags_options << QStringLiteral("rating");
}
if (save_cover) {
save_tags_options << "embedded cover";
save_tags_options << QStringLiteral("embedded cover");
}
qLog(Debug) << "Saving" << save_tags_options.join(", ") << "to" << filename;
qLog(Debug) << "Saving" << save_tags_options.join(QStringLiteral(", ")) << "to" << filename;
const Cover cover = LoadCoverFromRequest(request);
@ -1427,7 +1427,7 @@ void TagReaderTagLib::SetPlaycount(TagLib::APE::Tag *tag, const spb::tagreader::
void TagReaderTagLib::SetPlaycount(TagLib::ID3v2::Tag *tag, const spb::tagreader::SongMetadata &song) const {
SetUserTextFrame("FMPS_Playcount", QString::number(song.playcount()), tag);
SetUserTextFrame(QStringLiteral("FMPS_Playcount"), QString::number(song.playcount()), tag);
TagLib::ID3v2::PopularimeterFrame *frame = GetPOPMFrameFromTag(tag);
if (frame) {
frame->setCounter(song.playcount());
@ -1546,7 +1546,7 @@ void TagReaderTagLib::SetRating(TagLib::APE::Tag *tag, const spb::tagreader::Son
void TagReaderTagLib::SetRating(TagLib::ID3v2::Tag *tag, const spb::tagreader::SongMetadata &song) const {
SetUserTextFrame("FMPS_Rating", QString::number(song.rating()), tag);
SetUserTextFrame(QStringLiteral("FMPS_Rating"), QString::number(song.rating()), tag);
TagLib::ID3v2::PopularimeterFrame *frame = GetPOPMFrameFromTag(tag);
if (frame) {
frame->setRating(ConvertToPOPMRating(song.rating()));

View File

@ -65,8 +65,8 @@ RainbowAnalyzer::RainbowAnalyzer(const RainbowType rbtype, QWidget *parent)
background_brush_(QColor(0x0f, 0x43, 0x73)) {
rainbowtype = rbtype;
cat_dash_[0] = QPixmap(":/pictures/nyancat.png");
cat_dash_[1] = QPixmap(":/pictures/rainbowdash.png");
cat_dash_[0] = QPixmap(QStringLiteral(":/pictures/nyancat.png"));
cat_dash_[1] = QPixmap(QStringLiteral(":/pictures/rainbowdash.png"));
memset(history_, 0, sizeof(history_));
for (int i = 0; i < kRainbowBands; ++i) {

View File

@ -175,9 +175,9 @@ void CollectionBackend::ChangeDirPath(const int id, const QString &old_path, con
// Do the dirs table
{
SqlQuery q(db);
q.prepare(QString("UPDATE %1 SET path=:path WHERE ROWID=:id").arg(dirs_table_));
q.BindValue(":path", new_path);
q.BindValue(":id", id);
q.prepare(QStringLiteral("UPDATE %1 SET path=:path WHERE ROWID=:id").arg(dirs_table_));
q.BindValue(QStringLiteral(":path"), new_path);
q.BindValue(QStringLiteral(":id"), id);
if (!q.Exec()) {
db_->ReportErrors(q);
return;
@ -192,9 +192,9 @@ void CollectionBackend::ChangeDirPath(const int id, const QString &old_path, con
// Do the subdirs table
{
SqlQuery q(db);
q.prepare(QString("UPDATE %1 SET path=:path || substr(path, %2) WHERE directory=:id").arg(subdirs_table_).arg(path_len));
q.BindValue(":path", new_url);
q.BindValue(":id", id);
q.prepare(QStringLiteral("UPDATE %1 SET path=:path || substr(path, %2) WHERE directory=:id").arg(subdirs_table_).arg(path_len));
q.BindValue(QStringLiteral(":path"), new_url);
q.BindValue(QStringLiteral(":id"), id);
if (!q.Exec()) {
db_->ReportErrors(q);
return;
@ -204,9 +204,9 @@ void CollectionBackend::ChangeDirPath(const int id, const QString &old_path, con
// Do the songs table
{
SqlQuery q(db);
q.prepare(QString("UPDATE %1 SET url=:path || substr(url, %2) WHERE directory=:id").arg(songs_table_).arg(path_len));
q.BindValue(":path", new_url);
q.BindValue(":id", id);
q.prepare(QStringLiteral("UPDATE %1 SET url=:path || substr(url, %2) WHERE directory=:id").arg(songs_table_).arg(path_len));
q.BindValue(QStringLiteral(":path"), new_url);
q.BindValue(QStringLiteral(":id"), id);
if (!q.Exec()) {
db_->ReportErrors(q);
return;
@ -225,7 +225,7 @@ CollectionDirectoryList CollectionBackend::GetAllDirectories() {
CollectionDirectoryList ret;
SqlQuery q(db);
q.prepare(QString("SELECT ROWID, path FROM %1").arg(dirs_table_));
q.prepare(QStringLiteral("SELECT ROWID, path FROM %1").arg(dirs_table_));
if (!q.Exec()) {
db_->ReportErrors(q);
return ret;
@ -253,8 +253,8 @@ CollectionSubdirectoryList CollectionBackend::SubdirsInDirectory(const int id) {
CollectionSubdirectoryList CollectionBackend::SubdirsInDirectory(const int id, QSqlDatabase &db) {
SqlQuery q(db);
q.prepare(QString("SELECT path, mtime FROM %1 WHERE directory_id = :dir").arg(subdirs_table_));
q.BindValue(":dir", id);
q.prepare(QStringLiteral("SELECT path, mtime FROM %1 WHERE directory_id = :dir").arg(subdirs_table_));
q.BindValue(QStringLiteral(":dir"), id);
if (!q.Exec()) {
db_->ReportErrors(q);
return CollectionSubdirectoryList();
@ -279,7 +279,7 @@ void CollectionBackend::UpdateTotalSongCount() {
QSqlDatabase db(db_->Connect());
SqlQuery q(db);
q.prepare(QString("SELECT COUNT(*) FROM %1 WHERE unavailable = 0").arg(songs_table_));
q.prepare(QStringLiteral("SELECT COUNT(*) FROM %1 WHERE unavailable = 0").arg(songs_table_));
if (!q.Exec()) {
db_->ReportErrors(q);
return;
@ -299,7 +299,7 @@ void CollectionBackend::UpdateTotalArtistCount() {
QSqlDatabase db(db_->Connect());
SqlQuery q(db);
q.prepare(QString("SELECT COUNT(DISTINCT artist) FROM %1 WHERE unavailable = 0").arg(songs_table_));
q.prepare(QStringLiteral("SELECT COUNT(DISTINCT artist) FROM %1 WHERE unavailable = 0").arg(songs_table_));
if (!q.Exec()) {
db_->ReportErrors(q);
return;
@ -319,7 +319,7 @@ void CollectionBackend::UpdateTotalAlbumCount() {
QSqlDatabase db(db_->Connect());
SqlQuery q(db);
q.prepare(QString("SELECT COUNT(*) FROM (SELECT DISTINCT effective_albumartist, album FROM %1 WHERE unavailable = 0)").arg(songs_table_));
q.prepare(QStringLiteral("SELECT COUNT(*) FROM (SELECT DISTINCT effective_albumartist, album FROM %1 WHERE unavailable = 0)").arg(songs_table_));
if (!q.Exec()) {
db_->ReportErrors(q);
return;
@ -342,8 +342,8 @@ void CollectionBackend::AddDirectory(const QString &path) {
QSqlDatabase db(db_->Connect());
SqlQuery q(db);
q.prepare(QString("INSERT INTO %1 (path, subdirs) VALUES (:path, 1)").arg(dirs_table_));
q.BindValue(":path", db_path);
q.prepare(QStringLiteral("INSERT INTO %1 (path, subdirs) VALUES (:path, 1)").arg(dirs_table_));
q.BindValue(QStringLiteral(":path"), db_path);
if (!q.Exec()) {
db_->ReportErrors(q);
return;
@ -370,8 +370,8 @@ void CollectionBackend::RemoveDirectory(const CollectionDirectory &dir) {
// Delete the subdirs that were in this directory
{
SqlQuery q(db);
q.prepare(QString("DELETE FROM %1 WHERE directory_id = :id").arg(subdirs_table_));
q.BindValue(":id", dir.id);
q.prepare(QStringLiteral("DELETE FROM %1 WHERE directory_id = :id").arg(subdirs_table_));
q.BindValue(QStringLiteral(":id"), dir.id);
if (!q.Exec()) {
db_->ReportErrors(q);
return;
@ -381,8 +381,8 @@ void CollectionBackend::RemoveDirectory(const CollectionDirectory &dir) {
// Now remove the directory itself
{
SqlQuery q(db);
q.prepare(QString("DELETE FROM %1 WHERE ROWID = :id").arg(dirs_table_));
q.BindValue(":id", dir.id);
q.prepare(QStringLiteral("DELETE FROM %1 WHERE ROWID = :id").arg(dirs_table_));
q.BindValue(QStringLiteral(":id"), dir.id);
if (!q.Exec()) {
db_->ReportErrors(q);
return;
@ -401,8 +401,8 @@ SongList CollectionBackend::FindSongsInDirectory(const int id) {
QSqlDatabase db(db_->Connect());
SqlQuery q(db);
q.prepare(QString("SELECT ROWID, %1 FROM %2 WHERE directory_id = :directory_id").arg(Song::kColumnSpec, songs_table_));
q.BindValue(":directory_id", id);
q.prepare(QStringLiteral("SELECT ROWID, %1 FROM %2 WHERE directory_id = :directory_id").arg(Song::kColumnSpec, songs_table_));
q.BindValue(QStringLiteral(":directory_id"), id);
if (!q.Exec()) {
db_->ReportErrors(q);
return SongList();
@ -424,8 +424,8 @@ SongList CollectionBackend::SongsWithMissingFingerprint(const int id) {
QSqlDatabase db(db_->Connect());
SqlQuery q(db);
q.prepare(QString("SELECT ROWID, %1 FROM %2 WHERE directory_id = :directory_id AND unavailable = 0 AND (fingerprint IS NULL OR fingerprint = '')").arg(Song::kColumnSpec, songs_table_));
q.BindValue(":directory_id", id);
q.prepare(QStringLiteral("SELECT ROWID, %1 FROM %2 WHERE directory_id = :directory_id AND unavailable = 0 AND (fingerprint IS NULL OR fingerprint = '')").arg(Song::kColumnSpec, songs_table_));
q.BindValue(QStringLiteral(":directory_id"), id);
if (!q.Exec()) {
db_->ReportErrors(q);
return SongList();
@ -447,8 +447,8 @@ SongList CollectionBackend::SongsWithMissingLoudnessCharacteristics(const int id
QSqlDatabase db(db_->Connect());
SqlQuery q(db);
q.prepare(QString("SELECT ROWID, %1 FROM %2 WHERE directory_id = :directory_id AND unavailable = 0 AND (ebur128_integrated_loudness_lufs IS NULL OR ebur128_loudness_range_lu IS NULL)").arg(Song::kColumnSpec, songs_table_));
q.BindValue(":directory_id", id);
q.prepare(QStringLiteral("SELECT ROWID, %1 FROM %2 WHERE directory_id = :directory_id AND unavailable = 0 AND (ebur128_integrated_loudness_lufs IS NULL OR ebur128_loudness_range_lu IS NULL)").arg(Song::kColumnSpec, songs_table_));
q.BindValue(QStringLiteral(":directory_id"), id);
if (!q.Exec()) {
db_->ReportErrors(q);
return SongList();
@ -490,9 +490,9 @@ void CollectionBackend::AddOrUpdateSubdirs(const CollectionSubdirectoryList &sub
if (subdir.mtime == 0) {
// Delete the subdirectory
SqlQuery q(db);
q.prepare(QString("DELETE FROM %1 WHERE directory_id = :id AND path = :path").arg(subdirs_table_));
q.BindValue(":id", subdir.directory_id);
q.BindValue(":path", subdir.path);
q.prepare(QStringLiteral("DELETE FROM %1 WHERE directory_id = :id AND path = :path").arg(subdirs_table_));
q.BindValue(QStringLiteral(":id"), subdir.directory_id);
q.BindValue(QStringLiteral(":path"), subdir.path);
if (!q.Exec()) {
db_->ReportErrors(q);
return;
@ -503,9 +503,9 @@ void CollectionBackend::AddOrUpdateSubdirs(const CollectionSubdirectoryList &sub
bool exists = false;
{
SqlQuery q(db);
q.prepare(QString("SELECT ROWID FROM %1 WHERE directory_id = :id AND path = :path").arg(subdirs_table_));
q.BindValue(":id", subdir.directory_id);
q.BindValue(":path", subdir.path);
q.prepare(QStringLiteral("SELECT ROWID FROM %1 WHERE directory_id = :id AND path = :path").arg(subdirs_table_));
q.BindValue(QStringLiteral(":id"), subdir.directory_id);
q.BindValue(QStringLiteral(":path"), subdir.path);
if (!q.Exec()) {
db_->ReportErrors(q);
return;
@ -515,10 +515,10 @@ void CollectionBackend::AddOrUpdateSubdirs(const CollectionSubdirectoryList &sub
if (exists) {
SqlQuery q(db);
q.prepare(QString("UPDATE %1 SET mtime = :mtime WHERE directory_id = :id AND path = :path").arg(subdirs_table_));
q.BindValue(":mtime", subdir.mtime);
q.BindValue(":id", subdir.directory_id);
q.BindValue(":path", subdir.path);
q.prepare(QStringLiteral("UPDATE %1 SET mtime = :mtime WHERE directory_id = :id AND path = :path").arg(subdirs_table_));
q.BindValue(QStringLiteral(":mtime"), subdir.mtime);
q.BindValue(QStringLiteral(":id"), subdir.directory_id);
q.BindValue(QStringLiteral(":path"), subdir.path);
if (!q.Exec()) {
db_->ReportErrors(q);
return;
@ -526,10 +526,10 @@ void CollectionBackend::AddOrUpdateSubdirs(const CollectionSubdirectoryList &sub
}
else {
SqlQuery q(db);
q.prepare(QString("INSERT INTO %1 (directory_id, path, mtime) VALUES (:id, :path, :mtime)").arg(subdirs_table_));
q.BindValue(":id", subdir.directory_id);
q.BindValue(":path", subdir.path);
q.BindValue(":mtime", subdir.mtime);
q.prepare(QStringLiteral("INSERT INTO %1 (directory_id, path, mtime) VALUES (:id, :path, :mtime)").arg(subdirs_table_));
q.BindValue(QStringLiteral(":id"), subdir.directory_id);
q.BindValue(QStringLiteral(":path"), subdir.path);
q.BindValue(QStringLiteral(":mtime"), subdir.mtime);
if (!q.Exec()) {
db_->ReportErrors(q);
return;
@ -548,7 +548,7 @@ SongList CollectionBackend::GetAllSongs() {
QSqlDatabase db(db_->Connect());
SqlQuery q(db);
q.prepare(QString("SELECT ROWID, %1 FROM %2").arg(Song::kColumnSpec, songs_table_));
q.prepare(QStringLiteral("SELECT ROWID, %1 FROM %2").arg(Song::kColumnSpec, songs_table_));
if (!q.Exec()) {
db_->ReportErrors(q);
return SongList();
@ -584,8 +584,8 @@ void CollectionBackend::AddOrUpdateSongs(const SongList &songs) {
// This is to fix a possible race condition when a directory is removed while CollectionWatcher is scanning it.
if (!dirs_table_.isEmpty()) {
SqlQuery check_dir(db);
check_dir.prepare(QString("SELECT ROWID FROM %1 WHERE ROWID = :id").arg(dirs_table_));
check_dir.BindValue(":id", song.directory_id());
check_dir.prepare(QStringLiteral("SELECT ROWID FROM %1 WHERE ROWID = :id").arg(dirs_table_));
check_dir.BindValue(QStringLiteral(":id"), song.directory_id());
if (!check_dir.Exec()) {
db_->ReportErrors(check_dir);
return;
@ -604,9 +604,9 @@ void CollectionBackend::AddOrUpdateSongs(const SongList &songs) {
// Update
{
SqlQuery q(db);
q.prepare(QString("UPDATE %1 SET %2 WHERE ROWID = :id").arg(songs_table_, Song::kUpdateSpec));
q.prepare(QStringLiteral("UPDATE %1 SET %2 WHERE ROWID = :id").arg(songs_table_, Song::kUpdateSpec));
song.BindToQuery(&q);
q.BindValue(":id", song.id());
q.BindValue(QStringLiteral(":id"), song.id());
if (!q.Exec()) {
db_->ReportErrors(q);
return;
@ -615,9 +615,9 @@ void CollectionBackend::AddOrUpdateSongs(const SongList &songs) {
{
SqlQuery q(db);
q.prepare(QString("UPDATE %1 SET %2 WHERE ROWID = :id").arg(fts_table_, Song::kFtsUpdateSpec));
q.prepare(QStringLiteral("UPDATE %1 SET %2 WHERE ROWID = :id").arg(fts_table_, Song::kFtsUpdateSpec));
song.BindToFtsQuery(&q);
q.BindValue(":id", song.id());
q.BindValue(QStringLiteral(":id"), song.id());
if (!q.Exec()) {
db_->ReportErrors(q);
return;
@ -643,9 +643,9 @@ void CollectionBackend::AddOrUpdateSongs(const SongList &songs) {
// Update
{
SqlQuery q(db);
q.prepare(QString("UPDATE %1 SET %2 WHERE ROWID = :id").arg(songs_table_, Song::kUpdateSpec));
q.prepare(QStringLiteral("UPDATE %1 SET %2 WHERE ROWID = :id").arg(songs_table_, Song::kUpdateSpec));
new_song.BindToQuery(&q);
q.BindValue(":id", new_song.id());
q.BindValue(QStringLiteral(":id"), new_song.id());
if (!q.Exec()) {
db_->ReportErrors(q);
return;
@ -654,9 +654,9 @@ void CollectionBackend::AddOrUpdateSongs(const SongList &songs) {
{
SqlQuery q(db);
q.prepare(QString("UPDATE %1 SET %2 WHERE ROWID = :id").arg(fts_table_, Song::kFtsUpdateSpec));
q.prepare(QStringLiteral("UPDATE %1 SET %2 WHERE ROWID = :id").arg(fts_table_, Song::kFtsUpdateSpec));
new_song.BindToFtsQuery(&q);
q.BindValue(":id", new_song.id());
q.BindValue(QStringLiteral(":id"), new_song.id());
if (!q.Exec()) {
db_->ReportErrors(q);
return;
@ -675,7 +675,7 @@ void CollectionBackend::AddOrUpdateSongs(const SongList &songs) {
int id = -1;
{ // Insert the row and create a new ID
SqlQuery q(db);
q.prepare(QString("INSERT INTO %1 (%2) VALUES (%3)").arg(songs_table_, Song::kColumnSpec, Song::kBindSpec));
q.prepare(QStringLiteral("INSERT INTO %1 (%2) VALUES (%3)").arg(songs_table_, Song::kColumnSpec, Song::kBindSpec));
song.BindToQuery(&q);
if (!q.Exec()) {
db_->ReportErrors(q);
@ -689,8 +689,8 @@ void CollectionBackend::AddOrUpdateSongs(const SongList &songs) {
{ // Add to the FTS index
SqlQuery q(db);
q.prepare(QString("INSERT INTO %1 (ROWID, %2) VALUES (:id, %3)").arg(fts_table_, Song::kFtsColumnSpec, Song::kFtsBindSpec));
q.BindValue(":id", id);
q.prepare(QStringLiteral("INSERT INTO %1 (ROWID, %2) VALUES (:id, %3)").arg(fts_table_, Song::kFtsColumnSpec, Song::kFtsBindSpec));
q.BindValue(QStringLiteral(":id"), id);
song.BindToFtsQuery(&q);
if (!q.Exec()) {
db_->ReportErrors(q);
@ -750,9 +750,9 @@ void CollectionBackend::UpdateSongsBySongID(const SongMap &new_songs) {
{
SqlQuery q(db);
q.prepare(QString("UPDATE %1 SET %2 WHERE ROWID = :id").arg(songs_table_, Song::kUpdateSpec));
q.prepare(QStringLiteral("UPDATE %1 SET %2 WHERE ROWID = :id").arg(songs_table_, Song::kUpdateSpec));
new_song.BindToQuery(&q);
q.BindValue(":id", old_song.id());
q.BindValue(QStringLiteral(":id"), old_song.id());
if (!q.Exec()) {
db_->ReportErrors(q);
return;
@ -760,9 +760,9 @@ void CollectionBackend::UpdateSongsBySongID(const SongMap &new_songs) {
}
{
SqlQuery q(db);
q.prepare(QString("UPDATE %1 SET %2 WHERE ROWID = :id").arg(fts_table_, Song::kFtsUpdateSpec));
q.prepare(QStringLiteral("UPDATE %1 SET %2 WHERE ROWID = :id").arg(fts_table_, Song::kFtsUpdateSpec));
new_song.BindToFtsQuery(&q);
q.BindValue(":id", old_song.id());
q.BindValue(QStringLiteral(":id"), old_song.id());
if (!q.Exec()) {
db_->ReportErrors(q);
return;
@ -781,7 +781,7 @@ void CollectionBackend::UpdateSongsBySongID(const SongMap &new_songs) {
int id = -1;
{
SqlQuery q(db);
q.prepare(QString("INSERT INTO %1 (%2) VALUES (%3)").arg(songs_table_, Song::kColumnSpec, Song::kBindSpec));
q.prepare(QStringLiteral("INSERT INTO %1 (%2) VALUES (%3)").arg(songs_table_, Song::kColumnSpec, Song::kBindSpec));
new_song.BindToQuery(&q);
if (!q.Exec()) {
db_->ReportErrors(q);
@ -795,8 +795,8 @@ void CollectionBackend::UpdateSongsBySongID(const SongMap &new_songs) {
{ // Add to the FTS index
SqlQuery q(db);
q.prepare(QString("INSERT INTO %1 (ROWID, %2) VALUES (:id, %3)").arg(fts_table_, Song::kFtsColumnSpec, Song::kFtsBindSpec));
q.BindValue(":id", id);
q.prepare(QStringLiteral("INSERT INTO %1 (ROWID, %2) VALUES (:id, %3)").arg(fts_table_, Song::kFtsColumnSpec, Song::kFtsBindSpec));
q.BindValue(QStringLiteral(":id"), id);
new_song.BindToFtsQuery(&q);
if (!q.Exec()) {
db_->ReportErrors(q);
@ -816,8 +816,8 @@ void CollectionBackend::UpdateSongsBySongID(const SongMap &new_songs) {
if (!new_songs.contains(old_song.song_id())) {
{
SqlQuery q(db);
q.prepare(QString("DELETE FROM %1 WHERE ROWID = :id").arg(songs_table_));
q.BindValue(":id", old_song.id());
q.prepare(QStringLiteral("DELETE FROM %1 WHERE ROWID = :id").arg(songs_table_));
q.BindValue(QStringLiteral(":id"), old_song.id());
if (!q.Exec()) {
db_->ReportErrors(q);
return;
@ -825,8 +825,8 @@ void CollectionBackend::UpdateSongsBySongID(const SongMap &new_songs) {
}
{
SqlQuery q(db);
q.prepare(QString("DELETE FROM %1 WHERE ROWID = :id").arg(fts_table_));
q.BindValue(":id", old_song.id());
q.prepare(QStringLiteral("DELETE FROM %1 WHERE ROWID = :id").arg(fts_table_));
q.BindValue(QStringLiteral(":id"), old_song.id());
if (!q.Exec()) {
db_->ReportErrors(q);
return;
@ -853,12 +853,12 @@ void CollectionBackend::UpdateMTimesOnly(const SongList &songs) {
QSqlDatabase db(db_->Connect());
SqlQuery q(db);
q.prepare(QString("UPDATE %1 SET mtime = :mtime WHERE ROWID = :id").arg(songs_table_));
q.prepare(QStringLiteral("UPDATE %1 SET mtime = :mtime WHERE ROWID = :id").arg(songs_table_));
ScopedTransaction transaction(&db);
for (const Song &song : songs) {
q.BindValue(":mtime", song.mtime());
q.BindValue(":id", song.id());
q.BindValue(QStringLiteral(":mtime"), song.mtime());
q.BindValue(QStringLiteral(":id"), song.id());
if (!q.Exec()) {
db_->ReportErrors(q);
return;
@ -874,19 +874,19 @@ void CollectionBackend::DeleteSongs(const SongList &songs) {
QSqlDatabase db(db_->Connect());
SqlQuery remove(db);
remove.prepare(QString("DELETE FROM %1 WHERE ROWID = :id").arg(songs_table_));
remove.prepare(QStringLiteral("DELETE FROM %1 WHERE ROWID = :id").arg(songs_table_));
SqlQuery remove_fts(db);
remove_fts.prepare(QString("DELETE FROM %1 WHERE ROWID = :id").arg(fts_table_));
remove_fts.prepare(QStringLiteral("DELETE FROM %1 WHERE ROWID = :id").arg(fts_table_));
ScopedTransaction transaction(&db);
for (const Song &song : songs) {
remove.BindValue(":id", song.id());
remove.BindValue(QStringLiteral(":id"), song.id());
if (!remove.Exec()) {
db_->ReportErrors(remove);
return;
}
remove_fts.BindValue(":id", song.id());
remove_fts.BindValue(QStringLiteral(":id"), song.id());
if (!remove_fts.Exec()) {
db_->ReportErrors(remove_fts);
return;
@ -908,11 +908,11 @@ void CollectionBackend::MarkSongsUnavailable(const SongList &songs, const bool u
QSqlDatabase db(db_->Connect());
SqlQuery query(db);
query.prepare(QString("UPDATE %1 SET unavailable = %2 WHERE ROWID = :id").arg(songs_table_).arg(static_cast<int>(unavailable)));
query.prepare(QStringLiteral("UPDATE %1 SET unavailable = %2 WHERE ROWID = :id").arg(songs_table_).arg(static_cast<int>(unavailable)));
ScopedTransaction transaction(&db);
for (const Song &song : songs) {
query.BindValue(":id", song.id());
query.BindValue(QStringLiteral(":id"), song.id());
if (!query.Exec()) {
db_->ReportErrors(query);
return;
@ -957,7 +957,7 @@ QStringList CollectionBackend::GetAll(const QString &column, const CollectionFil
QStringList CollectionBackend::GetAllArtists(const CollectionFilterOptions &opt) {
return GetAll("artist", opt);
return GetAll(QStringLiteral("artist"), opt);
}
QStringList CollectionBackend::GetAllArtistsWithAlbums(const CollectionFilterOptions &opt) {
@ -967,16 +967,16 @@ QStringList CollectionBackend::GetAllArtistsWithAlbums(const CollectionFilterOpt
// Albums with 'albumartist' field set:
CollectionQuery query(db, songs_table_, fts_table_, opt);
query.SetColumnSpec("DISTINCT albumartist");
query.SetColumnSpec(QStringLiteral("DISTINCT albumartist"));
query.AddCompilationRequirement(false);
query.AddWhere("album", "", "!=");
query.AddWhere(QStringLiteral("album"), "", QStringLiteral("!="));
// Albums with no 'albumartist' (extract 'artist'):
CollectionQuery query2(db, songs_table_, fts_table_, opt);
query2.SetColumnSpec("DISTINCT artist");
query2.SetColumnSpec(QStringLiteral("DISTINCT artist"));
query2.AddCompilationRequirement(false);
query2.AddWhere("album", "", "!=");
query2.AddWhere("albumartist", "", "=");
query2.AddWhere(QStringLiteral("album"), "", QStringLiteral("!="));
query2.AddWhere(QStringLiteral("albumartist"), "", QStringLiteral("="));
if (!query.Exec()) {
ReportErrors(query);
@ -1015,7 +1015,7 @@ SongList CollectionBackend::GetArtistSongs(const QString &effective_albumartist,
CollectionQuery query(db, songs_table_, fts_table_, opt);
query.AddCompilationRequirement(false);
query.AddWhere("effective_albumartist", effective_albumartist);
query.AddWhere(QStringLiteral("effective_albumartist"), effective_albumartist);
SongList songs;
if (!ExecCollectionQuery(&query, songs)) {
@ -1033,8 +1033,8 @@ SongList CollectionBackend::GetAlbumSongs(const QString &effective_albumartist,
CollectionQuery query(db, songs_table_, fts_table_, opt);
query.AddCompilationRequirement(false);
query.AddWhere("effective_albumartist", effective_albumartist);
query.AddWhere("album", album);
query.AddWhere(QStringLiteral("effective_albumartist"), effective_albumartist);
query.AddWhere(QStringLiteral("album"), album);
SongList songs;
if (!ExecCollectionQuery(&query, songs)) {
@ -1052,7 +1052,7 @@ SongList CollectionBackend::GetSongsByAlbum(const QString &album, const Collecti
CollectionQuery query(db, songs_table_, fts_table_, opt);
query.AddCompilationRequirement(false);
query.AddWhere("album", album);
query.AddWhere(QStringLiteral("album"), album);
SongList songs;
if (!ExecCollectionQuery(&query, songs)) {
@ -1130,10 +1130,10 @@ SongList CollectionBackend::GetSongsByForeignId(const QStringList &ids, const QS
QMutexLocker l(db_->Mutex());
QSqlDatabase db(db_->Connect());
QString in = ids.join(",");
QString in = ids.join(QStringLiteral(","));
SqlQuery q(db);
q.prepare(QString("SELECT %3.ROWID, %2, %3.%4 FROM %3, %1 WHERE %3.%4 IN (in) AND %1.ROWID = %3.ROWID AND unavailable = 0").arg(songs_table_, Song::kColumnSpec, table, column, in));
q.prepare(QStringLiteral("SELECT %3.ROWID, %2, %3.%4 FROM %3, %1 WHERE %3.%4 IN (in) AND %1.ROWID = %3.ROWID AND unavailable = 0").arg(songs_table_, Song::kColumnSpec, table, column, in));
if (!q.Exec()) {
db_->ReportErrors(q);
return SongList();
@ -1161,10 +1161,10 @@ Song CollectionBackend::GetSongById(const int id, QSqlDatabase &db) {
SongList CollectionBackend::GetSongsById(const QStringList &ids, QSqlDatabase &db) {
QString in = ids.join(",");
QString in = ids.join(QStringLiteral(","));
SqlQuery q(db);
q.prepare(QString("SELECT ROWID, %1 FROM %2 WHERE ROWID IN (%3)").arg(Song::kColumnSpec, songs_table_, in));
q.prepare(QStringLiteral("SELECT ROWID, %1 FROM %2 WHERE ROWID IN (%3)").arg(Song::kColumnSpec, songs_table_, in));
if (!q.Exec()) {
db_->ReportErrors(q);
return SongList();
@ -1186,13 +1186,13 @@ Song CollectionBackend::GetSongByUrl(const QUrl &url, const qint64 beginning) {
QSqlDatabase db(db_->Connect());
SqlQuery q(db);
q.prepare(QString("SELECT ROWID, %1 FROM %2 WHERE (url = :url1 OR url = :url2 OR url = :url3 OR url = :url4) AND beginning = :beginning AND unavailable = 0").arg(Song::kColumnSpec, songs_table_));
q.prepare(QStringLiteral("SELECT ROWID, %1 FROM %2 WHERE (url = :url1 OR url = :url2 OR url = :url3 OR url = :url4) AND beginning = :beginning AND unavailable = 0").arg(Song::kColumnSpec, songs_table_));
q.BindValue(":url1", url);
q.BindValue(":url2", url.toString());
q.BindValue(":url3", url.toString(QUrl::FullyEncoded));
q.BindValue(":url4", url.toEncoded());
q.BindValue(":beginning", beginning);
q.BindValue(QStringLiteral(":url1"), url);
q.BindValue(QStringLiteral(":url2"), url.toString());
q.BindValue(QStringLiteral(":url3"), url.toString(QUrl::FullyEncoded));
q.BindValue(QStringLiteral(":url4"), url.toEncoded());
q.BindValue(QStringLiteral(":beginning"), beginning);
if (!q.Exec()) {
db_->ReportErrors(q);
@ -1216,13 +1216,13 @@ Song CollectionBackend::GetSongByUrlAndTrack(const QUrl &url, const int track) {
QSqlDatabase db(db_->Connect());
SqlQuery q(db);
q.prepare(QString("SELECT ROWID, %1 FROM %2 WHERE (url = :url1 OR url = :url2 OR url = :url3 OR url = :url4) AND track = :track AND unavailable = 0").arg(Song::kColumnSpec, songs_table_));
q.prepare(QStringLiteral("SELECT ROWID, %1 FROM %2 WHERE (url = :url1 OR url = :url2 OR url = :url3 OR url = :url4) AND track = :track AND unavailable = 0").arg(Song::kColumnSpec, songs_table_));
q.BindValue(":url1", url);
q.BindValue(":url2", url.toString());
q.BindValue(":url3", url.toString(QUrl::FullyEncoded));
q.BindValue(":url4", url.toEncoded());
q.BindValue(":track", track);
q.BindValue(QStringLiteral(":url1"), url);
q.BindValue(QStringLiteral(":url2"), url.toString());
q.BindValue(QStringLiteral(":url3"), url.toString(QUrl::FullyEncoded));
q.BindValue(QStringLiteral(":url4"), url.toEncoded());
q.BindValue(QStringLiteral(":track"), track);
if (!q.Exec()) {
db_->ReportErrors(q);
@ -1246,13 +1246,13 @@ SongList CollectionBackend::GetSongsByUrl(const QUrl &url, const bool unavailabl
QSqlDatabase db(db_->Connect());
SqlQuery q(db);
q.prepare(QString("SELECT ROWID, %1 FROM %2 WHERE (url = :url1 OR url = :url2 OR url = :url3 OR url = :url4) AND unavailable = :unavailable").arg(Song::kColumnSpec, songs_table_));
q.prepare(QStringLiteral("SELECT ROWID, %1 FROM %2 WHERE (url = :url1 OR url = :url2 OR url = :url3 OR url = :url4) AND unavailable = :unavailable").arg(Song::kColumnSpec, songs_table_));
q.BindValue(":url1", url);
q.BindValue(":url2", url.toString());
q.BindValue(":url3", url.toString(QUrl::FullyEncoded));
q.BindValue(":url4", url.toEncoded());
q.BindValue(":unavailable", (unavailable ? 1 : 0));
q.BindValue(QStringLiteral(":url1"), url);
q.BindValue(QStringLiteral(":url2"), url.toString());
q.BindValue(QStringLiteral(":url3"), url.toString(QUrl::FullyEncoded));
q.BindValue(QStringLiteral(":url4"), url.toEncoded());
q.BindValue(QStringLiteral(":unavailable"), (unavailable ? 1 : 0));
SongList songs;
if (q.Exec()) {
@ -1303,10 +1303,10 @@ SongList CollectionBackend::GetSongsBySongId(const QStringList &song_ids, QSqlDa
for (const QString &song_id : song_ids) {
song_ids2 << "'" + song_id + "'";
}
QString in = song_ids2.join(",");
QString in = song_ids2.join(QStringLiteral(","));
SqlQuery q(db);
q.prepare(QString("SELECT ROWID, %1 FROM %2 WHERE SONG_ID IN (%3)").arg(Song::kColumnSpec, songs_table_, in));
q.prepare(QStringLiteral("SELECT ROWID, %1 FROM %2 WHERE SONG_ID IN (%3)").arg(Song::kColumnSpec, songs_table_, in));
if (!q.Exec()) {
db_->ReportErrors(q);
return SongList();
@ -1329,8 +1329,8 @@ SongList CollectionBackend::GetSongsByFingerprint(const QString &fingerprint) {
QSqlDatabase db(db_->Connect());
SqlQuery q(db);
q.prepare(QString("SELECT ROWID, %1 FROM %2 WHERE fingerprint = :fingerprint").arg(Song::kColumnSpec, songs_table_));
q.BindValue(":fingerprint", fingerprint);
q.prepare(QStringLiteral("SELECT ROWID, %1 FROM %2 WHERE fingerprint = :fingerprint").arg(Song::kColumnSpec, songs_table_));
q.BindValue(QStringLiteral(":fingerprint"), fingerprint);
if (!q.Exec()) {
db_->ReportErrors(q);
return SongList();
@ -1360,7 +1360,7 @@ SongList CollectionBackend::GetCompilationSongs(const QString &album, const Coll
CollectionQuery query(db, songs_table_, fts_table_, opt);
query.SetColumnSpec("%songs_table.ROWID, " + Song::kColumnSpec);
query.AddCompilationRequirement(true);
query.AddWhere("album", album);
query.AddWhere(QStringLiteral("album"), album);
if (!query.Exec()) {
ReportErrors(query);
@ -1385,7 +1385,7 @@ void CollectionBackend::CompilationsNeedUpdating() {
// Look for albums that have songs by more than one 'effective album artist' in the same directory
SqlQuery q(db);
q.prepare(QString("SELECT effective_albumartist, album, url, compilation_detected FROM %1 WHERE unavailable = 0 ORDER BY album").arg(songs_table_));
q.prepare(QStringLiteral("SELECT effective_albumartist, album, url, compilation_detected FROM %1 WHERE unavailable = 0 ORDER BY album").arg(songs_table_));
if (!q.Exec()) {
db_->ReportErrors(q);
return;
@ -1452,11 +1452,11 @@ bool CollectionBackend::UpdateCompilations(const QSqlDatabase &db, SongList &del
{ // Get song, so we can tell the model its updated
SqlQuery q(db);
q.prepare(QString("SELECT ROWID, %1 FROM %2 WHERE (url = :url1 OR url = :url2 OR url = :url3 OR url = :url4) AND unavailable = 0").arg(Song::kColumnSpec, songs_table_));
q.BindValue(":url1", url);
q.BindValue(":url2", url.toString());
q.BindValue(":url3", url.toString(QUrl::FullyEncoded));
q.BindValue(":url4", url.toEncoded());
q.prepare(QStringLiteral("SELECT ROWID, %1 FROM %2 WHERE (url = :url1 OR url = :url2 OR url = :url3 OR url = :url4) AND unavailable = 0").arg(Song::kColumnSpec, songs_table_));
q.BindValue(QStringLiteral(":url1"), url);
q.BindValue(QStringLiteral(":url2"), url.toString());
q.BindValue(QStringLiteral(":url3"), url.toString(QUrl::FullyEncoded));
q.BindValue(QStringLiteral(":url4"), url.toEncoded());
if (q.Exec()) {
while (q.next()) {
Song song(source_);
@ -1474,12 +1474,12 @@ bool CollectionBackend::UpdateCompilations(const QSqlDatabase &db, SongList &del
// Update the song
SqlQuery q(db);
q.prepare(QString("UPDATE %1 SET compilation_detected = :compilation_detected, compilation_effective = ((compilation OR :compilation_detected OR compilation_on) AND NOT compilation_off) + 0 WHERE (url = :url1 OR url = :url2 OR url = :url3 OR url = :url4) AND unavailable = 0").arg(songs_table_));
q.BindValue(":compilation_detected", static_cast<int>(compilation_detected));
q.BindValue(":url1", url);
q.BindValue(":url2", url.toString());
q.BindValue(":url3", url.toString(QUrl::FullyEncoded));
q.BindValue(":url4", url.toEncoded());
q.prepare(QStringLiteral("UPDATE %1 SET compilation_detected = :compilation_detected, compilation_effective = ((compilation OR :compilation_detected OR compilation_on) AND NOT compilation_off) + 0 WHERE (url = :url1 OR url = :url2 OR url = :url3 OR url = :url4) AND unavailable = 0").arg(songs_table_));
q.BindValue(QStringLiteral(":compilation_detected"), static_cast<int>(compilation_detected));
q.BindValue(QStringLiteral(":url1"), url);
q.BindValue(QStringLiteral(":url2"), url.toString());
q.BindValue(QStringLiteral(":url3"), url.toString(QUrl::FullyEncoded));
q.BindValue(QStringLiteral(":url4"), url.toEncoded());
if (!q.Exec()) {
db_->ReportErrors(q);
return false;
@ -1495,15 +1495,15 @@ CollectionBackend::AlbumList CollectionBackend::GetAlbums(const QString &artist,
QSqlDatabase db(db_->Connect());
CollectionQuery query(db, songs_table_, fts_table_, opt);
query.SetColumnSpec("url, filetype, cue_path, effective_albumartist, album, compilation_effective, art_embedded, art_automatic, art_manual, art_unset");
query.SetOrderBy("effective_albumartist, album, url");
query.SetColumnSpec(QStringLiteral("url, filetype, cue_path, effective_albumartist, album, compilation_effective, art_embedded, art_automatic, art_manual, art_unset"));
query.SetOrderBy(QStringLiteral("effective_albumartist, album, url"));
if (compilation_required) {
query.AddCompilationRequirement(true);
}
else if (!artist.isEmpty()) {
query.AddCompilationRequirement(false);
query.AddWhere("effective_albumartist", artist);
query.AddWhere(QStringLiteral("effective_albumartist"), artist);
}
if (!query.Exec()) {
@ -1531,7 +1531,7 @@ CollectionBackend::AlbumList CollectionBackend::GetAlbums(const QString &artist,
album_info.art_embedded = query.Value(6).toBool();
const QString art_automatic = query.Value(7).toString();
if (art_automatic.contains(QRegularExpression("..+:.*"))) {
if (art_automatic.contains(QRegularExpression(QStringLiteral("..+:.*")))) {
album_info.art_automatic = QUrl::fromEncoded(art_automatic.toUtf8());
}
else {
@ -1539,7 +1539,7 @@ CollectionBackend::AlbumList CollectionBackend::GetAlbums(const QString &artist,
}
const QString art_manual = query.Value(8).toString();
if (art_manual.contains(QRegularExpression("..+:.*"))) {
if (art_manual.contains(QRegularExpression(QStringLiteral("..+:.*")))) {
album_info.art_manual = QUrl::fromEncoded(art_manual.toUtf8());
}
else {
@ -1586,11 +1586,11 @@ CollectionBackend::Album CollectionBackend::GetAlbumArt(const QString &effective
ret.album_artist = effective_albumartist;
CollectionQuery query(db, songs_table_, fts_table_);
query.SetColumnSpec("url, art_embedded, art_automatic, art_manual, art_unset");
query.SetColumnSpec(QStringLiteral("url, art_embedded, art_automatic, art_manual, art_unset"));
if (!effective_albumartist.isEmpty()) {
query.AddWhere("effective_albumartist", effective_albumartist);
query.AddWhere(QStringLiteral("effective_albumartist"), effective_albumartist);
}
query.AddWhere("album", album);
query.AddWhere(QStringLiteral("album"), album);
if (!query.Exec()) {
ReportErrors(query);
@ -1623,8 +1623,8 @@ void CollectionBackend::UpdateEmbeddedAlbumArt(const QString &effective_albumart
// Get the songs before they're updated
CollectionQuery query(db, songs_table_, fts_table_);
query.SetColumnSpec("ROWID, " + Song::kColumnSpec);
query.AddWhere("effective_albumartist", effective_albumartist);
query.AddWhere("album", album);
query.AddWhere(QStringLiteral("effective_albumartist"), effective_albumartist);
query.AddWhere(QStringLiteral("album"), album);
if (!query.Exec()) {
ReportErrors(query);
@ -1639,13 +1639,13 @@ void CollectionBackend::UpdateEmbeddedAlbumArt(const QString &effective_albumart
}
// Update the songs
QString sql = QString("UPDATE %1 SET art_embedded = :art_embedded, art_unset = 0 WHERE effective_albumartist = :effective_albumartist AND album = :album AND unavailable = 0").arg(songs_table_);
QString sql = QStringLiteral("UPDATE %1 SET art_embedded = :art_embedded, art_unset = 0 WHERE effective_albumartist = :effective_albumartist AND album = :album AND unavailable = 0").arg(songs_table_);
SqlQuery q(db);
q.prepare(sql);
q.BindValue(":art_embedded", art_embedded ? 1 : 0);
q.BindValue(":effective_albumartist", effective_albumartist);
q.BindValue(":album", album);
q.BindValue(QStringLiteral(":art_embedded"), art_embedded ? 1 : 0);
q.BindValue(QStringLiteral(":effective_albumartist"), effective_albumartist);
q.BindValue(QStringLiteral(":album"), album);
if (!q.Exec()) {
db_->ReportErrors(q);
@ -1685,8 +1685,8 @@ void CollectionBackend::UpdateManualAlbumArt(const QString &effective_albumartis
CollectionQuery query(db, songs_table_, fts_table_);
query.SetColumnSpec("ROWID, " + Song::kColumnSpec);
query.AddWhere("effective_albumartist", effective_albumartist);
query.AddWhere("album", album);
query.AddWhere(QStringLiteral("effective_albumartist"), effective_albumartist);
query.AddWhere(QStringLiteral("album"), album);
if (!query.Exec()) {
ReportErrors(query);
@ -1701,10 +1701,10 @@ void CollectionBackend::UpdateManualAlbumArt(const QString &effective_albumartis
}
SqlQuery q(db);
q.prepare(QString("UPDATE %1 SET art_manual = :art_manual, art_unset = 0 WHERE effective_albumartist = :effective_albumartist AND album = :album AND unavailable = 0").arg(songs_table_));
q.BindValue(":art_manual", art_manual.isValid() ? art_manual.toString(QUrl::FullyEncoded) : "");
q.BindValue(":effective_albumartist", effective_albumartist);
q.BindValue(":album", album);
q.prepare(QStringLiteral("UPDATE %1 SET art_manual = :art_manual, art_unset = 0 WHERE effective_albumartist = :effective_albumartist AND album = :album AND unavailable = 0").arg(songs_table_));
q.BindValue(QStringLiteral(":art_manual"), art_manual.isValid() ? art_manual.toString(QUrl::FullyEncoded) : QLatin1String(""));
q.BindValue(QStringLiteral(":effective_albumartist"), effective_albumartist);
q.BindValue(QStringLiteral(":album"), album);
if (!q.Exec()) {
db_->ReportErrors(q);
@ -1743,8 +1743,8 @@ void CollectionBackend::UnsetAlbumArt(const QString &effective_albumartist, cons
CollectionQuery query(db, songs_table_, fts_table_);
query.SetColumnSpec("ROWID, " + Song::kColumnSpec);
query.AddWhere("effective_albumartist", effective_albumartist);
query.AddWhere("album", album);
query.AddWhere(QStringLiteral("effective_albumartist"), effective_albumartist);
query.AddWhere(QStringLiteral("album"), album);
if (!query.Exec()) {
ReportErrors(query);
@ -1759,9 +1759,9 @@ void CollectionBackend::UnsetAlbumArt(const QString &effective_albumartist, cons
}
SqlQuery q(db);
q.prepare(QString("UPDATE %1 SET art_unset = 1, art_manual = '', art_automatic = '', art_embedded = '' WHERE effective_albumartist = :effective_albumartist AND album = :album AND unavailable = 0").arg(songs_table_));
q.BindValue(":effective_albumartist", effective_albumartist);
q.BindValue(":album", album);
q.prepare(QStringLiteral("UPDATE %1 SET art_unset = 1, art_manual = '', art_automatic = '', art_embedded = '' WHERE effective_albumartist = :effective_albumartist AND album = :album AND unavailable = 0").arg(songs_table_));
q.BindValue(QStringLiteral(":effective_albumartist"), effective_albumartist);
q.BindValue(QStringLiteral(":album"), album);
if (!q.Exec()) {
db_->ReportErrors(q);
@ -1800,8 +1800,8 @@ void CollectionBackend::ClearAlbumArt(const QString &effective_albumartist, cons
CollectionQuery query(db, songs_table_, fts_table_);
query.SetColumnSpec("ROWID, " + Song::kColumnSpec);
query.AddWhere("effective_albumartist", effective_albumartist);
query.AddWhere("album", album);
query.AddWhere(QStringLiteral("effective_albumartist"), effective_albumartist);
query.AddWhere(QStringLiteral("album"), album);
if (!query.Exec()) {
ReportErrors(query);
@ -1816,10 +1816,10 @@ void CollectionBackend::ClearAlbumArt(const QString &effective_albumartist, cons
}
SqlQuery q(db);
q.prepare(QString("UPDATE %1 SET art_embedded = 0, art_automatic = '', art_manual = '', art_unset = :art_unset WHERE effective_albumartist = :effective_albumartist AND album = :album AND unavailable = 0").arg(songs_table_));
q.BindValue(":art_unset", art_unset ? 1 : 0);
q.BindValue(":effective_albumartist", effective_albumartist);
q.BindValue(":album", album);
q.prepare(QStringLiteral("UPDATE %1 SET art_embedded = 0, art_automatic = '', art_manual = '', art_unset = :art_unset WHERE effective_albumartist = :effective_albumartist AND album = :album AND unavailable = 0").arg(songs_table_));
q.BindValue(QStringLiteral(":art_unset"), art_unset ? 1 : 0);
q.BindValue(QStringLiteral(":effective_albumartist"), effective_albumartist);
q.BindValue(QStringLiteral(":album"), album);
if (!q.Exec()) {
db_->ReportErrors(q);
@ -1855,8 +1855,8 @@ void CollectionBackend::ForceCompilation(const QString &album, const QList<QStri
// Get the songs before they're updated
CollectionQuery query(db, songs_table_, fts_table_);
query.SetColumnSpec("ROWID, " + Song::kColumnSpec);
query.AddWhere("album", album);
if (!artist.isEmpty()) query.AddWhere("artist", artist);
query.AddWhere(QStringLiteral("album"), album);
if (!artist.isEmpty()) query.AddWhere(QStringLiteral("artist"), artist);
if (!query.Exec()) {
ReportErrors(query);
@ -1870,15 +1870,15 @@ void CollectionBackend::ForceCompilation(const QString &album, const QList<QStri
}
// Update the songs
QString sql(QString("UPDATE %1 SET compilation_on = :compilation_on, compilation_off = :compilation_off, compilation_effective = ((compilation OR compilation_detected OR :compilation_on) AND NOT :compilation_off) + 0 WHERE album = :album AND unavailable = 0").arg(songs_table_));
if (!artist.isEmpty()) sql += " AND artist = :artist";
QString sql(QStringLiteral("UPDATE %1 SET compilation_on = :compilation_on, compilation_off = :compilation_off, compilation_effective = ((compilation OR compilation_detected OR :compilation_on) AND NOT :compilation_off) + 0 WHERE album = :album AND unavailable = 0").arg(songs_table_));
if (!artist.isEmpty()) sql += QLatin1String(" AND artist = :artist");
SqlQuery q(db);
q.prepare(sql);
q.BindValue(":compilation_on", on ? 1 : 0);
q.BindValue(":compilation_off", on ? 0 : 1);
q.BindValue(":album", album);
if (!artist.isEmpty()) q.BindValue(":artist", artist);
q.BindValue(QStringLiteral(":compilation_on"), on ? 1 : 0);
q.BindValue(QStringLiteral(":compilation_off"), on ? 0 : 1);
q.BindValue(QStringLiteral(":album"), album);
if (!artist.isEmpty()) q.BindValue(QStringLiteral(":artist"), artist);
if (!q.Exec()) {
db_->ReportErrors(q);
@ -1913,9 +1913,9 @@ void CollectionBackend::IncrementPlayCount(const int id) {
QSqlDatabase db(db_->Connect());
SqlQuery q(db);
q.prepare(QString("UPDATE %1 SET playcount = playcount + 1, lastplayed = :now WHERE ROWID = :id").arg(songs_table_));
q.BindValue(":now", QDateTime::currentDateTime().toSecsSinceEpoch());
q.BindValue(":id", id)