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.
This commit is contained in:
parent
43dcc51752
commit
8e8e1d1d72
|
@ -69,7 +69,8 @@ HEADERS += mainwindow.h \
|
|||
logview.h \
|
||||
filelist.h \
|
||||
helpwindow.h \
|
||||
statsdialog.h
|
||||
statsdialog.h \
|
||||
checkstatistics.h
|
||||
|
||||
SOURCES += main.cpp \
|
||||
mainwindow.cpp\
|
||||
|
@ -95,7 +96,8 @@ SOURCES += main.cpp \
|
|||
logview.cpp \
|
||||
filelist.cpp \
|
||||
helpwindow.cpp \
|
||||
statsdialog.cpp
|
||||
statsdialog.cpp \
|
||||
checkstatistics.cpp
|
||||
|
||||
win32 {
|
||||
DEFINES += _CRT_SECURE_NO_WARNINGS
|
||||
|
|
|
@ -860,6 +860,7 @@ void MainWindow::ShowStatistics()
|
|||
statsDialog.setPathSelected(mCurrentDirectory);
|
||||
statsDialog.setNumberOfFilesScanned(mThread->GetPreviousFilesCount());
|
||||
statsDialog.setScanDuration(mThread->GetPreviousScanDuration() / 1000.0);
|
||||
statsDialog.setStatistics(mUI.mResults->GetStatistics());
|
||||
|
||||
statsDialog.exec();
|
||||
}
|
||||
|
|
|
@ -250,7 +250,7 @@ ShowTypes ResultsTree::VariantToShowType(const QVariant &data)
|
|||
return (ShowTypes)value;
|
||||
}
|
||||
|
||||
ShowTypes ResultsTree::SeverityToShowType(const QString & severity) const
|
||||
ShowTypes ResultsTree::SeverityToShowType(const QString & severity)
|
||||
{
|
||||
if (severity == "error")
|
||||
return SHOW_ERRORS;
|
||||
|
|
|
@ -126,6 +126,13 @@ public:
|
|||
*/
|
||||
void Translate();
|
||||
|
||||
/**
|
||||
* @brief Convert severity string to ShowTypes value
|
||||
* @param severity Error severity string
|
||||
* @return Severity converted to ShowTypes value
|
||||
*/
|
||||
static ShowTypes SeverityToShowType(const QString &severity);
|
||||
|
||||
signals:
|
||||
/**
|
||||
* @brief Signal that results have been hidden or shown
|
||||
|
@ -280,13 +287,6 @@ protected:
|
|||
*/
|
||||
ShowTypes VariantToShowType(const QVariant &data);
|
||||
|
||||
/**
|
||||
* @brief Convert severity string to ShowTypes value
|
||||
* @param severity Error severity string
|
||||
* @return Severity converted to ShowTypes value
|
||||
*/
|
||||
ShowTypes SeverityToShowType(const QString &severity) const;
|
||||
|
||||
/**
|
||||
* @brief Convert ShowType to severity string
|
||||
* @param type ShowType to convert
|
||||
|
|
|
@ -33,11 +33,13 @@
|
|||
#include "xmlreport.h"
|
||||
#include "csvreport.h"
|
||||
#include "applicationlist.h"
|
||||
#include "checkstatistics.h"
|
||||
|
||||
ResultsView::ResultsView(QWidget * parent) :
|
||||
QWidget(parent),
|
||||
mErrorsFound(false),
|
||||
mShowNoErrorsMessage(true)
|
||||
mShowNoErrorsMessage(true),
|
||||
mStatistics(new CheckStatistics(this))
|
||||
{
|
||||
mUI.setupUi(this);
|
||||
|
||||
|
@ -67,6 +69,7 @@ void ResultsView::Clear()
|
|||
mUI.mTree->Clear();
|
||||
mUI.mDetails->setText("");
|
||||
mErrorsFound = false;
|
||||
mStatistics->Clear();
|
||||
|
||||
//Clear the progressbar
|
||||
mUI.mProgress->setMaximum(100);
|
||||
|
@ -83,6 +86,7 @@ void ResultsView::Error(const ErrorItem &item)
|
|||
mErrorsFound = true;
|
||||
mUI.mTree->AddErrorItem(item);
|
||||
emit GotResults();
|
||||
mStatistics->AddItem(ResultsTree::SeverityToShowType(item.severity));
|
||||
}
|
||||
|
||||
void ResultsView::ShowResults(ShowTypes type, bool show)
|
||||
|
|
|
@ -31,6 +31,7 @@ class ErrorItem;
|
|||
class ApplicationList;
|
||||
class QModelIndex;
|
||||
class QSettings;
|
||||
class CheckStatistics;
|
||||
|
||||
/// @addtogroup GUI
|
||||
/// @{
|
||||
|
@ -141,6 +142,16 @@ public:
|
|||
*/
|
||||
void ReadErrorsXml(const QString &filename);
|
||||
|
||||
/**
|
||||
* @brief Return checking statistics.
|
||||
* @param Pointer to checking statistics.
|
||||
*
|
||||
*/
|
||||
CheckStatistics *GetStatistics() const
|
||||
{
|
||||
return mStatistics;
|
||||
}
|
||||
|
||||
signals:
|
||||
|
||||
/**
|
||||
|
@ -207,6 +218,9 @@ protected:
|
|||
|
||||
Ui::ResultsView mUI;
|
||||
|
||||
CheckStatistics *mStatistics;
|
||||
|
||||
|
||||
private:
|
||||
};
|
||||
/// @}
|
||||
|
|
83
gui/stats.ui
83
gui/stats.ui
|
@ -20,7 +20,7 @@
|
|||
<enum>QTabWidget::Rounded</enum>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>1</number>
|
||||
<number>2</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="mProjectTab">
|
||||
<attribute name="title">
|
||||
|
@ -223,6 +223,85 @@
|
|||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="mStatsTab">
|
||||
<attribute name="title">
|
||||
<string>Statistics</string>
|
||||
</attribute>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Errors:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="mLblErrors">
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Warnings:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="mLblWarnings">
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Stylistic warnings:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="mLblStyle">
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Performance issues:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="mLblPerformance">
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
|
@ -275,6 +354,8 @@
|
|||
<tabstop>mPaths</tabstop>
|
||||
<tabstop>mIncludePaths</tabstop>
|
||||
<tabstop>mDefines</tabstop>
|
||||
<tabstop>mCopyToClipboard</tabstop>
|
||||
<tabstop>mButtonBox</tabstop>
|
||||
<tabstop>mPath</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "project.h"
|
||||
#include "projectfile.h"
|
||||
#include "statsdialog.h"
|
||||
#include "checkstatistics.h"
|
||||
|
||||
StatsDialog::StatsDialog(QWidget *parent)
|
||||
: QDialog(parent)
|
||||
|
@ -125,3 +126,10 @@ void StatsDialog::copyToClipboard()
|
|||
}
|
||||
}
|
||||
|
||||
void StatsDialog::setStatistics(const CheckStatistics *stats)
|
||||
{
|
||||
mUI.mLblErrors->setText(QString("%1").arg(stats->GetCount(SHOW_ERRORS)));
|
||||
mUI.mLblWarnings->setText(QString("%1").arg(stats->GetCount(SHOW_WARNINGS)));
|
||||
mUI.mLblStyle->setText(QString("%1").arg(stats->GetCount(SHOW_STYLE)));
|
||||
mUI.mLblPerformance->setText(QString("%1").arg(stats->GetCount(SHOW_PERFORMANCE)));
|
||||
}
|
|
@ -23,6 +23,7 @@
|
|||
#include "ui_stats.h"
|
||||
|
||||
class Project;
|
||||
class CheckStatistics;
|
||||
|
||||
/// @addtogroup GUI
|
||||
/// @{
|
||||
|
@ -57,6 +58,11 @@ public:
|
|||
*/
|
||||
void setScanDuration(double seconds);
|
||||
|
||||
/**
|
||||
* @brief Sets the numbers of different error/warnings found."
|
||||
*/
|
||||
void setStatistics(const CheckStatistics *stats);
|
||||
|
||||
private slots:
|
||||
void copyToClipboard();
|
||||
|
||||
|
|
Loading…
Reference in New Issue