libkcal

alarm.h
1/*
2 This file is part of libkcal.
3
4 Copyright (c) 2001-2003 Cornelius Schumacher <schumacher@kde.org>
5 Copyright (c) 2010 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.net>
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details.
16
17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA.
21*/
22
23#ifndef KCAL_ALARM_H
24#define KCAL_ALARM_H
25
26#include <tqstring.h>
27#include <tqstringlist.h>
28#include <tqvaluelist.h>
29
30#include "customproperties.h"
31#include "duration.h"
32#include "person.h"
33#include "listbase.h"
34#include "libkcal_export.h"
35
36#include <tdemacros.h>
37
38namespace KCal {
39
40class Incidence;
41
45class LIBKCAL_EXPORT Alarm : public CustomProperties
46{
47 public:
48 enum Type { Invalid, Display, Procedure, Email, Audio };
49
50 typedef ListBase<Alarm> List;
51
55 explicit Alarm( Incidence *parent );
59 virtual ~Alarm();
60
65 Alarm *clone();
66
71 Alarm &operator=( const Alarm & );
72
76 bool operator==( const Alarm & ) const;
77 bool operator!=( const Alarm &a ) const { return !operator==( a ); }
78
86 void setType( Type type );
87
91 Type type() const;
92
98 void setDisplayAlarm( const TQString &text = TQString() );
99
104 void setText( const TQString &text );
105
109 TQString text() const;
110
116 void setAudioAlarm( const TQString &audioFile = TQString() );
121 void setAudioFile( const TQString &audioFile );
127 TQString audioFile() const;
128
135 void setProcedureAlarm( const TQString &programFile,
136 const TQString &arguments = TQString() );
141 void setProgramFile( const TQString &programFile );
147 TQString programFile() const;
152 void setProgramArguments( const TQString &arguments );
158 TQString programArguments() const;
159
168 void setEmailAlarm( const TQString &subject, const TQString &text,
169 const TQValueList<Person> &addressees,
170 const TQStringList &attachments = TQStringList() );
171
176 void setMailAddress( const Person &mailAlarmAddress );
181 void setMailAddresses( const TQValueList<Person> &mailAlarmAddresses );
186 void addMailAddress( const Person &mailAlarmAddress );
190 TQValueList<Person> mailAddresses() const;
191
196 void setMailSubject( const TQString &mailAlarmSubject );
200 TQString mailSubject() const;
201
206 void setMailAttachment( const TQString &mailAttachFile );
211 void setMailAttachments( const TQStringList &mailAttachFiles );
216 void addMailAttachment( const TQString &mailAttachFile );
220 TQStringList mailAttachments() const;
221
226 void setMailText( const TQString &text );
232 TQString mailText() const;
233
237 void setTime( const TQDateTime &alarmTime );
241 TQDateTime time() const;
246 TQDateTime endTime() const;
250 bool hasTime() const;
251
255 void setStartOffset( const Duration & );
261 Duration startOffset() const;
266 bool hasStartOffset() const;
267
271 void setEndOffset( const Duration & );
277 Duration endOffset() const;
282 bool hasEndOffset() const;
283
289 void setSnoozeTime( const Duration &alarmSnoozeTime );
290
296 Duration snoozeTime() const;
297
302 void setRepeatCount( int alarmRepeatCount );
306 int repeatCount() const;
314 TQDateTime nextRepetition(const TQDateTime& preTime) const;
322 TQDateTime previousRepetition(const TQDateTime& afterTime) const;
327 Duration duration() const;
328
333 void toggleAlarm();
334
338 void setEnabled(bool enable);
342 bool enabled() const;
343
347 void setParent( Incidence * );
351 Incidence *parent() const { return mParent; }
352
353 protected:
358 virtual void customPropertyUpdated();
359
360 private:
361 Incidence *mParent; // the incidence which this alarm belongs to
362 Type mType; // type of alarm
363 TQString mDescription; // text to display/email body/procedure arguments
364 TQString mFile; // procedure program to run/optional audio file to play
365 TQStringList mMailAttachFiles; // filenames to attach to email
366 TQValueList<Person> mMailAddresses; // who to mail for reminder
367 TQString mMailSubject; // subject of email
368
369 Duration mAlarmSnoozeTime; // how long after alarm to snooze before
370 // triggering again
371 int mAlarmRepeatCount; // number of times for alarm to repeat
372 // after the initial time
373
374 TQDateTime mAlarmTime; // time at which to trigger the alarm
375 Duration mOffset; // time relative to incidence DTSTART to trigger the alarm
376 bool mEndOffset; // if true, mOffset relates to DTEND, not DTSTART
377 bool mHasTime; // use mAlarmTime, not mOffset
378 bool mAlarmEnabled;
379
380 class Private;
381 Private *d;
382};
383
384}
385
386#endif
void setAudioAlarm(const TQString &audioFile=TQString())
Set the alarm to be an audio alarm.
Definition alarm.cpp:149
bool hasStartOffset() const
Return whether the alarm is defined in terms of an offset relative to the start of the event.
Definition alarm.cpp:456
TQString audioFile() const
Return the name of the audio file for the alarm.
Definition alarm.cpp:164
Duration snoozeTime() const
Get how long the alarm snooze interval is.
Definition alarm.cpp:362
void setMailSubject(const TQString &mailAlarmSubject)
Set the subject line of the mail.
Definition alarm.cpp:244
void setMailAddress(const Person &mailAlarmAddress)
Send mail to this address when the alarm is triggered.
Definition alarm.cpp:214
TQString programFile() const
Return the name of the program file to execute when the alarm is triggered.
Definition alarm.cpp:185
void setMailAttachments(const TQStringList &mailAttachFiles)
Attach these filenames to the email.
Definition alarm.cpp:266
void addMailAttachment(const TQString &mailAttachFile)
Add this filename to the list of files to attach to the email.
Definition alarm.cpp:274
void setRepeatCount(int alarmRepeatCount)
Set how many times an alarm is to repeat itself after its initial occurrence (w/snoozes).
Definition alarm.cpp:367
TQString mailSubject() const
Return the subject line of the mail.
Definition alarm.cpp:252
TQDateTime time() const
Return the date/time when an alarm goes off.
Definition alarm.cpp:329
TQString text() const
Return the text string that displays when the alarm is triggered.
Definition alarm.cpp:316
void setEnabled(bool enable)
Set the alarm enabled status.
Definition alarm.cpp:432
void addMailAddress(const Person &mailAlarmAddress)
Add this address to the list of addresses to send mail to when the alarm is triggered.
Definition alarm.cpp:231
Alarm * clone()
Returns an exact copy of this alarm.
Definition alarm.cpp:50
Duration endOffset() const
Return offset of alarm in time relative to the end of the event.
Definition alarm.cpp:474
TQDateTime nextRepetition(const TQDateTime &preTime) const
Get the time of the alarm's initial occurrence or its next repetition, after a given time.
Definition alarm.cpp:384
bool hasEndOffset() const
Return whether the alarm is defined in terms of an offset relative to the end of the event.
Definition alarm.cpp:461
void setDisplayAlarm(const TQString &text=TQString())
Set the alarm to be a display alarm.
Definition alarm.cpp:300
TQDateTime previousRepetition(const TQDateTime &afterTime) const
Get the time of the alarm's latest repetition, or its initial occurrence if none, before a given time...
Definition alarm.cpp:401
Duration startOffset() const
Return offset of alarm in time relative to the start of the event.
Definition alarm.cpp:451
void setSnoozeTime(const Duration &alarmSnoozeTime)
Set the interval between snoozes for the alarm.
Definition alarm.cpp:354
TQString programArguments() const
Return the arguments to the program to run when the alarm is triggered.
Definition alarm.cpp:198
void setEndOffset(const Duration &)
Set offset of alarm in time relative to the end of the event.
Definition alarm.cpp:466
void setEmailAlarm(const TQString &subject, const TQString &text, const TQValueList< Person > &addressees, const TQStringList &attachments=TQStringList())
Set the alarm to be an email alarm.
Definition alarm.cpp:203
void setText(const TQString &text)
Set the text to be displayed when the alarm is triggered.
Definition alarm.cpp:308
Duration duration() const
Get how long between the alarm's initial occurrence and its final repetition.
Definition alarm.cpp:378
void setProgramArguments(const TQString &arguments)
Set the arguments to the program to execute when the alarm is triggered.
Definition alarm.cpp:190
Alarm(Incidence *parent)
Construct a new alarm with variables initialized to "sane" values.
Definition alarm.cpp:32
void setMailAttachment(const TQString &mailAttachFile)
Attach this filename to the email.
Definition alarm.cpp:257
bool enabled() const
Get the alarm enabled status.
Definition alarm.cpp:438
TQString mailText() const
Return the email body text.
Definition alarm.cpp:295
bool hasTime() const
Return true, if the alarm has an explicit date/time.
Definition alarm.cpp:349
void setStartOffset(const Duration &)
Set offset of alarm in time relative to the start of the event.
Definition alarm.cpp:443
void setMailAddresses(const TQValueList< Person > &mailAlarmAddresses)
Send mail to these addresses when the alarm is triggered.
Definition alarm.cpp:223
void toggleAlarm()
Toggles the value of alarm to be either on or off.
Definition alarm.cpp:426
TQValueList< Person > mailAddresses() const
Return the addresses to send mail to when an alarm goes off.
Definition alarm.cpp:239
void setTime(const TQDateTime &alarmTime)
Set the time to trigger an alarm.
Definition alarm.cpp:321
Type type() const
Return the type of the alarm.
Definition alarm.cpp:144
void setAudioFile(const TQString &audioFile)
Set the file to play when the audio alarm is triggered.
Definition alarm.cpp:156
void setMailText(const TQString &text)
Set the email body text.
Definition alarm.cpp:287
void setType(Type type)
Set the type of the alarm.
Definition alarm.cpp:115
void setProgramFile(const TQString &programFile)
Set the program file to execute when the alarm is triggered.
Definition alarm.cpp:177
bool operator==(const Alarm &) const
Compare this alarm with another one.
Definition alarm.cpp:74
void setParent(Incidence *)
Set the alarm's parent incidence.
Definition alarm.cpp:479
TQDateTime endTime() const
Return the date/time when the last repetition of the alarm goes off.
Definition alarm.cpp:418
void setProcedureAlarm(const TQString &programFile, const TQString &arguments=TQString())
Set the alarm to be a procedure alarm.
Definition alarm.cpp:169
int repeatCount() const
Get how many times an alarm repeats, after its initial occurrence.
Definition alarm.cpp:373
TQStringList mailAttachments() const
Return the filenames to attach to the email.
Definition alarm.cpp:282
Incidence * parent() const
Get the alarm's parent incidence.
Definition alarm.h:351
Alarm & operator=(const Alarm &)
Copy operator.
Definition alarm.cpp:55
CustomProperties()
Construct a new empty custom properties instance.
This class represents a duration.
Definition duration.h:34
This class provides the base class common to all calendar components.
Definition incidence.h:48
This class provides a template for lists of pointers.
Definition listbase.h:34
This class represents a person.
Definition person.h:35
Namespace KCal is for global classes, objects and/or functions in libkcal.
Definition alarm.h:38