@@ -119,7 +119,8 @@ MainWindow::MainWindow(TranslationHandler* th, QSettings* settings) :
119119 mPlatformActions(new QActionGroup(this )),
120120 mCStandardActions(new QActionGroup(this )),
121121 mCppStandardActions(new QActionGroup(this )),
122- mSelectLanguageActions(new QActionGroup(this ))
122+ mSelectLanguageActions(new QActionGroup(this )),
123+ mSelectReportActions(new QActionGroup(this ))
123124{
124125 {
125126 Settings tempSettings;
@@ -200,6 +201,15 @@ MainWindow::MainWindow(TranslationHandler* th, QSettings* settings) :
200201 connect (mUI ->mResults , &ResultsView::suppressIds, this , &MainWindow::suppressIds);
201202 connect (mUI ->mMenuView , &QMenu::aboutToShow, this , &MainWindow::aboutToShowViewMenu);
202203
204+ // Change report type
205+ connect (mUI ->mActionReportNormal , &QAction::triggered, this , &MainWindow::changeReportType);
206+ connect (mUI ->mActionReportAutosar , &QAction::triggered, this , &MainWindow::changeReportType);
207+ connect (mUI ->mActionReportCertC , &QAction::triggered, this , &MainWindow::changeReportType);
208+ connect (mUI ->mActionReportCertCpp , &QAction::triggered, this , &MainWindow::changeReportType);
209+ connect (mUI ->mActionReportMisraC , &QAction::triggered, this , &MainWindow::changeReportType);
210+ connect (mUI ->mActionReportMisraCpp2008 , &QAction::triggered, this , &MainWindow::changeReportType);
211+ connect (mUI ->mActionReportMisraCpp2023 , &QAction::triggered, this , &MainWindow::changeReportType);
212+
203213 // File menu
204214 connect (mUI ->mActionNewProjectFile , &QAction::triggered, this , &MainWindow::newProjectFile);
205215 connect (mUI ->mActionOpenProjectFile , &QAction::triggered, this , &MainWindow::openProjectFile);
@@ -261,6 +271,14 @@ MainWindow::MainWindow(TranslationHandler* th, QSettings* settings) :
261271 connect (action, SIGNAL (triggered ()), this , SLOT (selectPlatform ()));
262272 }
263273
274+ mUI ->mActionReportNormal ->setActionGroup (mSelectReportActions );
275+ mUI ->mActionReportAutosar ->setActionGroup (mSelectReportActions );
276+ mUI ->mActionReportCertC ->setActionGroup (mSelectReportActions );
277+ mUI ->mActionReportCertCpp ->setActionGroup (mSelectReportActions );
278+ mUI ->mActionReportMisraC ->setActionGroup (mSelectReportActions );
279+ mUI ->mActionReportMisraCpp2008 ->setActionGroup (mSelectReportActions );
280+ mUI ->mActionReportMisraCpp2023 ->setActionGroup (mSelectReportActions );
281+
264282 mUI ->mActionC89 ->setActionGroup (mCStandardActions );
265283 mUI ->mActionC99 ->setActionGroup (mCStandardActions );
266284 mUI ->mActionC11 ->setActionGroup (mCStandardActions );
@@ -312,6 +330,8 @@ MainWindow::MainWindow(TranslationHandler* th, QSettings* settings) :
312330 } else {
313331 delete mUI ->mLayoutInformation ;
314332 }
333+
334+ changeReportType ();
315335}
316336
317337MainWindow::~MainWindow ()
@@ -362,6 +382,15 @@ void MainWindow::loadSettings()
362382 mSettings ->value (SETTINGS_WINDOW_HEIGHT, 600 ).toInt ());
363383 }
364384
385+ const ReportType reportType = (ReportType)mSettings ->value (SETTINGS_REPORT_TYPE, (int )ReportType::normal).toInt ();
386+ mUI ->mActionReportNormal ->setChecked (reportType <= ReportType::normal);
387+ mUI ->mActionReportAutosar ->setChecked (reportType == ReportType::autosar);
388+ mUI ->mActionReportCertC ->setChecked (reportType == ReportType::certC);
389+ mUI ->mActionReportCertCpp ->setChecked (reportType == ReportType::certCpp);
390+ mUI ->mActionReportMisraC ->setChecked (reportType == ReportType::misraC);
391+ mUI ->mActionReportMisraCpp2008 ->setChecked (reportType == ReportType::misraCpp2008);
392+ mUI ->mActionReportMisraCpp2023 ->setChecked (reportType == ReportType::misraCpp2023);
393+
365394 const ShowTypes &types = mUI ->mResults ->getShowTypes ();
366395 mUI ->mActionShowStyle ->setChecked (types.isShown (ShowTypes::ShowStyle));
367396 mUI ->mActionShowErrors ->setChecked (types.isShown (ShowTypes::ShowErrors));
@@ -444,6 +473,15 @@ void MainWindow::saveSettings() const
444473 mSettings ->setValue (SETTINGS_WINDOW_HEIGHT, size ().height ());
445474 mSettings ->setValue (SETTINGS_WINDOW_MAXIMIZED, isMaximized ());
446475
476+ const ReportType reportType = mUI ->mActionReportAutosar ->isChecked () ? ReportType::autosar :
477+ mUI ->mActionReportCertC ->isChecked () ? ReportType::certC :
478+ mUI ->mActionReportCertCpp ->isChecked () ? ReportType::certCpp :
479+ mUI ->mActionReportMisraC ->isChecked () ? ReportType::misraC :
480+ mUI ->mActionReportMisraCpp2008 ->isChecked () ? ReportType::misraCpp2008 :
481+ mUI ->mActionReportMisraCpp2023 ->isChecked () ? ReportType::misraCpp2023 :
482+ ReportType::normal;
483+ mSettings ->setValue (SETTINGS_REPORT_TYPE, (int )reportType);
484+
447485 // Show * states
448486 mSettings ->setValue (SETTINGS_SHOW_STYLE, mUI ->mActionShowStyle ->isChecked ());
449487 mSettings ->setValue (SETTINGS_SHOW_ERRORS, mUI ->mActionShowErrors ->isChecked ());
@@ -2198,3 +2236,56 @@ bool MainWindow::isCppcheckPremium() const {
21982236 return mCppcheckCfgProductName .startsWith (" Cppcheck Premium " );
21992237}
22002238
2239+ void MainWindow::changeReportType () {
2240+ const ReportType reportType = mUI ->mActionReportAutosar ->isChecked () ? ReportType::autosar :
2241+ mUI ->mActionReportCertC ->isChecked () ? ReportType::certC :
2242+ mUI ->mActionReportCertCpp ->isChecked () ? ReportType::certCpp :
2243+ mUI ->mActionReportMisraC ->isChecked () ? ReportType::misraC :
2244+ mUI ->mActionReportMisraCpp2008 ->isChecked () ? ReportType::misraCpp2008 :
2245+ mUI ->mActionReportMisraCpp2023 ->isChecked () ? ReportType::misraCpp2023 :
2246+ ReportType::normal;
2247+
2248+ mUI ->mResults ->setReportType (reportType);
2249+
2250+ auto setTextAndHint = [](QAction* a, const QString& s) {
2251+ a->setVisible (!s.isEmpty ());
2252+ a->setText (s);
2253+ a->setToolTip (s);
2254+ };
2255+
2256+ const QString showMandatory = tr (" Show Mandatory" );
2257+ const QString showRequired = tr (" Show Required" );
2258+ const QString showAdvisory = tr (" Show Advisory" );
2259+ const QString showDocument = tr (" Show Document" );
2260+
2261+ if (mUI ->mActionReportAutosar ->isChecked ()) {
2262+ setTextAndHint (mUI ->mActionShowErrors , " " );
2263+ setTextAndHint (mUI ->mActionShowWarnings , showRequired);
2264+ setTextAndHint (mUI ->mActionShowStyle , showAdvisory);
2265+ setTextAndHint (mUI ->mActionShowPortability , " " );
2266+ setTextAndHint (mUI ->mActionShowPerformance , " " );
2267+ setTextAndHint (mUI ->mActionShowInformation , " " );
2268+ } else if (mUI ->mActionReportMisraC ->isChecked () || mUI ->mActionReportMisraCpp2008 ->isChecked () || mUI ->mActionReportMisraCpp2023 ->isChecked ()) {
2269+ setTextAndHint (mUI ->mActionShowErrors , mUI ->mActionReportMisraCpp2008 ->isChecked () ? " " : showMandatory);
2270+ setTextAndHint (mUI ->mActionShowWarnings , showRequired);
2271+ setTextAndHint (mUI ->mActionShowStyle , showAdvisory);
2272+ setTextAndHint (mUI ->mActionShowPortability , " " );
2273+ setTextAndHint (mUI ->mActionShowPerformance , " " );
2274+ setTextAndHint (mUI ->mActionShowInformation , mUI ->mActionReportMisraCpp2008 ->isChecked () ? showDocument : QString ());
2275+ } else if (mUI ->mActionReportCertC ->isChecked () || mUI ->mActionReportCertCpp ->isChecked ()) {
2276+ setTextAndHint (mUI ->mActionShowErrors , tr (" Show L1" ));
2277+ setTextAndHint (mUI ->mActionShowWarnings , tr (" Show L2" ));
2278+ setTextAndHint (mUI ->mActionShowStyle , tr (" Show L3" ));
2279+ setTextAndHint (mUI ->mActionShowPortability , " " );
2280+ setTextAndHint (mUI ->mActionShowPerformance , " " );
2281+ setTextAndHint (mUI ->mActionShowInformation , " " );
2282+ } else {
2283+ setTextAndHint (mUI ->mActionShowErrors , tr (" Show errors" ));
2284+ setTextAndHint (mUI ->mActionShowWarnings , tr (" Show warnings" ));
2285+ setTextAndHint (mUI ->mActionShowStyle , tr (" Show style" ));
2286+ setTextAndHint (mUI ->mActionShowPortability , tr (" Show portability" ));
2287+ setTextAndHint (mUI ->mActionShowPerformance , tr (" Show performance" ));
2288+ setTextAndHint (mUI ->mActionShowInformation , tr (" Show information" ));
2289+ }
2290+ }
2291+
0 commit comments