Replace QLatin1String with operator _L1

This commit is contained in:
Jonas Kvinge
2024-09-07 04:24:14 +02:00
parent e3e6a22172
commit 4270b12cd1
185 changed files with 2429 additions and 2139 deletions

View File

@@ -38,6 +38,7 @@
#include "devicemanager.h"
#include "deviceinfo.h"
using namespace Qt::StringLiterals;
using std::make_shared;
ConnectedDevice::ConnectedDevice(const QUrl &url, DeviceLister *lister, const QString &unique_id, SharedPtr<DeviceManager> manager, Application *app, const int database_id, const bool first_time, QObject *parent)
@@ -60,7 +61,7 @@ ConnectedDevice::ConnectedDevice(const QUrl &url, DeviceLister *lister, const QS
backend_->moveToThread(app_->database()->thread());
qLog(Debug) << &*backend_ << "for device" << unique_id_ << "moved to thread" << app_->database()->thread();
if (url_.scheme() != QLatin1String("cdda")) {
if (url_.scheme() != "cdda"_L1) {
QObject::connect(&*backend_, &CollectionBackend::TotalSongCountUpdated, this, &ConnectedDevice::BackendTotalSongCountUpdated);
}

View File

@@ -38,6 +38,8 @@
#include "core/scopedtransaction.h"
#include "devicedatabasebackend.h"
using namespace Qt::StringLiterals;
namespace {
constexpr int kDeviceSchemaVersion = 5;
}
@@ -144,13 +146,13 @@ int DeviceDatabaseBackend::AddDevice(const Device &device) {
int id = q.lastInsertId().toInt();
// Create the songs tables for the device
QString filename(QLatin1String(":/schema/device-schema.sql"));
QString filename(":/schema/device-schema.sql"_L1);
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(QLatin1String("%deviceid"), QString::number(id));
schema.replace("%deviceid"_L1, QString::number(id));
db_->ExecSchemaCommands(db, schema, 0, true);

View File

@@ -34,6 +34,8 @@
#include "devicedatabasebackend.h"
#include "deviceinfo.h"
using namespace Qt::StringLiterals;
DeviceDatabaseBackend::Device DeviceInfo::SaveToDb() const {
DeviceDatabaseBackend::Device ret;
@@ -49,7 +51,7 @@ DeviceDatabaseBackend::Device DeviceInfo::SaveToDb() const {
for (const Backend &backend : backends_) {
unique_ids << backend.unique_id_;
}
ret.unique_id_ = unique_ids.join(QLatin1Char(','));
ret.unique_id_ = unique_ids.join(u',');
return ret;
@@ -64,7 +66,7 @@ void DeviceInfo::InitFromDb(const DeviceDatabaseBackend::Device &dev) {
transcode_format_ = dev.transcode_format_;
icon_name_ = dev.icon_name_;
const QStringList unique_ids = dev.unique_id_.split(QLatin1Char(','));
const QStringList unique_ids = dev.unique_id_.split(u',');
for (const QString &id : unique_ids) {
backends_ << Backend(nullptr, id);
}
@@ -90,7 +92,7 @@ const DeviceInfo::Backend *DeviceInfo::BestBackend() const {
void DeviceInfo::LoadIcon(const QVariantList &icons, const QString &name_hint) {
icon_name_ = QLatin1String("device");
icon_name_ = "device"_L1;
if (icons.isEmpty()) {
icon_ = IconLoader::Load(icon_name_);
@@ -121,10 +123,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(QLatin1String("phone"))) icon_name_ = QLatin1String("device-phone");
else if (hint.contains(QLatin1String("ipod")) || hint.contains(QLatin1String("apple"))) icon_name_ = QLatin1String("device-ipod");
else if ((hint.contains(QLatin1String("usb"))) && (hint.contains(QLatin1String("reader")))) icon_name_ = QLatin1String("device-usb-flash");
else if (hint.contains(QLatin1String("usb"))) icon_name_ = QLatin1String("device-usb-drive");
if (hint.contains("phone"_L1)) icon_name_ = "device-phone"_L1;
else if (hint.contains("ipod"_L1) || hint.contains("apple"_L1)) icon_name_ = "device-ipod"_L1;
else if ((hint.contains("usb"_L1)) && (hint.contains("reader"_L1))) icon_name_ = "device-usb-flash"_L1;
else if (hint.contains("usb"_L1)) icon_name_ = "device-usb-drive"_L1;
icon_ = IconLoader::Load(icon_name_);
if (!icon_.isNull()) {
return;
@@ -133,7 +135,7 @@ void DeviceInfo::LoadIcon(const QVariantList &icons, const QString &name_hint) {
}
}
icon_name_ = QLatin1String("device");
icon_name_ = "device"_L1;
icon_ = IconLoader::Load(icon_name_);
}

View File

@@ -37,6 +37,8 @@
#include "core/logging.h"
using namespace Qt::StringLiterals;
DeviceLister::DeviceLister(QObject *parent)
: QObject(parent),
thread_(nullptr),
@@ -226,9 +228,9 @@ QUrl DeviceLister::MakeUrlFromLocalPath(const QString &path) const {
}
bool DeviceLister::IsIpod(const QString &path) {
return QFile::exists(path + QLatin1String("/iTunes_Control")) ||
QFile::exists(path + QLatin1String("/iPod_Control")) ||
QFile::exists(path + QLatin1String("/iTunes/iTunes_Control"));
return QFile::exists(path + "/iTunes_Control"_L1) ||
QFile::exists(path + "/iPod_Control"_L1) ||
QFile::exists(path + "/iTunes/iTunes_Control"_L1);
}
QVariantList DeviceLister::GuessIconForPath(const QString &path) {
@@ -277,7 +279,7 @@ QVariantList DeviceLister::GuessIconForPath(const QString &path) {
QVariantList DeviceLister::GuessIconForModel(const QString &vendor, const QString &model) {
QVariantList ret;
if (vendor.startsWith(QLatin1String("Google")) && model.contains(QLatin1String("Nexus"))) {
if (vendor.startsWith("Google"_L1) && model.contains("Nexus"_L1)) {
ret << QStringLiteral("phone-google-nexus-one");
}
return ret;

View File

@@ -84,6 +84,7 @@
# include "gpoddevice.h"
#endif
using namespace Qt::StringLiterals;
using std::make_unique;
const int DeviceManager::kDeviceIconSize = 32;
@@ -244,7 +245,7 @@ void DeviceManager::LoadAllDevices() {
void DeviceManager::AddDeviceFromDB(DeviceInfo *info) {
const QStringList icon_names = info->icon_name_.split(QLatin1Char(','));
const QStringList icon_names = info->icon_name_.split(u',');
QVariantList icons;
icons.reserve(icon_names.count());
for (const QString &icon_name : icon_names) {
@@ -603,7 +604,7 @@ SharedPtr<ConnectedDevice> DeviceManager::Connect(DeviceInfo *info) {
// If we get here it means that this URL scheme wasn't supported.
// If it was "ipod" or "mtp" then the user compiled out support and the device won't work properly.
if (url.scheme() == QLatin1String("mtp") || url.scheme() == QLatin1String("gphoto2")) {
if (url.scheme() == "mtp"_L1 || url.scheme() == "gphoto2"_L1) {
if (QMessageBox::critical(nullptr, tr("This device will not work properly"),
tr("This is an MTP device, but you compiled Strawberry without libmtp support.") + QStringLiteral(" ") +
tr("If you continue, this device will work slowly and songs copied to it may not work."),
@@ -611,9 +612,9 @@ SharedPtr<ConnectedDevice> DeviceManager::Connect(DeviceInfo *info) {
return ret;
}
if (url.scheme() == QLatin1String("ipod")) {
if (url.scheme() == "ipod"_L1) {
if (QMessageBox::critical(nullptr, tr("This device will not work properly"),
tr("This is an iPod, but you compiled Strawberry without libgpod support.") + QLatin1String(" ") +
tr("This is an iPod, but you compiled Strawberry without libgpod support.") + " "_L1 +
tr("If you continue, this device will work slowly and songs copied to it may not work."),
QMessageBox::Abort, QMessageBox::Ignore) == QMessageBox::Abort)
return ret;
@@ -628,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(QLatin1String(", "))));
app_->AddError(tr("This type of device is not supported: %1").arg(url_strings.join(", "_L1)));
return ret;
}

View File

@@ -67,6 +67,7 @@
#include "deviceproperties.h"
#include "deviceview.h"
using namespace Qt::StringLiterals;
using std::make_unique;
const int DeviceItemDelegate::kIconPadding = 6;
@@ -143,7 +144,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 ? QLatin1String("") : QLatin1String("s"));
status_text = tr("%1 song%2").arg(count).arg(count == 1 ? ""_L1 : "s"_L1);
}
else {
status_text = idx.data(DeviceManager::Role_MountPath).toString();

View File

@@ -47,6 +47,8 @@
#include "devicelister.h"
#include "giolister.h"
using namespace Qt::StringLiterals;
QString GioLister::DeviceInfo::unique_id() const {
if (!volume_root_uri.isEmpty()) return volume_root_uri;
@@ -69,7 +71,7 @@ bool GioLister::DeviceInfo::is_suitable() const {
if (filesystem_type.isEmpty()) return true;
return filesystem_type != QLatin1String("udf") && filesystem_type != QLatin1String("smb") && filesystem_type != QLatin1String("cifs") && filesystem_type != QLatin1String("ssh") && filesystem_type != QLatin1String("isofs");
return filesystem_type != "udf"_L1 && filesystem_type != "smb"_L1 && filesystem_type != "cifs"_L1 && filesystem_type != "ssh"_L1 && filesystem_type != "isofs"_L1;
}
@@ -295,12 +297,12 @@ void GioLister::VolumeAdded(GVolume *volume) {
DeviceInfo info;
info.ReadVolumeInfo(volume);
if (info.volume_root_uri.startsWith(QLatin1String("afc://")) || info.volume_root_uri.startsWith(QLatin1String("gphoto2://"))) {
if (info.volume_root_uri.startsWith("afc://"_L1) || info.volume_root_uri.startsWith("gphoto2://"_L1)) {
// Handled by iLister.
return;
}
#ifdef HAVE_AUDIOCD
if (info.volume_root_uri.startsWith(QLatin1String("cdda"))) {
if (info.volume_root_uri.startsWith("cdda"_L1)) {
// Audio CD devices are already handled by CDDA lister
return;
}
@@ -339,12 +341,12 @@ void GioLister::MountAdded(GMount *mount) {
DeviceInfo info;
info.ReadVolumeInfo(g_mount_get_volume(mount));
if (info.volume_root_uri.startsWith(QLatin1String("afc://")) || info.volume_root_uri.startsWith(QLatin1String("gphoto2://"))) {
if (info.volume_root_uri.startsWith("afc://"_L1) || info.volume_root_uri.startsWith("gphoto2://"_L1)) {
// Handled by iLister.
return;
}
#ifdef HAVE_AUDIOCD
if (info.volume_root_uri.startsWith(QLatin1String("cdda"))) {
if (info.volume_root_uri.startsWith("cdda"_L1)) {
// Audio CD devices are already handled by CDDA lister
return;
}
@@ -506,7 +508,7 @@ void GioLister::DeviceInfo::ReadMountInfo(GMount *mount) {
// Query the file's info for a filesystem ID
// Only afc devices (that I know of) give reliably unique IDs
if (filesystem_type == QLatin1String("afc")) {
if (filesystem_type == "afc"_L1) {
error = nullptr;
info = g_file_query_info(root, G_FILE_ATTRIBUTE_ID_FILESYSTEM, G_FILE_QUERY_INFO_NONE, nullptr, &error);
if (error) {
@@ -580,7 +582,7 @@ void GioLister::UpdateDeviceFreeSpace(const QString &id) {
{
QMutexLocker l(&mutex_);
if (!devices_.contains(id) || !devices_[id].mount_ptr || devices_.value(id).volume_root_uri.startsWith(QLatin1String("mtp://"))) return;
if (!devices_.contains(id) || !devices_[id].mount_ptr || devices_.value(id).volume_root_uri.startsWith("mtp://"_L1)) return;
GFile *root = g_mount_get_root(devices_.value(id).mount_ptr);
@@ -605,7 +607,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(QLatin1String("mtp://")) && !devices_[id].volume_root_uri.startsWith(QLatin1String("gphoto2://"));
return devices_.contains(id) && !devices_[id].mount_ptr && !devices_[id].volume_root_uri.startsWith("mtp://"_L1) && !devices_[id].volume_root_uri.startsWith("gphoto2://"_L1);
}
@@ -632,7 +634,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_.value(id).volume_root_uri.startsWith(QLatin1String("mtp://"))) return;
if (!devices_.contains(id) || !devices_[id].mount_ptr || devices_.value(id).volume_root_uri.startsWith("mtp://"_L1)) return;
const DeviceInfo device_info = devices_.value(id);

View File

@@ -325,10 +325,10 @@ bool GPodDevice::RemoveTrackFromITunesDb(const QString &path, const QString &rel
QString ipod_filename = path;
if (!relative_to.isEmpty() && path.startsWith(relative_to)) {
ipod_filename.remove(0, relative_to.length() + (relative_to.endsWith(QLatin1Char('/')) ? -1 : 0));
ipod_filename.remove(0, relative_to.length() + (relative_to.endsWith(u'/') ? -1 : 0));
}
ipod_filename.replace(QLatin1Char('/'), QLatin1Char(':'));
ipod_filename.replace(u'/', u':');
// Find the track in the itdb, identify it by its filename
Itdb_Track *track = nullptr;

View File

@@ -53,6 +53,8 @@
#import <Foundation/NSString.h>
#import <Foundation/NSURL.h>
using namespace Qt::Literals::StringLiterals;
#ifndef kUSBSerialNumberString
#define kUSBSerialNumberString "USB Serial Number"
#endif
@@ -134,9 +136,9 @@ bool MacOsDeviceLister::Init() {
}
MTPDevice d;
d.vendor = QLatin1String("SanDisk");
d.vendor = "SanDisk"_L1;
d.vendor_id = 0x781;
d.product = QLatin1String("Sansa Clip+");
d.product = "Sansa Clip+"_L1;
d.product_id = 0x74d0;
d.quirks = 0x2 | 0x4 | 0x40 | 0x4000;
@@ -299,7 +301,7 @@ QString GetIconForDevice(io_object_t device) {
scoped_nsobject<NSURL> bundle_url(reinterpret_cast<NSURL*>(KextManagerCreateURLForBundleIdentifier(kCFAllocatorDefault, reinterpret_cast<CFStringRef>(bundle))));
QString path = QString::fromUtf8([[bundle_url path] UTF8String]);
path += QLatin1String("/Contents/Resources/");
path += "/Contents/Resources/"_L1;
path += QString::fromUtf8([file UTF8String]);
return path;
}
@@ -312,7 +314,7 @@ QString GetSerialForDevice(io_object_t device) {
const QString serial = GetUSBRegistryEntryString(device, CFSTR(kUSBSerialNumberString));
if (!serial.isEmpty()) {
return QLatin1String("USB/") + serial;
return "USB/"_L1 + serial;
}
return QString();
@@ -322,7 +324,7 @@ QString GetSerialForDevice(io_object_t device) {
QString GetSerialForMTPDevice(io_object_t device) {
scoped_nsobject<NSString> serial(reinterpret_cast<NSString*>(GetPropertyForDevice(device, CFSTR(kUSBSerialNumberString))));
return QLatin1String("MTP/") + QString::fromUtf8([serial UTF8String]);
return "MTP/"_L1 + QString::fromUtf8([serial UTF8String]);
}
@@ -596,14 +598,14 @@ void MacOsDeviceLister::USBDeviceAddedCallback(void *refcon, io_iterator_t it) {
// Because this was designed by MS, the characters are in UTF-16 (LE?).
QString str = QString::fromUtf16(reinterpret_cast<char16_t*>(data.data() + 2), (data.size() / 2) - 2);
if (str.startsWith(QLatin1String("MSFT100"))) {
if (str.startsWith("MSFT100"_L1)) {
// We got the OS descriptor!
char vendor_code = data[16];
ret = DeviceRequest(dev, kUSBIn, kUSBVendor, kUSBDevice, vendor_code, 0, 4, 256, &data);
if (!ret || data.at(0) != 0x28)
continue;
if (QString::fromLatin1(data.data() + 0x12, 3) != QLatin1String("MTP")) {
if (QString::fromLatin1(data.data() + 0x12, 3) != "MTP"_L1) {
// Not quite.
continue;
}
@@ -613,7 +615,7 @@ void MacOsDeviceLister::USBDeviceAddedCallback(void *refcon, io_iterator_t it) {
continue;
}
if (QString::fromLatin1(data.data() + 0x12, 3) != QLatin1String("MTP")) {
if (QString::fromLatin1(data.data() + 0x12, 3) != "MTP"_L1) {
// Not quite.
continue;
}
@@ -674,7 +676,7 @@ void MacOsDeviceLister::FoundMTPDevice(const MTPDevice &device, const QString &s
}
bool IsMTPSerial(const QString &serial) { return serial.startsWith(QLatin1String("MTP")); }
bool IsMTPSerial(const QString &serial) { return serial.startsWith("MTP"_L1); }
bool MacOsDeviceLister::IsCDDevice(const QString &serial) const {
return cd_devices_.contains(serial);

View File

@@ -44,6 +44,8 @@
#include "mtploader.h"
#include "mtpconnection.h"
using namespace Qt::StringLiterals;
class DeviceLister;
class DeviceManager;
@@ -187,7 +189,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(QLatin1String(""));
metadata_on_device.set_albumartist(""_L1);
songs_to_add_ << metadata_on_device;
// Remove the original if requested
@@ -226,7 +228,7 @@ bool MtpDevice::DeleteFromStorage(const DeleteJob &job) {
// Extract the ID from the song's URL
QString filename = job.metadata_.url().path();
filename.remove(QLatin1Char('/'));
filename.remove(u'/');
bool ok = false;
uint32_t id = filename.toUInt(&ok);

View File

@@ -54,6 +54,7 @@
#include "udisks2filesystem.h"
#include "udisks2job.h"
using namespace Qt::StringLiterals;
using std::make_unique;
using std::make_shared;
@@ -83,7 +84,7 @@ QVariantList Udisks2Lister::DeviceIcons(const QString &id) {
QString Udisks2Lister::DeviceManufacturer(const QString &id) {
QReadLocker locker(&device_data_lock_);
if (!device_data_.contains(id)) return QLatin1String("");
if (!device_data_.contains(id)) return ""_L1;
return device_data_.value(id).vendor;
}
@@ -91,7 +92,7 @@ QString Udisks2Lister::DeviceManufacturer(const QString &id) {
QString Udisks2Lister::DeviceModel(const QString &id) {
QReadLocker locker(&device_data_lock_);
if (!device_data_.contains(id)) return QLatin1String("");
if (!device_data_.contains(id)) return ""_L1;
return device_data_.value(id).model;
}
@@ -122,7 +123,7 @@ QVariantMap Udisks2Lister::DeviceHardwareInfo(const QString &id) {
const PartitionData data = device_data_.value(id);
result[QStringLiteral(QT_TR_NOOP("D-Bus path"))] = data.dbus_path;
result[QStringLiteral(QT_TR_NOOP("Serial number"))] = data.serial;
result[QStringLiteral(QT_TR_NOOP("Mount points"))] = data.mount_paths.join(QLatin1String(", "));
result[QStringLiteral(QT_TR_NOOP("Mount points"))] = data.mount_paths.join(", "_L1);
result[QStringLiteral(QT_TR_NOOP("Partition label"))] = data.label;
result[QStringLiteral(QT_TR_NOOP("UUID"))] = data.uuid;
@@ -133,7 +134,7 @@ QVariantMap Udisks2Lister::DeviceHardwareInfo(const QString &id) {
QString Udisks2Lister::MakeFriendlyName(const QString &id) {
QReadLocker locker(&device_data_lock_);
if (!device_data_.contains(id)) return QLatin1String("");
if (!device_data_.contains(id)) return ""_L1;
return device_data_.value(id).friendly_name;
}
@@ -226,17 +227,17 @@ void Udisks2Lister::DBusInterfaceAdded(const QDBusObjectPath &path, const Interf
for (auto interface = interfaces.constBegin(); interface != interfaces.constEnd(); ++interface) {
if (interface.key() != QLatin1String("org.freedesktop.UDisks2.Job")) continue;
if (interface.key() != "org.freedesktop.UDisks2.Job"_L1) continue;
SharedPtr<OrgFreedesktopUDisks2JobInterface> job = make_shared<OrgFreedesktopUDisks2JobInterface>(QLatin1String(kUDisks2Service), path.path(), QDBusConnection::systemBus());
if (!job->isValid()) continue;
bool is_mount_job = false;
if (job->operation() == QLatin1String("filesystem-mount")) {
if (job->operation() == "filesystem-mount"_L1) {
is_mount_job = true;
}
else if (job->operation() == QLatin1String("filesystem-unmount")) {
else if (job->operation() == "filesystem-unmount"_L1) {
is_mount_job = false;
}
else {