summaryrefslogtreecommitdiffabout
path: root/libkdepim
authorzautrix <zautrix>2004-09-17 01:00:46 (UTC)
committer zautrix <zautrix>2004-09-17 01:00:46 (UTC)
commit0461502d8a19961121206e89ae4bc5b6b8a91a57 (patch) (unidiff)
tree51430c9a18064da4a80c9a5b5fc276290a9416c8 /libkdepim
parent6cc8e0fc67366fe4d6616d4246b9e8722e2c824f (diff)
downloadkdepimpi-0461502d8a19961121206e89ae4bc5b6b8a91a57.zip
kdepimpi-0461502d8a19961121206e89ae4bc5b6b8a91a57.tar.gz
kdepimpi-0461502d8a19961121206e89ae4bc5b6b8a91a57.tar.bz2
files removed
Diffstat (limited to 'libkdepim') (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/addresseeview.cpp401
-rw-r--r--libkdepim/addresseeview.h60
-rw-r--r--libkdepim/kincidenceformatter.cpp328
-rw-r--r--libkdepim/kincidenceformatter.h42
4 files changed, 0 insertions, 831 deletions
diff --git a/libkdepim/addresseeview.cpp b/libkdepim/addresseeview.cpp
deleted file mode 100644
index b4717d7..0000000
--- a/libkdepim/addresseeview.cpp
+++ b/dev/null
@@ -1,401 +0,0 @@
1/*
2 This file is part of libkdepim.
3
4 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
5
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.
10
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.
15
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., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA.
20*/
21
22#include <kabc/address.h>
23#include <kabc/addressee.h>
24#include <kabc/phonenumber.h>
25#include <kglobal.h>
26//US#include <kglobalsettings.h>
27#include <kiconloader.h>
28#include <klocale.h>
29//US #include <kstringhandler.h>
30#include <qscrollview.h>
31#include <qregexp.h>
32#include <qfile.h>
33#include <qapplication.h>
34
35
36#include "externalapphandler.h"
37#include "addresseeview.h"
38
39
40//US #ifndef DESKTOP_VERSION
41//US #include <qtopia/qcopenvelope_qws.h>
42//US #include <qpe/qpeapplication.h>
43//US #endif
44
45//US static int kphoneInstalled = 0;
46
47using namespace KPIM;
48
49AddresseeView::AddresseeView( QWidget *parent, const char *name )
50//US : KTextBrowser( parent, name )
51 : QTextBrowser( parent, name )
52
53
54{
55//US setWrapPolicy( QTextEdit::AtWordBoundary );
56 setLinkUnderline( false );
57 // setVScrollBarMode( QScrollView::AlwaysOff );
58 //setHScrollBarMode( QScrollView::AlwaysOff );
59
60//US QStyleSheet *sheet = styleSheet();
61//US QStyleSheetItem *link = sheet->item( "a" );
62//US link->setColor( KGlobalSettings::linkColor() );
63
64}
65
66void AddresseeView::setSource(const QString& n)
67{
68 //qDebug("********AddresseeView::setSource %s", n.latin1());
69
70 if ( n.left( 6 ) == "mailto" )
71 ExternalAppHandler::instance()->mailToOneContact( n.mid(7) );
72 else if ( n.left( 7 ) == "phoneto" )
73 ExternalAppHandler::instance()->callByPhone( n.mid(8) );
74 else if ( n.left( 5 ) == "faxto" )
75 ExternalAppHandler::instance()->callByFax( n.mid(6) );
76 else if ( n.left( 5 ) == "smsto" )
77 ExternalAppHandler::instance()->callBySMS( n.mid(6) );
78 else if ( n.left( 7 ) == "pagerto" )
79 ExternalAppHandler::instance()->callByPager( n.mid(8) );
80 else if ( n.left( 5 ) == "sipto" )
81 ExternalAppHandler::instance()->callBySIP( n.mid(6) );
82
83}
84void AddresseeView::setAddressee( const KABC::Addressee& addr )
85{
86 ExternalAppHandler* eah = ExternalAppHandler::instance();
87 bool kemailAvail = eah->isEmailAppAvailable();
88 bool kphoneAvail = eah->isPhoneAppAvailable();
89 bool kfaxAvail = eah->isFaxAppAvailable();
90 bool ksmsAvail = eah->isSMSAppAvailable();
91 bool kpagerAvail = eah->isPagerAppAvailable();
92 bool ksipAvail = eah->isSIPAppAvailable();
93
94
95 mAddressee = addr;
96 // clear view
97 setText( QString::null );
98
99 if ( mAddressee.isEmpty() )
100 return;
101
102 QString name = ( mAddressee.assembledName().isEmpty() ?
103 mAddressee.formattedName() : mAddressee.assembledName() );
104
105 QString dynamicPart;
106
107 QStringList emails = mAddressee.emails();
108 QStringList::ConstIterator emailIt;
109 QString type = i18n( "Email" );
110 emailIt = emails.begin();
111 if ( emailIt != emails.end() ) {
112 if ( kemailAvail ) {
113 dynamicPart += QString(
114 "<tr><td align=\"right\"><b>%1</b></td>"
115 "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" )
116 .arg( type )
117 .arg( name )
118 .arg( *emailIt )
119 .arg( *emailIt );
120 ++emailIt;
121 } else {
122 dynamicPart += QString(
123 "<tr><td align=\"right\"><b>%1</b></td>"
124 "<td align=\"left\">%2</td></tr>" )
125 .arg( type )
126 .arg( *emailIt );
127 ++emailIt;
128 }
129 }
130 if ( mAddressee.birthday().date().isValid() ) {
131 dynamicPart += QString(
132 "<tr><td align=\"right\"><b>%1</b></td>"
133 "<td align=\"left\">%2</td></tr>" )
134 .arg( i18n ("Birthday") )
135 .arg( KGlobal::locale()->formatDate( mAddressee.birthday().date() ,true) );
136 }
137 KABC::PhoneNumber::List phones = mAddressee.phoneNumbers();
138 KABC::PhoneNumber::List::ConstIterator phoneIt;
139 QString extension;
140 int phonetype;
141 QString sms;
142 for ( phoneIt = phones.begin(); phoneIt != phones.end(); ++phoneIt ) {
143 phonetype = (*phoneIt).type();
144 if (ksmsAvail &&
145 (
146 ((phonetype & KABC::PhoneNumber::Car) == KABC::PhoneNumber::Car) ||
147 ((phonetype & KABC::PhoneNumber::Cell) == KABC::PhoneNumber::Cell)
148 )
149 )
150 {
151 sms = QString("<a href=\"smsto:%1 \">(sms)</a>" )
152 .arg( (*phoneIt).number() );
153
154 }
155 else
156 sms = "";
157
158 extension = QString::null;
159 if ((phonetype & KABC::PhoneNumber::Fax) == KABC::PhoneNumber::Fax) {
160 if (kfaxAvail) extension = "faxto:";
161 }
162 else if ((phonetype & KABC::PhoneNumber::Pager) == KABC::PhoneNumber::Pager) {
163 if (kpagerAvail) extension = "pagerto:";
164 }
165 else if ((phonetype & KABC::PhoneNumber::Sip) == KABC::PhoneNumber::Sip) {
166 if (ksipAvail) extension = "sipto:";
167 }
168 else if (kphoneAvail) {
169 extension = "phoneto:";
170 }
171 else
172 extension = QString::null;
173
174 if ( !extension.isEmpty() ) {
175 dynamicPart += QString(
176 "<tr><td align=\"right\"><b>%1</b></td>"
177 "<td align=\"left\"><a href=\"%2%3 \">%4</a> %5</td></tr>" )
178 .arg( KABC::PhoneNumber::typeLabel( phonetype ) )
179 .arg( extension )
180 .arg( (*phoneIt).number() )
181 .arg( (*phoneIt).number() )
182 .arg( sms );
183
184 } else {
185 dynamicPart += QString(
186 "<tr><td align=\"right\"><b>%1</b></td>"
187 "<td align=\"left\">%2 %3</td></tr>" )
188 .arg( KABC::PhoneNumber::typeLabel( phonetype ) )
189 .arg( (*phoneIt).number() )
190 .arg( sms );
191 }
192 }
193
194
195 for ( ; emailIt != emails.end(); ++emailIt ) {
196 if ( kemailAvail ) {
197 dynamicPart += QString(
198 "<tr><td align=\"right\"><b>%1</b></td>"
199 "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" )
200 .arg( type )
201 .arg( name )
202 .arg( *emailIt )
203 .arg( *emailIt );
204 } else {
205 dynamicPart += QString(
206 "<tr><td align=\"right\"><b>%1</b></td>"
207 "<td align=\"left\">%2</td></tr>" )
208 .arg( type )
209 .arg( *emailIt );
210 }
211 }
212
213 if ( !mAddressee.url().url().isEmpty() ) {
214 dynamicPart += QString(
215 "<tr><td align=\"right\"><b>%1</b></td>"
216 "<td align=\"left\">%2</td></tr>" )
217 .arg( i18n( "Homepage" ) )
218//US .arg( KStringHandler::tagURLs( mAddressee.url().url() ) );
219 .arg( mAddressee.url().url() );
220 //qDebug("AddresseeView::setAddressee has to be verified.");
221 }
222
223 KABC::Address::List addresses = mAddressee.addresses();
224 KABC::Address::List::ConstIterator addrIt;
225 for ( addrIt = addresses.begin(); addrIt != addresses.end(); ++addrIt ) {
226 if ( true /*(*addrIt).label().isEmpty()*/ ) {
227 QString formattedAddress = (*addrIt).formattedAddress().stripWhiteSpace();
228//US formattedAddress = formattedAddress.replace( '\n', "<br>" );
229 //qDebug("adresss %s ",formattedAddress.latin1() );
230 formattedAddress = formattedAddress.replace( QRegExp("\n"), "<br>" );
231 //qDebug("AddresseeView::setAddressee has to be verified.");
232
233 dynamicPart += QString(
234 "<tr><td align=\"right\"><b>%1</b></td>"
235 "<td align=\"left\">%2</td></tr>" )
236 .arg( KABC::Address::typeLabel( (*addrIt).type() ) )
237 .arg( formattedAddress );
238 } else {
239
240 dynamicPart += QString(
241 "<tr><td align=\"right\"><b>%1</b></td>"
242 "<td align=\"left\">%2</td></tr>" )
243 .arg( KABC::Address::typeLabel( (*addrIt).type() ) )
244//US .arg( (*addrIt).label().replace( '\n', "<br>" ) );
245 .arg( (*addrIt).label() /*replace( QRegExp("\n"), "<br>" )*/ );
246
247 }
248 }
249
250 QString notes;
251 if ( !mAddressee.note().isEmpty() ) {
252 notes = QString(
253 "<tr>"
254 "<td align=\"right\" valign=\"top\"><b>%1</b></td>" // note label
255 "<td align=\"left\">%2</td>" // note
256 "</tr>" ).arg( i18n( "Notes" ) )
257//US .arg( mAddressee.note().replace( '\n', "<br>" ) );
258 .arg( mAddressee.note().replace( QRegExp("\n"), "<br>" ) );
259 //qDebug("AddresseeView::setAddressee has to be verified.");
260 }
261
262 QString aRole = "";
263 QString aOrga = "";
264 if ( true /*!mAddressee.role().isEmpty()*/ ) {
265 aRole = "<tr>"
266 "<td align=\"left\">" + mAddressee.role() + "</td>"
267 "</tr>";
268 }
269 if ( true /*!mAddressee.organization().isEmpty()*/ ) {
270 aOrga = "<tr>"
271 "<td align=\"left\">" + mAddressee.organization() + "</td>" ;
272 "</tr>";
273 }
274 mText = "";
275 QString picString = "";
276 KABC::Picture picture = mAddressee.photo();
277 bool picAvailintern = false;
278 bool picAvailUrl = false;
279 if (! picture.undefined() ) {
280 picAvailintern = (picture.isIntern() && !picture.data().isNull());
281 picAvailUrl = !picture.isIntern() && QFile::exists(picture.url() );
282 }
283 if ( picAvailUrl || picAvailintern || QApplication::desktop()->width() > 320 ) {
284 if ( picAvailintern ) {
285 QMimeSourceFactory::defaultFactory()->setImage( "myimage", picture.data() );
286 } else {
287 if ( picAvailUrl ) {
288 QMimeSourceFactory::defaultFactory()->setPixmap( "myimage", QPixmap( picture.url() ));
289 } else {
290 QMimeSourceFactory::defaultFactory()->setPixmap( "myimage", KGlobal::iconLoader()->loadIcon( "package_toys", KIcon::Desktop, 128 ) );
291 }
292 }
293 picString = "<img src=\"myimage\" width=\"50\" height=\"70\">";
294 mText = QString::fromLatin1(
295 "<html>"
296 "<body text=\"%1\" bgcolor=\"%2\">" // text and background color
297 "<table>"
298 "<tr>"
299 "<td rowspan=\"3\" align=\"right\" valign=\"top\">"
300 "%3"
301 "</td>"
302 "<td align=\"left\"><font size=\"+2\"><b>%4</b></font></td>" // name
303 "</tr>"
304 "%5" // role
305 "%6" // organization
306 "<td colspan=\"2\">&nbsp;</td>"
307 "%7" // dynamic part
308 "%8" // notes
309 "</table>"
310 "</body>"
311 "</html>")
312//US
313 .arg( /*KGlobalSettings::textColor().name()*/ "black" )
314//US
315 .arg( /*KGlobalSettings::baseColor().name()*/ "white" )
316 .arg( picString )
317 .arg( name )
318 .arg( aRole )
319 .arg( aOrga )
320 .arg( dynamicPart )
321 .arg( notes );
322
323 } else { // no picture!
324
325mText = "<table width=\"100%\">\n";
326 //mText += "<tr bgcolor=\"#3679AD\"><td><h2>";
327#ifdef DESKTOP_VERSION
328 mText += "<tr bgcolor=\"#5699CD\"><td align=\"left\"><h1>";
329#else
330 mText += "<tr bgcolor=\"#5699CD\"><td align=\"left\"><h2>";
331#endif
332
333#ifdef DESKTOP_VERSION
334 mText += "<font color=\"#FFFFFF\"> <em>" + name+"</em></font></h1>";
335#else
336 mText += "<font color=\"#FFFFFF\"> <em>" + name +"</em></font></h2>";
337#endif
338 mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>";
339
340 mText += "<table><td colspan=\"2\">&nbsp;</td>";
341 /*
342 mText += QString("<tr><td align=\"right\"><b2>%1</b2></td>"
343 "<td align=\"left\"><b>%2</b></td></tr>" )
344 .arg( i18n(" ") )
345 .arg( name );
346 */
347 if ( ! mAddressee.role().isEmpty() )
348 mText += QString("<tr><td align=\"right\"><b>%1</b></td>"
349 "<td align=\"left\">%2</td></tr>" )
350 .arg( i18n(" ") )
351 .arg( mAddressee.role());
352 if ( ! mAddressee.organization().isEmpty() )
353 mText += QString("<tr><td align=\"right\"><b>%1</b></td>"
354 "<td align=\"left\">%2</td></tr>" )
355 .arg( i18n(" ") )
356 .arg( mAddressee.organization());
357 mText += dynamicPart;
358 mText += notes;
359 mText += "</table>";
360
361 }
362
363 // at last display it...
364 setText( mText );
365
366}
367
368KABC::Addressee AddresseeView::addressee() const
369{
370 return mAddressee;
371}
372void AddresseeView::addTag(const QString & tag,const QString & text)
373{
374 if ( text.isEmpty() )
375 return;
376 int number=text.contains("\n");
377 QString str = "<" + tag + ">";
378 QString tmpText=text;
379 QString tmpStr=str;
380 if(number !=-1)
381 {
382 if (number > 0) {
383 int pos=0;
384 QString tmp;
385 for(int i=0;i<=number;i++) {
386 pos=tmpText.find("\n");
387 tmp=tmpText.left(pos);
388 tmpText=tmpText.right(tmpText.length()-pos-1);
389 tmpStr+=tmp+"<br>";
390 }
391 }
392 else tmpStr += tmpText;
393 tmpStr+="</" + tag + ">";
394 mText.append(tmpStr);
395 }
396 else
397 {
398 str += text + "</" + tag + ">";
399 mText.append(str);
400 }
401}
diff --git a/libkdepim/addresseeview.h b/libkdepim/addresseeview.h
deleted file mode 100644
index 1865fc4..0000000
--- a/libkdepim/addresseeview.h
+++ b/dev/null
@@ -1,60 +0,0 @@
1/*
2 This file is part of libkdepim.
3
4 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
5
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.
10
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.
15
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., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA.
20*/
21
22#ifndef KPIM_ADDRESSEEVIEW_H
23#define KPIM_ADDRESSEEVIEW_H
24
25#include <kabc/addressee.h>
26
27//US #include <ktextbrowser.h>
28#include <qtextbrowser.h>
29
30namespace KPIM {
31
32//US class AddresseeView : public KTextBrowser
33class AddresseeView : public QTextBrowser
34{
35 public:
36 AddresseeView( QWidget *parent = 0, const char *name = 0 );
37
38 /**
39 Sets the addressee object. The addressee is displayed immediately.
40
41 @param addr The addressee object.
42 */
43 void setAddressee( const KABC::Addressee& addr );
44 void setSource(const QString& n);
45 /**
46 Returns the current addressee object.
47 */
48 KABC::Addressee addressee() const;
49
50 private:
51 KABC::Addressee mAddressee;
52 QString mText;
53 void addTag(const QString & tag,const QString & text);
54 class AddresseeViewPrivate;
55 AddresseeViewPrivate *d;
56};
57
58}
59
60#endif
diff --git a/libkdepim/kincidenceformatter.cpp b/libkdepim/kincidenceformatter.cpp
deleted file mode 100644
index 2f41409..0000000
--- a/libkdepim/kincidenceformatter.cpp
+++ b/dev/null
@@ -1,328 +0,0 @@
1#include "kincidenceformatter.h"
2#include <kstaticdeleter.h>
3#include <kglobal.h>
4#include <klocale.h>
5#ifndef KORG_NOKABC
6#include <kabc/stdaddressbook.h>
7#define size count
8#endif
9
10KIncidenceFormatter* KIncidenceFormatter::mInstance = 0;
11static KStaticDeleter<KIncidenceFormatter> insd;
12
13QString KIncidenceFormatter::getFormattedText( Incidence * inc )
14{
15// #ifndef QT_NO_INPUTDIALOG
16// return QInputDialog::getItem( caption, label, items, current, editable );
17// #else
18// return QString::null;
19// #endif
20 mText = "";
21 if ( inc->type() == "Event" )
22 setEvent((Event *) inc );
23 else if ( inc->type() == "Todo" )
24 setTodo((Todo *) inc );
25 return mText;
26}
27
28KIncidenceFormatter* KIncidenceFormatter::instance()
29{
30 if (!mInstance) {
31 mInstance = insd.setObject(new KIncidenceFormatter());
32 }
33 return mInstance;
34}
35KIncidenceFormatter::~KIncidenceFormatter()
36{
37 if (mInstance == this)
38 mInstance = insd.setObject(0);
39 //qDebug("KIncidenceFormatter::~KIncidenceFormatter ");
40}
41KIncidenceFormatter::KIncidenceFormatter()
42{
43 mColorMode = 0;
44}
45void KIncidenceFormatter::setEvent(Event *event)
46{
47 int mode = 0;
48 mCurrentIncidence = event;
49 bool shortDate = true;
50 if ( mode == 0 ) {
51 addTag("h3",event->summary());
52 }
53 else {
54 if ( mColorMode == 1 ) {
55 mText +="<font color=\"#00A000\">";
56 }
57 if ( mColorMode == 2 ) {
58 mText +="<font color=\"#C00000\">";
59 }
60 // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>";
61 if ( mode == 1 ) {
62 addTag("h2",i18n( "Local: " ) +event->summary());
63 } else {
64 addTag("h2",i18n( "Remote: " ) +event->summary());
65 }
66 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) );
67 if ( mColorMode )
68 mText += "</font>";
69 }
70 if (event->cancelled ()) {
71 mText +="<font color=\"#B00000\">";
72 addTag("i",i18n("This event has been cancelled!"));
73 mText.append("<br>");
74 mText += "</font>";
75 }
76 if (!event->location().isEmpty()) {
77 addTag("b",i18n("Location: "));
78 mText.append(event->location()+"<br>");
79 }
80 if (event->doesFloat()) {
81 if (event->isMultiDay()) {
82 mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>")
83 .arg(event->dtStartDateStr(shortDate))
84 .arg(event->dtEndDateStr(shortDate)));
85 } else {
86 mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate )));
87 }
88 } else {
89 if (event->isMultiDay()) {
90 mText.append(i18n("<p><b>From:</b> %1</p> ")
91 .arg(event->dtStartStr( shortDate)));
92 mText.append(i18n("<p><b>To:</b> %1</p>")
93 .arg(event->dtEndStr(shortDate)));
94 } else {
95 mText.append(i18n("<p><b>On:</b> %1</p> ")
96 .arg(event->dtStartDateStr( shortDate )));
97 mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>")
98 .arg(event->dtStartTimeStr())
99 .arg(event->dtEndTimeStr()));
100 }
101 }
102
103 if (event->recurrence()->doesRecur()) {
104
105 QString recurText = event->recurrence()->recurrenceText();
106 addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>");
107 bool last;
108 QDate start = QDate::currentDate();
109 QDate next;
110 next = event->recurrence()->getPreviousDate( start , &last );
111 if ( !last ) {
112 next = event->recurrence()->getNextDate( start.addDays( - 1 ) );
113 addTag("p",i18n("Next recurrence is on: ")+ KGlobal::locale()->formatDate( next, shortDate ) );
114 //addTag("p", KGlobal::locale()->formatDate( next, shortDate ));
115 } else {
116 addTag("p",i18n("<b>Last recurrence was on:</b>") );
117 addTag("p", KGlobal::locale()->formatDate( next, shortDate ));
118 }
119 }
120
121
122 if (event->isAlarmEnabled()) {
123 Alarm *alarm =event->alarms().first() ;
124 QDateTime t = alarm->time();
125 int min = t.secsTo( event->dtStart() )/60;
126 QString s =i18n("(%1 min before)").arg( min );
127 addTag("p",i18n("<b>Alarm on: </b>") + s + ": "+KGlobal::locale()->formatDateTime( t, shortDate ));
128 //addTag("p", KGlobal::locale()->formatDateTime( t, shortDate ));
129 //addTag("p",s);
130 }
131
132 addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() );
133 // mText.append(event->secrecyStr()+"<br>");
134 formatCategories(event);
135 if (!event->description().isEmpty()) {
136 addTag("p",i18n("<b>Details: </b>"));
137 addTag("p",event->description());
138 }
139
140
141 formatReadOnly(event);
142 formatAttendees(event);
143
144
145}
146
147void KIncidenceFormatter::setTodo(Todo *event )
148{
149 int mode = 0;
150 mCurrentIncidence = event;
151 bool shortDate = true;
152 if (mode == 0 )
153 addTag("h3",event->summary());
154 else {
155 if ( mColorMode == 1 ) {
156 mText +="<font color=\"#00A000\">";
157 }
158 if ( mColorMode == 2 ) {
159 mText +="<font color=\"#B00000\">";
160 }
161 if ( mode == 1 ) {
162 addTag("h2",i18n( "Local: " ) +event->summary());
163 } else {
164 addTag("h2",i18n( "Remote: " ) +event->summary());
165 }
166 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) );
167 if ( mColorMode )
168 mText += "</font>";
169 }
170 if (event->cancelled ()) {
171 mText +="<font color=\"#B00000\">";
172 addTag("i",i18n("This todo has been cancelled!"));
173 mText.append("<br>");
174 mText += "</font>";
175 }
176
177 if (!event->location().isEmpty()) {
178 addTag("b",i18n("Location: "));
179 mText.append(event->location()+"<br>");
180 }
181 if (event->hasDueDate()) {
182 mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(shortDate)));
183 }
184 mText.append(i18n("<p><b>Priority:</b> %2</p>")
185 .arg(QString::number(event->priority())));
186
187 mText.append(i18n("<p><i>%1 % completed</i></p>")
188 .arg(event->percentComplete()));
189 addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() );
190 formatCategories(event);
191 if (!event->description().isEmpty()) {
192 addTag("p",i18n("<b>Details: </b>"));
193 addTag("p",event->description());
194 }
195
196
197
198 formatReadOnly(event);
199 formatAttendees(event);
200
201}
202
203void KIncidenceFormatter::setJournal(Journal* )
204{
205
206}
207
208void KIncidenceFormatter::formatCategories(Incidence *event)
209{
210 if (!event->categoriesStr().isEmpty()) {
211 addTag("p",i18n("<b>Categories: </b>")+event->categoriesStr() );
212 //mText.append(event->categoriesStr());
213 }
214}
215void KIncidenceFormatter::addTag(const QString & tag,const QString & text)
216{
217 int number=text.contains("\n");
218 QString str = "<" + tag + ">";
219 QString tmpText=text;
220 QString tmpStr=str;
221 if(number !=-1)
222 {
223 if (number > 0) {
224 int pos=0;
225 QString tmp;
226 for(int i=0;i<=number;i++) {
227 pos=tmpText.find("\n");
228 tmp=tmpText.left(pos);
229 tmpText=tmpText.right(tmpText.length()-pos-1);
230 tmpStr+=tmp+"<br>";
231 }
232 }
233 else tmpStr += tmpText;
234 tmpStr+="</" + tag + ">";
235 mText.append(tmpStr);
236 }
237 else
238 {
239 str += text + "</" + tag + ">";
240 mText.append(str);
241 }
242}
243
244void KIncidenceFormatter::formatAttendees(Incidence *event)
245{
246 QPtrList<Attendee> attendees = event->attendees();
247 if (attendees.count()) {
248 QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small);
249 addTag("h3",i18n("Organizer"));
250 mText.append("<ul><li>");
251#if 0
252 //ndef KORG_NOKABC
253
254 KABC::AddressBook *add_book = KABC::StdAddressBook::self();
255 KABC::Addressee::List addressList;
256 addressList = add_book->findByEmail(event->organizer());
257 KABC::Addressee o = addressList.first();
258 if (!o.isEmpty() && addressList.size()<2) {
259 mText += "<a href=\"uid:" + o.uid() + "\">";
260 mText += o.formattedName();
261 mText += "</a>\n";
262 } else {
263 mText.append(event->organizer());
264 }
265#else
266 mText.append(event->organizer());
267#endif
268 if (iconPath) {
269 mText += " <a href=\"mailto:" + event->organizer() + "\">";
270 mText += "<IMG src=\"" + iconPath + "\">";
271 mText += "</a>\n";
272 }
273 mText.append("</li></ul>");
274
275 addTag("h3",i18n("Attendees"));
276 Attendee *a;
277 mText.append("<ul>");
278 for(a=attendees.first();a;a=attendees.next()) {
279#if 0
280//ndef KORG_NOKABC
281 if (a->name().isEmpty()) {
282 addressList = add_book->findByEmail(a->email());
283 KABC::Addressee o = addressList.first();
284 if (!o.isEmpty() && addressList.size()<2) {
285 mText += "<a href=\"uid:" + o.uid() + "\">";
286 mText += o.formattedName();
287 mText += "</a>\n";
288 } else {
289 mText += "<li>";
290 mText.append(a->email());
291 mText += "\n";
292 }
293 } else {
294 mText += "<li><a href=\"uid:" + a->uid() + "\">";
295 if (!a->name().isEmpty()) mText += a->name();
296 else mText += a->email();
297 mText += "</a>\n";
298 }
299#else
300 //qDebug("nokabc ");
301 mText += "<li><a href=\"uid:" + a->uid() + "\">";
302 if (!a->name().isEmpty()) mText += a->name();
303 else mText += a->email();
304 mText += "</a>\n";
305#endif
306
307 if (!a->email().isEmpty()) {
308 if (iconPath) {
309 mText += "<a href=\"mailto:" + a->name() +" "+ "<" + a->email() + ">" + "\">";
310 mText += "<IMG src=\"" + iconPath + "\">";
311 mText += "</a>\n";
312 }
313 }
314 if (a->status() != Attendee::NeedsAction )
315 mText +="[" + a->statusStr() + "] ";
316 if (a->role() == Attendee::Chair )
317 mText +="(" + a->roleStr().left(1) + ".)";
318 }
319 mText.append("</li></ul>");
320 }
321}
322
323void KIncidenceFormatter::formatReadOnly(Incidence *event)
324{
325 if (event->isReadOnly()) {
326 addTag("p","<em>(" + i18n("read-only") + ")</em>");
327 }
328}
diff --git a/libkdepim/kincidenceformatter.h b/libkdepim/kincidenceformatter.h
deleted file mode 100644
index 8fe259a..0000000
--- a/libkdepim/kincidenceformatter.h
+++ b/dev/null
@@ -1,42 +0,0 @@
1#ifndef KINCIDENCENFORMATTER_H
2#define KINCIDENCENFORMATTER_H
3
4#include <qstring.h>
5#include <qobject.h>
6
7#include "libkcal/incidence.h"
8#include "libkcal/event.h"
9#include "libkcal/todo.h"
10#include "libkcal/journal.h"
11
12using namespace KCal;
13
14class KIncidenceFormatter : public QObject
15{
16 public:
17 static KIncidenceFormatter* instance();
18 KIncidenceFormatter();
19 ~KIncidenceFormatter();
20 QString getFormattedText( Incidence * inc );
21
22 void setEvent(Event *event);
23 void setTodo(Todo *event );
24 void setJournal(Journal* );
25
26 protected:
27 int mColorMode;
28 void addTag(const QString & tag,const QString & text);
29
30 void formatCategories(Incidence *event);
31 void formatAttendees(Incidence *event);
32 void formatReadOnly(Incidence *event);
33
34 private:
35 bool mSyncMode;
36
37 QString mText;
38 Incidence* mCurrentIncidence;
39 static KIncidenceFormatter* mInstance;
40};
41
42#endif