kpilot
pilotAddress.hGo to the documentation of this file.00001 #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
00033 #include <pi-macros.h>
00034 #include <pi-address.h>
00035
00036 #include <qnamespace.h>
00037
00038 #include "pilotRecord.h"
00039 #include "pilotAppInfo.h"
00040
00042 typedef PilotAppInfo<
00043 AddressAppInfo,
00044 unpack_AddressAppInfo,
00045 pack_AddressAppInfo> PilotAddressInfo_;
00046
00062 class PhoneSlot
00063 {
00064 friend class PilotAddress;
00065 protected:
00069 explicit PhoneSlot( const int v );
00070
00075 const PhoneSlot &operator=(const int &v);
00076
00081 unsigned int toOffset() const;
00082
00084 unsigned int toField() const;
00085
00086 public:
00087 static const int invalid = -1;
00088
00090 PhoneSlot()
00091 {
00092 i = invalid;
00093 }
00094
00096 bool operator ==( const PhoneSlot &v ) const
00097 {
00098 return v.i == i;
00099 }
00100
00104 const PhoneSlot &operator++();
00105
00107 static const PhoneSlot begin();
00108
00112 static const PhoneSlot end();
00113
00117 bool isValid() const
00118 {
00119 return (entryPhone1 <= i) && (i <= entryPhone5);
00120 }
00121
00122 operator QString() const;
00123 private:
00124 int i;
00125 } ;
00126
00127
00128 class PilotAddressInfo : public PilotAddressInfo_
00129 {
00130 public:
00131 PilotAddressInfo(PilotDatabase *d) : PilotAddressInfo_(d)
00132 {
00133 }
00134
00139 void resetToDefault();
00140
00141 enum EPhoneType {
00142 eWork=0,
00143 eHome,
00144 eFax,
00145 eOther,
00146 eEmail,
00147 eMain,
00148 ePager,
00149 eMobile,
00150 eNone=-1
00151 } ;
00152
00153 QString phoneLabel(EPhoneType i) const;
00154 } ;
00155
00190 class KDE_EXPORT PilotAddress : public PilotRecordBase
00191 {
00192 public:
00193 PilotAddress(PilotRecord *rec = 0L);
00194 PilotAddress(const PilotAddress ©From);
00195 PilotAddress& operator=( const PilotAddress &r );
00196 bool operator==(const PilotAddress &r);
00197
00198 virtual ~PilotAddress();
00199
00205 QString getTextRepresentation(const PilotAddressInfo *info, Qt::TextFormat richText) const;
00206
00218 void setField(int field, const QString &text);
00220 void setField(const PhoneSlot &i, const QString &t)
00221 {
00222 if (i.isValid())
00223 {
00224 setField(i.toField(),t);
00225 }
00226 }
00227
00231 QString getField(int field) const;
00233 QString getField(const PhoneSlot &i) const
00234 {
00235 return i.isValid() ? getField(i.toField()) : QString();
00236 }
00237
00242 QStringList getEmails() const;
00243 void setEmails(const QStringList &emails);
00244
00245 enum PhoneHandlingFlags
00246 {
00247 NoFlags=0,
00248 Replace
00249 } ;
00250
00257 QString getPhoneField(PilotAddressInfo::EPhoneType type) const;
00258
00268 PhoneSlot setPhoneField(PilotAddressInfo::EPhoneType type, const QString &value, PhoneHandlingFlags flags);
00269
00277 PhoneSlot getShownPhone() const;
00278
00291 PhoneSlot setShownPhone(PilotAddressInfo::EPhoneType phoneType);
00292
00299 const PhoneSlot &setShownPhone(const PhoneSlot &v);
00300
00308 PilotAddressInfo::EPhoneType getPhoneType(const PhoneSlot &field) const;
00309
00310 PilotRecord *pack() const;
00311
00312 const struct Address *address() const { return &fAddressInfo; } ;
00313
00314
00315 protected:
00316
00317
00318
00319 const char *getFieldP(int field) const
00320 {
00321 return fAddressInfo.entry[field];
00322 }
00323
00324 private:
00325 void _copyAddressInfo(const struct Address ©From);
00326 PhoneSlot _getNextEmptyPhoneSlot() const;
00327
00331 PhoneSlot _findPhoneFieldSlot(PilotAddressInfo::EPhoneType t) const;
00332
00333 struct Address fAddressInfo;
00334 };
00335
00336
00337
00338
00339 #endif
|