2010-09-01 08:12:24 +02:00
|
|
|
/*
|
|
|
|
* Cppcheck - A tool for static C/C++ code analysis
|
2023-01-28 10:16:34 +01:00
|
|
|
* Copyright (C) 2007-2023 Cppcheck team.
|
2010-09-01 08:12:24 +02:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2021-04-03 21:30:50 +02:00
|
|
|
|
|
|
|
#include "statsdialog.h"
|
|
|
|
|
2022-02-02 16:17:28 +01:00
|
|
|
#include "checkstatistics.h"
|
|
|
|
#include "projectfile.h"
|
2022-04-13 12:24:00 +02:00
|
|
|
#include "showtypes.h"
|
2022-02-02 16:17:28 +01:00
|
|
|
|
2022-03-19 19:54:20 +01:00
|
|
|
#include "ui_statsdialog.h"
|
|
|
|
|
2023-04-08 16:08:47 +02:00
|
|
|
#include <QApplication>
|
2022-02-02 16:17:28 +01:00
|
|
|
#include <QClipboard>
|
2017-05-28 16:16:28 +02:00
|
|
|
#include <QDate>
|
|
|
|
#include <QFileDialog>
|
|
|
|
#include <QFileInfo>
|
2023-10-09 10:07:20 +02:00
|
|
|
#include <QFont>
|
2023-04-08 16:08:47 +02:00
|
|
|
#include <QLabel>
|
|
|
|
#include <QLineEdit>
|
2022-02-02 16:17:28 +01:00
|
|
|
#include <QMimeData>
|
2023-04-08 16:08:47 +02:00
|
|
|
#include <QPageSize>
|
2023-10-09 10:07:20 +02:00
|
|
|
#include <QPlainTextEdit>
|
2022-02-02 16:17:28 +01:00
|
|
|
#include <QPrinter>
|
2023-04-08 16:08:47 +02:00
|
|
|
#include <QPushButton>
|
|
|
|
#include <QStringList>
|
2017-05-28 16:16:28 +02:00
|
|
|
#include <QTextDocument>
|
2010-10-31 12:16:55 +01:00
|
|
|
#include <QWidget>
|
2023-04-08 16:08:47 +02:00
|
|
|
#include <Qt>
|
2010-09-01 08:12:24 +02:00
|
|
|
|
2023-03-13 15:44:00 +01:00
|
|
|
#ifdef QT_CHARTS_LIB
|
2023-04-08 16:08:47 +02:00
|
|
|
#include "common.h"
|
|
|
|
|
2022-02-02 22:31:51 +01:00
|
|
|
#include <QAbstractSeries>
|
|
|
|
#include <QChartView>
|
2023-04-08 16:08:47 +02:00
|
|
|
#include <QDateTime>
|
2022-02-02 22:31:51 +01:00
|
|
|
#include <QDateTimeAxis>
|
2023-04-08 16:08:47 +02:00
|
|
|
#include <QDir>
|
|
|
|
#include <QFile>
|
|
|
|
#include <QIODevice>
|
|
|
|
#include <QLayout>
|
2022-02-02 22:31:51 +01:00
|
|
|
#include <QLineSeries>
|
2023-04-08 16:08:47 +02:00
|
|
|
#include <QList>
|
|
|
|
#include <QPainter>
|
|
|
|
#include <QPointF>
|
|
|
|
#include <QRegularExpression>
|
2022-02-02 22:31:51 +01:00
|
|
|
#include <QTextStream>
|
|
|
|
#include <QValueAxis>
|
|
|
|
|
2022-04-15 18:49:24 +02:00
|
|
|
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
2023-03-13 15:44:00 +01:00
|
|
|
QT_CHARTS_USE_NAMESPACE
|
2022-02-02 22:31:51 +01:00
|
|
|
#endif
|
2023-03-13 15:44:00 +01:00
|
|
|
|
|
|
|
static QLineSeries *numberOfReports(const QString &fileName, const QString &severity);
|
|
|
|
static QChartView *createChart(const QString &statsFile, const QString &tool);
|
2022-04-15 18:49:24 +02:00
|
|
|
#endif
|
2022-02-02 22:31:51 +01:00
|
|
|
|
2017-08-09 20:53:17 +02:00
|
|
|
static const QString CPPCHECK("cppcheck");
|
|
|
|
|
2010-09-01 08:12:24 +02:00
|
|
|
StatsDialog::StatsDialog(QWidget *parent)
|
2017-08-02 08:45:17 +02:00
|
|
|
: QDialog(parent),
|
2023-08-08 11:05:02 +02:00
|
|
|
mUI(new Ui::StatsDialog)
|
2010-09-01 08:12:24 +02:00
|
|
|
{
|
2022-03-19 19:54:20 +01:00
|
|
|
mUI->setupUi(this);
|
2010-09-01 08:12:24 +02:00
|
|
|
|
2023-08-31 18:28:47 +02:00
|
|
|
QFont font("courier");
|
|
|
|
font.setStyleHint(QFont::Monospace);
|
|
|
|
mUI->mCheckersReport->setFont(font);
|
|
|
|
|
2017-08-12 15:44:43 +02:00
|
|
|
setWindowFlags(Qt::Window);
|
|
|
|
|
2022-03-19 19:54:20 +01:00
|
|
|
connect(mUI->mCopyToClipboard, &QPushButton::pressed, this, &StatsDialog::copyToClipboard);
|
|
|
|
connect(mUI->mPDFexport, &QPushButton::pressed, this, &StatsDialog::pdfExport);
|
|
|
|
}
|
|
|
|
|
|
|
|
StatsDialog::~StatsDialog()
|
|
|
|
{
|
|
|
|
delete mUI;
|
2010-09-01 08:12:24 +02:00
|
|
|
}
|
|
|
|
|
2017-07-31 12:02:51 +02:00
|
|
|
void StatsDialog::setProject(const ProjectFile* projectFile)
|
2010-09-01 08:12:24 +02:00
|
|
|
{
|
2011-10-13 20:53:06 +02:00
|
|
|
if (projectFile) {
|
2022-03-19 19:54:20 +01:00
|
|
|
mUI->mProject->setText(projectFile->getRootPath());
|
|
|
|
mUI->mPaths->setText(projectFile->getCheckPaths().join(";"));
|
|
|
|
mUI->mIncludePaths->setText(projectFile->getIncludeDirs().join(";"));
|
|
|
|
mUI->mDefines->setText(projectFile->getDefines().join(";"));
|
|
|
|
mUI->mUndefines->setText(projectFile->getUndefines().join(";"));
|
2023-03-13 15:44:00 +01:00
|
|
|
#ifndef QT_CHARTS_LIB
|
2022-03-19 19:54:20 +01:00
|
|
|
mUI->mTabHistory->setVisible(false);
|
2017-08-09 16:31:04 +02:00
|
|
|
#else
|
2017-08-12 15:44:43 +02:00
|
|
|
QString statsFile;
|
2017-08-09 16:31:04 +02:00
|
|
|
if (!projectFile->getBuildDir().isEmpty()) {
|
|
|
|
const QString prjpath = QFileInfo(projectFile->getFilename()).absolutePath();
|
|
|
|
const QString buildDir = prjpath + '/' + projectFile->getBuildDir();
|
|
|
|
if (QDir(buildDir).exists()) {
|
2017-08-12 15:44:43 +02:00
|
|
|
statsFile = buildDir + "/statistics.txt";
|
|
|
|
}
|
|
|
|
}
|
2022-03-19 19:54:20 +01:00
|
|
|
mUI->mLblHistoryFile->setText(tr("File: ") + (statsFile.isEmpty() ? tr("No cppcheck build dir") : statsFile));
|
2017-08-12 15:44:43 +02:00
|
|
|
if (!statsFile.isEmpty()) {
|
2023-10-18 10:06:17 +02:00
|
|
|
QChartView *chartView = createChart(statsFile, "cppcheck");
|
2022-03-19 19:54:20 +01:00
|
|
|
mUI->mTabHistory->layout()->addWidget(chartView);
|
2021-04-30 16:47:02 +02:00
|
|
|
if (projectFile->getClangAnalyzer()) {
|
|
|
|
chartView = createChart(statsFile, CLANG_ANALYZER);
|
2022-03-19 19:54:20 +01:00
|
|
|
mUI->mTabHistory->layout()->addWidget(chartView);
|
2021-04-30 16:47:02 +02:00
|
|
|
}
|
2017-09-22 15:41:27 +02:00
|
|
|
if (projectFile->getClangTidy()) {
|
|
|
|
chartView = createChart(statsFile, CLANG_TIDY);
|
2022-03-19 19:54:20 +01:00
|
|
|
mUI->mTabHistory->layout()->addWidget(chartView);
|
2017-08-09 16:31:04 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2011-10-13 20:53:06 +02:00
|
|
|
} else {
|
2022-03-19 19:54:20 +01:00
|
|
|
mUI->mProject->setText(QString());
|
|
|
|
mUI->mPaths->setText(QString());
|
|
|
|
mUI->mIncludePaths->setText(QString());
|
|
|
|
mUI->mDefines->setText(QString());
|
|
|
|
mUI->mUndefines->setText(QString());
|
2010-09-01 08:12:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void StatsDialog::setPathSelected(const QString& path)
|
|
|
|
{
|
2022-03-19 19:54:20 +01:00
|
|
|
mUI->mPath->setText(path);
|
2010-09-01 08:12:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void StatsDialog::setNumberOfFilesScanned(int num)
|
|
|
|
{
|
2022-03-19 19:54:20 +01:00
|
|
|
mUI->mNumberOfFilesScanned->setText(QString::number(num));
|
2010-09-01 08:12:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void StatsDialog::setScanDuration(double seconds)
|
|
|
|
{
|
2010-12-14 09:16:26 +01:00
|
|
|
// Factor the duration into units (days/hours/minutes/seconds)
|
|
|
|
int secs = seconds;
|
2022-10-02 07:12:40 +02:00
|
|
|
const int days = secs / (24 * 60 * 60);
|
2010-12-14 09:16:26 +01:00
|
|
|
secs -= days * (24 * 60 * 60);
|
2022-10-02 07:12:40 +02:00
|
|
|
const int hours = secs / (60 * 60);
|
2010-12-14 09:16:26 +01:00
|
|
|
secs -= hours * (60 * 60);
|
2022-10-02 07:12:40 +02:00
|
|
|
const int mins = secs / 60;
|
2010-12-14 09:16:26 +01:00
|
|
|
secs -= mins * 60;
|
|
|
|
|
|
|
|
// Concatenate the two most significant units (e.g. "1 day and 3 hours")
|
|
|
|
QStringList parts;
|
|
|
|
if (days)
|
|
|
|
parts << ((days == 1) ? tr("1 day") : tr("%1 days").arg(days));
|
|
|
|
if (hours)
|
|
|
|
parts << ((hours == 1) ? tr("1 hour") : tr("%1 hours").arg(hours));
|
|
|
|
if (mins && parts.size() < 2)
|
|
|
|
parts << ((mins == 1) ? tr("1 minute") : tr("%1 minutes").arg(mins));
|
|
|
|
if (secs && parts.size() < 2)
|
|
|
|
parts << ((secs == 1) ? tr("1 second") : tr("%1 seconds").arg(secs));
|
|
|
|
|
|
|
|
// For durations < 1s, show the fraction of a second (e.g. "0.7 seconds")
|
|
|
|
if (parts.isEmpty())
|
|
|
|
parts << tr("0.%1 seconds").arg(int(10.0 *(seconds - secs)));
|
|
|
|
|
2022-03-19 19:54:20 +01:00
|
|
|
mUI->mScanDuration->setText(parts.join(tr(" and ")));
|
2010-09-01 08:12:24 +02:00
|
|
|
}
|
2017-07-28 13:43:49 +02:00
|
|
|
void StatsDialog::pdfExport()
|
2017-05-28 16:16:28 +02:00
|
|
|
{
|
|
|
|
const QString Stat = QString(
|
2021-08-07 20:51:18 +02:00
|
|
|
"<center><h1>%1 %2</h1></center>\n"
|
|
|
|
"<font color=\"red\"><h3>%3 : %4</h3></font>\n"
|
|
|
|
"<font color=\"green\"><h3>%5 : %6</h3></font>\n"
|
|
|
|
"<font color=\"orange\"><h3>%7 : %8</h3></font>\n"
|
|
|
|
"<font color=\"blue\"><h3>%9 : %10</h3></font>\n"
|
|
|
|
"<font color=\"blue\"><h3>%11 : %12</h3></font>\n"
|
|
|
|
"<font color=\"purple\"><h3>%13 : %14</h3></font>\n")
|
2023-12-27 10:36:18 +01:00
|
|
|
.arg(tr("Statistics"),
|
|
|
|
QDate::currentDate().toString("dd.MM.yyyy"),
|
|
|
|
tr("Errors"))
|
2017-08-09 20:53:17 +02:00
|
|
|
.arg(mStatistics->getCount(CPPCHECK,ShowTypes::ShowErrors))
|
2017-05-28 16:29:41 +02:00
|
|
|
.arg(tr("Warnings"))
|
2017-08-09 20:53:17 +02:00
|
|
|
.arg(mStatistics->getCount(CPPCHECK,ShowTypes::ShowWarnings))
|
2017-05-28 16:29:41 +02:00
|
|
|
.arg(tr("Style warnings"))
|
2017-08-09 20:53:17 +02:00
|
|
|
.arg(mStatistics->getCount(CPPCHECK,ShowTypes::ShowStyle))
|
2017-05-28 16:29:41 +02:00
|
|
|
.arg(tr("Portability warnings"))
|
2017-08-09 20:53:17 +02:00
|
|
|
.arg(mStatistics->getCount(CPPCHECK,ShowTypes::ShowPortability))
|
2017-05-28 16:29:41 +02:00
|
|
|
.arg(tr("Performance warnings"))
|
2017-08-09 20:53:17 +02:00
|
|
|
.arg(mStatistics->getCount(CPPCHECK,ShowTypes::ShowPerformance))
|
2017-05-28 16:29:41 +02:00
|
|
|
.arg(tr("Information messages"))
|
2017-08-09 20:53:17 +02:00
|
|
|
.arg(mStatistics->getCount(CPPCHECK,ShowTypes::ShowInformation));
|
2017-05-28 16:16:28 +02:00
|
|
|
|
2019-06-30 21:39:22 +02:00
|
|
|
QString fileName = QFileDialog::getSaveFileName((QWidget*)nullptr, tr("Export PDF"), QString(), "*.pdf");
|
2017-05-28 16:16:28 +02:00
|
|
|
if (QFileInfo(fileName).suffix().isEmpty()) {
|
|
|
|
fileName.append(".pdf");
|
|
|
|
}
|
|
|
|
QPrinter printer(QPrinter::PrinterResolution);
|
|
|
|
printer.setOutputFormat(QPrinter::PdfFormat);
|
2022-02-01 17:26:16 +01:00
|
|
|
printer.setPageSize(QPageSize(QPageSize::A4));
|
2017-05-28 16:16:28 +02:00
|
|
|
printer.setOutputFileName(fileName);
|
|
|
|
|
|
|
|
QTextDocument doc;
|
|
|
|
doc.setHtml(Stat);
|
|
|
|
// doc.setPageSize(printer.pageRect().size());
|
|
|
|
doc.print(&printer);
|
|
|
|
|
|
|
|
}
|
2010-09-01 08:12:24 +02:00
|
|
|
|
|
|
|
void StatsDialog::copyToClipboard()
|
|
|
|
{
|
|
|
|
QClipboard *clipboard = QApplication::clipboard();
|
2017-08-02 08:49:45 +02:00
|
|
|
if (!clipboard)
|
|
|
|
return;
|
2011-09-26 20:59:53 +02:00
|
|
|
|
2017-08-02 08:49:45 +02:00
|
|
|
const QString projSettings(tr("Project Settings"));
|
|
|
|
const QString project(tr("Project"));
|
|
|
|
const QString paths(tr("Paths"));
|
|
|
|
const QString incPaths(tr("Include paths"));
|
|
|
|
const QString defines(tr("Defines"));
|
2018-10-09 15:05:05 +02:00
|
|
|
const QString undefines(tr("Undefines"));
|
2017-08-02 08:49:45 +02:00
|
|
|
const QString prevScan(tr("Previous Scan"));
|
|
|
|
const QString selPath(tr("Path selected"));
|
|
|
|
const QString numFiles(tr("Number of files scanned"));
|
|
|
|
const QString duration(tr("Scan duration"));
|
|
|
|
const QString stats(tr("Statistics"));
|
|
|
|
const QString errors(tr("Errors"));
|
|
|
|
const QString warnings(tr("Warnings"));
|
|
|
|
const QString style(tr("Style warnings"));
|
|
|
|
const QString portability(tr("Portability warnings"));
|
|
|
|
const QString performance(tr("Performance warnings"));
|
|
|
|
const QString information(tr("Information messages"));
|
|
|
|
|
|
|
|
// Plain text summary
|
|
|
|
const QString settings = QString(
|
2021-08-07 20:51:18 +02:00
|
|
|
"%1\n"
|
|
|
|
"\t%2:\t%3\n"
|
|
|
|
"\t%4:\t%5\n"
|
|
|
|
"\t%6:\t%7\n"
|
|
|
|
"\t%8:\t%9\n"
|
|
|
|
"\t%10:\t%11\n"
|
|
|
|
)
|
2023-12-27 10:36:18 +01:00
|
|
|
.arg(projSettings,
|
|
|
|
project,
|
|
|
|
mUI->mProject->text(),
|
|
|
|
paths,
|
|
|
|
mUI->mPaths->text(),
|
|
|
|
incPaths,
|
|
|
|
mUI->mIncludePaths->text(),
|
|
|
|
defines)
|
|
|
|
.arg(mUI->mDefines->text(),
|
|
|
|
undefines,
|
|
|
|
mUI->mUndefines->text());
|
2017-08-02 08:49:45 +02:00
|
|
|
|
|
|
|
const QString previous = QString(
|
2021-08-07 20:51:18 +02:00
|
|
|
"%1\n"
|
|
|
|
"\t%2:\t%3\n"
|
|
|
|
"\t%4:\t%5\n"
|
|
|
|
"\t%6:\t%7\n"
|
|
|
|
)
|
2023-12-27 10:36:18 +01:00
|
|
|
.arg(prevScan,
|
|
|
|
selPath,
|
|
|
|
mUI->mPath->text(),
|
|
|
|
numFiles,
|
|
|
|
mUI->mNumberOfFilesScanned->text(),
|
|
|
|
duration,
|
|
|
|
mUI->mScanDuration->text());
|
2017-08-02 08:49:45 +02:00
|
|
|
|
|
|
|
const QString statistics = QString(
|
2021-08-07 20:51:18 +02:00
|
|
|
"%1\n"
|
|
|
|
"\t%2:\t%3\n"
|
|
|
|
"\t%4:\t%5\n"
|
|
|
|
"\t%6:\t%7\n"
|
|
|
|
"\t%8:\t%9\n"
|
|
|
|
"\t%10:\t%11\n"
|
|
|
|
"\t%12:\t%13\n"
|
|
|
|
)
|
2023-12-27 10:36:18 +01:00
|
|
|
.arg(stats,
|
|
|
|
errors)
|
2017-08-09 20:53:17 +02:00
|
|
|
.arg(mStatistics->getCount(CPPCHECK,ShowTypes::ShowErrors))
|
2017-08-02 08:49:45 +02:00
|
|
|
.arg(warnings)
|
2017-08-09 20:53:17 +02:00
|
|
|
.arg(mStatistics->getCount(CPPCHECK,ShowTypes::ShowWarnings))
|
2017-08-02 08:49:45 +02:00
|
|
|
.arg(style)
|
2017-08-09 20:53:17 +02:00
|
|
|
.arg(mStatistics->getCount(CPPCHECK,ShowTypes::ShowStyle))
|
2017-08-02 08:49:45 +02:00
|
|
|
.arg(portability)
|
2017-08-09 20:53:17 +02:00
|
|
|
.arg(mStatistics->getCount(CPPCHECK,ShowTypes::ShowPortability))
|
2017-08-02 08:49:45 +02:00
|
|
|
.arg(performance)
|
2017-08-09 20:53:17 +02:00
|
|
|
.arg(mStatistics->getCount(CPPCHECK,ShowTypes::ShowPerformance))
|
2017-08-02 08:49:45 +02:00
|
|
|
.arg(information)
|
2017-08-09 20:53:17 +02:00
|
|
|
.arg(mStatistics->getCount(CPPCHECK,ShowTypes::ShowInformation));
|
2017-08-02 08:49:45 +02:00
|
|
|
|
|
|
|
const QString textSummary = settings + previous + statistics;
|
|
|
|
|
|
|
|
// HTML summary
|
|
|
|
const QString htmlSettings = QString(
|
2021-08-07 20:51:18 +02:00
|
|
|
"<h3>%1<h3>\n"
|
|
|
|
"<table>\n"
|
|
|
|
" <tr><th>%2:</th><td>%3</td></tr>\n"
|
|
|
|
" <tr><th>%4:</th><td>%5</td></tr>\n"
|
|
|
|
" <tr><th>%6:</th><td>%7</td></tr>\n"
|
|
|
|
" <tr><th>%8:</th><td>%9</td></tr>\n"
|
|
|
|
" <tr><th>%10:</th><td>%11</td></tr>\n"
|
|
|
|
"</table>\n"
|
|
|
|
)
|
2023-12-27 10:36:18 +01:00
|
|
|
.arg(projSettings,
|
|
|
|
project,
|
|
|
|
mUI->mProject->text(),
|
|
|
|
paths,
|
|
|
|
mUI->mPaths->text(),
|
|
|
|
incPaths,
|
|
|
|
mUI->mIncludePaths->text(),
|
|
|
|
defines)
|
|
|
|
.arg(mUI->mDefines->text(),
|
|
|
|
undefines,
|
|
|
|
mUI->mUndefines->text());
|
2011-09-26 20:59:53 +02:00
|
|
|
|
2017-08-02 08:49:45 +02:00
|
|
|
const QString htmlPrevious = QString(
|
2021-08-07 20:51:18 +02:00
|
|
|
"<h3>%1</h3>\n"
|
|
|
|
"<table>\n"
|
|
|
|
" <tr><th>%2:</th><td>%3</td></tr>\n"
|
|
|
|
" <tr><th>%4:</th><td>%5</td></tr>\n"
|
|
|
|
" <tr><th>%6:</th><td>%7</td></tr>\n"
|
|
|
|
"</table>\n"
|
|
|
|
)
|
2023-12-27 10:36:18 +01:00
|
|
|
.arg(prevScan,
|
|
|
|
selPath,
|
|
|
|
mUI->mPath->text(),
|
|
|
|
numFiles,
|
|
|
|
mUI->mNumberOfFilesScanned->text(),
|
|
|
|
duration,
|
|
|
|
mUI->mScanDuration->text());
|
2011-09-26 20:59:53 +02:00
|
|
|
|
2017-08-02 08:49:45 +02:00
|
|
|
const QString htmlStatistics = QString(
|
2021-08-07 20:51:18 +02:00
|
|
|
"<h3>%1</h3>\n"
|
|
|
|
" <tr><th>%2:</th><td>%3</td></tr>\n"
|
|
|
|
" <tr><th>%4:</th><td>%5</td></tr>\n"
|
|
|
|
" <tr><th>%6:</th><td>%7</td></tr>\n"
|
|
|
|
" <tr><th>%8:</th><td>%9</td></tr>\n"
|
|
|
|
" <tr><th>%10:</th><td>%11</td></tr>\n"
|
|
|
|
" <tr><th>%12:</th><td>%13</td></tr>\n"
|
|
|
|
"</table>\n"
|
|
|
|
)
|
2023-12-27 10:36:18 +01:00
|
|
|
.arg(stats,
|
|
|
|
errors)
|
2017-08-09 20:53:17 +02:00
|
|
|
.arg(mStatistics->getCount(CPPCHECK,ShowTypes::ShowErrors))
|
2011-09-26 20:59:53 +02:00
|
|
|
.arg(warnings)
|
2017-08-09 20:53:17 +02:00
|
|
|
.arg(mStatistics->getCount(CPPCHECK,ShowTypes::ShowWarnings))
|
2011-09-26 20:59:53 +02:00
|
|
|
.arg(style)
|
2017-08-09 20:53:17 +02:00
|
|
|
.arg(mStatistics->getCount(CPPCHECK,ShowTypes::ShowStyle))
|
2011-09-26 20:59:53 +02:00
|
|
|
.arg(portability)
|
2017-08-09 20:53:17 +02:00
|
|
|
.arg(mStatistics->getCount(CPPCHECK,ShowTypes::ShowPortability))
|
2011-09-26 20:59:53 +02:00
|
|
|
.arg(performance)
|
2017-08-09 20:53:17 +02:00
|
|
|
.arg(mStatistics->getCount(CPPCHECK,ShowTypes::ShowPerformance))
|
2011-09-26 20:59:53 +02:00
|
|
|
.arg(information)
|
2017-08-09 20:53:17 +02:00
|
|
|
.arg(mStatistics->getCount(CPPCHECK,ShowTypes::ShowInformation));
|
2011-09-26 20:59:53 +02:00
|
|
|
|
2017-08-02 08:49:45 +02:00
|
|
|
const QString htmlSummary = htmlSettings + htmlPrevious + htmlStatistics;
|
2010-09-01 08:12:24 +02:00
|
|
|
|
2017-08-02 08:49:45 +02:00
|
|
|
QMimeData *mimeData = new QMimeData();
|
|
|
|
mimeData->setText(textSummary);
|
|
|
|
mimeData->setHtml(htmlSummary);
|
|
|
|
clipboard->setMimeData(mimeData);
|
2010-09-01 08:12:24 +02:00
|
|
|
}
|
|
|
|
|
2010-11-29 23:01:45 +01:00
|
|
|
void StatsDialog::setStatistics(const CheckStatistics *stats)
|
|
|
|
{
|
2017-08-02 08:45:17 +02:00
|
|
|
mStatistics = stats;
|
2023-08-31 18:28:47 +02:00
|
|
|
mUI->mLblErrors->setText(QString::number(stats->getCount(CPPCHECK,ShowTypes::ShowErrors)));
|
|
|
|
mUI->mLblWarnings->setText(QString::number(stats->getCount(CPPCHECK,ShowTypes::ShowWarnings)));
|
|
|
|
mUI->mLblStyle->setText(QString::number(stats->getCount(CPPCHECK,ShowTypes::ShowStyle)));
|
|
|
|
mUI->mLblPortability->setText(QString::number(stats->getCount(CPPCHECK,ShowTypes::ShowPortability)));
|
|
|
|
mUI->mLblPerformance->setText(QString::number(stats->getCount(CPPCHECK,ShowTypes::ShowPerformance)));
|
|
|
|
mUI->mLblInformation->setText(QString::number(stats->getCount(CPPCHECK,ShowTypes::ShowInformation)));
|
|
|
|
mUI->mLblActiveCheckers->setText(QString::number(stats->getNumberOfActiveCheckers()));
|
|
|
|
mUI->mCheckersReport->setPlainText(stats->getCheckersReport());
|
2010-12-14 09:16:26 +01:00
|
|
|
}
|
2017-08-09 16:31:04 +02:00
|
|
|
|
2023-03-13 15:44:00 +01:00
|
|
|
#ifdef QT_CHARTS_LIB
|
|
|
|
QChartView *createChart(const QString &statsFile, const QString &tool)
|
2017-08-12 15:44:43 +02:00
|
|
|
{
|
|
|
|
QChart *chart = new QChart;
|
|
|
|
chart->addSeries(numberOfReports(statsFile, tool + "-error"));
|
|
|
|
chart->addSeries(numberOfReports(statsFile, tool + "-warning"));
|
|
|
|
chart->addSeries(numberOfReports(statsFile, tool + "-style"));
|
|
|
|
chart->addSeries(numberOfReports(statsFile, tool + "-performance"));
|
|
|
|
chart->addSeries(numberOfReports(statsFile, tool + "-portability"));
|
|
|
|
|
|
|
|
QDateTimeAxis *axisX = new QDateTimeAxis;
|
|
|
|
axisX->setTitleText("Date");
|
|
|
|
chart->addAxis(axisX, Qt::AlignBottom);
|
|
|
|
|
2022-03-21 17:14:26 +01:00
|
|
|
for (QAbstractSeries *s : chart->series()) {
|
2017-08-12 15:44:43 +02:00
|
|
|
s->attachAxis(axisX);
|
|
|
|
}
|
|
|
|
|
|
|
|
QValueAxis *axisY = new QValueAxis;
|
|
|
|
axisY->setLabelFormat("%i");
|
|
|
|
axisY->setTitleText("Count");
|
|
|
|
chart->addAxis(axisY, Qt::AlignLeft);
|
|
|
|
|
|
|
|
qreal maxY = 0;
|
2022-03-21 17:14:26 +01:00
|
|
|
for (QAbstractSeries *s : chart->series()) {
|
2017-08-12 15:44:43 +02:00
|
|
|
s->attachAxis(axisY);
|
2022-12-19 20:01:12 +01:00
|
|
|
if (const QLineSeries *ls = dynamic_cast<const QLineSeries*>(s)) {
|
2022-03-21 17:14:26 +01:00
|
|
|
for (QPointF p : ls->points()) {
|
2017-08-12 15:44:43 +02:00
|
|
|
if (p.y() > maxY)
|
|
|
|
maxY = p.y();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
axisY->setMax(maxY);
|
|
|
|
|
|
|
|
//chart->createDefaultAxes();
|
|
|
|
chart->setTitle(tool);
|
|
|
|
|
|
|
|
QChartView *chartView = new QChartView(chart);
|
|
|
|
chartView->setRenderHint(QPainter::Antialiasing);
|
|
|
|
return chartView;
|
|
|
|
}
|
|
|
|
|
2023-03-13 15:44:00 +01:00
|
|
|
QLineSeries *numberOfReports(const QString &fileName, const QString &severity)
|
2017-08-09 16:31:04 +02:00
|
|
|
{
|
|
|
|
QLineSeries *series = new QLineSeries();
|
|
|
|
series->setName(severity);
|
|
|
|
QFile f(fileName);
|
|
|
|
if (f.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
|
|
|
quint64 t = 0;
|
|
|
|
QTextStream in(&f);
|
|
|
|
while (!in.atEnd()) {
|
|
|
|
QString line = in.readLine();
|
2022-04-11 19:15:42 +02:00
|
|
|
static const QRegularExpression rxdate("^\\[(\\d\\d)\\.(\\d\\d)\\.(\\d\\d\\d\\d)\\]$");
|
2022-03-23 18:16:22 +01:00
|
|
|
const QRegularExpressionMatch matchRes = rxdate.match(line);
|
|
|
|
if (matchRes.hasMatch()) {
|
2022-10-02 07:12:40 +02:00
|
|
|
const int y = matchRes.captured(3).toInt();
|
|
|
|
const int m = matchRes.captured(2).toInt();
|
|
|
|
const int d = matchRes.captured(1).toInt();
|
2017-08-09 16:31:04 +02:00
|
|
|
QDateTime dt;
|
|
|
|
dt.setDate(QDate(y,m,d));
|
|
|
|
if (t == dt.toMSecsSinceEpoch())
|
|
|
|
t += 1000;
|
|
|
|
else
|
|
|
|
t = dt.toMSecsSinceEpoch();
|
|
|
|
}
|
|
|
|
if (line.startsWith(severity + ':')) {
|
2022-10-02 07:12:40 +02:00
|
|
|
const int y = line.mid(1+severity.length()).toInt();
|
2017-08-09 16:31:04 +02:00
|
|
|
series->append(t, y);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return series;
|
|
|
|
}
|
|
|
|
#endif
|