kpilot/lib

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 <qbitarray.h>
00035 #include <qdatetime.h>
00036 
00037 #include <pi-macros.h>
00038 #include <pi-datebook.h>
00039 
00040 #include "pilotRecord.h"
00041 #include "pilotAppInfo.h"
00042 
00043 namespace KCal
00044 {
00045 class Event;
00046 }
00047 
00049 class KDE_EXPORT PilotDateEntry : public PilotRecordBase
00050 {
00051 public:
00053     PilotDateEntry(struct AppointmentAppInfo &appInfo);
00054 
00056     PilotDateEntry(struct AppointmentAppInfo &appInfo, PilotRecord *rec);
00057 
00059     PilotDateEntry(const PilotDateEntry &e);
00060 
00062     ~PilotDateEntry()
00063     {
00064         free_Appointment(&fAppointmentInfo);
00065     }
00066 
00068     PilotDateEntry& operator=(const PilotDateEntry &e);
00069 
00074     QString getTextRepresentation(bool richText=false);
00075 
00084     inline bool doesFloat() const
00085     {
00086         return fAppointmentInfo.event;
00087     }
00088 
00092     inline bool isEvent() const
00093     {
00094         return doesFloat();
00095     }
00096 
00105     inline void setFloats(bool f)
00106     {
00107         fAppointmentInfo.event = (f ? 1 : 0) /* Force 1 or 0 */ ;
00108     }
00109 
00111     inline struct tm getEventStart() const { return fAppointmentInfo.begin; }
00112 
00114     inline const struct tm *getEventStart_p() const
00115     {
00116         return &fAppointmentInfo.begin;
00117     }
00118 
00120     inline void setEventStart(struct tm& start)
00121     {
00122         fAppointmentInfo.begin = start;
00123     }
00124 
00131     QDateTime dtStart() const;
00132 
00134     inline struct tm getEventEnd() const
00135     {
00136         return fAppointmentInfo.end;
00137     }
00138 
00140     inline const struct tm *getEventEnd_p() const
00141     {
00142         return &fAppointmentInfo.end;
00143     }
00144 
00146     inline void setEventEnd(struct tm& end)
00147     {
00148         fAppointmentInfo.end = end;
00149     }
00150 
00157     QDateTime dtEnd() const;
00158 
00163     inline bool isAlarmEnabled() const
00164     {
00165         return fAppointmentInfo.alarm;
00166     }
00167 
00169     inline void setAlarmEnabled(bool b)
00170     {
00171         fAppointmentInfo.alarm = (b?1:0) /* Force to known int values */ ;
00172     }
00173 
00183     inline int getAdvance() const
00184     {
00185         return fAppointmentInfo.advance;
00186     }
00187 
00189     inline void setAdvance(int advance)
00190     {
00191         fAppointmentInfo.advance = advance;
00192     }
00193 
00195     inline int getAdvanceUnits() const
00196     {
00197         return fAppointmentInfo.advanceUnits;
00198     }
00199 
00201     inline void setAdvanceUnits(int units)
00202     {
00203         fAppointmentInfo.advanceUnits = units;
00204     }
00205 
00210     unsigned int alarmLeadTime() const;
00211 
00215     inline QDateTime dtAlarm() const
00216     {
00217         return dtStart().addSecs(-alarmLeadTime());
00218     }
00219 
00220     // The following need set routines written
00221     inline repeatTypes getRepeatType() const
00222     {
00223         return fAppointmentInfo.repeatType;
00224     }
00225     inline void setRepeatType(repeatTypes r)
00226     {
00227         fAppointmentInfo.repeatType = r;
00228     }
00229 
00230     inline int getRepeatForever() const
00231     {
00232         return fAppointmentInfo.repeatForever;
00233     }
00234     inline void setRepeatForever(int f = 1)
00235     {
00236         fAppointmentInfo.repeatForever = f;
00237     }
00238 
00239     inline struct tm getRepeatEnd() const
00240     {
00241         return fAppointmentInfo.repeatEnd;
00242     }
00243     inline void setRepeatEnd(struct tm tm)
00244     {
00245         fAppointmentInfo.repeatEnd = tm;
00246     }
00247 
00251     QDateTime dtRepeatEnd() const;
00252 
00253     inline int getRepeatFrequency() const
00254     {
00255         return fAppointmentInfo.repeatFrequency;
00256     }
00257     inline void setRepeatFrequency(int f)
00258     {
00259         fAppointmentInfo.repeatFrequency = f;
00260     }
00261 
00262     inline DayOfMonthType getRepeatDay() const
00263     {
00264         return fAppointmentInfo.repeatDay;
00265     }
00266     inline void setRepeatDay(DayOfMonthType rd)
00267     {
00268         fAppointmentInfo.repeatDay = rd;
00269     };
00270 
00271     inline const int *getRepeatDays() const
00272     {
00273         return fAppointmentInfo.repeatDays;
00274     }
00275     inline void setRepeatDays(int *rd)
00276     {
00277         for (int i = 0; i < 7; i++)
00278         {
00279             fAppointmentInfo.repeatDays[i] = rd[i];
00280         }
00281     }
00282     inline void setRepeatDays(QBitArray rba)
00283     {
00284         for (int i = 0; i < 7; i++)
00285         {
00286             fAppointmentInfo.repeatDays[i] = (rba[i] ? 1 : 0);
00287         }
00288     }
00289 
00290     inline int getExceptionCount() const
00291     {
00292         return fAppointmentInfo.exceptions;
00293     }
00294     inline void setExceptionCount(int e)
00295     {
00296         fAppointmentInfo.exceptions = e;
00297     }
00298 
00299     inline const struct tm *getExceptions() const
00300     {
00301         return fAppointmentInfo.exception;
00302     }
00303     void setExceptions(struct tm *e);
00304 
00309     void setDescription(const QString &);
00311     QString getDescription() const;
00312 
00317     void setNote(const QString &);
00319     QString getNote() const;
00320 
00328     void setLocation(const QString &);
00329 
00331     QString getLocation() const;
00332 
00333 protected:
00334     void  setDescriptionP(const char* desc, int l=-1);
00335     const char* getDescriptionP() const
00336     {
00337         return fAppointmentInfo.description;
00338     }
00339 
00340     void  setNoteP(const char* note, int l=-1);
00341     const char* getNoteP() const
00342     {
00343         return fAppointmentInfo.note;
00344     }
00345 
00346 public:
00347     bool isMultiDay() const
00348     {
00349     return ((fAppointmentInfo.repeatType == repeatDaily) &&
00350         (fAppointmentInfo.repeatFrequency == 1) &&
00351         ( !getRepeatForever() ) &&
00352         !doesFloat() );
00353     }
00354 
00355     inline QString getCategoryLabel() const
00356     {
00357         return Pilot::categoryName(&(fAppInfo.category),category());
00358     }
00359     inline bool setCategory(const QString &label)
00360     {
00361         int c = Pilot::insertCategory(&fAppInfo.category,label,false);
00362         PilotRecordBase::setCategory(c);
00363         return c>=0;
00364     } ;
00365 
00366     PilotRecord *pack() const;
00367 
00371     const AppointmentAppInfo &appInfo()
00372     {
00373         return fAppInfo;
00374     }
00375 
00376 private:
00377     struct Appointment fAppointmentInfo;
00378     struct AppointmentAppInfo &fAppInfo;
00379     void _copyExceptions(const PilotDateEntry &e);
00380 };
00381 
00382 
00383 typedef PilotAppInfo<AppointmentAppInfo,unpack_AppointmentAppInfo, pack_AppointmentAppInfo> PilotDateInfo;
00384 
00385 
00386 #endif
00387 
KDE Home | KDE Accessibility Home | Description of Access Keys