home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / kabc / phonenumber.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-10-10  |  4.1 KB  |  162 lines

  1. /*
  2.     This file is part of libkabc.
  3.     Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
  4.  
  5.     This library is free software; you can redistribute it and/or
  6.     modify it under the terms of the GNU Library General Public
  7.     License as published by the Free Software Foundation; either
  8.     version 2 of the License, or (at your option) any later version.
  9.  
  10.     This library is distributed in the hope that it will be useful,
  11.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.     Library General Public License for more details.
  14.  
  15.     You should have received a copy of the GNU Library General Public License
  16.     along with this library; see the file COPYING.LIB.  If not, write to
  17.     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  18.     Boston, MA 02110-1301, USA.
  19. */
  20.  
  21. #ifndef KABC_PHONENUMBER_H
  22. #define KABC_PHONENUMBER_H
  23.  
  24. #include <qvaluelist.h>
  25. #include <qstring.h>
  26.  
  27. #include <kdelibs_export.h>
  28.  
  29. namespace KABC {
  30.  
  31. /**
  32.   @short Phonenumber information.
  33.   
  34.   This class provides phone number information. A phone number is classified by
  35.   a type. The following types are available, it's possible to use multiple types
  36.  Types for a number by combining them through a logical or.
  37. */
  38. class KABC_EXPORT PhoneNumber
  39. {
  40.     friend KABC_EXPORT QDataStream &operator<<( QDataStream &, const PhoneNumber & );
  41.     friend KABC_EXPORT QDataStream &operator>>( QDataStream &, PhoneNumber & );
  42.  
  43.   public:
  44.     typedef QValueList<PhoneNumber> List;
  45.     typedef QValueList<int> TypeList;
  46.  
  47.     /**
  48.       @li @p Home -  Home number
  49.       @li @p Work -  Office number
  50.       @li @p Msg -   Messaging
  51.       @li @p Pref -  Preferred number
  52.       @li @p Voice - Voice
  53.       @li @p Fax -   Fax machine
  54.       @li @p Cell -  Cell phone
  55.       @li @p Video - Video phone
  56.       @li @p Bbs -   Mailbox
  57.       @li @p Modem - Modem
  58.       @li @p Car -   Car phone
  59.       @li @p Isdn -  ISDN connection
  60.       @li @p Pcs -   Personal Communication Service
  61.       @li @p Pager - Pager
  62.     */
  63.     enum Types { Home = 1, Work = 2, Msg = 4, Pref = 8, Voice = 16, Fax = 32,
  64.            Cell = 64, Video = 128, Bbs = 256, Modem = 512, Car = 1024,
  65.            Isdn = 2048, Pcs = 4096, Pager = 8192 };
  66.  
  67.     /**
  68.       Create an empty phone number object.
  69.     */  
  70.     PhoneNumber();
  71.  
  72.     /**
  73.       Create a phonenumber object.
  74.      
  75.       @param number Number
  76.       @param type   Type as defined in enum. Multiple types can be
  77.                     specified by combining them by a logical or.
  78.     */
  79.     PhoneNumber( const QString &number, int type = Home );
  80.  
  81.     /**
  82.       Destructor.
  83.     */
  84.     ~PhoneNumber();
  85.     
  86.     bool operator==( const PhoneNumber & ) const;
  87.     bool operator!=( const PhoneNumber & ) const;
  88.     
  89.     /**
  90.       Sets the unique identifier.
  91.     */
  92.     void setId( const QString &id );
  93.  
  94.     /**
  95.       Returns the unique identifier.
  96.     */
  97.     QString id() const;
  98.     
  99.     /**
  100.       Sets the number.
  101.     */
  102.     void setNumber( const QString & );
  103.  
  104.     /**
  105.       Returns the number.
  106.     */
  107.     QString number() const;
  108.     
  109.     /**
  110.       Sets the type. Multiple types can be specified by combining them by
  111.       a logical or.
  112.     */
  113.     void setType( int );
  114.  
  115.     /**
  116.       Returns the type. Can be a multiple types combined by a logical or.
  117.     */
  118.     int type() const;
  119.  
  120.     /**
  121.       Returns a translated string of all types the address has.
  122.     */
  123.     QString typeLabel() const;
  124.  
  125.     /**
  126.       Returns the translated label for phone number depending on its type.
  127.     */
  128.     QString label() const;
  129.  
  130.     /**
  131.       Returns a list of all available types
  132.     */
  133.     static TypeList typeList();
  134.  
  135.     /**
  136.       Returns the translated label for phone number type.
  137.     */
  138.     static QString typeLabel( int type );
  139.  
  140.     /**
  141.       Returns the translated label for phone number type.
  142.       @obsolete
  143.     */
  144.     static QString label( int type );
  145.  
  146.   private:
  147.     void init();
  148.     void validateNumber( const QString& );
  149.  
  150.     QString mId;
  151.   
  152.     int mType;
  153.     QString mNumber;
  154. };
  155.  
  156. KABC_EXPORT QDataStream &operator<<( QDataStream &, const PhoneNumber & );
  157. KABC_EXPORT QDataStream &operator>>( QDataStream &, PhoneNumber & );
  158.  
  159. }
  160.  
  161. #endif
  162.