Skip to content

Commit 523a4a6

Browse files
committed
GUI: Add files I forgot to add when committing statistic patches.
1 parent 57a61a4 commit 523a4a6

File tree

2 files changed

+149
-0
lines changed

2 files changed

+149
-0
lines changed

gui/checkstatistics.cpp

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/*
2+
* Cppcheck - A tool for static C/C++ code analysis
3+
* Copyright (C) 2007-2010 Daniel Marjamäki and Cppcheck team.
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
*/
18+
19+
#include <QDebug>
20+
#include "common.h"
21+
#include "checkstatistics.h"
22+
23+
CheckStatistics::CheckStatistics(QObject *parent)
24+
: QObject(parent)
25+
{
26+
Clear();
27+
}
28+
29+
void CheckStatistics::AddItem(ShowTypes type)
30+
{
31+
switch (type)
32+
{
33+
case SHOW_STYLE:
34+
mStyle++;
35+
break;
36+
case SHOW_WARNINGS:
37+
mWarning++;
38+
break;
39+
case SHOW_PERFORMANCE:
40+
mPerformance++;
41+
break;
42+
case SHOW_ERRORS:
43+
mError++;
44+
break;
45+
case SHOW_NONE:
46+
default:
47+
qDebug() << "Unknown error type - not added to statistics.";
48+
break;
49+
}
50+
}
51+
52+
void CheckStatistics::Clear()
53+
{
54+
mStyle = 0;
55+
mWarning = 0;
56+
mPerformance = 0;
57+
mError = 0;
58+
}
59+
60+
unsigned CheckStatistics::GetCount(ShowTypes type) const
61+
{
62+
unsigned count = 0;
63+
switch (type)
64+
{
65+
case SHOW_STYLE:
66+
count = mStyle;
67+
break;
68+
case SHOW_WARNINGS:
69+
count = mWarning;
70+
break;
71+
case SHOW_PERFORMANCE:
72+
count = mPerformance;
73+
break;
74+
case SHOW_ERRORS:
75+
count = mError;
76+
break;
77+
case SHOW_NONE:
78+
default:
79+
qDebug() << "Unknown error type - returning zero statistices.";
80+
break;
81+
}
82+
return count;
83+
}

gui/checkstatistics.h

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*
2+
* Cppcheck - A tool for static C/C++ code analysis
3+
* Copyright (C) 2007-2010 Daniel Marjamäki and Cppcheck team.
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
*/
18+
19+
#ifndef CHECKSTATISTICS_H
20+
#define CHECKSTATISTICS_H
21+
22+
#include <QObject>
23+
#include "common.h"
24+
25+
/// @addtogroup GUI
26+
/// @{
27+
28+
/**
29+
* A class for check statistics.
30+
*/
31+
class CheckStatistics : public QObject
32+
{
33+
public:
34+
CheckStatistics(QObject *parent = NULL);
35+
36+
/**
37+
* @brief Add new checked item to statistics.
38+
*
39+
* @param type Type of the item to add.
40+
*/
41+
void AddItem(ShowTypes type);
42+
43+
/**
44+
* @brief Clear the statistics.
45+
*
46+
*/
47+
void Clear();
48+
49+
/**
50+
* @brief Return statistics for given type.
51+
*
52+
* @param type Type for which the statistics are returned.
53+
* @return Number of items of given type.
54+
*/
55+
unsigned GetCount(ShowTypes type) const;
56+
57+
private:
58+
unsigned mStyle;
59+
unsigned mWarning;
60+
unsigned mPerformance;
61+
unsigned mError;
62+
};
63+
64+
/// @}
65+
66+
#endif // CHECKSTATISTICS_H

0 commit comments

Comments
 (0)