Formatting
This commit is contained in:
@@ -339,8 +339,9 @@ QVariant DeviceManager::data(const QModelIndex &idx, int role) const {
|
||||
return info->task_percentage_;
|
||||
|
||||
case MusicStorage::Role_Storage:
|
||||
if (!info->device_ && info->database_id_ != -1)
|
||||
if (!info->device_ && info->database_id_ != -1) {
|
||||
const_cast<DeviceManager*>(this)->Connect(info);
|
||||
}
|
||||
if (!info->device_) return QVariant();
|
||||
return QVariant::fromValue<std::shared_ptr<MusicStorage>>(info->device_);
|
||||
|
||||
@@ -452,7 +453,7 @@ void DeviceManager::PhysicalDeviceAdded(const QString &id) {
|
||||
// Do we have this device already?
|
||||
DeviceInfo *info = FindDeviceById(id);
|
||||
if (info) {
|
||||
for (int backend_index = 0 ; backend_index < info->backends_.count() ; ++backend_index) {
|
||||
for (int backend_index = 0; backend_index < info->backends_.count(); ++backend_index) {
|
||||
if (info->backends_[backend_index].unique_id_ == id) {
|
||||
info->backends_[backend_index].lister_ = lister;
|
||||
break;
|
||||
@@ -506,7 +507,7 @@ void DeviceManager::PhysicalDeviceRemoved(const QString &id) {
|
||||
|
||||
if (info->database_id_ != -1) {
|
||||
// Keep the structure around, but just "disconnect" it
|
||||
for (int backend_index = 0 ; backend_index < info->backends_.count() ; ++backend_index) {
|
||||
for (int backend_index = 0; backend_index < info->backends_.count(); ++backend_index) {
|
||||
if (info->backends_[backend_index].unique_id_ == id) {
|
||||
info->backends_[backend_index].lister_ = nullptr;
|
||||
break;
|
||||
@@ -523,7 +524,7 @@ void DeviceManager::PhysicalDeviceRemoved(const QString &id) {
|
||||
}
|
||||
else {
|
||||
// If this was the last lister for the device then remove it from the model
|
||||
for (int backend_index = 0 ; backend_index < info->backends_.count() ; ++backend_index) {
|
||||
for (int backend_index = 0; backend_index < info->backends_.count(); ++backend_index) {
|
||||
if (info->backends_[backend_index].unique_id_ == id) {
|
||||
info->backends_.removeAt(backend_index);
|
||||
break;
|
||||
@@ -817,8 +818,9 @@ void DeviceManager::SetDeviceOptions(const QModelIndex &idx, const QString &frie
|
||||
|
||||
emit dataChanged(idx, idx);
|
||||
|
||||
if (info->database_id_ != -1)
|
||||
if (info->database_id_ != -1) {
|
||||
backend_->SetDeviceOptions(info->database_id_, friendly_name, icon_name, mode, format);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -853,10 +855,12 @@ void DeviceManager::TasksChanged() {
|
||||
if (!idx.isValid()) continue;
|
||||
|
||||
DeviceInfo *info = IndexToItem(idx);
|
||||
if (task.progress_max)
|
||||
if (task.progress_max) {
|
||||
info->task_percentage_ = static_cast<int>(float(task.progress) / task.progress_max * 100);
|
||||
else
|
||||
}
|
||||
else {
|
||||
info->task_percentage_ = 0;
|
||||
}
|
||||
|
||||
emit dataChanged(idx, idx);
|
||||
finished_tasks.removeAll(idx);
|
||||
|
||||
@@ -144,8 +144,9 @@ void DeviceProperties::ModelChanged() {
|
||||
|
||||
if (!isVisible()) return;
|
||||
|
||||
if (!index_.isValid())
|
||||
if (!index_.isValid()) {
|
||||
reject(); // Device went away
|
||||
}
|
||||
else {
|
||||
UpdateHardwareInfo();
|
||||
UpdateFormats();
|
||||
|
||||
@@ -47,10 +47,12 @@ QString GioLister::DeviceInfo::unique_id() const {
|
||||
|
||||
if (!volume_root_uri.isEmpty()) return volume_root_uri;
|
||||
|
||||
if (mount_ptr)
|
||||
if (mount_ptr) {
|
||||
return QString("Gio/%1/%2/%3").arg(mount_uuid, filesystem_type).arg(filesystem_size);
|
||||
else
|
||||
}
|
||||
else {
|
||||
return QString("Gio/unmounted/%1").arg(reinterpret_cast<qulonglong>(volume_ptr.get()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -205,11 +207,13 @@ QList<QUrl> GioLister::MakeDeviceUrls(const QString &id) {
|
||||
}
|
||||
|
||||
QStringList uris;
|
||||
if (!volume_root_uri.isEmpty())
|
||||
if (!volume_root_uri.isEmpty()) {
|
||||
uris << volume_root_uri;
|
||||
}
|
||||
|
||||
if (!mount_uri.isEmpty())
|
||||
if (!mount_uri.isEmpty()) {
|
||||
uris << mount_uri;
|
||||
}
|
||||
|
||||
QList<QUrl> ret;
|
||||
|
||||
@@ -288,9 +292,10 @@ void GioLister::VolumeAdded(GVolume *volume) {
|
||||
return;
|
||||
}
|
||||
#ifdef HAVE_AUDIOCD
|
||||
if (info.volume_root_uri.startsWith("cdda"))
|
||||
if (info.volume_root_uri.startsWith("cdda")) {
|
||||
// Audio CD devices are already handled by CDDA lister
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
info.ReadDriveInfo(g_volume_get_drive(volume));
|
||||
info.ReadMountInfo(g_volume_get_mount(volume));
|
||||
@@ -331,9 +336,10 @@ void GioLister::MountAdded(GMount *mount) {
|
||||
return;
|
||||
}
|
||||
#ifdef HAVE_AUDIOCD
|
||||
if (info.volume_root_uri.startsWith("cdda"))
|
||||
if (info.volume_root_uri.startsWith("cdda")) {
|
||||
// Audio CD devices are already handled by CDDA lister
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
info.ReadMountInfo(mount);
|
||||
info.ReadDriveInfo(g_mount_get_drive(mount));
|
||||
@@ -363,10 +369,12 @@ void GioLister::MountAdded(GMount *mount) {
|
||||
devices_[info.unique_id()] = info;
|
||||
}
|
||||
|
||||
if (!old_id.isEmpty())
|
||||
emit DeviceChanged(old_id);
|
||||
else
|
||||
if (old_id.isEmpty()) {
|
||||
emit DeviceAdded(info.unique_id());
|
||||
}
|
||||
else {
|
||||
emit DeviceChanged(old_id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -386,8 +394,9 @@ void GioLister::MountChanged(GMount *mount) {
|
||||
new_info.ReadDriveInfo(g_mount_get_drive(mount));
|
||||
|
||||
// Ignore the change if the new info is useless
|
||||
if (new_info.invalid_enclosing_mount || (devices_[id].filesystem_size != 0 && new_info.filesystem_size == 0) || (!devices_[id].filesystem_type.isEmpty() && new_info.filesystem_type.isEmpty()))
|
||||
if (new_info.invalid_enclosing_mount || (devices_[id].filesystem_size != 0 && new_info.filesystem_size == 0) || (!devices_[id].filesystem_type.isEmpty() && new_info.filesystem_type.isEmpty())) {
|
||||
return;
|
||||
}
|
||||
|
||||
devices_[id] = new_info;
|
||||
}
|
||||
@@ -412,9 +421,11 @@ void GioLister::MountRemoved(GMount *mount) {
|
||||
}
|
||||
|
||||
QString GioLister::DeviceInfo::ConvertAndFree(char *str) {
|
||||
|
||||
QString ret = QString::fromUtf8(str);
|
||||
g_free(str);
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
void GioLister::DeviceInfo::ReadMountInfo(GMount *mount) {
|
||||
|
||||
@@ -315,8 +315,9 @@ void GPodDevice::StartDelete() { Start(); }
|
||||
bool GPodDevice::RemoveTrackFromITunesDb(const QString &path, const QString &relative_to) {
|
||||
|
||||
QString ipod_filename = path;
|
||||
if (!relative_to.isEmpty() && path.startsWith(relative_to))
|
||||
if (!relative_to.isEmpty() && path.startsWith(relative_to)) {
|
||||
ipod_filename.remove(0, relative_to.length() + (relative_to.endsWith('/') ? -1 : 0));
|
||||
}
|
||||
|
||||
ipod_filename.replace('/', ':');
|
||||
|
||||
@@ -337,7 +338,7 @@ bool GPodDevice::RemoveTrackFromITunesDb(const QString &path, const QString &rel
|
||||
}
|
||||
|
||||
// Remove the track from all playlists
|
||||
for (GList *playlists = db_->playlists ; playlists != nullptr ; playlists = playlists->next) {
|
||||
for (GList *playlists = db_->playlists; playlists != nullptr; playlists = playlists->next) {
|
||||
Itdb_Playlist *playlist = static_cast<Itdb_Playlist*>(playlists->data);
|
||||
|
||||
if (itdb_playlist_contains_track(playlist, track)) {
|
||||
@@ -356,11 +357,14 @@ bool GPodDevice::DeleteFromStorage(const DeleteJob &job) {
|
||||
|
||||
Q_ASSERT(db_);
|
||||
|
||||
if (!RemoveTrackFromITunesDb(job.metadata_.url().toLocalFile(), url_.path()))
|
||||
if (!RemoveTrackFromITunesDb(job.metadata_.url().toLocalFile(), url_.path())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Remove the file
|
||||
if (!QFile::remove(job.metadata_.url().toLocalFile())) return false;
|
||||
if (!QFile::remove(job.metadata_.url().toLocalFile())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Remove it from our collection model
|
||||
songs_to_remove_ << job.metadata_;
|
||||
@@ -382,4 +386,3 @@ bool GPodDevice::GetSupportedFiletypes(QList<Song::FileType> *ret) {
|
||||
*ret << Song::FileType_MPEG;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -255,8 +255,9 @@ bool MtpDevice::GetSupportedFiletypes(QList<Song::FileType> *ret, LIBMTP_mtpdevi
|
||||
uint16_t *list = nullptr;
|
||||
uint16_t length = 0;
|
||||
|
||||
if (LIBMTP_Get_Supported_Filetypes(device, &list, &length) != 0 || !list || !length)
|
||||
if (LIBMTP_Get_Supported_Filetypes(device, &list, &length) != 0 || !list || !length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < length; ++i) {
|
||||
switch (LIBMTP_filetype_t(list[i])) {
|
||||
|
||||
@@ -164,8 +164,9 @@ void Udisks2Lister::UnmountDevice(const QString &id) {
|
||||
auto eject_result = drive.Eject(QVariantMap());
|
||||
eject_result.waitForFinished();
|
||||
|
||||
if (eject_result.isError())
|
||||
if (eject_result.isError()) {
|
||||
qLog(Warning) << "Failed to eject " << id << ": " << eject_result.error();
|
||||
}
|
||||
}
|
||||
|
||||
device_data_.remove(id);
|
||||
@@ -313,7 +314,9 @@ void Udisks2Lister::JobCompleted(const bool success, const QString &message) {
|
||||
OrgFreedesktopUDisks2JobInterface *job = qobject_cast<OrgFreedesktopUDisks2JobInterface*>(sender());
|
||||
QDBusObjectPath jobPath(job->path());
|
||||
|
||||
if (!job->isValid() || !success || !mounting_jobs_.contains(jobPath)) return;
|
||||
if (!job->isValid() || !success || !mounting_jobs_.contains(jobPath)) {
|
||||
return;
|
||||
}
|
||||
|
||||
qLog(Debug) << "Pending Job Completed | Path = " << job->path() << " | Mount? = " << mounting_jobs_[jobPath].is_mount << " | Success = " << success;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user