From: Soeren Apel Date: Tue, 3 Mar 2020 21:59:25 +0000 (+0100) Subject: clazy fixes X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=49fee853b3f56ba78810260c71c3c402067f09fe;p=pulseview.git clazy fixes --- diff --git a/pv/application.cpp b/pv/application.cpp index 3e4691d0..6f666c5c 100644 --- a/pv/application.cpp +++ b/pv/application.cpp @@ -73,7 +73,7 @@ QStringList Application::get_languages() result << "en"; // Add default language to the set // Remove file extensions - for (QString file : files) + for (const QString& file : files) result << file.split(".").front(); result.sort(Qt::CaseInsensitive); diff --git a/pv/dialogs/settings.cpp b/pv/dialogs/settings.cpp index b648b4b3..9f458c99 100644 --- a/pv/dialogs/settings.cpp +++ b/pv/dialogs/settings.cpp @@ -221,7 +221,7 @@ QWidget *Settings::get_general_settings_form(QWidget *parent) const Application* a = qobject_cast(QApplication::instance()); QString current_language = settings.value(GlobalSettings::Key_General_Language).toString(); - for (QString language : a->get_languages()) { + for (const QString& language : a->get_languages()) { QLocale locale = QLocale(language); QString desc = locale.languageToString(locale.language()); language_cb->addItem(desc, language); @@ -610,7 +610,7 @@ void Settings::on_general_language_changed(const QString &text) GlobalSettings settings; Application* a = qobject_cast(QApplication::instance()); - for (QString language : a->get_languages()) { + for (const QString& language : a->get_languages()) { QLocale locale = QLocale(language); QString desc = locale.languageToString(locale.language()); diff --git a/pv/globalsettings.cpp b/pv/globalsettings.cpp index 2e3e52f1..ca649bef 100644 --- a/pv/globalsettings.cpp +++ b/pv/globalsettings.cpp @@ -102,7 +102,7 @@ void GlobalSettings::set_defaults_where_needed() { if (!contains(Key_General_Language)) { // Determine and set default UI language - QString language = QLocale().uiLanguages().first(); // May return e.g. en-Latn-US + QString language = QLocale().uiLanguages().first(); // May return e.g. en-Latn-US // clazy:exclude=detaching-temporary language = language.split("-").first(); setValue(Key_General_Language, language); diff --git a/pv/popups/channels.cpp b/pv/popups/channels.cpp index b7fcad45..842a19d2 100644 --- a/pv/popups/channels.cpp +++ b/pv/popups/channels.cpp @@ -272,14 +272,14 @@ void Channels::populate_group(shared_ptr group, if (sigs.size() > 8) { QPushButton *row_enable_button = new QPushButton(tr("All"), this); grid->addWidget(row_enable_button, row, 8); - connect(row_enable_button, &QPushButton::clicked, - [this_row]() { - for (QCheckBox *box : this_row) - box->setChecked(true); + connect(row_enable_button, &QPushButton::clicked, row_enable_button, + [this_row]() { + for (QCheckBox *box : this_row) + box->setChecked(true); }); QPushButton *row_disable_button = new QPushButton(tr("None"), this); - connect(row_disable_button, &QPushButton::clicked, + connect(row_disable_button, &QPushButton::clicked, row_disable_button, [this_row]() { for (QCheckBox *box : this_row) box->setChecked(false); @@ -302,14 +302,16 @@ void Channels::populate_group(shared_ptr group, group_layout->addWidget(btn_enable_all); group_layout->addWidget(btn_disable_all); - connect(btn_enable_all, &QPushButton::clicked, [group_checkboxes](){ - for (QCheckBox *box: group_checkboxes) - box->setChecked(true); + connect(btn_enable_all, &QPushButton::clicked, btn_enable_all, + [group_checkboxes](){ + for (QCheckBox *box: group_checkboxes) + box->setChecked(true); }); - connect(btn_disable_all, &QPushButton::clicked, [group_checkboxes](){ - for (QCheckBox *box: group_checkboxes) - box->setChecked(false); + connect(btn_disable_all, &QPushButton::clicked, btn_disable_all, + [group_checkboxes](){ + for (QCheckBox *box: group_checkboxes) + box->setChecked(false); }); } diff --git a/pv/session.cpp b/pv/session.cpp index e42f730a..bc644ab9 100644 --- a/pv/session.cpp +++ b/pv/session.cpp @@ -235,7 +235,7 @@ void Session::save_setup(QSettings &settings) const int view_id = 0; i = 0; - for (const shared_ptr vb : views_) { + for (const shared_ptr& vb : views_) { shared_ptr tv = dynamic_pointer_cast(vb); if (tv) { for (const shared_ptr& time_item : tv->time_items()) { diff --git a/pv/views/trace/cursorpair.cpp b/pv/views/trace/cursorpair.cpp index fa8200be..7d7d8e4d 100644 --- a/pv/views/trace/cursorpair.cpp +++ b/pv/views/trace/cursorpair.cpp @@ -130,10 +130,11 @@ QMenu *CursorPair::create_header_context_menu(QWidget *parent) displayIntervalAction->setChecked(show_interval_); menu->addAction(displayIntervalAction); - connect(displayIntervalAction, &QAction::toggled, [=]{ - GlobalSettings settings; - settings.setValue(GlobalSettings::Key_View_CursorShowInterval, - !settings.value(GlobalSettings::Key_View_CursorShowInterval).value()); + connect(displayIntervalAction, &QAction::toggled, displayIntervalAction, + [=]{ + GlobalSettings settings; + settings.setValue(GlobalSettings::Key_View_CursorShowInterval, + !settings.value(GlobalSettings::Key_View_CursorShowInterval).value()); }); QAction *displayFrequencyAction = new QAction(tr("Display frequency"), this); @@ -141,10 +142,11 @@ QMenu *CursorPair::create_header_context_menu(QWidget *parent) displayFrequencyAction->setChecked(show_frequency_); menu->addAction(displayFrequencyAction); - connect(displayFrequencyAction, &QAction::toggled, [=]{ - GlobalSettings settings; - settings.setValue(GlobalSettings::Key_View_CursorShowFrequency, - !settings.value(GlobalSettings::Key_View_CursorShowFrequency).value()); + connect(displayFrequencyAction, &QAction::toggled, displayFrequencyAction, + [=]{ + GlobalSettings settings; + settings.setValue(GlobalSettings::Key_View_CursorShowFrequency, + !settings.value(GlobalSettings::Key_View_CursorShowFrequency).value()); }); QAction *displaySamplesAction = new QAction(tr("Display samples"), this); @@ -152,10 +154,11 @@ QMenu *CursorPair::create_header_context_menu(QWidget *parent) displaySamplesAction->setChecked(show_samples_); menu->addAction(displaySamplesAction); - connect(displaySamplesAction, &QAction::toggled, [=]{ - GlobalSettings settings; - settings.setValue(GlobalSettings::Key_View_CursorShowSamples, - !settings.value(GlobalSettings::Key_View_CursorShowSamples).value()); + connect(displaySamplesAction, &QAction::toggled, displaySamplesAction, + [=]{ + GlobalSettings settings; + settings.setValue(GlobalSettings::Key_View_CursorShowSamples, + !settings.value(GlobalSettings::Key_View_CursorShowSamples).value()); }); return menu;