[education/rkward] rkward/settings: Fix various cppcheck issues
Thomas Friedrichsmeier
null at kde.org
Mon Jul 22 22:34:28 BST 2024
Git commit 6355a7276cac9d4ef967b2fa2c96b105493f3d51 by Thomas Friedrichsmeier.
Committed on 22/07/2024 at 21:34.
Pushed by tfry into branch 'master'.
Fix various cppcheck issues
M +5 -5 rkward/settings/rksettings.cpp
M +1 -1 rkward/settings/rksettingsmodulecommandeditor.cpp
M +2 -2 rkward/settings/rksettingsmodulecommandeditor.h
M +2 -2 rkward/settings/rksettingsmoduleconsole.h
M +1 -1 rkward/settings/rksettingsmoduledebug.cpp
M +2 -2 rkward/settings/rksettingsmoduledebug.h
M +2 -2 rkward/settings/rksettingsmodulegeneral.h
M +1 -1 rkward/settings/rksettingsmodulegraphics.cpp
M +2 -2 rkward/settings/rksettingsmodulegraphics.h
M +1 -1 rkward/settings/rksettingsmodulekateplugins.cpp
M +2 -2 rkward/settings/rksettingsmodulekateplugins.h
M +1 -1 rkward/settings/rksettingsmoduleobjectbrowser.cpp
M +2 -2 rkward/settings/rksettingsmoduleobjectbrowser.h
M +1 -1 rkward/settings/rksettingsmoduleoutput.cpp
M +2 -2 rkward/settings/rksettingsmoduleoutput.h
M +2 -2 rkward/settings/rksettingsmoduleplugins.cpp
M +2 -2 rkward/settings/rksettingsmoduleplugins.h
M +2 -2 rkward/settings/rksettingsmoduler.cpp
M +4 -4 rkward/settings/rksettingsmoduler.h
M +1 -1 rkward/settings/rksettingsmodulewatch.cpp
M +2 -4 rkward/settings/rksettingsmodulewatch.h
https://invent.kde.org/education/rkward/-/commit/6355a7276cac9d4ef967b2fa2c96b105493f3d51
diff --git a/rkward/settings/rksettings.cpp b/rkward/settings/rksettings.cpp
index 0740fafb8..2edbf9c69 100644
--- a/rkward/settings/rksettings.cpp
+++ b/rkward/settings/rksettings.cpp
@@ -102,11 +102,11 @@ void RKSettings::initDialogPages() {
KPageWidgetItem* RKSettings::findPage(const RKSettingsModule::PageId id) const {
RK_TRACE (SETTINGS);
- for (auto it = pages.constBegin(); it != pages.constEnd(); ++it) {
- if (static_cast<RKSettingsModuleWidget*>((*it)->widget())->pageid == id) return *it;
- }
- RK_ASSERT(false);
- return nullptr;
+ auto it = std::find_if(pages.constBegin(), pages.constEnd(), [id](KPageWidgetItem* p) {
+ return (static_cast<RKSettingsModuleWidget*>(p->widget())->pageid == id);
+ });
+ RK_ASSERT(it != pages.constEnd());
+ return *it;
}
void RKSettings::pageChange (KPageWidgetItem *current, KPageWidgetItem *) {
diff --git a/rkward/settings/rksettingsmodulecommandeditor.cpp b/rkward/settings/rksettingsmodulecommandeditor.cpp
index c987cf336..c7dd2ee65 100644
--- a/rkward/settings/rksettingsmodulecommandeditor.cpp
+++ b/rkward/settings/rksettingsmodulecommandeditor.cpp
@@ -160,7 +160,7 @@ public:
main_vbox->addStretch();
}
- void applyChanges() {
+ void applyChanges() override {
RK_TRACE(SETTINGS);
completion_settings_widget->applyChanges();
diff --git a/rkward/settings/rksettingsmodulecommandeditor.h b/rkward/settings/rksettingsmodulecommandeditor.h
index 1916b7aa0..44768f199 100644
--- a/rkward/settings/rksettingsmodulecommandeditor.h
+++ b/rkward/settings/rksettingsmodulecommandeditor.h
@@ -84,8 +84,8 @@ configuration for the Command Editor windows
class RKSettingsModuleCommandEditor : public RKSettingsModule {
Q_OBJECT
public:
- RKSettingsModuleCommandEditor(QObject *parent);
- ~RKSettingsModuleCommandEditor();
+ explicit RKSettingsModuleCommandEditor(QObject *parent);
+ ~RKSettingsModuleCommandEditor() override;
void syncConfig(KConfig *config, RKConfigBase::ConfigSyncAction) override;
QList<RKSettingsModuleWidget*> createPages(QWidget *parent) override;
diff --git a/rkward/settings/rksettingsmoduleconsole.h b/rkward/settings/rksettingsmoduleconsole.h
index 10049bc64..602a035a7 100644
--- a/rkward/settings/rksettingsmoduleconsole.h
+++ b/rkward/settings/rksettingsmoduleconsole.h
@@ -23,8 +23,8 @@ Settings module for the console. Allows you to configure whether to store comman
class RKSettingsModuleConsole : public RKSettingsModule {
Q_OBJECT
public:
- RKSettingsModuleConsole(QObject *parent);
- ~RKSettingsModuleConsole();
+ explicit RKSettingsModuleConsole(QObject *parent);
+ ~RKSettingsModuleConsole() override;
void syncConfig(KConfig *config, RKConfigBase::ConfigSyncAction) override;
QList<RKSettingsModuleWidget*> createPages(QWidget *parent) override;
diff --git a/rkward/settings/rksettingsmoduledebug.cpp b/rkward/settings/rksettingsmoduledebug.cpp
index 86e0f57a2..cea24b7a1 100644
--- a/rkward/settings/rksettingsmoduledebug.cpp
+++ b/rkward/settings/rksettingsmoduledebug.cpp
@@ -88,7 +88,7 @@ public:
main_vbox->addStretch();
}
}
- void applyChanges() {
+ void applyChanges() override {
RK_TRACE(SETTINGS);
RK_Debug::RK_Debug_Level = DL_FATAL - debug_level_box->intValue();
diff --git a/rkward/settings/rksettingsmoduledebug.h b/rkward/settings/rksettingsmoduledebug.h
index f47601abc..c726e0b0f 100644
--- a/rkward/settings/rksettingsmoduledebug.h
+++ b/rkward/settings/rksettingsmoduledebug.h
@@ -21,8 +21,8 @@ configuration for the Command Editor windows
class RKSettingsModuleDebug : public RKSettingsModule {
Q_OBJECT
public:
- RKSettingsModuleDebug(QObject *parent);
- ~RKSettingsModuleDebug();
+ explicit RKSettingsModuleDebug(QObject *parent);
+ ~RKSettingsModuleDebug() override;
void syncConfig(KConfig *config, RKConfigBase::ConfigSyncAction) override;
QList<RKSettingsModuleWidget*> createPages(QWidget *parent) override;
diff --git a/rkward/settings/rksettingsmodulegeneral.h b/rkward/settings/rksettingsmodulegeneral.h
index 45896998d..9fb01a3ff 100644
--- a/rkward/settings/rksettingsmodulegeneral.h
+++ b/rkward/settings/rksettingsmodulegeneral.h
@@ -20,8 +20,8 @@ class RKSpinBox;
class RKSettingsModuleGeneral : public RKSettingsModule {
Q_OBJECT
public:
- RKSettingsModuleGeneral(QObject *parent);
- ~RKSettingsModuleGeneral ();
+ explicit RKSettingsModuleGeneral(QObject *parent);
+ ~RKSettingsModuleGeneral() override;
enum WorkplaceSaveMode { // don't change the int values of this enum, or you'll ruin users saved settings. Append new values at the end
SaveWorkplaceWithWorkspace=0,
diff --git a/rkward/settings/rksettingsmodulegraphics.cpp b/rkward/settings/rksettingsmodulegraphics.cpp
index 25ae934c2..7a824be29 100644
--- a/rkward/settings/rksettingsmodulegraphics.cpp
+++ b/rkward/settings/rksettingsmodulegraphics.cpp
@@ -153,7 +153,7 @@ public:
change();
}
- void applyChanges() {
+ void applyChanges() override {
RK_TRACE(SETTINGS);
RKSettingsModuleGraphics::default_device = (RKSettingsModuleGraphics::DefaultDevice) default_device_group->checkedId();
diff --git a/rkward/settings/rksettingsmodulegraphics.h b/rkward/settings/rksettingsmodulegraphics.h
index 61dbc381e..294c58d7a 100644
--- a/rkward/settings/rksettingsmodulegraphics.h
+++ b/rkward/settings/rksettingsmodulegraphics.h
@@ -24,8 +24,8 @@ class QRadioButton;
class RKSettingsModuleGraphics : public RKSettingsModule {
Q_OBJECT
public:
- RKSettingsModuleGraphics(QObject *parent);
- ~RKSettingsModuleGraphics();
+ explicit RKSettingsModuleGraphics(QObject *parent);
+ ~RKSettingsModuleGraphics() override;
/** generate the commands needed to set the R run time options */
static QStringList makeRRunTimeOptionCommands ();
diff --git a/rkward/settings/rksettingsmodulekateplugins.cpp b/rkward/settings/rksettingsmodulekateplugins.cpp
index 12449f05b..f638d3959 100644
--- a/rkward/settings/rksettingsmodulekateplugins.cpp
+++ b/rkward/settings/rksettingsmodulekateplugins.cpp
@@ -66,7 +66,7 @@ public:
connect(plugin_table, &QTreeWidget::itemChanged, this, &RKSettingsPageKatePlugins::change);
}
- void applyChanges() {
+ void applyChanges() override {
RK_TRACE(SETTINGS);
QStringList p;
diff --git a/rkward/settings/rksettingsmodulekateplugins.h b/rkward/settings/rksettingsmodulekateplugins.h
index 837f4063b..c6c8e87d6 100644
--- a/rkward/settings/rksettingsmodulekateplugins.h
+++ b/rkward/settings/rksettingsmodulekateplugins.h
@@ -18,8 +18,8 @@ class QTreeWidget;
*/
class RKSettingsModuleKatePlugins : public RKSettingsModule {
public:
- RKSettingsModuleKatePlugins(QObject *parent);
- ~RKSettingsModuleKatePlugins();
+ explicit RKSettingsModuleKatePlugins(QObject *parent);
+ ~RKSettingsModuleKatePlugins() override;
void syncConfig(KConfig *config, RKConfigBase::ConfigSyncAction) override;
QList<RKSettingsModuleWidget*> createPages(QWidget *parent) override;
diff --git a/rkward/settings/rksettingsmoduleobjectbrowser.cpp b/rkward/settings/rksettingsmoduleobjectbrowser.cpp
index ffd94054a..98bc7ced4 100644
--- a/rkward/settings/rksettingsmoduleobjectbrowser.cpp
+++ b/rkward/settings/rksettingsmoduleobjectbrowser.cpp
@@ -53,7 +53,7 @@ public:
});
layout->addWidget(blacklist_choser);
}
- void applyChanges() {
+ void applyChanges() override {
RK_TRACE(SETTINGS);
RKSettingsModuleObjectBrowser::getstructure_blacklist = blacklist_choser->getValues();
diff --git a/rkward/settings/rksettingsmoduleobjectbrowser.h b/rkward/settings/rksettingsmoduleobjectbrowser.h
index 8e6a0115b..92399dea3 100644
--- a/rkward/settings/rksettingsmoduleobjectbrowser.h
+++ b/rkward/settings/rksettingsmoduleobjectbrowser.h
@@ -22,8 +22,8 @@ class MultiStringSelector;
class RKSettingsModuleObjectBrowser : public RKSettingsModule {
Q_OBJECT
public:
- RKSettingsModuleObjectBrowser(QObject *parent);
- ~RKSettingsModuleObjectBrowser();
+ explicit RKSettingsModuleObjectBrowser(QObject *parent);
+ ~RKSettingsModuleObjectBrowser() override;
void syncConfig(KConfig *config, RKConfigBase::ConfigSyncAction) override;
QList<RKSettingsModuleWidget*> createPages(QWidget *parent) override;
diff --git a/rkward/settings/rksettingsmoduleoutput.cpp b/rkward/settings/rksettingsmoduleoutput.cpp
index db754d5c1..8b81c68a2 100644
--- a/rkward/settings/rksettingsmoduleoutput.cpp
+++ b/rkward/settings/rksettingsmoduleoutput.cpp
@@ -181,7 +181,7 @@ public:
change();
graphics_jpg_quality_box->setEnabled(graphics_type_box->itemData(graphics_type_box->currentIndex()).toString() == "\"JPG\"");
}
- void applyChanges() {
+ void applyChanges() override {
RK_TRACE(SETTINGS);
RKSettingsModuleOutput::custom_css_file = custom_css_file_box->getLocation();
RKSettingsModuleOutput::graphics_type = graphics_type_box->itemData(graphics_type_box->currentIndex()).toString();
diff --git a/rkward/settings/rksettingsmoduleoutput.h b/rkward/settings/rksettingsmoduleoutput.h
index eaa6e5daf..891cd1664 100644
--- a/rkward/settings/rksettingsmoduleoutput.h
+++ b/rkward/settings/rksettingsmoduleoutput.h
@@ -59,8 +59,8 @@ private:
class RKSettingsModuleOutput : public RKSettingsModule {
Q_OBJECT
public:
- RKSettingsModuleOutput(QObject *parent);
- ~RKSettingsModuleOutput();
+ explicit RKSettingsModuleOutput(QObject *parent);
+ ~RKSettingsModuleOutput() override;
void syncConfig(KConfig *config, RKConfigBase::ConfigSyncAction) override;
QList<RKSettingsModuleWidget*> createPages(QWidget *parent) override;
diff --git a/rkward/settings/rksettingsmoduleplugins.cpp b/rkward/settings/rksettingsmoduleplugins.cpp
index 7dce1fb18..1a1142527 100644
--- a/rkward/settings/rksettingsmoduleplugins.cpp
+++ b/rkward/settings/rksettingsmoduleplugins.cpp
@@ -84,7 +84,7 @@ public:
main_vbox->addStretch();
}
- void applyChanges() {
+ void applyChanges() override {
RK_TRACE(SETTINGS);
RKSettingsModulePlugins::interface_pref = static_cast<RKSettingsModulePlugins::PluginPrefs>(button_group->checkedId());
@@ -104,7 +104,7 @@ public:
layout->addWidget(l);
layout->addStretch();
}
- void applyChanges() {};
+ void applyChanges() override {};
};
RKSettingsModulePlugins::RKSettingsModulePlugins(QObject *parent) : RKSettingsModule(parent) {
diff --git a/rkward/settings/rksettingsmoduleplugins.h b/rkward/settings/rksettingsmoduleplugins.h
index 6b9d4fef5..904ffc1ca 100644
--- a/rkward/settings/rksettingsmoduleplugins.h
+++ b/rkward/settings/rksettingsmoduleplugins.h
@@ -25,8 +25,8 @@ class RKSpinBox;
class RKSettingsModulePlugins : public RKSettingsModule {
Q_OBJECT
public:
- RKSettingsModulePlugins(QObject *parent);
- ~RKSettingsModulePlugins();
+ explicit RKSettingsModulePlugins(QObject *parent);
+ ~RKSettingsModulePlugins() override;
enum PluginPrefs { PreferDialog=0, PreferRecommended=1, PreferWizard=2 };
diff --git a/rkward/settings/rksettingsmoduler.cpp b/rkward/settings/rksettingsmoduler.cpp
index 7d0ecdea1..41bbfd5a3 100755
--- a/rkward/settings/rksettingsmoduler.cpp
+++ b/rkward/settings/rksettingsmoduler.cpp
@@ -184,7 +184,7 @@ public:
});
main_vbox->addWidget(addpaths_selector);
}
- void applyChanges() {
+ void applyChanges() override {
RK_TRACE(SETTINGS);
RKSettingsModuleR::options_outdec = outdec_input->text();
@@ -414,7 +414,7 @@ public:
main_vbox->addStretch();
}
- void applyChanges() {
+ void applyChanges() override {
RK_TRACE(SETTINGS);
RKSettingsModuleRPackages::cran_mirror_url = cran_mirror_input->text();
diff --git a/rkward/settings/rksettingsmoduler.h b/rkward/settings/rksettingsmoduler.h
index 94d43998a..2267ade3e 100644
--- a/rkward/settings/rksettingsmoduler.h
+++ b/rkward/settings/rksettingsmoduler.h
@@ -26,8 +26,8 @@ Configure the R-backend
class RKSettingsModuleR : public RKSettingsModule {
Q_OBJECT
public:
- RKSettingsModuleR(QObject *parent);
- ~RKSettingsModuleR();
+ explicit RKSettingsModuleR(QObject *parent);
+ ~RKSettingsModuleR() override;
void syncConfig(KConfig *config, RKConfigBase::ConfigSyncAction) override;
QList<RKSettingsModuleWidget*> createPages(QWidget *parent) override;
@@ -76,8 +76,8 @@ Configure packages and library paths
class RKSettingsModuleRPackages : public RKSettingsModule {
Q_OBJECT
public:
- RKSettingsModuleRPackages(QObject *parent);
- ~RKSettingsModuleRPackages();
+ explicit RKSettingsModuleRPackages(QObject *parent);
+ ~RKSettingsModuleRPackages() override;
void syncConfig(KConfig *config, RKConfigBase::ConfigSyncAction) override;
QList<RKSettingsModuleWidget*> createPages(QWidget *parent) override;
diff --git a/rkward/settings/rksettingsmodulewatch.cpp b/rkward/settings/rksettingsmodulewatch.cpp
index 05e7007b0..7ceafb88f 100644
--- a/rkward/settings/rksettingsmodulewatch.cpp
+++ b/rkward/settings/rksettingsmodulewatch.cpp
@@ -161,7 +161,7 @@ public:
app_filter_boxes.output->setEnabled(app_filter_boxes.input->isChecked());
sync_filter_boxes.output->setEnabled(sync_filter_boxes.input->isChecked());
}
- void applyChanges() {
+ void applyChanges() override {
RK_TRACE(SETTINGS);
RKSettingsModuleWatch::user_filter = getFilterSettings(&user_filter_boxes);
diff --git a/rkward/settings/rksettingsmodulewatch.h b/rkward/settings/rksettingsmodulewatch.h
index 2cee90c2b..0b78388b7 100644
--- a/rkward/settings/rksettingsmodulewatch.h
+++ b/rkward/settings/rksettingsmodulewatch.h
@@ -23,15 +23,13 @@ class RKSettingsModuleWatch : public RKSettingsModule
{
Q_OBJECT
public:
- RKSettingsModuleWatch(QObject *parent);
- ~RKSettingsModuleWatch();
+ explicit RKSettingsModuleWatch(QObject *parent);
+ ~RKSettingsModuleWatch() override;
void syncConfig(KConfig *config, RKConfigBase::ConfigSyncAction) override;
QList<RKSettingsModuleWidget*> createPages(QWidget *parent) override;
static constexpr PageId page_id = QLatin1String("commandlog");
- void validateGUI ();
-
static bool shouldShowInput (RCommand *command);
static bool shouldShowOutput (RCommand *command);
static bool shouldShowError (RCommand *command);
More information about the rkward-tracker
mailing list