Skip to content

Commit 29adee8

Browse files
authored
Fix #12410 (GUI: show results customized for misra/cert/autosar) (danmar#6556)
1 parent fc9bd28 commit 29adee8

File tree

15 files changed

+1672
-134
lines changed

15 files changed

+1672
-134
lines changed

gui/common.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@
4848
#define SETTINGS_TOOLBARS_VIEW_SHOW "Toolbars/ShowView"
4949
#define SETTINGS_TOOLBARS_FILTER_SHOW "Toolbars/ShowFilter"
5050

51+
// Report type
52+
#define SETTINGS_REPORT_TYPE "Report type"
53+
enum class ReportType : std::uint8_t { normal=0, autosar=1, certC=2, certCpp=3, misraC=4, misraCpp2008=5, misraCpp2023=6 };
54+
5155
// Show * states
5256
#define SETTINGS_SHOW_STYLE "Show style"
5357
#define SETTINGS_SHOW_ERRORS "Show errors"

gui/erroritem.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ class ErrorItem {
9292
QList<QErrorPathItem> errorPath;
9393
QString symbolNames;
9494
QString remark;
95+
QString classification; // misra/cert/etc: classification/level
96+
QString guideline; // misra/cert/etc: guideline/rule
9597

9698
// Special GUI properties
9799
QString sinceDate;

gui/mainwindow.cpp

Lines changed: 92 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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

317337
MainWindow::~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+

gui/mainwindow.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,8 @@ private slots:
241241
void replyFinished(QNetworkReply *reply);
242242

243243
void hideInformation();
244+
245+
void changeReportType();
244246
private:
245247

246248
bool isCppcheckPremium() const;
@@ -462,6 +464,9 @@ private slots:
462464
/** @brief GUI actions for selecting language. */
463465
QActionGroup *mSelectLanguageActions;
464466

467+
/** @brief GUI actions for selecting report. */
468+
QActionGroup *mSelectReportActions;
469+
465470
/**
466471
* @brief Are we exiting the cppcheck?
467472
* If this is true then the cppcheck is waiting for check threads to exit

gui/mainwindow.ui

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,22 @@
159159
<addaction name="mActionToolBarView"/>
160160
<addaction name="mActionToolBarFilter"/>
161161
</widget>
162+
<widget class="QMenu" name="menuReport">
163+
<property name="title">
164+
<string>Report</string>
165+
</property>
166+
<addaction name="mActionReportNormal"/>
167+
<addaction name="mActionReportAutosar"/>
168+
<addaction name="mActionReportCertC"/>
169+
<addaction name="mActionReportCertCpp"/>
170+
<addaction name="mActionReportMisraC"/>
171+
<addaction name="mActionReportMisraCpp2008"/>
172+
<addaction name="mActionReportMisraCpp2023"/>
173+
</widget>
162174
<addaction name="mMenuToolbars"/>
163175
<addaction name="separator"/>
176+
<addaction name="menuReport"/>
177+
<addaction name="separator"/>
164178
<addaction name="mActionShowErrors"/>
165179
<addaction name="mActionShowWarnings"/>
166180
<addaction name="mActionShowStyle"/>
@@ -950,6 +964,67 @@
950964
<string>Compliance report...</string>
951965
</property>
952966
</action>
967+
<action name="actionReport">
968+
<property name="text">
969+
<string>Report</string>
970+
</property>
971+
</action>
972+
<action name="mActionReportNormal">
973+
<property name="checkable">
974+
<bool>true</bool>
975+
</property>
976+
<property name="text">
977+
<string>Normal</string>
978+
</property>
979+
</action>
980+
<action name="mActionReportMisraC">
981+
<property name="checkable">
982+
<bool>true</bool>
983+
</property>
984+
<property name="text">
985+
<string>Misra C</string>
986+
</property>
987+
</action>
988+
<action name="mActionReportMisraCpp2008">
989+
<property name="checkable">
990+
<bool>true</bool>
991+
</property>
992+
<property name="text">
993+
<string>Misra C++ 2008</string>
994+
</property>
995+
</action>
996+
<action name="mActionReportCertC">
997+
<property name="checkable">
998+
<bool>true</bool>
999+
</property>
1000+
<property name="text">
1001+
<string>Cert C</string>
1002+
</property>
1003+
</action>
1004+
<action name="mActionReportCertCpp">
1005+
<property name="checkable">
1006+
<bool>true</bool>
1007+
</property>
1008+
<property name="text">
1009+
<string>Cert C++</string>
1010+
</property>
1011+
</action>
1012+
<action name="mActionReportMisraCpp2023">
1013+
<property name="checkable">
1014+
<bool>true</bool>
1015+
</property>
1016+
<property name="text">
1017+
<string>Misra C++ 2023</string>
1018+
</property>
1019+
</action>
1020+
<action name="mActionReportAutosar">
1021+
<property name="checkable">
1022+
<bool>true</bool>
1023+
</property>
1024+
<property name="text">
1025+
<string>Autosar</string>
1026+
</property>
1027+
</action>
9531028
</widget>
9541029
<customwidgets>
9551030
<customwidget>

0 commit comments

Comments
 (0)