krop's commit fixes my problem in a better way, reverting
[kdepim.git] / libkdepim / addresseeview.h
blobb9e6509d85b7af4c82e745158b0f51eea045818b
1 /*
2 This file is part of libkdepim.
4 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
22 #ifndef KDEPIM_ADDRESSEEVIEW_H
23 #define KDEPIM_ADDRESSEEVIEW_H
25 #include "kdepim_export.h"
27 #include <kabc/addressee.h>
29 #include <KIMProxy>
30 #include <KTextBrowser>
32 class QPixmap;
34 namespace KIO {
35 class Job;
37 class KToggleAction;
39 class KConfig;
40 class KJob;
42 namespace KPIM {
45 class KDEPIM_EXPORT AddresseeView : public KTextBrowser
47 Q_OBJECT
48 public:
49 /**
50 Constructor.
52 @param config The config object where the settings are stored
53 which fields will be shown.
55 explicit AddresseeView( QWidget *parent = 0, KConfig *config = 0 );
57 ~AddresseeView();
59 /**
60 Sets the addressee object. The addressee is displayed immediately.
62 @param addr The addressee object.
64 void setAddressee( const KABC::Addressee& addr );
66 /**
67 Returns the current addressee object.
69 KABC::Addressee addressee() const;
72 /**
73 This enums are used by enableLinks to set which kind of links shall
74 be enabled.
76 enum LinkMask {
77 NoLinks = 0,
78 AddressLinks = 1,
79 EmailLinks = 2,
80 PhoneLinks = 4,
81 URLLinks = 8,
82 IMLinks = 16,
83 DefaultLinks = AddressLinks | EmailLinks | PhoneLinks | URLLinks | IMLinks
86 /**
87 Sets which parts of the contact shall be presented as links.
88 The mask can be OR'ed LinkMask. By default all links are enabled.
90 void enableLinks( int linkMask );
92 /**
93 This enums are used by vCardAsHTML to decide which fields shall be
94 shown.
96 enum FieldMask {
97 NoFields = 0,
98 BirthdayFields = 1,
99 AddressFields = 2,
100 EmailFields = 4,
101 PhoneFields = 8,
102 URLFields = 16,
103 IMFields = 32,
104 CustomFields = 64,
105 DefaultFields = AddressFields | EmailFields | PhoneFields | URLFields
109 Returns the HTML representation of a contact.
110 The HTML code looks like
111 &lt;div&gt;
112 &lt;table&gt;
114 &lt;/table&gt;
115 &lt;/div&gt;
117 @param addr The addressee object.
118 @param linkMask The mask for which parts of the contact will
119 be displayed as links.
120 The links looks like this:
121 "addr://&lt;addr id&gt;" for addresses
122 "mailto:&lt;email address&gt;" for emails
123 "phone://&lt;phone number&gt;" for phone numbers
124 "http://&lt;url&gt;" for urls
125 "im:&lt;im addrss&gt;" for instant messaging addresses
126 "sms://&lt;phone number&gt;" for sending a sms
127 @param internalLoading If true, the loading of internal pictures is done automatically.
128 @param fieldMask The mask for which fields of the contact will
129 be displayed.
131 static QString vCardAsHTML( const KABC::Addressee& addr, ::KIMProxy *proxy, LinkMask linkMask = DefaultLinks,
132 bool internalLoading = true, FieldMask fieldMask = DefaultFields );
135 * Encodes a QPixmap as a PNG into a data: URL (rfc2397), readable by the data kio protocol
136 * @param pixmap the pixmap to encode
137 * @return a data: URL
139 static QString pixmapAsDataUrl( const QPixmap& pixmap );
141 Q_SIGNALS:
142 void urlHighlighted( const QString &url );
143 void emailHighlighted( const QString &email );
144 void phoneNumberHighlighted( const QString &number );
145 void faxNumberHighlighted( const QString &number );
147 void highlightedMessage( const QString &message );
149 void addressClicked( const QString &uid );
151 protected:
152 virtual void urlClicked( const QString &url );
153 virtual void emailClicked( const QString &mail );
154 virtual void phoneNumberClicked( const QString &number );
155 virtual void smsTextClicked( const QString &number );
156 virtual void sendSMS( const QString &number, const QString &msg );
157 virtual void faxNumberClicked( const QString &number );
158 virtual void imAddressClicked();
159 virtual void contextMenuEvent( QContextMenuEvent *e );
162 private Q_SLOTS:
163 void slotMailClicked( const QString&, const QString& );
164 void slotUrlClicked( const QString& );
165 void slotHighlighted( const QString& );
166 void slotPresenceChanged( const QString & );
167 void slotPresenceInfoExpired();
168 void configChanged();
170 void data( KIO::Job*, const QByteArray& );
171 void result( KJob* );
173 private:
174 void load();
175 void save();
177 void updateView();
179 QString strippedNumber( const QString &number );
181 KConfig *mConfig;
182 bool mDefaultConfig;
184 QByteArray mImageData;
185 KIO::Job *mImageJob;
187 KToggleAction *mActionShowBirthday;
188 KToggleAction *mActionShowAddresses;
189 KToggleAction *mActionShowEmails;
190 KToggleAction *mActionShowPhones;
191 KToggleAction *mActionShowURLs;
192 KToggleAction *mActionShowIMAddresses;
193 KToggleAction *mActionShowCustomFields;
195 KABC::Addressee mAddressee;
196 int mLinkMask;
198 class AddresseeViewPrivate;
199 AddresseeViewPrivate *d;
200 ::KIMProxy *mKIMProxy;
205 #endif