More const detach fixes
This commit is contained in:
parent
be09011bb7
commit
7ebcc73a49
@ -165,7 +165,7 @@ static void MessageHandler(QtMsgType type, const QMessageLogContext&, const QStr
|
||||
d << line.toLocal8Bit().constData();
|
||||
if (d.buf_) {
|
||||
d.buf_->close();
|
||||
fprintf(type == QtCriticalMsg || type == QtFatalMsg ? stderr : stdout, "%s\n", d.buf_->buffer().data());
|
||||
fprintf(type == QtCriticalMsg || type == QtFatalMsg ? stderr : stdout, "%s\n", d.buf_->buffer().constData());
|
||||
fflush(type == QtCriticalMsg || type == QtFatalMsg ? stderr : stdout);
|
||||
}
|
||||
}
|
||||
|
@ -149,7 +149,7 @@ void AnalyzerContainer::DisableAnalyzer() {
|
||||
|
||||
void AnalyzerContainer::ChangeAnalyzer(const int id) {
|
||||
|
||||
QObject *instance = analyzer_types_[id]->newInstance(Q_ARG(QWidget*, this));
|
||||
QObject *instance = analyzer_types_.at(id)->newInstance(Q_ARG(QWidget*, this));
|
||||
|
||||
if (!instance) {
|
||||
qLog(Warning) << "Couldn't initialize a new" << analyzer_types_[id]->className();
|
||||
@ -200,22 +200,25 @@ void AnalyzerContainer::Load() {
|
||||
for (int i = 0; i < analyzer_types_.count(); ++i) {
|
||||
if (type == QString::fromLatin1(analyzer_types_[i]->className())) {
|
||||
ChangeAnalyzer(i);
|
||||
actions_[i]->setChecked(true);
|
||||
QAction *action = actions_.value(i);
|
||||
action->setChecked(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!current_analyzer_) {
|
||||
ChangeAnalyzer(0);
|
||||
actions_[0]->setChecked(true);
|
||||
QAction *action = actions_.value(0);
|
||||
action->setChecked(true);
|
||||
}
|
||||
}
|
||||
|
||||
// Framerate
|
||||
QList<QAction*> actions = group_framerate_->actions();
|
||||
const QList<QAction*> actions = group_framerate_->actions();
|
||||
for (int i = 0; i < framerate_list_.count(); ++i) {
|
||||
if (current_framerate_ == framerate_list_[i]) {
|
||||
if (current_framerate_ == framerate_list_.value(i)) {
|
||||
ChangeFramerate(current_framerate_);
|
||||
actions[i]->setChecked(true);
|
||||
QAction *action = actions[i];
|
||||
action->setChecked(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -167,11 +167,12 @@ void BlockAnalyzer::analyze(QPainter &p, const Scope &s, const bool new_frame) {
|
||||
|
||||
for (int x = 0, y = 0; x < static_cast<int>(scope_.size()); ++x) {
|
||||
// determine y
|
||||
for (y = 0; scope_[x] < yscale_[y]; ++y);
|
||||
for (y = 0; scope_[x] < yscale_.at(y); ++y);
|
||||
|
||||
// This is opposite to what you'd think, higher than y means the bar is lower than y (physically)
|
||||
if (static_cast<double>(y) > store_[x]) {
|
||||
y = static_cast<int>(store_[x] += step_);
|
||||
if (static_cast<double>(y) > store_.value(x)) {
|
||||
store_[x] += step_;
|
||||
y = static_cast<int>(store_.value(x));
|
||||
}
|
||||
else {
|
||||
store_[x] = y;
|
||||
@ -179,18 +180,19 @@ void BlockAnalyzer::analyze(QPainter &p, const Scope &s, const bool new_frame) {
|
||||
|
||||
// If y is lower than fade_pos_, then the bar has exceeded the height of the fadeout
|
||||
// if the fadeout is quite faded now, then display the new one
|
||||
if (y <= fade_pos_[x] /*|| fade_intensity_[x] < kFadeSize / 3*/) {
|
||||
if (y <= fade_pos_.at(x) /*|| fade_intensity_[x] < kFadeSize / 3*/) {
|
||||
fade_pos_[x] = y;
|
||||
fade_intensity_[x] = kFadeSize;
|
||||
}
|
||||
|
||||
if (fade_intensity_[x] > 0) {
|
||||
const int offset = --fade_intensity_[x];
|
||||
const int y2 = y_ + (fade_pos_[x] * (kHeight + 1));
|
||||
if (fade_intensity_.at(x) > 0) {
|
||||
--fade_intensity_[x];
|
||||
const int offset = fade_intensity_.value(x);
|
||||
const int y2 = y_ + (fade_pos_.value(x) * (kHeight + 1));
|
||||
canvas_painter.drawPixmap(x * (kWidth + 1), y2, fade_bars_[offset], 0, 0, kWidth, height() - y2);
|
||||
}
|
||||
|
||||
if (fade_intensity_[x] == 0) fade_pos_[x] = rows_;
|
||||
if (fade_intensity_.at(x) == 0) fade_pos_[x] = rows_;
|
||||
|
||||
// REMEMBER: y is a number from 0 to rows_, 0 means all blocks are glowing, rows_ means none are
|
||||
canvas_painter.drawPixmap(x * (kWidth + 1), y * (kHeight + 1) + y_, *bar(), 0, y * (kHeight + 1), bar()->width(), bar()->height());
|
||||
|
@ -158,7 +158,7 @@ void CollectionFilterWidget::Init(CollectionModel *model, CollectionFilter *filt
|
||||
|
||||
const QList<QAction*> actions = filter_max_ages_.keys();
|
||||
for (QAction *action : actions) {
|
||||
int filter_max_age = filter_max_ages_[action];
|
||||
const int filter_max_age = filter_max_ages_.value(action);
|
||||
QObject::connect(action, &QAction::triggered, this, [this, filter_max_age]() { model_->SetFilterMaxAge(filter_max_age); } );
|
||||
}
|
||||
|
||||
|
@ -514,7 +514,7 @@ void CollectionModel::AddReAddOrUpdateSongsInternal(const SongList &songs) {
|
||||
songs_added << new_song;
|
||||
continue;
|
||||
}
|
||||
const Song &old_song = song_nodes_[new_song.id()]->metadata;
|
||||
const Song old_song = song_nodes_.value(new_song.id())->metadata;
|
||||
bool container_key_changed = false;
|
||||
bool has_unique_album_identifier_1 = false;
|
||||
bool has_unique_album_identifier_2 = false;
|
||||
@ -606,7 +606,7 @@ void CollectionModel::UpdateSongsInternal(const SongList &songs) {
|
||||
qLog(Error) << "Song does not exist in model" << new_song.id() << new_song.PrettyTitleWithArtist();
|
||||
continue;
|
||||
}
|
||||
CollectionItem *item = song_nodes_[new_song.id()];
|
||||
CollectionItem *item = song_nodes_.value(new_song.id());
|
||||
const Song &old_song = item->metadata;
|
||||
const bool song_title_data_changed = IsSongTitleDataChanged(old_song, new_song);
|
||||
const bool art_changed = !old_song.IsArtEqual(new_song);
|
||||
@ -648,7 +648,7 @@ void CollectionModel::RemoveSongsInternal(const SongList &songs) {
|
||||
for (const Song &song : songs) {
|
||||
|
||||
if (song_nodes_.contains(song.id())) {
|
||||
CollectionItem *node = song_nodes_[song.id()];
|
||||
CollectionItem *node = song_nodes_.value(song.id());
|
||||
|
||||
if (node->parent != root_) parents << node->parent;
|
||||
|
||||
@ -706,7 +706,7 @@ void CollectionModel::RemoveSongsInternal(const SongList &songs) {
|
||||
}
|
||||
|
||||
// Remove the divider
|
||||
int row = divider_nodes_[divider_key]->row;
|
||||
const int row = divider_nodes_.value(divider_key)->row;
|
||||
beginRemoveRows(ItemToIndex(root_), row, row);
|
||||
root_->Delete(row);
|
||||
endRemoveRows();
|
||||
|
@ -611,7 +611,7 @@ void CollectionView::SearchForThis() {
|
||||
CollectionItem *item = app_->collection_model()->IndexToItem(index);
|
||||
const CollectionModel::GroupBy group_by = app_->collection_model()->GetGroupBy()[item->container_level];
|
||||
while (!item->children.isEmpty()) {
|
||||
item = item->children.first();
|
||||
item = item->children.constFirst();
|
||||
}
|
||||
|
||||
switch (group_by) {
|
||||
|
@ -1131,7 +1131,7 @@ void CollectionWatcher::RescanPathsNow() {
|
||||
if (stop_or_abort_requested()) break;
|
||||
ScanTransaction transaction(this, dir, false, false, mark_songs_unavailable_);
|
||||
|
||||
const QStringList paths = rescan_queue_[dir];
|
||||
const QStringList paths = rescan_queue_.value(dir);
|
||||
|
||||
QMap<QString, quint64> subdir_files_count;
|
||||
for (const QString &path : paths) {
|
||||
|
@ -161,7 +161,7 @@ QSqlDatabase Database::Connect() {
|
||||
// Attach external databases
|
||||
QStringList keys = attached_databases_.keys();
|
||||
for (const QString &key : std::as_const(keys)) {
|
||||
QString filename = attached_databases_[key].filename_;
|
||||
QString filename = attached_databases_.value(key).filename_;
|
||||
|
||||
if (!injected_database_name_.isNull()) filename = injected_database_name_;
|
||||
|
||||
@ -182,7 +182,7 @@ QSqlDatabase Database::Connect() {
|
||||
// We might have to initialize the schema in some attached databases now, if they were deleted and don't match up with the main schema version.
|
||||
keys = attached_databases_.keys();
|
||||
for (const QString &key : std::as_const(keys)) {
|
||||
if (attached_databases_[key].is_temporary_ && attached_databases_[key].schema_.isEmpty()) {
|
||||
if (attached_databases_.value(key).is_temporary_ && attached_databases_.value(key).schema_.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
// Find out if there are any tables in this database
|
||||
@ -258,7 +258,7 @@ void Database::RecreateAttachedDb(const QString &database_name) {
|
||||
return;
|
||||
}
|
||||
|
||||
const QString filename = attached_databases_[database_name].filename_;
|
||||
const QString filename = attached_databases_.value(database_name).filename_;
|
||||
|
||||
QMutexLocker l(&mutex_);
|
||||
{
|
||||
|
@ -116,7 +116,7 @@ void DeleteFiles::ProcessSomeFiles() {
|
||||
for (; progress_ < n; ++progress_) {
|
||||
task_manager_->SetTaskProgress(task_id_, progress_, songs_.count());
|
||||
|
||||
const Song &song = songs_[progress_];
|
||||
const Song song = songs_.value(progress_);
|
||||
|
||||
MusicStorage::DeleteJob job;
|
||||
job.metadata_ = song;
|
||||
|
@ -535,8 +535,8 @@ void MergedProxyModel::LayoutChanged() {
|
||||
for (QAbstractItemModel *model : models) {
|
||||
if (!old_merge_points_.contains(model)) continue;
|
||||
|
||||
const int old_row = old_merge_points_[model].row();
|
||||
const int new_row = merge_points_[model].row();
|
||||
const int old_row = old_merge_points_.value(model).row();
|
||||
const int new_row = merge_points_.value(model).row();
|
||||
|
||||
if (old_row != new_row) {
|
||||
beginResetModel();
|
||||
|
@ -618,7 +618,8 @@ void Player::UnPause() {
|
||||
if (time >= 30) { // Stream URL might be expired.
|
||||
qLog(Debug) << "Re-requesting stream URL for" << song.url();
|
||||
play_offset_nanosec_ = engine_->position_nanosec();
|
||||
HandleLoadResult(url_handlers_[song.url().scheme()]->StartLoading(song.url()));
|
||||
UrlHandler *url_handler = url_handlers_.value(song.url().scheme());
|
||||
HandleLoadResult(url_handler->StartLoading(song.url()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -826,7 +827,8 @@ void Player::PlayAt(const int index, const bool pause, const quint64 offset_nano
|
||||
pause_ = pause;
|
||||
stream_change_type_ = change;
|
||||
autoscroll_ = autoscroll;
|
||||
HandleLoadResult(url_handlers_[url.scheme()]->StartLoading(url));
|
||||
UrlHandler *url_handler = url_handlers_.value(url.scheme());
|
||||
HandleLoadResult(url_handler->StartLoading(url));
|
||||
}
|
||||
else {
|
||||
qLog(Debug) << "Playing song" << current_item_->Metadata().title() << url << "position" << offset_nanosec;
|
||||
@ -1003,7 +1005,8 @@ void Player::TrackAboutToEnd() {
|
||||
if (url_handlers_.contains(url.scheme())) {
|
||||
if (loading_async_.contains(url)) return;
|
||||
autoscroll_ = Playlist::AutoScroll::Maybe;
|
||||
UrlHandler::LoadResult result = url_handlers_[url.scheme()]->StartLoading(url);
|
||||
UrlHandler *url_handler = url_handlers_.value(url.scheme());
|
||||
const UrlHandler::LoadResult result = url_handler->StartLoading(url);
|
||||
switch (result.type_) {
|
||||
case UrlHandler::LoadResult::Type::Error:
|
||||
emit Error(result.error_);
|
||||
|
@ -70,8 +70,7 @@ void TaskManager::SetTaskBlocksCollectionScans(const int id) {
|
||||
QMutexLocker l(&mutex_);
|
||||
if (!tasks_.contains(id)) return;
|
||||
|
||||
Task &t = tasks_[id];
|
||||
t.blocks_collection_scans = true;
|
||||
tasks_[id].blocks_collection_scans = true;
|
||||
}
|
||||
|
||||
emit TasksChanged();
|
||||
@ -85,9 +84,10 @@ void TaskManager::SetTaskProgress(const int id, const quint64 progress, const qu
|
||||
QMutexLocker l(&mutex_);
|
||||
if (!tasks_.contains(id)) return;
|
||||
|
||||
Task &t = tasks_[id];
|
||||
Task t = tasks_.value(id);
|
||||
t.progress = progress;
|
||||
if (max > 0) t.progress_max = max;
|
||||
tasks_[id] = t;
|
||||
}
|
||||
|
||||
emit TasksChanged();
|
||||
@ -99,9 +99,10 @@ void TaskManager::IncreaseTaskProgress(const int id, const quint64 progress, con
|
||||
QMutexLocker l(&mutex_);
|
||||
if (!tasks_.contains(id)) return;
|
||||
|
||||
Task &t = tasks_[id];
|
||||
Task t = tasks_.value(id);
|
||||
t.progress += progress;
|
||||
if (max > 0) t.progress_max = max;
|
||||
tasks_[id] = t;
|
||||
}
|
||||
|
||||
emit TasksChanged();
|
||||
@ -116,7 +117,7 @@ void TaskManager::SetTaskFinished(const int id) {
|
||||
QMutexLocker l(&mutex_);
|
||||
if (!tasks_.contains(id)) return;
|
||||
|
||||
if (tasks_[id].blocks_collection_scans) {
|
||||
if (tasks_.value(id).blocks_collection_scans) {
|
||||
resume_collection_watchers = true;
|
||||
QList<Task> tasks = tasks_.values();
|
||||
|
||||
@ -139,7 +140,7 @@ quint64 TaskManager::GetTaskProgress(int id) {
|
||||
{
|
||||
QMutexLocker l(&mutex_);
|
||||
if (!tasks_.contains(id)) return 0;
|
||||
return tasks_[id].progress;
|
||||
return tasks_.value(id).progress;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -134,7 +134,7 @@ void AlbumCoverFetcherSearch::Start(SharedPtr<CoverProviders> cover_providers) {
|
||||
void AlbumCoverFetcherSearch::ProviderSearchResults(const int id, const CoverProviderSearchResults &results) {
|
||||
|
||||
if (!pending_requests_.contains(id)) return;
|
||||
CoverProvider *provider = pending_requests_[id];
|
||||
CoverProvider *provider = pending_requests_.value(id);
|
||||
ProviderSearchResults(provider, results);
|
||||
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ void AlbumCoverLoader::CancelTasks(const QSet<quint64> &ids) {
|
||||
|
||||
QMutexLocker l(&mutex_load_image_async_);
|
||||
for (QQueue<TaskPtr>::iterator it = tasks_.begin(); it != tasks_.end();) {
|
||||
TaskPtr task = *it;
|
||||
const TaskPtr task = *it;
|
||||
if (ids.contains(task->id)) {
|
||||
it = tasks_.erase(it);
|
||||
}
|
||||
|
@ -621,11 +621,11 @@ bool AlbumCoverManager::eventFilter(QObject *obj, QEvent *e) {
|
||||
}
|
||||
|
||||
Song AlbumCoverManager::GetSingleSelectionAsSong() {
|
||||
return context_menu_items_.size() != 1 ? Song() : AlbumItemAsSong(context_menu_items_[0]);
|
||||
return context_menu_items_.size() != 1 ? Song() : AlbumItemAsSong(context_menu_items_.value(0));
|
||||
}
|
||||
|
||||
Song AlbumCoverManager::GetFirstSelectedAsSong() {
|
||||
return context_menu_items_.isEmpty() ? Song() : AlbumItemAsSong(context_menu_items_[0]);
|
||||
return context_menu_items_.isEmpty() ? Song() : AlbumItemAsSong(context_menu_items_.value(0));
|
||||
}
|
||||
|
||||
Song AlbumCoverManager::AlbumItemAsSong(AlbumItem *album_item) {
|
||||
@ -646,7 +646,7 @@ Song AlbumCoverManager::AlbumItemAsSong(AlbumItem *album_item) {
|
||||
result.set_album(album_item->data(Role_Album).toString());
|
||||
|
||||
result.set_filetype(static_cast<Song::FileType>(album_item->data(Role_Filetype).toInt()));
|
||||
result.set_url(album_item->urls.first());
|
||||
result.set_url(album_item->urls.constFirst());
|
||||
result.set_cue_path(album_item->data(Role_CuePath).toString());
|
||||
|
||||
result.set_art_embedded(album_item->data(Role_ArtEmbedded).toBool());
|
||||
@ -1085,7 +1085,7 @@ void AlbumCoverManager::LoadAlbumCoverAsync(AlbumItem *album_item) {
|
||||
cover_options.types = cover_types_;
|
||||
cover_options.desired_scaled_size = QSize(kThumbnailSize, kThumbnailSize);
|
||||
cover_options.device_pixel_ratio = devicePixelRatioF();
|
||||
quint64 cover_load_id = app_->album_cover_loader()->LoadImageAsync(cover_options, album_item->data(Role_ArtEmbedded).toBool(), album_item->data(Role_ArtAutomatic).toUrl(), album_item->data(Role_ArtManual).toUrl(), album_item->data(Role_ArtUnset).toBool(), album_item->urls.first());
|
||||
quint64 cover_load_id = app_->album_cover_loader()->LoadImageAsync(cover_options, album_item->data(Role_ArtEmbedded).toBool(), album_item->data(Role_ArtAutomatic).toUrl(), album_item->data(Role_ArtManual).toUrl(), album_item->data(Role_ArtUnset).toBool(), album_item->urls.constFirst());
|
||||
cover_loading_tasks_.insert(cover_load_id, album_item);
|
||||
|
||||
}
|
||||
|
@ -830,7 +830,7 @@ void DeviceManager::DeviceTaskStarted(const int id) {
|
||||
if (!device) return;
|
||||
|
||||
for (int i = 0; i < devices_.count(); ++i) {
|
||||
DeviceInfo *info = devices_[i];
|
||||
DeviceInfo *info = devices_.value(i);
|
||||
if (info->device_ && &*info->device_ == device) {
|
||||
QModelIndex index = ItemToIndex(info);
|
||||
if (!index.isValid()) continue;
|
||||
@ -851,7 +851,7 @@ void DeviceManager::TasksChanged() {
|
||||
for (const TaskManager::Task &task : tasks) {
|
||||
if (!active_tasks_.contains(task.id)) continue;
|
||||
|
||||
const QPersistentModelIndex idx = active_tasks_[task.id];
|
||||
const QPersistentModelIndex idx = active_tasks_.value(task.id);
|
||||
if (!idx.isValid()) continue;
|
||||
|
||||
DeviceInfo *info = IndexToItem(idx);
|
||||
|
@ -144,14 +144,14 @@ QVariantList GioLister::DeviceIcons(const QString &id) {
|
||||
QMutexLocker l(&mutex_);
|
||||
if (!devices_.contains(id)) return ret;
|
||||
|
||||
const DeviceInfo &info = devices_[id];
|
||||
const DeviceInfo device_info = devices_.value(id);
|
||||
|
||||
if (info.mount_ptr) {
|
||||
ret << DeviceLister::GuessIconForPath(info.mount_path);
|
||||
ret << info.mount_icon_names;
|
||||
if (device_info.mount_ptr) {
|
||||
ret << DeviceLister::GuessIconForPath(device_info.mount_path);
|
||||
ret << device_info.mount_icon_names;
|
||||
}
|
||||
|
||||
ret << DeviceLister::GuessIconForModel(QString(), info.mount_name);
|
||||
ret << DeviceLister::GuessIconForModel(QString(), device_info.mount_name);
|
||||
|
||||
return ret;
|
||||
|
||||
@ -163,9 +163,9 @@ QString GioLister::DeviceModel(const QString &id) {
|
||||
|
||||
QMutexLocker l(&mutex_);
|
||||
if (!devices_.contains(id)) return QString();
|
||||
const DeviceInfo &info = devices_[id];
|
||||
const DeviceInfo device_info = devices_.value(id);
|
||||
|
||||
return info.drive_name.isEmpty() ? info.volume_name : info.drive_name;
|
||||
return device_info.drive_name.isEmpty() ? device_info.volume_name : device_info.drive_name;
|
||||
|
||||
}
|
||||
|
||||
@ -187,7 +187,7 @@ QVariantMap GioLister::DeviceHardwareInfo(const QString &id) {
|
||||
|
||||
QMutexLocker l(&mutex_);
|
||||
if (!devices_.contains(id)) return ret;
|
||||
const DeviceInfo &info = devices_[id];
|
||||
const DeviceInfo info = devices_.value(id);
|
||||
|
||||
ret[QStringLiteral(QT_TR_NOOP("Mount point"))] = info.mount_path;
|
||||
ret[QStringLiteral(QT_TR_NOOP("Device"))] = info.volume_unix_device;
|
||||
@ -399,7 +399,7 @@ 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_.value(id).filesystem_size != 0 && new_info.filesystem_size == 0) || (!devices_[id].filesystem_type.isEmpty() && new_info.filesystem_type.isEmpty())) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -577,11 +577,9 @@ void GioLister::UpdateDeviceFreeSpace(const QString &id) {
|
||||
|
||||
{
|
||||
QMutexLocker l(&mutex_);
|
||||
if (!devices_.contains(id) || !devices_[id].mount_ptr || devices_[id].volume_root_uri.startsWith(QLatin1String("mtp://"))) return;
|
||||
if (!devices_.contains(id) || !devices_[id].mount_ptr || devices_.value(id).volume_root_uri.startsWith(QLatin1String("mtp://"))) return;
|
||||
|
||||
DeviceInfo &device_info = devices_[id];
|
||||
|
||||
GFile *root = g_mount_get_root(device_info.mount_ptr);
|
||||
GFile *root = g_mount_get_root(devices_.value(id).mount_ptr);
|
||||
|
||||
GError *error = nullptr;
|
||||
GFileInfo *info = g_file_query_filesystem_info(root, G_FILE_ATTRIBUTE_FILESYSTEM_FREE, nullptr, &error);
|
||||
@ -590,7 +588,7 @@ void GioLister::UpdateDeviceFreeSpace(const QString &id) {
|
||||
g_error_free(error);
|
||||
}
|
||||
else {
|
||||
device_info.filesystem_free = g_file_info_get_attribute_uint64(info, G_FILE_ATTRIBUTE_FILESYSTEM_FREE);
|
||||
devices_[id].filesystem_free = g_file_info_get_attribute_uint64(info, G_FILE_ATTRIBUTE_FILESYSTEM_FREE);
|
||||
g_object_unref(info);
|
||||
}
|
||||
|
||||
@ -616,14 +614,14 @@ void GioLister::MountDevice(const QString &id, const int request_id) {
|
||||
return;
|
||||
}
|
||||
|
||||
const DeviceInfo &info = devices_[id];
|
||||
if (info.mount_ptr) {
|
||||
const DeviceInfo device_info = devices_.value(id);
|
||||
if (device_info.mount_ptr) {
|
||||
// Already mounted
|
||||
emit DeviceMounted(id, request_id, true);
|
||||
return;
|
||||
}
|
||||
|
||||
g_volume_mount(info.volume_ptr, G_MOUNT_MOUNT_NONE, nullptr, nullptr, VolumeMountFinished, nullptr);
|
||||
g_volume_mount(device_info.volume_ptr, G_MOUNT_MOUNT_NONE, nullptr, nullptr, VolumeMountFinished, nullptr);
|
||||
emit DeviceMounted(id, request_id, true);
|
||||
|
||||
}
|
||||
@ -631,25 +629,25 @@ 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(QLatin1String("mtp://"))) return;
|
||||
if (!devices_.contains(id) || !devices_[id].mount_ptr || devices_.value(id).volume_root_uri.startsWith(QLatin1String("mtp://"))) return;
|
||||
|
||||
const DeviceInfo &info = devices_[id];
|
||||
const DeviceInfo device_info = devices_.value(id);
|
||||
|
||||
if (!info.mount_ptr) return;
|
||||
if (!device_info.mount_ptr) return;
|
||||
|
||||
if (info.volume_ptr) {
|
||||
if (g_volume_can_eject(info.volume_ptr)) {
|
||||
g_volume_eject_with_operation(info.volume_ptr, G_MOUNT_UNMOUNT_NONE, nullptr, nullptr, reinterpret_cast<GAsyncReadyCallback>(VolumeEjectFinished), nullptr);
|
||||
if (device_info.volume_ptr) {
|
||||
if (g_volume_can_eject(device_info.volume_ptr)) {
|
||||
g_volume_eject_with_operation(device_info.volume_ptr, G_MOUNT_UNMOUNT_NONE, nullptr, nullptr, reinterpret_cast<GAsyncReadyCallback>(VolumeEjectFinished), nullptr);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else return;
|
||||
|
||||
if (g_mount_can_eject(info.mount_ptr)) {
|
||||
g_mount_eject_with_operation(info.mount_ptr, G_MOUNT_UNMOUNT_NONE, nullptr, nullptr, reinterpret_cast<GAsyncReadyCallback>(MountEjectFinished), nullptr);
|
||||
if (g_mount_can_eject(device_info.mount_ptr)) {
|
||||
g_mount_eject_with_operation(device_info.mount_ptr, G_MOUNT_UNMOUNT_NONE, nullptr, nullptr, reinterpret_cast<GAsyncReadyCallback>(MountEjectFinished), nullptr);
|
||||
}
|
||||
else if (g_mount_can_unmount(info.mount_ptr)) {
|
||||
g_mount_unmount_with_operation(info.mount_ptr, G_MOUNT_UNMOUNT_NONE, nullptr, nullptr, reinterpret_cast<GAsyncReadyCallback>(MountUnmountFinished), nullptr);
|
||||
else if (g_mount_can_unmount(device_info.mount_ptr)) {
|
||||
g_mount_unmount_with_operation(device_info.mount_ptr, G_MOUNT_UNMOUNT_NONE, nullptr, nullptr, reinterpret_cast<GAsyncReadyCallback>(MountUnmountFinished), nullptr);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -148,7 +148,7 @@ T GioLister::LockAndGetDeviceInfo(const QString &id, T DeviceInfo::*field) {
|
||||
QMutexLocker l(&mutex_);
|
||||
if (!devices_.contains(id)) return T();
|
||||
|
||||
return devices_[id].*field;
|
||||
return devices_.value(id).*field;
|
||||
}
|
||||
|
||||
#endif // GIOLISTER_H
|
||||
|
@ -74,7 +74,7 @@ QVariantList Udisks2Lister::DeviceIcons(const QString &id) {
|
||||
|
||||
QReadLocker locker(&device_data_lock_);
|
||||
if (!device_data_.contains(id)) return QVariantList();
|
||||
QString path = device_data_[id].mount_paths.at(0);
|
||||
const QString path = device_data_.value(id).mount_paths.value(0);
|
||||
|
||||
return QVariantList() << GuessIconForPath(path) << GuessIconForModel(DeviceManufacturer(id), DeviceModel(id));
|
||||
|
||||
@ -84,7 +84,7 @@ QString Udisks2Lister::DeviceManufacturer(const QString &id) {
|
||||
|
||||
QReadLocker locker(&device_data_lock_);
|
||||
if (!device_data_.contains(id)) return QLatin1String("");
|
||||
return device_data_[id].vendor;
|
||||
return device_data_.value(id).vendor;
|
||||
|
||||
}
|
||||
|
||||
@ -92,7 +92,7 @@ QString Udisks2Lister::DeviceModel(const QString &id) {
|
||||
|
||||
QReadLocker locker(&device_data_lock_);
|
||||
if (!device_data_.contains(id)) return QLatin1String("");
|
||||
return device_data_[id].model;
|
||||
return device_data_.value(id).model;
|
||||
|
||||
}
|
||||
|
||||
@ -100,7 +100,7 @@ quint64 Udisks2Lister::DeviceCapacity(const QString &id) {
|
||||
|
||||
QReadLocker locker(&device_data_lock_);
|
||||
if (!device_data_.contains(id)) return 0;
|
||||
return device_data_[id].capacity;
|
||||
return device_data_.value(id).capacity;
|
||||
|
||||
}
|
||||
|
||||
@ -108,7 +108,7 @@ quint64 Udisks2Lister::DeviceFreeSpace(const QString &id) {
|
||||
|
||||
QReadLocker locker(&device_data_lock_);
|
||||
if (!device_data_.contains(id)) return 0;
|
||||
return device_data_[id].free_space;
|
||||
return device_data_.value(id).free_space;
|
||||
|
||||
}
|
||||
|
||||
@ -119,7 +119,7 @@ QVariantMap Udisks2Lister::DeviceHardwareInfo(const QString &id) {
|
||||
|
||||
QVariantMap result;
|
||||
|
||||
const PartitionData &data = device_data_[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(", "));
|
||||
@ -134,7 +134,7 @@ QString Udisks2Lister::MakeFriendlyName(const QString &id) {
|
||||
|
||||
QReadLocker locker(&device_data_lock_);
|
||||
if (!device_data_.contains(id)) return QLatin1String("");
|
||||
return device_data_[id].friendly_name;
|
||||
return device_data_.value(id).friendly_name;
|
||||
|
||||
}
|
||||
|
||||
@ -153,7 +153,7 @@ void Udisks2Lister::UnmountDevice(const QString &id) {
|
||||
QReadLocker locker(&device_data_lock_);
|
||||
if (!device_data_.contains(id)) return;
|
||||
|
||||
OrgFreedesktopUDisks2FilesystemInterface filesystem(QLatin1String(kUDisks2Service), device_data_[id].dbus_path, QDBusConnection::systemBus());
|
||||
OrgFreedesktopUDisks2FilesystemInterface filesystem(QLatin1String(kUDisks2Service), device_data_.value(id).dbus_path, QDBusConnection::systemBus());
|
||||
|
||||
if (filesystem.isValid()) {
|
||||
auto unmount_result = filesystem.Unmount(QVariantMap());
|
||||
@ -164,7 +164,7 @@ void Udisks2Lister::UnmountDevice(const QString &id) {
|
||||
return;
|
||||
}
|
||||
|
||||
OrgFreedesktopUDisks2DriveInterface drive(QLatin1String(kUDisks2Service), device_data_[id].dbus_drive_path, QDBusConnection::systemBus());
|
||||
OrgFreedesktopUDisks2DriveInterface drive(QLatin1String(kUDisks2Service), device_data_.value(id).dbus_drive_path, QDBusConnection::systemBus());
|
||||
|
||||
if (drive.isValid()) {
|
||||
auto eject_result = drive.Eject(QVariantMap());
|
||||
@ -183,7 +183,7 @@ void Udisks2Lister::UnmountDevice(const QString &id) {
|
||||
|
||||
void Udisks2Lister::UpdateDeviceFreeSpace(const QString &id) {
|
||||
QWriteLocker locker(&device_data_lock_);
|
||||
device_data_[id].free_space = Utilities::FileSystemFreeSpace(device_data_[id].mount_paths.at(0));
|
||||
device_data_[id].free_space = Utilities::FileSystemFreeSpace(device_data_.value(id).mount_paths.value(0));
|
||||
emit DeviceChanged(id);
|
||||
}
|
||||
|
||||
@ -326,11 +326,12 @@ void Udisks2Lister::JobCompleted(const bool success, const QString &message) {
|
||||
|
||||
qLog(Debug) << "Pending Job Completed | Path = " << job->path() << " | Mount? = " << mounting_jobs_[jobPath].is_mount << " | Success = " << success;
|
||||
|
||||
for (const auto &mounted_object : std::as_const(mounting_jobs_[jobPath].mounted_partitions)) {
|
||||
const QList<QDBusObjectPath> mounted_partitions = mounting_jobs_.value(jobPath).mounted_partitions;
|
||||
for (const QDBusObjectPath &mounted_object : mounted_partitions) {
|
||||
auto partition_data = ReadPartitionData(mounted_object);
|
||||
if (partition_data.dbus_path.isEmpty()) continue;
|
||||
|
||||
mounting_jobs_[jobPath].is_mount ? HandleFinishedMountJob(partition_data) : HandleFinishedUnmountJob(partition_data, mounted_object);
|
||||
mounting_jobs_.value(jobPath).is_mount ? HandleFinishedMountJob(partition_data) : HandleFinishedUnmountJob(partition_data, mounted_object);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -548,7 +548,7 @@ void EditTagDialog::InitFieldValue(const FieldData &field, const QModelIndexList
|
||||
editor->set_partially();
|
||||
}
|
||||
else {
|
||||
editor->set_value(data_[sel[0].row()].current_value(field.id_));
|
||||
editor->set_value(data_.value(sel.value(0).row()).current_value(field.id_));
|
||||
}
|
||||
}
|
||||
else if (field.editor_) {
|
||||
@ -601,8 +601,9 @@ void EditTagDialog::ResetFieldValue(const FieldData &field, const QModelIndexLis
|
||||
|
||||
// Reset each selected song
|
||||
for (const QModelIndex &i : sel) {
|
||||
Data &tag_data = data_[i.row()];
|
||||
Data tag_data = data_.value(i.row());
|
||||
tag_data.set_value(field.id_, tag_data.original_value(field.id_));
|
||||
data_[i.row()] = tag_data;
|
||||
}
|
||||
|
||||
// Reset the field
|
||||
@ -634,8 +635,8 @@ void EditTagDialog::SelectionChanged() {
|
||||
UpdateStatisticsTab(data_[indexes.first().row()].original_);
|
||||
}
|
||||
|
||||
const Song &first_song = data_[indexes.first().row()].original_;
|
||||
UpdateCoverAction first_cover_action = data_[indexes.first().row()].cover_action_;
|
||||
const Song first_song = data_.value(indexes.first().row()).original_;
|
||||
const UpdateCoverAction first_cover_action = data_.value(indexes.first().row()).cover_action_;
|
||||
bool art_different = false;
|
||||
bool action_different = false;
|
||||
bool albumartist_enabled = false;
|
||||
@ -648,14 +649,14 @@ void EditTagDialog::SelectionChanged() {
|
||||
bool comment_enabled = false;
|
||||
bool lyrics_enabled = false;
|
||||
for (const QModelIndex &idx : indexes) {
|
||||
if (data_[idx.row()].cover_action_ == UpdateCoverAction::None) {
|
||||
if (data_.value(idx.row()).cover_action_ == UpdateCoverAction::None) {
|
||||
data_[idx.row()].cover_result_ = AlbumCoverImageResult();
|
||||
}
|
||||
const Song &song = data_[idx.row()].original_;
|
||||
if (data_[idx.row()].cover_action_ != first_cover_action || (first_cover_action != UpdateCoverAction::None && data_[idx.row()].cover_result_.image_data != data_[indexes.first().row()].cover_result_.image_data)) {
|
||||
const Song song = data_.value(idx.row()).original_;
|
||||
if (data_.value(idx.row()).cover_action_ != first_cover_action || (first_cover_action != UpdateCoverAction::None && data_[idx.row()].cover_result_.image_data != data_[indexes.first().row()].cover_result_.image_data)) {
|
||||
action_different = true;
|
||||
}
|
||||
if (data_[idx.row()].cover_action_ != first_cover_action ||
|
||||
if (data_.value(idx.row()).cover_action_ != first_cover_action ||
|
||||
song.art_manual() != first_song.art_manual() ||
|
||||
song.art_embedded() != first_song.art_embedded() ||
|
||||
song.art_automatic() != first_song.art_automatic() ||
|
||||
@ -733,7 +734,7 @@ void EditTagDialog::SelectionChanged() {
|
||||
cover_options.types = cover_types_;
|
||||
cover_options.desired_scaled_size = QSize(kSmallImageSize, kSmallImageSize);
|
||||
cover_options.device_pixel_ratio = devicePixelRatioF();
|
||||
if (data_[indexes.first().row()].cover_action_ == UpdateCoverAction::None) {
|
||||
if (data_.value(indexes.first().row()).cover_action_ == UpdateCoverAction::None) {
|
||||
tags_cover_art_id_ = app_->album_cover_loader()->LoadImageAsync(cover_options, first_song);
|
||||
}
|
||||
else {
|
||||
@ -933,8 +934,8 @@ void EditTagDialog::AlbumCoverLoaded(const quint64 id, const AlbumCoverLoaderRes
|
||||
for (const QModelIndex &idx : indexes) {
|
||||
data_[idx.row()].cover_result_ = result.album_cover;
|
||||
if (!first_song.is_valid()) {
|
||||
first_song = data_[idx.row()].current_;
|
||||
cover_action = data_[idx.row()].cover_action_;
|
||||
first_song = data_.value(idx.row()).current_;
|
||||
cover_action = data_.value(idx.row()).cover_action_;
|
||||
}
|
||||
}
|
||||
bool enable_change_art = false;
|
||||
@ -1023,7 +1024,7 @@ void EditTagDialog::SaveCoverToFile() {
|
||||
|
||||
if (ui_->song_list->selectionModel()->selectedIndexes().isEmpty()) return;
|
||||
|
||||
const Data &first_data = data_[ui_->song_list->selectionModel()->selectedIndexes().first().row()];
|
||||
const Data first_data = data_.value(ui_->song_list->selectionModel()->selectedIndexes().first().row());
|
||||
album_cover_choice_controller_->SaveCoverToFileManual(first_data.current_, first_data.cover_result_);
|
||||
|
||||
}
|
||||
@ -1084,7 +1085,7 @@ void EditTagDialog::DeleteCover() {
|
||||
void EditTagDialog::ShowCover() {
|
||||
|
||||
if (ui_->song_list->selectionModel()->selectedIndexes().isEmpty()) return;
|
||||
const Data &first_data = data_[ui_->song_list->selectionModel()->selectedIndexes().first().row()];
|
||||
const Data first_data = data_.value(ui_->song_list->selectionModel()->selectedIndexes().first().row());
|
||||
album_cover_choice_controller_->ShowCover(first_data.current_, first_data.cover_result_.image);
|
||||
|
||||
}
|
||||
@ -1094,8 +1095,8 @@ void EditTagDialog::UpdateCover(const UpdateCoverAction cover_action, const Albu
|
||||
const QModelIndexList indexes = ui_->song_list->selectionModel()->selectedIndexes();
|
||||
if (indexes.isEmpty()) return;
|
||||
|
||||
QString artist = data_[indexes.first().row()].current_.effective_albumartist();
|
||||
QString album = data_[indexes.first().row()].current_.album();
|
||||
QString artist = data_.value(indexes.first().row()).current_.effective_albumartist();
|
||||
QString album = data_.value(indexes.first().row()).current_.album();
|
||||
|
||||
for (const QModelIndex &idx : indexes) {
|
||||
data_[idx.row()].cover_action_ = cover_action;
|
||||
@ -1372,7 +1373,7 @@ void EditTagDialog::FetchTag() {
|
||||
SongList songs;
|
||||
|
||||
for (const QModelIndex &idx : sel) {
|
||||
Song song = data_[idx.row()].original_;
|
||||
const Song song = data_.value(idx.row()).original_;
|
||||
if (!song.is_valid()) {
|
||||
continue;
|
||||
}
|
||||
@ -1429,7 +1430,7 @@ void EditTagDialog::FetchTagSongChosen(const Song &original_song, const Song &ne
|
||||
void EditTagDialog::FetchLyrics() {
|
||||
|
||||
if (ui_->song_list->selectionModel()->selectedIndexes().isEmpty()) return;
|
||||
const Song &song = data_[ui_->song_list->selectionModel()->selectedIndexes().first().row()].current_;
|
||||
const Song song = data_.value(ui_->song_list->selectionModel()->selectedIndexes().first().row()).current_;
|
||||
lyrics_fetcher_->Clear();
|
||||
ui_->lyrics->setPlainText(tr("loading..."));
|
||||
lyrics_id_ = static_cast<qint64>(lyrics_fetcher_->Search(song.effective_albumartist(), song.artist(), song.album(), song.title()));
|
||||
|
@ -174,7 +174,7 @@ void TrackSelectionDialog::UpdateStack() {
|
||||
const int row = ui_->song_list->currentRow();
|
||||
if (row < 0 || row >= data_.count()) return;
|
||||
|
||||
const Data &tag_data = data_[row];
|
||||
const Data tag_data = data_.value(row);
|
||||
|
||||
if (tag_data.pending_) {
|
||||
ui_->stack->setCurrentWidget(ui_->loading_page);
|
||||
|
@ -929,7 +929,7 @@ void GstEngine::PipelineFinished(const int pipeline_id) {
|
||||
|
||||
qLog(Debug) << "Pipeline" << pipeline_id << "finished";
|
||||
|
||||
GstEnginePipelinePtr pipeline = old_pipelines_[pipeline_id];
|
||||
GstEnginePipelinePtr pipeline = old_pipelines_.value(pipeline_id);
|
||||
old_pipelines_.remove(pipeline_id);
|
||||
if (pipeline == fadeout_pause_pipeline_) {
|
||||
StopFadeoutPause();
|
||||
|
@ -1947,7 +1947,7 @@ void GstEnginePipeline::UpdateEqualizer() {
|
||||
|
||||
// Update band gains
|
||||
for (int i = 0; i < kEqBandCount; ++i) {
|
||||
float gain = eq_enabled_ ? static_cast<float>(eq_band_gains_[i]) : static_cast<float>(0.0);
|
||||
float gain = eq_enabled_ ? static_cast<float>(eq_band_gains_.value(i)) : static_cast<float>(0.0);
|
||||
if (gain < 0) {
|
||||
gain *= 0.24F;
|
||||
}
|
||||
|
@ -185,7 +185,7 @@ void Equalizer::PresetChanged(const QString &name) {
|
||||
}
|
||||
last_preset_ = name;
|
||||
|
||||
Params &p = presets_[name];
|
||||
const Params p = presets_.value(name);
|
||||
|
||||
loading_ = true;
|
||||
preamp_->set_value(p.preamp);
|
||||
|
@ -135,7 +135,7 @@ void LyricsFetcherSearch::AllProvidersFinished() {
|
||||
|
||||
if (!results_.isEmpty()) {
|
||||
qLog(Debug) << "Using lyrics from" << results_.last().provider << "for" << request_.artist << request_.title << "with score" << results_.last().score;
|
||||
emit LyricsFetched(id_, results_.last().provider, results_.last().lyrics);
|
||||
emit LyricsFetched(id_, results_.constLast().provider, results_.constLast().lyrics);
|
||||
}
|
||||
else {
|
||||
emit LyricsFetched(id_, QString(), QString());
|
||||
|
@ -177,10 +177,11 @@ QByteArray MoodbarBuilder::Finish(int width) {
|
||||
const int end = std::max(static_cast<int>((i + 1) * frames_.count() / width), start + 1);
|
||||
|
||||
for (int j = start; j < end; j++) {
|
||||
const Rgb &frame = frames_[j];
|
||||
const Rgb frame = frames_.value(j);
|
||||
rgb.r += frame.r * 255;
|
||||
rgb.g += frame.g * 255;
|
||||
rgb.b += frame.b * 255;
|
||||
frames_[j] = rgb;
|
||||
}
|
||||
|
||||
const int n = end - start;
|
||||
|
@ -107,7 +107,7 @@ MoodbarLoader::Result MoodbarLoader::Load(const QUrl &url, const bool has_cue, Q
|
||||
|
||||
// Are we in the middle of loading this moodbar already?
|
||||
if (requests_.contains(url)) {
|
||||
*async_pipeline = requests_[url];
|
||||
*async_pipeline = requests_.value(url);
|
||||
return Result::WillLoadAsync;
|
||||
}
|
||||
|
||||
@ -173,7 +173,7 @@ void MoodbarLoader::MaybeTakeNextRequest() {
|
||||
active_requests_ << url;
|
||||
|
||||
qLog(Info) << "Creating moodbar data for" << url.toLocalFile();
|
||||
QMetaObject::invokeMethod(requests_[url], &MoodbarPipeline::Start, Qt::QueuedConnection);
|
||||
QMetaObject::invokeMethod(requests_.value(url), &MoodbarPipeline::Start, Qt::QueuedConnection);
|
||||
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,7 @@ void TagFetcher::StartFetch(const SongList &songs) {
|
||||
|
||||
if (have_fingerprints) {
|
||||
for (int i = 0; i < songs_.count(); ++i) {
|
||||
const Song &song = songs_[i];
|
||||
const Song song = songs_.value(i);
|
||||
emit Progress(song, tr("Identifying song"));
|
||||
acoustid_client_->Start(i, song.fingerprint(), static_cast<int>(song.length_nanosec() / kNsecPerMsec));
|
||||
}
|
||||
@ -104,7 +104,7 @@ void TagFetcher::FingerprintFound(const int index) {
|
||||
if (!watcher || index >= songs_.count()) return;
|
||||
|
||||
const QString fingerprint = watcher->resultAt(index);
|
||||
const Song &song = songs_[index];
|
||||
const Song song = songs_.value(index);
|
||||
|
||||
if (fingerprint.isEmpty()) {
|
||||
emit ResultAvailable(song, SongList());
|
||||
@ -122,7 +122,7 @@ void TagFetcher::PuidsFound(const int index, const QStringList &puid_list, const
|
||||
return;
|
||||
}
|
||||
|
||||
const Song &song = songs_[index];
|
||||
const Song song = songs_.value(index);
|
||||
|
||||
if (puid_list.isEmpty()) {
|
||||
emit ResultAvailable(song, SongList(), error);
|
||||
@ -140,7 +140,7 @@ void TagFetcher::TagsFetched(const int index, const MusicBrainzClient::ResultLis
|
||||
return;
|
||||
}
|
||||
|
||||
const Song &original_song = songs_[index];
|
||||
const Song original_song = songs_.value(index);
|
||||
SongList songs_guessed;
|
||||
songs_guessed.reserve(results.count());
|
||||
for (const MusicBrainzClient::Result &result : results) {
|
||||
|
@ -251,7 +251,7 @@ void OSDPretty::Load() {
|
||||
if (s.contains(QLatin1String("popup_screen"))) {
|
||||
popup_screen_name_ = s.value("popup_screen").toString();
|
||||
if (screens_.contains(popup_screen_name_)) {
|
||||
popup_screen_ = screens_[popup_screen_name_];
|
||||
popup_screen_ = screens_.value(popup_screen_name_);
|
||||
}
|
||||
else {
|
||||
popup_screen_ = current_screen();
|
||||
|
@ -620,7 +620,7 @@ int Playlist::next_row(const bool ignore_repeat_track) {
|
||||
// Still off the end? Then just give up
|
||||
if (next_virtual_index < 0 || next_virtual_index >= virtual_items_.count()) return -1;
|
||||
|
||||
return virtual_items_[next_virtual_index];
|
||||
return virtual_items_.value(next_virtual_index);
|
||||
|
||||
}
|
||||
|
||||
@ -651,7 +651,7 @@ int Playlist::previous_row(const bool ignore_repeat_track) {
|
||||
// Still off the beginning? Then just give up
|
||||
if (prev_virtual_index < 0) return -1;
|
||||
|
||||
return virtual_items_[prev_virtual_index];
|
||||
return virtual_items_.value(prev_virtual_index);
|
||||
|
||||
}
|
||||
|
||||
@ -1227,7 +1227,7 @@ void Playlist::UpdateItems(SongList songs) {
|
||||
QMutableListIterator<Song> it(songs);
|
||||
while (it.hasNext()) {
|
||||
const Song &song = it.next();
|
||||
const PlaylistItemPtr &item = items_[i];
|
||||
const PlaylistItemPtr item = items_.value(i);
|
||||
if (item->Metadata().url() == song.url() && (item->Metadata().filetype() == Song::FileType::Unknown || item->Metadata().filetype() == Song::FileType::Stream || item->Metadata().filetype() == Song::FileType::CDDA || !item->Metadata().init_from_file())) {
|
||||
PlaylistItemPtr new_item;
|
||||
if (song.url().isLocalFile()) {
|
||||
@ -2315,7 +2315,7 @@ void Playlist::InvalidateDeletedSongs() {
|
||||
QList<int> invalidated_rows;
|
||||
|
||||
for (int row = 0; row < items_.count(); ++row) {
|
||||
PlaylistItemPtr item = items_[row];
|
||||
PlaylistItemPtr item = items_.value(row);
|
||||
Song song = item->Metadata();
|
||||
|
||||
if (song.url().isLocalFile()) {
|
||||
@ -2349,7 +2349,7 @@ void Playlist::RemoveDeletedSongs() {
|
||||
QList<int> rows_to_remove;
|
||||
|
||||
for (int row = 0; row < items_.count(); ++row) {
|
||||
PlaylistItemPtr item = items_[row];
|
||||
PlaylistItemPtr item = items_.value(row);
|
||||
Song song = item->Metadata();
|
||||
|
||||
if (song.url().isLocalFile() && !QFile::exists(song.url().toLocalFile())) {
|
||||
@ -2383,7 +2383,7 @@ void Playlist::RemoveDuplicateSongs() {
|
||||
std::unordered_map<Song, int, SongSimilarHash, SongSimilarEqual> unique_songs;
|
||||
|
||||
for (int row = 0; row < items_.count(); ++row) {
|
||||
PlaylistItemPtr item = items_[row];
|
||||
PlaylistItemPtr item = items_.value(row);
|
||||
const Song &song = item->Metadata();
|
||||
|
||||
bool found_duplicate = false;
|
||||
@ -2416,7 +2416,7 @@ void Playlist::RemoveUnavailableSongs() {
|
||||
|
||||
QList<int> rows_to_remove;
|
||||
for (int row = 0; row < items_.count(); ++row) {
|
||||
PlaylistItemPtr item = items_[row];
|
||||
PlaylistItemPtr item = items_.value(row);
|
||||
const Song &song = item->Metadata();
|
||||
|
||||
// Check only local files
|
||||
|
@ -135,7 +135,7 @@ void PlaylistListModel::RowsAboutToBeRemoved(const QModelIndex &parent, const in
|
||||
const int id = idx.data(Role_PlaylistId).toInt();
|
||||
QMap<int, QStandardItem*>::iterator it = playlists_by_id_.find(id);
|
||||
if (it != playlists_by_id_.end() && it.value() == item) {
|
||||
playlists_by_id_.erase(it); // clazy:exclude=strict-iterators
|
||||
playlists_by_id_.erase(it);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -431,7 +431,8 @@ void PlaylistManager::UpdateSummaryText() {
|
||||
int selected = 0;
|
||||
|
||||
// Get the length of the selected tracks
|
||||
for (const QItemSelectionRange &range : std::as_const(playlists_[current_id()].selection)) {
|
||||
const QItemSelection ranges = playlists_.value(current_id()).selection;
|
||||
for (const QItemSelectionRange &range : ranges) {
|
||||
if (!range.isValid()) continue;
|
||||
|
||||
selected += range.bottom() - range.top() + 1;
|
||||
|
@ -57,7 +57,7 @@ void InsertItems::undo() {
|
||||
bool InsertItems::UpdateItem(const PlaylistItemPtr &updated_item) {
|
||||
|
||||
for (int i = 0; i < items_.size(); i++) {
|
||||
PlaylistItemPtr item = items_[i];
|
||||
PlaylistItemPtr item = items_.value(i);
|
||||
if (item->Metadata().url() == updated_item->Metadata().url()) {
|
||||
items_[i] = updated_item;
|
||||
return true;
|
||||
|
@ -177,7 +177,7 @@ void SongLoaderInserter::AsyncLoad() {
|
||||
task_manager_->SetTaskProgress(async_load_id, async_progress, pending_.count());
|
||||
bool first_loaded = false;
|
||||
for (int i = 0; i < pending_.count(); ++i) {
|
||||
SongLoader *loader = pending_[i];
|
||||
SongLoader *loader = pending_.value(i);
|
||||
SongLoader::Result res = loader->LoadFilenamesBlocking();
|
||||
task_manager_->SetTaskProgress(async_load_id, ++async_progress);
|
||||
|
||||
@ -208,7 +208,7 @@ void SongLoaderInserter::AsyncLoad() {
|
||||
task_manager_->SetTaskProgress(async_load_id, async_progress, songs_.count());
|
||||
SongList songs;
|
||||
for (int i = 0; i < pending_.count(); ++i) {
|
||||
SongLoader *loader = pending_[i];
|
||||
SongLoader *loader = pending_.value(i);
|
||||
if (i != 0) {
|
||||
// We already did this earlier for the first song.
|
||||
loader->LoadMetadataBlocking();
|
||||
|
@ -801,7 +801,7 @@ void QobuzRequest::AlbumsFinishCheck(const Artist &artist, const int limit, cons
|
||||
|
||||
// Get songs for all the albums.
|
||||
|
||||
for (QHash<QString, AlbumSongsRequest>::iterator it = album_songs_requests_pending_.begin(); it != album_songs_requests_pending_.end(); ++it) {
|
||||
for (QHash<QString, AlbumSongsRequest>::const_iterator it = album_songs_requests_pending_.constBegin(); it != album_songs_requests_pending_.constEnd(); ++it) {
|
||||
const AlbumSongsRequest &request = it.value();
|
||||
AddAlbumSongsRequest(request.artist, request.album);
|
||||
}
|
||||
@ -1366,7 +1366,7 @@ void QobuzRequest::AlbumCoverReceived(QNetworkReply *reply, const QUrl &cover_ur
|
||||
QByteArrayList format_list = QImageReader::imageFormatsForMimeType(mimetype.toUtf8());
|
||||
char *format = nullptr;
|
||||
if (!format_list.isEmpty()) {
|
||||
format = format_list.first().data();
|
||||
format = format_list[0].data();
|
||||
}
|
||||
|
||||
QImage image;
|
||||
|
@ -159,32 +159,32 @@ void QobuzStreamURLRequest::StreamURLReceived() {
|
||||
need_login_ = true;
|
||||
return;
|
||||
}
|
||||
emit StreamURLFailure(id_, media_url_, errors_.first());
|
||||
emit StreamURLFailure(id_, media_url_, errors_.constFirst());
|
||||
return;
|
||||
}
|
||||
|
||||
QJsonObject json_obj = ExtractJsonObj(data);
|
||||
if (json_obj.isEmpty()) {
|
||||
emit StreamURLFailure(id_, media_url_, errors_.first());
|
||||
emit StreamURLFailure(id_, media_url_, errors_.constFirst());
|
||||
return;
|
||||
}
|
||||
|
||||
if (!json_obj.contains(QLatin1String("track_id"))) {
|
||||
Error(QStringLiteral("Invalid Json reply, stream url is missing track_id."), json_obj);
|
||||
emit StreamURLFailure(id_, media_url_, errors_.first());
|
||||
emit StreamURLFailure(id_, media_url_, errors_.constFirst());
|
||||
return;
|
||||
}
|
||||
|
||||
int track_id = json_obj[QLatin1String("track_id")].toInt();
|
||||
if (track_id != song_id_) {
|
||||
Error(QStringLiteral("Incorrect track ID returned."), json_obj);
|
||||
emit StreamURLFailure(id_, media_url_, errors_.first());
|
||||
emit StreamURLFailure(id_, media_url_, errors_.constFirst());
|
||||
return;
|
||||
}
|
||||
|
||||
if (!json_obj.contains(QLatin1String("mime_type")) || !json_obj.contains(QLatin1String("url"))) {
|
||||
Error(QStringLiteral("Invalid Json reply, stream url is missing url or mime_type."), json_obj);
|
||||
emit StreamURLFailure(id_, media_url_, errors_.first());
|
||||
emit StreamURLFailure(id_, media_url_, errors_.constFirst());
|
||||
return;
|
||||
}
|
||||
|
||||
@ -205,7 +205,7 @@ void QobuzStreamURLRequest::StreamURLReceived() {
|
||||
|
||||
if (!url.isValid()) {
|
||||
Error(QStringLiteral("Returned stream url is invalid."), json_obj);
|
||||
emit StreamURLFailure(id_, media_url_, errors_.first());
|
||||
emit StreamURLFailure(id_, media_url_, errors_.constFirst());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -163,7 +163,7 @@ void RadioModel::AddChannels(const RadioChannelList &channels) {
|
||||
for (const RadioChannel &channel : channels) {
|
||||
RadioItem *container = nullptr;
|
||||
if (container_nodes_.contains(channel.source)) {
|
||||
container = container_nodes_[channel.source];
|
||||
container = container_nodes_.value(channel.source);
|
||||
}
|
||||
else {
|
||||
beginInsertRows(ItemToIndex(root_), static_cast<int>(root_->children.count()), static_cast<int>(root_->children.count()));
|
||||
|
@ -49,7 +49,7 @@ AudioScrobbler::AudioScrobbler(Application *app, QObject *parent)
|
||||
AudioScrobbler::~AudioScrobbler() {
|
||||
|
||||
while (!services_.isEmpty()) {
|
||||
ScrobblerServicePtr service = services_.first();
|
||||
ScrobblerServicePtr service = services_.value(services_.firstKey());
|
||||
RemoveService(service);
|
||||
}
|
||||
|
||||
|
@ -278,17 +278,19 @@ void GlobalShortcutsSettingsPage::OpenMateKeybindingProperties() {
|
||||
|
||||
void GlobalShortcutsSettingsPage::SetShortcut(const QString &id, const QKeySequence &key) {
|
||||
|
||||
Shortcut &shortcut = shortcuts_[id];
|
||||
Shortcut shortcut = shortcuts_.value(id);
|
||||
|
||||
shortcut.key = key;
|
||||
shortcut.item->setText(1, key.toString(QKeySequence::NativeText));
|
||||
|
||||
shortcuts_[id] = shortcut;
|
||||
|
||||
}
|
||||
|
||||
void GlobalShortcutsSettingsPage::ItemClicked(QTreeWidgetItem *item) {
|
||||
|
||||
current_id_ = item->data(0, Qt::UserRole).toString();
|
||||
Shortcut &shortcut = shortcuts_[current_id_];
|
||||
const Shortcut shortcut = shortcuts_.value(current_id_);
|
||||
|
||||
// Enable options
|
||||
ui_->shortcut_options->setEnabled(true);
|
||||
@ -324,7 +326,7 @@ void GlobalShortcutsSettingsPage::ChangeClicked() {
|
||||
|
||||
GlobalShortcutsManager *manager = dialog()->global_shortcuts_manager();
|
||||
manager->Unregister();
|
||||
QKeySequence key = grabber_->GetKey(shortcuts_[current_id_].s.action->text());
|
||||
QKeySequence key = grabber_->GetKey(shortcuts_.value(current_id_).s.action->text());
|
||||
manager->Register();
|
||||
|
||||
if (key.isEmpty()) return;
|
||||
|
@ -186,7 +186,7 @@ void SmartPlaylistQueryWizardPlugin::SetGenerator(PlaylistGeneratorPtr g) {
|
||||
|
||||
for (const SmartPlaylistSearchTerm &term : std::as_const(search.terms_)) {
|
||||
AddSearchTerm();
|
||||
search_page_->terms_.last()->SetTerm(term);
|
||||
search_page_->terms_.constLast()->SetTerm(term);
|
||||
}
|
||||
|
||||
// Sort order
|
||||
|
@ -122,7 +122,7 @@ void SmartPlaylistsModel::Init() {
|
||||
// How many defaults do we have to write?
|
||||
int unwritten_defaults = 0;
|
||||
for (int i = version; i < default_smart_playlists_.count(); ++i) {
|
||||
unwritten_defaults += static_cast<int>(default_smart_playlists_[i].count());
|
||||
unwritten_defaults += static_cast<int>(default_smart_playlists_.value(i).count());
|
||||
}
|
||||
|
||||
// Save the defaults if there are any unwritten ones
|
||||
@ -134,7 +134,8 @@ void SmartPlaylistsModel::Init() {
|
||||
// Append the new ones
|
||||
s.beginWriteArray(collection_backend_->songs_table(), playlist_index + unwritten_defaults);
|
||||
for (; version < default_smart_playlists_.count(); ++version) {
|
||||
for (PlaylistGeneratorPtr gen : std::as_const(default_smart_playlists_[version])) {
|
||||
const GeneratorList generators = default_smart_playlists_.value(version);
|
||||
for (PlaylistGeneratorPtr gen : generators) {
|
||||
SaveGenerator(&s, playlist_index++, gen);
|
||||
}
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ void SmartPlaylistWizard::SetGenerator(PlaylistGeneratorPtr gen) {
|
||||
|
||||
// Find the right type and jump to the start page
|
||||
for (int i = 0; i < plugins_.count(); ++i) {
|
||||
if (plugins_[i]->type() == gen->type()) {
|
||||
if (plugins_.value(i)->type() == gen->type()) {
|
||||
TypeChanged(i);
|
||||
// TODO: Put this back in when the setStartId is removed from the ctor next();
|
||||
break;
|
||||
@ -130,7 +130,8 @@ void SmartPlaylistWizard::SetGenerator(PlaylistGeneratorPtr gen) {
|
||||
finish_page_->ui_->dynamic->setChecked(gen->is_dynamic());
|
||||
|
||||
// Tell the plugin to load
|
||||
plugins_[type_index_]->SetGenerator(gen);
|
||||
SmartPlaylistWizardPlugin *plugin = plugins_.value(type_index_);
|
||||
plugin->SetGenerator(gen);
|
||||
|
||||
}
|
||||
|
||||
@ -158,7 +159,7 @@ void SmartPlaylistWizard::AddPlugin(SmartPlaylistWizardPlugin *plugin) {
|
||||
void SmartPlaylistWizard::TypeChanged(const int index) {
|
||||
|
||||
type_index_ = index;
|
||||
type_page_->next_id_ = plugins_[type_index_]->start_page();
|
||||
type_page_->next_id_ = plugins_.value(type_index_)->start_page();
|
||||
|
||||
}
|
||||
|
||||
@ -179,7 +180,7 @@ PlaylistGeneratorPtr SmartPlaylistWizard::CreateGenerator() const {
|
||||
void SmartPlaylistWizard::initializePage(const int id) {
|
||||
|
||||
if (id == finish_id_) {
|
||||
finish_page_->ui_->dynamic_container->setEnabled(plugins_[type_index_]->is_dynamic());
|
||||
finish_page_->ui_->dynamic_container->setEnabled(plugins_.value(type_index_)->is_dynamic());
|
||||
}
|
||||
QWizard::initializePage(id);
|
||||
|
||||
|
@ -855,7 +855,7 @@ void SpotifyRequest::AlbumsFinishCheck(const Artist &artist, const int limit, co
|
||||
|
||||
// Get songs for all the albums.
|
||||
|
||||
for (QMap<QString, AlbumSongsRequest> ::iterator it = album_songs_requests_pending_.begin(); it != album_songs_requests_pending_.end(); ++it) {
|
||||
for (QMap<QString, AlbumSongsRequest> ::const_iterator it = album_songs_requests_pending_.constBegin(); it != album_songs_requests_pending_.constEnd(); ++it) {
|
||||
AlbumSongsRequest request = it.value();
|
||||
AddAlbumSongsRequest(request.artist, request.album);
|
||||
}
|
||||
@ -1315,7 +1315,7 @@ void SpotifyRequest::AlbumCoverReceived(QNetworkReply *reply, const QString &alb
|
||||
QList<QByteArray> format_list = QImageReader::imageFormatsForMimeType(mimetype.toUtf8());
|
||||
char *format = nullptr;
|
||||
if (!format_list.isEmpty()) {
|
||||
format = format_list.first().data();
|
||||
format = format_list[0].data();
|
||||
}
|
||||
|
||||
QImage image;
|
||||
|
@ -258,7 +258,7 @@ QStandardItem *StreamingSearchModel::BuildContainers(const Song &s, QStandardIte
|
||||
key->group_[level] = display_text + unique_tag;
|
||||
QStandardItem *container = nullptr;
|
||||
if (containers_.contains(*key)) {
|
||||
container = containers_[*key];
|
||||
container = containers_.value(*key);
|
||||
}
|
||||
else {
|
||||
container = new QStandardItem(display_text);
|
||||
|
@ -366,7 +366,7 @@ void StreamingSearchView::timerEvent(QTimerEvent *e) {
|
||||
QMap<int, DelayedSearch>::iterator it = delayed_searches_.find(e->timerId());
|
||||
if (it != delayed_searches_.end()) {
|
||||
SearchAsync(it.value().id_, it.value().query_, it.value().type_);
|
||||
delayed_searches_.erase(it); // clazy:exclude=strict-iterators
|
||||
delayed_searches_.erase(it);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -517,11 +517,10 @@ void StreamingSearchView::SearchDone(const int service_id, const SongMap &songs,
|
||||
|
||||
void StreamingSearchView::CancelSearch(const int id) {
|
||||
|
||||
QMap<int, DelayedSearch>::iterator it;
|
||||
for (it = delayed_searches_.begin(); it != delayed_searches_.end(); ++it) {
|
||||
for (QMap<int, DelayedSearch>::iterator it = delayed_searches_.begin(); it != delayed_searches_.end(); ++it) {
|
||||
if (it.value().id_ == id) {
|
||||
killTimer(it.key());
|
||||
delayed_searches_.erase(it); // clazy:exclude=strict-iterators
|
||||
delayed_searches_.erase(it);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -556,7 +555,7 @@ void StreamingSearchView::SearchError(const int id, const QString &error) {
|
||||
void StreamingSearchView::UpdateStatus(const int service_id, const QString &text) {
|
||||
|
||||
if (!pending_searches_.contains(service_id)) return;
|
||||
const PendingState state = pending_searches_[service_id];
|
||||
const PendingState state = pending_searches_.value(service_id);
|
||||
const int search_id = state.orig_id_;
|
||||
if (search_id != last_search_id_) return;
|
||||
ui_->progressbar->show();
|
||||
@ -567,7 +566,7 @@ void StreamingSearchView::UpdateStatus(const int service_id, const QString &text
|
||||
void StreamingSearchView::ProgressSetMaximum(const int service_id, const int max) {
|
||||
|
||||
if (!pending_searches_.contains(service_id)) return;
|
||||
const PendingState state = pending_searches_[service_id];
|
||||
const PendingState state = pending_searches_.value(service_id);
|
||||
const int search_id = state.orig_id_;
|
||||
if (search_id != last_search_id_) return;
|
||||
ui_->progressbar->setMaximum(max);
|
||||
@ -577,7 +576,7 @@ void StreamingSearchView::ProgressSetMaximum(const int service_id, const int max
|
||||
void StreamingSearchView::UpdateProgress(const int service_id, const int progress) {
|
||||
|
||||
if (!pending_searches_.contains(service_id)) return;
|
||||
const PendingState state = pending_searches_[service_id];
|
||||
const PendingState state = pending_searches_.value(service_id);
|
||||
const int search_id = state.orig_id_;
|
||||
if (search_id != last_search_id_) return;
|
||||
ui_->progressbar->setValue(progress);
|
||||
|
@ -34,7 +34,7 @@ StreamingServices::StreamingServices(QObject *parent) : QObject(parent) {}
|
||||
StreamingServices::~StreamingServices() {
|
||||
|
||||
while (!services_.isEmpty()) {
|
||||
StreamingServicePtr service = services_.first();
|
||||
StreamingServicePtr service = services_.value(services_.firstKey());
|
||||
RemoveService(service);
|
||||
}
|
||||
|
||||
|
@ -306,8 +306,8 @@ void SubsonicRequest::AlbumsFinishCheck(const int offset, const int size, const
|
||||
|
||||
if (albums_requests_queue_.isEmpty() && albums_requests_active_ <= 0) { // Albums list is finished, get songs for all albums.
|
||||
|
||||
for (QHash<QString, Request> ::iterator it = album_songs_requests_pending_.begin(); it != album_songs_requests_pending_.end(); ++it) {
|
||||
Request request = it.value();
|
||||
for (QHash<QString, Request>::const_iterator it = album_songs_requests_pending_.constBegin(); it != album_songs_requests_pending_.constEnd(); ++it) {
|
||||
const Request request = it.value();
|
||||
AddAlbumSongsRequest(request.artist_id, request.album_id, request.album_artist);
|
||||
}
|
||||
album_songs_requests_pending_.clear();
|
||||
@ -822,7 +822,7 @@ void SubsonicRequest::AlbumCoverReceived(QNetworkReply *reply, const AlbumCoverR
|
||||
QByteArrayList format_list = QImageReader::imageFormatsForMimeType(mimetype.toUtf8());
|
||||
char *format = nullptr;
|
||||
if (!format_list.isEmpty()) {
|
||||
format = format_list.first().data();
|
||||
format = format_list[0].data();
|
||||
}
|
||||
|
||||
QImage image;
|
||||
|
@ -812,7 +812,7 @@ void TidalRequest::AlbumsFinishCheck(const Artist &artist, const int limit, cons
|
||||
|
||||
// Get songs for all the albums.
|
||||
|
||||
for (QHash<QString, AlbumSongsRequest>::iterator it = album_songs_requests_pending_.begin(); it != album_songs_requests_pending_.end(); ++it) {
|
||||
for (QHash<QString, AlbumSongsRequest>::const_iterator it = album_songs_requests_pending_.constBegin(); it != album_songs_requests_pending_.constEnd(); ++it) {
|
||||
const AlbumSongsRequest &request = it.value();
|
||||
AddAlbumSongsRequest(request.artist, request.album);
|
||||
}
|
||||
@ -1302,7 +1302,7 @@ void TidalRequest::AlbumCoverReceived(QNetworkReply *reply, const QString &album
|
||||
QByteArrayList format_list = QImageReader::imageFormatsForMimeType(mimetype.toUtf8());
|
||||
char *format = nullptr;
|
||||
if (!format_list.isEmpty()) {
|
||||
format = format_list.first().data();
|
||||
format = format_list[0].data();
|
||||
}
|
||||
|
||||
QImage image;
|
||||
|
@ -159,19 +159,19 @@ void TidalStreamURLRequest::StreamURLReceived() {
|
||||
need_login_ = true;
|
||||
return;
|
||||
}
|
||||
emit StreamURLFailure(id_, media_url_, errors_.first());
|
||||
emit StreamURLFailure(id_, media_url_, errors_.constFirst());
|
||||
return;
|
||||
}
|
||||
|
||||
QJsonObject json_obj = ExtractJsonObj(data);
|
||||
if (json_obj.isEmpty()) {
|
||||
emit StreamURLFailure(id_, media_url_, errors_.first());
|
||||
emit StreamURLFailure(id_, media_url_, errors_.constFirst());
|
||||
return;
|
||||
}
|
||||
|
||||
if (!json_obj.contains(QLatin1String("trackId"))) {
|
||||
Error(QStringLiteral("Invalid Json reply, stream missing trackId."), json_obj);
|
||||
emit StreamURLFailure(id_, media_url_, errors_.first());
|
||||
emit StreamURLFailure(id_, media_url_, errors_.constFirst());
|
||||
return;
|
||||
}
|
||||
int track_id = json_obj[QLatin1String("trackId")].toInt();
|
||||
@ -211,7 +211,7 @@ void TidalStreamURLRequest::StreamURLReceived() {
|
||||
|
||||
json_obj = ExtractJsonObj(data_manifest);
|
||||
if (json_obj.isEmpty()) {
|
||||
emit StreamURLFailure(id_, media_url_, errors_.first());
|
||||
emit StreamURLFailure(id_, media_url_, errors_.constFirst());
|
||||
return;
|
||||
}
|
||||
|
||||
@ -220,14 +220,14 @@ void TidalStreamURLRequest::StreamURLReceived() {
|
||||
QString key_id = json_obj[QLatin1String("keyId")].toString();
|
||||
if (!encryption_type.isEmpty() && !key_id.isEmpty()) {
|
||||
Error(tr("Received URL with %1 encrypted stream from Tidal. Strawberry does not currently support encrypted streams.").arg(encryption_type));
|
||||
emit StreamURLFailure(id_, media_url_, errors_.first());
|
||||
emit StreamURLFailure(id_, media_url_, errors_.constFirst());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!json_obj.contains(QLatin1String("mimeType"))) {
|
||||
Error(QStringLiteral("Invalid Json reply, stream url reply manifest is missing mimeType."), json_obj);
|
||||
emit StreamURLFailure(id_, media_url_, errors_.first());
|
||||
emit StreamURLFailure(id_, media_url_, errors_.constFirst());
|
||||
return;
|
||||
}
|
||||
|
||||
@ -250,7 +250,7 @@ void TidalStreamURLRequest::StreamURLReceived() {
|
||||
QJsonValue json_urls = json_obj[QLatin1String("urls")];
|
||||
if (!json_urls.isArray()) {
|
||||
Error(QStringLiteral("Invalid Json reply, urls is not an array."), json_urls);
|
||||
emit StreamURLFailure(id_, media_url_, errors_.first());
|
||||
emit StreamURLFailure(id_, media_url_, errors_.constFirst());
|
||||
return;
|
||||
}
|
||||
const QJsonArray json_array_urls = json_urls.toArray();
|
||||
@ -273,7 +273,7 @@ void TidalStreamURLRequest::StreamURLReceived() {
|
||||
QString encryption_key = json_obj[QLatin1String("encryptionKey")].toString();
|
||||
if (!encryption_key.isEmpty()) {
|
||||
Error(tr("Received URL with encrypted stream from Tidal. Strawberry does not currently support encrypted streams."));
|
||||
emit StreamURLFailure(id_, media_url_, errors_.first());
|
||||
emit StreamURLFailure(id_, media_url_, errors_.constFirst());
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -283,14 +283,14 @@ void TidalStreamURLRequest::StreamURLReceived() {
|
||||
QString security_token = json_obj[QLatin1String("securityToken")].toString();
|
||||
if (!security_type.isEmpty() && !security_token.isEmpty()) {
|
||||
Error(tr("Received URL with encrypted stream from Tidal. Strawberry does not currently support encrypted streams."));
|
||||
emit StreamURLFailure(id_, media_url_, errors_.first());
|
||||
emit StreamURLFailure(id_, media_url_, errors_.constFirst());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (urls.isEmpty()) {
|
||||
Error(QStringLiteral("Missing stream urls."), json_obj);
|
||||
emit StreamURLFailure(id_, media_url_, errors_.first());
|
||||
emit StreamURLFailure(id_, media_url_, errors_.constFirst());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -490,7 +490,7 @@ bool Transcoder::event(QEvent *e) {
|
||||
gst_bus_set_sync_handler(gst_pipeline_get_bus(GST_PIPELINE(finished_event->state_->pipeline_)), nullptr, nullptr, nullptr);
|
||||
|
||||
// Remove it from the list - this will also destroy the GStreamer pipeline
|
||||
current_jobs_.erase(it); // clazy:exclude=strict-iterators
|
||||
current_jobs_.erase(it);
|
||||
|
||||
// Emit the finished signal
|
||||
emit JobComplete(input, output, finished_event->success_);
|
||||
@ -525,7 +525,7 @@ void Transcoder::Cancel() {
|
||||
}
|
||||
|
||||
// Remove the job, this destroys the GStreamer pipeline too
|
||||
it = current_jobs_.erase(it); // clazy:exclude=strict-iterators
|
||||
it = current_jobs_.erase(it);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -278,7 +278,8 @@ void FancyTabWidget::CurrentTabChangedSlot(const int idx) {
|
||||
int FancyTabWidget::IndexOfTab(QWidget *widget) {
|
||||
|
||||
if (!tabs_.contains(widget)) return -1;
|
||||
return QTabWidget::indexOf(tabs_[widget]->page());
|
||||
QWidget *page = tabs_.value(widget)->page();
|
||||
return QTabWidget::indexOf(page);
|
||||
|
||||
}
|
||||
|
||||
|
@ -101,7 +101,7 @@ void LoginStateWidget::SetLoggedIn(const State state, const QString &account_nam
|
||||
void LoginStateWidget::FocusLastCredentialField() {
|
||||
|
||||
if (!credential_fields_.isEmpty()) {
|
||||
QObject *object = credential_fields_.last();
|
||||
QObject *object = credential_fields_.constLast();
|
||||
QWidget *widget = qobject_cast<QWidget*>(object);
|
||||
QLineEdit *line_edit = qobject_cast<QLineEdit*>(object);
|
||||
|
||||
|
@ -239,7 +239,7 @@ void StretchHeaderView::NormaliseWidths(const QList<int> §ions) {
|
||||
selected_sum = 0.0;
|
||||
for (int i = 0; i < count(); ++i) {
|
||||
if (sections.contains(i)) {
|
||||
selected_sum += column_widths_[i];
|
||||
selected_sum += column_widths_.value(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -263,7 +263,7 @@ void StretchHeaderView::ResizeSections(const QList<int> §ions) {
|
||||
if (isSectionHidden(i) || (!sections.isEmpty() && !sections.contains(i))) {
|
||||
continue;
|
||||
}
|
||||
const int pixels = static_cast<int>(column_widths_[i] * width());
|
||||
const int pixels = static_cast<int>(column_widths_.value(i) * width());
|
||||
if (pixels != 0) {
|
||||
resizeSection(i, pixels);
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ void VolumeSlider::paintEvent(QPaintEvent*) {
|
||||
|
||||
p.drawPixmap(0, 0, pixmap_gradient_, 0, 0, offset + padding, 0);
|
||||
p.drawPixmap(0, 0, pixmap_inset_);
|
||||
p.drawPixmap(offset - handle_pixmaps_[0].width() / 2 + padding, 0, handle_pixmaps_[anim_count_]);
|
||||
p.drawPixmap(offset - handle_pixmaps_.value(0).width() / 2 + padding, 0, handle_pixmaps_[anim_count_]);
|
||||
|
||||
// Draw percentage number
|
||||
QStyleOptionViewItem opt;
|
||||
|
Loading…
x
Reference in New Issue
Block a user