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 
00036 #include <pi-macros.h>
00037 #include <pi-datebook.h>
00038 
00039 #include "pilotAppCategory.h"
00040 #include "pilotDatabase.h"
00041 
00042 namespace KCal
00043 {
00044 class Event;
00045 }
00046 
00048 class KDE_EXPORT PilotDateEntry : public PilotAppCategory
00049 {
00050 public:
00052     PilotDateEntry(struct AppointmentAppInfo &appInfo);
00053 
00055     PilotDateEntry(struct AppointmentAppInfo &appInfo, PilotRecord* rec);
00056 
00058     PilotDateEntry(const PilotDateEntry &e);
00059 
00061     ~PilotDateEntry() { free_Appointment(&fAppointmentInfo); }
00062 
00064     PilotDateEntry& operator=(const PilotDateEntry &e);
00065 
00070     virtual QString getTextRepresentation(bool richText=false);
00071 
00080     bool doesFloat() const { return fAppointmentInfo.event; }
00084     inline bool isEvent() const { return doesFloat(); }
00086     int KDE_DEPRECATED getEvent() const { return doesFloat(); }
00087 
00096     void setFloats(bool f) { fAppointmentInfo.event = (f ? 1 : 0) /* Force 1 or 0 */ ; }
00098     void KDE_DEPRECATED setEvent(int event) { setFloats( event ); }
00099 
00101     struct tm getEventStart() const { return fAppointmentInfo.begin; }
00103     const struct tm *getEventStart_p() const { return &fAppointmentInfo.begin; }
00105     void setEventStart(struct tm& start) { fAppointmentInfo.begin = start; }
00112     QDateTime dtStart() const;
00113 
00115     struct tm getEventEnd() const { return fAppointmentInfo.end; }
00117     const struct tm *getEventEnd_p() const { return &fAppointmentInfo.end; }
00119     void setEventEnd(struct tm& end) { fAppointmentInfo.end = end; }
00126     QDateTime dtEnd() const;
00127 
00132     bool isAlarmEnabled() const { return fAppointmentInfo.alarm; }
00134     int KDE_DEPRECATED getAlarm() const { return fAppointmentInfo.alarm; }
00136     void KDE_DEPRECATED setAlarm(int alarm) { fAppointmentInfo.alarm = alarm; }
00138     void setAlarmEnabled(bool b) { fAppointmentInfo.alarm = (b?1:0) /* Force to known int values */ ; }
00139 
00149     int getAdvance() const { return fAppointmentInfo.advance; }
00151     void setAdvance(int advance) { fAppointmentInfo.advance = advance; }
00152 
00154     int getAdvanceUnits() const { return fAppointmentInfo.advanceUnits; }
00156     void setAdvanceUnits(int units) { fAppointmentInfo.advanceUnits = units; }
00157 
00162     unsigned int alarmLeadTime() const;
00163 
00167     QDateTime dtAlarm() const { return dtStart().addSecs(-alarmLeadTime()); }
00168 
00169   // The following need set routines written
00170   repeatTypes getRepeatType() const { return fAppointmentInfo.repeatType; }
00171   void setRepeatType(repeatTypes r) { fAppointmentInfo.repeatType = r; }
00172 
00173   int getRepeatForever() const { return fAppointmentInfo.repeatForever; }
00174   void setRepeatForever(int f = 1) { fAppointmentInfo.repeatForever = f; }
00175 
00176   struct tm getRepeatEnd() const { return fAppointmentInfo.repeatEnd; }
00177   void setRepeatEnd(struct tm tm) { fAppointmentInfo.repeatEnd = tm; }
00181     QDateTime dtRepeatEnd() const;
00182 
00183   int getRepeatFrequency() const { return fAppointmentInfo.repeatFrequency; }
00184   void setRepeatFrequency(int f) { fAppointmentInfo.repeatFrequency = f; }
00185 
00186   DayOfMonthType getRepeatDay() const { return fAppointmentInfo.repeatDay; }
00187   void setRepeatDay(DayOfMonthType rd) { fAppointmentInfo.repeatDay = rd; };
00188 
00189   const int *getRepeatDays() const { return fAppointmentInfo.repeatDays; }
00190   void setRepeatDays(int *rd) {
00191     for (int i = 0; i < 7; i++)
00192       fAppointmentInfo.repeatDays[i] = rd[i];
00193   }
00194   void setRepeatDays(QBitArray rba) {
00195     for (int i = 0; i < 7; i++)
00196       fAppointmentInfo.repeatDays[i] = (rba[i] ? 1 : 0);
00197   }
00198 
00199   int getExceptionCount() const { return fAppointmentInfo.exceptions; }
00200   void setExceptionCount(int e) { fAppointmentInfo.exceptions = e; }
00201 
00202   const struct tm *getExceptions() const { return fAppointmentInfo.exception; }
00203   void setExceptions(struct tm *e);
00204 
00209     void setDescription(const QString &);
00211     QString getDescription() const;
00212 
00217     void setNote(const QString &);
00219     QString getNote() const;
00220 
00221 protected:
00222     void  setDescriptionP(const char* desc, int l=-1);
00223     const char* getDescriptionP() const { return fAppointmentInfo.description; }
00224 
00225     void  setNoteP(const char* note, int l=-1);
00226     const char* getNoteP() const { return fAppointmentInfo.note; }
00227 
00228 public:
00229   bool isMultiDay() const {
00230     return ((fAppointmentInfo.repeatType == repeatDaily) &&
00231             (fAppointmentInfo.repeatFrequency == 1) &&
00232             ( !getRepeatForever() ) &&
00233             !doesFloat() );
00234   }
00235 
00236   QString getCategoryLabel() const;
00237   inline bool setCategory(const QString &label) { return PilotAppCategory::setCategory(fAppInfo.category,label); } ;
00238   static const int KDE_DEPRECATED APP_BUFFER_SIZE;
00239 
00240 protected:
00241   void *pack_(void *buf, int *size);
00242   void unpack(const void *buf, int size = 0) { }
00243 
00244 private:
00245   struct Appointment fAppointmentInfo;
00246         struct AppointmentAppInfo &fAppInfo;
00247     void _copyExceptions(const PilotDateEntry &e);
00248 };
00249 
00250 
00251 typedef PilotAppInfo<AppointmentAppInfo,unpack_AppointmentAppInfo, pack_AppointmentAppInfo> PilotDateInfo;
00252 
00253 
00254 #endif
00255 
KDE Home | KDE Accessibility Home | Description of Access Keys