]> sigrok.org Git - pulseview.git/commitdiff
clazy fixes
authorSoeren Apel <redacted>
Tue, 3 Mar 2020 21:59:25 +0000 (22:59 +0100)
committerUwe Hermann <redacted>
Mon, 16 Mar 2020 22:36:50 +0000 (23:36 +0100)
pv/application.cpp
pv/dialogs/settings.cpp
pv/globalsettings.cpp
pv/popups/channels.cpp
pv/session.cpp
pv/views/trace/cursorpair.cpp

index 3e4691d0776434398467cd0cd0b3230bc37317ec..6f666c5c308762c55ea0990297f1ea9fea1536eb 100644 (file)
@@ -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);
index b648b4b3f942b71d1e0a5fccd4e9c6de888eba09..9f458c99953e8c26c1721b5b9e819e73f9f1a1f7 100644 (file)
@@ -221,7 +221,7 @@ QWidget *Settings::get_general_settings_form(QWidget *parent) const
        Application* a = qobject_cast<Application*>(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<Application*>(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());
 
index 2e3e52f1b31ab7627cb6cb82d9a2d623088cfe5d..ca649befad8f318dab49f90e2ef73ad766756625 100644 (file)
@@ -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);
index b7fcad4584bdd1a5f82042c4955afa84648f1d3d..842a19d29305ba3db38de9a43f096ba22da45490 100644 (file)
@@ -272,14 +272,14 @@ void Channels::populate_group(shared_ptr<ChannelGroup> 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<ChannelGroup> 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);
                        });
        }
 
index e42f730a4dc4d2900b6ee4e12f541f0c134ec0ee..bc644ab908a77a02615af1910e80c85b56ee25b8 100644 (file)
@@ -235,7 +235,7 @@ void Session::save_setup(QSettings &settings) const
 
        int view_id = 0;
        i = 0;
-       for (const shared_ptr<views::ViewBase> vb : views_) {
+       for (const shared_ptr<views::ViewBase>& vb : views_) {
                shared_ptr<views::trace::View> tv = dynamic_pointer_cast<views::trace::View>(vb);
                if (tv) {
                        for (const shared_ptr<views::trace::TimeItem>& time_item : tv->time_items()) {
index fa8200bea844150230c80d78fc15625742311d14..7d7d8e4d6477d2e9efbd2a5b84f1bd3f52ec9d79 100644 (file)
@@ -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<bool>());
+       connect(displayIntervalAction, &QAction::toggled, displayIntervalAction,
+               [=]{
+                       GlobalSettings settings;
+                       settings.setValue(GlobalSettings::Key_View_CursorShowInterval,
+                               !settings.value(GlobalSettings::Key_View_CursorShowInterval).value<bool>());
                });
 
        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<bool>());
+       connect(displayFrequencyAction, &QAction::toggled, displayFrequencyAction,
+               [=]{
+                       GlobalSettings settings;
+                       settings.setValue(GlobalSettings::Key_View_CursorShowFrequency,
+                               !settings.value(GlobalSettings::Key_View_CursorShowFrequency).value<bool>());
                });
 
        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<bool>());
+       connect(displaySamplesAction, &QAction::toggled, displaySamplesAction,
+               [=]{
+                       GlobalSettings settings;
+                       settings.setValue(GlobalSettings::Key_View_CursorShowSamples,
+                               !settings.value(GlobalSettings::Key_View_CursorShowSamples).value<bool>());
                });
 
        return menu;