Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #12410 (GUI: show results customized for misra/cert/autosar) #6556

Merged
merged 1 commit into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions gui/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@
#define SETTINGS_TOOLBARS_VIEW_SHOW "Toolbars/ShowView"
#define SETTINGS_TOOLBARS_FILTER_SHOW "Toolbars/ShowFilter"

// Report type
#define SETTINGS_REPORT_TYPE "Report type"
enum class ReportType : std::uint8_t { normal=0, autosar=1, certC=2, certCpp=3, misraC=4, misraCpp2008=5, misraCpp2023=6 };

// Show * states
#define SETTINGS_SHOW_STYLE "Show style"
#define SETTINGS_SHOW_ERRORS "Show errors"
Expand Down
2 changes: 2 additions & 0 deletions gui/erroritem.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ class ErrorItem {
QList<QErrorPathItem> errorPath;
QString symbolNames;
QString remark;
QString classification; // misra/cert/etc: classification/level
QString guideline; // misra/cert/etc: guideline/rule

// Special GUI properties
QString sinceDate;
Expand Down
93 changes: 92 additions & 1 deletion gui/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ MainWindow::MainWindow(TranslationHandler* th, QSettings* settings) :
mPlatformActions(new QActionGroup(this)),
mCStandardActions(new QActionGroup(this)),
mCppStandardActions(new QActionGroup(this)),
mSelectLanguageActions(new QActionGroup(this))
mSelectLanguageActions(new QActionGroup(this)),
mSelectReportActions(new QActionGroup(this))
{
{
Settings tempSettings;
Expand Down Expand Up @@ -200,6 +201,15 @@ MainWindow::MainWindow(TranslationHandler* th, QSettings* settings) :
connect(mUI->mResults, &ResultsView::suppressIds, this, &MainWindow::suppressIds);
connect(mUI->mMenuView, &QMenu::aboutToShow, this, &MainWindow::aboutToShowViewMenu);

// Change report type
connect(mUI->mActionReportNormal, &QAction::triggered, this, &MainWindow::changeReportType);
connect(mUI->mActionReportAutosar, &QAction::triggered, this, &MainWindow::changeReportType);
connect(mUI->mActionReportCertC, &QAction::triggered, this, &MainWindow::changeReportType);
connect(mUI->mActionReportCertCpp, &QAction::triggered, this, &MainWindow::changeReportType);
connect(mUI->mActionReportMisraC, &QAction::triggered, this, &MainWindow::changeReportType);
connect(mUI->mActionReportMisraCpp2008, &QAction::triggered, this, &MainWindow::changeReportType);
connect(mUI->mActionReportMisraCpp2023, &QAction::triggered, this, &MainWindow::changeReportType);

// File menu
connect(mUI->mActionNewProjectFile, &QAction::triggered, this, &MainWindow::newProjectFile);
connect(mUI->mActionOpenProjectFile, &QAction::triggered, this, &MainWindow::openProjectFile);
Expand Down Expand Up @@ -261,6 +271,14 @@ MainWindow::MainWindow(TranslationHandler* th, QSettings* settings) :
connect(action, SIGNAL(triggered()), this, SLOT(selectPlatform()));
}

mUI->mActionReportNormal->setActionGroup(mSelectReportActions);
mUI->mActionReportAutosar->setActionGroup(mSelectReportActions);
mUI->mActionReportCertC->setActionGroup(mSelectReportActions);
mUI->mActionReportCertCpp->setActionGroup(mSelectReportActions);
mUI->mActionReportMisraC->setActionGroup(mSelectReportActions);
mUI->mActionReportMisraCpp2008->setActionGroup(mSelectReportActions);
mUI->mActionReportMisraCpp2023->setActionGroup(mSelectReportActions);

mUI->mActionC89->setActionGroup(mCStandardActions);
mUI->mActionC99->setActionGroup(mCStandardActions);
mUI->mActionC11->setActionGroup(mCStandardActions);
Expand Down Expand Up @@ -312,6 +330,8 @@ MainWindow::MainWindow(TranslationHandler* th, QSettings* settings) :
} else {
delete mUI->mLayoutInformation;
}

changeReportType();
}

