summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koeventviewer.cpp1
-rw-r--r--korganizer/koeventviewerdialog.cpp1
2 files changed, 1 insertions, 1 deletions
diff --git a/korganizer/koeventviewer.cpp b/korganizer/koeventviewer.cpp
index d34e6a9..948047a 100644
--- a/korganizer/koeventviewer.cpp
+++ b/korganizer/koeventviewer.cpp
@@ -1,581 +1,580 @@
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 19
20#include <qcstring.h> 20#include <qcstring.h>
21#include <qwhatsthis.h> 21#include <qwhatsthis.h>
22#include <qdialog.h> 22#include <qdialog.h>
23#include <qapplication.h> 23#include <qapplication.h>
24#include <qlabel.h> 24#include <qlabel.h>
25#include <qlayout.h> 25#include <qlayout.h>
26 26
27#include <klocale.h> 27#include <klocale.h>
28#include <kapplication.h> 28#include <kapplication.h>
29#include <libkcal/event.h> 29#include <libkcal/event.h>
30#include <libkcal/todo.h> 30#include <libkcal/todo.h>
31#include <kdebug.h> 31#include <kdebug.h>
32#include <kiconloader.h> 32#include <kiconloader.h>
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 <libkdepim/addresseeview.h> 38#include <libkdepim/addresseeview.h>
39#include <kabc/stdaddressbook.h> 39#include <kabc/stdaddressbook.h>
40 40
41#ifndef KORG_NODCOP 41#ifndef KORG_NODCOP
42#include <dcopclient.h> 42#include <dcopclient.h>
43#include "korganizer.h" 43#include "korganizer.h"
44#include "koprefs.h" 44#include "koprefs.h"
45#include "actionmanager.h" 45#include "actionmanager.h"
46#endif 46#endif
47 47
48#include "koeventviewer.h" 48#include "koeventviewer.h"
49#ifndef KORG_NOKABC 49#ifndef KORG_NOKABC
50#include <kabc/stdaddressbook.h> 50#include <kabc/stdaddressbook.h>
51#define size count 51#define size count
52#endif 52#endif
53 53
54#ifdef DESKTOP_VERSION 54#ifdef DESKTOP_VERSION
55#include <kabc/addresseedialog.h> 55#include <kabc/addresseedialog.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 KPIM::AddresseeView av ( &dia ); 90 KPIM::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
98 } 97 }
99 dia.exec(); 98 dia.exec();
100 break; 99 break;
101 } 100 }
102 } 101 }
103 return; 102 return;
104 } 103 }
105#else 104#else
106 { 105 {
107 if ( "uid:organizer" == n ) { 106 if ( "uid:organizer" == n ) {
108 ExternalAppHandler::instance()->requestDetailsFromKAPI("", mCurrentIncidence->organizer(),""); 107 ExternalAppHandler::instance()->requestDetailsFromKAPI("", mCurrentIncidence->organizer(),"");
109 return; 108 return;
110 } 109 }
111 QPtrList<Attendee> attendees = mCurrentIncidence->attendees(); 110 QPtrList<Attendee> attendees = mCurrentIncidence->attendees();
112 if (attendees.count()) { 111 if (attendees.count()) {
113 Attendee *a; 112 Attendee *a;
114 for(a=attendees.first();a;a=attendees.next()) { 113 for(a=attendees.first();a;a=attendees.next()) {
115 if ( "uid:"+a->uid() == n ) { 114 if ( "uid:"+a->uid() == n ) {
116 bool res = ExternalAppHandler::instance()->requestDetailsFromKAPI(a->name(), a->email(), a->uid()); 115 bool res = ExternalAppHandler::instance()->requestDetailsFromKAPI(a->name(), a->email(), a->uid());
117 return; 116 return;
118 } 117 }
119 } 118 }
120 } 119 }
121 return; 120 return;
122 } 121 }
123 //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*/);
124 // the result should now arrive through method insertAttendees 123 // the result should now arrive through method insertAttendees
125 //QString uid = "uid:"+(*it).uid(); 124 //QString uid = "uid:"+(*it).uid();
126#endif 125#endif
127 if ( n.left(6) == "mailto" ) { 126 if ( n.left(6) == "mailto" ) {
128 // qDebug("KOEventViewer::setSource %s ", n.mid(7).latin1()); 127 // qDebug("KOEventViewer::setSource %s ", n.mid(7).latin1());
129#ifndef DESKTOP_VERSION 128#ifndef DESKTOP_VERSION
130 QCopEnvelope e("QPE/Application/ompi", "newMail(QString)" ); 129 QCopEnvelope e("QPE/Application/ompi", "newMail(QString)" );
131 e << n.mid(7); 130 e << n.mid(7);
132#endif 131#endif
133 132
134 } 133 }
135 134
136 135
137#ifndef KORG_NODCOP 136#ifndef KORG_NODCOP
138 kdDebug() << "KOEventViewer::setSource(): " << n << endl; 137 kdDebug() << "KOEventViewer::setSource(): " << n << endl;
139 QString tmpStr; 138 QString tmpStr;
140 if (n.startsWith("mailto:")) { 139 if (n.startsWith("mailto:")) {
141 KApplication::kApplication()->invokeMailer(n.mid(7),QString::null); 140 KApplication::kApplication()->invokeMailer(n.mid(7),QString::null);
142 //emit showIncidence(n); 141 //emit showIncidence(n);
143 return; 142 return;
144 } else if (n.startsWith("uid:")) { 143 } else if (n.startsWith("uid:")) {
145 DCOPClient *client = KApplication::kApplication()->dcopClient(); 144 DCOPClient *client = KApplication::kApplication()->dcopClient();
146 const QByteArray noParamData; 145 const QByteArray noParamData;
147 const QByteArray paramData; 146 const QByteArray paramData;
148 QByteArray replyData; 147 QByteArray replyData;
149 QCString replyTypeStr; 148 QCString replyTypeStr;
150#define PING_ABBROWSER (client->call("kaddressbook", "KAddressBookIface", "interfaces()", noParamData, replyTypeStr, replyData)) 149#define PING_ABBROWSER (client->call("kaddressbook", "KAddressBookIface", "interfaces()", noParamData, replyTypeStr, replyData))
151 bool foundAbbrowser = PING_ABBROWSER; 150 bool foundAbbrowser = PING_ABBROWSER;
152 151
153 if (foundAbbrowser) { 152 if (foundAbbrowser) {
154 //KAddressbook is already running, so just DCOP to it to bring up the contact editor 153 //KAddressbook is already running, so just DCOP to it to bring up the contact editor
155 //client->send("kaddressbook","KAddressBookIface", 154 //client->send("kaddressbook","KAddressBookIface",
156 QDataStream arg(paramData, IO_WriteOnly); 155 QDataStream arg(paramData, IO_WriteOnly);
157 arg << n.mid(6); 156 arg << n.mid(6);
158 client->send("kaddressbook", "KAddressBookIface", "showContactEditor( QString )", paramData); 157 client->send("kaddressbook", "KAddressBookIface", "showContactEditor( QString )", paramData);
159 return; 158 return;
160 } else { 159 } else {
161 /* 160 /*
162 KaddressBook is not already running. Pass it the UID of the contact via the command line while starting it - its neater. 161 KaddressBook is not already running. Pass it the UID of the contact via the command line while starting it - its neater.
163 We start it without its main interface 162 We start it without its main interface
164 */ 163 */
165 KIconLoader* iconLoader = new KIconLoader(); 164 KIconLoader* iconLoader = new KIconLoader();
166 QString iconPath = iconLoader->iconPath("go",KIcon::Small); 165 QString iconPath = iconLoader->iconPath("go",KIcon::Small);
167 ActionManager::setStartedKAddressBook(true); 166 ActionManager::setStartedKAddressBook(true);
168 tmpStr = "kaddressbook --editor-only --uid "; 167 tmpStr = "kaddressbook --editor-only --uid ";
169 tmpStr += KProcess::quote(n.mid(6)); 168 tmpStr += KProcess::quote(n.mid(6));
170 KRun::runCommand(tmpStr,"KAddressBook",iconPath); 169 KRun::runCommand(tmpStr,"KAddressBook",iconPath);
171 return; 170 return;
172 } 171 }
173 } else { 172 } else {
174 //QTextBrowser::setSource(n); 173 //QTextBrowser::setSource(n);
175 } 174 }
176#endif 175#endif
177} 176}
178 177
179void KOEventViewer::addTag(const QString & tag,const QString & text) 178void KOEventViewer::addTag(const QString & tag,const QString & text)
180{ 179{
181 int number=text.contains("\n"); 180 int number=text.contains("\n");
182 QString str = "<" + tag + ">"; 181 QString str = "<" + tag + ">";
183 QString tmpText=text; 182 QString tmpText=text;
184 QString tmpStr=str; 183 QString tmpStr=str;
185 if(number !=-1) 184 if(number !=-1)
186 { 185 {
187 if (number > 0) { 186 if (number > 0) {
188 int pos=0; 187 int pos=0;
189 QString tmp; 188 QString tmp;
190 for(int i=0;i<=number;i++) { 189 for(int i=0;i<=number;i++) {
191 pos=tmpText.find("\n"); 190 pos=tmpText.find("\n");
192 tmp=tmpText.left(pos); 191 tmp=tmpText.left(pos);
193 tmpText=tmpText.right(tmpText.length()-pos-1); 192 tmpText=tmpText.right(tmpText.length()-pos-1);
194 tmpStr+=tmp+"<br>"; 193 tmpStr+=tmp+"<br>";
195 } 194 }
196 } 195 }
197 else tmpStr += tmpText; 196 else tmpStr += tmpText;
198 tmpStr+="</" + tag + ">"; 197 tmpStr+="</" + tag + ">";
199 mText.append(tmpStr); 198 mText.append(tmpStr);
200 } 199 }
201 else 200 else
202 { 201 {
203 str += text + "</" + tag + ">"; 202 str += text + "</" + tag + ">";
204 mText.append(str); 203 mText.append(str);
205 } 204 }
206} 205}
207 206
208void KOEventViewer::setColorMode( int m ) 207void KOEventViewer::setColorMode( int m )
209{ 208{
210 mColorMode = m; 209 mColorMode = m;
211} 210}
212void KOEventViewer::appendEvent(Event *event, int mode ) 211void KOEventViewer::appendEvent(Event *event, int mode )
213{ 212{
214 mMailSubject = ""; 213 mMailSubject = "";
215 mCurrentIncidence = event; 214 mCurrentIncidence = event;
216 bool shortDate = KOPrefs::instance()->mShortDateInViewer; 215 bool shortDate = KOPrefs::instance()->mShortDateInViewer;
217 topLevelWidget()->setCaption(i18n("Event Viewer")); 216 topLevelWidget()->setCaption(i18n("Event Viewer"));
218 if ( mode == 0 ) { 217 if ( mode == 0 ) {
219 addTag("h2",event->summary()); 218 addTag("h2",event->summary());
220 } 219 }
221 else { 220 else {
222 if ( mColorMode == 1 ) { 221 if ( mColorMode == 1 ) {
223 mText +="<font color=\"#00A000\">"; 222 mText +="<font color=\"#00A000\">";
224 } 223 }
225 if ( mColorMode == 2 ) { 224 if ( mColorMode == 2 ) {
226 mText +="<font color=\"#C00000\">"; 225 mText +="<font color=\"#C00000\">";
227 } 226 }
228 // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; 227 // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>";
229 if ( mode == 1 ) { 228 if ( mode == 1 ) {
230 addTag("h2",i18n( "Local: " ) +event->summary()); 229 addTag("h2",i18n( "Local: " ) +event->summary());
231 } else { 230 } else {
232 addTag("h2",i18n( "Remote: " ) +event->summary()); 231 addTag("h2",i18n( "Remote: " ) +event->summary());
233 } 232 }
234 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); 233 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) );
235 if ( mColorMode ) 234 if ( mColorMode )
236 mText += "</font>"; 235 mText += "</font>";
237 } 236 }
238 mMailSubject += i18n( "Meeting " )+ event->summary(); 237 mMailSubject += i18n( "Meeting " )+ event->summary();
239 if (event->cancelled ()) { 238 if (event->cancelled ()) {
240 mText +="<font color=\"#B00000\">"; 239 mText +="<font color=\"#B00000\">";
241 addTag("i",i18n("This event has been cancelled!")); 240 addTag("i",i18n("This event has been cancelled!"));
242 mText.append("<br>"); 241 mText.append("<br>");
243 mText += "</font>"; 242 mText += "</font>";
244 mMailSubject += i18n("(cancelled)"); 243 mMailSubject += i18n("(cancelled)");
245 } 244 }
246 if (!event->location().isEmpty()) { 245 if (!event->location().isEmpty()) {
247 addTag("b",i18n("Location: ")); 246 addTag("b",i18n("Location: "));
248 mText.append(event->location()+"<br>"); 247 mText.append(event->location()+"<br>");
249 mMailSubject += i18n(" at ") + event->location(); 248 mMailSubject += i18n(" at ") + event->location();
250 } 249 }
251 if (event->doesFloat()) { 250 if (event->doesFloat()) {
252 if (event->isMultiDay()) { 251 if (event->isMultiDay()) {
253 mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>") 252 mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>")
254 .arg(event->dtStartDateStr(shortDate)) 253 .arg(event->dtStartDateStr(shortDate))
255 .arg(event->dtEndDateStr(shortDate))); 254 .arg(event->dtEndDateStr(shortDate)));
256 } else { 255 } else {
257 mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate ))); 256 mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate )));
258 } 257 }
259 } else { 258 } else {
260 if (event->isMultiDay()) { 259 if (event->isMultiDay()) {
261 mText.append(i18n("<p><b>From:</b> %1</p> ") 260 mText.append(i18n("<p><b>From:</b> %1</p> ")
262 .arg(event->dtStartStr( shortDate))); 261 .arg(event->dtStartStr( shortDate)));
263 mText.append(i18n("<p><b>To:</b> %1</p>") 262 mText.append(i18n("<p><b>To:</b> %1</p>")
264 .arg(event->dtEndStr(shortDate))); 263 .arg(event->dtEndStr(shortDate)));
265 } else { 264 } else {
266 mText.append(i18n("<p><b>On:</b> %1</p> ") 265 mText.append(i18n("<p><b>On:</b> %1</p> ")
267 .arg(event->dtStartDateStr( shortDate ))); 266 .arg(event->dtStartDateStr( shortDate )));
268 mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>") 267 mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>")
269 .arg(event->dtStartTimeStr()) 268 .arg(event->dtStartTimeStr())
270 .arg(event->dtEndTimeStr())); 269 .arg(event->dtEndTimeStr()));
271 } 270 }
272 } 271 }
273 272
274 if (event->recurrence()->doesRecur()) { 273 if (event->recurrence()->doesRecur()) {
275 274
276 QString recurText = event->recurrence()->recurrenceText(); 275 QString recurText = event->recurrence()->recurrenceText();
277 addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>"); 276 addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>");
278 bool last; 277 bool last;
279 QDate start = QDate::currentDate(); 278 QDate start = QDate::currentDate();
280 QDate next; 279 QDate next;
281 next = event->recurrence()->getPreviousDate( start , &last ); 280 next = event->recurrence()->getPreviousDate( start , &last );
282 if ( !last ) { 281 if ( !last ) {
283 next = event->recurrence()->getNextDate( start.addDays( - 1 ) ); 282 next = event->recurrence()->getNextDate( start.addDays( - 1 ) );
284 addTag("p",i18n("<b>Next recurrence is on:</b>") ); 283 addTag("p",i18n("<b>Next recurrence is on:</b>") );
285 addTag("p", KGlobal::locale()->formatDate( next, shortDate )); 284 addTag("p", KGlobal::locale()->formatDate( next, shortDate ));
286 QDateTime nextdt = QDateTime( next, event->dtStart().time()); 285 QDateTime nextdt = QDateTime( next, event->dtStart().time());
287 mMailSubject += i18n(" - " )+ KGlobal::locale()->formatDateTime( nextdt, true ); 286 mMailSubject += i18n(" - " )+ KGlobal::locale()->formatDateTime( nextdt, true );
288 287
289 } else { 288 } else {
290 addTag("p",i18n("<b>Last recurrence was on:</b>") ); 289 addTag("p",i18n("<b>Last recurrence was on:</b>") );
291 addTag("p", KGlobal::locale()->formatDate( next, shortDate )); 290 addTag("p", KGlobal::locale()->formatDate( next, shortDate ));
292 } 291 }
293 } else { 292 } else {
294 mMailSubject += i18n(" - " )+event->dtStartStr( true ); 293 mMailSubject += i18n(" - " )+event->dtStartStr( true );
295 294
296 } 295 }
297 296
298 297
299 if (event->isAlarmEnabled()) { 298 if (event->isAlarmEnabled()) {
300 Alarm *alarm =event->alarms().first() ; 299 Alarm *alarm =event->alarms().first() ;
301 QDateTime t = alarm->time(); 300 QDateTime t = alarm->time();
302 int min = t.secsTo( event->dtStart() )/60; 301 int min = t.secsTo( event->dtStart() )/60;
303 QString s =i18n("( %1 min before )").arg( min ); 302 QString s =i18n("( %1 min before )").arg( min );
304 addTag("p",i18n("<b>Alarm on: ") + s +" </b>"); 303 addTag("p",i18n("<b>Alarm on: ") + s +" </b>");
305 addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); 304 addTag("p", KGlobal::locale()->formatDateTime( t, shortDate ));
306 //addTag("p",s); 305 //addTag("p",s);
307 } 306 }
308 307
309 addTag("b",i18n("Access: ")); 308 addTag("b",i18n("Access: "));
310 mText.append(event->secrecyStr()+"<br>"); 309 mText.append(event->secrecyStr()+"<br>");
311 if (!event->description().isEmpty()) { 310 if (!event->description().isEmpty()) {
312 addTag("p",i18n("<b>Details: </b>")); 311 addTag("p",i18n("<b>Details: </b>"));
313 addTag("p",event->description()); 312 addTag("p",event->description());
314 } 313 }
315 314
316 formatCategories(event); 315 formatCategories(event);
317 316
318 formatReadOnly(event); 317 formatReadOnly(event);
319 formatAttendees(event); 318 formatAttendees(event);
320 319
321 setText(mText); 320 setText(mText);
322 //QWhatsThis::add(this,mText); 321 //QWhatsThis::add(this,mText);
323 322
324} 323}
325 324
326void KOEventViewer::appendTodo(Todo *event, int mode ) 325void KOEventViewer::appendTodo(Todo *event, int mode )
327{ 326{
328 mMailSubject = ""; 327 mMailSubject = "";
329 mCurrentIncidence = event; 328 mCurrentIncidence = event;
330 topLevelWidget()->setCaption(i18n("Todo Viewer")); 329 topLevelWidget()->setCaption(i18n("Todo Viewer"));
331 bool shortDate = KOPrefs::instance()->mShortDateInViewer; 330 bool shortDate = KOPrefs::instance()->mShortDateInViewer;
332 if (mode == 0 ) 331 if (mode == 0 )
333 addTag("h2",event->summary()); 332 addTag("h2",event->summary());
334 else { 333 else {
335 if ( mColorMode == 1 ) { 334 if ( mColorMode == 1 ) {
336 mText +="<font color=\"#00A000\">"; 335 mText +="<font color=\"#00A000\">";
337 } 336 }
338 if ( mColorMode == 2 ) { 337 if ( mColorMode == 2 ) {
339 mText +="<font color=\"#B00000\">"; 338 mText +="<font color=\"#B00000\">";
340 } 339 }
341 if ( mode == 1 ) { 340 if ( mode == 1 ) {
342 addTag("h2",i18n( "Local: " ) +event->summary()); 341 addTag("h2",i18n( "Local: " ) +event->summary());
343 } else { 342 } else {
344 addTag("h2",i18n( "Remote: " ) +event->summary()); 343 addTag("h2",i18n( "Remote: " ) +event->summary());
345 } 344 }
346 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); 345 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) );
347 if ( mColorMode ) 346 if ( mColorMode )
348 mText += "</font>"; 347 mText += "</font>";
349 } 348 }
350 mMailSubject += i18n( "Todo " )+ event->summary(); 349 mMailSubject += i18n( "Todo " )+ event->summary();
351 if (event->cancelled ()) { 350 if (event->cancelled ()) {
352 mText +="<font color=\"#B00000\">"; 351 mText +="<font color=\"#B00000\">";
353 addTag("i",i18n("This todo has been cancelled!")); 352 addTag("i",i18n("This todo has been cancelled!"));
354 mText.append("<br>"); 353 mText.append("<br>");
355 mText += "</font>"; 354 mText += "</font>";
356 mMailSubject += i18n("(cancelled)"); 355 mMailSubject += i18n("(cancelled)");
357 } 356 }
358 357
359 if (!event->location().isEmpty()) { 358 if (!event->location().isEmpty()) {
360 addTag("b",i18n("Location: ")); 359 addTag("b",i18n("Location: "));
361 mText.append(event->location()+"<br>"); 360 mText.append(event->location()+"<br>");
362 mMailSubject += i18n(" at ") + event->location(); 361 mMailSubject += i18n(" at ") + event->location();
363 } 362 }
364 if (event->hasDueDate()) { 363 if (event->hasDueDate()) {
365 mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(KOPrefs::instance()->mShortDateInViewer))); 364 mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(KOPrefs::instance()->mShortDateInViewer)));
366 mMailSubject += i18n(" - " )+event->dtDueStr( true ); 365 mMailSubject += i18n(" - " )+event->dtDueStr( true );
367 } 366 }
368 addTag("b",i18n("Access: ")); 367 addTag("b",i18n("Access: "));
369 mText.append(event->secrecyStr()+"<br>"); 368 mText.append(event->secrecyStr()+"<br>");
370 if (!event->description().isEmpty()) { 369 if (!event->description().isEmpty()) {
371 addTag("p",i18n("<b>Details: </b>")); 370 addTag("p",i18n("<b>Details: </b>"));
372 addTag("p",event->description()); 371 addTag("p",event->description());
373 } 372 }
374 373
375 formatCategories(event); 374 formatCategories(event);
376 375
377 mText.append(i18n("<p><b>Priority:</b> %2</p>") 376 mText.append(i18n("<p><b>Priority:</b> %2</p>")
378 .arg(QString::number(event->priority()))); 377 .arg(QString::number(event->priority())));
379 378
380 mText.append(i18n("<p><i>%1 % completed</i></p>") 379 mText.append(i18n("<p><i>%1 % completed</i></p>")
381 .arg(event->percentComplete())); 380 .arg(event->percentComplete()));
382 381
383 formatReadOnly(event); 382 formatReadOnly(event);
384 formatAttendees(event); 383 formatAttendees(event);
385 384
386 setText(mText); 385 setText(mText);
387} 386}
388 387
389void KOEventViewer::formatCategories(Incidence *event) 388void KOEventViewer::formatCategories(Incidence *event)
390{ 389{
391 if (!event->categoriesStr().isEmpty()) { 390 if (!event->categoriesStr().isEmpty()) {
392 if (event->categories().count() == 1) { 391 if (event->categories().count() == 1) {
393 addTag("h3",i18n("Category")); 392 addTag("h3",i18n("Category"));
394 } else { 393 } else {
395 addTag("h3",i18n("Categories")); 394 addTag("h3",i18n("Categories"));
396 } 395 }
397 addTag("p",event->categoriesStr()); 396 addTag("p",event->categoriesStr());
398 } 397 }
399} 398}
400void KOEventViewer::formatAttendees(Incidence *event) 399void KOEventViewer::formatAttendees(Incidence *event)
401{ 400{
402 QPtrList<Attendee> attendees = event->attendees(); 401 QPtrList<Attendee> attendees = event->attendees();
403 if (attendees.count()) { 402 if (attendees.count()) {
404 403
405 404
406 QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); 405 QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small);
407 addTag("h3",i18n("Organizer")); 406 addTag("h3",i18n("Organizer"));
408 mText.append("<ul><li>"); 407 mText.append("<ul><li>");
409#ifndef KORG_NOKABC 408#ifndef KORG_NOKABC
410 409
411#ifdef DESKTOP_VERSION 410#ifdef DESKTOP_VERSION
412 KABC::AddressBook *add_book = KABC::StdAddressBook::self(); 411 KABC::AddressBook *add_book = KABC::StdAddressBook::self();
413 KABC::Addressee::List addressList; 412 KABC::Addressee::List addressList;
414 addressList = add_book->findByEmail(event->organizer()); 413 addressList = add_book->findByEmail(event->organizer());
415 KABC::Addressee o = addressList.first(); 414 KABC::Addressee o = addressList.first();
416 if (!o.isEmpty() && addressList.size()<2) { 415 if (!o.isEmpty() && addressList.size()<2) {
417 mText += "<a href=\"uid:" + o.uid() + "\">"; 416 mText += "<a href=\"uid:" + o.uid() + "\">";
418 mText += o.formattedName(); 417 mText += o.formattedName();
419 mText += "</a>\n"; 418 mText += "</a>\n";
420 } else { 419 } else {
421 mText.append(event->organizer()); 420 mText.append(event->organizer());
422 } 421 }
423#else //DESKTOP_VERSION 422#else //DESKTOP_VERSION
424 mText += "<a href=\"uid:organizer\">"; 423 mText += "<a href=\"uid:organizer\">";
425 mText += event->organizer(); 424 mText += event->organizer();
426 mText += "</a>\n"; 425 mText += "</a>\n";
427#endif //DESKTOP_VERSION 426#endif //DESKTOP_VERSION
428 427
429 428
430#else 429#else
431 mText.append(event->organizer()); 430 mText.append(event->organizer());
432#endif 431#endif
433 432
434 if (iconPath) { 433 if (iconPath) {
435 mText += " <a href=\"mailto:" + event->organizer() + "\">"; 434 mText += " <a href=\"mailto:" + event->organizer() + "\">";
436 mText += "<IMG src=\"" + iconPath + "\">"; 435 mText += "<IMG src=\"" + iconPath + "\">";
437 mText += "</a>\n"; 436 mText += "</a>\n";
438 } 437 }
439 mText.append("</li></ul>"); 438 mText.append("</li></ul>");
440 439
441 addTag("h3",i18n("Attendees")); 440 addTag("h3",i18n("Attendees"));
442 Attendee *a; 441 Attendee *a;
443 mText.append("<ul>"); 442 mText.append("<ul>");
444 for(a=attendees.first();a;a=attendees.next()) { 443 for(a=attendees.first();a;a=attendees.next()) {
445#ifndef KORG_NOKABC 444#ifndef KORG_NOKABC
446#ifdef DESKTOP_VERSION 445#ifdef DESKTOP_VERSION
447 if (a->name().isEmpty()) { 446 if (a->name().isEmpty()) {
448 addressList = add_book->findByEmail(a->email()); 447 addressList = add_book->findByEmail(a->email());
449 KABC::Addressee o = addressList.first(); 448 KABC::Addressee o = addressList.first();
450 if (!o.isEmpty() && addressList.size()<2) { 449 if (!o.isEmpty() && addressList.size()<2) {
451 mText += "<a href=\"uid:" + o.uid() + "\">"; 450 mText += "<a href=\"uid:" + o.uid() + "\">";
452 mText += o.formattedName(); 451 mText += o.formattedName();
453 mText += "</a>\n"; 452 mText += "</a>\n";
454 } else { 453 } else {
455 mText += "<li>"; 454 mText += "<li>";
456 mText.append(a->email()); 455 mText.append(a->email());
457 mText += "\n"; 456 mText += "\n";
458 } 457 }
459 } else { 458 } else {
460 mText += "<li><a href=\"uid:" + a->uid() + "\">"; 459 mText += "<li><a href=\"uid:" + a->uid() + "\">";
461 if (!a->name().isEmpty()) mText += a->name(); 460 if (!a->name().isEmpty()) mText += a->name();
462 else mText += a->email(); 461 else mText += a->email();
463 mText += "</a>\n"; 462 mText += "</a>\n";
464 } 463 }
465#else //DESKTOP_VERSION 464#else //DESKTOP_VERSION
466 mText += "<li><a href=\"uid:" + a->uid() + "\">"; 465 mText += "<li><a href=\"uid:" + a->uid() + "\">";
467 if (!a->name().isEmpty()) mText += a->name(); 466 if (!a->name().isEmpty()) mText += a->name();
468 else mText += a->email(); 467 else mText += a->email();
469 mText += "</a>\n"; 468 mText += "</a>\n";
470#endif //DESKTOP_VERSION 469#endif //DESKTOP_VERSION
471#else 470#else
472 //qDebug("nokabc "); 471 //qDebug("nokabc ");
473 mText += "<li><a href=\"uid:" + a->uid() + "\">"; 472 mText += "<li><a href=\"uid:" + a->uid() + "\">";
474 if (!a->name().isEmpty()) mText += a->name(); 473 if (!a->name().isEmpty()) mText += a->name();
475 else mText += a->email(); 474 else mText += a->email();
476 mText += "</a>\n"; 475 mText += "</a>\n";
477#endif 476#endif
478 477
479 478
480 if (!a->email().isEmpty()) { 479 if (!a->email().isEmpty()) {
481 if (iconPath) { 480 if (iconPath) {
482 mText += "<a href=\"mailto:" + a->name() +" <" + a->email() + ">:" + mMailSubject + "\">"; 481 mText += "<a href=\"mailto:" + a->name() +" <" + a->email() + ">:" + mMailSubject + "\">";
483 mText += "<IMG src=\"" + iconPath + "\">"; 482 mText += "<IMG src=\"" + iconPath + "\">";
484 mText += "</a>\n"; 483 mText += "</a>\n";
485 } 484 }
486 } 485 }
487 if (a->status() != Attendee::NeedsAction ) 486 if (a->status() != Attendee::NeedsAction )
488 mText +="[" + a->statusStr() + "] "; 487 mText +="[" + a->statusStr() + "] ";
489 if (a->role() == Attendee::Chair ) 488 if (a->role() == Attendee::Chair )
490 mText +="(" + a->roleStr().left(1) + ".)"; 489 mText +="(" + a->roleStr().left(1) + ".)";
491 } 490 }
492 mText.append("</li></ul>"); 491 mText.append("</li></ul>");
493 } 492 }
494 493
495} 494}
496void KOEventViewer::appendJournal(Journal *jour, int mode ) 495void KOEventViewer::appendJournal(Journal *jour, int mode )
497{ 496{
498 bool shortDate = KOPrefs::instance()->mShortDateInViewer; 497 bool shortDate = KOPrefs::instance()->mShortDateInViewer;
499 if (mode == 0 ) 498 if (mode == 0 )
500 addTag("h2",i18n("Journal from: ")); 499 addTag("h2",i18n("Journal from: "));
501 else { 500 else {
502 if ( mode == 1 ) { 501 if ( mode == 1 ) {
503 addTag("h2",i18n( "Local: " ) +i18n("Journal from: ")); 502 addTag("h2",i18n( "Local: " ) +i18n("Journal from: "));
504 } else { 503 } else {
505 addTag("h2",i18n( "Remote: " ) +i18n("Journal from: ")); 504 addTag("h2",i18n( "Remote: " ) +i18n("Journal from: "));
506 } 505 }
507 addTag("h3",i18n( "Last modified " ) + KGlobal::locale()->formatDateTime(jour->lastModified(),shortDate ) ); 506 addTag("h3",i18n( "Last modified " ) + KGlobal::locale()->formatDateTime(jour->lastModified(),shortDate ) );
508 } 507 }
509 topLevelWidget()->setCaption("Journal Viewer"); 508 topLevelWidget()->setCaption("Journal Viewer");
510 mText.append(i18n("<h3> %1 </h3> ").arg(jour->dtStartDateStr(KOPrefs::instance()->mShortDateInViewer))); 509 mText.append(i18n("<h3> %1 </h3> ").arg(jour->dtStartDateStr(KOPrefs::instance()->mShortDateInViewer)));
511 if (!jour->description().isEmpty()) { 510 if (!jour->description().isEmpty()) {
512 addTag("p",jour->description()); 511 addTag("p",jour->description());
513 } 512 }
514 setText(mText); 513 setText(mText);
515} 514}
516 515
517void KOEventViewer::formatReadOnly(Incidence *event) 516void KOEventViewer::formatReadOnly(Incidence *event)
518{ 517{
519 if (event->isReadOnly()) { 518 if (event->isReadOnly()) {
520 addTag("p","<em>(" + i18n("read-only") + ")</em>"); 519 addTag("p","<em>(" + i18n("read-only") + ")</em>");
521 } 520 }
522} 521}
523void KOEventViewer::setSyncMode( bool b ) 522void KOEventViewer::setSyncMode( bool b )
524{ 523{
525 mSyncMode = b; 524 mSyncMode = b;
526} 525}
527 526
528 527
529void KOEventViewer::setTodo(Todo *event, bool clearV ) 528void KOEventViewer::setTodo(Todo *event, bool clearV )
530{ 529{
531 if ( clearV ) 530 if ( clearV )
532 clearEvents(); 531 clearEvents();
533 if ( mSyncMode ) { 532 if ( mSyncMode ) {
534 if ( clearV ) 533 if ( clearV )
535 appendTodo(event,1 ); 534 appendTodo(event,1 );
536 else 535 else
537 appendTodo(event,2); 536 appendTodo(event,2);
538 } else 537 } else
539 appendTodo(event); 538 appendTodo(event);
540} 539}
541void KOEventViewer::setJournal(Journal *event, bool clearV ) 540void KOEventViewer::setJournal(Journal *event, bool clearV )
542{ 541{
543 if ( clearV ) 542 if ( clearV )
544 clearEvents(); 543 clearEvents();
545 if ( mSyncMode ) { 544 if ( mSyncMode ) {
546 if ( clearV ) 545 if ( clearV )
547 appendJournal(event, 1); 546 appendJournal(event, 1);
548 else 547 else
549 appendJournal(event, 2); 548 appendJournal(event, 2);
550 } else 549 } else
551 appendJournal(event); 550 appendJournal(event);
552} 551}
553 552
554void KOEventViewer::setEvent(Event *event) 553void KOEventViewer::setEvent(Event *event)
555{ 554{
556 clearEvents(); 555 clearEvents();
557 if ( mSyncMode ) 556 if ( mSyncMode )
558 appendEvent(event, 1); 557 appendEvent(event, 1);
559 else 558 else
560 appendEvent(event); 559 appendEvent(event);
561} 560}
562 561
563void KOEventViewer::addEvent(Event *event) 562void KOEventViewer::addEvent(Event *event)
564{ 563{
565 if ( mSyncMode ) 564 if ( mSyncMode )
566 appendEvent(event, 2); 565 appendEvent(event, 2);
567 else 566 else
568 appendEvent(event); 567 appendEvent(event);
569} 568}
570 569
571void KOEventViewer::clearEvents(bool now) 570void KOEventViewer::clearEvents(bool now)
572{ 571{
573 mText = ""; 572 mText = "";
574 if (now) setText(mText); 573 if (now) setText(mText);
575} 574}
576 575
577void KOEventViewer::addText(QString text) 576void KOEventViewer::addText(QString text)
578{ 577{
579 mText.append(text); 578 mText.append(text);
580 setText(mText); 579 setText(mText);
581} 580}
diff --git a/korganizer/koeventviewerdialog.cpp b/korganizer/koeventviewerdialog.cpp
index be183eb..68c0e1a 100644
--- a/korganizer/koeventviewerdialog.cpp
+++ b/korganizer/koeventviewerdialog.cpp
@@ -1,239 +1,240 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,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 19
20#include <klocale.h> 20#include <klocale.h>
21 21
22#include <libkcal/event.h> 22#include <libkcal/event.h>
23#include <qpushbutton.h> 23#include <qpushbutton.h>
24 24
25#include "koeventviewer.h" 25#include "koeventviewer.h"
26#include "koprefs.h" 26#include "koprefs.h"
27#include <libkcal/todo.h> 27#include <libkcal/todo.h>
28#include "qapp.h" 28#include "qapp.h"
29 29
30#include "koeventviewerdialog.h" 30#include "koeventviewerdialog.h"
31extern int globalFlagBlockAgenda; 31extern int globalFlagBlockAgenda;
32 32
33KOEventViewerDialog::KOEventViewerDialog(QWidget *parent,const char *name) 33KOEventViewerDialog::KOEventViewerDialog(QWidget *parent,const char *name)
34 : KDialogBase(parent,name, 34 : KDialogBase(parent,name,
35#ifndef DESKTOP_VERSION 35#ifndef DESKTOP_VERSION
36 true , 36 true ,
37#else 37#else
38 false, 38 false,
39#endif 39#endif
40 i18n("Event Viewer"),Ok|User1|Close,Close, false, i18n("Agenda")) 40 i18n("Event Viewer"),Ok|User1|Close,Close, false, i18n("Agenda"))
41{ 41{
42 42
43 mEventViewer = new KOEventViewer(this); 43 mEventViewer = new KOEventViewer(this);
44 mEventViewer->setFont( KOPrefs::instance()->mEventViewFont ); 44 mEventViewer->setFont( KOPrefs::instance()->mEventViewFont );
45 setMainWidget(mEventViewer); 45 setMainWidget(mEventViewer);
46 setButtonText(Ok, i18n("Edit") ); 46 setButtonText(Ok, i18n("Edit") );
47 47
48 QObject::connect(findButton( Ok ),SIGNAL(clicked()), 48 QObject::connect(findButton( Ok ),SIGNAL(clicked()),
49 SLOT(editIncidence())); 49 SLOT(editIncidence()));
50 QObject::connect(this,SIGNAL(user1Clicked()), 50 QObject::connect(this,SIGNAL(user1Clicked()),
51 SLOT(showIncidence())); 51 SLOT(showIncidence()));
52 mIncidence = 0; 52 mIncidence = 0;
53 // TODO: Set a sensible size (based on the content?). 53 // TODO: Set a sensible size (based on the content?).
54 //showMaximized(); 54 //showMaximized();
55 //qDebug("++++++++++++KOEventViewerDialog() "); 55 //qDebug("++++++++++++KOEventViewerDialog() ");
56 // if ( KOPrefs::instance()->mCompactDialogs ) { 56 // if ( KOPrefs::instance()->mCompactDialogs ) {
57// setFixedSize( 240,284 ); 57// setFixedSize( 240,284 );
58// move( 0, 15 ); 58// move( 0, 15 );
59// } else { 59// } else {
60// setMinimumSize(300,200); 60// setMinimumSize(300,200);
61// resize(320,300); 61// resize(320,300);
62// } 62// }
63 mSyncMode = false; 63 mSyncMode = false;
64 mSyncResult = 0; 64 mSyncResult = 0;
65 65
66} 66}
67 67
68KOEventViewerDialog::~KOEventViewerDialog() 68KOEventViewerDialog::~KOEventViewerDialog()
69{ 69{
70 //qDebug("-------~KOEventViewerDialog() "); 70 //qDebug("-------~KOEventViewerDialog() ");
71} 71}
72void KOEventViewerDialog::showMe() 72void KOEventViewerDialog::showMe()
73{ 73{
74 74
75#ifdef DESKTOP_VERSION 75#ifdef DESKTOP_VERSION
76 show(); 76 show();
77#else 77#else
78 showMaximized(); 78 showMaximized();
79#endif 79#endif
80 setFocus(); 80 setFocus();
81 setActiveWindow(); 81 setActiveWindow();
82 82
83} 83}
84void KOEventViewerDialog::setSyncMode( bool b ) 84void KOEventViewerDialog::setSyncMode( bool b )
85{ 85{
86 mSyncMode = b; 86 mSyncMode = b;
87 //qDebug("KOEventViewerDialog::setSyncMode %d ",mSyncMode ); 87 //qDebug("KOEventViewerDialog::setSyncMode %d ",mSyncMode );
88 if ( mSyncMode ) { 88 if ( mSyncMode ) {
89 findButton( Close )->setText( i18n("Cancel Sync")); 89 findButton( Close )->setText( i18n("Cancel Sync"));
90 findButton( Ok )->setText( i18n("Remote")); 90 findButton( Ok )->setText( i18n("Remote"));
91 findButton( User1 )->setText( i18n("Local")); 91 findButton( User1 )->setText( i18n("Local"));
92 } else { 92 } else {
93 findButton( Close )->setText( i18n("Close")); 93 findButton( Close )->setText( i18n("Close"));
94 findButton( Ok )->setText( i18n("Edit")); 94 findButton( Ok )->setText( i18n("Edit"));
95 findButton( User1 )->setText( i18n("Agenda")); 95 findButton( User1 )->setText( i18n("Agenda"));
96 } 96 }
97 mEventViewer->setSyncMode( b ); 97 mEventViewer->setSyncMode( b );
98} 98}
99void KOEventViewerDialog::setColorMode( int m ) 99void KOEventViewerDialog::setColorMode( int m )
100{ 100{
101 mEventViewer->setColorMode( m ); 101 mEventViewer->setColorMode( m );
102} 102}
103int KOEventViewerDialog::executeS( bool local ) 103int KOEventViewerDialog::executeS( bool local )
104{ 104{
105 mSyncResult = 3; 105 mSyncResult = 3;
106 if ( local ) 106 if ( local )
107 findButton( User1 )->setFocus(); 107 findButton( User1 )->setFocus();
108 else 108 else
109 findButton( Ok )->setFocus(); 109 findButton( Ok )->setFocus();
110 exec(); 110 exec();
111 return mSyncResult; 111 return mSyncResult;
112} 112}
113 113
114void KOEventViewerDialog::updateConfig() 114void KOEventViewerDialog::updateConfig()
115{ 115{
116 mEventViewer->setFont( KOPrefs::instance()->mEventViewFont ); 116 mEventViewer->setFont( KOPrefs::instance()->mEventViewFont );
117 117
118} 118}
119void KOEventViewerDialog::setEvent(Event *event) 119void KOEventViewerDialog::setEvent(Event *event)
120{ 120{
121 mEventViewer->setEvent(event); 121 mEventViewer->setEvent(event);
122 mIncidence = event; 122 mIncidence = event;
123 findButton( Close )->setFocus(); 123 findButton( Close )->setFocus();
124} 124}
125void KOEventViewerDialog::setIncidence(Incidence *in ) 125void KOEventViewerDialog::setIncidence(Incidence *in )
126{ 126{
127 if ( in->type() == "Event" ) 127 if ( in->type() == "Event" )
128 setEvent( (Event*) in ); 128 setEvent( (Event*) in );
129 else if ( in->type() =="Todo" ) 129 else if ( in->type() =="Todo" )
130 setTodo( (Todo*) in ); 130 setTodo( (Todo*) in );
131 else if ( in->type() =="Journal" ) 131 else if ( in->type() =="Journal" )
132 setJournal( (Journal*) in ); 132 setJournal( (Journal*) in );
133} 133}
134void KOEventViewerDialog::addIncidence(Incidence *in) 134void KOEventViewerDialog::addIncidence(Incidence *in)
135{ 135{
136 if ( in->type() == "Event" ) 136 if ( in->type() == "Event" )
137 addEvent( (Event*) in ); 137 addEvent( (Event*) in );
138 else if ( in->type() =="Todo" ) 138 else if ( in->type() =="Todo" )
139 mEventViewer->setTodo( (Todo*) in, false ); 139 mEventViewer->setTodo( (Todo*) in, false );
140 else if ( in->type() =="Journal" ) 140 else if ( in->type() =="Journal" )
141 mEventViewer->setJournal( (Journal*) in, false ); 141 mEventViewer->setJournal( (Journal*) in, false );
142 if ( mSyncMode ) { 142 if ( mSyncMode ) {
143 findButton( User1 )->setFocus(); 143 findButton( User1 )->setFocus();
144 setCaption(i18n("Conflict! Please choose entry")); 144 setCaption(i18n("Conflict! Please choose entry"));
145 } 145 }
146} 146}
147 147
148void KOEventViewerDialog::addEvent(Event *event) 148void KOEventViewerDialog::addEvent(Event *event)
149{ 149{
150 mEventViewer->addEvent(event); 150 mEventViewer->addEvent(event);
151 mIncidence = event; 151 mIncidence = event;
152 findButton( Close )->setFocus(); 152 findButton( Close )->setFocus();
153} 153}
154 154
155void KOEventViewerDialog::setTodo(Todo *event) 155void KOEventViewerDialog::setTodo(Todo *event)
156{ 156{
157 mEventViewer->setTodo(event); 157 mEventViewer->setTodo(event);
158 mIncidence = (Incidence*)event; 158 mIncidence = (Incidence*)event;
159 findButton( Close )->setFocus(); 159 findButton( Close )->setFocus();
160} 160}
161void KOEventViewerDialog::setJournal(Journal *j) 161void KOEventViewerDialog::setJournal(Journal *j)
162{ 162{
163 mEventViewer->setJournal(j); 163 mEventViewer->setJournal(j);
164 mIncidence = (Incidence*)j; 164 mIncidence = (Incidence*)j;
165 findButton( Close )->setFocus(); 165 findButton( Close )->setFocus();
166} 166}
167 167
168void KOEventViewerDialog::addText(QString text) 168void KOEventViewerDialog::addText(QString text)
169{ 169{
170 mEventViewer->addText(text); 170 mEventViewer->addText(text);
171 findButton( Close )->setFocus(); 171 findButton( Close )->setFocus();
172} 172}
173void KOEventViewerDialog::editIncidence() 173void KOEventViewerDialog::editIncidence()
174{ 174{
175 if ( mSyncMode ) { 175 if ( mSyncMode ) {
176 mSyncResult = 2; 176 mSyncResult = 2;
177 accept(); 177 accept();
178 return; 178 return;
179 } 179 }
180 if ( mIncidence ){ 180 if ( mIncidence ){
181#ifndef DESKTOP_VERSION 181#ifndef DESKTOP_VERSION
182 hide(); 182 hide();
183#endif 183#endif
184 emit editIncidence( mIncidence ); 184 emit editIncidence( mIncidence );
185 } 185 }
186} 186}
187void KOEventViewerDialog::showIncidence() 187void KOEventViewerDialog::showIncidence()
188{ 188{
189 189
190 if ( mSyncMode ) { 190 if ( mSyncMode ) {
191 mSyncResult = 1; 191 mSyncResult = 1;
192 accept(); 192 accept();
193 return; 193 return;
194 } 194 }
195 195
196 if ( mIncidence ){ 196 if ( mIncidence ){
197#ifndef DESKTOP_VERSION 197#ifndef DESKTOP_VERSION
198 hide(); 198 hide();
199#endif 199#endif
200 QDate date; 200 QDate date;
201 if ( mIncidence->type() == "Todo" ) { 201 if ( mIncidence->type() == "Todo" ) {
202 if ( ((Todo*)mIncidence)->hasDueDate() ) 202 if ( ((Todo*)mIncidence)->hasDueDate() )
203 date = ((Todo*)mIncidence)->dtDue().date(); 203 date = ((Todo*)mIncidence)->dtDue().date();
204 else { 204 else {
205 globalFlagBlockAgenda = 2; 205 globalFlagBlockAgenda = 2;
206 emit showAgendaView( false ); 206 emit showAgendaView( false );
207 return; 207 return;
208 } 208 }
209 } else 209 } else
210 date = mIncidence->dtStart().date(); 210 date = mIncidence->dtStart().date();
211 globalFlagBlockAgenda = 1; 211 globalFlagBlockAgenda = 1;
212 emit showAgendaView( false ); 212 emit showAgendaView( false );
213 globalFlagBlockAgenda = 2; 213 globalFlagBlockAgenda = 2;
214 emit jumpToTime( date ); 214 emit jumpToTime( date );
215 } 215 }
216} 216}
217void KOEventViewerDialog::keyPressEvent ( QKeyEvent * e ) 217void KOEventViewerDialog::keyPressEvent ( QKeyEvent * e )
218{ 218{
219 switch ( e->key() ) { 219 switch ( e->key() ) {
220 220
221 case Qt::Key_A : 221 case Qt::Key_A :
222 case Qt::Key_L : 222 case Qt::Key_L :
223 showIncidence(); 223 showIncidence();
224 break; 224 break;
225 case Qt::Key_E : 225 case Qt::Key_E :
226 case Qt::Key_R : 226 case Qt::Key_R :
227 editIncidence(); 227 editIncidence();
228 break; 228 break;
229 case Qt::Key_C: 229 case Qt::Key_C:
230 case Qt::Key_Escape:
230 close(); 231 close();
231 break; 232 break;
232 case Qt::Key_I: 233 case Qt::Key_I:
233 accept(); 234 accept();
234 break; 235 break;
235 default: 236 default:
236 break; 237 break;
237 } 238 }
238 239
239} 240}