Skip to content

Commit 8e8e1d1

Browse files
committed
GUI: Collect statistics about amount of different severities.
Add new class for collecting statistics per each error severity. Add a new tab to Statistics-dialog for these numbers.
1 parent 43dcc51 commit 8e8e1d1

9 files changed

Lines changed: 128 additions & 12 deletions

File tree

gui/gui.pro

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ HEADERS += mainwindow.h \
6969
logview.h \
7070
filelist.h \
7171
helpwindow.h \
72-
statsdialog.h
72+
statsdialog.h \
73+
checkstatistics.h
7374

7475
SOURCES += main.cpp \
7576
mainwindow.cpp\
@@ -95,7 +96,8 @@ SOURCES += main.cpp \
9596
logview.cpp \
9697
filelist.cpp \
9798
helpwindow.cpp \
98-
statsdialog.cpp
99+
statsdialog.cpp \
100+
checkstatistics.cpp
99101

100102
win32 {
101103
DEFINES += _CRT_SECURE_NO_WARNINGS

gui/mainwindow.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -860,6 +860,7 @@ void MainWindow::ShowStatistics()
860860
statsDialog.setPathSelected(mCurrentDirectory);
861861
statsDialog.setNumberOfFilesScanned(mThread->GetPreviousFilesCount());
862862
statsDialog.setScanDuration(mThread->GetPreviousScanDuration() / 1000.0);
863+
statsDialog.setStatistics(mUI.mResults->GetStatistics());
863864

864865
statsDialog.exec();
865866
}

gui/resultstree.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ ShowTypes ResultsTree::VariantToShowType(const QVariant &data)
250250
return (ShowTypes)value;
251251
}
252252

