libkdepim

addresseeview.h

00001 /*
00002     This file is part of libkdepim.
00003 
00004     Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
00005 
00006     This library is free software; you can redistribute it and/or
00007     modify it under the terms of the GNU Library General Public
00008     License as published by the Free Software Foundation; either
00009     version 2 of the License, or (at your option) any later version.
00010 
00011     This library is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014     Library General Public License for more details.
00015 
00016     You should have received a copy of the GNU Library General Public License
00017     along with this library; see the file COPYING.LIB.  If not, write to
00018     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019     Boston, MA 02110-1301, USA.
00020 */
00021 
00022 #ifndef KPIM_ADDRESSEEVIEW_H
00023 #define KPIM_ADDRESSEEVIEW_H
00024 
00025 #include <tqcstring.h>
00026 
00027 #include <kabc/addressee.h>
00028 #include <ktextbrowser.h>
00029 #include <kimproxy.h>
00030 #include <kdepimmacros.h>
00031 
00032 namespace KIO {
00033 class Job;
00034 }
00035 class KToggleAction;
00036 
00037 class TQPopupMenu;
00038 
00039 
00040 namespace KPIM {
00041 
00042 
00043 class KDE_EXPORT AddresseeView : public KTextBrowser
00044 {
00045   Q_OBJECT
00046   TQ_OBJECT
00047   public:
00054     AddresseeView( TQWidget *parent = 0, const char *name = 0,
00055                    KConfig *config = 0 );
00056 
00057     ~AddresseeView();
00058 
00064     void setAddressee( const KABC::Addressee& addr );
00065 
00069     KABC::Addressee addressee() const;
00070 
00071 
00076     enum LinkMask {
00077       NoLinks = 0,
00078       AddressLinks = 1,
00079       EmailLinks = 2,
00080       PhoneLinks = 4,
00081       URLLinks = 8,
00082       IMLinks = 16,
00083       DefaultLinks = AddressLinks | EmailLinks | PhoneLinks | URLLinks | IMLinks
00084     };
00085 
00090     void enableLinks( int linkMask );
00091 
00096     enum FieldMask {
00097       NoFields = 0,
00098       BirthdayFields = 1,
00099       AddressFields = 2,
00100       EmailFields = 4,
00101       PhoneFields = 8,
00102       URLFields = 16,
00103       IMFields = 32,
00104       CustomFields = 64,
00105       DefaultFields = AddressFields | EmailFields | PhoneFields | URLFields
00106     };
00107 
00131     static TQString vCardAsHTML( const KABC::Addressee& addr, ::KIMProxy *proxy, LinkMask linkMask = DefaultLinks,
00132                                 bool internalLoading = true, FieldMask fieldMask = DefaultFields );
00133 
00139     static TQString pixmapAsDataUrl( const TQPixmap& pixmap );
00140 
00141   signals:
00142     void urlHighlighted( const TQString &url );
00143     void emailHighlighted( const TQString &email );
00144     void phoneNumberHighlighted( const TQString &number );
00145     void faxNumberHighlighted( const TQString &number );
00146 
00147     void highlightedMessage( const TQString &message );
00148 
00149     void addressClicked( const TQString &uid );
00150 
00151   protected:
00152     virtual void urlClicked( const TQString &url );
00153     virtual void emailClicked( const TQString &mail );
00154     virtual void phoneNumberClicked( const TQString &number );
00155     virtual void smsTextClicked( const TQString &number );
00156     virtual void sendSMS( const TQString &number, const TQString &msg );
00157     virtual void faxNumberClicked( const TQString &number );
00158     virtual void imAddressClicked();
00159 
00160     virtual TQPopupMenu *createPopupMenu( const TQPoint& );
00161 
00162   private slots:
00163     void slotMailClicked( const TQString&, const TQString& );
00164     void slotUrlClicked( const TQString& );
00165     void slotHighlighted( const TQString& );
00166     void slotPresenceChanged( const TQString & );
00167     void slotPresenceInfoExpired();
00168     void configChanged();
00169 
00170     void data( KIO::Job*, const TQByteArray& );
00171     void result( KIO::Job* );
00172 
00173   private:
00174     void load();
00175     void save();
00176 
00177     void updateView();
00178 
00179     TQString strippedNumber( const TQString &number );
00180 
00181     KConfig *mConfig;
00182     bool mDefaultConfig;
00183 
00184     TQByteArray mImageData;
00185     KIO::Job *mImageJob;
00186 
00187     KToggleAction *mActionShowBirthday;
00188     KToggleAction *mActionShowAddresses;
00189     KToggleAction *mActionShowEmails;
00190     KToggleAction *mActionShowPhones;
00191     KToggleAction *mActionShowURLs;
00192     KToggleAction *mActionShowIMAddresses;
00193     KToggleAction *mActionShowCustomFields;
00194 
00195     KABC::Addressee mAddressee;
00196     int mLinkMask;
00197 
00198     class AddresseeViewPrivate;
00199     AddresseeViewPrivate *d;
00200     ::KIMProxy *mKIMProxy;
00201 };
00202 
00203 }
00204 
00205 #endif