00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
#ifndef KABC_ADDRESS_H
00022
#define KABC_ADDRESS_H
00023
00024
#include <qmap.h>
00025
#include <qstring.h>
00026
#include <qvaluelist.h>
00027
00028
00029
#define KABC_FMTTAG_realname QString("%n")
00030
#define KABC_FMTTAG_REALNAME QString("%N")
00031
#define KABC_FMTTAG_company QString("%cm")
00032
#define KABC_FMTTAG_COMPANY QString("%CM")
00033
#define KABC_FMTTAG_pobox QString("%p")
00034
#define KABC_FMTTAG_street QString("%s")
00035
#define KABC_FMTTAG_STREET QString("%S")
00036
#define KABC_FMTTAG_zipcode QString("%z")
00037
#define KABC_FMTTAG_location QString("%l")
00038
#define KABC_FMTTAG_LOCATION QString("%L")
00039
#define KABC_FMTTAG_region QString("%r")
00040
#define KABC_FMTTAG_REGION QString("%R")
00041
#define KABC_FMTTAG_newline QString("\\n")
00042
#define KABC_FMTTAG_condcomma QString("%,")
00043
#define KABC_FMTTAG_condwhite QString("%w")
00044
#define KABC_FMTTAG_purgeempty QString("%0")
00045
00046 namespace KABC {
00047
00053 class Address
00054 {
00055
friend QDataStream &operator<<(
QDataStream &,
const Address & );
00056
friend QDataStream &operator>>(
QDataStream &,
Address & );
00057
00058
public:
00062 typedef QValueList<Address> List;
00063
typedef QValueList<int> TypeList;
00064
00076 enum Type { Dom = 1, Intl = 2, Postal = 4, Parcel = 8, Home = 16, Work = 32,
00077 Pref = 64 };
00078
00083
Address();
00084
00089
Address(
int );
00090
00091
bool operator==(
const Address & ) const;
00092
bool operator!=( const
Address & ) const;
00093
00097
bool isEmpty() const;
00098
00102
void clear();
00103
00107
void setId( const
QString & );
00108
00109
00110
00111
00112 QString
id() const;
00113
00119
void setType(
int type );
00120
00124
int type() const;
00125
00129 QString typeLabel() const;
00130
00134
void setPostOfficeBox( const QString & );
00135
00139 QString postOfficeBox() const;
00140
00144 static QString postOfficeBoxLabel();
00145
00149
void setExtended( const QString & );
00150
00154 QString extended() const;
00155
00159 static QString extendedLabel();
00160
00164
void setStreet( const QString & );
00165
00169 QString street() const;
00170
00174 static QString streetLabel();
00175
00179
void setLocality( const QString & );
00180
00184 QString locality() const;
00185
00189 static QString localityLabel();
00190
00194
void setRegion( const QString & );
00195
00199 QString region() const;
00200
00204 static QString regionLabel();
00205
00209
void setPostalCode( const QString & );
00210
00214 QString postalCode() const;
00215
00219 static QString postalCodeLabel();
00220
00224
void setCountry( const QString & );
00225
00229 QString country() const;
00230
00234 static QString countryLabel();
00235
00239
void setLabel( const QString & );
00240
00244 QString label() const;
00245
00249 static QString labelLabel();
00250
00254 static TypeList typeList();
00255
00259 static QString typeLabel(
int type );
00260
00264
void dump() const;
00265
00277 QString formattedAddress( const QString &realName=QString::null
00278 , const QString &orgaName=QString::null ) const;
00279
00287 static QString countryToISO( const QString &cname );
00288
00296 static QString ISOtoCountry( const QString &ISOname );
00297
00298 private:
00305
bool parseAddressTemplateSection( const QString &tsection
00306 , QString &result
00307 , const QString &realName
00308 , const QString &orgaName ) const;
00309
00315
int findBalancedBracket( const QString &tsection,
int pos ) const;
00316
00317
bool mEmpty;
00318
00319 QString mId;
00320
int mType;
00321
00322 QString mPostOfficeBox;
00323 QString mExtended;
00324 QString mStreet;
00325 QString mLocality;
00326 QString mRegion;
00327 QString mPostalCode;
00328 QString mCountry;
00329 QString mLabel;
00330
00331 static
QMap<QString, QString> *mISOMap;
00332 };
00333
00334
QDataStream &operator<<(
QDataStream &, const
Address & );
00335 QDataStream &operator>>( QDataStream &, Address & );
00336
00337 }
00338
00339 #endif