MainWindow::~MainWindow()
Expand Down Expand Up @@ -362,6 +382,15 @@ void MainWindow::loadSettings()
mSettings->value(SETTINGS_WINDOW_HEIGHT, 600).toInt());
}

const ReportType reportType = (ReportType)mSettings->value(SETTINGS_REPORT_TYPE, (int)ReportType::normal).toInt();
mUI->mActionReportNormal->setChecked(reportType <= ReportType::normal);
mUI->mActionReportAutosar->setChecked(reportType == ReportType::autosar);
mUI->mActionReportCertC->setChecked(reportType == ReportType::certC);
mUI->mActionReportCertCpp->setChecked(reportType == ReportType::certCpp);
mUI->mActionReportMisraC->setChecked(reportType == ReportType::misraC);
mUI->mActionReportMisraCpp2008->setChecked(reportType == ReportType::misraCpp2008);
mUI->mActionReportMisraCpp2023->setChecked(reportType == ReportType::misraCpp2023);

const ShowTypes &types = mUI->mResults->getShowTypes();
mUI->mActionShowStyle->setChecked(types.isShown(ShowTypes::ShowStyle));
mUI->mActionShowErrors->setChecked(types.isShown(ShowTypes::ShowErrors));
Expand Down Expand Up @@ -444,6 +473,15 @@ void MainWindow::saveSettings() const
mSettings->setValue(SETTINGS_WINDOW_HEIGHT, size().height());
mSettings->setValue(SETTINGS_WINDOW_MAXIMIZED, isMaximized());

const ReportType reportType = mUI->mActionReportAutosar->isChecked() ? ReportType::autosar :
mUI->mActionReportCertC->isChecked() ? ReportType::certC :
mUI->mActionReportCertCpp->isChecked() ? ReportType::certCpp :
mUI->mActionReportMisraC->isChecked() ? ReportType::misraC :
mUI->mActionReportMisraCpp2008->isChecked() ? ReportType::misraCpp2008 :
mUI->mActionReportMisraCpp2023->isChecked() ? ReportType::misraCpp2023 :
ReportType::normal;
mSettings->setValue(SETTINGS_REPORT_TYPE, (int)reportType);

// Show * states
mSettings->setValue(SETTINGS_SHOW_STYLE, mUI->mActionShowStyle->isChecked());
mSettings->setValue(SETTINGS_SHOW_ERRORS, mUI->mActionShowErrors->isChecked());
Expand Down Expand Up @@ -2198,3 +2236,56 @@ bool MainWindow::isCppcheckPremium() const {
return mCppcheckCfgProductName.startsWith("Cppcheck Premium ");
}

