-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
chronoracetimings.hpp
107 lines (81 loc) · 3.02 KB
/
chronoracetimings.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
/*****************************************************************************
* 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 CHRONORACETIMINGS_H
#define CHRONORACETIMINGS_H
#include <QDialog>
#include <QTimerEvent>
#include <QElapsedTimer>
#include <QThread>
#include "ui_chronoracetimings.h"
class TimingsWorker : public QObject
{
Q_OBJECT
public:
explicit TimingsWorker();
public slots:
void writeToDisk(QString const &buffer);
signals:
void writeDone();
private:
QString timingsFilePath { "" };
};
class ChronoRaceTimings : public QDialog
{
Q_OBJECT
public:
explicit ChronoRaceTimings(QWidget *parent = Q_NULLPTR);
protected:
bool eventFilter(QObject *watched, QEvent *event) override;
void timerEvent(QTimerEvent *event) override;
public slots:
void accept() override;
void reject() override;
void show(); //NOSONAR
void clearDiskBuffer();
signals:
void newTimingsCount(int count);
void saveToDisk(QString const &buffer);
void error(QString const &message);
private:
QScopedPointer<Ui::ChronoRaceTimings> ui { new Ui::ChronoRaceTimings };
int timingRowCount { 0 };
int updateTimerId { 0 };
int backupTimerId { 0 };
QElapsedTimer timer;
QList<QString> saveToDiskQueue;
QThread saveToDiskThread;
TimingsWorker saveToDiskWorker;
QTableWidgetItem *currentBibItem { Q_NULLPTR };
void updateCurrentBibItem(QTableWidgetItem *newBibItem);
void recordTiming(qint64 seconds);
void deleteTiming();
void deleteBib();
void saveTimings();
void stepUp();
void stepDown();
bool enterPressed();
bool digitPressed(QString const &key);
bool upPressed();
bool downPressed();
private slots:
void start();
void stop();
void reset();
void lock(bool checked);
void bibClicked(QTableWidgetItem *item);
};
#endif // CHRONORACETIMINGS_H