pilotMemo.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 static const char *pilotMemo_id =
00029 "$Id: pilotMemo.cc,v 1.2.4.4 2003/03/12 23:31:15 adridg Exp $";
00030
00031 #include "options.h"
00032
00033 #include <qtextcodec.h>
00034
00035 #include "pilotMemo.h"
00036
00037
00038
00039 PilotMemo::PilotMemo(PilotRecord * rec) : PilotAppCategory(rec)
00040 {
00041 FUNCTIONSETUP;
00042 unpack(rec->getData(), 1);
00043 (void) pilotMemo_id;
00044 }
00045
00046 void PilotMemo::unpack(const void *text, int )
00047 {
00048 FUNCTIONSETUP;
00049
00050 fText = codec()->toUnicode((const char *)text);
00051 }
00052
00053
00054 void *PilotMemo::internalPack(unsigned char *buf)
00055 {
00056 FUNCTIONSETUP;
00057 QCString s = codec()->fromUnicode(fText);
00058 return strcpy((char *) buf, (const char *)s);
00059 }
00060
00061 void *PilotMemo::pack(void *buf, int *len)
00062 {
00063 FUNCTIONSETUP;
00064 if (((unsigned)*len) < fText.length())
00065 return NULL;
00066
00067 *len = fText.length();
00068
00069 return internalPack((unsigned char *) buf);
00070 }
00071
00072
00073 QString PilotMemo::getTitle() const
00074 {
00075 if (fText.isEmpty()) return QString::null;
00076
00077 int memoTitleLen = fText.find('\n');
00078 if (-1 == memoTitleLen) memoTitleLen=fText.length();
00079 return fText.left(memoTitleLen);
00080 }
00081
00082 QString PilotMemo::shortTitle() const
00083 {
00084 FUNCTIONSETUP;
00085 QString t = QString(getTitle()).simplifyWhiteSpace();
00086
00087 if (t.length() < 32)
00088 return t;
00089 t.truncate(40);
00090
00091 int spaceIndex = t.findRev(' ');
00092
00093 if (spaceIndex > 32)
00094 {
00095 t.truncate(spaceIndex);
00096 }
00097
00098 t += CSL1("...");
00099
00100 return t;
00101 }
00102
00103 QString PilotMemo::sensibleTitle() const
00104 {
00105 FUNCTIONSETUP;
00106 QString s = getTitle();
00107
00108 if (!s.isEmpty())
00109 {
00110 return s;
00111 }
00112 else
00113 {
00114 return QString(i18n("[unknown]"));
00115 }
00116 }
This file is part of the documentation for kdelibs Version 3.1.5.