Skip to content

Commit d78869b

Browse files
committed
Remove superfluous QObject inheritance
QObject is a special, non-copyable Qt class. Classes which just need the translation features shall not be derived from QObject but can use Q_DECLARE_TR_FUNCTIONS instead. Note that class 'Problem' needs an explicitly declared virtual destructor now.
1 parent 95b4969 commit d78869b

File tree

7 files changed

+39
-19
lines changed

7 files changed

+39
-19
lines changed

src/layout.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
Copyright 2011 Thomas Schöps
3+
Copyright 2019 Kai Pastor
34
45
This file is part of OpenOrienteering's scoring tool.
56
@@ -26,9 +27,9 @@
2627
#include <Qt>
2728
#include <QtGlobal>
2829
#include <QColor>
30+
#include <QCoreApplication>
2931
#include <QFont>
3032
#include <QMap>
31-
#include <QObject>
3233
#include <QPointF>
3334
#include <QRectF>
3435
#include <QString>
@@ -40,9 +41,10 @@ class QWidget;
4041
class QXmlStreamAttributes;
4142
QT_END_NAMESPACE
4243

43-
class Layout : public QObject
44+
class Layout
4445
{
45-
Q_OBJECT
46+
Q_DECLARE_TR_FUNCTIONS(Layout)
47+
4648
public:
4749

4850
struct Font

src/mainWindow.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
Copyright 2011 Thomas Schöps
3+
Copyright 2019 Kai Pastor
34
45
This file is part of OpenOrienteering's scoring tool.
56
@@ -24,6 +25,7 @@
2425
#include <vector>
2526

2627
#include <QtGlobal>
28+
#include <QCoreApplication>
2729
#include <QDialog>
2830
#include <QObject>
2931
#include <QSize>
@@ -220,7 +222,8 @@ public slots:
220222

221223
class SimilarClubProblem : public Problem
222224
{
223-
Q_OBJECT
225+
Q_DECLARE_TR_FUNCTIONS(SimilarClubProblem)
226+
224227
public:
225228
SimilarClubProblem(Club* club, std::vector<Club*>& similarClubs, ResultList* results);
226229
virtual int getNumSolutions();
@@ -235,7 +238,8 @@ Q_OBJECT
235238

236239
class SimilarRunnerProblem : public Problem
237240
{
238-
Q_OBJECT
241+
Q_DECLARE_TR_FUNCTIONS(SimilarRunnerProblem)
242+
239243
public:
240244
SimilarRunnerProblem(Runner* runner, std::vector<Runner*>& similarRunners, ResultList* results);
241245
virtual int getNumSolutions();

src/problemWidget.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
Copyright 2011 Thomas Schöps
3+
Copyright 2019 Kai Pastor
34
45
This file is part of OpenOrienteering's scoring tool.
56
@@ -48,6 +49,8 @@ Problem::Problem()
4849
selection = 0;
4950
}
5051

52+
Problem::~Problem() = default;
53+
5154
ProblemWidget::ProblemWidget(QWidget* parent) : QTableWidget(parent)
5255
{
5356
verticalHeader()->setVisible(false);

src/problemWidget.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
Copyright 2011 Thomas Schöps
3+
Copyright 2019 Kai Pastor
34
45
This file is part of OpenOrienteering's scoring tool.
56
@@ -41,9 +42,8 @@ QT_END_NAMESPACE
4142

4243
class ActionSelectionDelegate;
4344

44-
class Problem : public QObject
45+
class Problem
4546
{
46-
Q_OBJECT
4747
public:
4848

4949
enum SolutionType
@@ -54,6 +54,7 @@ Q_OBJECT
5454
};
5555

5656
Problem();
57+
virtual ~Problem();
5758

5859
virtual int getNumSolutions() = 0;
5960
virtual QString getSolutionDescription(int i) = 0;

src/runner.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
Copyright 2011 Thomas Schöps
3+
Copyright 2019 Kai Pastor
34
45
This file is part of OpenOrienteering's scoring tool.
56
@@ -31,6 +32,7 @@
3132
#include <QtGlobal>
3233

3334
#include <QAbstractTableModel>
35+
#include <QCoreApplication>
3436
#include <QModelIndex>
3537
#include <QObject>
3638
#include <QString>
@@ -49,9 +51,10 @@ class ComboBoxDelegate;
4951

5052
/// Stores runner data
5153
/// TODO: Chip list
52-
class Runner : public QObject
54+
class Runner
5355
{
54-
Q_OBJECT
56+
Q_DECLARE_TR_FUNCTIONS(Runner)
57+
5558
public:
5659

5760
Runner();

src/scoring.h

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
Copyright 2011 Thomas Schöps
3+
Copyright 2019 Kai Pastor
34
45
This file is part of OpenOrienteering's scoring tool.
56
@@ -27,8 +28,8 @@
2728
#include <vector>
2829

2930
#include <QtGlobal>
31+
#include <QCoreApplication>
3032
#include <QMap>
31-
#include <QObject>
3233
#include <QString>
3334
#include <QStringList>
3435

@@ -54,9 +55,10 @@ enum RuleType
5455
TimePoints = 3
5556
};
5657

57-
struct Ruleset : public QObject
58+
struct Ruleset
5859
{
59-
Q_OBJECT
60+
Q_DECLARE_TR_FUNCTIONS(Ruleset)
61+
6062
public:
6163

6264
struct TimeRatioSettings
@@ -116,9 +118,10 @@ class CustomCategory : public AbstractCategory
116118
};
117119

118120
/// Scorings take race results as input and calculate handicapped times or points for every runner (and possibly team)
119-
class Scoring : public QObject
121+
class Scoring
120122
{
121-
Q_OBJECT
123+
Q_DECLARE_TR_FUNCTIONS(Scoring)
124+
122125
public:
123126

124127
enum CalculationFlags
@@ -268,7 +271,8 @@ class ScoringDB
268271

269272
class ClubDifferentProblem : public Problem
270273
{
271-
Q_OBJECT
274+
Q_DECLARE_TR_FUNCTIONS(ClubDifferentProblem)
275+
272276
public:
273277

274278
ClubDifferentProblem(Club* club, const QString& country_text, Location* country, const QString& province_text, Location* province);

src/seriesScoring.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
Copyright 2011 Thomas Schöps
3+
Copyright 2019 Kai Pastor
34
45
This file is part of OpenOrienteering's scoring tool.
56
@@ -26,8 +27,8 @@
2627
#include <vector>
2728

2829
#include <QtGlobal>
30+
#include <QCoreApplication>
2931
#include <QMap>
30-
#include <QObject>
3132
#include <QString>
3233

3334
#include "problemWidget.h"
@@ -58,9 +59,10 @@ struct SeriesRaceResult
5859
};
5960

6061
/// Aggregates result lists from multiple races and calculates a series scoring, possibly also taking into account some organizer bonus
61-
class SeriesScoring : public QObject
62+
class SeriesScoring
6263
{
63-
Q_OBJECT
64+
Q_DECLARE_TR_FUNCTIONS(SeriesScoring)
65+
6466
public:
6567

6668
typedef std::map< int, SeriesRaceResult* > ResultMap;
@@ -195,7 +197,8 @@ class SeriesScoringDB
195197

196198
class OrganizerMissingProblem : public Problem
197199
{
198-
Q_OBJECT
200+
Q_DECLARE_TR_FUNCTIONS(OrganizerMissingProblem)
201+
199202
public:
200203

201204
OrganizerMissingProblem(SeriesRaceResult* result, const QString& first_name, const QString& last_name, int year, bool isMale);

0 commit comments

Comments
 (0)