diff --git a/config/globalconfigpage.cpp b/config/globalconfigpage.cpp index f736c1d..989e657 100644 --- a/config/globalconfigpage.cpp +++ b/config/globalconfigpage.cpp @@ -1,62 +1,58 @@ /* This file is part of KDevelop Copyright 2017 Anton Anikin This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "globalconfigpage.h" #include "ui_globalconfigpage.h" #include "globalsettings.h" #include namespace Valgrind { GlobalConfigPage::GlobalConfigPage(KDevelop::IPlugin* plugin, QWidget* parent) : ConfigPage(plugin, GlobalSettings::self(), parent) { Ui::GlobalConfigPage ui; ui.setupUi(this); } -GlobalConfigPage::~GlobalConfigPage() -{ -} - KDevelop::ConfigPage::ConfigPageType GlobalConfigPage::configPageType() const { return KDevelop::ConfigPage::AnalyzerConfigPage; } QString GlobalConfigPage::name() const { return i18n("Valgrind"); } QString GlobalConfigPage::fullName() const { return i18n("Configure Valgrind Settings"); } QIcon GlobalConfigPage::icon() const { return QIcon::fromTheme(QStringLiteral("kdevelop")); } } diff --git a/config/globalconfigpage.h b/config/globalconfigpage.h index e4bb498..fe345da 100644 --- a/config/globalconfigpage.h +++ b/config/globalconfigpage.h @@ -1,43 +1,43 @@ /* This file is part of KDevelop Copyright 2017 Anton Anikin This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #pragma once #include namespace Valgrind { class GlobalConfigPage: public KDevelop::ConfigPage { Q_OBJECT public: GlobalConfigPage(KDevelop::IPlugin* plugin, QWidget* parent); - ~GlobalConfigPage() override; + ~GlobalConfigPage() override = default; KDevelop::ConfigPage::ConfigPageType configPageType() const override; QString name() const override; QString fullName() const override; QIcon icon() const override; }; } diff --git a/include/iconfigpage.h b/include/iconfigpage.h new file mode 100644 index 0000000..3fbdac0 --- /dev/null +++ b/include/iconfigpage.h @@ -0,0 +1 @@ +#include "tools/generic/core/iconfigpage.h" diff --git a/tools/cachegrind/configpage.cpp b/tools/cachegrind/configpage.cpp index e46f61e..65079ff 100644 --- a/tools/cachegrind/configpage.cpp +++ b/tools/cachegrind/configpage.cpp @@ -1,118 +1,111 @@ /* This file is part of KDevelop Copyright 2011 Sebastien Rannou Copyright 2011 Lionel Duc Copyright 2017 Anton Anikin This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "configpage.h" #include "ui_configpage.h" #include "settings.h" #include "tool.h" #include namespace Valgrind { namespace Cachegrind { -ConfigPage::ConfigPage(QWidget *parent) - : LaunchConfigurationPage(parent) +ConfigPage::ConfigPage(QWidget* parent) + : IConfigPage(parent) + , ui(new Ui::ConfigPage()) { - ui = new Ui::ConfigPage(); ui->setupUi(this); - connect(ui->extraParameters, &QLineEdit::textChanged, this, &ConfigPage::changed); + connectToChanged(ui->extraParameters); - connect(ui->cacheSimulation, &QCheckBox::toggled, this, &ConfigPage::changed); - connect(ui->branchSimulation, &QCheckBox::toggled, this, &ConfigPage::changed); - connect(ui->cgAnnotateParameters, &QLineEdit::textChanged, this, &ConfigPage::changed); + connectToChanged(ui->cacheSimulation); + connectToChanged(ui->branchSimulation); + connectToChanged(ui->cgAnnotateParameters); - connect(ui->cacheSimulation, &QCheckBox::toggled, this, &ConfigPage::check); - connect(ui->branchSimulation, &QCheckBox::toggled, this, &ConfigPage::check); + connectToChanged(ui->cacheSimulation); + connectToChanged(ui->branchSimulation); } -ConfigPage::~ConfigPage() -{ - delete ui; -} +ConfigPage::~ConfigPage() = default; QString ConfigPage::title() const { return Tool::self()->name(); } QIcon ConfigPage::icon() const { return QIcon(); } void ConfigPage::loadFromConfiguration(const KConfigGroup& cfg, KDevelop::IProject*) { QSignalBlocker blocker(this); Settings settings; settings.load(cfg); ui->extraParameters->setText(settings.extraParameters); ui->cacheSimulation->setChecked(settings.cacheSimulation); ui->branchSimulation->setChecked(settings.branchSimulation); ui->cgAnnotateParameters->setText(settings.cgAnnotateParameters); check(); } void ConfigPage::saveToConfiguration(KConfigGroup cfg, KDevelop::IProject*) const { Settings settings; settings.extraParameters = ui->extraParameters->text(); settings.cacheSimulation = ui->cacheSimulation->isChecked(); settings.branchSimulation = ui->branchSimulation->isChecked(); settings.cgAnnotateParameters = ui->cgAnnotateParameters->text(); settings.save(cfg); } void ConfigPage::check() { if (!ui->cacheSimulation->isChecked() && !ui->branchSimulation->isChecked()) { ui->messageWidget->setVisible(true); return; } ui->messageWidget->setVisible(false); } ConfigPageFactory::ConfigPageFactory() { } -ConfigPageFactory::~ConfigPageFactory() -{ -} - KDevelop::LaunchConfigurationPage* ConfigPageFactory::createWidget(QWidget* parent) { return new ConfigPage(parent); } } } diff --git a/tools/cachegrind/configpage.h b/tools/cachegrind/configpage.h index 9de64ae..43d5f3d 100644 --- a/tools/cachegrind/configpage.h +++ b/tools/cachegrind/configpage.h @@ -1,69 +1,64 @@ /* This file is part of KDevelop * Copyright 2011 Sebastien Rannou * Copyright 2017 Anton Anikin This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #pragma once -#include +#include "iconfigpage.h" namespace Valgrind { namespace Cachegrind { -namespace Ui -{ - -class ConfigPage; - -} +namespace Ui { class ConfigPage; } -class ConfigPage : public KDevelop::LaunchConfigurationPage +class ConfigPage : public IConfigPage { Q_OBJECT public: explicit ConfigPage(QWidget* parent = nullptr); ~ConfigPage() override; QString title() const override; QIcon icon() const override; void loadFromConfiguration(const KConfigGroup& cfg, KDevelop::IProject* project = nullptr) override; void saveToConfiguration(KConfigGroup cfg, KDevelop::IProject* project = nullptr) const override; private: void check(); - Ui::ConfigPage* ui; + QScopedPointer ui; }; class ConfigPageFactory : public KDevelop::LaunchConfigurationPageFactory { public: ConfigPageFactory(); - ~ConfigPageFactory() override; + ~ConfigPageFactory() override = default; KDevelop::LaunchConfigurationPage* createWidget(QWidget* parent) override; }; } } diff --git a/tools/callgrind/configpage.cpp b/tools/callgrind/configpage.cpp index ec6eb98..c464ed2 100644 --- a/tools/callgrind/configpage.cpp +++ b/tools/callgrind/configpage.cpp @@ -1,105 +1,97 @@ /* This file is part of KDevelop * Copyright 2011 Sebastien Rannou * Copyright 2017 Anton Anikin This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "configpage.h" #include "ui_configpage.h" #include "settings.h" #include "tool.h" #include namespace Valgrind { namespace Callgrind { ConfigPage::ConfigPage(QWidget* parent) - : LaunchConfigurationPage(parent) + : IConfigPage(parent) + , ui(new Ui::ConfigPage()) { - ui = new Ui::ConfigPage(); ui->setupUi(this); - connect(ui->extraParameters, &QLineEdit::textChanged, this, &ConfigPage::changed); - connect(ui->cacheSimulation, &QCheckBox::toggled, this, &ConfigPage::changed); - connect(ui->branchSimulation, &QCheckBox::toggled, this, &ConfigPage::changed); - connect(ui->launchKCachegrind, &QCheckBox::toggled, this, &ConfigPage::changed); - connect(ui->callgrindAnnotateParameters, &QLineEdit::textChanged, this, &ConfigPage::changed); + connectToChanged(ui->extraParameters); + connectToChanged(ui->cacheSimulation); + connectToChanged(ui->branchSimulation); + connectToChanged(ui->launchKCachegrind); + connectToChanged(ui->callgrindAnnotateParameters); } -ConfigPage::~ConfigPage() -{ - delete ui; -} +ConfigPage::~ConfigPage() = default; QString ConfigPage::title() const { return Tool::self()->name(); } QIcon ConfigPage::icon() const { return QIcon(); } void ConfigPage::loadFromConfiguration(const KConfigGroup& cfg, KDevelop::IProject*) { QSignalBlocker blocker(this); Settings settings; settings.load(cfg); ui->extraParameters->setText(settings.extraParameters); ui->cacheSimulation->setChecked(settings.cacheSimulation); ui->branchSimulation->setChecked(settings.branchSimulation); ui->launchKCachegrind->setChecked(settings.launchKCachegrind); ui->callgrindAnnotateParameters->setText(settings.callgrindAnnotateParameters); } - void ConfigPage::saveToConfiguration(KConfigGroup cfg, KDevelop::IProject*) const { Settings settings; settings.extraParameters = ui->extraParameters->text(); settings.cacheSimulation = ui->cacheSimulation->isChecked(); settings.branchSimulation = ui->branchSimulation->isChecked(); settings.launchKCachegrind = ui->launchKCachegrind->isChecked(); settings.callgrindAnnotateParameters = ui->callgrindAnnotateParameters->text(); settings.save(cfg); } ConfigPageFactory::ConfigPageFactory() { } -ConfigPageFactory::~ConfigPageFactory() -{ -} - KDevelop::LaunchConfigurationPage* ConfigPageFactory::createWidget(QWidget* parent) { return new ConfigPage(parent); } } } diff --git a/tools/callgrind/configpage.h b/tools/callgrind/configpage.h index 2f10940..23f559c 100644 --- a/tools/callgrind/configpage.h +++ b/tools/callgrind/configpage.h @@ -1,67 +1,62 @@ /* This file is part of KDevelop * Copyright 2011 Sebastien Rannou * Copyright 2017 Anton Anikin This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #pragma once -#include +#include "iconfigpage.h" namespace Valgrind { namespace Callgrind { -namespace Ui -{ - -class ConfigPage; - -} +namespace Ui { class ConfigPage; } -class ConfigPage : public KDevelop::LaunchConfigurationPage +class ConfigPage : public IConfigPage { Q_OBJECT public: explicit ConfigPage(QWidget* parent = nullptr); ~ConfigPage() override; QString title() const override; QIcon icon() const override; void loadFromConfiguration(const KConfigGroup& cfg, KDevelop::IProject* project = nullptr) override; void saveToConfiguration(KConfigGroup cfg, KDevelop::IProject* project = nullptr) const override; private: - Ui::ConfigPage* ui; + QScopedPointer ui; }; class ConfigPageFactory : public KDevelop::LaunchConfigurationPageFactory { public: ConfigPageFactory(); - ~ConfigPageFactory() override; + ~ConfigPageFactory() override = default; KDevelop::LaunchConfigurationPage* createWidget(QWidget* parent) override; }; } } diff --git a/tools/drd/configpage.cpp b/tools/drd/configpage.cpp index 08bed3b..11a734f 100644 --- a/tools/drd/configpage.cpp +++ b/tools/drd/configpage.cpp @@ -1,157 +1,148 @@ /* This file is part of KDevelop * Copyright 2017 Anton Anikin This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "configpage.h" #include "ui_configpage.h" #include "settings.h" #include "tool.h" #include namespace Valgrind { namespace DRD { ConfigPage::ConfigPage(QWidget* parent) - : LaunchConfigurationPage(parent) + : IConfigPage(parent) + , ui(new Ui::ConfigPage()) { - ui = new Ui::ConfigPage(); ui->setupUi(this); - connect(ui->joinListVol, static_cast(&QSpinBox::valueChanged), - this, &ConfigPage::changed); - connect(ui->segmentMergingInterval, static_cast(&QSpinBox::valueChanged), - this, &ConfigPage::changed); - - connect(ui->checkStackVar, &QCheckBox::toggled, this, &ConfigPage::changed); - connect(ui->firstRaceOnly, &QCheckBox::toggled, this, &ConfigPage::changed); - connect(ui->freeIsWrite, &QCheckBox::toggled, this, &ConfigPage::changed); - connect(ui->reportSignalUnlocked, &QCheckBox::toggled, this, &ConfigPage::changed); - connect(ui->segmentMerging, &QCheckBox::toggled, this, &ConfigPage::changed); - connect(ui->showConflSeg, &QCheckBox::toggled, this, &ConfigPage::changed); - connect(ui->showStackUsage, &QCheckBox::toggled, this, &ConfigPage::changed); - connect(ui->ignoreThreadCreation, &QCheckBox::toggled, this, &ConfigPage::changed); - connect(ui->showInstructionPointer, &QCheckBox::toggled, this, &ConfigPage::changed); - - connect(ui->traceAlloc, &QCheckBox::toggled, this, &ConfigPage::changed); - connect(ui->traceBarrier, &QCheckBox::toggled, this, &ConfigPage::changed); - connect(ui->traceCond, &QCheckBox::toggled, this, &ConfigPage::changed); - connect(ui->traceForkJoin, &QCheckBox::toggled, this, &ConfigPage::changed); - connect(ui->traceHb, &QCheckBox::toggled, this, &ConfigPage::changed); - connect(ui->traceMutex, &QCheckBox::toggled, this, &ConfigPage::changed); - connect(ui->traceRwlock, &QCheckBox::toggled, this, &ConfigPage::changed); - connect(ui->traceSemaphore, &QCheckBox::toggled, this, &ConfigPage::changed); + connectToChanged(ui->joinListVol); + connectToChanged(ui->segmentMergingInterval); + + connectToChanged(ui->checkStackVar); + connectToChanged(ui->firstRaceOnly); + connectToChanged(ui->freeIsWrite); + connectToChanged(ui->reportSignalUnlocked); + connectToChanged(ui->segmentMerging); + connectToChanged(ui->showConflSeg); + connectToChanged(ui->showStackUsage); + connectToChanged(ui->ignoreThreadCreation); + connectToChanged(ui->showInstructionPointer); + + connectToChanged(ui->traceAlloc); + connectToChanged(ui->traceBarrier); + connectToChanged(ui->traceCond); + connectToChanged(ui->traceForkJoin); + connectToChanged(ui->traceHb); + connectToChanged(ui->traceMutex); + connectToChanged(ui->traceRwlock); + connectToChanged(ui->traceSemaphore); ui->joinListVolLabel->setToolTip(ui->joinListVol->toolTip()); ui->segmentMergingIntervalLabel->setToolTip(ui->segmentMergingInterval->toolTip()); } -ConfigPage::~ConfigPage() -{ - delete ui; -} +ConfigPage::~ConfigPage() = default; QString ConfigPage::title() const { return Tool::self()->name(); } QIcon ConfigPage::icon() const { return QIcon(); } void ConfigPage::loadFromConfiguration(const KConfigGroup& cfg, KDevelop::IProject*) { QSignalBlocker blocker(this); Settings settings; settings.load(cfg); ui->joinListVol->setValue(settings.joinListVol); ui->segmentMergingInterval->setValue(settings.segmentMergingInterval); ui->checkStackVar->setChecked(settings.checkStackVar); ui->firstRaceOnly->setChecked(settings.firstRaceOnly); ui->freeIsWrite->setChecked(settings.freeIsWrite); ui->reportSignalUnlocked->setChecked(settings.reportSignalUnlocked); ui->segmentMerging->setChecked(settings.segmentMerging); ui->showConflSeg->setChecked(settings.showConflSeg); ui->showStackUsage->setChecked(settings.showStackUsage); ui->ignoreThreadCreation->setChecked(settings.ignoreThreadCreation); ui->showInstructionPointer->setChecked(settings.showInstructionPointer); ui->traceAlloc->setChecked(settings.traceAlloc); ui->traceBarrier->setChecked(settings.traceBarrier); ui->traceCond->setChecked(settings.traceCond); ui->traceForkJoin->setChecked(settings.traceForkJoin); ui->traceHb->setChecked(settings.traceHb); ui->traceMutex->setChecked(settings.traceMutex); ui->traceRwlock->setChecked(settings.traceRwlock); ui->traceSemaphore->setChecked(settings.traceSemaphore); } void ConfigPage::saveToConfiguration(KConfigGroup cfg, KDevelop::IProject*) const { Settings settings; settings.joinListVol = ui->joinListVol->value(); settings.segmentMergingInterval = ui->segmentMergingInterval->value(); settings.checkStackVar = ui->checkStackVar->isChecked(); settings.firstRaceOnly = ui->firstRaceOnly->isChecked(); settings.freeIsWrite = ui->freeIsWrite->isChecked(); settings.reportSignalUnlocked = ui->reportSignalUnlocked->isChecked(); settings.segmentMerging = ui->segmentMerging->isChecked(); settings.showConflSeg = ui->showConflSeg->isChecked(); settings.showStackUsage = ui->showStackUsage->isChecked(); settings.ignoreThreadCreation = ui->ignoreThreadCreation->isChecked(); settings.showInstructionPointer = ui->showInstructionPointer->isChecked(); settings.traceAlloc = ui->traceAlloc->isChecked(); settings.traceBarrier = ui->traceBarrier->isChecked(); settings.traceCond = ui->traceCond->isChecked(); settings.traceForkJoin = ui->traceForkJoin->isChecked(); settings.traceHb = ui->traceHb->isChecked(); settings.traceMutex = ui->traceMutex->isChecked(); settings.traceRwlock = ui->traceRwlock->isChecked(); settings.traceSemaphore = ui->traceSemaphore->isChecked(); settings.save(cfg); } ConfigPageFactory::ConfigPageFactory() { } -ConfigPageFactory::~ConfigPageFactory() -{ -} - KDevelop::LaunchConfigurationPage* ConfigPageFactory::createWidget(QWidget* parent) { return new ConfigPage(parent); } } } diff --git a/tools/drd/configpage.h b/tools/drd/configpage.h index 96f26c9..aaffbcb 100644 --- a/tools/drd/configpage.h +++ b/tools/drd/configpage.h @@ -1,66 +1,61 @@ /* This file is part of KDevelop * Copyright 2017 Anton Anikin This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #pragma once -#include +#include "iconfigpage.h" namespace Valgrind { namespace DRD { -namespace Ui -{ - -class ConfigPage; - -} +namespace Ui { class ConfigPage; } -class ConfigPage : public KDevelop::LaunchConfigurationPage +class ConfigPage : public IConfigPage { Q_OBJECT public: explicit ConfigPage(QWidget* parent = nullptr); ~ConfigPage() override; QString title() const override; QIcon icon() const override; void loadFromConfiguration(const KConfigGroup& cfg, KDevelop::IProject* project = nullptr) override; void saveToConfiguration(KConfigGroup cfg, KDevelop::IProject* project = nullptr) const override; private: - Ui::ConfigPage* ui; + QScopedPointer ui; }; class ConfigPageFactory : public KDevelop::LaunchConfigurationPageFactory { public: ConfigPageFactory(); - ~ConfigPageFactory() override; + ~ConfigPageFactory() override = default; KDevelop::LaunchConfigurationPage* createWidget(QWidget* parent) override; }; } } diff --git a/tools/generic/CMakeLists.txt b/tools/generic/CMakeLists.txt index c6add0f..34be6da 100644 --- a/tools/generic/CMakeLists.txt +++ b/tools/generic/CMakeLists.txt @@ -1,25 +1,26 @@ ki18n_wrap_ui(generic_UI_SRCS configpage.ui ) add_library(generic_tool STATIC + core/iconfigpage.cpp core/ijob.cpp core/isettings.cpp core/itool.cpp core/launcher.cpp core/utils.cpp core/xml/ixmljob.cpp core/xml/ixmlsettings.cpp core/xml/error.cpp core/xml/parser.cpp configpage.cpp settings.cpp ${generic_UI_SRCS} ) target_link_libraries(generic_tool kdevvalgrind_config ) diff --git a/tools/generic/configpage.cpp b/tools/generic/configpage.cpp index ae66f13..6bbb246 100644 --- a/tools/generic/configpage.cpp +++ b/tools/generic/configpage.cpp @@ -1,105 +1,96 @@ /* This file is part of KDevelop Copyright 2011 Lionel Duc Copyright 2017 Anton Anikin This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "configpage.h" #include "ui_configpage.h" #include "settings.h" #include namespace Valgrind { namespace Generic { ConfigPage::ConfigPage(QWidget* parent) - : LaunchConfigurationPage(parent) + : IConfigPage(parent) + , ui(new Ui::ConfigPage()) { - ui = new Ui::ConfigPage(); ui->setupUi(this); - connect(ui->extraParameters, &QLineEdit::textEdited, this, &ConfigPage::changed); - connect(ui->limitErrors, &QCheckBox::toggled, this, &ConfigPage::changed); - connect(ui->maxStackframe, static_cast(&QSpinBox::valueChanged), - this, &ConfigPage::changed); - connect(ui->numCallers, static_cast(&QSpinBox::valueChanged), - this, &ConfigPage::changed); + connectToChanged(ui->extraParameters); + connectToChanged(ui->limitErrors); + connectToChanged(ui->maxStackframe); + connectToChanged(ui->numCallers); ui->numCallersLabel->setToolTip(ui->numCallers->toolTip()); ui->maxStackframeLabel->setToolTip(ui->maxStackframe->toolTip()); } -ConfigPage::~ConfigPage() -{ - delete ui; -} +ConfigPage::~ConfigPage() = default; QString ConfigPage::title() const { return i18n("Valgrind Generic Settings"); } QIcon ConfigPage::icon() const { return QIcon(); } void ConfigPage::loadFromConfiguration(const KConfigGroup& cfg, KDevelop::IProject*) { QSignalBlocker blocker(this); Settings settings; settings.load(cfg); ui->extraParameters->setText(settings.extraParameters); ui->numCallers->setValue(settings.numCallers); ui->maxStackframe->setValue(settings.maxStackframe); ui->limitErrors->setChecked(settings.limitErrors); } void ConfigPage::saveToConfiguration(KConfigGroup cfg, KDevelop::IProject*) const { Settings settings; settings.extraParameters = ui->extraParameters->text(); settings.numCallers = ui->numCallers->value(); settings.maxStackframe = ui->maxStackframe->value(); settings.limitErrors = ui->limitErrors->isChecked(); settings.save(cfg); } ConfigPageFactory::ConfigPageFactory() { } -ConfigPageFactory::~ConfigPageFactory() -{ -} - KDevelop::LaunchConfigurationPage* ConfigPageFactory::createWidget(QWidget* parent) { return new ConfigPage(parent); } } } diff --git a/tools/generic/configpage.h b/tools/generic/configpage.h index ef592b4..1978b5d 100644 --- a/tools/generic/configpage.h +++ b/tools/generic/configpage.h @@ -1,68 +1,63 @@ /* This file is part of KDevelop Copyright 2011 Lionel Duc Copyright 2011 Sebastien Rannou Copyright 2017 Anton Anikin This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #pragma once -#include +#include "iconfigpage.h" namespace Valgrind { namespace Generic { -namespace Ui -{ - -class ConfigPage; - -} +namespace Ui { class ConfigPage; } -class ConfigPage : public KDevelop::LaunchConfigurationPage +class ConfigPage : public IConfigPage { Q_OBJECT public: explicit ConfigPage(QWidget* parent = nullptr); ~ConfigPage() override; QString title() const override; QIcon icon() const override; void loadFromConfiguration(const KConfigGroup& cfg, KDevelop::IProject* project = nullptr) override; void saveToConfiguration(KConfigGroup cfg, KDevelop::IProject* project = nullptr) const override; private: - Ui::ConfigPage* ui; + QScopedPointer ui; }; class ConfigPageFactory : public KDevelop::LaunchConfigurationPageFactory { public: ConfigPageFactory(); - ~ConfigPageFactory() override; + ~ConfigPageFactory() override = default; KDevelop::LaunchConfigurationPage* createWidget(QWidget* parent) override; }; } } diff --git a/tools/generic/core/iconfigpage.cpp b/tools/generic/core/iconfigpage.cpp new file mode 100644 index 0000000..9a3bd58 --- /dev/null +++ b/tools/generic/core/iconfigpage.cpp @@ -0,0 +1,57 @@ +/* This file is part of KDevelop + Copyright 2018 Anton Anikin + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; see the file COPYING. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "iconfigpage.h" + +#include +#include +#include +#include + +namespace Valgrind +{ + +IConfigPage::IConfigPage(QWidget* parent) + : LaunchConfigurationPage(parent) +{ +} + +void IConfigPage::connectToChanged(QCheckBox* box) +{ + connect(box, &QCheckBox::toggled, this, &LaunchConfigurationPage::changed); +} + +void IConfigPage::connectToChanged(QComboBox* box) +{ + connect(box, static_cast(&QComboBox::currentIndexChanged), + this, &LaunchConfigurationPage::changed); +} + +void IConfigPage::connectToChanged(QLineEdit* edit) +{ + connect(edit, &QLineEdit::textChanged, this, &LaunchConfigurationPage::changed); +} + +void IConfigPage::connectToChanged(QSpinBox* box) +{ + connect(box, static_cast(&QSpinBox::valueChanged), + this, &LaunchConfigurationPage::changed); +} + +} diff --git a/config/globalconfigpage.h b/tools/generic/core/iconfigpage.h similarity index 57% copy from config/globalconfigpage.h copy to tools/generic/core/iconfigpage.h index e4bb498..7510577 100644 --- a/config/globalconfigpage.h +++ b/tools/generic/core/iconfigpage.h @@ -1,43 +1,48 @@ /* This file is part of KDevelop - - Copyright 2017 Anton Anikin + Copyright 2018 Anton Anikin This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; see the file COPYING. If not, write to + along with this program; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #pragma once -#include +#include + +class QCheckBox; +class QComboBox; +class QLineEdit; +class QSpinBox; namespace Valgrind { -class GlobalConfigPage: public KDevelop::ConfigPage +class IConfigPage : public KDevelop::LaunchConfigurationPage { Q_OBJECT public: - GlobalConfigPage(KDevelop::IPlugin* plugin, QWidget* parent); - ~GlobalConfigPage() override; + ~IConfigPage() override = default; - KDevelop::ConfigPage::ConfigPageType configPageType() const override; +protected: + explicit IConfigPage(QWidget* parent = nullptr); - QString name() const override; - QString fullName() const override; - QIcon icon() const override; + void connectToChanged(QCheckBox* box); + void connectToChanged(QComboBox* box); + void connectToChanged(QLineEdit* edit); + void connectToChanged(QSpinBox* box); }; } diff --git a/tools/helgrind/configpage.cpp b/tools/helgrind/configpage.cpp index c06d627..68a8343 100644 --- a/tools/helgrind/configpage.cpp +++ b/tools/helgrind/configpage.cpp @@ -1,121 +1,112 @@ /* This file is part of KDevelop * Copyright 2017 Anton Anikin This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "configpage.h" #include "ui_configpage.h" #include "settings.h" #include "tool.h" #include namespace Valgrind { namespace Helgrind { ConfigPage::ConfigPage(QWidget* parent) - : LaunchConfigurationPage(parent) + : IConfigPage(parent) + , ui(new Ui::ConfigPage()) { - ui = new Ui::ConfigPage(); ui->setupUi(this); - connect(ui->extraParameters, &QLineEdit::textEdited, this, &ConfigPage::changed); - connect(ui->conflictCacheSize, static_cast(&QSpinBox::valueChanged), - this, &ConfigPage::changed); - connect(ui->historyLevel, static_cast(&QComboBox::currentIndexChanged), - this, &ConfigPage::changed); + connectToChanged(ui->extraParameters); + connectToChanged(ui->conflictCacheSize); + connectToChanged(ui->historyLevel); - connect(ui->trackLockorders, &QCheckBox::toggled, this, &ConfigPage::changed); - connect(ui->checkStackRefs, &QCheckBox::toggled, this, &ConfigPage::changed); - connect(ui->ignoreThreadCreation, &QCheckBox::toggled, this, &ConfigPage::changed); - connect(ui->freeIsWrite, &QCheckBox::toggled, this, &ConfigPage::changed); - connect(ui->showInstructionPointer, &QCheckBox::toggled, this, &ConfigPage::changed); + connectToChanged(ui->trackLockorders); + connectToChanged(ui->checkStackRefs); + connectToChanged(ui->ignoreThreadCreation); + connectToChanged(ui->freeIsWrite); + connectToChanged(ui->showInstructionPointer); ui->historyLevelLabel->setToolTip(ui->historyLevel->toolTip()); ui->conflictCacheSizeLabel->setToolTip(ui->conflictCacheSize->toolTip()); } -ConfigPage::~ConfigPage() -{ - delete ui; -} +ConfigPage::~ConfigPage() = default; QString ConfigPage::title() const { return Tool::self()->name(); } QIcon ConfigPage::icon() const { return QIcon(); } void ConfigPage::loadFromConfiguration(const KConfigGroup& cfg, KDevelop::IProject*) { QSignalBlocker blocker(this); Settings settings; settings.load(cfg); ui->extraParameters->setText(settings.extraParameters); ui->conflictCacheSize->setValue(settings.conflictCacheSize); ui->historyLevel->setCurrentText(settings.historyLevel); ui->trackLockorders->setChecked(settings.trackLockorders); ui->checkStackRefs->setChecked(settings.checkStackRefs); ui->ignoreThreadCreation->setChecked(settings.ignoreThreadCreation); ui->freeIsWrite->setChecked(settings.freeIsWrite); ui->showInstructionPointer->setChecked(settings.showInstructionPointer); } void ConfigPage::saveToConfiguration(KConfigGroup cfg, KDevelop::IProject*) const { Settings settings; settings.extraParameters = ui->extraParameters->text(); settings.conflictCacheSize = ui->conflictCacheSize->value(); settings.historyLevel = ui->historyLevel->currentText(); settings.trackLockorders = ui->trackLockorders->isChecked(); settings.checkStackRefs = ui->checkStackRefs->isChecked(); settings.ignoreThreadCreation = ui->ignoreThreadCreation->isChecked(); settings.freeIsWrite = ui->freeIsWrite->isChecked(); settings.showInstructionPointer = ui->showInstructionPointer->isChecked(); settings.save(cfg); } ConfigPageFactory::ConfigPageFactory() { } -ConfigPageFactory::~ConfigPageFactory() -{ -} - KDevelop::LaunchConfigurationPage* ConfigPageFactory::createWidget(QWidget* parent) { return new ConfigPage(parent); } } } diff --git a/tools/helgrind/configpage.h b/tools/helgrind/configpage.h index 22b72a1..b86c0b5 100644 --- a/tools/helgrind/configpage.h +++ b/tools/helgrind/configpage.h @@ -1,66 +1,61 @@ /* This file is part of KDevelop * Copyright 2017 Anton Anikin This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #pragma once -#include +#include "iconfigpage.h" namespace Valgrind { namespace Helgrind { -namespace Ui -{ - -class ConfigPage; - -} +namespace Ui { class ConfigPage; } -class ConfigPage : public KDevelop::LaunchConfigurationPage +class ConfigPage : public IConfigPage { Q_OBJECT public: explicit ConfigPage(QWidget* parent = nullptr); ~ConfigPage() override; QString title() const override; QIcon icon() const override; void loadFromConfiguration(const KConfigGroup& cfg, KDevelop::IProject* project = nullptr) override; void saveToConfiguration(KConfigGroup cfg, KDevelop::IProject* project = nullptr) const override; private: - Ui::ConfigPage* ui; + QScopedPointer ui; }; class ConfigPageFactory : public KDevelop::LaunchConfigurationPageFactory { public: ConfigPageFactory(); - ~ConfigPageFactory() override; + ~ConfigPageFactory() override = default; KDevelop::LaunchConfigurationPage* createWidget(QWidget* parent) override; }; } } diff --git a/tools/massif/configpage.cpp b/tools/massif/configpage.cpp index d6f1933..ae26593 100644 --- a/tools/massif/configpage.cpp +++ b/tools/massif/configpage.cpp @@ -1,150 +1,137 @@ /* This file is part of KDevelop * Copyright 2011 Sebastien Rannou * Copyright 2011 Lionel Duc * Copyright 2017 Anton Anikin This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "configpage.h" #include "ui_configpage.h" #include "settings.h" #include "tool.h" #include namespace Valgrind { namespace Massif { ConfigPage::ConfigPage(QWidget* parent) - : LaunchConfigurationPage(parent) + : IConfigPage(parent) + , ui(new Ui::ConfigPage()) { - ui = new Ui::ConfigPage(); ui->setupUi(this); - connect(ui->extraParameters, &QLineEdit::textEdited, this, &ConfigPage::changed); - connect(ui->launchMassifVisualizer, &QCheckBox::toggled, this, &ConfigPage::changed); - connect(ui->depth, static_cast(&QSpinBox::valueChanged), - this, &ConfigPage::changed); - connect(ui->threshold, static_cast(&QSpinBox::valueChanged), - this, &ConfigPage::changed); - connect(ui->peakInaccuracy, static_cast(&QSpinBox::valueChanged), - this, &ConfigPage::changed); - connect(ui->maxSnapshots, static_cast(&QSpinBox::valueChanged), - this, &ConfigPage::changed); - connect(ui->snapshotFreq, static_cast(&QSpinBox::valueChanged), - this, &ConfigPage::changed); - connect(ui->timeUnit, static_cast(&QComboBox::currentIndexChanged), - this, &ConfigPage::changed); - connect(ui->profileHeap, &QCheckBox::toggled, this, &ConfigPage::changed); - connect(ui->profileStack, &QCheckBox::toggled, this, &ConfigPage::changed); - connect(ui->pagesAsHeap, &QCheckBox::toggled, this, &ConfigPage::changed); - - connect(ui->profileStack, &QCheckBox::toggled, this, &ConfigPage::check); - connect(ui->pagesAsHeap, &QCheckBox::toggled, this, &ConfigPage::check); + connectToChanged(ui->extraParameters); + connectToChanged(ui->launchMassifVisualizer); + connectToChanged(ui->depth); + connectToChanged(ui->threshold); + connectToChanged(ui->peakInaccuracy); + connectToChanged(ui->maxSnapshots); + connectToChanged(ui->snapshotFreq); + connectToChanged(ui->timeUnit); + connectToChanged(ui->profileHeap); + connectToChanged(ui->profileStack); + connectToChanged(ui->pagesAsHeap); + + connectToChanged(ui->profileStack); + connectToChanged(ui->pagesAsHeap); check(); ui->timeUnitLabel->setToolTip(ui->timeUnit->toolTip()); ui->depthLabel->setToolTip(ui->depth->toolTip()); ui->thresholdLabel->setToolTip(ui->threshold->toolTip()); ui->peakInaccuracyLabel->setToolTip(ui->peakInaccuracy->toolTip()); ui->maxSnapshotsLabel->setToolTip(ui->maxSnapshots->toolTip()); ui->snapshotFreqLabel->setToolTip(ui->snapshotFreq->toolTip()); } -ConfigPage::~ConfigPage() -{ - delete ui; -} +ConfigPage::~ConfigPage() = default; QString ConfigPage::title() const { return Tool::self()->name(); } QIcon ConfigPage::icon() const { return QIcon(); } void ConfigPage::loadFromConfiguration(const KConfigGroup& cfg, KDevelop::IProject*) { QSignalBlocker blocker(this); Settings settings; settings.load(cfg); ui->extraParameters->setText(settings.extraParameters); ui->depth->setValue(settings.snapshotTreeDepth); ui->threshold->setValue(settings.threshold); ui->peakInaccuracy->setValue(settings.peakInaccuracy); ui->maxSnapshots->setValue(settings.maximumSnapshots); ui->snapshotFreq->setValue(settings.detailedSnapshotsFrequency); ui->timeUnit->setCurrentIndex(settings.timeUnit); ui->profileHeap->setChecked(settings.profileHeap); ui->profileStack->setChecked(settings.profileStack); ui->pagesAsHeap->setChecked(settings.pagesAsHeap); ui->launchMassifVisualizer->setChecked(settings.launchVisualizer); } void ConfigPage::saveToConfiguration(KConfigGroup cfg, KDevelop::IProject*) const { Settings settings; settings.extraParameters = ui->extraParameters->text(); settings.snapshotTreeDepth = ui->depth->value(); settings.threshold = ui->threshold->value(); settings.peakInaccuracy = ui->peakInaccuracy->value(); settings.maximumSnapshots = ui->maxSnapshots->value(); settings.detailedSnapshotsFrequency = ui->snapshotFreq->value(); settings.timeUnit = ui->timeUnit->currentIndex(); settings.profileHeap = ui->profileHeap->isChecked(); settings.profileStack = ui->profileStack->isChecked(); settings.pagesAsHeap = ui->pagesAsHeap->isChecked(); settings.launchVisualizer = ui->launchMassifVisualizer->isChecked(); settings.save(cfg); } void ConfigPage::check() { if (ui->profileStack->isChecked() && ui->pagesAsHeap->isChecked()) { ui->messageWidget->setVisible(true); return; } ui->messageWidget->setVisible(false); } ConfigPageFactory::ConfigPageFactory() { } -ConfigPageFactory::~ConfigPageFactory() -{ -} - KDevelop::LaunchConfigurationPage* ConfigPageFactory::createWidget(QWidget* parent) { return new ConfigPage(parent); } } } diff --git a/tools/massif/configpage.h b/tools/massif/configpage.h index ba37ea0..d43c2ed 100644 --- a/tools/massif/configpage.h +++ b/tools/massif/configpage.h @@ -1,69 +1,64 @@ /* This file is part of KDevelop * Copyright 2011 Sebastien Rannou * Copyright 2017 Anton Anikin This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #pragma once -#include +#include "iconfigpage.h" namespace Valgrind { namespace Massif { -namespace Ui -{ - -class ConfigPage; - -} +namespace Ui { class ConfigPage; } -class ConfigPage : public KDevelop::LaunchConfigurationPage +class ConfigPage : public IConfigPage { Q_OBJECT public: explicit ConfigPage(QWidget* parent = nullptr); ~ConfigPage() override; QString title() const override; QIcon icon() const override; void loadFromConfiguration(const KConfigGroup& cfg, KDevelop::IProject* project = nullptr) override; void saveToConfiguration(KConfigGroup cfg, KDevelop::IProject* project = nullptr) const override; private: void check(); - Ui::ConfigPage* ui; + QScopedPointer ui; }; class ConfigPageFactory : public KDevelop::LaunchConfigurationPageFactory { public: ConfigPageFactory(); - ~ConfigPageFactory() override; + ~ConfigPageFactory() override = default; KDevelop::LaunchConfigurationPage* createWidget(QWidget* parent) override; }; } } diff --git a/tools/memcheck/configpage.cpp b/tools/memcheck/configpage.cpp index 3b473cd..4e4d3db 100644 --- a/tools/memcheck/configpage.cpp +++ b/tools/memcheck/configpage.cpp @@ -1,226 +1,216 @@ /* This file is part of KDevelop * Copyright 2011 Mathieu Lornac * Copyright 2011 Damien Coppel * Copyright 2011 Lionel Duc * Copyright 2017 Anton Anikin This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ - #include "configpage.h" #include "ui_configpage.h" #include "debug.h" #include "settings.h" #include "tool.h" #include namespace Valgrind { namespace Memcheck { ConfigPage::ConfigPage(QWidget* parent) - : LaunchConfigurationPage(parent) + : IConfigPage(parent) + , ui(new Ui::ConfigPage()) { - ui = new Ui::ConfigPage(); ui->setupUi(this); - connect(ui->leakResolution, &QComboBox::currentTextChanged, this, &ConfigPage::changed); - connect(ui->keepStacktraces, &QComboBox::currentTextChanged, this, &ConfigPage::changed); - connect(ui->freelistVol, static_cast(&QSpinBox::valueChanged), - this, &ConfigPage::changed); - connect(ui->freelistBigBlocks, static_cast(&QSpinBox::valueChanged), - this, &ConfigPage::changed); - connect(ui->extraParameters, &QLineEdit::textEdited, this, &ConfigPage::changed); + connectToChanged(ui->leakResolution); + connectToChanged(ui->keepStacktraces); + connectToChanged(ui->freelistVol); + connectToChanged(ui->freelistBigBlocks); + connectToChanged(ui->extraParameters); - connect(ui->undefValueErrors, &QCheckBox::toggled, this, &ConfigPage::changed); - connect(ui->showMismatchedFrees, &QCheckBox::toggled, this, &ConfigPage::changed); - connect(ui->partialLoadsOk, &QCheckBox::toggled, this, &ConfigPage::changed); - connect(ui->trackOrigins, &QCheckBox::toggled, this, &ConfigPage::changed); - connect(ui->expensiveDefinednessChecks, &QCheckBox::toggled, this, &ConfigPage::changed); + connectToChanged(ui->undefValueErrors); + connectToChanged(ui->showMismatchedFrees); + connectToChanged(ui->partialLoadsOk); + connectToChanged(ui->trackOrigins); + connectToChanged(ui->expensiveDefinednessChecks); - connect(ui->showInstructionPointer, &QCheckBox::toggled, this, &ConfigPage::changed); + connectToChanged(ui->showInstructionPointer); static const QStringList leakKinds = { QStringLiteral("definite"), QStringLiteral("possible"), QStringLiteral("indirect"), QStringLiteral("reachable") }; setupMenuButton(ui->showLeakKinds, leakKinds); static const QStringList heuristics = { QStringLiteral("stdstring"), QStringLiteral("length64"), QStringLiteral("newarray"), QStringLiteral("multipleinheritance") }; setupMenuButton(ui->leakCheckHeuristics, heuristics); ui->leakResolutionLabel->setToolTip(ui->leakResolution->toolTip()); ui->showLeakKindsLabel->setToolTip(ui->showLeakKinds->toolTip()); ui->leakCheckHeuristicsLabel->setToolTip(ui->leakCheckHeuristics->toolTip()); ui->keepStacktracesLabel->setToolTip(ui->keepStacktraces->toolTip()); ui->freelistVolLabel->setToolTip(ui->freelistVol->toolTip()); ui->freelistBigBlocksLabel->setToolTip(ui->freelistBigBlocks->toolTip()); } -ConfigPage::~ConfigPage() -{ - delete ui; -} +ConfigPage::~ConfigPage() = default; QString ConfigPage::title() const { return Tool::self()->name(); } QIcon ConfigPage::icon() const { return QIcon(); } void ConfigPage::loadFromConfiguration(const KConfigGroup& cfg, KDevelop::IProject*) { QSignalBlocker blocker(this); Settings settings; settings.load(cfg); ui->leakResolution->setCurrentText(settings.leakResolution); updateMenuButton(ui->showLeakKinds, settings.showLeakKinds); updateMenuButton(ui->leakCheckHeuristics, settings.leakCheckHeuristics); ui->keepStacktraces->setCurrentText(settings.keepStacktraces); ui->freelistVol->setValue(settings.freelistVol); ui->freelistBigBlocks->setValue(settings.freelistBigBlocks); ui->extraParameters->setText(settings.extraParameters); ui->undefValueErrors->setChecked(settings.undefValueErrors); ui->showMismatchedFrees->setChecked(settings.showMismatchedFrees); ui->partialLoadsOk->setChecked(settings.partialLoadsOk); ui->trackOrigins->setChecked(settings.trackOrigins); ui->expensiveDefinednessChecks->setChecked(settings.expensiveDefinednessChecks); ui->showInstructionPointer->setChecked(settings.showInstructionPointer); } void ConfigPage::saveToConfiguration(KConfigGroup cfg, KDevelop::IProject*) const { Settings settings; settings.leakResolution = ui->leakResolution->currentText(); settings.showLeakKinds = ui->showLeakKinds->text().trimmed().remove(QChar(' ')); settings.leakCheckHeuristics = ui->leakCheckHeuristics->text().trimmed().remove(QChar(' ')); settings.keepStacktraces = ui->keepStacktraces->currentText(); settings.freelistVol = ui->freelistVol->value(); settings.freelistBigBlocks = ui->freelistBigBlocks->value(); settings.extraParameters = ui->extraParameters->text(); settings.undefValueErrors = ui->undefValueErrors->isChecked(); settings.showMismatchedFrees = ui->showMismatchedFrees->isChecked(); settings.partialLoadsOk = ui->partialLoadsOk->isChecked(); settings.trackOrigins = ui->trackOrigins->isChecked(); settings.expensiveDefinednessChecks = ui->expensiveDefinednessChecks->isChecked(); settings.showInstructionPointer = ui->showInstructionPointer->isChecked(); settings.save(cfg); } QString selectedItemsText(QMenu* menu) { Q_ASSERT(menu); QStringList selected; const auto actions = menu->actions(); for (auto action : actions) { if (action->isChecked()) { selected += action->text(); } } if (selected.isEmpty()) { return QStringLiteral("none"); } if (selected.size() == actions.size()) { return QStringLiteral("all"); } return selected.join(QStringLiteral(", ")); } void ConfigPage::setupMenuButton(QPushButton* button, const QStringList& items) { Q_ASSERT(button); auto menu = new QMenu(button); button->setMenu(menu); button->setStyleSheet(QStringLiteral("Text-align:left")); auto slot = [button, menu]() { button->setText(QChar(' ') + selectedItemsText(menu)); }; for (const QString& text : items) { auto action = new QAction(text, menu); action->setCheckable(true); action->setChecked(false); connect(action, &QAction::toggled, this, slot); connect(action, &QAction::toggled, this, &ConfigPage::changed); menu->addAction(action); } slot(); } void ConfigPage::updateMenuButton(QPushButton* button, const QString& text) { Q_ASSERT(button); auto enabled = text.split(QChar(',')); const auto actions = button->menu()->actions(); for (auto action : actions) { if (text == QStringLiteral("all")) { action->setChecked(true); } else if (text == QStringLiteral("none")) { action->setChecked(false); } else { action->setChecked(enabled.contains(action->text())); } } } ConfigPageFactory::ConfigPageFactory() { } -ConfigPageFactory::~ConfigPageFactory() -{ -} - KDevelop::LaunchConfigurationPage* ConfigPageFactory::createWidget(QWidget* parent) { return new ConfigPage(parent); } } } diff --git a/tools/memcheck/configpage.h b/tools/memcheck/configpage.h index 2b6e42b..28e65ed 100644 --- a/tools/memcheck/configpage.h +++ b/tools/memcheck/configpage.h @@ -1,74 +1,69 @@ /* This file is part of KDevelop * Copyright 2011 Mathieu Lornac * Copyright 2011 Damien Coppel * Copyright 2011 Lionel Duc * Copyright 2017 Anton Anikin This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #pragma once -#include +#include "iconfigpage.h" class QPushButton; namespace Valgrind { namespace Memcheck { -namespace Ui -{ - -class ConfigPage; - -} +namespace Ui { class ConfigPage; } -class ConfigPage : public KDevelop::LaunchConfigurationPage +class ConfigPage : public IConfigPage { Q_OBJECT public: explicit ConfigPage(QWidget* parent = nullptr); ~ConfigPage() override; QString title() const override; QIcon icon() const override; void loadFromConfiguration(const KConfigGroup& cfg, KDevelop::IProject* project = nullptr) override; void saveToConfiguration(KConfigGroup cfg, KDevelop::IProject* project = nullptr) const override; private: void setupMenuButton(QPushButton* button, const QStringList& items); void updateMenuButton(QPushButton* button, const QString& text); - Ui::ConfigPage* ui; + QScopedPointer ui; }; class ConfigPageFactory : public KDevelop::LaunchConfigurationPageFactory { public: ConfigPageFactory(); - ~ConfigPageFactory() override; + ~ConfigPageFactory() override = default; KDevelop::LaunchConfigurationPage* createWidget(QWidget* parent) override; }; } }