Fix various clazy warnings

This commit is contained in:
Jonas Kvinge
2021-03-21 04:47:11 +01:00
parent 20c1c1d4be
commit 78588d8cdf
92 changed files with 337 additions and 234 deletions

View File

@@ -80,7 +80,8 @@ ConnectedDevice::~ConnectedDevice() {
void ConnectedDevice::InitBackendDirectory(const QString &mount_point, const bool first_time, const bool rewrite_path) {
if (first_time || backend_->GetAllDirectories().isEmpty()) {
QList<Directory> directories = backend_->GetAllDirectories();
if (first_time || directories.isEmpty()) {
backend_->AddDirectory(mount_point);
}
else {
@@ -91,7 +92,7 @@ void ConnectedDevice::InitBackendDirectory(const QString &mount_point, const boo
// This can be done entirely in sqlite so it's relatively fast...
// Get the directory it was mounted at last time. Devices only have one directory (the root).
Directory dir = backend_->GetAllDirectories()[0];
Directory dir = directories[0];
if (dir.path != mount_point) {
// The directory is different, commence the munging.
qLog(Info) << "Changing path from" << dir.path << "to" << mount_point;

View File

@@ -106,7 +106,7 @@ DeviceDatabaseBackend::DeviceList DeviceDatabaseBackend::GetAllDevices() {
}
}
for (Device dev : old_devices) {
for (const Device &dev : old_devices) {
RemoveDevice(dev.id_);
}

View File

@@ -793,7 +793,7 @@ void DeviceManager::RemoveFromDB(DeviceInfo *info, QModelIndex idx) {
info->friendly_name_ = info->BestBackend()->lister_->MakeFriendlyName(id);
info->LoadIcon(info->BestBackend()->lister_->DeviceIcons(id), info->friendly_name_);
dataChanged(idx, idx);
emit dataChanged(idx, idx);
}
}

View File

@@ -161,7 +161,8 @@ void DeviceProperties::UpdateHardwareInfo() {
QVariantMap info = lister->DeviceHardwareInfo(id);
// Remove empty items
for (const QString &key : info.keys()) {
QStringList keys = info.keys();
for (const QString &key : keys) {
if (info[key].isNull() || info[key].toString().isEmpty())
info.remove(key);
}
@@ -173,7 +174,8 @@ void DeviceProperties::UpdateHardwareInfo() {
int row = 0;
AddHardwareInfo(row++, tr("Model"), lister->DeviceModel(id));
AddHardwareInfo(row++, tr("Manufacturer"), lister->DeviceManufacturer(id));
for (const QString &key : info.keys()) {
keys = info.keys();
for (const QString &key : keys) {
AddHardwareInfo(row++, tr(key.toLatin1()), info[key].toString());
}
@@ -202,7 +204,6 @@ void DeviceProperties::UpdateHardwareInfo() {
void DeviceProperties::UpdateFormats() {
QString id = index_.data(DeviceManager::Role_UniqueId).toString();
DeviceLister *lister = manager_->GetLister(index_);
std::shared_ptr<ConnectedDevice> device = manager_->GetConnectedDevice(index_);

View File

@@ -408,16 +408,17 @@ void DeviceView::OpenInNewPlaylist() {
void DeviceView::Delete() {
if (selectedIndexes().isEmpty()) return;
QModelIndexList selected_indexes = selectedIndexes();
if (selected_indexes.isEmpty()) return;
// Take the device of the first selected item
QModelIndex device_index = FindParentDevice(selectedIndexes()[0]);
QModelIndex device_index = FindParentDevice(selected_indexes[0]);
if (!device_index.isValid()) return;
if (QMessageBox::question(this, tr("Delete files"),
tr("These files will be deleted from the device, are you sure you want to continue?"),
QMessageBox::Yes, QMessageBox::Cancel) != QMessageBox::Yes)
if (QMessageBox::question(this, tr("Delete files"), tr("These files will be deleted from the device, are you sure you want to continue?"), QMessageBox::Yes, QMessageBox::Cancel) != QMessageBox::Yes) {
return;
}
std::shared_ptr<MusicStorage> storage = device_index.data(MusicStorage::Role_Storage).value<std::shared_ptr<MusicStorage>>();

View File

@@ -70,6 +70,9 @@ class DeviceView : public AutoExpandingTreeView {
void SetApplication(Application *app);
// AutoExpandingTreeView
bool CanRecursivelyExpand(const QModelIndex &idx) const override;
protected:
void contextMenuEvent(QContextMenuEvent*) override;
void mouseDoubleClickEvent(QMouseEvent *e) override;
@@ -93,9 +96,6 @@ class DeviceView : public AutoExpandingTreeView {
void DeleteFinished(const SongList &songs_with_errors);
// AutoExpandingTreeView
bool CanRecursivelyExpand(const QModelIndex &idx) const override;
private:
QModelIndex MapToDevice(const QModelIndex &merged_model_index) const;
QModelIndex MapToCollection(const QModelIndex &merged_model_index) const;

View File

@@ -348,7 +348,8 @@ void GioLister::MountAdded(GMount *mount) {
QMutexLocker l(&mutex_);
// The volume might already exist - either mounted or unmounted.
for (const QString &id : devices_.keys()) {
QStringList ids = devices_.keys();
for (const QString &id : ids) {
if (devices_[id].volume_ptr == info.volume_ptr) {
old_id = id;
break;

View File

@@ -166,7 +166,7 @@ void Udisks2Lister::UnmountDevice(const QString &id) {
}
device_data_.remove(id);
DeviceRemoved(id);
emit DeviceRemoved(id);
}
}
@@ -190,7 +190,8 @@ bool Udisks2Lister::Init() {
return false;
}
for (const QDBusObjectPath &path : reply.value().keys()) {
QList<QDBusObjectPath> paths = reply.value().keys();
for (const QDBusObjectPath &path : paths) {
auto partition_data = ReadPartitionData(path);
if (!partition_data.dbus_path.isEmpty()) {
@@ -199,7 +200,8 @@ bool Udisks2Lister::Init() {
}
}
for (const auto &id : device_data_.keys()) {
QStringList ids = device_data_.keys();
for (const QString &id : ids) {
emit DeviceAdded(id);
}
@@ -269,7 +271,7 @@ void Udisks2Lister::RemoveDevice(const QDBusObjectPath &device_path) {
QWriteLocker locker(&device_data_lock_);
QString id;
for (const auto &data : device_data_) {
for (const auto &data : qAsConst(device_data_)) {
if (data.dbus_path == device_path.path()) {
id = data.unique_id();
break;
@@ -280,7 +282,8 @@ void Udisks2Lister::RemoveDevice(const QDBusObjectPath &device_path) {
qLog(Debug) << "UDisks2 device removed: " << device_path.path();
device_data_.remove(id);
DeviceRemoved(id);
emit DeviceRemoved(id);
}
@@ -325,7 +328,8 @@ void Udisks2Lister::HandleFinishedMountJob(const Udisks2Lister::PartitionData &p
qLog(Debug) << "UDisks2 mount job finished: Drive = " << partition_data.dbus_drive_path << " | Partition = " << partition_data.dbus_path;
QWriteLocker locker(&device_data_lock_);
device_data_[partition_data.unique_id()] = partition_data;
DeviceAdded(partition_data.unique_id());
emit DeviceAdded(partition_data.unique_id());
}
@@ -345,7 +349,7 @@ void Udisks2Lister::HandleFinishedUnmountJob(const Udisks2Lister::PartitionData
if (!id.isEmpty()) {
qLog(Debug) << "Partition " << partition_data.dbus_path << " has no more mount points, removing it from device list";
device_data_.remove(id);
DeviceRemoved(id);
emit DeviceRemoved(id);
}
}