kpilot

pilotDateEntry.h

Go to the documentation of this file.
00001 #ifndef _KPILOT_PILOTDATEENTRY_H
00002 #define _KPILOT_PILOTDATEENTRY_H
00003 /* pilotDateEntry.h -*- C++ -*- KPilot
00004 **
00005 ** Copyright (C) 1998-2001 by Dan Pilone
00006 ** Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
00007 **
00008 ** See the .cc file for an explanation of what this file is for.
00009 */
00010 
00013 /*
00014 ** This program is free software; you can redistribute it and/or modify
00015 ** it under the terms of the GNU Lesser General Public License as published by
00016 ** the Free Software Foundation; either version 2.1 of the License, or
00017 ** (at your option) any later version.
00018 **
00019 ** This program is distributed in the hope that it will be useful,
00020 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
00021 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00022 ** GNU Lesser General Public License for more details.
00023 **
00024 ** You should have received a copy of the GNU Lesser General Public License
00025 ** along with this program in a file called COPYING; if not, write to
00026 ** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
00027 ** MA 02110-1301, USA.
00028 */
00029 
00030 /*
00031 ** Bug reports and questions can be sent to kde-pim@kde.org
00032 */
00033 
00034 #include <pi-macros.h>
00035 #include <pi-datebook.h>
00036 
00037 #include <qbitarray.h>
00038 #include <qdatetime.h>
00039 #include <qnamespace.h>
00040 
00041 #include "pilotRecord.h"
00042 #include "pilotAppInfo.h"
00043 
00044 namespace KCal
00045 {
00046 class Event;
00047 }
00048 
00050 typedef PilotAppInfo<
00051     AppointmentAppInfo,
00052     unpack_AppointmentAppInfo, 
00053     pack_AppointmentAppInfo> PilotDateInfo_;
00054 
00055 
00056 class PilotDateInfo : public PilotDateInfo_
00057 {
00058 public:
00059     PilotDateInfo(PilotDatabase *d) : PilotDateInfo_(d)
00060     {
00061     }
00062 
00067     void resetToDefault();
00068 
00069 };
00070 
00072 class KDE_EXPORT PilotDateEntry : public PilotRecordBase
00073 {
00074 public:
00076     PilotDateEntry();
00077 
00079     PilotDateEntry(PilotRecord *rec);
00080 
00082     PilotDateEntry(const PilotDateEntry &e);
00083 
00085     ~PilotDateEntry()
00086     {
00087         free_Appointment(&fAppointmentInfo);
00088     }
00089 
00091     PilotDateEntry& operator=(const PilotDateEntry &e);
00092 
00097     QString getTextRepresentation(Qt::TextFormat richText);
00098 
00107     inline bool doesFloat() const
00108     {
00109         return fAppointmentInfo.event;
00110     }
00111 
00115     inline bool isEvent() const
00116     {
00117         return doesFloat();
00118     }
00119 
00128     inline void setFloats(bool f)
00129     {
00130         fAppointmentInfo.event = (f ? 1 : 0) /* Force 1 or 0 */ ;
00131     }
00132 
00134     inline struct tm getEventStart() const { return fAppointmentInfo.begin; }
00135 
00137     inline const struct tm *getEventStart_p() const
00138     {
00139         return &fAppointmentInfo.begin;
00140     }
00141 
00143     inline void setEventStart(struct tm& start)
00144     {
00145         fAppointmentInfo.begin = start;
00146     }
00147 
00154     QDateTime dtStart() const;
00155 
00157     inline struct tm getEventEnd() const
00158     {
00159         return fAppointmentInfo.end;
00160     }
00161 
00163     inline const struct tm *getEventEnd_p() const
00164     {
00165         return &fAppointmentInfo.end;
00166     }
00167 
00169     inline void setEventEnd(struct tm& end)
00170     {
00171         fAppointmentInfo.end = end;
00172     }
00173 
00180     QDateTime dtEnd() const;
00181 
00186     inline bool isAlarmEnabled() const
00187     {
00188         return fAppointmentInfo.alarm;
00189     }
00190 
00192     inline void setAlarmEnabled(bool b)
00193     {
00194         fAppointmentInfo.alarm = (b?1:0) /* Force to known int values */ ;
00195     }
00196 
00206     inline int getAdvance() const
00207     {
00208         return fAppointmentInfo.advance;
00209     }
00210 
00212     inline void setAdvance(int advance)
00213     {
00214         fAppointmentInfo.advance = advance;
00215     }
00216 
00218     inline int getAdvanceUnits() const
00219     {
00220         return fAppointmentInfo.advanceUnits;
00221     }
00222 
00224     inline void setAdvanceUnits(int units)
00225     {
00226         fAppointmentInfo.advanceUnits = units;
00227     }
00228 
00233     unsigned int alarmLeadTime() const;
00234 
00238     inline QDateTime dtAlarm() const
00239     {
00240         return dtStart().addSecs(-alarmLeadTime());
00241     }
00242 
00243     // The following need set routines written
00244     inline repeatTypes getRepeatType() const
00245     {
00246         return fAppointmentInfo.repeatType;
00247     }
00248     inline void setRepeatType(repeatTypes r)
00249     {
00250         fAppointmentInfo.repeatType = r;
00251     }
00252 
00253     inline int getRepeatForever() const
00254     {
00255         return fAppointmentInfo.repeatForever;
00256     }
00257     inline void setRepeatForever(int f = 1)
00258     {
00259         fAppointmentInfo.repeatForever = f;
00260     }
00261 
00262     inline struct tm getRepeatEnd() const
00263     {
00264         return fAppointmentInfo.repeatEnd;
00265     }
00266     inline void setRepeatEnd(struct tm tm)
00267     {
00268         fAppointmentInfo.repeatEnd = tm;
00269     }
00270 
00274     QDateTime dtRepeatEnd() const;
00275 
00276     inline int getRepeatFrequency() const
00277     {
00278         return fAppointmentInfo.repeatFrequency;
00279     }
00280     inline void setRepeatFrequency(int f)
00281     {
00282         fAppointmentInfo.repeatFrequency = f;
00283     }
00284 
00285     inline DayOfMonthType getRepeatDay() const
00286     {
00287         return fAppointmentInfo.repeatDay;
00288     }
00289     inline void setRepeatDay(DayOfMonthType rd)
00290     {
00291         fAppointmentInfo.repeatDay = rd;
00292     };
00293 
00294     inline const int *getRepeatDays() const
00295     {
00296         return fAppointmentInfo.repeatDays;
00297     }
00298     inline void setRepeatDays(int *rd)
00299     {
00300         for (int i = 0; i < 7; i++)
00301         {
00302             fAppointmentInfo.repeatDays[i] = rd[i];
00303         }
00304     }
00305     inline void setRepeatDays(QBitArray rba)
00306     {
00307         for (int i = 0; i < 7; i++)
00308         {
00309             fAppointmentInfo.repeatDays[i] = (rba[i] ? 1 : 0);
00310         }
00311     }
00312 
00313     inline int getExceptionCount() const
00314     {
00315         return fAppointmentInfo.exceptions;
00316     }
00317     inline void setExceptionCount(int e)
00318     {
00319         fAppointmentInfo.exceptions = e;
00320     }
00321 
00322     inline const struct tm *getExceptions() const
00323     {
00324         return fAppointmentInfo.exception;
00325     }
00326     void setExceptions(struct tm *e);
00327 
00332     void setDescription(const QString &);
00334     QString getDescription() const;
00335 
00340     void setNote(const QString &);
00342     QString getNote() const;
00343 
00351     void setLocation(const QString &);
00352 
00354     QString getLocation() const;
00355 
00356 protected:
00357     void  setDescriptionP(const char* desc, int l=-1);
00358     const char* getDescriptionP() const
00359     {
00360         return fAppointmentInfo.description;
00361     }
00362 
00363     void  setNoteP(const char* note, int l=-1);
00364     const char* getNoteP() const
00365     {
00366         return fAppointmentInfo.note;
00367     }
00368 
00369 public:
00370     bool isMultiDay() const
00371     {
00372     return ((fAppointmentInfo.repeatType == repeatDaily) &&
00373         (fAppointmentInfo.repeatFrequency == 1) &&
00374         ( !getRepeatForever() ) &&
00375         !doesFloat() );
00376     }
00377 
00378     PilotRecord *pack() const;
00379 
00380 private:
00381     struct Appointment fAppointmentInfo;
00382     void _copyExceptions(const PilotDateEntry &e);
00383 };
00384 
00385 
00386 
00387 #endif
00388