void MainWindow::changeReportType() {
const ReportType reportType = mUI->mActionReportAutosar->isChecked() ? ReportType::autosar :
mUI->mActionReportCertC->isChecked() ? ReportType::certC :
mUI->mActionReportCertCpp->isChecked() ? ReportType::certCpp :
mUI->mActionReportMisraC->isChecked() ? ReportType::misraC :
mUI->mActionReportMisraCpp2008->isChecked() ? ReportType::misraCpp2008 :
mUI->mActionReportMisraCpp2023->isChecked() ? ReportType::misraCpp2023 :
ReportType::normal;

mUI->mResults->setReportType(reportType);

auto setTextAndHint = [](QAction* a, const QString& s) {
a->setVisible(!s.isEmpty());
a->setText(s);
a->setToolTip(s);
};

const QString showMandatory = tr("Show Mandatory");
const QString showRequired = tr("Show Required");
const QString showAdvisory = tr("Show Advisory");
const QString showDocument = tr("Show Document");

if (mUI->mActionReportAutosar->isChecked()) {
setTextAndHint(mUI->mActionShowErrors, "");
setTextAndHint(mUI->mActionShowWarnings, showRequired);
setTextAndHint(mUI->mActionShowStyle, showAdvisory);
setTextAndHint(mUI->mActionShowPortability, "");
setTextAndHint(mUI->mActionShowPerformance, "");
setTextAndHint(mUI->mActionShowInformation, "");
} else if (mUI->mActionReportMisraC->isChecked() || mUI->mActionReportMisraCpp2008->isChecked() || mUI->mActionReportMisraCpp2023->isChecked()) {
setTextAndHint(mUI->mActionShowErrors, mUI->mActionReportMisraCpp2008->isChecked() ? "" : showMandatory);
setTextAndHint(mUI->mActionShowWarnings, showRequired);
setTextAndHint(mUI->mActionShowStyle, showAdvisory);
setTextAndHint(mUI->mActionShowPortability, "");
setTextAndHint(mUI->mActionShowPerformance, "");
setTextAndHint(mUI->mActionShowInformation, mUI->mActionReportMisraCpp2008->isChecked() ? showDocument : QString());
} else if (mUI->mActionReportCertC->isChecked() || mUI->mActionReportCertCpp->isChecked()) {
setTextAndHint(mUI->mActionShowErrors, tr("Show L1"));
setTextAndHint(mUI->mActionShowWarnings, tr("Show L2"));
setTextAndHint(mUI->mActionShowStyle, tr("Show L3"));
setTextAndHint(mUI->mActionShowPortability, "");
setTextAndHint(mUI->mActionShowPerformance, "");
setTextAndHint(mUI->mActionShowInformation, "");
} else {
setTextAndHint(mUI->mActionShowErrors, tr("Show errors"));
setTextAndHint(mUI->mActionShowWarnings, tr("Show warnings"));
setTextAndHint(mUI->mActionShowStyle, tr("Show style"));
setTextAndHint(mUI->mActionShowPortability, tr("Show portability"));
setTextAndHint(mUI->mActionShowPerformance, tr("Show performance"));
setTextAndHint(mUI->mActionShowInformation, tr("Show information"));
}
}

5 changes: 5 additions & 0 deletions gui/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,8 @@ private slots:
void replyFinished(QNetworkReply *reply);

void hideInformation();

void changeReportType();
private:

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

/** @brief GUI actions for selecting report. */
QActionGroup *mSelectReportActions;

/**
* @brief Are we exiting the cppcheck?
* If this is true then the cppcheck is waiting for check threads to exit
Expand Down
75 changes: 75 additions & 0 deletions gui/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,22 @@
<addaction name="mActionToolBarView"/>
<addaction name="mActionToolBarFilter"/>
</widget>
<widget class="QMenu" name="menuReport">
<property name="title">
<string>Report</string>
</property>
<addaction name="mActionReportNormal"/>
<addaction name="mActionReportAutosar"/>
<addaction name="mActionReportCertC"/>
<addaction name="mActionReportCertCpp"/>
<addaction name="mActionReportMisraC"/>
<addaction name="mActionReportMisraCpp2008"/>
<addaction name="mActionReportMisraCpp2023"/>
</widget>
<addaction name="mMenuToolbars"/>
<addaction name="separator"/>
<addaction name="menuReport"/>
<addaction name="separator"/>
<addaction name="mActionShowErrors"/>
<addaction name="mActionShowWarnings"/>
<addaction name="mActionShowStyle"/>
Expand Down Expand Up @@ -950,6 +964,67 @@
<string>Compliance report...</string>
</property>
</action>
<action name="actionReport">
<property name="text">
<string>Report</string>
</property>
</action>
<action name="mActionReportNormal">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Normal</string>
</property>
</action>
<action name="mActionReportMisraC">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Misra C</string>
</property>
</action>
<action name="mActionReportMisraCpp2008">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Misra C++ 2008</string>
</property>
</action>
<action name="mActionReportCertC">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Cert C</string>
</property>
</action>
<action name="mActionReportCertCpp">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Cert C++</string>
</property>
</action>
<action name="mActionReportMisraCpp2023">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Misra C++ 2023</string>
</property>
</action>
<action name="mActionReportAutosar">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Autosar</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>
Expand Down
Loading
Loading