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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
|
#ifndef _KPILOT_PILOTDATEENTRY_H
#define _KPILOT_PILOTDATEENTRY_H
/* pilotDateEntry.h -*- C++ -*- KPilot
**
** Copyright (C) 1998-2001 by Dan Pilone
** Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
**
** See the .cc file for an explanation of what this file is for.
*/
/** @file pilotDateEntry.h defines a wrapper for datebook entries. */
/*
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
** the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public License
** along with this program in a file called COPYING; if not, write to
** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
** MA 02110-1301, USA.
*/
/*
** Bug reports and questions can be sent to kde-pim@kde.org
*/
#include <pi-macros.h>
#include <pi-datebook.h>
#include <tqbitarray.h>
#include <tqdatetime.h>
#include <tqnamespace.h>
#include "pilotRecord.h"
#include "pilotAppInfo.h"
namespace KCal
{
class Event;
}
/** Interpreted form of the AppInfo block in the datebook database. */
typedef PilotAppInfo<
AppointmentAppInfo,
unpack_AppointmentAppInfo,
pack_AppointmentAppInfo> PilotDateInfo_;
class PilotDateInfo : public PilotDateInfo_
{
public:
PilotDateInfo(PilotDatabase *d) : PilotDateInfo_(d)
{
}
/** This resets the entire AppInfo block to one as it would be
* in an English-language handheld, with 3 categories and
* default field labels for everything.
*/
void resetToDefault();
};
/** This class is a wrapper for pilot-link's datebook entries (struct Appointment). */
class KDE_EXPORT PilotDateEntry : public PilotRecordBase
{
public:
/** Constructor. Zeroes out the appointment. */
PilotDateEntry();
/** Constructor. Interprets the given record as an appointment. */
PilotDateEntry(PilotRecord *rec);
/** Copy constructor. */
PilotDateEntry(const PilotDateEntry &e);
/** Destructor. */
~PilotDateEntry()
{
free_Appointment(&fAppointmentInfo);
}
/** Assignment operator. */
PilotDateEntry& operator=(const PilotDateEntry &e);
/** Create a textual representation (human-readable) of this appointment.
* If @p richText is true, then the text representation uses qt style
* tags as well.
*/
TQString getTextRepresentation(Qt::TextFormat richText);
/** Is this appointment a "floating" appointment?
*
* Floating appointments are those that have a day assigned, but no time
* in that day (birthday appointments are like that). You can think of these
* as "events", which don't have a time associated with them for a given day,
* as opposed to a regular "appointment", which does normally have a time
* associated with it.
*/
inline bool doesFloat() const
{
return fAppointmentInfo.event;
}
/** Is this a non-time-related event as opposed to an appointment that has a
* time associated with it?.
*/
inline bool isEvent() const
{
return doesFloat();
}
/** Sets this appointment's floating status.
*
* Floating appointments are those that have a day assigned, but no time
* in that day (birthday appointments are like that). You can think of these
* as "events", which don't have a time associated with them for a given day,
* as opposed to a regular "appointment", which does normally have a time
* associated with it.
*/
inline void setFloats(bool f)
{
fAppointmentInfo.event = (f ? 1 : 0) /* Force 1 or 0 */ ;
}
/** Get the start time of this appointment. See dtStart() for caveats. */
inline struct tm getEventStart() const { return fAppointmentInfo.begin; }
/** Get a pointer to the start time of this appointment. See dtStart() for caveats. */
inline const struct tm *getEventStart_p() const
{
return &fAppointmentInfo.begin;
}
/** Sets the start time of this appointment. */
inline void setEventStart(struct tm& start)
{
fAppointmentInfo.begin = start;
}
/** Get the start time of this appointment. For floating appointments, the
* time is undefined (perhaps 1 minute past midnight).
*
* Floating appointments are those that have a day assigned, but no time
* in that day (birthday appointments are like that).
*/
TQDateTime dtStart() const;
/** Get the end time of this appointment. See dtEnd() for caveats. */
inline struct tm getEventEnd() const
{
return fAppointmentInfo.end;
}
/** Get a pointer to the end time of this appointment. See dtEnd() for caveats. */
inline const struct tm *getEventEnd_p() const
{
return &fAppointmentInfo.end;
}
/** Set the end time of this appointment. */
inline void setEventEnd(struct tm& end)
{
fAppointmentInfo.end = end;
}
/** Get the end time of this appointment. For floating appointments, the
* time is undefined (perhaps 1 minute past midnight).
*
* Floating appointments are those that have a day assigned, but no time
* in that day (birthday appointments are like that).
*/
TQDateTime dtEnd() const;
/** Does this appointment have an alarm set? On the Pilot, an event
* may have an alarm (or not). If it has one, it is also enabled and
* causes the Pilot to beep (or whatever is set in the system preferences).
*/
inline bool isAlarmEnabled() const
{
return fAppointmentInfo.alarm;
}
/** Set whether this appointment has an alarm. */
inline void setAlarmEnabled(bool b)
{
fAppointmentInfo.alarm = (b?1:0) /* Force to known int values */ ;
}
/** Get the numeric part of "alarm: __ (v) minutes" on the pilot -- you
* set the alarm time in two parts, a number and a unit type to use; unit
* types are minutes, hours, days and the number is whatever you like.
*
* If alarms are not enabled for this appointment, returns garbage.
*
* @see alarmLeadTime()
* @see dtAlarm()
*/
inline int getAdvance() const
{
return fAppointmentInfo.advance;
}
/** Set the numeric part of the alarm setting. See getAdvance for details. */
inline void setAdvance(int advance)
{
fAppointmentInfo.advance = advance;
}
/** Returns the units part of the alarm time. See getAdvance . */
inline int getAdvanceUnits() const
{
return fAppointmentInfo.advanceUnits;
}
/** Sets the unites part of the alarm time. See getAdvance . */
inline void setAdvanceUnits(int units)
{
fAppointmentInfo.advanceUnits = units;
}
/** Returns the number of @em seconds "lead time" the alarm should sound
* before the actual appointment. This interprets the advance number and units.
* The value is always positive, 0 if no alarms are enabled.
*/
unsigned int alarmLeadTime() const;
/** Returns the absolute date and time that the alarm should sound for
* this appointment.
*/
inline TQDateTime dtAlarm() const
{
return dtStart().addSecs(-alarmLeadTime());
}
// The following need set routines written
inline repeatTypes getRepeatType() const
{
return fAppointmentInfo.repeatType;
}
inline void setRepeatType(repeatTypes r)
{
fAppointmentInfo.repeatType = r;
}
inline int getRepeatForever() const
{
return fAppointmentInfo.repeatForever;
}
inline void setRepeatForever(int f = 1)
{
fAppointmentInfo.repeatForever = f;
}
inline struct tm getRepeatEnd() const
{
return fAppointmentInfo.repeatEnd;
}
inline void setRepeatEnd(struct tm tm)
{
fAppointmentInfo.repeatEnd = tm;
}
/** Returns the date and time that the repeat ends. If there is no repeat,
* returns an invalid date and time.
*/
TQDateTime dtRepeatEnd() const;
inline int getRepeatFrequency() const
{
return fAppointmentInfo.repeatFrequency;
}
inline void setRepeatFrequency(int f)
{
fAppointmentInfo.repeatFrequency = f;
}
inline DayOfMonthType getRepeatDay() const
{
return fAppointmentInfo.repeatDay;
}
inline void setRepeatDay(DayOfMonthType rd)
{
fAppointmentInfo.repeatDay = rd;
};
inline const int *getRepeatDays() const
{
return fAppointmentInfo.repeatDays;
}
inline void setRepeatDays(int *rd)
{
for (int i = 0; i < 7; i++)
{
fAppointmentInfo.repeatDays[i] = rd[i];
}
}
inline void setRepeatDays(TQBitArray rba)
{
for (int i = 0; i < 7; i++)
{
fAppointmentInfo.repeatDays[i] = (rba[i] ? 1 : 0);
}
}
inline int getExceptionCount() const
{
return fAppointmentInfo.exceptions;
}
inline void setExceptionCount(int e)
{
fAppointmentInfo.exceptions = e;
}
inline const struct tm *getExceptions() const
{
return fAppointmentInfo.exception;
}
void setExceptions(struct tm *e);
/** Sets the description of the appointment. This is the short string
* entered in the day view on the handheld, and it is called the summary
* in libkcal.
*/
void setDescription(const TQString &);
/** Gets the description of the appointment. See setDescription for meaning. */
TQString getDescription() const;
/** Sets the note for the appointment. The note is the long text entry
* that is possible - but clumsy - on the handheld. It is called the
* description in libkcal.
*/
void setNote(const TQString &);
/** Gets the note for this appointment. See setNote for meaning. */
TQString getNote() const;
/**
* Sets the location for the appointment. For now it will be placed within
* the notes on the handheld. It will be placed on one line and starts with:
* Location: {location}. Everything on that line will be counted as location.
* TODO: Make distinguish between handhelds that support the location field
* and the ones that don't. (Shouldn't this be done in the pilot-link lib?)
*/
void setLocation(const TQString &);
/** Gets the location for this appointment. See setNote for meaning. */
TQString getLocation() const;
protected:
void setDescriptionP(const char* desc, int l=-1);
const char* getDescriptionP() const
{
return fAppointmentInfo.description;
}
void setNoteP(const char* note, int l=-1);
const char* getNoteP() const
{
return fAppointmentInfo.note;
}
public:
bool isMultiDay() const
{
return ((fAppointmentInfo.repeatType == repeatDaily) &&
(fAppointmentInfo.repeatFrequency == 1) &&
( !getRepeatForever() ) &&
!doesFloat() );
}
PilotRecord *pack() const;
private:
struct Appointment fAppointmentInfo;
void _copyExceptions(const PilotDateEntry &e);
};
#endif
|