kpilot/lib
pilotAddress.h00001 #ifndef _KPILOT_PILOTADDRESS_H
00002 #define _KPILOT_PILOTADDRESS_H
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
00029
00030
00031
00032 #include <pi-macros.h>
00033 #include <pi-address.h>
00034
00035 #include <kabc/addressbook.h>
00036
00037 #include "pilotRecord.h"
00038 #include "pilotAppInfo.h"
00039
00041 typedef PilotAppInfo<
00042 AddressAppInfo,
00043 unpack_AddressAppInfo,
00044 pack_AddressAppInfo> PilotAddressInfo;
00045
00080 class KDE_EXPORT PilotAddress : public PilotRecordBase
00081 {
00082 public:
00083 enum EPhoneType {
00084 eWork=0, eHome, eFax, eOther, eEmail, eMain,
00085 ePager, eMobile
00086 };
00087
00088 PilotAddress(PilotAddressInfo *appinfo, PilotRecord *rec = 0L);
00089 PilotAddress(const PilotAddress ©From);
00090 PilotAddress& operator=( const PilotAddress &r );
00091 bool operator==(const PilotAddress &r);
00092
00093 virtual ~PilotAddress();
00094
00098 QString getTextRepresentation(bool richText=false) const;
00099
00103 void reset() { memset(&fAddressInfo, 0, sizeof(struct Address)); }
00104
00116 void setField(int field, const QString &text);
00117 QString getField(int field) const;
00118
00123 QStringList getEmails() const;
00124 void setEmails(QStringList emails);
00125
00130 KABC::PhoneNumber::List getPhoneNumbers() const;
00131 void setPhoneNumbers(KABC::PhoneNumber::List list);
00132
00133 QString getCategoryLabel() const;
00134
00139 inline bool setCategory(const QString &label)
00140 {
00141 int c = Pilot::insertCategory(&fAppInfo.category,label,false);
00142 PilotRecordBase::setCategory(c);
00143 return c>=0;
00144 } ;
00145
00146
00153 QString getPhoneField(EPhoneType type, bool checkCustom4=true) const;
00154
00164 int setPhoneField(EPhoneType type, const QString &field,
00165 bool overflowCustom=true, bool overwriteExisting=true);
00166
00175 int getShownPhone() const { return fAddressInfo.showPhone; }
00176 void setShownPhone(EPhoneType phoneType);
00177 int getPhoneLabelIndex(int index) const { return fAddressInfo.phoneLabel[index]; }
00178
00179
00180 PilotRecord *pack() const;
00181
00182 const struct Address *address() const { return &fAddressInfo; } ;
00183
00184 protected:
00185
00186
00187
00188 const char *getFieldP(int field) const
00189 { return fAddressInfo.entry[field]; }
00190
00191 private:
00192 void _copyAddressInfo(const struct Address ©From);
00193 int _getNextEmptyPhoneSlot() const;
00194
00198 int _getAppPhoneLabelNum(const QString &phoneType) const;
00199
00203 int _findPhoneFieldSlot(int appTypeNum) const;
00204
00205 void _loadMaps();
00206
00208 QMap < int, int> pilotToPhoneMap;
00209
00210 struct AddressAppInfo &fAppInfo;
00211 struct Address fAddressInfo;
00212 };
00213
00214
00215
00216
00217 #endif
|