-
Notifications
You must be signed in to change notification settings - Fork 1
/
TemporalPlug.h
47 lines (35 loc) · 1.12 KB
/
TemporalPlug.h
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
#ifndef TEMPORALPLUG_H
#define TEMPORALPLUG_H
#include "Plug.h"
class TemporalPlug : public Plug
{
Q_OBJECT
protected:
QDate date;
TemporalPlug(QWidget *parent) : Plug(parent) { }
bool isOutdated()
{
return Plug::isOutdated() || globalDate() != fromGlobalDate(date);
}
// Convert the given date to a date that can be presented to the outside
// world as the single date shown by this plug.
virtual QDate toGlobalDate(QDate date) { return date; }
// Sanitize the given date to a date expected by this plug internally, for
// example if the year number is the only thing that matters, other parts
// of the date can be erased to make comparisons straightforward.
virtual QDate fromGlobalDate(QDate globalDate) { return globalDate; }
// Process and share a date
void setGlobalDate(QDate date)
{
sharedDate = toGlobalDate(date);
}
// Read and interpret the shared date
QDate globalDate()
{
return fromGlobalDate(sharedDate);
}
static bool currentDateLock;
private:
static QDate sharedDate;
};
#endif // TEMPORALPLUG_H