blob: 6c81f8f035fefffa707449ba6abc5f85a12539a2 (
plain)
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
#include <qshared.h>
#include <qtopia/timeconversion.h>
#include "orecur.h"
struct ORecur::Data : public QShared {
Data() : QShared() {
type = ORecur::NoRepeat;
freq = -1;
days = 0;
pos = 0;
create = -1;
hasEnd = FALSE;
end = 0;
}
char days; // Q_UINT8 for 8 seven days;)
ORecur::RepeatType type;
int freq;
int pos;
bool hasEnd : 1;
time_t end;
time_t create;
};
ORecur::ORecur() {
data = new Data;
}
ORecur::ORecur( const ORecur& rec)
: data( rec.data )
{
data->ref();
}
ORecur::~ORecur() {
if ( data->deref() ) {
delete data;
data = 0l;
}
}
void ORecur::deref() {
if ( data->deref() ) {
delete data;
data = 0l;
}
}
bool ORecur::operator==( const ORecur& )const {
return false;
}
ORecur &ORecur::operator=( const ORecur& re) {
re.data->ref();
deref();
data = re.data;
return *this;
}
ORecur::RepeatType ORecur::type()const{
return data->type;
}
int ORecur::frequency()const {
return data->freq;
}
int ORecur::position()const {
return data->pos;
}
char ORecur::days() const{
return data->days;
}
bool ORecur::hasEndDate()const {
return data->hasEnd;
}
QDate ORecur::endDate()const {
return TimeConversion::fromUTC( data->end ).date();
}
time_t ORecur::endDateUTC()const {
return data->end;
}
time_t ORecur::createTime()const {
return data->create;
}
void ORecur::setType( const RepeatType& z) {
checkOrModify();
data->type = z;
}
void ORecur::setFrequency( int freq ) {
checkOrModify();
data->freq = freq;
}
void ORecur::setPosition( int pos ) {
checkOrModify();
data->pos = pos;
}
void ORecur::setDays( char c ) {
checkOrModify();
data->days = c;
}
void ORecur::setEndDate( const QDate& dt) {
checkOrModify();
data->end = TimeConversion::toUTC( dt );
}
void ORecur::setEndDateUTC( time_t t) {
checkOrModify();
data->end = t;
}
void ORecur::setCreateTime( time_t t) {
checkOrModify();
data->create = t;
}
void ORecur::setHasEndDate( bool b) {
checkOrModify();
data->hasEnd = b;
}
void ORecur::checkOrModify() {
if ( data->count != 1 ) {
data->deref();
Data* d2 = new Data;
d2->days = data->days;
d2->type = data->type;
d2->freq = data->freq;
d2->pos = data->pos;
d2->hasEnd = data->hasEnd;
d2->end = data->end;
d2->create = data->create;
data = d2;
}
}
|