Port to QStringLiteral operator
This commit is contained in:
@@ -30,6 +30,8 @@
|
||||
#include "radiobackend.h"
|
||||
#include "radiochannel.h"
|
||||
|
||||
using namespace Qt::Literals::StringLiterals;
|
||||
|
||||
RadioBackend::RadioBackend(SharedPtr<Database> db, QObject *parent)
|
||||
: QObject(parent),
|
||||
db_(db),
|
||||
@@ -67,13 +69,13 @@ void RadioBackend::AddChannels(const RadioChannelList &channels) {
|
||||
QSqlDatabase db(db_->Connect());
|
||||
|
||||
SqlQuery q(db);
|
||||
q.prepare(QStringLiteral("INSERT INTO radio_channels (source, name, url, thumbnail_url) VALUES (:source, :name, :url, :thumbnail_url)"));
|
||||
q.prepare(u"INSERT INTO radio_channels (source, name, url, thumbnail_url) VALUES (:source, :name, :url, :thumbnail_url)"_s);
|
||||
|
||||
for (const RadioChannel &channel : channels) {
|
||||
q.BindValue(QStringLiteral(":source"), static_cast<int>(channel.source));
|
||||
q.BindValue(QStringLiteral(":name"), channel.name);
|
||||
q.BindValue(QStringLiteral(":url"), channel.url);
|
||||
q.BindValue(QStringLiteral(":thumbnail_url"), channel.thumbnail_url);
|
||||
q.BindValue(u":source"_s, static_cast<int>(channel.source));
|
||||
q.BindValue(u":name"_s, channel.name);
|
||||
q.BindValue(u":url"_s, channel.url);
|
||||
q.BindValue(u":thumbnail_url"_s, channel.thumbnail_url);
|
||||
if (!q.Exec()) {
|
||||
db_->ReportErrors(q);
|
||||
return;
|
||||
@@ -96,7 +98,7 @@ void RadioBackend::GetChannels() {
|
||||
QSqlDatabase db(db_->Connect());
|
||||
|
||||
SqlQuery q(db);
|
||||
q.prepare(QStringLiteral("SELECT source, name, url, thumbnail_url FROM radio_channels"));
|
||||
q.prepare(u"SELECT source, name, url, thumbnail_url FROM radio_channels"_s);
|
||||
|
||||
if (!q.Exec()) {
|
||||
db_->ReportErrors(q);
|
||||
@@ -127,7 +129,7 @@ void RadioBackend::DeleteChannels() {
|
||||
QSqlDatabase db(db_->Connect());
|
||||
|
||||
SqlQuery q(db);
|
||||
q.prepare(QStringLiteral("DELETE FROM radio_channels"));
|
||||
q.prepare(u"DELETE FROM radio_channels"_s);
|
||||
|
||||
if (!q.Exec()) {
|
||||
db_->ReportErrors(q);
|
||||
|
||||
@@ -127,7 +127,7 @@ QVariant RadioModel::data(const RadioItem *item, int role) const {
|
||||
}
|
||||
|
||||
QStringList RadioModel::mimeTypes() const {
|
||||
return QStringList() << QStringLiteral("text/uri-list");
|
||||
return QStringList() << u"text/uri-list"_s;
|
||||
}
|
||||
|
||||
QMimeData *RadioModel::mimeData(const QModelIndexList &indexes) const {
|
||||
@@ -330,7 +330,7 @@ QString RadioModel::SortText(QString text) {
|
||||
else {
|
||||
text = text.toLower();
|
||||
}
|
||||
static const QRegularExpression regex_words_and_whitespaces(QStringLiteral("[^\\w ]"), QRegularExpression::UseUnicodePropertiesOption);
|
||||
static const QRegularExpression regex_words_and_whitespaces(u"[^\\w ]"_s, QRegularExpression::UseUnicodePropertiesOption);
|
||||
text = text.remove(regex_words_and_whitespaces);
|
||||
|
||||
return text;
|
||||
|
||||
@@ -39,10 +39,10 @@ constexpr char kApiChannelsUrl[] = "https://api.radioparadise.com/api/list_strea
|
||||
}
|
||||
|
||||
RadioParadiseService::RadioParadiseService(Application *app, SharedPtr<NetworkAccessManager> network, QObject *parent)
|
||||
: RadioService(Song::Source::RadioParadise, QStringLiteral("Radio Paradise"), IconLoader::Load(QStringLiteral("radioparadise")), app, network, parent) {}
|
||||
: RadioService(Song::Source::RadioParadise, u"Radio Paradise"_s, IconLoader::Load(u"radioparadise"_s), app, network, parent) {}
|
||||
|
||||
QUrl RadioParadiseService::Homepage() { return QUrl(QStringLiteral("https://radioparadise.com/")); }
|
||||
QUrl RadioParadiseService::Donate() { return QUrl(QStringLiteral("https://payments.radioparadise.com/rp2s-content.php?name=Support&file=support")); }
|
||||
QUrl RadioParadiseService::Homepage() { return QUrl(u"https://radioparadise.com/"_s); }
|
||||
QUrl RadioParadiseService::Donate() { return QUrl(u"https://payments.radioparadise.com/rp2s-content.php?name=Support&file=support"_s); }
|
||||
|
||||
void RadioParadiseService::Abort() {
|
||||
|
||||
@@ -83,7 +83,7 @@ void RadioParadiseService::GetChannelsReply(QNetworkReply *reply, const int task
|
||||
}
|
||||
|
||||
if (!object.contains("channels"_L1) || !object["channels"_L1].isArray()) {
|
||||
Error(QStringLiteral("Missing JSON channels array."), object);
|
||||
Error(u"Missing JSON channels array."_s, object);
|
||||
app_->task_manager()->SetTaskFinished(task_id);
|
||||
Q_EMIT NewChannels();
|
||||
return;
|
||||
@@ -111,7 +111,7 @@ void RadioParadiseService::GetChannelsReply(QNetworkReply *reply, const int task
|
||||
}
|
||||
QString label = obj_stream["label"_L1].toString();
|
||||
QString url = obj_stream["url"_L1].toString();
|
||||
static const QRegularExpression regex_url_schema(QStringLiteral("^[0-9a-zA-Z]*:\\/\\/"), QRegularExpression::CaseInsensitiveOption);
|
||||
static const QRegularExpression regex_url_schema(u"^[0-9a-zA-Z]*:\\/\\/"_s, QRegularExpression::CaseInsensitiveOption);
|
||||
if (!url.contains(regex_url_schema)) {
|
||||
url.prepend("https://"_L1);
|
||||
}
|
||||
|
||||
@@ -35,6 +35,8 @@
|
||||
#include "radiomimedata.h"
|
||||
#include "collection/collectionitemdelegate.h"
|
||||
|
||||
using namespace Qt::Literals::StringLiterals;
|
||||
|
||||
RadioView::RadioView(QWidget *parent)
|
||||
: AutoExpandingTreeView(parent),
|
||||
menu_(nullptr),
|
||||
@@ -70,27 +72,27 @@ void RadioView::contextMenuEvent(QContextMenuEvent *e) {
|
||||
if (!menu_) {
|
||||
menu_ = new QMenu;
|
||||
|
||||
action_playlist_append_ = new QAction(IconLoader::Load(QStringLiteral("media-playback-start")), tr("Append to current playlist"), this);
|
||||
action_playlist_append_ = new QAction(IconLoader::Load(u"media-playback-start"_s), tr("Append to current playlist"), this);
|
||||
QObject::connect(action_playlist_append_, &QAction::triggered, this, &RadioView::AddToPlaylist);
|
||||
menu_->addAction(action_playlist_append_);
|
||||
|
||||
action_playlist_replace_ = new QAction(IconLoader::Load(QStringLiteral("media-playback-start")), tr("Replace current playlist"), this);
|
||||
action_playlist_replace_ = new QAction(IconLoader::Load(u"media-playback-start"_s), tr("Replace current playlist"), this);
|
||||
QObject::connect(action_playlist_replace_, &QAction::triggered, this, &RadioView::ReplacePlaylist);
|
||||
menu_->addAction(action_playlist_replace_);
|
||||
|
||||
action_playlist_new_ = new QAction(IconLoader::Load(QStringLiteral("document-new")), tr("Open in new playlist"), this);
|
||||
action_playlist_new_ = new QAction(IconLoader::Load(u"document-new"_s), tr("Open in new playlist"), this);
|
||||
QObject::connect(action_playlist_new_, &QAction::triggered, this, &RadioView::OpenInNewPlaylist);
|
||||
menu_->addAction(action_playlist_new_);
|
||||
|
||||
action_homepage_ = new QAction(IconLoader::Load(QStringLiteral("download")), tr("Open homepage"), this);
|
||||
action_homepage_ = new QAction(IconLoader::Load(u"download"_s), tr("Open homepage"), this);
|
||||
QObject::connect(action_homepage_, &QAction::triggered, this, &RadioView::Homepage);
|
||||
menu_->addAction(action_homepage_);
|
||||
|
||||
action_donate_ = new QAction(IconLoader::Load(QStringLiteral("download")), tr("Donate"), this);
|
||||
action_donate_ = new QAction(IconLoader::Load(u"download"_s), tr("Donate"), this);
|
||||
QObject::connect(action_donate_, &QAction::triggered, this, &RadioView::Donate);
|
||||
menu_->addAction(action_donate_);
|
||||
|
||||
menu_->addAction(IconLoader::Load(QStringLiteral("view-refresh")), tr("Refresh channels"), this, &RadioView::GetChannels);
|
||||
menu_->addAction(IconLoader::Load(u"view-refresh"_s), tr("Refresh channels"), this, &RadioView::GetChannels);
|
||||
}
|
||||
|
||||
const bool channels_selected = !selectedIndexes().isEmpty();
|
||||
|
||||
@@ -27,6 +27,8 @@
|
||||
#include "radioviewcontainer.h"
|
||||
#include "ui_radioviewcontainer.h"
|
||||
|
||||
using namespace Qt::Literals::StringLiterals;
|
||||
|
||||
RadioViewContainer::RadioViewContainer(QWidget *parent)
|
||||
: QWidget(parent),
|
||||
ui_(new Ui_RadioViewContainer) {
|
||||
@@ -35,7 +37,7 @@ RadioViewContainer::RadioViewContainer(QWidget *parent)
|
||||
|
||||
QObject::connect(ui_->refresh, &QToolButton::clicked, this, &RadioViewContainer::Refresh);
|
||||
|
||||
ui_->refresh->setIcon(IconLoader::Load(QStringLiteral("view-refresh")));
|
||||
ui_->refresh->setIcon(IconLoader::Load(u"view-refresh"_s));
|
||||
|
||||
ReloadSettings();
|
||||
|
||||
|
||||
@@ -43,14 +43,14 @@ constexpr char kApiChannelsUrl[] = "https://somafm.com/channels.json";
|
||||
}
|
||||
|
||||
SomaFMService::SomaFMService(Application *app, SharedPtr<NetworkAccessManager> network, QObject *parent)
|
||||
: RadioService(Song::Source::SomaFM, QStringLiteral("SomaFM"), IconLoader::Load(QStringLiteral("somafm")), app, network, parent) {}
|
||||
: RadioService(Song::Source::SomaFM, u"SomaFM"_s, IconLoader::Load(u"somafm"_s), app, network, parent) {}
|
||||
|
||||
SomaFMService::~SomaFMService() {
|
||||
Abort();
|
||||
}
|
||||
|
||||
QUrl SomaFMService::Homepage() { return QUrl(QStringLiteral("https://somafm.com/")); }
|
||||
QUrl SomaFMService::Donate() { return QUrl(QStringLiteral("https://somafm.com/support/")); }
|
||||
QUrl SomaFMService::Homepage() { return QUrl(u"https://somafm.com/"_s); }
|
||||
QUrl SomaFMService::Donate() { return QUrl(u"https://somafm.com/support/"_s); }
|
||||
|
||||
void SomaFMService::Abort() {
|
||||
|
||||
@@ -91,7 +91,7 @@ void SomaFMService::GetChannelsReply(QNetworkReply *reply, const int task_id) {
|
||||
}
|
||||
|
||||
if (!object.contains("channels"_L1) || !object["channels"_L1].isArray()) {
|
||||
Error(QStringLiteral("Missing JSON channels array."), object);
|
||||
Error(u"Missing JSON channels array."_s, object);
|
||||
app_->task_manager()->SetTaskFinished(task_id);
|
||||
Q_EMIT NewChannels();
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user