-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
crloader.hpp
108 lines (94 loc) · 3.87 KB
/
crloader.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/*****************************************************************************
* Copyright (C) 2021 by Lorenzo Buzzi ([email protected]) *
* *
* 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 <https://www.gnu.org/licenses/>. *
*****************************************************************************/
#ifndef CRLOADER_H
#define CRLOADER_H
#include <QCoreApplication>
#include <QString>
#include <QStringConverter>
#include <QList>
#include <QDataStream>
#include "timing.hpp"
#include "category.hpp"
#include "competitor.hpp"
#include "crtablemodel.hpp"
#include "startlistmodel.hpp"
#include "teamslistmodel.hpp"
#include "timingsmodel.hpp"
#include "rankingsmodel.hpp"
#include "categoriesmodel.hpp"
namespace loader {
class CRLoader;
}
class CRLoader
{
Q_DECLARE_TR_FUNCTIONS(CRLoader)
public:
enum class Format
{
PDF = 0,
TEXT = 1,
CSV = 2
};
enum class Model
{
STARTLIST,
TEAMSLIST,
RANKINGS,
CATEGORIES,
TIMINGS
};
private:
static StartListModel startListModel;
static TeamsListModel teamsListModel;
static TimingsModel timingsModel;
static RankingsModel rankingsModel;
static CategoriesModel categoriesModel;
static QList<QVariant> standardItemList;
static QStringConverter::Encoding encoding;
static Format format;
static void loadCSV(QString const &filePath, QAbstractTableModel *model);
static void saveCSV(QString const &filePath, QAbstractTableModel const *model);
static void checkString(QAbstractTableModel *model, QString &token, QChar character = '\0');
public:
static void saveRaceData(QDataStream &out);
static void loadRaceData(QDataStream &in);
static QPair<int, int> importStartList(QString const &path);
static QList<Competitor> getStartList();
static uint getStartListLegs();
static void setStartListLegs(uint leg);
static uint getStartListBibMax();
static uint getStartListNameWidthMax();
static uint getTeamNameWidthMax();
static void clearTimings();
static void addTiming(QString const &bib, QString const &timing);
static QList<Timing> const &getTimings();
static int importModel(Model model, QString const &path);
static void exportModel(Model model, QString const &path);
static QList<Ranking> const &getRankings();
static QList<Category> const &getCategories();
static CRTableModel *getStartListModel();
static CRTableModel *getTeamsListModel();
static CRTableModel *getTimingsModel();
static CRTableModel *getRankingsModel();
static CRTableModel *getCategoriesModel();
static QStringConverter::Encoding getEncoding();
static void setEncoding(QStringConverter::Encoding const &value);
static Format getFormat();
static void setFormat(Format const &value);
static QStringList getClubs();
};
#endif // CRLOADER_H