summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-02-04 10:23:55 (UTC)
committer zautrix <zautrix>2005-02-04 10:23:55 (UTC)
commit83256090c493dab56f1afba4829e864598bf70d2 (patch) (unidiff)
tree8d5b7ee0c6fe42f0f14c53b80c924ccddd5a1599 /korganizer
parenta96872e5ecff3a8fb1785aff71f5f7f150ef8604 (diff)
downloadkdepimpi-83256090c493dab56f1afba4829e864598bf70d2.zip
kdepimpi-83256090c493dab56f1afba4829e864598bf70d2.tar.gz
kdepimpi-83256090c493dab56f1afba4829e864598bf70d2.tar.bz2
mail send
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koeventviewer.cpp56
-rw-r--r--korganizer/koeventviewer.h3
2 files changed, 56 insertions, 3 deletions
diff --git a/korganizer/koeventviewer.cpp b/korganizer/koeventviewer.cpp
index 7dc1880..bf41edb 100644
--- a/korganizer/koeventviewer.cpp
+++ b/korganizer/koeventviewer.cpp
@@ -33,241 +33,268 @@
33#include <krun.h> 33#include <krun.h>
34#include <kglobal.h> 34#include <kglobal.h>
35#include <kprocess.h> 35#include <kprocess.h>
36#include "koprefs.h" 36#include "koprefs.h"
37 37
38#include <kabc/stdaddressbook.h> 38#include <kabc/stdaddressbook.h>
39 39
40#ifndef KORG_NODCOP 40#ifndef KORG_NODCOP
41#include <dcopclient.h> 41#include <dcopclient.h>
42#include "korganizer.h" 42#include "korganizer.h"
43#include "koprefs.h" 43#include "koprefs.h"
44#include "actionmanager.h" 44#include "actionmanager.h"
45#endif 45#endif
46 46
47#include "koeventviewer.h" 47#include "koeventviewer.h"
48//#ifndef KORG_NOKABC 48//#ifndef KORG_NOKABC
49//#include <kabc/stdaddressbook.h> 49//#include <kabc/stdaddressbook.h>
50//#define size count 50//#define size count
51//#endif 51//#endif
52 52
53#ifdef DESKTOP_VERSION 53#ifdef DESKTOP_VERSION
54#include <kabc/addresseedialog.h> 54#include <kabc/addresseedialog.h>
55#include <kabc/addresseeview.h> 55#include <kabc/addresseeview.h>
56#else //DESKTOP_VERSION 56#else //DESKTOP_VERSION
57#include <externalapphandler.h> 57#include <externalapphandler.h>
58#include <qtopia/qcopenvelope_qws.h> 58#include <qtopia/qcopenvelope_qws.h>
59#endif //DESKTOP_VERSION 59#endif //DESKTOP_VERSION
60 60
61KOEventViewer::KOEventViewer(QWidget *parent,const char *name) 61KOEventViewer::KOEventViewer(QWidget *parent,const char *name)
62 : QTextBrowser(parent,name) 62 : QTextBrowser(parent,name)
63{ 63{
64 mSyncMode = false; 64 mSyncMode = false;
65 mColorMode = 0; 65 mColorMode = 0;
66} 66}
67 67
68KOEventViewer::~KOEventViewer() 68KOEventViewer::~KOEventViewer()
69{ 69{
70} 70}
71 71
72void KOEventViewer::setSource(const QString& n) 72void KOEventViewer::setSource(const QString& n)
73{ 73{
74 74
75 if ( n.left(3) == "uid" ) 75 if ( n.left(3) == "uid" )
76#ifdef DESKTOP_VERSION 76#ifdef DESKTOP_VERSION
77 { 77 {
78 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 78 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
79 KABC::AddressBook::Iterator it; 79 KABC::AddressBook::Iterator it;
80 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 80 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
81 // LR I do not understand, why the uid string is different on zaurus and desktop 81 // LR I do not understand, why the uid string is different on zaurus and desktop
82 QString uid = "uid://"+(*it).uid(); 82 QString uid = "uid://"+(*it).uid();
83 83
84 //qDebug("for *%s* +%s+ ", n.latin1(), uid.latin1()); 84 //qDebug("for *%s* +%s+ ", n.latin1(), uid.latin1());
85 if (n == uid ) { 85 if (n == uid ) {
86 //qDebug("found %s ",(*it).mobileHomePhone().latin1() ); 86 //qDebug("found %s ",(*it).mobileHomePhone().latin1() );
87 QDialog dia( this,"dia123", true ); 87 QDialog dia( this,"dia123", true );
88 dia.setCaption( i18n("Details of attendee") ); 88 dia.setCaption( i18n("Details of attendee") );
89 QVBoxLayout lay ( &dia ); 89 QVBoxLayout lay ( &dia );
90 KABC::AddresseeView av ( &dia ); 90 KABC::AddresseeView av ( &dia );
91 av.setAddressee( (*it) ); 91 av.setAddressee( (*it) );
92 lay.addWidget( &av ); 92 lay.addWidget( &av );
93 if ( QApplication::desktop()->width() < 480 ) 93 if ( QApplication::desktop()->width() < 480 )
94 dia.resize( 220, 240); 94 dia.resize( 220, 240);
95 else { 95 else {
96 dia.resize( 400,400); 96 dia.resize( 400,400);
97 } 97 }
98 dia.exec(); 98 dia.exec();
99 break; 99 break;
100 } 100 }
101 } 101 }
102 return; 102 return;
103 } 103 }
104#else 104#else
105 { 105 {
106 if ( "uid:organizer" == n ) { 106 if ( "uid:organizer" == n ) {
107 ExternalAppHandler::instance()->requestDetailsFromKAPI("", mCurrentIncidence->organizer(),""); 107 ExternalAppHandler::instance()->requestDetailsFromKAPI("", mCurrentIncidence->organizer(),"");
108 return; 108 return;
109 } 109 }
110 QPtrList<Attendee> attendees = mCurrentIncidence->attendees(); 110 QPtrList<Attendee> attendees = mCurrentIncidence->attendees();
111 if (attendees.count()) { 111 if (attendees.count()) {
112 Attendee *a; 112 Attendee *a;
113 for(a=attendees.first();a;a=attendees.next()) { 113 for(a=attendees.first();a;a=attendees.next()) {
114 if ( "uid:"+a->uid() == n ) { 114 if ( "uid:"+a->uid() == n ) {
115 bool res = ExternalAppHandler::instance()->requestDetailsFromKAPI(a->name(), a->email(), a->uid()); 115 bool res = ExternalAppHandler::instance()->requestDetailsFromKAPI(a->name(), a->email(), a->uid());
116 return; 116 return;
117 } 117 }
118 } 118 }
119 } 119 }
120 return; 120 return;
121 } 121 }
122 //requestNameEmailUidListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); 122 //requestNameEmailUidListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/);
123 // the result should now arrive through method insertAttendees 123 // the result should now arrive through method insertAttendees
124 //QString uid = "uid:"+(*it).uid(); 124 //QString uid = "uid:"+(*it).uid();
125#endif 125#endif
126 if ( n.left(6) == "mailto" ) { 126 if ( n.left(6) == "mailto" ) {
127 // qDebug("KOEventViewer::setSource %s ", n.mid(7).latin1()); 127 // qDebug("KOEventViewer::setSource %s ", n.mid(7).latin1());
128#ifndef DESKTOP_VERSION 128#ifndef DESKTOP_VERSION
129 if ( n.mid(7,3) == "ALL" ) {
130 qDebug("all ");
131 mailToAttendees( true );
132 } else if ( n.mid(7,4) == "RSVP" ) {
133 mailToAttendees( false );
134 qDebug("rsvp ");
135 } else {
129 QCopEnvelope e("QPE/Application/ompi", "newMail(QString)" ); 136 QCopEnvelope e("QPE/Application/ompi", "newMail(QString)" );
130 e << n.mid(7); 137 e << n.mid(7);
138 }
131#endif 139#endif
132 140
133 } 141 }
134 142
135 143
136#ifndef KORG_NODCOP 144#ifndef KORG_NODCOP
137 kdDebug() << "KOEventViewer::setSource(): " << n << endl; 145 kdDebug() << "KOEventViewer::setSource(): " << n << endl;
138 QString tmpStr; 146 QString tmpStr;
139 if (n.startsWith("mailto:")) { 147 if (n.startsWith("mailto:")) {
140 KApplication::kApplication()->invokeMailer(n.mid(7),QString::null); 148 KApplication::kApplication()->invokeMailer(n.mid(7),QString::null);
141 //emit showIncidence(n); 149 //emit showIncidence(n);
142 return; 150 return;
143 } else if (n.startsWith("uid:")) { 151 } else if (n.startsWith("uid:")) {
144 DCOPClient *client = KApplication::kApplication()->dcopClient(); 152 DCOPClient *client = KApplication::kApplication()->dcopClient();
145 const QByteArray noParamData; 153 const QByteArray noParamData;
146 const QByteArray paramData; 154 const QByteArray paramData;
147 QByteArray replyData; 155 QByteArray replyData;
148 QCString replyTypeStr; 156 QCString replyTypeStr;
149#define PING_ABBROWSER (client->call("kaddressbook", "KAddressBookIface", "interfaces()", noParamData, replyTypeStr, replyData)) 157#define PING_ABBROWSER (client->call("kaddressbook", "KAddressBookIface", "interfaces()", noParamData, replyTypeStr, replyData))
150 bool foundAbbrowser = PING_ABBROWSER; 158 bool foundAbbrowser = PING_ABBROWSER;
151 159
152 if (foundAbbrowser) { 160 if (foundAbbrowser) {
153 //KAddressbook is already running, so just DCOP to it to bring up the contact editor 161 //KAddressbook is already running, so just DCOP to it to bring up the contact editor
154 //client->send("kaddressbook","KAddressBookIface", 162 //client->send("kaddressbook","KAddressBookIface",
155 QDataStream arg(paramData, IO_WriteOnly); 163 QDataStream arg(paramData, IO_WriteOnly);
156 arg << n.mid(6); 164 arg << n.mid(6);
157 client->send("kaddressbook", "KAddressBookIface", "showContactEditor( QString )", paramData); 165 client->send("kaddressbook", "KAddressBookIface", "showContactEditor( QString )", paramData);
158 return; 166 return;
159 } else { 167 } else {
160 /* 168 /*
161 KaddressBook is not already running. Pass it the UID of the contact via the command line while starting it - its neater. 169 KaddressBook is not already running. Pass it the UID of the contact via the command line while starting it - its neater.
162 We start it without its main interface 170 We start it without its main interface
163 */ 171 */
164 KIconLoader* iconLoader = new KIconLoader(); 172 KIconLoader* iconLoader = new KIconLoader();
165 QString iconPath = iconLoader->iconPath("go",KIcon::Small); 173 QString iconPath = iconLoader->iconPath("go",KIcon::Small);
166 ActionManager::setStartedKAddressBook(true); 174 ActionManager::setStartedKAddressBook(true);
167 tmpStr = "kaddressbook --editor-only --uid "; 175 tmpStr = "kaddressbook --editor-only --uid ";
168 tmpStr += KProcess::quote(n.mid(6)); 176 tmpStr += KProcess::quote(n.mid(6));
169 KRun::runCommand(tmpStr,"KAddressBook",iconPath); 177 KRun::runCommand(tmpStr,"KAddressBook",iconPath);
170 return; 178 return;
171 } 179 }
172 } else { 180 } else {
173 //QTextBrowser::setSource(n); 181 //QTextBrowser::setSource(n);
174 } 182 }
175#endif 183#endif
176} 184}
185void KOEventViewer::mailToAttendees( bool all )
186{
187 QPtrList<Attendee> attendees = mCurrentIncidence->attendees();
188 if (attendees.count() == 0) return;
189 QStringList nameList;
190 QStringList emailList;
191 QStringList uidList;
192 Attendee* a;
193 for(a=attendees.first();a;a=attendees.next()) {
194 if ( !all && !a->RSVP() ) continue;
195 if (!a->email().isEmpty()) {
196 nameList.append (a->name() );
197 emailList.append (a->email() );
198 uidList.append (a->uid() );
199 }
200 }
201 QString uid = "ComposeMailUIpick2"+mMailSubject;
202 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList);
177 203
204}
178void KOEventViewer::addTag(const QString & tag,const QString & text) 205void KOEventViewer::addTag(const QString & tag,const QString & text)
179{ 206{
180 int number=text.contains("\n"); 207 int number=text.contains("\n");
181 QString str = "<" + tag + ">"; 208 QString str = "<" + tag + ">";
182 QString tmpText=text; 209 QString tmpText=text;
183 QString tmpStr=str; 210 QString tmpStr=str;
184 if(number !=-1) 211 if(number !=-1)
185 { 212 {
186 if (number > 0) { 213 if (number > 0) {
187 int pos=0; 214 int pos=0;
188 QString tmp; 215 QString tmp;
189 for(int i=0;i<=number;i++) { 216 for(int i=0;i<=number;i++) {
190 pos=tmpText.find("\n"); 217 pos=tmpText.find("\n");
191 tmp=tmpText.left(pos); 218 tmp=tmpText.left(pos);
192 tmpText=tmpText.right(tmpText.length()-pos-1); 219 tmpText=tmpText.right(tmpText.length()-pos-1);
193 tmpStr+=tmp+"<br>"; 220 tmpStr+=tmp+"<br>";
194 } 221 }
195 } 222 }
196 else tmpStr += tmpText; 223 else tmpStr += tmpText;
197 tmpStr+="</" + tag + ">"; 224 tmpStr+="</" + tag + ">";
198 mText.append(tmpStr); 225 mText.append(tmpStr);
199 } 226 }
200 else 227 else
201 { 228 {
202 str += text + "</" + tag + ">"; 229 str += text + "</" + tag + ">";
203 mText.append(str); 230 mText.append(str);
204 } 231 }
205} 232}
206 233
207void KOEventViewer::setColorMode( int m ) 234void KOEventViewer::setColorMode( int m )
208{ 235{
209 mColorMode = m; 236 mColorMode = m;
210} 237}
211void KOEventViewer::appendEvent(Event *event, int mode ) 238void KOEventViewer::appendEvent(Event *event, int mode )
212{ 239{
213 mMailSubject = ""; 240 mMailSubject = "";
214 mCurrentIncidence = event; 241 mCurrentIncidence = event;
215 bool shortDate = KOPrefs::instance()->mShortDateInViewer; 242 bool shortDate = KOPrefs::instance()->mShortDateInViewer;
216 topLevelWidget()->setCaption(i18n("Event Viewer")); 243 topLevelWidget()->setCaption(i18n("Event Viewer"));
217 if ( mode == 0 ) { 244 if ( mode == 0 ) {
218 addTag("h2",event->summary()); 245 addTag("h2",event->summary());
219 } 246 }
220 else { 247 else {
221 if ( mColorMode == 1 ) { 248 if ( mColorMode == 1 ) {
222 mText +="<font color=\"#00A000\">"; 249 mText +="<font color=\"#00A000\">";
223 } 250 }
224 if ( mColorMode == 2 ) { 251 if ( mColorMode == 2 ) {
225 mText +="<font color=\"#C00000\">"; 252 mText +="<font color=\"#C00000\">";
226 } 253 }
227 // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; 254 // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>";
228 if ( mode == 1 ) { 255 if ( mode == 1 ) {
229 addTag("h2",i18n( "Local: " ) +event->summary()); 256 addTag("h2",i18n( "Local: " ) +event->summary());
230 } else { 257 } else {
231 addTag("h2",i18n( "Remote: " ) +event->summary()); 258 addTag("h2",i18n( "Remote: " ) +event->summary());
232 } 259 }
233 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); 260 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) );
234 if ( mColorMode ) 261 if ( mColorMode )
235 mText += "</font>"; 262 mText += "</font>";
236 } 263 }
237 mMailSubject += i18n( "Meeting " )+ event->summary(); 264 mMailSubject += i18n( "Meeting " )+ event->summary();
238 if (event->cancelled ()) { 265 if (event->cancelled ()) {
239 mText +="<font color=\"#B00000\">"; 266 mText +="<font color=\"#B00000\">";
240 addTag("i",i18n("This event has been cancelled!")); 267 addTag("i",i18n("This event has been cancelled!"));
241 mText.append("<br>"); 268 mText.append("<br>");
242 mText += "</font>"; 269 mText += "</font>";
243 mMailSubject += i18n("(cancelled)"); 270 mMailSubject += i18n("(cancelled)");
244 } 271 }
245 if (!event->location().isEmpty()) { 272 if (!event->location().isEmpty()) {
246 addTag("b",i18n("Location: ")); 273 addTag("b",i18n("Location: "));
247 mText.append(event->location()+"<br>"); 274 mText.append(event->location()+"<br>");
248 mMailSubject += i18n(" at ") + event->location(); 275 mMailSubject += i18n(" at ") + event->location();
249 } 276 }
250 if (event->doesFloat()) { 277 if (event->doesFloat()) {
251 if (event->isMultiDay()) { 278 if (event->isMultiDay()) {
252 mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>") 279 mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>")
253 .arg(event->dtStartDateStr(shortDate)) 280 .arg(event->dtStartDateStr(shortDate))
254 .arg(event->dtEndDateStr(shortDate))); 281 .arg(event->dtEndDateStr(shortDate)));
255 } else { 282 } else {
256 mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate ))); 283 mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate )));
257 } 284 }
258 } else { 285 } else {
259 if (event->isMultiDay()) { 286 if (event->isMultiDay()) {
260 mText.append(i18n("<p><b>From:</b> %1</p> ") 287 mText.append(i18n("<p><b>From:</b> %1</p> ")
261 .arg(event->dtStartStr( shortDate))); 288 .arg(event->dtStartStr( shortDate)));
262 mText.append(i18n("<p><b>To:</b> %1</p>") 289 mText.append(i18n("<p><b>To:</b> %1</p>")
263 .arg(event->dtEndStr(shortDate))); 290 .arg(event->dtEndStr(shortDate)));
264 } else { 291 } else {
265 mText.append(i18n("<p><b>On:</b> %1</p> ") 292 mText.append(i18n("<p><b>On:</b> %1</p> ")
266 .arg(event->dtStartDateStr( shortDate ))); 293 .arg(event->dtStartDateStr( shortDate )));
267 mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>") 294 mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>")
268 .arg(event->dtStartTimeStr()) 295 .arg(event->dtStartTimeStr())
269 .arg(event->dtEndTimeStr())); 296 .arg(event->dtEndTimeStr()));
270 } 297 }
271 } 298 }
272 299
273 if (event->recurrence()->doesRecur()) { 300 if (event->recurrence()->doesRecur()) {
@@ -369,238 +396,263 @@ void KOEventViewer::appendTodo(Todo *event, int mode )
369 addTag("b",i18n("Location: ")); 396 addTag("b",i18n("Location: "));
370 mText.append(event->location()+"<br>"); 397 mText.append(event->location()+"<br>");
371 mMailSubject += i18n(" at ") + event->location(); 398 mMailSubject += i18n(" at ") + event->location();
372 } 399 }
373 if (event->hasStartDate()) { 400 if (event->hasStartDate()) {
374 mText.append(i18n("<p><b>Start on:</b> %1</p>").arg(event->dtStartStr(KOPrefs::instance()->mShortDateInViewer))); 401 mText.append(i18n("<p><b>Start on:</b> %1</p>").arg(event->dtStartStr(KOPrefs::instance()->mShortDateInViewer)));
375 } 402 }
376 if (event->hasDueDate()) { 403 if (event->hasDueDate()) {
377 mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(KOPrefs::instance()->mShortDateInViewer))); 404 mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(KOPrefs::instance()->mShortDateInViewer)));
378 mMailSubject += i18n(" - " )+event->dtDueStr( true ); 405 mMailSubject += i18n(" - " )+event->dtDueStr( true );
379 } 406 }
380 addTag("b",i18n("Access: ")); 407 addTag("b",i18n("Access: "));
381 mText.append(event->secrecyStr()+"<br>"); 408 mText.append(event->secrecyStr()+"<br>");
382 if (!event->description().isEmpty()) { 409 if (!event->description().isEmpty()) {
383 addTag("p",i18n("<b>Details: </b>")); 410 addTag("p",i18n("<b>Details: </b>"));
384 addTag("p",event->description()); 411 addTag("p",event->description());
385 } 412 }
386 413
387 formatCategories(event); 414 formatCategories(event);
388 415
389 mText.append(i18n("<p><b>Priority:</b> %2</p>") 416 mText.append(i18n("<p><b>Priority:</b> %2</p>")
390 .arg(QString::number(event->priority()))); 417 .arg(QString::number(event->priority())));
391 418
392 formatReadOnly(event); 419 formatReadOnly(event);
393 formatAttendees(event); 420 formatAttendees(event);
394 if ( event->relatedTo() ) { 421 if ( event->relatedTo() ) {
395 addTag("b",i18n("Parent todo: ")); 422 addTag("b",i18n("Parent todo: "));
396 mText.append(event->relatedTo()->summary()+" [" +QString::number(event->relatedTo()->priority()) + "/" + QString::number(((Todo*)event->relatedTo())->percentComplete())+"%] <br>"); 423 mText.append(event->relatedTo()->summary()+" [" +QString::number(event->relatedTo()->priority()) + "/" + QString::number(((Todo*)event->relatedTo())->percentComplete())+"%] <br>");
397 } 424 }
398 QPtrList<Incidence> Relations = event->relations(); 425 QPtrList<Incidence> Relations = event->relations();
399 Incidence *to; 426 Incidence *to;
400 if ( Relations.first() ) 427 if ( Relations.first() )
401 addTag("b",i18n("Sub todos:<br>")); 428 addTag("b",i18n("Sub todos:<br>"));
402 for (to=Relations.first();to;to=Relations.next()) { 429 for (to=Relations.first();to;to=Relations.next()) {
403 mText.append( to->summary()+" [" +QString::number(to->priority()) + "/" + QString::number(((Todo*)to)->percentComplete())+"%]<br>"); 430 mText.append( to->summary()+" [" +QString::number(to->priority()) + "/" + QString::number(((Todo*)to)->percentComplete())+"%]<br>");
404 431
405 } 432 }
406 setText(mText); 433 setText(mText);
407} 434}
408 435
409void KOEventViewer::formatCategories(Incidence *event) 436void KOEventViewer::formatCategories(Incidence *event)
410{ 437{
411 if (!event->categoriesStr().isEmpty()) { 438 if (!event->categoriesStr().isEmpty()) {
412 if (event->categories().count() == 1) { 439 if (event->categories().count() == 1) {
413 addTag("h3",i18n("Category")); 440 addTag("h3",i18n("Category"));
414 } else { 441 } else {
415 addTag("h3",i18n("Categories")); 442 addTag("h3",i18n("Categories"));
416 } 443 }
417 addTag("p",event->categoriesStr()); 444 addTag("p",event->categoriesStr());
418 } 445 }
419} 446}
420void KOEventViewer::formatAttendees(Incidence *event) 447void KOEventViewer::formatAttendees(Incidence *event)
421{ 448{
422 QPtrList<Attendee> attendees = event->attendees(); 449 QPtrList<Attendee> attendees = event->attendees();
423 if (attendees.count()) { 450 if (attendees.count()) {
424 451
425 452
426 QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); 453 QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small);
427 QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small); 454 QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small);
428 addTag("h3",i18n("Organizer")); 455 addTag("h3",i18n("Organizer"));
429 mText.append("<ul><li>"); 456 mText.append("<ul><li>");
430#ifndef KORG_NOKABC 457#ifndef KORG_NOKABC
431 458
432#ifdef DESKTOP_VERSION 459#ifdef DESKTOP_VERSION
433 KABC::AddressBook *add_book = KABC::StdAddressBook::self(); 460 KABC::AddressBook *add_book = KABC::StdAddressBook::self();
434 KABC::Addressee::List addressList; 461 KABC::Addressee::List addressList;
435 addressList = add_book->findByEmail(event->organizer()); 462 addressList = add_book->findByEmail(event->organizer());
436 KABC::Addressee o = addressList.first(); 463 KABC::Addressee o = addressList.first();
437 if (!o.isEmpty() && addressList.size()<2) { 464 if (!o.isEmpty() && addressList.size()<2) {
438 mText += "<a href=\"uid:" + o.uid() + "\">"; 465 mText += "<a href=\"uid:" + o.uid() + "\">";
439 mText += o.formattedName(); 466 mText += o.formattedName();
440 mText += "</a>\n"; 467 mText += "</a>\n";
441 } else { 468 } else {
442 mText.append(event->organizer()); 469 mText.append(event->organizer());
443 } 470 }
444#else //DESKTOP_VERSION 471#else //DESKTOP_VERSION
445 mText += "<a href=\"uid:organizer\">"; 472 mText += "<a href=\"uid:organizer\">";
446 mText += event->organizer(); 473 mText += event->organizer();
447 mText += "</a>\n"; 474 mText += "</a>\n";
448#endif //DESKTOP_VERSION 475#endif //DESKTOP_VERSION
449 476
450 477
451#else 478#else
452 mText.append(event->organizer()); 479 mText.append(event->organizer());
453#endif 480#endif
454 481
455 if (iconPath) { 482 if (iconPath) {
456 mText += " <a href=\"mailto:" + event->organizer() + "\">"; 483 mText += " <a href=\"mailto:" + event->organizer() + "\">";
457 mText += "<IMG src=\"" + iconPath + "\">"; 484 mText += "<IMG src=\"" + iconPath + "\">";
458 mText += "</a>\n"; 485 mText += "</a>\n";
459 } 486 }
460 mText.append("</li></ul>"); 487 mText.append("</li></ul>");
461 488
462 addTag("h3",i18n("Attendees")); 489 addTag("h3",i18n("Attendees"));
463 Attendee *a; 490 Attendee *a;
464 mText.append("<ul>"); 491 mText.append("<ul>");
492 int a_count = 0;
493 int a_count_nr = 0;
494
465 for(a=attendees.first();a;a=attendees.next()) { 495 for(a=attendees.first();a;a=attendees.next()) {
466#ifndef KORG_NOKABC 496#ifndef KORG_NOKABC
467#ifdef DESKTOP_VERSION 497#ifdef DESKTOP_VERSION
468 if (a->name().isEmpty()) { 498 if (a->name().isEmpty()) {
469 addressList = add_book->findByEmail(a->email()); 499 addressList = add_book->findByEmail(a->email());
470 KABC::Addressee o = addressList.first(); 500 KABC::Addressee o = addressList.first();
471 if (!o.isEmpty() && addressList.size()<2) { 501 if (!o.isEmpty() && addressList.size()<2) {
472 mText += "<a href=\"uid:" + o.uid() + "\">"; 502 mText += "<a href=\"uid:" + o.uid() + "\">";
473 mText += o.formattedName(); 503 mText += o.formattedName();
474 mText += "</a>\n"; 504 mText += "</a>\n";
475 } else { 505 } else {
476 mText += "<li>"; 506 mText += "<li>";
477 mText.append(a->email()); 507 mText.append(a->email());
478 mText += "\n"; 508 mText += "\n";
479 } 509 }
480 } else { 510 } else {
481 mText += "<li><a href=\"uid:" + a->uid() + "\">"; 511 mText += "<li><a href=\"uid:" + a->uid() + "\">";
482 if (!a->name().isEmpty()) mText += a->name(); 512 if (!a->name().isEmpty()) mText += a->name();
483 else mText += a->email(); 513 else mText += a->email();
484 mText += "</a>\n"; 514 mText += "</a>\n";
485 } 515 }
486#else //DESKTOP_VERSION 516#else //DESKTOP_VERSION
487 mText += "<li><a href=\"uid:" + a->uid() + "\">"; 517 mText += "<li><a href=\"uid:" + a->uid() + "\">";
488 if (!a->name().isEmpty()) mText += a->name(); 518 if (!a->name().isEmpty()) mText += a->name();
489 else mText += a->email(); 519 else mText += a->email();
490 mText += "</a>\n"; 520 mText += "</a>\n";
491#endif //DESKTOP_VERSION 521#endif //DESKTOP_VERSION
492#else 522#else
493 //qDebug("nokabc "); 523 //qDebug("nokabc ");
494 mText += "<li><a href=\"uid:" + a->uid() + "\">"; 524 mText += "<li><a href=\"uid:" + a->uid() + "\">";
495 if (!a->name().isEmpty()) mText += a->name(); 525 if (!a->name().isEmpty()) mText += a->name();
496 else mText += a->email(); 526 else mText += a->email();
497 mText += "</a>\n"; 527 mText += "</a>\n";
498#endif 528#endif
499 529
500 530
501 if (!a->email().isEmpty()) { 531 if (!a->email().isEmpty()) {
502 if (iconPath) { 532 if (iconPath) {
503 mText += "<a href=\"mailto:" + a->name() +" <" + a->email() + ">:" + mMailSubject + "\">"; 533 mText += "<a href=\"mailto:" + a->name() +" <" + a->email() + ">:" + mMailSubject + "\">";
504 if ( a->RSVP() ) 534 if ( a->RSVP() ) {
535 ++a_count;
505 mText += "<IMG src=\"" + iconPath + "\">"; 536 mText += "<IMG src=\"" + iconPath + "\">";
506 else 537 }
538 else {
539 ++a_count_nr;
507 mText += "<IMG src=\"" + NOiconPath + "\">"; 540 mText += "<IMG src=\"" + NOiconPath + "\">";
541 }
508 mText += "</a>\n"; 542 mText += "</a>\n";
509 } 543 }
510 } 544 }
511 if (a->status() != Attendee::NeedsAction ) 545 if (a->status() != Attendee::NeedsAction )
512 mText +="[" + a->statusStr() + "] "; 546 mText +="[" + a->statusStr() + "] ";
513 if (a->role() == Attendee::Chair ) 547 if (a->role() == Attendee::Chair )
514 mText +="(" + a->roleStr().left(1) + ".)"; 548 mText +="(" + a->roleStr().left(1) + ".)";
515 } 549 }
516 mText.append("</li></ul>"); 550 mText.append("</li></ul>");
551 if ( a_count > 1 ) {
552 mText += "<a href=\"mailto:ALL\">";
553 mText += i18n( "Mail to all" );
554 mText += "</a> ( ";
555 mText += "<IMG src=\"" + iconPath + "\">";
556 mText += i18n( " and " );
557 mText += "<IMG src=\"" + NOiconPath + "\"> )";
558 mText += "<br>\n";
559
560
561 }
562 if ( a_count_nr > 1 ) {
563 mText += "<a href=\"mailto:RSVP\">";
564 mText += i18n( "Mail to selected" );
565 mText += "</a> ( ";
566 mText += i18n( "<IMG src=\"%1\"> only )").arg ( iconPath );
567 mText += "\n";
568 }
517 } 569 }
518 570
519} 571}
520void KOEventViewer::appendJournal(Journal *jour, int mode ) 572void KOEventViewer::appendJournal(Journal *jour, int mode )
521{ 573{
522 bool shortDate = KOPrefs::instance()->mShortDateInViewer; 574 bool shortDate = KOPrefs::instance()->mShortDateInViewer;
523 if (mode == 0 ) { 575 if (mode == 0 ) {
524 addTag("h2",i18n("Journal from: ")); 576 addTag("h2",i18n("Journal from: "));
525 } 577 }
526 else { 578 else {
527 if ( mode == 1 ) { 579 if ( mode == 1 ) {
528 addTag("h2",i18n( "Local: " ) +i18n("Journal from: ")); 580 addTag("h2",i18n( "Local: " ) +i18n("Journal from: "));
529 } else { 581 } else {
530 addTag("h2",i18n( "Remote: " ) +i18n("Journal from: ")); 582 addTag("h2",i18n( "Remote: " ) +i18n("Journal from: "));
531 } 583 }
532 } 584 }
533 topLevelWidget()->setCaption("Journal Viewer"); 585 topLevelWidget()->setCaption("Journal Viewer");
534 mText.append(i18n("<h3> %1 </h3> ").arg(jour->dtStartDateStr(KOPrefs::instance()->mShortDateInViewer))); 586 mText.append(i18n("<h3> %1 </h3> ").arg(jour->dtStartDateStr(KOPrefs::instance()->mShortDateInViewer)));
535 addTag("b",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(jour->lastModified(),shortDate ) ); 587 addTag("b",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(jour->lastModified(),shortDate ) );
536 if (!jour->description().isEmpty()) { 588 if (!jour->description().isEmpty()) {
537 addTag("p",jour->description()); 589 addTag("p",jour->description());
538 } 590 }
539 setText(mText); 591 setText(mText);
540} 592}
541 593
542void KOEventViewer::formatReadOnly(Incidence *event) 594void KOEventViewer::formatReadOnly(Incidence *event)
543{ 595{
544 if (event->isReadOnly()) { 596 if (event->isReadOnly()) {
545 addTag("p","<em>(" + i18n("read-only") + ")</em>"); 597 addTag("p","<em>(" + i18n("read-only") + ")</em>");
546 } 598 }
547} 599}
548void KOEventViewer::setSyncMode( bool b ) 600void KOEventViewer::setSyncMode( bool b )
549{ 601{
550 mSyncMode = b; 602 mSyncMode = b;
551} 603}
552 604
553 605
554void KOEventViewer::setTodo(Todo *event, bool clearV ) 606void KOEventViewer::setTodo(Todo *event, bool clearV )
555{ 607{
556 if ( clearV ) 608 if ( clearV )
557 clearEvents(); 609 clearEvents();
558 if ( mSyncMode ) { 610 if ( mSyncMode ) {
559 if ( clearV ) 611 if ( clearV )
560 appendTodo(event,1 ); 612 appendTodo(event,1 );
561 else 613 else
562 appendTodo(event,2); 614 appendTodo(event,2);
563 } else 615 } else
564 appendTodo(event); 616 appendTodo(event);
565} 617}
566void KOEventViewer::setJournal(Journal *event, bool clearV ) 618void KOEventViewer::setJournal(Journal *event, bool clearV )
567{ 619{
568 if ( clearV ) 620 if ( clearV )
569 clearEvents(); 621 clearEvents();
570 if ( mSyncMode ) { 622 if ( mSyncMode ) {
571 if ( clearV ) 623 if ( clearV )
572 appendJournal(event, 1); 624 appendJournal(event, 1);
573 else 625 else
574 appendJournal(event, 2); 626 appendJournal(event, 2);
575 } else 627 } else
576 appendJournal(event); 628 appendJournal(event);
577} 629}
578 630
579void KOEventViewer::setEvent(Event *event) 631void KOEventViewer::setEvent(Event *event)
580{ 632{
581 clearEvents(); 633 clearEvents();
582 if ( mSyncMode ) 634 if ( mSyncMode )
583 appendEvent(event, 1); 635 appendEvent(event, 1);
584 else 636 else
585 appendEvent(event); 637 appendEvent(event);
586} 638}
587 639
588void KOEventViewer::addEvent(Event *event) 640void KOEventViewer::addEvent(Event *event)
589{ 641{
590 if ( mSyncMode ) 642 if ( mSyncMode )
591 appendEvent(event, 2); 643 appendEvent(event, 2);
592 else 644 else
593 appendEvent(event); 645 appendEvent(event);
594} 646}
595 647
596void KOEventViewer::clearEvents(bool now) 648void KOEventViewer::clearEvents(bool now)
597{ 649{
598 mText = ""; 650 mText = "";
599 if (now) setText(mText); 651 if (now) setText(mText);
600} 652}
601 653
602void KOEventViewer::addText(QString text) 654void KOEventViewer::addText(QString text)
603{ 655{
604 mText.append(text); 656 mText.append(text);
605 setText(mText); 657 setText(mText);
606} 658}
diff --git a/korganizer/koeventviewer.h b/korganizer/koeventviewer.h
index 0cd3f33..cf44284 100644
--- a/korganizer/koeventviewer.h
+++ b/korganizer/koeventviewer.h
@@ -1,74 +1,75 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*/ 18*/
19#ifndef KOEVENTVIEWER_H 19#ifndef KOEVENTVIEWER_H
20#define KOEVENTVIEWER_H 20#define KOEVENTVIEWER_H
21// 21//
22// Viewer widget for events. 22// Viewer widget for events.
23// 23//
24 24
25#include <qtextbrowser.h> 25#include <qtextbrowser.h>
26 26
27#include <libkcal/event.h> 27#include <libkcal/event.h>
28#include <libkcal/journal.h> 28#include <libkcal/journal.h>
29 29
30 30
31using namespace KCal; 31using namespace KCal;
32 32
33class KOEventViewer : public QTextBrowser { 33class KOEventViewer : public QTextBrowser {
34 Q_OBJECT 34 Q_OBJECT
35 public: 35 public:
36 KOEventViewer(QWidget *parent=0,const char *name=0); 36 KOEventViewer(QWidget *parent=0,const char *name=0);
37 virtual ~KOEventViewer(); 37 virtual ~KOEventViewer();
38 38
39 void setSource(const QString &); 39 void setSource(const QString &);
40 void setEvent(Event *event); 40 void setEvent(Event *event);
41 void addEvent(Event *event); 41 void addEvent(Event *event);
42 void setTodo(Todo *event, bool clearV = true ); 42 void setTodo(Todo *event, bool clearV = true );
43 void setJournal(Journal *jour, bool clearV = true ); 43 void setJournal(Journal *jour, bool clearV = true );
44 44
45 void appendEvent(Event *event, int mode = 0 ); 45 void appendEvent(Event *event, int mode = 0 );
46 void appendTodo(Todo *event, int mode = 0 ); 46 void appendTodo(Todo *event, int mode = 0 );
47 void appendJournal(Journal *jour, int mode = 0 ); 47 void appendJournal(Journal *jour, int mode = 0 );
48 48
49 void clearEvents(bool now=false); 49 void clearEvents(bool now=false);
50 50
51 void addText(QString text); 51 void addText(QString text);
52 void setSyncMode( bool ); 52 void setSyncMode( bool );
53 void setColorMode( int ); 53 void setColorMode( int );
54 void mailToAttendees( bool all );
54 55
55 protected: 56 protected:
56 int mColorMode; 57 int mColorMode;
57 void addTag(const QString & tag,const QString & text); 58 void addTag(const QString & tag,const QString & text);
58 59
59 void formatCategories(Incidence *event); 60 void formatCategories(Incidence *event);
60 void formatAttendees(Incidence *event); 61 void formatAttendees(Incidence *event);
61 void formatReadOnly(Incidence *event); 62 void formatReadOnly(Incidence *event);
62 63
63 private: 64 private:
64 QTextBrowser *mEventTextView; 65 QTextBrowser *mEventTextView;
65 bool mSyncMode; 66 bool mSyncMode;
66 67
67 QString mText; 68 QString mText;
68 QString mMailSubject; 69 QString mMailSubject;
69 Incidence* mCurrentIncidence; 70 Incidence* mCurrentIncidence;
70 signals: 71 signals:
71 void launchaddressbook(QString uid); 72 void launchaddressbook(QString uid);
72}; 73};
73 74
74#endif 75#endif