kpilot/lib

pilotAddress.h

00001 #ifndef _KPILOT_PILOTADDRESS_H
00002 #define _KPILOT_PILOTADDRESS_H
00003 /* pilotAddress.h           KPilot
00004 **
00005 ** Copyright (C) 1998-2001 by Dan Pilone
00006 ** Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
00007 **
00008 ** This is a wrapper for pilot-link's address structures.
00009 */
00010 
00011 /*
00012 ** This program is free software; you can redistribute it and/or modify
00013 ** it under the terms of the GNU Lesser General Public License as published by
00014 ** the Free Software Foundation; either version 2.1 of the License, or
00015 ** (at your option) any later version.
00016 **
00017 ** This program is distributed in the hope that it will be useful,
00018 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
00019 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00020 ** GNU Lesser General Public License for more details.
00021 **
00022 ** You should have received a copy of the GNU Lesser General Public License
00023 ** along with this program in a file called COPYING; if not, write to
00024 ** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
00025 ** MA 02110-1301, USA.
00026 */
00027 
00028 /*
00029 ** Bug reports and questions can be sent to kde-pim@kde.org
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 
00074 namespace KABC
00075 {
00076     class PhoneNumber;
00077 }
00078 
00079 typedef PilotAppInfo<AddressAppInfo,unpack_AddressAppInfo, pack_AddressAppInfo> PilotAddressInfo;
00080 
00081 class KDE_EXPORT PilotAddress : public PilotRecordBase
00082 {
00083 public:
00084     enum EPhoneType {
00085         eWork=0, eHome, eFax, eOther, eEmail, eMain,
00086         ePager, eMobile
00087         };
00088 
00089     PilotAddress(PilotAddressInfo *appinfo, PilotRecord *rec = 0L);
00090     PilotAddress(const PilotAddress &copyFrom);
00091     PilotAddress& operator=( const PilotAddress &r );
00092     bool operator==(const PilotAddress &r);
00093 
00094     virtual ~PilotAddress();
00095 
00099     virtual QString getTextRepresentation(bool richText=false);
00100 
00104     void reset() { memset(&fAddressInfo, 0, sizeof(struct Address)); }
00105 
00117     void setField(int field, const QString &text);
00118     QString getField(int field) const;
00119 
00124     QStringList getEmails() const;
00125     void setEmails(QStringList emails);
00126 
00131     KABC::PhoneNumber::List getPhoneNumbers() const;
00132     void setPhoneNumbers(KABC::PhoneNumber::List list);
00133 
00134     QString getCategoryLabel() const;
00135 
00140     inline bool setCategory(const QString &label) { return Pilot::insertCategory(&fAppInfo.category,label,false)>=0; } ;
00141 
00142 
00149     QString getPhoneField(EPhoneType type, bool checkCustom4=true) const;
00150 
00160     int setPhoneField(EPhoneType type, const QString &field,
00161         bool overflowCustom=true, bool overwriteExisting=true);
00162 
00171     int getShownPhone() const { return fAddressInfo.showPhone; }
00172     void setShownPhone(EPhoneType phoneType);
00173     int  getPhoneLabelIndex(int index) const { return fAddressInfo.phoneLabel[index]; }
00174 
00175 
00176     PilotRecord *pack() const;
00177 
00178     const struct Address *address() const { return &fAddressInfo; } ;
00179 
00180 protected:
00181     // Get the pointers in cases where no conversion to
00182     // unicode is desired.
00183     //
00184     const char *getFieldP(int field) const
00185         { return fAddressInfo.entry[field]; }
00186 
00187 private:
00188     void _copyAddressInfo(const struct Address &copyFrom);
00189     int _getNextEmptyPhoneSlot() const;
00190 
00194     int _getAppPhoneLabelNum(const QString &phoneType) const;
00195 
00199     int _findPhoneFieldSlot(int appTypeNum) const;
00200 
00201     void _loadMaps();
00202 
00204     QMap < int, int> pilotToPhoneMap;
00205 
00206     struct AddressAppInfo &fAppInfo;
00207     struct Address fAddressInfo;
00208 };
00209 
00210 
00211 
00212 
00213 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys