Add const and std::as_const
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
#include "config.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <utility>
|
||||
|
||||
#include <QObject>
|
||||
#include <QList>
|
||||
@@ -101,7 +102,7 @@ void CoversSettingsPage::Load() {
|
||||
QList<CoverProvider*> cover_providers_sorted = dialog()->app()->cover_providers()->List();
|
||||
std::stable_sort(cover_providers_sorted.begin(), cover_providers_sorted.end(), ProviderCompareOrder);
|
||||
|
||||
for (CoverProvider *provider : cover_providers_sorted) {
|
||||
for (CoverProvider *provider : std::as_const(cover_providers_sorted)) {
|
||||
QListWidgetItem *item = new QListWidgetItem(ui_->providers);
|
||||
item->setText(provider->name());
|
||||
item->setCheckState(provider->is_enabled() ? Qt::Checked : Qt::Unchecked);
|
||||
|
||||
@@ -153,7 +153,7 @@ void GlobalShortcutsSettingsPage::Load() {
|
||||
}
|
||||
#endif // HAVE_X11_GLOBALSHORTCUTS
|
||||
|
||||
QList<GlobalShortcutsManager::Shortcut> shortcuts = manager->shortcuts().values();
|
||||
const QList<GlobalShortcutsManager::Shortcut> shortcuts = manager->shortcuts().values();
|
||||
for (const GlobalShortcutsManager::Shortcut &i : shortcuts) {
|
||||
Shortcut shortcut;
|
||||
shortcut.s = i;
|
||||
@@ -167,7 +167,7 @@ void GlobalShortcutsSettingsPage::Load() {
|
||||
ItemClicked(ui_->list->topLevelItem(0));
|
||||
}
|
||||
|
||||
QList<Shortcut> shortcuts = shortcuts_.values();
|
||||
const QList<Shortcut> shortcuts = shortcuts_.values();
|
||||
for (const Shortcut &shortcut : shortcuts) {
|
||||
SetShortcut(shortcut.s.id, shortcut.s.action->shortcut());
|
||||
}
|
||||
@@ -215,7 +215,7 @@ void GlobalShortcutsSettingsPage::Save() {
|
||||
Settings s;
|
||||
s.beginGroup(kSettingsGroup);
|
||||
|
||||
QList<Shortcut> shortcuts = shortcuts_.values();
|
||||
const QList<Shortcut> shortcuts = shortcuts_.values();
|
||||
for (const Shortcut &shortcut : shortcuts) {
|
||||
shortcut.s.action->setShortcut(shortcut.key);
|
||||
shortcut.s.shortcut->setKey(shortcut.key);
|
||||
@@ -330,7 +330,7 @@ void GlobalShortcutsSettingsPage::ChangeClicked() {
|
||||
if (key.isEmpty()) return;
|
||||
|
||||
// Check if this key sequence is used by any other actions
|
||||
QStringList ids = shortcuts_.keys();
|
||||
const QStringList ids = shortcuts_.keys();
|
||||
for (const QString &id : ids) {
|
||||
if (shortcuts_[id].key == key) SetShortcut(id, QKeySequence());
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "config.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <utility>
|
||||
|
||||
#include <QObject>
|
||||
#include <QList>
|
||||
@@ -81,7 +82,7 @@ void LyricsSettingsPage::Load() {
|
||||
QList<LyricsProvider*> lyrics_providers_sorted = dialog()->app()->lyrics_providers()->List();
|
||||
std::stable_sort(lyrics_providers_sorted.begin(), lyrics_providers_sorted.end(), ProviderCompareOrder);
|
||||
|
||||
for (LyricsProvider *provider : lyrics_providers_sorted) {
|
||||
for (LyricsProvider *provider : std::as_const(lyrics_providers_sorted)) {
|
||||
QListWidgetItem *item = new QListWidgetItem(ui_->providers);
|
||||
item->setText(provider->name());
|
||||
item->setCheckState(provider->is_enabled() ? Qt::Checked : Qt::Unchecked);
|
||||
|
||||
@@ -192,7 +192,7 @@ void SettingsDialog::showEvent(QShowEvent *e) {
|
||||
LoadGeometry();
|
||||
// Load settings
|
||||
loading_settings_ = true;
|
||||
QList<PageData> pages = pages_.values();
|
||||
const QList<PageData> pages = pages_.values();
|
||||
for (const PageData &page : pages) {
|
||||
page.page_->Load();
|
||||
}
|
||||
@@ -211,7 +211,7 @@ void SettingsDialog::closeEvent(QCloseEvent*) {
|
||||
|
||||
void SettingsDialog::accept() {
|
||||
|
||||
QList<PageData> pages = pages_.values();
|
||||
const QList<PageData> pages = pages_.values();
|
||||
for (const PageData &page : pages) {
|
||||
page.page_->Accept();
|
||||
}
|
||||
@@ -226,7 +226,7 @@ void SettingsDialog::accept() {
|
||||
void SettingsDialog::reject() {
|
||||
|
||||
// Notify each page that user clicks on Cancel
|
||||
QList<PageData> pages = pages_.values();
|
||||
const QList<PageData> pages = pages_.values();
|
||||
for (const PageData &page : pages) {
|
||||
page.page_->Reject();
|
||||
}
|
||||
@@ -314,7 +314,7 @@ void SettingsDialog::AddPage(const Page id, SettingsPage *page, QTreeWidgetItem
|
||||
|
||||
void SettingsDialog::Save() {
|
||||
|
||||
QList<PageData> pages = pages_.values();
|
||||
const QList<PageData> pages = pages_.values();
|
||||
for (const PageData &page : pages) {
|
||||
page.page_->Apply();
|
||||
}
|
||||
@@ -327,7 +327,7 @@ void SettingsDialog::DialogButtonClicked(QAbstractButton *button) {
|
||||
|
||||
// While we only connect Apply at the moment, this might change in the future
|
||||
if (ui_->buttonBox->button(QDialogButtonBox::Apply) == button) {
|
||||
QList<PageData> pages = pages_.values();
|
||||
const QList<PageData> pages = pages_.values();
|
||||
for (const PageData &page : pages) {
|
||||
page.page_->Apply();
|
||||
}
|
||||
@@ -357,7 +357,7 @@ void SettingsDialog::CurrentItemChanged(QTreeWidgetItem *item) {
|
||||
ui_->title->setText(QStringLiteral("<b>") + item->text(0) + QStringLiteral("</b>"));
|
||||
|
||||
// Display the right page
|
||||
QList<PageData> pages = pages_.values();
|
||||
const QList<PageData> pages = pages_.values();
|
||||
for (const PageData &page : pages) {
|
||||
if (page.item_ == item) {
|
||||
ui_->stacked_widget->setCurrentWidget(page.scroll_area_);
|
||||
|
||||
Reference in New Issue
Block a user