pilotTodoEntry.cc
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #include "options.h"
00029
00030 #include <stdlib.h>
00031
00032 #include <qtextcodec.h>
00033
00034 #include <kdebug.h>
00035
00036
00037 #include "pilotTodoEntry.h"
00038
00039 static const char *pilotTodoEntry_id = "$Id: pilotTodoEntry.cc,v 1.7.4.4 2003/03/12 23:31:16 adridg Exp $";
00040 const int PilotTodoEntry::APP_BUFFER_SIZE = 0xffff;
00041
00042
00043 PilotTodoEntry::PilotTodoEntry(struct ToDoAppInfo &appInfo):PilotAppCategory(), fAppInfo(appInfo)
00044 {
00045 FUNCTIONSETUP;
00046 ::memset(&fTodoInfo, 0, sizeof(struct ToDo));
00047 }
00048
00049
00050
00051 PilotTodoEntry::PilotTodoEntry(struct ToDoAppInfo &appInfo, PilotRecord * rec):PilotAppCategory(rec), fAppInfo(appInfo)
00052 {
00053 ::memset(&fTodoInfo, 0, sizeof(struct ToDo));
00054 if (rec)
00055 {
00056 unpack_ToDo(&fTodoInfo, (unsigned char *) rec->getData(),
00057 rec->getLen());
00058 }
00059 (void) pilotTodoEntry_id;
00060 }
00061
00062
00063 PilotTodoEntry::PilotTodoEntry(const PilotTodoEntry & e):PilotAppCategory(e), fAppInfo(e.fAppInfo)
00064 {
00065 FUNCTIONSETUP;
00066 ::memcpy(&fTodoInfo, &e.fTodoInfo, sizeof(fTodoInfo));
00067
00068 fTodoInfo.description = 0L;
00069 fTodoInfo.note = 0L;
00070
00071 setDescriptionP(e.getDescriptionP());
00072 setNoteP(e.getNoteP());
00073
00074 }
00075
00076
00077 PilotTodoEntry & PilotTodoEntry::operator = (const PilotTodoEntry & e)
00078 {
00079 if (this != &e)
00080 {
00081 KPILOT_FREE(fTodoInfo.description);
00082 KPILOT_FREE(fTodoInfo.note);
00083
00084 ::memcpy(&fTodoInfo, &e.fTodoInfo, sizeof(fTodoInfo));
00085
00086 fTodoInfo.description = 0L;
00087 fTodoInfo.note = 0L;
00088
00089 setDescriptionP(e.getDescriptionP());
00090 setNoteP(e.getNoteP());
00091
00092 }
00093
00094 return *this;
00095 }
00096
00097 bool PilotTodoEntry::setCategory(const QString &label)
00098 {
00099 FUNCTIONSETUP;
00100 for (int catId = 0; catId < 16; catId++)
00101 {
00102 QString aCat = codec()->toUnicode(fAppInfo.category.name[catId]);
00103
00104 if (label == aCat)
00105 {
00106 setCat(catId);
00107 return true;
00108 }
00109 else
00110
00111 if (aCat.isEmpty())
00112 {
00113 qstrncpy(fAppInfo.category.name[catId],
00114 codec()->fromUnicode(label), 16);
00115 setCat(catId);
00116 return true;
00117 }
00118 }
00119
00120 return false;
00121 }
00122
00123 QString PilotTodoEntry::getCategoryLabel() const
00124 {
00125 return codec()->toUnicode(fAppInfo.category.name[getCat()]);
00126 }
00127
00128 void *PilotTodoEntry::pack(void *buf, int *len)
00129 {
00130 int i;
00131
00132 i = pack_ToDo(&fTodoInfo, (unsigned char *) buf, *len);
00133 *len = i;
00134 return buf;
00135 }
00136
00137 void PilotTodoEntry::setDescription(const QString &desc)
00138 {
00139 setDescriptionP(codec()->fromUnicode(desc),desc.length());
00140 }
00141
00142 void PilotTodoEntry::setDescriptionP(const char *desc, int len)
00143 {
00144 KPILOT_FREE(fTodoInfo.description);
00145 if (desc && *desc)
00146 {
00147 if (-1 == len) len=::strlen(desc);
00148
00149 fTodoInfo.description = (char *)::malloc(len + 1);
00150 if (fTodoInfo.description)
00151 {
00152 ::strcpy(fTodoInfo.description, desc);
00153 }
00154 else
00155 {
00156 kdError(LIBPILOTDB_AREA) << __FUNCTION__
00157 << ": malloc() failed, description not set"
00158 << endl;
00159 }
00160 }
00161 else
00162 {
00163 fTodoInfo.description = 0L;
00164 }
00165 }
00166
00167 QString PilotTodoEntry::getDescription() const
00168 {
00169 return codec()->toUnicode(getDescriptionP());
00170 }
00171
00172 void PilotTodoEntry::setNote(const QString ¬e)
00173 {
00174 setNoteP(codec()->fromUnicode(note),note.length());
00175 }
00176
00177 void PilotTodoEntry::setNoteP(const char *note, int len)
00178 {
00179 KPILOT_FREE(fTodoInfo.note);
00180 if (note && *note)
00181 {
00182 if (-1 == len) len=::strlen(note);
00183 fTodoInfo.note = (char *)::malloc(len + 1);
00184 if (fTodoInfo.note)
00185 {
00186 ::strcpy(fTodoInfo.note, note);
00187 }
00188 else
00189 {
00190 kdError(LIBPILOTDB_AREA) << __FUNCTION__
00191 << ": malloc() failed, note not set" << endl;
00192 }
00193 }
00194 else
00195 {
00196 fTodoInfo.note = 0L;
00197 }
00198 }
00199
00200 QString PilotTodoEntry::getNote() const
00201 {
00202 return codec()->toUnicode(getNoteP());
00203 }
00204
This file is part of the documentation for kdelibs Version 3.1.5.