libkcal Library API Documentation

alarm.cpp

00001 /*
00002     This file is part of libkcal.
00003     Copyright (c) 1998 Preston Brown
00004     Copyright (c) 2001 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., 59 Temple Place - Suite 330,
00019     Boston, MA 02111-1307, USA.
00020 */
00021 
00022 #include <kdebug.h>
00023 
00024 #include "incidence.h"
00025 #include "todo.h"
00026 
00027 #include "alarm.h"
00028 
00029 using namespace KCal;
00030 
00031 Alarm::Alarm(Incidence *parent)
00032 {
00033   mParent = parent;
00034 
00035   mAlarmSnoozeTime = 5;
00036   mAlarmRepeatCount = 0;
00037   mAlarmEnabled = false;
00038 
00039   mHasTime = false;
00040 }
00041 
00042 Alarm::~Alarm()
00043 {
00044 }
00045 
00046 void Alarm::setAudioFile(const QString &audioAlarmFile)
00047 {
00048   mAudioAlarmFile = audioAlarmFile;
00049   mParent->updated();
00050 }
00051 
00052 QString Alarm::audioFile() const
00053 {
00054   return mAudioAlarmFile;
00055 }
00056 
00057 void Alarm::setProgramFile(const QString &programAlarmFile)
00058 {
00059   mProgramAlarmFile = programAlarmFile;
00060   mParent->updated();
00061 }
00062 
00063 QString Alarm::programFile() const
00064 {
00065   return mProgramAlarmFile;
00066 }
00067 
00068 void Alarm::setMailAddress(const QString &mailAlarmAddress)
00069 {
00070   mMailAlarmAddresses.clear();
00071   mMailAlarmAddresses += mailAlarmAddress;
00072   mParent->updated();
00073 }
00074 
00075 void Alarm::setMailAddresses(const QStringList &mailAlarmAddresses)
00076 {
00077   mMailAlarmAddresses = mailAlarmAddresses;
00078   mParent->updated();
00079 }
00080 
00081 void Alarm::addMailAddress(const QString &mailAlarmAddress)
00082 {
00083   mMailAlarmAddresses += mailAlarmAddress;
00084   mParent->updated();
00085 }
00086 
00087 QStringList Alarm::mailAddresses() const
00088 {
00089   return mMailAlarmAddresses;
00090 }
00091 
00092 void Alarm::setMailSubject(const QString &mailAlarmSubject)
00093 {
00094   mMailAlarmSubject = mailAlarmSubject;
00095   mParent->updated();
00096 }
00097 
00098 QString Alarm::mailSubject() const
00099 {
00100   return mMailAlarmSubject;
00101 }
00102 
00103 void Alarm::setMailAttachment(const QString &mailAttachFile)
00104 {
00105   mMailAttachFiles.clear();
00106   mMailAttachFiles += mailAttachFile;
00107   mParent->updated();
00108 }
00109 
00110 void Alarm::setMailAttachments(const QStringList &mailAttachFiles)
00111 {
00112   mMailAttachFiles = mailAttachFiles;
00113   mParent->updated();
00114 }
00115 
00116 void Alarm::addMailAttachment(const QString &mailAttachFile)
00117 {
00118   mMailAttachFiles += mailAttachFile;
00119   mParent->updated();
00120 }
00121 
00122 QStringList Alarm::mailAttachments() const
00123 {
00124   return mMailAttachFiles;
00125 }
00126 
00127 void Alarm::setText(const QString &alarmText)
00128 {
00129   mAlarmText = alarmText;
00130   mParent->updated();
00131 }
00132 
00133 QString Alarm::text() const
00134 {
00135   return mAlarmText;
00136 }
00137 
00138 void Alarm::setTime(const QDateTime &alarmTime)
00139 {
00140   mAlarmTime = alarmTime;
00141   mHasTime = true;
00142 
00143   mParent->updated();
00144 }
00145 
00146 QDateTime Alarm::time() const
00147 {
00148   if ( hasTime() ) return mAlarmTime;
00149   else
00150   {
00151     if (mParent->type()=="Todo") {
00152       Todo *t = static_cast<Todo*>(mParent);
00153       return mOffset.end( t->dtDue() );
00154     } else {
00155       return mOffset.end( mParent->dtStart() );
00156     }
00157   }
00158 }
00159 
00160 bool Alarm::hasTime() const
00161 {
00162   return mHasTime;
00163 }
00164 
00165 void Alarm::setSnoozeTime(int alarmSnoozeTime)
00166 {
00167   mAlarmSnoozeTime = alarmSnoozeTime;
00168   mParent->updated();
00169 }
00170 
00171 int Alarm::snoozeTime() const
00172 {
00173   return mAlarmSnoozeTime;
00174 }
00175 
00176 void Alarm::setRepeatCount(int alarmRepeatCount)
00177 {
00178   kdDebug(5800) << "Alarm::setRepeatCount(): " << alarmRepeatCount << endl;
00179 
00180   mAlarmRepeatCount = alarmRepeatCount;
00181   mParent->updated();
00182 }
00183 
00184 int Alarm::repeatCount() const
00185 {
00186   kdDebug(5800) << "Alarm::repeatCount(): " << mAlarmRepeatCount << endl;
00187   return mAlarmRepeatCount;
00188 }
00189 
00190 void Alarm::toggleAlarm()
00191 {
00192   if (mAlarmEnabled) {
00193     mAlarmEnabled = false;
00194   } else {
00195     mAlarmEnabled = true;
00196   }
00197 
00198   mParent->updated();
00199 }
00200 
00201 void Alarm::setEnabled(bool enable)
00202 {
00203   mAlarmEnabled = enable;
00204   mParent->updated();
00205 }
00206 
00207 bool Alarm::enabled() const
00208 {
00209   return mAlarmEnabled;
00210 }
00211 
00212 void Alarm::setOffset( const Duration &offset )
00213 {
00214   mOffset = offset;
00215   mHasTime = false;
00216 
00217   mParent->updated();
00218 }
00219 
00220 Duration Alarm::offset() const
00221 {
00222   return mOffset;
00223 }
00224 
00225 void Alarm::setParent( Incidence *parent )
00226 {
00227   mParent = parent;
00228 }
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.4.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Sat Oct 18 02:47:03 2003 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001