Use QStringLiteral
This commit is contained in:
@@ -54,7 +54,7 @@ class CddaDevice : public ConnectedDevice {
|
||||
bool CopyToStorage(const CopyJob&, QString&) override { return false; }
|
||||
bool DeleteFromStorage(const MusicStorage::DeleteJob&) override { return false; }
|
||||
|
||||
static QStringList url_schemes() { return QStringList() << "cdda"; }
|
||||
static QStringList url_schemes() { return QStringList() << QStringLiteral("cdda"); }
|
||||
|
||||
signals:
|
||||
void SongsDiscovered(const SongList &songs);
|
||||
|
||||
@@ -41,7 +41,7 @@ QStringList CddaLister::DeviceUniqueIDs() { return devices_list_; }
|
||||
|
||||
QVariantList CddaLister::DeviceIcons(const QString &) {
|
||||
QVariantList icons;
|
||||
icons << QString("media-optical");
|
||||
icons << QStringLiteral("media-optical");
|
||||
return icons;
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ QString CddaLister::MakeFriendlyName(const QString &id) {
|
||||
return QString(cd_info.psz_model);
|
||||
}
|
||||
cdio_destroy(cdio);
|
||||
return QString("CD (") + id + ")";
|
||||
return QStringLiteral("CD (") + id + ")";
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -61,10 +61,10 @@ CddaSongLoader::~CddaSongLoader() {
|
||||
QUrl CddaSongLoader::GetUrlFromTrack(int track_number) const {
|
||||
|
||||
if (url_.isEmpty()) {
|
||||
return QUrl(QString("cdda://%1a").arg(track_number));
|
||||
return QUrl(QStringLiteral("cdda://%1a").arg(track_number));
|
||||
}
|
||||
else {
|
||||
return QUrl(QString("cdda://%1/%2").arg(url_.path()).arg(track_number));
|
||||
return QUrl(QStringLiteral("cdda://%1/%2").arg(url_.path()).arg(track_number));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -74,7 +74,7 @@ void CddaSongLoader::LoadSongs() {
|
||||
QMutexLocker locker(&mutex_load_);
|
||||
cdio_ = cdio_open(url_.path().toLocal8Bit().constData(), DRIVER_DEVICE);
|
||||
if (cdio_ == nullptr) {
|
||||
Error("Unable to open CDIO device.");
|
||||
Error(QStringLiteral("Unable to open CDIO device."));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ void CddaSongLoader::LoadSongs() {
|
||||
GError *error = nullptr;
|
||||
cdda_ = gst_element_make_from_uri(GST_URI_SRC, "cdda://", nullptr, &error);
|
||||
if (error) {
|
||||
Error(QString("%1: %2").arg(error->code).arg(error->message));
|
||||
Error(QStringLiteral("%1: %2").arg(error->code).arg(error->message));
|
||||
}
|
||||
if (!cdda_) return;
|
||||
|
||||
@@ -140,7 +140,7 @@ void CddaSongLoader::LoadSongs() {
|
||||
song.set_valid(true);
|
||||
song.set_filetype(Song::FileType::CDDA);
|
||||
song.set_url(GetUrlFromTrack(track_number));
|
||||
song.set_title(QString("Track %1").arg(track_number));
|
||||
song.set_title(QStringLiteral("Track %1").arg(track_number));
|
||||
song.set_track(track_number);
|
||||
songs << song;
|
||||
}
|
||||
|
||||
@@ -67,10 +67,10 @@ ConnectedDevice::ConnectedDevice(const QUrl &url, DeviceLister *lister, const QS
|
||||
backend_->Init(app_->database(),
|
||||
app_->task_manager(),
|
||||
Song::Source::Device,
|
||||
QString("device_%1_songs").arg(database_id),
|
||||
QString("device_%1_fts").arg(database_id),
|
||||
QString("device_%1_directories").arg(database_id),
|
||||
QString("device_%1_subdirectories").arg(database_id));
|
||||
QStringLiteral("device_%1_songs").arg(database_id),
|
||||
QStringLiteral("device_%1_fts").arg(database_id),
|
||||
QStringLiteral("device_%1_directories").arg(database_id),
|
||||
QStringLiteral("device_%1_subdirectories").arg(database_id));
|
||||
|
||||
// Create the model
|
||||
model_ = new CollectionModel(backend_, app_, this);
|
||||
|
||||
@@ -80,7 +80,7 @@ DeviceDatabaseBackend::DeviceList DeviceDatabaseBackend::GetAllDevices() {
|
||||
QMutexLocker l(db_->Mutex());
|
||||
QSqlDatabase db(db_->Connect());
|
||||
SqlQuery q(db);
|
||||
q.prepare("SELECT ROWID, unique_id, friendly_name, size, icon, schema_version, transcode_mode, transcode_format FROM devices");
|
||||
q.prepare(QStringLiteral("SELECT ROWID, unique_id, friendly_name, size, icon, schema_version, transcode_mode, transcode_format FROM devices"));
|
||||
if (!q.Exec()) {
|
||||
db_->ReportErrors(q);
|
||||
return ret;
|
||||
@@ -124,13 +124,13 @@ int DeviceDatabaseBackend::AddDevice(const Device &device) {
|
||||
|
||||
// Insert the device into the devices table
|
||||
SqlQuery q(db);
|
||||
q.prepare("INSERT INTO devices (unique_id, friendly_name, size, icon, transcode_mode, transcode_format) VALUES (:unique_id, :friendly_name, :size, :icon, :transcode_mode, :transcode_format)");
|
||||
q.BindValue(":unique_id", device.unique_id_);
|
||||
q.BindValue(":friendly_name", device.friendly_name_);
|
||||
q.BindValue(":size", device.size_);
|
||||
q.BindValue(":icon", device.icon_name_);
|
||||
q.BindValue(":transcode_mode", static_cast<int>(device.transcode_mode_));
|
||||
q.BindValue(":transcode_format", static_cast<int>(device.transcode_format_));
|
||||
q.prepare(QStringLiteral("INSERT INTO devices (unique_id, friendly_name, size, icon, transcode_mode, transcode_format) VALUES (:unique_id, :friendly_name, :size, :icon, :transcode_mode, :transcode_format)"));
|
||||
q.BindValue(QStringLiteral(":unique_id"), device.unique_id_);
|
||||
q.BindValue(QStringLiteral(":friendly_name"), device.friendly_name_);
|
||||
q.BindValue(QStringLiteral(":size"), device.size_);
|
||||
q.BindValue(QStringLiteral(":icon"), device.icon_name_);
|
||||
q.BindValue(QStringLiteral(":transcode_mode"), static_cast<int>(device.transcode_mode_));
|
||||
q.BindValue(QStringLiteral(":transcode_format"), static_cast<int>(device.transcode_format_));
|
||||
if (!q.Exec()) {
|
||||
db_->ReportErrors(q);
|
||||
return -1;
|
||||
@@ -138,13 +138,13 @@ int DeviceDatabaseBackend::AddDevice(const Device &device) {
|
||||
int id = q.lastInsertId().toInt();
|
||||
|
||||
// Create the songs tables for the device
|
||||
QString filename(":/schema/device-schema.sql");
|
||||
QString filename(QStringLiteral(":/schema/device-schema.sql"));
|
||||
QFile schema_file(filename);
|
||||
if (!schema_file.open(QIODevice::ReadOnly)) {
|
||||
qFatal("Couldn't open schema file %s: %s", filename.toUtf8().constData(), schema_file.errorString().toUtf8().constData());
|
||||
}
|
||||
QString schema = QString::fromUtf8(schema_file.readAll());
|
||||
schema.replace("%deviceid", QString::number(id));
|
||||
schema.replace(QLatin1String("%deviceid"), QString::number(id));
|
||||
|
||||
db_->ExecSchemaCommands(db, schema, 0, true);
|
||||
|
||||
@@ -164,8 +164,8 @@ void DeviceDatabaseBackend::RemoveDevice(const int id) {
|
||||
// Remove the device from the devices table
|
||||
{
|
||||
SqlQuery q(db);
|
||||
q.prepare("DELETE FROM devices WHERE ROWID=:id");
|
||||
q.BindValue(":id", id);
|
||||
q.prepare(QStringLiteral("DELETE FROM devices WHERE ROWID=:id"));
|
||||
q.BindValue(QStringLiteral(":id"), id);
|
||||
if (!q.Exec()) {
|
||||
db_->ReportErrors(q);
|
||||
return;
|
||||
@@ -175,7 +175,7 @@ void DeviceDatabaseBackend::RemoveDevice(const int id) {
|
||||
// Remove the songs tables for the device
|
||||
{
|
||||
SqlQuery q(db);
|
||||
q.prepare(QString("DROP TABLE device_%1_songs").arg(id));
|
||||
q.prepare(QStringLiteral("DROP TABLE device_%1_songs").arg(id));
|
||||
if (!q.Exec()) {
|
||||
db_->ReportErrors(q);
|
||||
return;
|
||||
@@ -184,7 +184,7 @@ void DeviceDatabaseBackend::RemoveDevice(const int id) {
|
||||
|
||||
{
|
||||
SqlQuery q(db);
|
||||
q.prepare(QString("DROP TABLE device_%1_fts").arg(id));
|
||||
q.prepare(QStringLiteral("DROP TABLE device_%1_fts").arg(id));
|
||||
if (!q.Exec()) {
|
||||
db_->ReportErrors(q);
|
||||
return;
|
||||
@@ -193,7 +193,7 @@ void DeviceDatabaseBackend::RemoveDevice(const int id) {
|
||||
|
||||
{
|
||||
SqlQuery q(db);
|
||||
q.prepare(QString("DROP TABLE device_%1_directories").arg(id));
|
||||
q.prepare(QStringLiteral("DROP TABLE device_%1_directories").arg(id));
|
||||
if (!q.Exec()) {
|
||||
db_->ReportErrors(q);
|
||||
return;
|
||||
@@ -202,7 +202,7 @@ void DeviceDatabaseBackend::RemoveDevice(const int id) {
|
||||
|
||||
{
|
||||
SqlQuery q(db);
|
||||
q.prepare(QString("DROP TABLE device_%1_subdirectories").arg(id));
|
||||
q.prepare(QStringLiteral("DROP TABLE device_%1_subdirectories").arg(id));
|
||||
if (!q.Exec()) {
|
||||
db_->ReportErrors(q);
|
||||
return;
|
||||
@@ -226,11 +226,11 @@ void DeviceDatabaseBackend::SetDeviceOptions(const int id, const QString &friend
|
||||
" transcode_mode=:transcode_mode,"
|
||||
" transcode_format=:transcode_format"
|
||||
" WHERE ROWID=:id");
|
||||
q.BindValue(":friendly_name", friendly_name);
|
||||
q.BindValue(":icon_name", icon_name);
|
||||
q.BindValue(":transcode_mode", static_cast<int>(mode));
|
||||
q.BindValue(":transcode_format", static_cast<int>(format));
|
||||
q.BindValue(":id", id);
|
||||
q.BindValue(QStringLiteral(":friendly_name"), friendly_name);
|
||||
q.BindValue(QStringLiteral(":icon_name"), icon_name);
|
||||
q.BindValue(QStringLiteral(":transcode_mode"), static_cast<int>(mode));
|
||||
q.BindValue(QStringLiteral(":transcode_format"), static_cast<int>(format));
|
||||
q.BindValue(QStringLiteral(":id"), id);
|
||||
if (!q.Exec()) {
|
||||
db_->ReportErrors(q);
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ DeviceDatabaseBackend::Device DeviceInfo::SaveToDb() const {
|
||||
for (const Backend &backend : backends_) {
|
||||
unique_ids << backend.unique_id_;
|
||||
}
|
||||
ret.unique_id_ = unique_ids.join(",");
|
||||
ret.unique_id_ = unique_ids.join(QStringLiteral(","));
|
||||
|
||||
return ret;
|
||||
|
||||
@@ -90,7 +90,7 @@ const DeviceInfo::Backend *DeviceInfo::BestBackend() const {
|
||||
|
||||
void DeviceInfo::LoadIcon(const QVariantList &icons, const QString &name_hint) {
|
||||
|
||||
icon_name_ = "device";
|
||||
icon_name_ = QStringLiteral("device");
|
||||
|
||||
if (icons.isEmpty()) {
|
||||
icon_ = IconLoader::Load(icon_name_);
|
||||
@@ -121,10 +121,10 @@ void DeviceInfo::LoadIcon(const QVariantList &icons, const QString &name_hint) {
|
||||
QString icon_name = icon.toString();
|
||||
if (!icon_name.isEmpty()) {
|
||||
QString hint = icons.first().toString().toLower() + name_hint.toLower();
|
||||
if (hint.contains("phone")) icon_name_ = "device-phone";
|
||||
else if (hint.contains("ipod") || hint.contains("apple")) icon_name_ = "device-ipod";
|
||||
else if ((hint.contains("usb")) && (hint.contains("reader"))) icon_name_ = "device-usb-flash";
|
||||
else if (hint.contains("usb")) icon_name_ = "device-usb-drive";
|
||||
if (hint.contains(QLatin1String("phone"))) icon_name_ = QStringLiteral("device-phone");
|
||||
else if (hint.contains(QLatin1String("ipod")) || hint.contains(QLatin1String("apple"))) icon_name_ = QStringLiteral("device-ipod");
|
||||
else if ((hint.contains(QLatin1String("usb"))) && (hint.contains(QLatin1String("reader")))) icon_name_ = QStringLiteral("device-usb-flash");
|
||||
else if (hint.contains(QLatin1String("usb"))) icon_name_ = QStringLiteral("device-usb-drive");
|
||||
icon_ = IconLoader::Load(icon_name_);
|
||||
if (!icon_.isNull()) {
|
||||
return;
|
||||
@@ -133,7 +133,7 @@ void DeviceInfo::LoadIcon(const QVariantList &icons, const QString &name_hint) {
|
||||
}
|
||||
}
|
||||
|
||||
icon_name_ = "device";
|
||||
icon_name_ = QStringLiteral("device");
|
||||
icon_ = IconLoader::Load(icon_name_);
|
||||
|
||||
}
|
||||
|
||||
@@ -110,48 +110,48 @@ QString GetIpodColour(Itdb_IpodModel model) {
|
||||
case ITDB_IPOD_MODEL_MINI_GREEN:
|
||||
case ITDB_IPOD_MODEL_NANO_GREEN:
|
||||
case ITDB_IPOD_MODEL_SHUFFLE_GREEN:
|
||||
return "green";
|
||||
return QStringLiteral("green");
|
||||
|
||||
case ITDB_IPOD_MODEL_MINI_BLUE:
|
||||
case ITDB_IPOD_MODEL_NANO_BLUE:
|
||||
case ITDB_IPOD_MODEL_SHUFFLE_BLUE:
|
||||
return "blue";
|
||||
return QStringLiteral("blue");
|
||||
|
||||
case ITDB_IPOD_MODEL_MINI_PINK:
|
||||
case ITDB_IPOD_MODEL_NANO_PINK:
|
||||
case ITDB_IPOD_MODEL_SHUFFLE_PINK:
|
||||
return "pink";
|
||||
return QStringLiteral("pink");
|
||||
|
||||
case ITDB_IPOD_MODEL_MINI_GOLD:
|
||||
return "gold";
|
||||
return QStringLiteral("gold");
|
||||
|
||||
case ITDB_IPOD_MODEL_NANO_WHITE:
|
||||
case ITDB_IPOD_MODEL_VIDEO_WHITE:
|
||||
return "white";
|
||||
return QStringLiteral("white");
|
||||
|
||||
case ITDB_IPOD_MODEL_NANO_SILVER:
|
||||
case ITDB_IPOD_MODEL_CLASSIC_SILVER:
|
||||
return "silver";
|
||||
return QStringLiteral("silver");
|
||||
|
||||
case ITDB_IPOD_MODEL_NANO_RED:
|
||||
case ITDB_IPOD_MODEL_SHUFFLE_RED:
|
||||
return "red";
|
||||
return QStringLiteral("red");
|
||||
|
||||
case ITDB_IPOD_MODEL_NANO_YELLOW:
|
||||
return "yellow";
|
||||
return QStringLiteral("yellow");
|
||||
|
||||
case ITDB_IPOD_MODEL_NANO_PURPLE:
|
||||
case ITDB_IPOD_MODEL_SHUFFLE_PURPLE:
|
||||
return "purple";
|
||||
return QStringLiteral("purple");
|
||||
|
||||
case ITDB_IPOD_MODEL_NANO_ORANGE:
|
||||
case ITDB_IPOD_MODEL_SHUFFLE_ORANGE:
|
||||
return "orange";
|
||||
return QStringLiteral("orange");
|
||||
|
||||
case ITDB_IPOD_MODEL_NANO_BLACK:
|
||||
case ITDB_IPOD_MODEL_VIDEO_BLACK:
|
||||
case ITDB_IPOD_MODEL_CLASSIC_BLACK:
|
||||
return "black";
|
||||
return QStringLiteral("black");
|
||||
|
||||
default:
|
||||
return QString();
|
||||
@@ -167,7 +167,7 @@ QString GetIpodModel(Itdb_IpodModel model) {
|
||||
case ITDB_IPOD_MODEL_MINI_PINK:
|
||||
case ITDB_IPOD_MODEL_MINI_GREEN:
|
||||
case ITDB_IPOD_MODEL_MINI_GOLD:
|
||||
return "mini";
|
||||
return QStringLiteral("mini");
|
||||
|
||||
case ITDB_IPOD_MODEL_NANO_WHITE:
|
||||
case ITDB_IPOD_MODEL_NANO_BLACK:
|
||||
@@ -179,7 +179,7 @@ QString GetIpodModel(Itdb_IpodModel model) {
|
||||
case ITDB_IPOD_MODEL_NANO_YELLOW:
|
||||
case ITDB_IPOD_MODEL_NANO_PURPLE:
|
||||
case ITDB_IPOD_MODEL_NANO_ORANGE:
|
||||
return "nano";
|
||||
return QStringLiteral("nano");
|
||||
|
||||
case ITDB_IPOD_MODEL_SHUFFLE:
|
||||
case ITDB_IPOD_MODEL_SHUFFLE_SILVER:
|
||||
@@ -188,17 +188,17 @@ QString GetIpodModel(Itdb_IpodModel model) {
|
||||
case ITDB_IPOD_MODEL_SHUFFLE_GREEN:
|
||||
case ITDB_IPOD_MODEL_SHUFFLE_ORANGE:
|
||||
case ITDB_IPOD_MODEL_SHUFFLE_RED:
|
||||
return "shuffle";
|
||||
return QStringLiteral("shuffle");
|
||||
|
||||
case ITDB_IPOD_MODEL_COLOR:
|
||||
case ITDB_IPOD_MODEL_REGULAR:
|
||||
case ITDB_IPOD_MODEL_CLASSIC_SILVER:
|
||||
case ITDB_IPOD_MODEL_CLASSIC_BLACK:
|
||||
return "standard";
|
||||
return QStringLiteral("standard");
|
||||
|
||||
case ITDB_IPOD_MODEL_COLOR_U2:
|
||||
case ITDB_IPOD_MODEL_REGULAR_U2:
|
||||
return "U2";
|
||||
return QStringLiteral("U2");
|
||||
|
||||
default:
|
||||
return QString();
|
||||
@@ -213,7 +213,7 @@ QUrl DeviceLister::MakeUrlFromLocalPath(const QString &path) const {
|
||||
|
||||
if (IsIpod(path)) {
|
||||
QUrl ret;
|
||||
ret.setScheme("ipod");
|
||||
ret.setScheme(QStringLiteral("ipod"));
|
||||
ret.setPath(QDir::fromNativeSeparators(path));
|
||||
return ret;
|
||||
}
|
||||
@@ -246,10 +246,10 @@ QVariantList DeviceLister::GuessIconForPath(const QString &path) {
|
||||
QString colour = GetIpodColour(info->ipod_model);
|
||||
|
||||
if (!model.isEmpty()) {
|
||||
QString model_icon = QString("multimedia-player-ipod-%1").arg(model);
|
||||
QString model_icon = QStringLiteral("multimedia-player-ipod-%1").arg(model);
|
||||
if (QFile(model_icon).exists()) ret << model_icon;
|
||||
if (!colour.isEmpty()) {
|
||||
QString colour_icon = QString("multimedia-player-ipod-%1-%2").arg(model, colour);
|
||||
QString colour_icon = QStringLiteral("multimedia-player-ipod-%1-%2").arg(model, colour);
|
||||
if (QFile(colour_icon).exists()) ret << colour_icon;
|
||||
}
|
||||
}
|
||||
@@ -274,7 +274,7 @@ QVariantList DeviceLister::GuessIconForPath(const QString &path) {
|
||||
QVariantList DeviceLister::GuessIconForModel(const QString &vendor, const QString &model) {
|
||||
|
||||
QVariantList ret;
|
||||
if (vendor.startsWith("Google") && model.contains("Nexus")) {
|
||||
if (vendor.startsWith(QLatin1String("Google")) && model.contains(QLatin1String("Nexus"))) {
|
||||
ret << "phone-google-nexus-one";
|
||||
}
|
||||
return ret;
|
||||
|
||||
@@ -91,7 +91,7 @@ const int DeviceManager::kDeviceIconOverlaySize = 16;
|
||||
DeviceManager::DeviceManager(Application *app, QObject *parent)
|
||||
: SimpleTreeModel<DeviceInfo>(new DeviceInfo(this), parent),
|
||||
app_(app),
|
||||
not_connected_overlay_(IconLoader::Load("edit-delete")) {
|
||||
not_connected_overlay_(IconLoader::Load(QStringLiteral("edit-delete"))) {
|
||||
|
||||
thread_pool_.setMaxThreadCount(1);
|
||||
QObject::connect(&*app_->task_manager(), &TaskManager::TasksChanged, this, &DeviceManager::TasksChanged);
|
||||
@@ -289,7 +289,7 @@ QVariant DeviceManager::data(const QModelIndex &idx, int role) const {
|
||||
}
|
||||
|
||||
if (info->size_ > 0) {
|
||||
text = text + QString(" (%1)").arg(Utilities::PrettySize(info->size_));
|
||||
text = text + QStringLiteral(" (%1)").arg(Utilities::PrettySize(info->size_));
|
||||
}
|
||||
if (info->device_) info->device_->Refresh();
|
||||
return text;
|
||||
@@ -629,7 +629,7 @@ SharedPtr<ConnectedDevice> DeviceManager::Connect(DeviceInfo *info) {
|
||||
url_strings << url.toString();
|
||||
}
|
||||
|
||||
app_->AddError(tr("This type of device is not supported: %1").arg(url_strings.join(", ")));
|
||||
app_->AddError(tr("This type of device is not supported: %1").arg(url_strings.join(QStringLiteral(", "))));
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -89,13 +89,13 @@ void DeviceProperties::ShowDevice(const QModelIndex &idx) {
|
||||
if (ui_->icon->count() == 0) {
|
||||
// Only load the icons the first time the dialog is shown
|
||||
QStringList icon_names = QStringList()
|
||||
<< "device"
|
||||
<< "device-usb-drive"
|
||||
<< "device-usb-flash"
|
||||
<< "media-optical"
|
||||
<< "device-ipod"
|
||||
<< "device-ipod-nano"
|
||||
<< "device-phone";
|
||||
<< QStringLiteral("device")
|
||||
<< QStringLiteral("device-usb-drive")
|
||||
<< QStringLiteral("device-usb-flash")
|
||||
<< QStringLiteral("media-optical")
|
||||
<< QStringLiteral("device-ipod")
|
||||
<< QStringLiteral("device-ipod-nano")
|
||||
<< QStringLiteral("device-phone");
|
||||
|
||||
|
||||
for (const QString &icon_name : icon_names) {
|
||||
|
||||
@@ -143,7 +143,7 @@ void DeviceItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op
|
||||
QVariant song_count = idx.data(DeviceManager::Role_SongCount);
|
||||
if (song_count.isValid()) {
|
||||
int count = song_count.toInt();
|
||||
status_text = tr("%1 song%2").arg(count).arg(count == 1 ? "" : "s");
|
||||
status_text = tr("%1 song%2").arg(count).arg(count == 1 ? QLatin1String("") : QLatin1String("s"));
|
||||
}
|
||||
else {
|
||||
status_text = idx.data(DeviceManager::Role_MountPath).toString();
|
||||
@@ -235,19 +235,19 @@ void DeviceView::contextMenuEvent(QContextMenuEvent *e) {
|
||||
collection_menu_ = new QMenu(this);
|
||||
|
||||
// Device menu
|
||||
eject_action_ = device_menu_->addAction(IconLoader::Load("media-eject"), tr("Safely remove device"), this, &DeviceView::Unmount);
|
||||
forget_action_ = device_menu_->addAction(IconLoader::Load("list-remove"), tr("Forget device"), this, &DeviceView::Forget);
|
||||
eject_action_ = device_menu_->addAction(IconLoader::Load(QStringLiteral("media-eject")), tr("Safely remove device"), this, &DeviceView::Unmount);
|
||||
forget_action_ = device_menu_->addAction(IconLoader::Load(QStringLiteral("list-remove")), tr("Forget device"), this, &DeviceView::Forget);
|
||||
device_menu_->addSeparator();
|
||||
properties_action_ = device_menu_->addAction(IconLoader::Load("configure"), tr("Device properties..."), this, &DeviceView::Properties);
|
||||
properties_action_ = device_menu_->addAction(IconLoader::Load(QStringLiteral("configure")), tr("Device properties..."), this, &DeviceView::Properties);
|
||||
|
||||
// Collection menu
|
||||
add_to_playlist_action_ = collection_menu_->addAction(IconLoader::Load("media-playback-start"), tr("Append to current playlist"), this, &DeviceView::AddToPlaylist);
|
||||
load_action_ = collection_menu_->addAction(IconLoader::Load("media-playback-start"), tr("Replace current playlist"), this, &DeviceView::Load);
|
||||
open_in_new_playlist_ = collection_menu_->addAction(IconLoader::Load("document-new"), tr("Open in new playlist"), this, &DeviceView::OpenInNewPlaylist);
|
||||
add_to_playlist_action_ = collection_menu_->addAction(IconLoader::Load(QStringLiteral("media-playback-start")), tr("Append to current playlist"), this, &DeviceView::AddToPlaylist);
|
||||
load_action_ = collection_menu_->addAction(IconLoader::Load(QStringLiteral("media-playback-start")), tr("Replace current playlist"), this, &DeviceView::Load);
|
||||
open_in_new_playlist_ = collection_menu_->addAction(IconLoader::Load(QStringLiteral("document-new")), tr("Open in new playlist"), this, &DeviceView::OpenInNewPlaylist);
|
||||
|
||||
collection_menu_->addSeparator();
|
||||
organize_action_ = collection_menu_->addAction(IconLoader::Load("edit-copy"), tr("Copy to collection..."), this, &DeviceView::Organize);
|
||||
delete_action_ = collection_menu_->addAction(IconLoader::Load("edit-delete"), tr("Delete from device..."), this, &DeviceView::Delete);
|
||||
organize_action_ = collection_menu_->addAction(IconLoader::Load(QStringLiteral("edit-copy")), tr("Copy to collection..."), this, &DeviceView::Organize);
|
||||
delete_action_ = collection_menu_->addAction(IconLoader::Load(QStringLiteral("edit-delete")), tr("Delete from device..."), this, &DeviceView::Delete);
|
||||
}
|
||||
|
||||
menu_index_ = currentIndex();
|
||||
|
||||
@@ -52,7 +52,7 @@ class FilesystemDevice : public ConnectedDevice, public virtual FilesystemMusicS
|
||||
bool Init() override;
|
||||
void CloseAsync();
|
||||
|
||||
static QStringList url_schemes() { return QStringList() << "file"; }
|
||||
static QStringList url_schemes() { return QStringList() << QStringLiteral("file"); }
|
||||
|
||||
private slots:
|
||||
void Close() override;
|
||||
|
||||
@@ -51,10 +51,10 @@ QString GioLister::DeviceInfo::unique_id() const {
|
||||
if (!volume_root_uri.isEmpty()) return volume_root_uri;
|
||||
|
||||
if (mount_ptr) {
|
||||
return QString("Gio/%1/%2/%3").arg(mount_uuid, filesystem_type).arg(filesystem_size);
|
||||
return QStringLiteral("Gio/%1/%2/%3").arg(mount_uuid, filesystem_type).arg(filesystem_size);
|
||||
}
|
||||
else {
|
||||
return QString("Gio/unmounted/%1").arg(reinterpret_cast<qulonglong>(volume_ptr.get()));
|
||||
return QStringLiteral("Gio/unmounted/%1").arg(reinterpret_cast<qulonglong>(volume_ptr.get()));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -225,11 +225,11 @@ QList<QUrl> GioLister::MakeDeviceUrls(const QString &id) {
|
||||
for (QString uri : uris) {
|
||||
|
||||
// gphoto2 gives invalid hostnames with []:, characters in
|
||||
uri.replace(QRegularExpression("//\\[usb:(\\d+),(\\d+)\\]"), "//usb-\\1-\\2");
|
||||
uri.replace(QRegularExpression(QStringLiteral("//\\[usb:(\\d+),(\\d+)\\]")), QStringLiteral("//usb-\\1-\\2"));
|
||||
|
||||
QUrl url;
|
||||
|
||||
if (uri.contains(QRegularExpression("..+:.*"))) {
|
||||
if (uri.contains(QRegularExpression(QStringLiteral("..+:.*")))) {
|
||||
url = QUrl::fromEncoded(uri.toUtf8());
|
||||
}
|
||||
else {
|
||||
@@ -240,15 +240,15 @@ QList<QUrl> GioLister::MakeDeviceUrls(const QString &id) {
|
||||
|
||||
// Special case for file:// GIO URIs - we have to check whether they point to an ipod.
|
||||
if (url.isLocalFile() && IsIpod(url.path())) {
|
||||
url.setScheme("ipod");
|
||||
url.setScheme(QStringLiteral("ipod"));
|
||||
}
|
||||
|
||||
QRegularExpression device_re("usb/(\\d+)/(\\d+)");
|
||||
QRegularExpression device_re(QStringLiteral("usb/(\\d+)/(\\d+)"));
|
||||
QRegularExpressionMatch re_match = device_re.match(unix_device);
|
||||
if (re_match.hasMatch()) {
|
||||
QUrlQuery url_query(url);
|
||||
url_query.addQueryItem("busnum", re_match.captured(1));
|
||||
url_query.addQueryItem("devnum", re_match.captured(2));
|
||||
url_query.addQueryItem(QStringLiteral("busnum"), re_match.captured(1));
|
||||
url_query.addQueryItem(QStringLiteral("devnum"), re_match.captured(2));
|
||||
url.setQuery(url_query);
|
||||
}
|
||||
|
||||
@@ -292,12 +292,12 @@ void GioLister::VolumeAdded(GVolume *volume) {
|
||||
|
||||
DeviceInfo info;
|
||||
info.ReadVolumeInfo(volume);
|
||||
if (info.volume_root_uri.startsWith("afc://") || info.volume_root_uri.startsWith("gphoto2://")) {
|
||||
if (info.volume_root_uri.startsWith(QLatin1String("afc://")) || info.volume_root_uri.startsWith(QLatin1String("gphoto2://"))) {
|
||||
// Handled by iLister.
|
||||
return;
|
||||
}
|
||||
#ifdef HAVE_AUDIOCD
|
||||
if (info.volume_root_uri.startsWith("cdda")) {
|
||||
if (info.volume_root_uri.startsWith(QLatin1String("cdda"))) {
|
||||
// Audio CD devices are already handled by CDDA lister
|
||||
return;
|
||||
}
|
||||
@@ -336,12 +336,12 @@ void GioLister::MountAdded(GMount *mount) {
|
||||
|
||||
DeviceInfo info;
|
||||
info.ReadVolumeInfo(g_mount_get_volume(mount));
|
||||
if (info.volume_root_uri.startsWith("afc://") || info.volume_root_uri.startsWith("gphoto2://")) {
|
||||
if (info.volume_root_uri.startsWith(QLatin1String("afc://")) || info.volume_root_uri.startsWith(QLatin1String("gphoto2://"))) {
|
||||
// Handled by iLister.
|
||||
return;
|
||||
}
|
||||
#ifdef HAVE_AUDIOCD
|
||||
if (info.volume_root_uri.startsWith("cdda")) {
|
||||
if (info.volume_root_uri.startsWith(QLatin1String("cdda"))) {
|
||||
// Audio CD devices are already handled by CDDA lister
|
||||
return;
|
||||
}
|
||||
@@ -577,7 +577,7 @@ void GioLister::UpdateDeviceFreeSpace(const QString &id) {
|
||||
|
||||
{
|
||||
QMutexLocker l(&mutex_);
|
||||
if (!devices_.contains(id) || !devices_[id].mount_ptr || devices_[id].volume_root_uri.startsWith("mtp://")) return;
|
||||
if (!devices_.contains(id) || !devices_[id].mount_ptr || devices_[id].volume_root_uri.startsWith(QLatin1String("mtp://"))) return;
|
||||
|
||||
DeviceInfo &device_info = devices_[id];
|
||||
|
||||
@@ -604,7 +604,7 @@ void GioLister::UpdateDeviceFreeSpace(const QString &id) {
|
||||
bool GioLister::DeviceNeedsMount(const QString &id) {
|
||||
|
||||
QMutexLocker l(&mutex_);
|
||||
return devices_.contains(id) && !devices_[id].mount_ptr && !devices_[id].volume_root_uri.startsWith("mtp://") && !devices_[id].volume_root_uri.startsWith("gphoto2://");
|
||||
return devices_.contains(id) && !devices_[id].mount_ptr && !devices_[id].volume_root_uri.startsWith(QLatin1String("mtp://")) && !devices_[id].volume_root_uri.startsWith(QLatin1String("gphoto2://"));
|
||||
|
||||
}
|
||||
|
||||
@@ -631,7 +631,7 @@ void GioLister::MountDevice(const QString &id, const int request_id) {
|
||||
void GioLister::UnmountDevice(const QString &id) {
|
||||
|
||||
QMutexLocker l(&mutex_);
|
||||
if (!devices_.contains(id) || !devices_[id].mount_ptr || devices_[id].volume_root_uri.startsWith("mtp://")) return;
|
||||
if (!devices_.contains(id) || !devices_[id].mount_ptr || devices_[id].volume_root_uri.startsWith(QLatin1String("mtp://"))) return;
|
||||
|
||||
const DeviceInfo &info = devices_[id];
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ class GPodDevice : public ConnectedDevice, public virtual MusicStorage {
|
||||
bool IsLoading() override { return loader_; }
|
||||
QObject *Loader() { return loader_; }
|
||||
|
||||
static QStringList url_schemes() { return QStringList() << "ipod"; }
|
||||
static QStringList url_schemes() { return QStringList() << QStringLiteral("ipod"); }
|
||||
|
||||
bool GetSupportedFiletypes(QList<Song::FileType> *ret) override;
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ MtpConnection::MtpConnection(const QUrl &url, QObject *parent) : QObject(parent)
|
||||
|
||||
QString hostname = url.host();
|
||||
// Parse the URL
|
||||
QRegularExpression host_re("^usb-(\\d+)-(\\d+)$");
|
||||
QRegularExpression host_re(QStringLiteral("^usb-(\\d+)-(\\d+)$"));
|
||||
|
||||
unsigned int bus_location = 0;
|
||||
unsigned int device_num = 0;
|
||||
@@ -49,9 +49,9 @@ MtpConnection::MtpConnection(const QUrl &url, QObject *parent) : QObject(parent)
|
||||
bus_location = re_match.captured(1).toUInt();
|
||||
device_num = re_match.captured(2).toUInt();
|
||||
}
|
||||
else if (url_query.hasQueryItem("busnum")) {
|
||||
bus_location = url_query.queryItemValue("busnum").toUInt();
|
||||
device_num = url_query.queryItemValue("devnum").toUInt();
|
||||
else if (url_query.hasQueryItem(QStringLiteral("busnum"))) {
|
||||
bus_location = url_query.queryItemValue(QStringLiteral("busnum")).toUInt();
|
||||
device_num = url_query.queryItemValue(QStringLiteral("devnum")).toUInt();
|
||||
}
|
||||
else {
|
||||
error_text_ = tr("Invalid MTP device: %1").arg(hostname);
|
||||
@@ -59,13 +59,13 @@ MtpConnection::MtpConnection(const QUrl &url, QObject *parent) : QObject(parent)
|
||||
return;
|
||||
}
|
||||
|
||||
if (url_query.hasQueryItem("vendor")) {
|
||||
if (url_query.hasQueryItem(QStringLiteral("vendor"))) {
|
||||
LIBMTP_raw_device_t *raw_device = static_cast<LIBMTP_raw_device_t*>(malloc(sizeof(LIBMTP_raw_device_t)));
|
||||
raw_device->device_entry.vendor = url_query.queryItemValue("vendor").toLatin1().data();
|
||||
raw_device->device_entry.product = url_query.queryItemValue("product").toLatin1().data();
|
||||
raw_device->device_entry.vendor_id = url_query.queryItemValue("vendor_id").toUShort();
|
||||
raw_device->device_entry.product_id = url_query.queryItemValue("product_id").toUShort();
|
||||
raw_device->device_entry.device_flags = url_query.queryItemValue("quirks").toUInt();
|
||||
raw_device->device_entry.vendor = url_query.queryItemValue(QStringLiteral("vendor")).toLatin1().data();
|
||||
raw_device->device_entry.product = url_query.queryItemValue(QStringLiteral("product")).toLatin1().data();
|
||||
raw_device->device_entry.vendor_id = url_query.queryItemValue(QStringLiteral("vendor_id")).toUShort();
|
||||
raw_device->device_entry.product_id = url_query.queryItemValue(QStringLiteral("product_id")).toUShort();
|
||||
raw_device->device_entry.device_flags = url_query.queryItemValue(QStringLiteral("quirks")).toUInt();
|
||||
|
||||
raw_device->bus_location = bus_location;
|
||||
raw_device->devnum = device_num;
|
||||
@@ -122,16 +122,16 @@ QString MtpConnection::ErrorString(const LIBMTP_error_number_t error_number) {
|
||||
|
||||
switch(error_number) {
|
||||
case LIBMTP_ERROR_NO_DEVICE_ATTACHED:
|
||||
return "No Devices have been found.";
|
||||
return QStringLiteral("No Devices have been found.");
|
||||
case LIBMTP_ERROR_CONNECTING:
|
||||
return "There has been an error connecting.";
|
||||
return QStringLiteral("There has been an error connecting.");
|
||||
case LIBMTP_ERROR_MEMORY_ALLOCATION:
|
||||
return "Memory Allocation Error.";
|
||||
return QStringLiteral("Memory Allocation Error.");
|
||||
case LIBMTP_ERROR_GENERAL:
|
||||
default:
|
||||
return "Unknown error, please report this to the libmtp developers.";
|
||||
return QStringLiteral("Unknown error, please report this to the libmtp developers.");
|
||||
case LIBMTP_ERROR_NONE:
|
||||
return "Successfully connected.";
|
||||
return QStringLiteral("Successfully connected.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ MtpDevice::~MtpDevice() {
|
||||
|
||||
bool MtpDevice::Init() {
|
||||
|
||||
InitBackendDirectory("/", first_time_, false);
|
||||
InitBackendDirectory(QStringLiteral("/"), first_time_, false);
|
||||
model_->Init();
|
||||
|
||||
loader_ = new MtpLoader(url_, app_->task_manager(), backend_);
|
||||
@@ -187,7 +187,7 @@ bool MtpDevice::CopyToStorage(const CopyJob &job, QString &error_text) {
|
||||
metadata_on_device.InitFromMTP(&track, url_.host());
|
||||
metadata_on_device.set_directory_id(1);
|
||||
metadata_on_device.set_artist(metadata_on_device.effective_albumartist());
|
||||
metadata_on_device.set_albumartist("");
|
||||
metadata_on_device.set_albumartist(QLatin1String(""));
|
||||
songs_to_add_ << metadata_on_device;
|
||||
|
||||
// Remove the original if requested
|
||||
|
||||
@@ -51,7 +51,7 @@ class MtpDevice : public ConnectedDevice {
|
||||
Q_INVOKABLE MtpDevice(const QUrl &url, DeviceLister *lister, const QString &unique_id, SharedPtr<DeviceManager> manager, Application *app, const int database_id, const bool first_time, QObject *parent = nullptr);
|
||||
~MtpDevice() override;
|
||||
|
||||
static QStringList url_schemes() { return QStringList() << "mtp"; }
|
||||
static QStringList url_schemes() { return QStringList() << QStringLiteral("mtp"); }
|
||||
|
||||
bool Init() override;
|
||||
void ConnectAsync() override;
|
||||
|
||||
@@ -79,7 +79,7 @@ QVariantList Udisks2Lister::DeviceIcons(const QString &id) {
|
||||
QString Udisks2Lister::DeviceManufacturer(const QString &id) {
|
||||
|
||||
QReadLocker locker(&device_data_lock_);
|
||||
if (!device_data_.contains(id)) return "";
|
||||
if (!device_data_.contains(id)) return QLatin1String("");
|
||||
return device_data_[id].vendor;
|
||||
|
||||
}
|
||||
@@ -87,7 +87,7 @@ QString Udisks2Lister::DeviceManufacturer(const QString &id) {
|
||||
QString Udisks2Lister::DeviceModel(const QString &id) {
|
||||
|
||||
QReadLocker locker(&device_data_lock_);
|
||||
if (!device_data_.contains(id)) return "";
|
||||
if (!device_data_.contains(id)) return QLatin1String("");
|
||||
return device_data_[id].model;
|
||||
|
||||
}
|
||||
@@ -118,7 +118,7 @@ QVariantMap Udisks2Lister::DeviceHardwareInfo(const QString &id) {
|
||||
const PartitionData &data = device_data_[id];
|
||||
result[QT_TR_NOOP("D-Bus path")] = data.dbus_path;
|
||||
result[QT_TR_NOOP("Serial number")] = data.serial;
|
||||
result[QT_TR_NOOP("Mount points")] = data.mount_paths.join(", ");
|
||||
result[QT_TR_NOOP("Mount points")] = data.mount_paths.join(QStringLiteral(", "));
|
||||
result[QT_TR_NOOP("Partition label")] = data.label;
|
||||
result[QT_TR_NOOP("UUID")] = data.uuid;
|
||||
|
||||
@@ -129,7 +129,7 @@ QVariantMap Udisks2Lister::DeviceHardwareInfo(const QString &id) {
|
||||
QString Udisks2Lister::MakeFriendlyName(const QString &id) {
|
||||
|
||||
QReadLocker locker(&device_data_lock_);
|
||||
if (!device_data_.contains(id)) return "";
|
||||
if (!device_data_.contains(id)) return QLatin1String("");
|
||||
return device_data_[id].friendly_name;
|
||||
|
||||
}
|
||||
@@ -408,7 +408,7 @@ Udisks2Lister::PartitionData Udisks2Lister::ReadPartitionData(const QDBusObjectP
|
||||
}
|
||||
|
||||
QString Udisks2Lister::PartitionData::unique_id() const {
|
||||
return QString("Udisks2/%1/%2/%3/%4/%5")
|
||||
return QStringLiteral("Udisks2/%1/%2/%3/%4/%5")
|
||||
.arg(serial, vendor, model)
|
||||
.arg(capacity)
|
||||
.arg(uuid);
|
||||
|
||||
Reference in New Issue
Block a user