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 <qcstring.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 QPopupMenu;
00038 
00039 
00040 namespace KPIM {
00041 
00042 
00043 class KDE_EXPORT AddresseeView : public KTextBrowser
00044 {
00045   Q_OBJECT
00046   public:
00053     AddresseeView( QWidget *parent = 0, const char *name = 0,
00054                    KConfig *config = 0 );
00055 
00056     ~AddresseeView();
00057 
00063     void setAddressee( const KABC::Addressee& addr );
00064 
00068     KABC::Addressee addressee() const;
00069 
00070 
00075     enum LinkMask {
00076       NoLinks = 0,
00077       AddressLinks = 1,
00078       EmailLinks = 2,
00079       PhoneLinks = 4,
00080       URLLinks = 8,
00081       IMLinks = 16,
00082       DefaultLinks = AddressLinks | EmailLinks | PhoneLinks | URLLinks | IMLinks
00083     };
00084 
00089     void enableLinks( int linkMask );
00090 
00095     enum FieldMask {
00096       NoFields = 0,
00097       BirthdayFields = 1,
00098       AddressFields = 2,
00099       EmailFields = 4,
00100       PhoneFields = 8,
00101       URLFields = 16,
00102       IMFields = 32,
00103       CustomFields = 64,
00104       Categories = 128,
00105       DefaultFields = AddressFields | EmailFields | PhoneFields | URLFields | Categories
00106     };
00107 
00131     static QString vCardAsHTML( const KABC::Addressee& addr, ::KIMProxy *proxy, LinkMask linkMask = DefaultLinks,
00132                                 bool internalLoading = true, FieldMask fieldMask = DefaultFields );
00133 
00139     static QString pixmapAsDataUrl( const QPixmap& pixmap );
00140 
00141   signals:
00142     void urlHighlighted( const QString &url );
00143     void emailHighlighted( const QString &email );
00144     void phoneNumberHighlighted( const QString &number );
00145     void faxNumberHighlighted( const QString &number );
00146 
00147     void highlightedMessage( const QString &message );
00148 
00149     void addressClicked( const QString &uid );
00150 
00151   protected:
00152     virtual void urlClicked( const QString &url );
00153     virtual void emailClicked( const QString &mail );
00154     virtual void phoneNumberClicked( const QString &number );
00155     virtual void smsTextClicked( const QString &number );
00156     virtual void sendSMS( const QString &number, const QString &msg );
00157     virtual void faxNumberClicked( const QString &number );
00158     virtual void imAddressClicked();
00159 
00160     virtual QPopupMenu *createPopupMenu( const QPoint& );
00161 
00162   private slots:
00163     void slotMailClicked( const QString&, const QString& );
00164     void slotUrlClicked( const QString& );
00165     void slotHighlighted( const QString& );
00166     void slotPresenceChanged( const QString & );
00167     void slotPresenceInfoExpired();
00168     void configChanged();
00169 
00170     void data( KIO::Job*, const QByteArray& );
00171     void result( KIO::Job* );
00172 
00173   private:
00174     void load();
00175     void save();
00176 
00177     void updateView();
00178 
00179     QString strippedNumber( const QString &number );
00180 
00181     KConfig *mConfig;
00182     bool mDefaultConfig;
00183 
00184     QByteArray 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     KToggleAction *mActionShowCategories;
00195 
00196     KABC::Addressee mAddressee;
00197     int mLinkMask;
00198 
00199     class AddresseeViewPrivate;
00200     AddresseeViewPrivate *d;
00201     ::KIMProxy *mKIMProxy;
00202 };
00203 
00204 }
00205 
00206 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys