Skip to content

Commit 0b8af4f

Browse files
authored
some minor QtCharts usage cleanups (#4890)
1 parent 61e8b84 commit 0b8af4f

9 files changed

Lines changed: 20 additions & 39 deletions

File tree

.github/workflows/CI-unixish.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -459,9 +459,9 @@ jobs:
459459
./cppcheck $selfcheck_options --cppcheck-build-dir=b1 --addon=naming.json -DCHECK_INTERNAL cli lib || ec=1
460460
# check gui with qt settings
461461
mkdir b2
462-
./cppcheck $selfcheck_options --cppcheck-build-dir=b2 -DQT_VERSION=0x050000 -DQ_MOC_OUTPUT_REVISION=67 --library=qt --addon=naming.json -Igui/temp -Igui gui/*.cpp gui/temp/*.cpp || ec=1
462+
./cppcheck $selfcheck_options --cppcheck-build-dir=b2 -DQT_VERSION=0x050000 -DQ_MOC_OUTPUT_REVISION=67 -DQT_CHARTS_LIB --library=qt --addon=naming.json -Igui/temp -Igui gui/*.cpp gui/temp/*.cpp || ec=1
463463
# self check test and tools
464464
./cppcheck $selfcheck_options -Icli test/*.cpp tools/*.cpp || ec=1
465465
# triage
466-
./cppcheck $selfcheck_options -DQ_MOC_OUTPUT_REVISION=67 --library=qt -Itools/triage/temp -Igui tools/triage/*.cpp tools/triage/temp/*.cpp || ec=1
466+
./cppcheck $selfcheck_options -DQ_MOC_OUTPUT_REVISION=67 -DQT_CHARTS_LIB --library=qt -Itools/triage/temp -Igui tools/triage/*.cpp tools/triage/temp/*.cpp || ec=1
467467
exit $ec

.github/workflows/asan.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ jobs:
7575
selfcheck_options="-q -j$(nproc) --std=c++11 --template=selfcheck --showtime=top5 -D__CPPCHECK__ --error-exitcode=1 --inline-suppr --suppressions-list=.selfcheck_suppressions --library=cppcheck-lib -Ilib -Iexternals/simplecpp/ -Iexternals/tinyxml2/ --inconclusive --enable=style,performance,portability,warning,missingInclude,internal --exception-handling --debug-warnings"
7676
ec=0
7777
./cmake.output/bin/cppcheck $selfcheck_options --addon=naming.json -DCHECK_INTERNAL cli lib || ec=1
78-
./cmake.output/bin/cppcheck $selfcheck_options -DQT_VERSION=0x050000 -DQ_MOC_OUTPUT_REVISION=67 --library=qt --addon=naming.json -Icmake.output/gui -Igui gui/*.cpp cmake.output/gui/*.cpp || ec=1
78+
./cmake.output/bin/cppcheck $selfcheck_options -DQT_VERSION=0x050000 -DQ_MOC_OUTPUT_REVISION=67 -DQT_CHARTS_LIB --library=qt --addon=naming.json -Icmake.output/gui -Igui gui/*.cpp cmake.output/gui/*.cpp || ec=1
7979
./cmake.output/bin/cppcheck $selfcheck_options -Icli test/*.cpp tools/*.cpp || ec=1
80-
./cmake.output/bin/cppcheck $selfcheck_options -DQ_MOC_OUTPUT_REVISION=67 --library=qt -Icmake.output/tools/triage -Igui tools/triage/*.cpp cmake.output/tools/triage/*.cpp || ec=1
80+
./cmake.output/bin/cppcheck $selfcheck_options -DQ_MOC_OUTPUT_REVISION=67 -DQT_CHARTS_LIB --library=qt -Icmake.output/tools/triage -Igui tools/triage/*.cpp cmake.output/tools/triage/*.cpp || ec=1
8181
exit $ec

.github/workflows/selfcheck.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ jobs:
6868
- name: Self check (unusedFunction)
6969
if: false # TODO: fails with preprocessorErrorDirective - see #10667
7070
run: |
71-
./cppcheck -q --template=selfcheck --error-exitcode=1 --library=cppcheck-lib --library=qt -D__CPPCHECK__ -D__GNUC__ -DQT_VERSION=0x050000 -DQ_MOC_OUTPUT_REVISION=67 --enable=unusedFunction --exception-handling -rp=. --project=cmake.output/compile_commands.json --suppressions-list=.selfcheck_unused_suppressions --inline-suppr
71+
./cppcheck -q --template=selfcheck --error-exitcode=1 --library=cppcheck-lib --library=qt -D__CPPCHECK__ -D__GNUC__ -DQT_VERSION=0x050000 -DQ_MOC_OUTPUT_REVISION=67 -DQT_CHARTS_LIB --enable=unusedFunction --exception-handling -rp=. --project=cmake.output/compile_commands.json --suppressions-list=.selfcheck_unused_suppressions --inline-suppr
7272
env:
7373
DISABLE_VALUEFLOW: 1
7474
UNUSEDFUNCTION_ONLY: 1
@@ -89,7 +89,7 @@ jobs:
8989
# TODO: find a way to report unmatched suppressions without need to add information checks
9090
- name: Self check (unusedFunction / no test)
9191
run: |
92-
./cppcheck -q --template=selfcheck --error-exitcode=1 --library=cppcheck-lib --library=qt -D__CPPCHECK__ -D__GNUC__ -DQT_VERSION=0x050000 -DQ_MOC_OUTPUT_REVISION=67 --enable=unusedFunction --exception-handling -rp=. --project=cmake.output.notest/compile_commands.json --suppressions-list=.selfcheck_unused_suppressions --inline-suppr
92+
./cppcheck -q --template=selfcheck --error-exitcode=1 --library=cppcheck-lib --library=qt -D__CPPCHECK__ -D__GNUC__ -DQT_VERSION=0x050000 -DQ_MOC_OUTPUT_REVISION=67 -DQT_CHARTS_LIB --enable=unusedFunction --exception-handling -rp=. --project=cmake.output.notest/compile_commands.json --suppressions-list=.selfcheck_unused_suppressions --inline-suppr
9393
env:
9494
DISABLE_VALUEFLOW: 1
9595
UNUSEDFUNCTION_ONLY: 1
@@ -115,7 +115,7 @@ jobs:
115115
- name: Self check (unusedFunction / corpus / no test / callgrind)
116116
run: |
117117
# TODO: fix -rp so the suppressions actually work
118-
valgrind --tool=callgrind ./cppcheck --template=selfcheck --error-exitcode=0 --library=cppcheck-lib --library=qt -D__GNUC__ -DQT_VERSION=0x050000 -DQ_MOC_OUTPUT_REVISION=67 --enable=unusedFunction --exception-handling -rp=. --project=cmake.output.corpus/compile_commands.json --suppressions-list=.selfcheck_unused_suppressions --inline-suppr 2>callgrind.log || (cat callgrind.log && false)
118+
valgrind --tool=callgrind ./cppcheck --template=selfcheck --error-exitcode=0 --library=cppcheck-lib --library=qt -D__GNUC__ -DQT_VERSION=0x050000 -DQ_MOC_OUTPUT_REVISION=67 -DQT_CHARTS_LIB --enable=unusedFunction --exception-handling -rp=. --project=cmake.output.corpus/compile_commands.json --suppressions-list=.selfcheck_unused_suppressions --inline-suppr 2>callgrind.log || (cat callgrind.log && false)
119119
cat callgrind.log
120120
callgrind_annotate --auto=no > callgrind.annotated.log
121121
head -50 callgrind.annotated.log

.github/workflows/tsan.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ jobs:
6161
selfcheck_options="-q -j$(nproc) --std=c++11 --template=selfcheck --showtime=top5 -D__CPPCHECK__ --error-exitcode=0 --inline-suppr --suppressions-list=.selfcheck_suppressions --library=cppcheck-lib -Ilib -Iexternals/simplecpp/ -Iexternals/tinyxml2/ --inconclusive --enable=style,performance,portability,warning,missingInclude,internal --exception-handling --debug-warnings"
6262
ec=0
6363
./cmake.output/bin/cppcheck $selfcheck_options --addon=naming.json -DCHECK_INTERNAL cli lib || ec=1
64-
./cmake.output/bin/cppcheck $selfcheck_options -DQT_VERSION=0x050000 -DQ_MOC_OUTPUT_REVISION=67 --library=qt --addon=naming.json -Igui/temp -Igui gui/*.cpp gui/temp/*.cpp || ec=1
64+
./cmake.output/bin/cppcheck $selfcheck_options -DQT_VERSION=0x050000 -DQ_MOC_OUTPUT_REVISION=67 -DQT_CHARTS_LIB --library=qt --addon=naming.json -Igui/temp -Igui gui/*.cpp gui/temp/*.cpp || ec=1
6565
./cmake.output/bin/cppcheck $selfcheck_options -Icli test/*.cpp tools/*.cpp || ec=1
66-
./cmake.output/bin/cppcheck $selfcheck_options -DQ_MOC_OUTPUT_REVISION=67 --library=qt -Itools/triage/temp -Igui tools/triage/*.cpp tools/triage/temp/*.cpp || ec=1
66+
./cmake.output/bin/cppcheck $selfcheck_options -DQ_MOC_OUTPUT_REVISION=67 -DQT_CHARTS_LIB --library=qt -Itools/triage/temp -Igui tools/triage/*.cpp tools/triage/temp/*.cpp || ec=1
6767
exit $ec

.github/workflows/ubsan.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ jobs:
7373
selfcheck_options="-q -j$(nproc) --std=c++11 --template=selfcheck --showtime=top5 -D__CPPCHECK__ --error-exitcode=1 --inline-suppr --suppressions-list=.selfcheck_suppressions --library=cppcheck-lib -Ilib -Iexternals/simplecpp/ -Iexternals/tinyxml2/ --inconclusive --enable=style,performance,portability,warning,missingInclude,internal --exception-handling --debug-warnings"
7474
ec=0
7575
./cmake.output/bin/cppcheck $selfcheck_options --addon=naming.json -DCHECK_INTERNAL cli lib || ec=1
76-
./cmake.output/bin/cppcheck $selfcheck_options -DQT_VERSION=0x050000 -DQ_MOC_OUTPUT_REVISION=67 --library=qt --addon=naming.json -Icmake.output/gui -Igui gui/*.cpp cmake.output/gui/*.cpp || ec=1
76+
./cmake.output/bin/cppcheck $selfcheck_options -DQT_VERSION=0x050000 -DQ_MOC_OUTPUT_REVISION=67 -DQT_CHARTS_LIB --library=qt --addon=naming.json -Icmake.output/gui -Igui gui/*.cpp cmake.output/gui/*.cpp || ec=1
7777
./cmake.output/bin/cppcheck $selfcheck_options -Icli test/*.cpp tools/*.cpp || ec=1
78-
./cmake.output/bin/cppcheck $selfcheck_options -DQ_MOC_OUTPUT_REVISION=67 --library=qt -Icmake.output/tools/triage -Igui tools/triage/*.cpp cmake.output/tools/triage/*.cpp || ec=1
78+
./cmake.output/bin/cppcheck $selfcheck_options -DQ_MOC_OUTPUT_REVISION=67 -DQT_CHARTS_LIB --library=qt -Icmake.output/tools/triage -Igui tools/triage/*.cpp cmake.output/tools/triage/*.cpp || ec=1
7979
exit $ec

gui/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ CheckOptions:
5555
endif()
5656
target_link_libraries(cppcheck-gui ${QT_CORE_LIB} ${QT_GUI_LIB} ${QT_WIDGETS_LIB} ${QT_PRINTSUPPORT_LIB} ${QT_HELP_LIB} ${QT_NETWORK_LIB})
5757
if(WITH_QCHART)
58-
target_compile_definitions (cppcheck-gui PRIVATE HAVE_QCHART)
5958
target_link_libraries(cppcheck-gui ${QT_CHARTS_LIB})
6059
endif()
6160
if (BUILD_CORE_DLL)

gui/gui.pro

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,6 @@ contains(QMAKE_CXX, clang++) {
214214

215215
contains(HAVE_QCHART, [yY][eE][sS]) {
216216
QT += charts
217-
DEFINES += HAVE_QCHART
218217
} else {
219218
message("Charts disabled - to enable it pass HAVE_QCHART=yes to qmake.")
220219
}

gui/statsdialog.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
#include <QTextDocument>
3636
#include <QWidget>
3737

38-
#ifdef HAVE_QCHART
38+
#ifdef QT_CHARTS_LIB
3939
#include <QAbstractSeries>
4040
#include <QChartView>
4141
#include <QDateTimeAxis>
@@ -44,8 +44,11 @@
4444
#include <QValueAxis>
4545

4646
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
47-
using namespace QtCharts;
47+
QT_CHARTS_USE_NAMESPACE
4848
#endif
49+
50+
static QLineSeries *numberOfReports(const QString &fileName, const QString &severity);
51+
static QChartView *createChart(const QString &statsFile, const QString &tool);
4952
#endif
5053

5154
static const QString CPPCHECK("cppcheck");
@@ -76,7 +79,7 @@ void StatsDialog::setProject(const ProjectFile* projectFile)
7679
mUI->mIncludePaths->setText(projectFile->getIncludeDirs().join(";"));
7780
mUI->mDefines->setText(projectFile->getDefines().join(";"));
7881
mUI->mUndefines->setText(projectFile->getUndefines().join(";"));
79-
#ifndef HAVE_QCHART
82+
#ifndef QT_CHARTS_LIB
8083
mUI->mTabHistory->setVisible(false);
8184
#else
8285
QString statsFile;
@@ -356,8 +359,8 @@ void StatsDialog::setStatistics(const CheckStatistics *stats)
356359
mUI->mLblInformation->setText(QString("%1").arg(stats->getCount(CPPCHECK,ShowTypes::ShowInformation)));
357360
}
358361

359-
#ifdef HAVE_QCHART
360-
QChartView *StatsDialog::createChart(const QString &statsFile, const QString &tool)
362+
#ifdef QT_CHARTS_LIB
363+
QChartView *createChart(const QString &statsFile, const QString &tool)
361364
{
362365
QChart *chart = new QChart;
363366
chart->addSeries(numberOfReports(statsFile, tool + "-error"));
@@ -399,7 +402,7 @@ QChartView *StatsDialog::createChart(const QString &statsFile, const QString &to
399402
return chartView;
400403
}
401404

402-
QLineSeries *StatsDialog::numberOfReports(const QString &fileName, const QString &severity) const
405+
QLineSeries *numberOfReports(const QString &fileName, const QString &severity)
403406
{
404407
QLineSeries *series = new QLineSeries();
405408
series->setName(severity);

gui/statsdialog.h

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,6 @@ namespace Ui {
2929
class StatsDialog;
3030
}
3131

32-
#ifdef HAVE_QCHART
33-
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
34-
namespace QtCharts {
35-
#endif
36-
class QChartView;
37-
class QLineSeries;
38-
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
39-
}
40-
#endif
41-
#endif
42-
4332
/// @addtogroup GUI
4433
/// @{
4534

@@ -81,15 +70,6 @@ class StatsDialog : public QDialog {
8170
private slots:
8271
void copyToClipboard();
8372
void pdfExport();
84-
#ifdef HAVE_QCHART
85-
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
86-
QChartView *createChart(const QString &statsFile, const QString &tool);
87-
QLineSeries *numberOfReports(const QString &fileName, const QString &severity) const;
88-
#else
89-
QtCharts::QChartView *createChart(const QString &statsFile, const QString &tool);
90-
QtCharts::QLineSeries *numberOfReports(const QString &fileName, const QString &severity) const;
91-
#endif
92-
#endif
9373
private:
9474
Ui::StatsDialog *mUI;
9575
const CheckStatistics *mStatistics;

0 commit comments

Comments
 (0)