2121#include < QDebug>
2222#include < QVBoxLayout>
2323#include < QFile>
24+ #include < QMessageBox>
2425
25- ResultsView::ResultsView (QSettings &settings, ApplicationList &list)
26+ ResultsView::ResultsView (QSettings &settings, ApplicationList &list) :
27+ mErrorsFound(false ),
28+ mShowNoErrorsMessage(true )
2629{
2730 QVBoxLayout *layout = new QVBoxLayout ();
2831 setLayout (layout);
@@ -35,6 +38,8 @@ ResultsView::ResultsView(QSettings &settings, ApplicationList &list)
3538 mTree = new ResultsTree (settings, list);
3639 layout->addWidget (mTree );
3740
41+ mShowNoErrorsMessage = settings.value (tr (" Show no errors message" ), true ).toBool ();
42+
3843}
3944
4045ResultsView::~ResultsView ()
@@ -46,6 +51,11 @@ ResultsView::~ResultsView()
4651void ResultsView::Clear ()
4752{
4853 mTree ->Clear ();
54+ mErrorsFound = false ;
55+
56+ // Clear the progressbar
57+ mProgress ->setMaximum (100 );
58+ mProgress ->setValue (0 );
4959}
5060
5161
@@ -57,6 +67,32 @@ void ResultsView::Progress(int value, int max)
5767 if (value >= max)
5868 {
5969 mProgress ->setVisible (false );
70+ // Should we inform user of non visible/not found errors?
71+ if (mShowNoErrorsMessage )
72+ { // Tell user that we found no errors
73+ if (!mErrorsFound )
74+ {
75+ QMessageBox msg (QMessageBox::Information,
76+ tr (" Cppcheck" ),
77+ tr (" No errors found." ),
78+ QMessageBox::Ok,
79+ this );
80+
81+ msg.exec ();
82+ } // If we have errors but they aren't visible, tell user about it
83+ else if (!mTree ->VisibleErrors ())
84+ {
85+ QString text = tr (" Errors found from the file, but they are configured to be hidden.\n " \
86+ " To toggle what kind of errors are shown, open view menu." );
87+ QMessageBox msg (QMessageBox::Information,
88+ tr (" Cppcheck" ),
89+ text,
90+ QMessageBox::Ok,
91+ this );
92+
93+ msg.exec ();
94+ }
95+ }
6096 }
6197 else
6298 {
@@ -71,6 +107,7 @@ void ResultsView::Error(const QString &file,
71107 const QVariantList &lines,
72108 const QString &id)
73109{
110+ mErrorsFound = true ;
74111 mTree ->AddErrorItem (file, severity, message, files, lines, id);
75112 emit GotResults ();
76113}
@@ -92,6 +129,13 @@ void ResultsView::ExpandAllResults()
92129
93130void ResultsView::Save (const QString &filename, bool xml)
94131{
132+ if (!mErrorsFound )
133+ {
134+ QMessageBox msgBox;
135+ msgBox.setText (" No errors found, nothing to save." );
136+ msgBox.exec ();
137+ }
138+
95139 QFile file (filename);
96140 if (!file.open (QIODevice::WriteOnly | QIODevice::Text))
97141 {
@@ -105,9 +149,11 @@ void ResultsView::Save(const QString &filename, bool xml)
105149
106150void ResultsView::UpdateSettings (bool showFullPath,
107151 bool saveFullPath,
108- bool saveAllErrors)
152+ bool saveAllErrors,
153+ bool showNoErrorsMessage)
109154{
110155 mTree ->UpdateSettings (showFullPath, saveFullPath, saveAllErrors);
156+ mShowNoErrorsMessage = showNoErrorsMessage;
111157}
112158
113159void ResultsView::SetCheckDirectory (const QString &dir)
0 commit comments