libkcal

alarm.h

Go to the documentation of this file.
00001 /*
00002     This file is part of libkcal.
00003 
00004     Copyright (c) 2001-2003 Cornelius Schumacher <schumacher@kde.org>
00005 
00006     This library is free software; you can redistribute it and/or
00007     modify it under the terms of the GNU Library General Public
00008     License as published by the Free Software Foundation; either
00009     version 2 of the License, or (at your option) any later version.
00010 
00011     This library is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014     Library General Public License for more details.
00015 
00016     You should have received a copy of the GNU Library General Public License
00017     along with this library; see the file COPYING.LIB.  If not, write to
00018     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019     Boston, MA 02110-1301, USA.
00020 */
00021 
00022 #ifndef KCAL_ALARM_H
00023 #define KCAL_ALARM_H
00024 
00025 #include <qstring.h>
00026 #include <qstringlist.h>
00027 #include <qvaluelist.h>
00028 
00029 #include "customproperties.h"
00030 #include "duration.h"
00031 #include "person.h"
00032 #include "listbase.h"
00033 #include "libkcal_export.h"
00034 
00035 #include <kdepimmacros.h>
00036 
00037 namespace KCal {
00038 
00039 class Incidence;
00040 
00044 class LIBKCAL_EXPORT Alarm : public CustomProperties
00045 {
00046   public:
00047     enum Type { Invalid, Display, Procedure, Email, Audio };
00048 
00049     typedef ListBase<Alarm> List;
00050 
00054     explicit Alarm( Incidence *parent );
00058     ~Alarm();
00059 
00063     bool operator==( const Alarm & ) const;
00064     bool operator!=( const Alarm &a ) const { return !operator==( a ); }
00065 
00073     void setType( Type type );
00077     Type type() const;
00078 
00084     void setDisplayAlarm( const QString &text = QString::null );
00089     void setText( const QString &text );
00093     QString text() const;
00094 
00100     void setAudioAlarm( const QString &audioFile = QString::null );
00105     void setAudioFile( const QString &audioFile );
00111     QString audioFile() const;
00112 
00119     void setProcedureAlarm( const QString &programFile,
00120                             const QString &arguments = QString::null );
00125     void setProgramFile( const QString &programFile );
00131     QString programFile() const;
00136     void setProgramArguments( const QString &arguments );
00142     QString programArguments() const;
00143 
00152     void setEmailAlarm( const QString &subject, const QString &text,
00153                         const QValueList<Person> &addressees,
00154                         const QStringList &attachments = QStringList() );
00155 
00160     void setMailAddress( const Person &mailAlarmAddress );
00165     void setMailAddresses( const QValueList<Person> &mailAlarmAddresses );
00170     void addMailAddress( const Person &mailAlarmAddress );
00174     QValueList<Person> mailAddresses() const;
00175 
00180     void setMailSubject( const QString &mailAlarmSubject );
00184     QString mailSubject() const;
00185 
00190     void setMailAttachment( const QString &mailAttachFile );
00195     void setMailAttachments( const QStringList &mailAttachFiles );
00200     void addMailAttachment( const QString &mailAttachFile );
00204     QStringList mailAttachments() const;
00205 
00210     void setMailText( const QString &text );
00216     QString mailText() const;
00217 
00221     void setTime( const QDateTime &alarmTime );
00225     QDateTime time() const;
00230     QDateTime endTime() const;
00234     bool hasTime() const;
00235 
00239     void setStartOffset( const Duration & );
00245     Duration startOffset() const;
00250     bool hasStartOffset() const;
00251 
00255     void setEndOffset( const Duration & );
00261     Duration endOffset() const;
00266     bool hasEndOffset() const;
00267 
00273     void setSnoozeTime( int alarmSnoozeTime );
00274 
00280     int snoozeTime() const;
00281 
00286     void setRepeatCount( int alarmRepeatCount );
00290     int repeatCount() const;
00298     QDateTime nextRepetition(const QDateTime& preTime) const;
00306     QDateTime previousRepetition(const QDateTime& afterTime) const;
00311     int duration() const;
00312 
00317     void toggleAlarm();
00318 
00322     void setEnabled(bool enable);
00326     bool enabled() const;
00327 
00331     void setParent( Incidence * );
00335     Incidence *parent() const  { return mParent; }
00336 
00337   protected:
00342     virtual void customPropertyUpdated();
00343 
00344   private:
00345     Incidence *mParent;          // the incidence which this alarm belongs to
00346     Type mType;                  // type of alarm
00347     QString mDescription;        // text to display/email body/procedure arguments
00348     QString mFile;               // procedure program to run/optional audio file to play
00349     QStringList mMailAttachFiles;      // filenames to attach to email
00350     QValueList<Person> mMailAddresses; // who to mail for reminder
00351     QString mMailSubject;        // subject of email
00352 
00353     int mAlarmSnoozeTime;        // number of minutes after alarm to
00354                                  // snooze before ringing again
00355     int mAlarmRepeatCount;       // number of times for alarm to repeat
00356                                  // after the initial time
00357 
00358     QDateTime mAlarmTime;        // time at which to trigger the alarm
00359     Duration mOffset;            // time relative to incidence DTSTART to trigger the alarm
00360     bool mEndOffset;             // if true, mOffset relates to DTEND, not DTSTART
00361     bool mHasTime;               // use mAlarmTime, not mOffset
00362     bool mAlarmEnabled;
00363 
00364     class Private;
00365     Private *d;
00366 };
00367 
00368 }
00369 
00370 #endif