253-
ShowTypes ResultsTree::SeverityToShowType(const QString & severity) const
253+
ShowTypes ResultsTree::SeverityToShowType(const QString & severity)
254254
{
255255
if (severity == "error")
256256
return SHOW_ERRORS;

gui/resultstree.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,13 @@ class ResultsTree : public QTreeView
126126
*/
127127
void Translate();
128128

129+
/**
130+
* @brief Convert severity string to ShowTypes value
131+
* @param severity Error severity string
132+
* @return Severity converted to ShowTypes value
133+
*/
134+
static ShowTypes SeverityToShowType(const QString &severity);
135+
129136
signals:
130137
/**
131138
* @brief Signal that results have been hidden or shown
@@ -280,13 +287,6 @@ protected slots:
280287
*/
281288
ShowTypes VariantToShowType(const QVariant &data);
282289

283-
/**
284-
* @brief Convert severity string to ShowTypes value
285-
* @param severity Error severity string
286-
* @return Severity converted to ShowTypes value
287-
*/
288-
ShowTypes SeverityToShowType(const QString &severity) const;
289-
290290
/**
291291
* @brief Convert ShowType to severity string
292292
* @param type ShowType to convert

gui/resultsview.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,13 @@
3333
#include "xmlreport.h"
3434
#include "csvreport.h"
3535
#include "applicationlist.h"
36+
#include "checkstatistics.h"
3637

3738
ResultsView::ResultsView(QWidget * parent) :
3839
QWidget(parent),
3940
mErrorsFound(false),
40-
mShowNoErrorsMessage(true)
41+
mShowNoErrorsMessage(true),
42+
mStatistics(new CheckStatistics(this))
4143
{
4244
mUI.setupUi(this);
4345

@@ -67,6 +69,7 @@ void ResultsView::Clear()
6769
mUI.mTree->Clear();
6870
mUI.mDetails->setText("");
6971
mErrorsFound = false;
72+
mStatistics->Clear();
7073

7174
//Clear the progressbar
7275
mUI.mProgress->setMaximum(100);
@@ -83,6 +86,7 @@ void ResultsView::Error(const ErrorItem &item)
8386
mErrorsFound = true;
8487
mUI.mTree->AddErrorItem(item);
8588
emit GotResults();
89+
mStatistics->AddItem(ResultsTree::SeverityToShowType(item.severity));
8690
}
8791

8892
void ResultsView::ShowResults(ShowTypes type, bool show)

gui/resultsview.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class ErrorItem;
3131
class ApplicationList;
3232
class QModelIndex;
3333
class QSettings;
34+
class CheckStatistics;
3435

3536
/// @addtogroup GUI
3637
/// @{
@@ -141,6 +142,16 @@ class ResultsView : public QWidget
141142
*/
142143
void ReadErrorsXml(const QString &filename);
143144

145+
/**
146+
* @brief Return checking statistics.
147+
* @param Pointer to checking statistics.
148+
*
149+
*/
150+
CheckStatistics *GetStatistics() const
151+
{
152+
return mStatistics;
153+
}
154+
144155
signals:
145156

146157
/**
@@ -207,6 +218,9 @@ public slots:
207218

208219
Ui::ResultsView mUI;
209220

221+
CheckStatistics *mStatistics;
222+
223+
210224
private:
211225
};
212226
/// @}

gui/stats.ui

Lines changed: 82 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<enum>QTabWidget::Rounded</enum>
2121
</property>
2222
<property name="currentIndex">
23-
<number>1</number>
23+
<number>2</number>
2424
</property>
2525
<widget class="QWidget" name="mProjectTab">
2626
<attribute name="title">
@@ -223,6 +223,85 @@
223223
</item>
224224
</layout>
225225
</widget>
226+
<widget class="QWidget" name="mStatsTab">
227+
<attribute name="title">
228+
<string>Statistics</string>
229+
</attribute>
230+
<layout class="QFormLayout" name="formLayout">
231+
<item row="0" column="0">
232+
<layout class="QHBoxLayout" name="horizontalLayout_5">
233+
<item>
234+
<widget class="QLabel" name="label">
235+
<property name="text">
236+
<string>Errors:</string>
237+
</property>
238+
</widget>
239+
</item>
240+
<item>
241+
<widget class="QLabel" name="mLblErrors">
242+
<property name="text">
243+
<string>TextLabel</string>
244+
</property>
245+
</widget>
246+
</item>
247+
</layout>
248+
</item>
249+
<item row="1" column="0">
250+
<layout class="QHBoxLayout" name="horizontalLayout_2">
251+
<item>
252+
<widget class="QLabel" name="label_2">
253+
<property name="text">
254+
<string>Warnings:</string>
255+
</property>
256+
</widget>
257+
</item>
258+
<item>
259+
<widget class="QLabel" name="mLblWarnings">
260+
<property name="text">
261+
<string>TextLabel</string>
262+
</property>
263+
</widget>
264+
</item>
265+
</layout>
266+
</item>
267+
<item row="2" column="0">
268+
<layout class="QHBoxLayout" name="horizontalLayout_3">
269+
<item>
270+
<widget class="QLabel" name="label_3">
271+
<property name="text">
272+
<string>Stylistic warnings:</string>
273+
</property>
274+
</widget>
275+
</item>
276+
<item>
277+
<widget class="QLabel" name="mLblStyle">
278+
<property name="text">
279+
<string>TextLabel</string>
280+
</property>
281+
</widget>
282+
</item>
283+
</layout>
284+
</item>
285+
<item row="3" column="0">
286+
<layout class="QHBoxLayout" name="horizontalLayout_4">
287+
<item>
288+
<widget class="QLabel" name="label_4">
289+
<property name="text">
290+
<string>Performance issues:</string>
291+
</property>
292+
</widget>
293+
</item>
294+
<item>
295+
<widget class="QLabel" name="mLblPerformance">
296+
<property name="text">
297+
<string>TextLabel</string>
298+
</property>
299+
</widget>
300+
</item>
301+
</layout>
302+
</item>
303+
</layout>
304+
</widget>
226305
</widget>
227306
</item>
228307
<item>
@@ -275,6 +354,8 @@
275354
<tabstop>mPaths</tabstop>
276355
<tabstop>mIncludePaths</tabstop>
277356
<tabstop>mDefines</tabstop>
357+
<tabstop>mCopyToClipboard</tabstop>
358+
<tabstop>mButtonBox</tabstop>
278359
<tabstop>mPath</tabstop>
279360
</tabstops>
280361
<resources/>

gui/statsdialog.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "project.h"
2626
#include "projectfile.h"
2727
#include "statsdialog.h"
28+
#include "checkstatistics.h"
2829

2930
StatsDialog::StatsDialog(QWidget *parent)
3031
: QDialog(parent)
@@ -125,3 +126,10 @@ void StatsDialog::copyToClipboard()
125126
}
126127
}
127128

129+
void StatsDialog::setStatistics(const CheckStatistics *stats)
130+
{
131+
mUI.mLblErrors->setText(QString("%1").arg(stats->GetCount(SHOW_ERRORS)));
132+
mUI.mLblWarnings->setText(QString("%1").arg(stats->GetCount(SHOW_WARNINGS)));
133+
mUI.mLblStyle->setText(QString("%1").arg(stats->GetCount(SHOW_STYLE)));
134+
mUI.mLblPerformance->setText(QString("%1").arg(stats->GetCount(SHOW_PERFORMANCE)));
135+
}

gui/statsdialog.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "ui_stats.h"
2424

2525
class Project;
26+
class CheckStatistics;
2627

2728
/// @addtogroup GUI
2829
/// @{
@@ -57,6 +58,11 @@ class StatsDialog : public QDialog
5758
*/
5859
void setScanDuration(double seconds);
5960

61+
/**
62+
* @brief Sets the numbers of different error/warnings found."
63+
*/
64+
void setStatistics(const CheckStatistics *stats);
65+
6066
private slots:
6167
void copyToClipboard();
6268

0 commit comments

Comments
 (0)