summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-07-03 16:54:31 (UTC)
committer zautrix <zautrix>2004-07-03 16:54:31 (UTC)
commit6c035951faeaea6d7651e5fd028c7fd2a674cdfc (patch) (unidiff)
treef55c6dd1f4457a5c3d387e6511d596438988955e
parent1da48d95d970233f0d1ea9a7fba5c98cfcf24798 (diff)
downloadkdepimpi-6c035951faeaea6d7651e5fd028c7fd2a674cdfc.zip
kdepimpi-6c035951faeaea6d7651e5fd028c7fd2a674cdfc.tar.gz
kdepimpi-6c035951faeaea6d7651e5fd028c7fd2a674cdfc.tar.bz2
Added connection to KM when clicking on email
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/addresseeview.cpp18
-rw-r--r--libkdepim/addresseeview.h2
-rw-r--r--libkdepim/kincidenceformatter.cpp6
3 files changed, 22 insertions, 4 deletions
diff --git a/libkdepim/addresseeview.cpp b/libkdepim/addresseeview.cpp
index deafd34..70fc57c 100644
--- a/libkdepim/addresseeview.cpp
+++ b/libkdepim/addresseeview.cpp
@@ -1,217 +1,233 @@
1/* 1/*
2 This file is part of libkdepim. 2 This file is part of libkdepim.
3 3
4 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 4 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 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 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, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22#include <kabc/address.h> 22#include <kabc/address.h>
23#include <kabc/addressee.h> 23#include <kabc/addressee.h>
24#include <kabc/phonenumber.h> 24#include <kabc/phonenumber.h>
25#include <kglobal.h> 25#include <kglobal.h>
26//US#include <kglobalsettings.h> 26//US#include <kglobalsettings.h>
27#include <kiconloader.h> 27#include <kiconloader.h>
28#include <klocale.h> 28#include <klocale.h>
29//US #include <kstringhandler.h> 29//US #include <kstringhandler.h>
30#include <qscrollview.h> 30#include <qscrollview.h>
31#include <qregexp.h> 31#include <qregexp.h>
32#include <qfile.h> 32#include <qfile.h>
33#include <qapplication.h> 33#include <qapplication.h>
34 34
35 35
36#include "addresseeview.h" 36#include "addresseeview.h"
37 37
38
39#ifndef DESKTOP_VERSION
40#include <qtopia/qcopenvelope_qws.h>
41#endif
42
43
44
38using namespace KPIM; 45using namespace KPIM;
39 46
40AddresseeView::AddresseeView( QWidget *parent, const char *name ) 47AddresseeView::AddresseeView( QWidget *parent, const char *name )
41//US : KTextBrowser( parent, name ) 48//US : KTextBrowser( parent, name )
42 : QTextBrowser( parent, name ) 49 : QTextBrowser( parent, name )
43 50
44 51
45{ 52{
46//US setWrapPolicy( QTextEdit::AtWordBoundary ); 53//US setWrapPolicy( QTextEdit::AtWordBoundary );
47 setLinkUnderline( false ); 54 setLinkUnderline( false );
48 // setVScrollBarMode( QScrollView::AlwaysOff ); 55 // setVScrollBarMode( QScrollView::AlwaysOff );
49 //setHScrollBarMode( QScrollView::AlwaysOff ); 56 //setHScrollBarMode( QScrollView::AlwaysOff );
50 57
51//US QStyleSheet *sheet = styleSheet(); 58//US QStyleSheet *sheet = styleSheet();
52//US QStyleSheetItem *link = sheet->item( "a" ); 59//US QStyleSheetItem *link = sheet->item( "a" );
53//US link->setColor( KGlobalSettings::linkColor() ); 60//US link->setColor( KGlobalSettings::linkColor() );
54 61
55} 62}
63void AddresseeView::setSource(const QString& n)
64{
65 //qDebug("********AddresseeView::setSource %s", n.mid(7).latin1());
66#ifndef DESKTOP_VERSION
67 QCopEnvelope e("QPE/Application/kmpi", "newMail(QString)");
68 e << n.mid(7);
69#endif
56 70
71}
57void AddresseeView::setAddressee( const KABC::Addressee& addr ) 72void AddresseeView::setAddressee( const KABC::Addressee& addr )
58{ 73{
59 mAddressee = addr; 74 mAddressee = addr;
60 75
61 // clear view 76 // clear view
62 setText( QString::null ); 77 setText( QString::null );
63 78
64 if ( mAddressee.isEmpty() ) 79 if ( mAddressee.isEmpty() )
65 return; 80 return;
66 81
67 QString name = ( mAddressee.formattedName().isEmpty() ? 82 QString name = ( mAddressee.formattedName().isEmpty() ?
68 mAddressee.assembledName() : mAddressee.formattedName() ); 83 mAddressee.assembledName() : mAddressee.formattedName() );
69 84
70 QString dynamicPart; 85 QString dynamicPart;
71 86
72 KABC::PhoneNumber::List phones = mAddressee.phoneNumbers(); 87 KABC::PhoneNumber::List phones = mAddressee.phoneNumbers();
73 KABC::PhoneNumber::List::ConstIterator phoneIt; 88 KABC::PhoneNumber::List::ConstIterator phoneIt;
74 for ( phoneIt = phones.begin(); phoneIt != phones.end(); ++phoneIt ) { 89 for ( phoneIt = phones.begin(); phoneIt != phones.end(); ++phoneIt ) {
75 dynamicPart += QString( 90 dynamicPart += QString(
76 "<tr><td align=\"right\"><b>%1</b></td>" 91 "<tr><td align=\"right\"><b>%1</b></td>"
77 "<td align=\"left\">%2</td></tr>" ) 92 "<td align=\"left\">%2</td></tr>" )
78 .arg( KABC::PhoneNumber::typeLabel( (*phoneIt).type() ) ) 93 .arg( KABC::PhoneNumber::typeLabel( (*phoneIt).type() ) )
79 .arg( (*phoneIt).number() ); 94 .arg( (*phoneIt).number() );
80 } 95 }
81 96
82 QStringList emails = mAddressee.emails(); 97 QStringList emails = mAddressee.emails();
83 QStringList::ConstIterator emailIt; 98 QStringList::ConstIterator emailIt;
84 QString type = i18n( "Email" ); 99 QString type = i18n( "Email" );
85 for ( emailIt = emails.begin(); emailIt != emails.end(); ++emailIt ) { 100 for ( emailIt = emails.begin(); emailIt != emails.end(); ++emailIt ) {
86 dynamicPart += QString( 101 dynamicPart += QString(
87 "<tr><td align=\"right\"><b>%1</b></td>" 102 "<tr><td align=\"right\"><b>%1</b></td>"
88 "<td align=\"left\"><a href=\"mailto:%2\">%3</a></td></tr>" ) 103 "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" )
89 .arg( type ) 104 .arg( type )
105 .arg( name )
90 .arg( *emailIt ) 106 .arg( *emailIt )
91 .arg( *emailIt ); 107 .arg( *emailIt );
92 type = i18n( "Other" ); 108 type = i18n( "Other" );
93 } 109 }
94 110
95 if ( !mAddressee.url().url().isEmpty() ) { 111 if ( !mAddressee.url().url().isEmpty() ) {
96 dynamicPart += QString( 112 dynamicPart += QString(
97 "<tr><td align=\"right\"><b>%1</b></td>" 113 "<tr><td align=\"right\"><b>%1</b></td>"
98 "<td align=\"left\">%2</td></tr>" ) 114 "<td align=\"left\">%2</td></tr>" )
99 .arg( i18n( "Homepage" ) ) 115 .arg( i18n( "Homepage" ) )
100//US .arg( KStringHandler::tagURLs( mAddressee.url().url() ) ); 116//US .arg( KStringHandler::tagURLs( mAddressee.url().url() ) );
101 .arg( mAddressee.url().url() ); 117 .arg( mAddressee.url().url() );
102 //qDebug("AddresseeView::setAddressee has to be verified."); 118 //qDebug("AddresseeView::setAddressee has to be verified.");
103 } 119 }
104 120
105 KABC::Address::List addresses = mAddressee.addresses(); 121 KABC::Address::List addresses = mAddressee.addresses();
106 KABC::Address::List::ConstIterator addrIt; 122 KABC::Address::List::ConstIterator addrIt;
107 for ( addrIt = addresses.begin(); addrIt != addresses.end(); ++addrIt ) { 123 for ( addrIt = addresses.begin(); addrIt != addresses.end(); ++addrIt ) {
108 if ( true /*(*addrIt).label().isEmpty()*/ ) { 124 if ( true /*(*addrIt).label().isEmpty()*/ ) {
109 QString formattedAddress = (*addrIt).formattedAddress().stripWhiteSpace(); 125 QString formattedAddress = (*addrIt).formattedAddress().stripWhiteSpace();
110//US formattedAddress = formattedAddress.replace( '\n', "<br>" ); 126//US formattedAddress = formattedAddress.replace( '\n', "<br>" );
111 //qDebug("adresss %s ",formattedAddress.latin1() ); 127 //qDebug("adresss %s ",formattedAddress.latin1() );
112 formattedAddress = formattedAddress.replace( QRegExp("\n"), "<br>" ); 128 formattedAddress = formattedAddress.replace( QRegExp("\n"), "<br>" );
113 //qDebug("AddresseeView::setAddressee has to be verified."); 129 //qDebug("AddresseeView::setAddressee has to be verified.");
114 130
115 dynamicPart += QString( 131 dynamicPart += QString(
116 "<tr><td align=\"right\"><b>%1</b></td>" 132 "<tr><td align=\"right\"><b>%1</b></td>"
117 "<td align=\"left\">%2</td></tr>" ) 133 "<td align=\"left\">%2</td></tr>" )
118 .arg( KABC::Address::typeLabel( (*addrIt).type() ) ) 134 .arg( KABC::Address::typeLabel( (*addrIt).type() ) )
119 .arg( formattedAddress ); 135 .arg( formattedAddress );
120 } else { 136 } else {
121 137
122 dynamicPart += QString( 138 dynamicPart += QString(
123 "<tr><td align=\"right\"><b>%1</b></td>" 139 "<tr><td align=\"right\"><b>%1</b></td>"
124 "<td align=\"left\">%2</td></tr>" ) 140 "<td align=\"left\">%2</td></tr>" )
125 .arg( KABC::Address::typeLabel( (*addrIt).type() ) ) 141 .arg( KABC::Address::typeLabel( (*addrIt).type() ) )
126//US .arg( (*addrIt).label().replace( '\n', "<br>" ) ); 142//US .arg( (*addrIt).label().replace( '\n', "<br>" ) );
127 .arg( (*addrIt).label() /*replace( QRegExp("\n"), "<br>" )*/ ); 143 .arg( (*addrIt).label() /*replace( QRegExp("\n"), "<br>" )*/ );
128 144
129 } 145 }
130 } 146 }
131 147
132 QString notes; 148 QString notes;
133 if ( !mAddressee.note().isEmpty() ) { 149 if ( !mAddressee.note().isEmpty() ) {
134 notes = QString( 150 notes = QString(
135 "<tr>" 151 "<tr>"
136 "<td align=\"right\" valign=\"top\"><b>%1:</b></td>" // note label 152 "<td align=\"right\" valign=\"top\"><b>%1:</b></td>" // note label
137 "<td align=\"left\">%2</td>" // note 153 "<td align=\"left\">%2</td>" // note
138 "</tr>" ).arg( i18n( "Notes" ) ) 154 "</tr>" ).arg( i18n( "Notes" ) )
139//US .arg( mAddressee.note().replace( '\n', "<br>" ) ); 155//US .arg( mAddressee.note().replace( '\n', "<br>" ) );
140 .arg( mAddressee.note().replace( QRegExp("\n"), "<br>" ) ); 156 .arg( mAddressee.note().replace( QRegExp("\n"), "<br>" ) );
141 //qDebug("AddresseeView::setAddressee has to be verified."); 157 //qDebug("AddresseeView::setAddressee has to be verified.");
142 } 158 }
143 159
144 QString aRole = ""; 160 QString aRole = "";
145 QString aOrga = ""; 161 QString aOrga = "";
146 if ( true /*!mAddressee.role().isEmpty()*/ ) { 162 if ( true /*!mAddressee.role().isEmpty()*/ ) {
147 aRole = "<tr>" 163 aRole = "<tr>"
148 "<td align=\"left\">" + mAddressee.role() + "</td>" 164 "<td align=\"left\">" + mAddressee.role() + "</td>"
149 "</tr>"; 165 "</tr>";
150 } 166 }
151 if ( true /*!mAddressee.organization().isEmpty()*/ ) { 167 if ( true /*!mAddressee.organization().isEmpty()*/ ) {
152 aOrga = "<tr>" 168 aOrga = "<tr>"
153 "<td align=\"left\">" + mAddressee.organization() + "</td>" ; 169 "<td align=\"left\">" + mAddressee.organization() + "</td>" ;
154 "</tr>"; 170 "</tr>";
155 } 171 }
156 mText = ""; 172 mText = "";
157 QString picString = ""; 173 QString picString = "";
158 KABC::Picture picture = mAddressee.photo(); 174 KABC::Picture picture = mAddressee.photo();
159 bool picAvailintern = false; 175 bool picAvailintern = false;
160 bool picAvailUrl = false; 176 bool picAvailUrl = false;
161 if (! picture.undefined() ) { 177 if (! picture.undefined() ) {
162 picAvailintern = (picture.isIntern() && !picture.data().isNull()); 178 picAvailintern = (picture.isIntern() && !picture.data().isNull());
163 picAvailUrl = !picture.isIntern() && QFile::exists(picture.url() ); 179 picAvailUrl = !picture.isIntern() && QFile::exists(picture.url() );
164 } 180 }
165 if ( picAvailUrl || picAvailintern || QApplication::desktop()->width() > 320 ) { 181 if ( picAvailUrl || picAvailintern || QApplication::desktop()->width() > 320 ) {
166 if ( picAvailintern ) { 182 if ( picAvailintern ) {
167 QMimeSourceFactory::defaultFactory()->setImage( "myimage", picture.data() ); 183 QMimeSourceFactory::defaultFactory()->setImage( "myimage", picture.data() );
168 } else { 184 } else {
169 if ( picAvailUrl ) { 185 if ( picAvailUrl ) {
170 QMimeSourceFactory::defaultFactory()->setPixmap( "myimage", QPixmap( picture.url() )); 186 QMimeSourceFactory::defaultFactory()->setPixmap( "myimage", QPixmap( picture.url() ));
171 } else { 187 } else {
172 QMimeSourceFactory::defaultFactory()->setPixmap( "myimage", KGlobal::iconLoader()->loadIcon( "package_toys", KIcon::Desktop, 128 ) ); 188 QMimeSourceFactory::defaultFactory()->setPixmap( "myimage", KGlobal::iconLoader()->loadIcon( "package_toys", KIcon::Desktop, 128 ) );
173 } 189 }
174 } 190 }
175 picString = "<img src=\"myimage\" width=\"50\" height=\"70\">"; 191 picString = "<img src=\"myimage\" width=\"50\" height=\"70\">";
176 mText = QString::fromLatin1( 192 mText = QString::fromLatin1(
177 "<html>" 193 "<html>"
178 "<body text=\"%1\" bgcolor=\"%2\">" // text and background color 194 "<body text=\"%1\" bgcolor=\"%2\">" // text and background color
179 "<table>" 195 "<table>"
180 "<tr>" 196 "<tr>"
181 "<td rowspan=\"3\" align=\"right\" valign=\"top\">" 197 "<td rowspan=\"3\" align=\"right\" valign=\"top\">"
182 "%3" 198 "%3"
183 "</td>" 199 "</td>"
184 "<td align=\"left\"><font size=\"+2\"><b>%4</b></font></td>" // name 200 "<td align=\"left\"><font size=\"+2\"><b>%4</b></font></td>" // name
185 "</tr>" 201 "</tr>"
186 "%5" // role 202 "%5" // role
187 "%6" // organization 203 "%6" // organization
188 "<td colspan=\"2\">&nbsp;</td>" 204 "<td colspan=\"2\">&nbsp;</td>"
189 "%7" // dynamic part 205 "%7" // dynamic part
190 "%8" // notes 206 "%8" // notes
191 "</table>" 207 "</table>"
192 "</body>" 208 "</body>"
193 "</html>") 209 "</html>")
194//US 210//US
195 .arg( /*KGlobalSettings::textColor().name()*/ "black" ) 211 .arg( /*KGlobalSettings::textColor().name()*/ "black" )
196//US 212//US
197 .arg( /*KGlobalSettings::baseColor().name()*/ "white" ) 213 .arg( /*KGlobalSettings::baseColor().name()*/ "white" )
198 .arg( picString ) 214 .arg( picString )
199 .arg( name ) 215 .arg( name )
200 .arg( aRole ) 216 .arg( aRole )
201 .arg( aOrga ) 217 .arg( aOrga )
202 .arg( dynamicPart ) 218 .arg( dynamicPart )
203 .arg( notes ); 219 .arg( notes );
204 220
205 } else { // no picture! 221 } else { // no picture!
206 222
207mText = "<table width=\"100%\">\n"; 223mText = "<table width=\"100%\">\n";
208 //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; 224 //mText += "<tr bgcolor=\"#3679AD\"><td><h2>";
209#ifdef DESKTOP_VERSION 225#ifdef DESKTOP_VERSION
210 mText += "<tr bgcolor=\"#5699CD\"><td align=\"left\"><h1>"; 226 mText += "<tr bgcolor=\"#5699CD\"><td align=\"left\"><h1>";
211#else 227#else
212 mText += "<tr bgcolor=\"#5699CD\"><td align=\"left\"><h2>"; 228 mText += "<tr bgcolor=\"#5699CD\"><td align=\"left\"><h2>";
213#endif 229#endif
214 230
215#ifdef DESKTOP_VERSION 231#ifdef DESKTOP_VERSION
216 mText += "<font color=\"#FFFFFF\"> <em>" + name+"</em></font></h1>"; 232 mText += "<font color=\"#FFFFFF\"> <em>" + name+"</em></font></h1>";
217#else 233#else
diff --git a/libkdepim/addresseeview.h b/libkdepim/addresseeview.h
index 598ef0d..1865fc4 100644
--- a/libkdepim/addresseeview.h
+++ b/libkdepim/addresseeview.h
@@ -1,60 +1,60 @@
1/* 1/*
2 This file is part of libkdepim. 2 This file is part of libkdepim.
3 3
4 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 4 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 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 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, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22#ifndef KPIM_ADDRESSEEVIEW_H 22#ifndef KPIM_ADDRESSEEVIEW_H
23#define KPIM_ADDRESSEEVIEW_H 23#define KPIM_ADDRESSEEVIEW_H
24 24
25#include <kabc/addressee.h> 25#include <kabc/addressee.h>
26 26
27//US #include <ktextbrowser.h> 27//US #include <ktextbrowser.h>
28#include <qtextbrowser.h> 28#include <qtextbrowser.h>
29 29
30namespace KPIM { 30namespace KPIM {
31 31
32//US class AddresseeView : public KTextBrowser 32//US class AddresseeView : public KTextBrowser
33class AddresseeView : public QTextBrowser 33class AddresseeView : public QTextBrowser
34{ 34{
35 public: 35 public:
36 AddresseeView( QWidget *parent = 0, const char *name = 0 ); 36 AddresseeView( QWidget *parent = 0, const char *name = 0 );
37 37
38 /** 38 /**
39 Sets the addressee object. The addressee is displayed immediately. 39 Sets the addressee object. The addressee is displayed immediately.
40 40
41 @param addr The addressee object. 41 @param addr The addressee object.
42 */ 42 */
43 void setAddressee( const KABC::Addressee& addr ); 43 void setAddressee( const KABC::Addressee& addr );
44 44 void setSource(const QString& n);
45 /** 45 /**
46 Returns the current addressee object. 46 Returns the current addressee object.
47 */ 47 */
48 KABC::Addressee addressee() const; 48 KABC::Addressee addressee() const;
49 49
50 private: 50 private:
51 KABC::Addressee mAddressee; 51 KABC::Addressee mAddressee;
52 QString mText; 52 QString mText;
53 void addTag(const QString & tag,const QString & text); 53 void addTag(const QString & tag,const QString & text);
54 class AddresseeViewPrivate; 54 class AddresseeViewPrivate;
55 AddresseeViewPrivate *d; 55 AddresseeViewPrivate *d;
56}; 56};
57 57
58} 58}
59 59
60#endif 60#endif
diff --git a/libkdepim/kincidenceformatter.cpp b/libkdepim/kincidenceformatter.cpp
index 4815519..2f41409 100644
--- a/libkdepim/kincidenceformatter.cpp
+++ b/libkdepim/kincidenceformatter.cpp
@@ -123,204 +123,206 @@ void KIncidenceFormatter::setEvent(Event *event)
123 Alarm *alarm =event->alarms().first() ; 123 Alarm *alarm =event->alarms().first() ;
124 QDateTime t = alarm->time(); 124 QDateTime t = alarm->time();
125 int min = t.secsTo( event->dtStart() )/60; 125 int min = t.secsTo( event->dtStart() )/60;
126 QString s =i18n("(%1 min before)").arg( min ); 126 QString s =i18n("(%1 min before)").arg( min );
127 addTag("p",i18n("<b>Alarm on: </b>") + s + ": "+KGlobal::locale()->formatDateTime( t, shortDate )); 127 addTag("p",i18n("<b>Alarm on: </b>") + s + ": "+KGlobal::locale()->formatDateTime( t, shortDate ));
128 //addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); 128 //addTag("p", KGlobal::locale()->formatDateTime( t, shortDate ));
129 //addTag("p",s); 129 //addTag("p",s);
130 } 130 }
131 131
132 addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() ); 132 addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() );
133 // mText.append(event->secrecyStr()+"<br>"); 133 // mText.append(event->secrecyStr()+"<br>");
134 formatCategories(event); 134 formatCategories(event);
135 if (!event->description().isEmpty()) { 135 if (!event->description().isEmpty()) {
136 addTag("p",i18n("<b>Details: </b>")); 136 addTag("p",i18n("<b>Details: </b>"));
137 addTag("p",event->description()); 137 addTag("p",event->description());
138 } 138 }
139 139
140 140
141 formatReadOnly(event); 141 formatReadOnly(event);
142 formatAttendees(event); 142 formatAttendees(event);
143 143
144 144
145} 145}
146 146
147void KIncidenceFormatter::setTodo(Todo *event ) 147void KIncidenceFormatter::setTodo(Todo *event )
148{ 148{
149 int mode = 0; 149 int mode = 0;
150 mCurrentIncidence = event; 150 mCurrentIncidence = event;
151 bool shortDate = true; 151 bool shortDate = true;
152 if (mode == 0 ) 152 if (mode == 0 )
153 addTag("h3",event->summary()); 153 addTag("h3",event->summary());
154 else { 154 else {
155 if ( mColorMode == 1 ) { 155 if ( mColorMode == 1 ) {
156 mText +="<font color=\"#00A000\">"; 156 mText +="<font color=\"#00A000\">";
157 } 157 }
158 if ( mColorMode == 2 ) { 158 if ( mColorMode == 2 ) {
159 mText +="<font color=\"#B00000\">"; 159 mText +="<font color=\"#B00000\">";
160 } 160 }
161 if ( mode == 1 ) { 161 if ( mode == 1 ) {
162 addTag("h2",i18n( "Local: " ) +event->summary()); 162 addTag("h2",i18n( "Local: " ) +event->summary());
163 } else { 163 } else {
164 addTag("h2",i18n( "Remote: " ) +event->summary()); 164 addTag("h2",i18n( "Remote: " ) +event->summary());
165 } 165 }
166 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); 166 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) );
167 if ( mColorMode ) 167 if ( mColorMode )
168 mText += "</font>"; 168 mText += "</font>";
169 } 169 }
170 if (event->cancelled ()) { 170 if (event->cancelled ()) {
171 mText +="<font color=\"#B00000\">"; 171 mText +="<font color=\"#B00000\">";
172 addTag("i",i18n("This todo has been cancelled!")); 172 addTag("i",i18n("This todo has been cancelled!"));
173 mText.append("<br>"); 173 mText.append("<br>");
174 mText += "</font>"; 174 mText += "</font>";
175 } 175 }
176 176
177 if (!event->location().isEmpty()) { 177 if (!event->location().isEmpty()) {
178 addTag("b",i18n("Location: ")); 178 addTag("b",i18n("Location: "));
179 mText.append(event->location()+"<br>"); 179 mText.append(event->location()+"<br>");
180 } 180 }
181 if (event->hasDueDate()) { 181 if (event->hasDueDate()) {
182 mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(shortDate))); 182 mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(shortDate)));
183 } 183 }
184 mText.append(i18n("<p><b>Priority:</b> %2</p>") 184 mText.append(i18n("<p><b>Priority:</b> %2</p>")
185 .arg(QString::number(event->priority()))); 185 .arg(QString::number(event->priority())));
186 186
187 mText.append(i18n("<p><i>%1 % completed</i></p>") 187 mText.append(i18n("<p><i>%1 % completed</i></p>")
188 .arg(event->percentComplete())); 188 .arg(event->percentComplete()));
189 addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() ); 189 addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() );
190 formatCategories(event); 190 formatCategories(event);
191 if (!event->description().isEmpty()) { 191 if (!event->description().isEmpty()) {
192 addTag("p",i18n("<b>Details: </b>")); 192 addTag("p",i18n("<b>Details: </b>"));
193 addTag("p",event->description()); 193 addTag("p",event->description());
194 } 194 }
195 195
196 196
197 197
198 formatReadOnly(event); 198 formatReadOnly(event);
199 formatAttendees(event); 199 formatAttendees(event);
200 200
201} 201}
202 202
203void KIncidenceFormatter::setJournal(Journal* ) 203void KIncidenceFormatter::setJournal(Journal* )
204{ 204{
205 205
206} 206}
207 207
208void KIncidenceFormatter::formatCategories(Incidence *event) 208void KIncidenceFormatter::formatCategories(Incidence *event)
209{ 209{
210 if (!event->categoriesStr().isEmpty()) { 210 if (!event->categoriesStr().isEmpty()) {
211 addTag("p",i18n("<b>Categories: </b>")+event->categoriesStr() ); 211 addTag("p",i18n("<b>Categories: </b>")+event->categoriesStr() );
212 //mText.append(event->categoriesStr()); 212 //mText.append(event->categoriesStr());
213 } 213 }
214} 214}
215void KIncidenceFormatter::addTag(const QString & tag,const QString & text) 215void KIncidenceFormatter::addTag(const QString & tag,const QString & text)
216{ 216{
217 int number=text.contains("\n"); 217 int number=text.contains("\n");
218 QString str = "<" + tag + ">"; 218 QString str = "<" + tag + ">";
219 QString tmpText=text; 219 QString tmpText=text;
220 QString tmpStr=str; 220 QString tmpStr=str;
221 if(number !=-1) 221 if(number !=-1)
222 { 222 {
223 if (number > 0) { 223 if (number > 0) {
224 int pos=0; 224 int pos=0;
225 QString tmp; 225 QString tmp;
226 for(int i=0;i<=number;i++) { 226 for(int i=0;i<=number;i++) {
227 pos=tmpText.find("\n"); 227 pos=tmpText.find("\n");
228 tmp=tmpText.left(pos); 228 tmp=tmpText.left(pos);
229 tmpText=tmpText.right(tmpText.length()-pos-1); 229 tmpText=tmpText.right(tmpText.length()-pos-1);
230 tmpStr+=tmp+"<br>"; 230 tmpStr+=tmp+"<br>";
231 } 231 }
232 } 232 }
233 else tmpStr += tmpText; 233 else tmpStr += tmpText;
234 tmpStr+="</" + tag + ">"; 234 tmpStr+="</" + tag + ">";
235 mText.append(tmpStr); 235 mText.append(tmpStr);
236 } 236 }
237 else 237 else
238 { 238 {
239 str += text + "</" + tag + ">"; 239 str += text + "</" + tag + ">";
240 mText.append(str); 240 mText.append(str);
241 } 241 }
242} 242}
243 243
244void KIncidenceFormatter::formatAttendees(Incidence *event) 244void KIncidenceFormatter::formatAttendees(Incidence *event)
245{ 245{
246 QPtrList<Attendee> attendees = event->attendees(); 246 QPtrList<Attendee> attendees = event->attendees();
247 if (attendees.count()) { 247 if (attendees.count()) {
248 QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); 248 QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small);
249 addTag("h3",i18n("Organizer")); 249 addTag("h3",i18n("Organizer"));
250 mText.append("<ul><li>"); 250 mText.append("<ul><li>");
251#ifndef KORG_NOKABC 251#if 0
252 //ndef KORG_NOKABC
252 253
253 KABC::AddressBook *add_book = KABC::StdAddressBook::self(); 254 KABC::AddressBook *add_book = KABC::StdAddressBook::self();
254 KABC::Addressee::List addressList; 255 KABC::Addressee::List addressList;
255 addressList = add_book->findByEmail(event->organizer()); 256 addressList = add_book->findByEmail(event->organizer());
256 KABC::Addressee o = addressList.first(); 257 KABC::Addressee o = addressList.first();
257 if (!o.isEmpty() && addressList.size()<2) { 258 if (!o.isEmpty() && addressList.size()<2) {
258 mText += "<a href=\"uid:" + o.uid() + "\">"; 259 mText += "<a href=\"uid:" + o.uid() + "\">";
259 mText += o.formattedName(); 260 mText += o.formattedName();
260 mText += "</a>\n"; 261 mText += "</a>\n";
261 } else { 262 } else {
262 mText.append(event->organizer()); 263 mText.append(event->organizer());
263 } 264 }
264#else 265#else
265 mText.append(event->organizer()); 266 mText.append(event->organizer());
266#endif 267#endif
267 if (iconPath) { 268 if (iconPath) {
268 mText += " <a href=\"mailto:" + event->organizer() + "\">"; 269 mText += " <a href=\"mailto:" + event->organizer() + "\">";
269 mText += "<IMG src=\"" + iconPath + "\">"; 270 mText += "<IMG src=\"" + iconPath + "\">";
270 mText += "</a>\n"; 271 mText += "</a>\n";
271 } 272 }
272 mText.append("</li></ul>"); 273 mText.append("</li></ul>");
273 274
274 addTag("h3",i18n("Attendees")); 275 addTag("h3",i18n("Attendees"));
275 Attendee *a; 276 Attendee *a;
276 mText.append("<ul>"); 277 mText.append("<ul>");
277 for(a=attendees.first();a;a=attendees.next()) { 278 for(a=attendees.first();a;a=attendees.next()) {
278#ifndef KORG_NOKABC 279#if 0
280//ndef KORG_NOKABC
279 if (a->name().isEmpty()) { 281 if (a->name().isEmpty()) {
280 addressList = add_book->findByEmail(a->email()); 282 addressList = add_book->findByEmail(a->email());
281 KABC::Addressee o = addressList.first(); 283 KABC::Addressee o = addressList.first();
282 if (!o.isEmpty() && addressList.size()<2) { 284 if (!o.isEmpty() && addressList.size()<2) {
283 mText += "<a href=\"uid:" + o.uid() + "\">"; 285 mText += "<a href=\"uid:" + o.uid() + "\">";
284 mText += o.formattedName(); 286 mText += o.formattedName();
285 mText += "</a>\n"; 287 mText += "</a>\n";
286 } else { 288 } else {
287 mText += "<li>"; 289 mText += "<li>";
288 mText.append(a->email()); 290 mText.append(a->email());
289 mText += "\n"; 291 mText += "\n";
290 } 292 }
291 } else { 293 } else {
292 mText += "<li><a href=\"uid:" + a->uid() + "\">"; 294 mText += "<li><a href=\"uid:" + a->uid() + "\">";
293 if (!a->name().isEmpty()) mText += a->name(); 295 if (!a->name().isEmpty()) mText += a->name();
294 else mText += a->email(); 296 else mText += a->email();
295 mText += "</a>\n"; 297 mText += "</a>\n";
296 } 298 }
297#else 299#else
298 //qDebug("nokabc "); 300 //qDebug("nokabc ");
299 mText += "<li><a href=\"uid:" + a->uid() + "\">"; 301 mText += "<li><a href=\"uid:" + a->uid() + "\">";
300 if (!a->name().isEmpty()) mText += a->name(); 302 if (!a->name().isEmpty()) mText += a->name();
301 else mText += a->email(); 303 else mText += a->email();
302 mText += "</a>\n"; 304 mText += "</a>\n";
303#endif 305#endif
304 306
305 if (!a->email().isEmpty()) { 307 if (!a->email().isEmpty()) {
306 if (iconPath) { 308 if (iconPath) {
307 mText += "<a href=\"mailto:" + a->name() +" "+ "<" + a->email() + ">" + "\">"; 309 mText += "<a href=\"mailto:" + a->name() +" "+ "<" + a->email() + ">" + "\">";
308 mText += "<IMG src=\"" + iconPath + "\">"; 310 mText += "<IMG src=\"" + iconPath + "\">";
309 mText += "</a>\n"; 311 mText += "</a>\n";
310 } 312 }
311 } 313 }
312 if (a->status() != Attendee::NeedsAction ) 314 if (a->status() != Attendee::NeedsAction )
313 mText +="[" + a->statusStr() + "] "; 315 mText +="[" + a->statusStr() + "] ";
314 if (a->role() == Attendee::Chair ) 316 if (a->role() == Attendee::Chair )
315 mText +="(" + a->roleStr().left(1) + ".)"; 317 mText +="(" + a->roleStr().left(1) + ".)";
316 } 318 }
317 mText.append("</li></ul>"); 319 mText.append("</li></ul>");
318 } 320 }
319} 321}
320 322
321void KIncidenceFormatter::formatReadOnly(Incidence *event) 323void KIncidenceFormatter::formatReadOnly(Incidence *event)
322{ 324{
323 if (event->isReadOnly()) { 325 if (event->isReadOnly()) {
324 addTag("p","<em>(" + i18n("read-only") + ")</em>"); 326 addTag("p","<em>(" + i18n("read-only") + ")</em>");
325 } 327 }
326} 328}