address.h
00001 /* 00002 This file is part of libkabc. 00003 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License as published by the Free Software Foundation; either 00008 version 2 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public License 00016 along with this library; see the file COPYING.LIB. If not, write to 00017 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00018 Boston, MA 02110-1301, USA. 00019 */ 00020 00021 #ifndef KABC_ADDRESS_H 00022 #define KABC_ADDRESS_H 00023 00024 #include <QtCore/QSharedDataPointer> 00025 #include <QtCore/QString> 00026 00027 #include "kabc_export.h" 00028 00029 namespace KABC { 00030 00037 class KABC_EXPORT Address 00038 { 00039 friend KABC_EXPORT QDataStream &operator<<( QDataStream &s, const Address &addr ); 00040 friend KABC_EXPORT QDataStream &operator>>( QDataStream &s, Address &addr ); 00041 00042 public: 00046 typedef QList<Address> List; 00047 00051 enum TypeFlag { 00052 Dom = 1, 00053 Intl = 2, 00054 Postal = 4, 00055 Parcel = 8, 00056 Home = 16, 00057 Work = 32, 00058 Pref = 64 00059 }; 00060 00061 Q_DECLARE_FLAGS( Type, TypeFlag ) 00062 00063 00066 typedef QList<TypeFlag> TypeList; 00067 00071 Address(); 00072 00076 Address( Type type ); 00077 00081 Address( const Address &address ); 00082 00086 ~Address(); 00087 00094 bool operator==( const Address &addr ) const; 00095 00102 bool operator!=( const Address &addr ) const; 00103 00110 Address &operator=( const Address &addr ); 00111 00115 bool isEmpty() const; 00116 00120 void clear(); 00121 00125 void setId( const QString &identifier ); 00126 00130 QString id() const; 00131 00137 void setType( Type type ); 00138 00142 Type type() const; 00143 00147 QString typeLabel() const; 00148 00152 void setPostOfficeBox( const QString &postOfficeBox ); 00153 00157 QString postOfficeBox() const; 00158 00162 static QString postOfficeBoxLabel(); 00163 00167 void setExtended( const QString &extended ); 00168 00172 QString extended() const; 00173 00177 static QString extendedLabel(); 00178 00182 void setStreet( const QString &street ); 00183 00187 QString street() const; 00188 00192 static QString streetLabel(); 00193 00199 void setLocality( const QString &locality ); 00200 00204 QString locality() const; 00205 00209 static QString localityLabel(); 00210 00216 void setRegion( const QString ®ion ); 00217 00221 QString region() const; 00222 00226 static QString regionLabel(); 00227 00231 void setPostalCode( const QString &code ); 00232 00236 QString postalCode() const; 00237 00241 static QString postalCodeLabel(); 00242 00246 void setCountry( const QString &country ); 00247 00251 QString country() const; 00252 00256 static QString countryLabel(); 00257 00263 void setLabel( const QString &label ); 00264 00268 QString label() const; 00269 00273 static QString labelLabel(); 00274 00278 static TypeList typeList(); 00279 00283 static QString typeLabel( Type type ); 00284 00288 QString toString() const; 00289 00301 QString formattedAddress( const QString &realName = QString(), 00302 const QString &orgaName = QString() ) const; 00303 00311 static QString countryToISO( const QString &cname ); 00312 00319 static QString ISOtoCountry( const QString &ISOname ); 00320 00321 private: 00322 class Private; 00323 QSharedDataPointer<Private> d; 00324 }; 00325 00326 Q_DECLARE_OPERATORS_FOR_FLAGS( Address::Type ) 00327 00331 KABC_EXPORT QDataStream &operator<<( QDataStream &stream, const Address &address ); 00332 00336 KABC_EXPORT QDataStream &operator>>( QDataStream &stream, Address &address ); 00337 00338 } 00339 00340 #endif