CppCheck: Rework settings handling

Change-Id: Id9c9b316c5e0d39bc5fcba14951664e72d947a71
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
hjk
2023-05-15 18:00:42 +02:00
parent 77c19ae213
commit 824de3046c
8 changed files with 174 additions and 333 deletions

View File

@@ -28,6 +28,8 @@
#include <utils/qtcassert.h>
#include <utils/utilsicons.h>
using namespace Utils;
namespace Cppcheck::Internal {
class CppcheckPluginPrivate final : public QObject
@@ -36,11 +38,11 @@ public:
explicit CppcheckPluginPrivate();
CppcheckTextMarkManager marks;
CppcheckTool tool{marks, Constants::CHECK_PROGRESS_ID};
CppcheckOptions options;
CppcheckTool tool{options, marks, Constants::CHECK_PROGRESS_ID};
CppcheckTrigger trigger{marks, tool};
CppcheckOptionsPage options{tool, trigger};
DiagnosticsModel manualRunModel;
CppcheckTool manualRunTool{manualRunModel, Constants::MANUAL_CHECK_PROGRESS_ID};
CppcheckTool manualRunTool{options, manualRunModel, Constants::MANUAL_CHECK_PROGRESS_ID};
Utils::Perspective perspective{Constants::PERSPECTIVE_ID, ::Cppcheck::Tr::tr("Cppcheck")};
QAction *manualRunAction;
@@ -51,7 +53,11 @@ public:
CppcheckPluginPrivate::CppcheckPluginPrivate()
{
manualRunTool.updateOptions(tool.options());
tool.updateOptions();
connect(&options, &AspectContainer::changed, [this] {
tool.updateOptions();
trigger.recheck();
});
auto manualRunView = new DiagnosticView;
manualRunView->setModel(&manualRunModel);
@@ -103,7 +109,12 @@ void CppcheckPluginPrivate::startManualRun()
if (!project)
return;
ManualRunDialog dialog(manualRunTool.options(), project);
manualRunTool.updateOptions();
auto optionsWidget = new QWidget;
options.layouter()(optionsWidget);
ManualRunDialog dialog(optionsWidget, project);
if (dialog.exec() == ManualRunDialog::Rejected)
return;
@@ -114,7 +125,7 @@ void CppcheckPluginPrivate::startManualRun()
return;
manualRunTool.setProject(project);
manualRunTool.updateOptions(dialog.options());
manualRunTool.updateOptions();
manualRunTool.check(files);
perspective.select();
}