summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-04-15 09:18:49 (UTC)
committer zautrix <zautrix>2005-04-15 09:18:49 (UTC)
commitab47475f1b03a8c82f9b0388549a2618743f2a69 (patch) (unidiff)
tree381622b3ceb94daf771a2697ee10f0cd6572e947 /korganizer
parentacb5803cdda97ef1369388eb15eb669e2835c06a (diff)
downloadkdepimpi-ab47475f1b03a8c82f9b0388549a2618743f2a69.zip
kdepimpi-ab47475f1b03a8c82f9b0388549a2618743f2a69.tar.gz
kdepimpi-ab47475f1b03a8c82f9b0388549a2618743f2a69.tar.bz2
fixxx
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koeventviewer.cpp94
-rw-r--r--korganizer/komonthview.cpp5
2 files changed, 59 insertions, 40 deletions
diff --git a/korganizer/koeventviewer.cpp b/korganizer/koeventviewer.cpp
index bdad248..fefc778 100644
--- a/korganizer/koeventviewer.cpp
+++ b/korganizer/koeventviewer.cpp
@@ -122,589 +122,607 @@ void KOEventViewer::setSource(const QString& n)
122 QString uid = "uid://"+(*it).uid(); 122 QString uid = "uid://"+(*it).uid();
123 123
124 //qDebug("for *%s* +%s+ ", n.latin1(), uid.latin1()); 124 //qDebug("for *%s* +%s+ ", n.latin1(), uid.latin1());
125 if (n == uid ) { 125 if (n == uid ) {
126 //qDebug("found %s ",(*it).mobileHomePhone().latin1() ); 126 //qDebug("found %s ",(*it).mobileHomePhone().latin1() );
127 QDialog dia( this,"dia123", true ); 127 QDialog dia( this,"dia123", true );
128 dia.setCaption( i18n("Details of attendee") ); 128 dia.setCaption( i18n("Details of attendee") );
129 QVBoxLayout lay ( &dia ); 129 QVBoxLayout lay ( &dia );
130 KABC::AddresseeView av ( &dia ); 130 KABC::AddresseeView av ( &dia );
131 av.setAddressee( (*it) ); 131 av.setAddressee( (*it) );
132 lay.addWidget( &av ); 132 lay.addWidget( &av );
133 if ( QApplication::desktop()->width() < 480 ) 133 if ( QApplication::desktop()->width() < 480 )
134 dia.resize( 220, 240); 134 dia.resize( 220, 240);
135 else { 135 else {
136 dia.resize( 400,400); 136 dia.resize( 400,400);
137 } 137 }
138 dia.exec(); 138 dia.exec();
139 break; 139 break;
140 } 140 }
141 } 141 }
142 return; 142 return;
143 } 143 }
144#else 144#else
145 { 145 {
146 if ( "uid:organizer" == n ) { 146 if ( "uid:organizer" == n ) {
147 ExternalAppHandler::instance()->requestDetailsFromKAPI("", mCurrentIncidence->organizer(),""); 147 ExternalAppHandler::instance()->requestDetailsFromKAPI("", mCurrentIncidence->organizer(),"");
148 return; 148 return;
149 } 149 }
150 QPtrList<Attendee> attendees = mCurrentIncidence->attendees(); 150 QPtrList<Attendee> attendees = mCurrentIncidence->attendees();
151 if (attendees.count()) { 151 if (attendees.count()) {
152 Attendee *a; 152 Attendee *a;
153 for(a=attendees.first();a;a=attendees.next()) { 153 for(a=attendees.first();a;a=attendees.next()) {
154 if ( "uid:"+a->uid() == n ) { 154 if ( "uid:"+a->uid() == n ) {
155 bool res = ExternalAppHandler::instance()->requestDetailsFromKAPI(a->name(), a->email(), a->uid()); 155 bool res = ExternalAppHandler::instance()->requestDetailsFromKAPI(a->name(), a->email(), a->uid());
156 return; 156 return;
157 } 157 }
158 } 158 }
159 } 159 }
160 return; 160 return;
161 } 161 }
162 //requestNameEmailUidListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); 162 //requestNameEmailUidListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/);
163 // the result should now arrive through method insertAttendees 163 // the result should now arrive through method insertAttendees
164 //QString uid = "uid:"+(*it).uid(); 164 //QString uid = "uid:"+(*it).uid();
165#endif 165#endif
166 if ( n.left(6) == "mailto" ) { 166 if ( n.left(6) == "mailto" ) {
167 // qDebug("KOEventViewer::setSource %s ", n.mid(7).latin1()); 167 // qDebug("KOEventViewer::setSource %s ", n.mid(7).latin1());
168#ifndef DESKTOP_VERSION 168#ifndef DESKTOP_VERSION
169 if ( n.mid(7,3) == "ALL" ) { 169 if ( n.mid(7,3) == "ALL" ) {
170 qDebug("all "); 170 qDebug("all ");
171 mailToAttendees( true ); 171 mailToAttendees( true );
172 } else if ( n.mid(7,4) == "RSVP" ) { 172 } else if ( n.mid(7,4) == "RSVP" ) {
173 mailToAttendees( false ); 173 mailToAttendees( false );
174 qDebug("rsvp "); 174 qDebug("rsvp ");
175 } else { 175 } else {
176 QCopEnvelope e("QPE/Application/ompi", "newMail(QString)" ); 176 QCopEnvelope e("QPE/Application/ompi", "newMail(QString)" );
177 e << n.mid(7); 177 e << n.mid(7);
178 } 178 }
179#endif 179#endif
180 180
181 } 181 }
182 182
183 183
184#ifndef KORG_NODCOP 184#ifndef KORG_NODCOP
185 kdDebug() << "KOEventViewer::setSource(): " << n << endl; 185 kdDebug() << "KOEventViewer::setSource(): " << n << endl;
186 QString tmpStr; 186 QString tmpStr;
187 if (n.startsWith("mailto:")) { 187 if (n.startsWith("mailto:")) {
188 KApplication::kApplication()->invokeMailer(n.mid(7),QString::null); 188 KApplication::kApplication()->invokeMailer(n.mid(7),QString::null);
189 //emit showIncidence(n); 189 //emit showIncidence(n);
190 return; 190 return;
191 } else if (n.startsWith("uid:")) { 191 } else if (n.startsWith("uid:")) {
192 DCOPClient *client = KApplication::kApplication()->dcopClient(); 192 DCOPClient *client = KApplication::kApplication()->dcopClient();
193 const QByteArray noParamData; 193 const QByteArray noParamData;
194 const QByteArray paramData; 194 const QByteArray paramData;
195 QByteArray replyData; 195 QByteArray replyData;
196 QCString replyTypeStr; 196 QCString replyTypeStr;
197#define PING_ABBROWSER (client->call("kaddressbook", "KAddressBookIface", "interfaces()", noParamData, replyTypeStr, replyData)) 197#define PING_ABBROWSER (client->call("kaddressbook", "KAddressBookIface", "interfaces()", noParamData, replyTypeStr, replyData))
198 bool foundAbbrowser = PING_ABBROWSER; 198 bool foundAbbrowser = PING_ABBROWSER;
199 199
200 if (foundAbbrowser) { 200 if (foundAbbrowser) {
201 //KAddressbook is already running, so just DCOP to it to bring up the contact editor 201 //KAddressbook is already running, so just DCOP to it to bring up the contact editor
202 //client->send("kaddressbook","KAddressBookIface", 202 //client->send("kaddressbook","KAddressBookIface",
203 QDataStream arg(paramData, IO_WriteOnly); 203 QDataStream arg(paramData, IO_WriteOnly);
204 arg << n.mid(6); 204 arg << n.mid(6);
205 client->send("kaddressbook", "KAddressBookIface", "showContactEditor( QString )", paramData); 205 client->send("kaddressbook", "KAddressBookIface", "showContactEditor( QString )", paramData);
206 return; 206 return;
207 } else { 207 } else {
208 /* 208 /*
209 KaddressBook is not already running. Pass it the UID of the contact via the command line while starting it - its neater. 209 KaddressBook is not already running. Pass it the UID of the contact via the command line while starting it - its neater.
210 We start it without its main interface 210 We start it without its main interface
211 */ 211 */
212 KIconLoader* iconLoader = new KIconLoader(); 212 KIconLoader* iconLoader = new KIconLoader();
213 QString iconPath = iconLoader->iconPath("go",KIcon::Small); 213 QString iconPath = iconLoader->iconPath("go",KIcon::Small);
214 ActionManager::setStartedKAddressBook(true); 214 ActionManager::setStartedKAddressBook(true);
215 tmpStr = "kaddressbook --editor-only --uid "; 215 tmpStr = "kaddressbook --editor-only --uid ";
216 tmpStr += KProcess::quote(n.mid(6)); 216 tmpStr += KProcess::quote(n.mid(6));
217 KRun::runCommand(tmpStr,"KAddressBook",iconPath); 217 KRun::runCommand(tmpStr,"KAddressBook",iconPath);
218 return; 218 return;
219 } 219 }
220 } else { 220 } else {
221 //QTextBrowser::setSource(n); 221 //QTextBrowser::setSource(n);
222 } 222 }
223#endif 223#endif
224} 224}
225void KOEventViewer::mailToAttendees( bool all ) 225void KOEventViewer::mailToAttendees( bool all )
226{ 226{
227 QPtrList<Attendee> attendees = mCurrentIncidence->attendees(); 227 QPtrList<Attendee> attendees = mCurrentIncidence->attendees();
228 if (attendees.count() == 0) return; 228 if (attendees.count() == 0) return;
229 QStringList nameList; 229 QStringList nameList;
230 QStringList emailList; 230 QStringList emailList;
231 QStringList uidList; 231 QStringList uidList;
232 Attendee* a; 232 Attendee* a;
233 for(a=attendees.first();a;a=attendees.next()) { 233 for(a=attendees.first();a;a=attendees.next()) {
234 if ( !all && !a->RSVP() ) continue; 234 if ( !all && !a->RSVP() ) continue;
235 if (!a->email().isEmpty()) { 235 if (!a->email().isEmpty()) {
236 nameList.append (a->name() ); 236 nameList.append (a->name() );
237 emailList.append (a->email() ); 237 emailList.append (a->email() );
238 uidList.append (a->uid() ); 238 uidList.append (a->uid() );
239 } 239 }
240 } 240 }
241 QString uid = "ComposeMailUIpick2"+mMailSubject; 241 QString uid = "ComposeMailUIpick2"+mMailSubject;
242#ifndef DESKTOP_VERSION 242#ifndef DESKTOP_VERSION
243 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); 243 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList);
244#endif 244#endif
245 245
246} 246}
247void KOEventViewer::addTag(const QString & tag,const QString & text) 247void KOEventViewer::addTag(const QString & tag,const QString & text)
248{ 248{
249 int number=text.contains("\n"); 249 int number=text.contains("\n");
250 QString str = "<" + tag + ">"; 250 QString str = "<" + tag + ">";
251 QString tmpText=text; 251 QString tmpText=text;
252 QString tmpStr=str; 252 QString tmpStr=str;
253 if(number !=-1) 253 if(number !=-1)
254 { 254 {
255 if (number > 0) { 255 if (number > 0) {
256 int pos=0; 256 int pos=0;
257 QString tmp; 257 QString tmp;
258 for(int i=0;i<=number;i++) { 258 for(int i=0;i<=number;i++) {
259 pos=tmpText.find("\n"); 259 pos=tmpText.find("\n");
260 tmp=tmpText.left(pos); 260 tmp=tmpText.left(pos);
261 tmpText=tmpText.right(tmpText.length()-pos-1); 261 tmpText=tmpText.right(tmpText.length()-pos-1);
262 tmpStr+=tmp+"<br>"; 262 tmpStr+=tmp+"<br>";
263 } 263 }
264 } 264 }
265 else tmpStr += tmpText; 265 else tmpStr += tmpText;
266 tmpStr+="</" + tag + ">"; 266 tmpStr+="</" + tag + ">";
267 mText.append(tmpStr); 267 mText.append(tmpStr);
268 } 268 }
269 else 269 else
270 { 270 {
271 str += text + "</" + tag + ">"; 271 str += text + "</" + tag + ">";
272 mText.append(str); 272 mText.append(str);
273 } 273 }
274} 274}
275 275
276void KOEventViewer::setColorMode( int m ) 276void KOEventViewer::setColorMode( int m )
277{ 277{
278 mColorMode = m; 278 mColorMode = m;
279} 279}
280void KOEventViewer::appendEvent(Event *event, int mode ) 280void KOEventViewer::appendEvent(Event *event, int mode )
281{ 281{
282 mMailSubject = ""; 282 mMailSubject = "";
283 mCurrentIncidence = event; 283 mCurrentIncidence = event;
284 bool shortDate = KOPrefs::instance()->mShortDateInViewer; 284 bool shortDate = KOPrefs::instance()->mShortDateInViewer;
285 topLevelWidget()->setCaption(i18n("Event Viewer")); 285 topLevelWidget()->setCaption(i18n("Event Viewer"));
286 if ( mode == 0 ) { 286 if ( mode == 0 ) {
287 addTag("h2",deTag(event->summary())); 287 addTag("h2",deTag(event->summary()));
288 } 288 }
289 else { 289 else {
290 if ( mColorMode == 1 ) { 290 if ( mColorMode == 1 ) {
291 mText +="<font color=\"#00A000\">"; 291 mText +="<font color=\"#00A000\">";
292 } 292 }
293 if ( mColorMode == 2 ) { 293 if ( mColorMode == 2 ) {
294 mText +="<font color=\"#C00000\">"; 294 mText +="<font color=\"#C00000\">";
295 } 295 }
296 // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; 296 // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>";
297 if ( mode == 1 ) { 297 if ( mode == 1 ) {
298 addTag("h2",i18n( "Local: " ) +deTag(event->summary())); 298 addTag("h2",i18n( "Local: " ) +deTag(event->summary()));
299 } else { 299 } else {
300 addTag("h2",i18n( "Remote: " ) +deTag(event->summary())); 300 addTag("h2",i18n( "Remote: " ) +deTag(event->summary()));
301 } 301 }
302 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); 302 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) );
303 if ( mColorMode ) 303 if ( mColorMode )
304 mText += "</font>"; 304 mText += "</font>";
305 } 305 }
306 mMailSubject += i18n( "Meeting " )+ event->summary(); 306 mMailSubject += i18n( "Meeting " )+ event->summary();
307 if (event->cancelled ()) { 307 if (event->cancelled ()) {
308 mText +="<font color=\"#B00000\">"; 308 mText +="<font color=\"#B00000\">";
309 addTag("i",i18n("This event has been cancelled!")); 309 addTag("i",i18n("This event has been cancelled!"));
310 mText.append("<br>"); 310 mText.append("<br>");
311 mText += "</font>"; 311 mText += "</font>";
312 mMailSubject += i18n("(cancelled)"); 312 mMailSubject += i18n("(cancelled)");
313 } 313 }
314 if (!event->location().isEmpty()) { 314
315 addTag("b",i18n("Location: "));
316 mText.append(deTag(event->location())+"<br>");
317 mMailSubject += i18n(" at ") + event->location();
318 }
319 if (event->doesFloat()) { 315 if (event->doesFloat()) {
320 if (event->isMultiDay()) { 316 if (event->isMultiDay()) {
321 mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>") 317 mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>")
322 .arg(event->dtStartDateStr(shortDate)) 318 .arg(event->dtStartDateStr(shortDate))
323 .arg(event->dtEndDateStr(shortDate))); 319 .arg(event->dtEndDateStr(shortDate)));
324 } else { 320 } else {
325 mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate ))); 321 mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate )));
326 } 322 }
327 } else { 323 } else {
328 if (event->isMultiDay()) { 324 if (event->isMultiDay()) {
329 mText.append(i18n("<p><b>From:</b> %1</p> ") 325 mText.append(i18n("<p><b>From:</b> %1</p> ")
330 .arg(event->dtStartStr( shortDate))); 326 .arg(event->dtStartStr( shortDate)));
331 mText.append(i18n("<p><b>To:</b> %1</p>") 327 mText.append(i18n("<p><b>To:</b> %1</p>")
332 .arg(event->dtEndStr(shortDate))); 328 .arg(event->dtEndStr(shortDate)));
333 } else { 329 } else {
334 mText.append(i18n("<p><b>On:</b> %1</p> ")
335 .arg(event->dtStartDateStr( shortDate )));
336 mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>") 330 mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>")
337 .arg(event->dtStartTimeStr()) 331 .arg(event->dtStartTimeStr())
338 .arg(event->dtEndTimeStr())); 332 .arg(event->dtEndTimeStr()));
333 mText.append(i18n("<p><b>On:</b> %1</p> ")
334 .arg(event->dtStartDateStr( shortDate )));
339 } 335 }
340 } 336 }
341 337 if (!event->location().isEmpty()) {
338 addTag("b",i18n("Location: "));
339 mText.append(deTag(event->location())+"<br>");
340 mMailSubject += i18n(" at ") + event->location();
341 }
342 if (event->recurrence()->doesRecur()) { 342 if (event->recurrence()->doesRecur()) {
343 343
344 QString recurText = event->recurrence()->recurrenceText(); 344 QString recurText = event->recurrence()->recurrenceText();
345 addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>"); 345 addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>");
346 bool ok; 346 bool ok;
347 QDate start = QDate::currentDate(); 347 QDate start = QDate::currentDate();
348 QDateTime next; 348 QDateTime next;
349 next = event->getNextOccurence( QDateTime::currentDateTime() , &ok ); 349 next = event->getNextOccurence( QDateTime::currentDateTime() , &ok );
350 if ( ok ) { 350 if ( ok ) {
351 addTag("p",i18n("<b>Next recurrence is on:</b>") ); 351 addTag("p",i18n("<b>Next recurrence is on:</b>") );
352 addTag("p", KGlobal::locale()->formatDate( next.date(), shortDate )); 352 addTag("p", KGlobal::locale()->formatDate( next.date(), shortDate ));
353 mMailSubject += i18n(" - " )+ KGlobal::locale()->formatDateTime( next, true ); 353 mMailSubject += i18n(" - " )+ KGlobal::locale()->formatDateTime( next, true );
354 354
355 } else { 355 } else {
356 bool last; 356 bool last;
357 QDate nextd; 357 QDate nextd;
358 nextd = event->recurrence()->getPreviousDate( QDate::currentDate() , &last ); 358 nextd = event->recurrence()->getPreviousDate( QDate::currentDate() , &last );
359 if ( last ) { 359 if ( last ) {
360 addTag("p",i18n("<b>Last recurrence was on:</b>") ); 360 addTag("p",i18n("<b>Last recurrence was on:</b>") );
361 addTag("p", KGlobal::locale()->formatDate( nextd, shortDate )); 361 addTag("p", KGlobal::locale()->formatDate( nextd, shortDate ));
362 } 362 }
363 } 363 }
364 } else { 364 } else {
365 mMailSubject += i18n(" - " )+event->dtStartStr( true ); 365 mMailSubject += i18n(" - " )+event->dtStartStr( true );
366 366
367 } 367 }
368 368
369 369
370 if (event->isAlarmEnabled()) { 370 if (event->isAlarmEnabled()) {
371 Alarm *alarm =event->alarms().first() ; 371 Alarm *alarm =event->alarms().first() ;
372 QDateTime t = alarm->time(); 372 QDateTime t = alarm->time();
373 QString s =i18n("( %1 before )").arg( alarm->offsetText() ); 373 QString s =i18n("( %1 before )").arg( alarm->offsetText() );
374 addTag("p",i18n("<b>Alarm on: ") + s +" </b>"); 374 addTag("p",i18n("<b>Alarm on: ") + s +" </b>");
375 addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); 375 addTag("p", KGlobal::locale()->formatDateTime( t, shortDate ));
376 //addTag("p",s); 376 //addTag("p",s);
377 } 377 }
378 378
379 addTag("b",i18n("Access: ")); 379 addTag("b",i18n("Access: "));
380 mText.append(event->secrecyStr()+"<br>"); 380 mText.append(event->secrecyStr()+"<br>");
381 381
382 382
383 if ( KOPrefs::instance()->mEVshowDetails ) { 383
384 if (!event->description().isEmpty()) {
385 addTag("p",i18n("<b>Details: </b>"));
386 addTag("p",deTag(event->description()));
387 }
388 }
389 formatCategories(event); 384 formatCategories(event);
390 385
391 formatReadOnly(event); 386 formatReadOnly(event);
392 formatAttendees(event); 387 formatAttendees(event);
393 388
394 if ( KOPrefs::instance()->mEVshowCreated ) { 389 if ( KOPrefs::instance()->mEVshowCreated ) {
390#ifdef DESKTOP_VERSION
391 addTag("p",i18n("<b>Created: ") +" </b>"+KGlobal::locale()->formatDateTime( event->created(), shortDate ));
392#else
395 addTag("p",i18n("<b>Created: ") +" </b>"); 393 addTag("p",i18n("<b>Created: ") +" </b>");
396 addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); 394 addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate ));
395#endif
397 396
398 } 397 }
399 if ( KOPrefs::instance()->mEVshowChanged ) { 398 if ( KOPrefs::instance()->mEVshowChanged ) {
399#ifdef DESKTOP_VERSION
400 addTag("p",i18n("<b>Last modified: ") +" </b>" + KGlobal::locale()->formatDateTime( event->lastModified(), shortDate ) );
401#else
400 addTag("p",i18n("<b>Last modified: ") +" </b>"); 402 addTag("p",i18n("<b>Last modified: ") +" </b>");
401 addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); 403 addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate ));
404#endif
402 405
406 }
407 if ( KOPrefs::instance()->mEVshowDetails ) {
408 if (!event->description().isEmpty()) {
409 addTag("p",i18n("<b>Details: </b>"));
410 addTag("p",deTag(event->description()));
411 }
403 } 412 }
404 setText(mText); 413 setText(mText);
405 //QWhatsThis::add(this,mText); 414 //QWhatsThis::add(this,mText);
406 415
407} 416}
408 417
409void KOEventViewer::appendTodo(Todo *event, int mode ) 418void KOEventViewer::appendTodo(Todo *event, int mode )
410{ 419{
411 mMailSubject = ""; 420 mMailSubject = "";
412 mCurrentIncidence = event; 421 mCurrentIncidence = event;
413 topLevelWidget()->setCaption(i18n("Todo Viewer")); 422 topLevelWidget()->setCaption(i18n("Todo Viewer"));
414 bool shortDate = KOPrefs::instance()->mShortDateInViewer; 423 bool shortDate = KOPrefs::instance()->mShortDateInViewer;
415 if (mode == 0 ) 424 if (mode == 0 )
416 addTag("h2",deTag(event->summary())); 425 addTag("h2",deTag(event->summary()));
417 else { 426 else {
418 if ( mColorMode == 1 ) { 427 if ( mColorMode == 1 ) {
419 mText +="<font color=\"#00A000\">"; 428 mText +="<font color=\"#00A000\">";
420 } 429 }
421 if ( mColorMode == 2 ) { 430 if ( mColorMode == 2 ) {
422 mText +="<font color=\"#B00000\">"; 431 mText +="<font color=\"#B00000\">";
423 } 432 }
424 if ( mode == 1 ) { 433 if ( mode == 1 ) {
425 addTag("h2",i18n( "Local: " ) +deTag(event->summary())); 434 addTag("h2",i18n( "Local: " ) +deTag(event->summary()));
426 } else { 435 } else {
427 addTag("h2",i18n( "Remote: " ) +deTag(event->summary())); 436 addTag("h2",i18n( "Remote: " ) +deTag(event->summary()));
428 } 437 }
429 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); 438 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) );
430 if ( mColorMode ) 439 if ( mColorMode )
431 mText += "</font>"; 440 mText += "</font>";
432 } 441 }
433 mMailSubject += i18n( "Todo " )+ event->summary(); 442 mMailSubject += i18n( "Todo " )+ event->summary();
434 443
435 if ( event->percentComplete() == 100 && event->hasCompletedDate() ) { 444 if ( event->percentComplete() == 100 && event->hasCompletedDate() ) {
436 mText +="<font color=\"#B00000\">"; 445 mText +="<font color=\"#B00000\">";
437 addTag("i", i18n("<p><i>Completed on %1</i></p>").arg( event->completedStr(KOPrefs::instance()->mShortDateInViewer) ) ); 446 addTag("i", i18n("<p><i>Completed on %1</i></p>").arg( event->completedStr(KOPrefs::instance()->mShortDateInViewer) ) );
438 mText += "</font>"; 447 mText += "</font>";
439 } else { 448 } else {
440 mText.append(i18n("<p><i>%1 % completed</i></p>") 449 mText.append(i18n("<p><i>%1 % completed</i></p>")
441 .arg(event->percentComplete())); 450 .arg(event->percentComplete()));
442 } 451 }
443 452
444 if (event->cancelled ()) { 453 if (event->cancelled ()) {
445 mText +="<font color=\"#B00000\">"; 454 mText +="<font color=\"#B00000\">";
446 addTag("i",i18n("This todo has been cancelled!")); 455 addTag("i",i18n("This todo has been cancelled!"));
447 mText.append("<br>"); 456 mText.append("<br>");
448 mText += "</font>"; 457 mText += "</font>";
449 mMailSubject += i18n("(cancelled)"); 458 mMailSubject += i18n("(cancelled)");
450 } 459 }
451 460
452 if (!event->location().isEmpty()) { 461
453 addTag("b",i18n("Location: "));
454 mText.append(deTag(event->location())+"<br>");
455 mMailSubject += i18n(" at ") + event->location();
456 }
457 462
458 if (event->recurrence()->doesRecur()) { 463 if (event->recurrence()->doesRecur()) {
459 464
460 QString recurText = event->recurrence()->recurrenceText(); 465 QString recurText = event->recurrence()->recurrenceText();
461 addTag("p","<em>" + i18n("This is a %1 recurring todo.").arg(recurText ) + "</em>"); 466 addTag("p","<em>" + i18n("This is a %1 recurring todo.").arg(recurText ) + "</em>");
462 467
463 } 468 }
464 if (event->hasStartDate()) { 469 if (event->hasStartDate()) {
465 mText.append(i18n("<p><b>Start on:</b> %1</p>").arg(event->dtStartStr(KOPrefs::instance()->mShortDateInViewer))); 470 mText.append(i18n("<p><b>Start on:</b> %1</p>").arg(event->dtStartStr(KOPrefs::instance()->mShortDateInViewer)));
466 } 471 }
467 if (event->hasDueDate()) { 472 if (event->hasDueDate()) {
468 mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(KOPrefs::instance()->mShortDateInViewer))); 473 mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(KOPrefs::instance()->mShortDateInViewer)));
469 mMailSubject += i18n(" - " )+event->dtDueStr( true ); 474 mMailSubject += i18n(" - " )+event->dtDueStr( true );
470 } 475 }
471 476 if (!event->location().isEmpty()) {
477 addTag("b",i18n("Location: "));
478 mText.append(deTag(event->location())+"<br>");
479 mMailSubject += i18n(" at ") + event->location();
480 }
481 mText.append(i18n("<p><b>Priority:</b> %2</p>")
482 .arg(QString::number(event->priority())));
472 483
473 if (event->isAlarmEnabled()) { 484 if (event->isAlarmEnabled()) {
474 Alarm *alarm =event->alarms().first() ; 485 Alarm *alarm =event->alarms().first() ;
475 QDateTime t = alarm->time(); 486 QDateTime t = alarm->time();
476 QString s =i18n("( %1 before )").arg( alarm->offsetText() ); 487 QString s =i18n("( %1 before )").arg( alarm->offsetText() );
477 addTag("p",i18n("<b>Alarm on: ") + s +" </b>"); 488 addTag("p",i18n("<b>Alarm on: ") + s +" </b>");
478 addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); 489 addTag("p", KGlobal::locale()->formatDateTime( t, shortDate ));
479 //addTag("p",s); 490 //addTag("p",s);
480 } 491 }
481 492
482 addTag("b",i18n("Access: ")); 493 addTag("b",i18n("Access: "));
483 mText.append(event->secrecyStr()+"<br>"); 494 mText.append(event->secrecyStr()+"<br>");
484 if ( KOPrefs::instance()->mEVshowDetails ) {
485 if (!event->description().isEmpty()) {
486 addTag("p",i18n("<b>Details: </b>"));
487 addTag("p",deTag(event->description()));
488 }
489 }
490 495
491 formatCategories(event); 496 formatCategories(event);
492 497
493 mText.append(i18n("<p><b>Priority:</b> %2</p>")
494 .arg(QString::number(event->priority())));
495
496 formatReadOnly(event); 498 formatReadOnly(event);
497 formatAttendees(event); 499 formatAttendees(event);
500
501 if ( KOPrefs::instance()->mEVshowCreated ) {
502#ifdef DESKTOP_VERSION
503 addTag("p",i18n("<b>Created: ") +" </b>"+KGlobal::locale()->formatDateTime( event->created(), shortDate ));
504#else
505 addTag("p",i18n("<b>Created: ") +" </b>");
506 addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate ));
507#endif
508
509 }
510 if ( KOPrefs::instance()->mEVshowChanged ) {
511#ifdef DESKTOP_VERSION
512 addTag("p",i18n("<b>Last modified: ") +" </b>" +KGlobal::locale()->formatDateTime( event->lastModified(), shortDate ) );
513#else
514 addTag("p",i18n("<b>Last modified: ") +" </b>");
515 addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate ));
516#endif
517
518 }
498 if ( event->relatedTo() ) { 519 if ( event->relatedTo() ) {
499 addTag("b",i18n("Parent todo:<br>")); 520 addTag("b",i18n("Parent todo:<br>"));
500 mText.append(deTag(event->relatedTo()->summary())+" [" +QString::number(event->relatedTo()->priority()) + "/" + QString::number(((Todo*)event->relatedTo())->percentComplete())+"%] <br>"); 521 mText.append(deTag(event->relatedTo()->summary())+" [" +QString::number(event->relatedTo()->priority()) + "/" + QString::number(((Todo*)event->relatedTo())->percentComplete())+"%] <br>");
501 } 522 }
502 QPtrList<Incidence> Relations = event->relations(); 523 QPtrList<Incidence> Relations = event->relations();
503 Incidence *to; 524 Incidence *to;
504 if ( Relations.first() ) 525 if ( Relations.first() )
505 addTag("b",i18n("Sub todos:<br>")); 526 addTag("b",i18n("Sub todos:<br>"));
506 for (to=Relations.first();to;to=Relations.next()) { 527 for (to=Relations.first();to;to=Relations.next()) {
507 mText.append( deTag(to->summary())+" [" +QString::number(to->priority()) + "/" + QString::number(((Todo*)to)->percentComplete())+"%]<br>"); 528 mText.append( deTag(to->summary())+" [" +QString::number(to->priority()) + "/" + QString::number(((Todo*)to)->percentComplete())+"%]<br>");
508 529
509 } 530 }
510 if ( KOPrefs::instance()->mEVshowCreated ) { 531
511 addTag("p",i18n("<b>Created: ") +" </b>"); 532 if ( KOPrefs::instance()->mEVshowDetails ) {
512 addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); 533 if (!event->description().isEmpty()) {
513 534 addTag("p",i18n("<b>Details: </b>"));
514 } 535 addTag("p",deTag(event->description()));
515 if ( KOPrefs::instance()->mEVshowChanged ) { 536 }
516 addTag("p",i18n("<b>Last modified: ") +" </b>");
517 addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate ));
518
519 } 537 }
520 setText(mText); 538 setText(mText);
521} 539}
522 540
523void KOEventViewer::formatCategories(Incidence *event) 541void KOEventViewer::formatCategories(Incidence *event)
524{ 542{
525 if (!event->categoriesStr().isEmpty()) { 543 if (!event->categoriesStr().isEmpty()) {
526 if (event->categories().count() == 1) { 544 if (event->categories().count() == 1) {
527 addTag("h3",i18n("Category")); 545 addTag("h3",i18n("Category"));
528 } else { 546 } else {
529 addTag("h3",i18n("Categories")); 547 addTag("h3",i18n("Categories"));
530 } 548 }
531 addTag("p",event->categoriesStr()); 549 addTag("p",event->categoriesStr());
532 } 550 }
533} 551}
534void KOEventViewer::formatAttendees(Incidence *event) 552void KOEventViewer::formatAttendees(Incidence *event)
535{ 553{
536 QPtrList<Attendee> attendees = event->attendees(); 554 QPtrList<Attendee> attendees = event->attendees();
537 if (attendees.count()) { 555 if (attendees.count()) {
538 556
539 557
540 QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); 558 QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small);
541 QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small); 559 QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small);
542 addTag("h3",i18n("Organizer")); 560 addTag("h3",i18n("Organizer"));
543 mText.append("<ul><li>"); 561 mText.append("<ul><li>");
544#ifndef KORG_NOKABC 562#ifndef KORG_NOKABC
545 563
546#ifdef DESKTOP_VERSION 564#ifdef DESKTOP_VERSION
547 KABC::AddressBook *add_book = KABC::StdAddressBook::self(); 565 KABC::AddressBook *add_book = KABC::StdAddressBook::self();
548 KABC::Addressee::List addressList; 566 KABC::Addressee::List addressList;
549 addressList = add_book->findByEmail(event->organizer()); 567 addressList = add_book->findByEmail(event->organizer());
550 KABC::Addressee o = addressList.first(); 568 KABC::Addressee o = addressList.first();
551 if (!o.isEmpty() && addressList.size()<2) { 569 if (!o.isEmpty() && addressList.size()<2) {
552 mText += "<a href=\"uid:" + o.uid() + "\">"; 570 mText += "<a href=\"uid:" + o.uid() + "\">";
553 mText += o.formattedName(); 571 mText += o.formattedName();
554 mText += "</a>\n"; 572 mText += "</a>\n";
555 } else { 573 } else {
556 mText.append(event->organizer()); 574 mText.append(event->organizer());
557 } 575 }
558#else //DESKTOP_VERSION 576#else //DESKTOP_VERSION
559 mText += "<a href=\"uid:organizer\">"; 577 mText += "<a href=\"uid:organizer\">";
560 mText += event->organizer(); 578 mText += event->organizer();
561 mText += "</a>\n"; 579 mText += "</a>\n";
562#endif //DESKTOP_VERSION 580#endif //DESKTOP_VERSION
563 581
564 582
565#else 583#else
566 mText.append(event->organizer()); 584 mText.append(event->organizer());
567#endif 585#endif
568 586
569 if (iconPath) { 587 if (iconPath) {
570 mText += " <a href=\"mailto:" + event->organizer() + "\">"; 588 mText += " <a href=\"mailto:" + event->organizer() + "\">";
571 mText += "<IMG src=\"" + iconPath + "\">"; 589 mText += "<IMG src=\"" + iconPath + "\">";
572 mText += "</a>\n"; 590 mText += "</a>\n";
573 } 591 }
574 mText.append("</li></ul>"); 592 mText.append("</li></ul>");
575 593
576 addTag("h3",i18n("Attendees")); 594 addTag("h3",i18n("Attendees"));
577 Attendee *a; 595 Attendee *a;
578 mText.append("<ul>"); 596 mText.append("<ul>");
579 int a_count = 0; 597 int a_count = 0;
580 int a_count_nr = 0; 598 int a_count_nr = 0;
581 599
582 for(a=attendees.first();a;a=attendees.next()) { 600 for(a=attendees.first();a;a=attendees.next()) {
583#ifndef KORG_NOKABC 601#ifndef KORG_NOKABC
584#ifdef DESKTOP_VERSION 602#ifdef DESKTOP_VERSION
585 if (a->name().isEmpty()) { 603 if (a->name().isEmpty()) {
586 addressList = add_book->findByEmail(a->email()); 604 addressList = add_book->findByEmail(a->email());
587 KABC::Addressee o = addressList.first(); 605 KABC::Addressee o = addressList.first();
588 if (!o.isEmpty() && addressList.size()<2) { 606 if (!o.isEmpty() && addressList.size()<2) {
589 mText += "<a href=\"uid:" + o.uid() + "\">"; 607 mText += "<a href=\"uid:" + o.uid() + "\">";
590 mText += o.formattedName(); 608 mText += o.formattedName();
591 mText += "</a>\n"; 609 mText += "</a>\n";
592 } else { 610 } else {
593 mText += "<li>"; 611 mText += "<li>";
594 mText.append(a->email()); 612 mText.append(a->email());
595 mText += "\n"; 613 mText += "\n";
596 } 614 }
597 } else { 615 } else {
598 mText += "<li><a href=\"uid:" + a->uid() + "\">"; 616 mText += "<li><a href=\"uid:" + a->uid() + "\">";
599 if (!a->name().isEmpty()) mText += a->name(); 617 if (!a->name().isEmpty()) mText += a->name();
600 else mText += a->email(); 618 else mText += a->email();
601 mText += "</a>\n"; 619 mText += "</a>\n";
602 } 620 }
603#else //DESKTOP_VERSION 621#else //DESKTOP_VERSION
604 mText += "<li><a href=\"uid:" + a->uid() + "\">"; 622 mText += "<li><a href=\"uid:" + a->uid() + "\">";
605 if (!a->name().isEmpty()) mText += a->name(); 623 if (!a->name().isEmpty()) mText += a->name();
606 else mText += a->email(); 624 else mText += a->email();
607 mText += "</a>\n"; 625 mText += "</a>\n";
608#endif //DESKTOP_VERSION 626#endif //DESKTOP_VERSION
609#else 627#else
610 //qDebug("nokabc "); 628 //qDebug("nokabc ");
611 mText += "<li><a href=\"uid:" + a->uid() + "\">"; 629 mText += "<li><a href=\"uid:" + a->uid() + "\">";
612 if (!a->name().isEmpty()) mText += a->name(); 630 if (!a->name().isEmpty()) mText += a->name();
613 else mText += a->email(); 631 else mText += a->email();
614 mText += "</a>\n"; 632 mText += "</a>\n";
615#endif 633#endif
616 634
617 635
618 if (!a->email().isEmpty()) { 636 if (!a->email().isEmpty()) {
619 if (iconPath) { 637 if (iconPath) {
620 mText += "<a href=\"mailto:" + a->name() +" <" + a->email() + ">:" + mMailSubject + "\">"; 638 mText += "<a href=\"mailto:" + a->name() +" <" + a->email() + ">:" + mMailSubject + "\">";
621 if ( a->RSVP() ) { 639 if ( a->RSVP() ) {
622 ++a_count_nr; 640 ++a_count_nr;
623 mText += "<IMG src=\"" + iconPath + "\">"; 641 mText += "<IMG src=\"" + iconPath + "\">";
624 } 642 }
625 else { 643 else {
626 ++a_count; 644 ++a_count;
627 mText += "<IMG src=\"" + NOiconPath + "\">"; 645 mText += "<IMG src=\"" + NOiconPath + "\">";
628 } 646 }
629 mText += "</a>\n"; 647 mText += "</a>\n";
630 } 648 }
631 } 649 }
632 if (a->status() != Attendee::NeedsAction ) 650 if (a->status() != Attendee::NeedsAction )
633 mText +="[" + a->statusStr() + "] "; 651 mText +="[" + a->statusStr() + "] ";
634 if (a->role() == Attendee::Chair ) 652 if (a->role() == Attendee::Chair )
635 mText +="(" + a->roleStr().left(1) + ".)"; 653 mText +="(" + a->roleStr().left(1) + ".)";
636 } 654 }
637 mText.append("</li></ul>"); 655 mText.append("</li></ul>");
638 if ( (a_count+a_count_nr) > 1 ) { 656 if ( (a_count+a_count_nr) > 1 ) {
639 mText += "<a href=\"mailto:ALL\">"; 657 mText += "<a href=\"mailto:ALL\">";
640 mText += i18n( "Mail to all" ); 658 mText += i18n( "Mail to all" );
641 mText += "</a> ( "; 659 mText += "</a> ( ";
642 mText += "<IMG src=\"" + iconPath + "\">"; 660 mText += "<IMG src=\"" + iconPath + "\">";
643 mText += i18n( " and " ); 661 mText += i18n( " and " );
644 mText += "<IMG src=\"" + NOiconPath + "\"> )"; 662 mText += "<IMG src=\"" + NOiconPath + "\"> )";
645 mText += "<br>\n"; 663 mText += "<br>\n";
646 664
647 665
648 } 666 }
649 if ( a_count_nr > 1 ) { 667 if ( a_count_nr > 1 ) {
650 mText += "<a href=\"mailto:RSVP\">"; 668 mText += "<a href=\"mailto:RSVP\">";
651 mText += i18n( "Mail to selected" ); 669 mText += i18n( "Mail to selected" );
652 mText += "</a> ( "; 670 mText += "</a> ( ";
653 mText += i18n( "<IMG src=\"%1\"> only )").arg ( iconPath ); 671 mText += i18n( "<IMG src=\"%1\"> only )").arg ( iconPath );
654 mText += "<br>\n"; 672 mText += "<br>\n";
655 } 673 }
656 } 674 }
657 675
658} 676}
659void KOEventViewer::appendJournal(Journal *jour, int mode ) 677void KOEventViewer::appendJournal(Journal *jour, int mode )
660{ 678{
661 bool shortDate = KOPrefs::instance()->mShortDateInViewer; 679 bool shortDate = KOPrefs::instance()->mShortDateInViewer;
662 if (mode == 0 ) { 680 if (mode == 0 ) {
663 addTag("h2",i18n("Journal from: ")); 681 addTag("h2",i18n("Journal from: "));
664 } 682 }
665 else { 683 else {
666 if ( mode == 1 ) { 684 if ( mode == 1 ) {
667 addTag("h2",i18n( "Local: " ) +i18n("Journal from: ")); 685 addTag("h2",i18n( "Local: " ) +i18n("Journal from: "));
668 } else { 686 } else {
669 addTag("h2",i18n( "Remote: " ) +i18n("Journal from: ")); 687 addTag("h2",i18n( "Remote: " ) +i18n("Journal from: "));
670 } 688 }
671 } 689 }
672 topLevelWidget()->setCaption("Journal Viewer"); 690 topLevelWidget()->setCaption("Journal Viewer");
673 mText.append(i18n("<h3> %1 </h3> ").arg(jour->dtStartDateStr(KOPrefs::instance()->mShortDateInViewer))); 691 mText.append(i18n("<h3> %1 </h3> ").arg(jour->dtStartDateStr(KOPrefs::instance()->mShortDateInViewer)));
674 addTag("b",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(jour->lastModified(),shortDate ) ); 692 addTag("b",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(jour->lastModified(),shortDate ) );
675 if (!jour->description().isEmpty()) { 693 if (!jour->description().isEmpty()) {
676 addTag("p",deTag(jour->description())); 694 addTag("p",deTag(jour->description()));
677 } 695 }
678 setText(mText); 696 setText(mText);
679} 697}
680 698
681void KOEventViewer::formatReadOnly(Incidence *event) 699void KOEventViewer::formatReadOnly(Incidence *event)
682{ 700{
683 if (event->isReadOnly()) { 701 if (event->isReadOnly()) {
684 addTag("p","<em>(" + i18n("read-only") + ")</em>"); 702 addTag("p","<em>(" + i18n("read-only") + ")</em>");
685 } 703 }
686} 704}
687void KOEventViewer::setSyncMode( bool b ) 705void KOEventViewer::setSyncMode( bool b )
688{ 706{
689 mSyncMode = b; 707 mSyncMode = b;
690} 708}
691 709
692void KOEventViewer::setTodo(Todo *event, bool clearV ) 710void KOEventViewer::setTodo(Todo *event, bool clearV )
693{ 711{
694 if ( clearV ) 712 if ( clearV )
695 clearEvents(); 713 clearEvents();
696 if ( mSyncMode ) { 714 if ( mSyncMode ) {
697 if ( clearV ) 715 if ( clearV )
698 appendTodo(event,1 ); 716 appendTodo(event,1 );
699 else 717 else
700 appendTodo(event,2); 718 appendTodo(event,2);
701 } else 719 } else
702 appendTodo(event); 720 appendTodo(event);
703} 721}
704void KOEventViewer::setJournal(Journal *event, bool clearV ) 722void KOEventViewer::setJournal(Journal *event, bool clearV )
705{ 723{
706 if ( clearV ) 724 if ( clearV )
707 clearEvents(); 725 clearEvents();
708 if ( mSyncMode ) { 726 if ( mSyncMode ) {
709 if ( clearV ) 727 if ( clearV )
710 appendJournal(event, 1); 728 appendJournal(event, 1);
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index 65d6acf..b175f9a 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -453,518 +453,519 @@ int MonthViewItem::width(const QListBox *lb) const
453 //qDebug("ret wid %d ", lb->width()); 453 //qDebug("ret wid %d ", lb->width());
454 return lb->width(); 454 return lb->width();
455} 455}
456 456
457 457
458MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) 458MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par )
459 : KNoScrollListBox( par ), 459 : KNoScrollListBox( par ),
460 mMonthView( parent ) 460 mMonthView( parent )
461{ 461{
462 //QVBoxLayout *topLayout = new QVBoxLayout( this ); 462 //QVBoxLayout *topLayout = new QVBoxLayout( this );
463 currentPalette = 0; 463 currentPalette = 0;
464 // mLabel = new QLabel( this );QPushButton 464 // mLabel = new QLabel( this );QPushButton
465 mLabel = new QPushButton( this ); 465 mLabel = new QPushButton( this );
466 //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); 466 //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain );
467 //mLabel->setLineWidth( 1 ); 467 //mLabel->setLineWidth( 1 );
468 //mLabel->setAlignment( AlignCenter ); 468 //mLabel->setAlignment( AlignCenter );
469 mLabel->setFlat( true ); 469 mLabel->setFlat( true );
470 mLabel->setFocusPolicy(NoFocus); 470 mLabel->setFocusPolicy(NoFocus);
471 //mItemList = new KNoScrollListBox( this ); 471 //mItemList = new KNoScrollListBox( this );
472 setMinimumSize( 10, 10 ); 472 setMinimumSize( 10, 10 );
473 setFrameStyle( QFrame::Panel | QFrame::Plain ); 473 setFrameStyle( QFrame::Panel | QFrame::Plain );
474 setLineWidth( 1 ); 474 setLineWidth( 1 );
475 //topLayout->addWidget( mItemList ); 475 //topLayout->addWidget( mItemList );
476 mLabel->raise(); 476 mLabel->raise();
477 // QColor( 0,0,255 ) QColor( 160,1600,255 ) 477 // QColor( 0,0,255 ) QColor( 160,1600,255 )
478 mStandardPalette = palette(); 478 mStandardPalette = palette();
479 mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); 479 mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) );
480 480
481 enableScrollBars( false ); 481 enableScrollBars( false );
482 updateConfig(); 482 updateConfig();
483 //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); 483 //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() ));
484 connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); 484 connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() ));
485 connect( this , SIGNAL( doubleClicked( QListBoxItem *) ), 485 connect( this , SIGNAL( doubleClicked( QListBoxItem *) ),
486 SLOT( defaultAction( QListBoxItem * ) ) ); 486 SLOT( defaultAction( QListBoxItem * ) ) );
487 connect( this, SIGNAL( rightButtonPressed( QListBoxItem *, 487 connect( this, SIGNAL( rightButtonPressed( QListBoxItem *,
488 const QPoint &) ), 488 const QPoint &) ),
489 SLOT( contextMenu( QListBoxItem * ) ) ); 489 SLOT( contextMenu( QListBoxItem * ) ) );
490 connect( this, SIGNAL( highlighted( QListBoxItem *) ), 490 connect( this, SIGNAL( highlighted( QListBoxItem *) ),
491 SLOT( selection( QListBoxItem * ) ) ); 491 SLOT( selection( QListBoxItem * ) ) );
492 492
493 /* 493 /*
494 connect( this, SIGNAL( clicked( QListBoxItem * ) ), 494 connect( this, SIGNAL( clicked( QListBoxItem * ) ),
495 SLOT( selection( QListBoxItem * ) ) ); 495 SLOT( selection( QListBoxItem * ) ) );
496 */ 496 */
497} 497}
498#ifdef DESKTOP_VERSION 498#ifdef DESKTOP_VERSION
499QToolTipGroup *MonthViewCell::toolTipGroup() 499QToolTipGroup *MonthViewCell::toolTipGroup()
500{ 500{
501 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); 501 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0);
502 return mToolTipGroup; 502 return mToolTipGroup;
503} 503}
504#endif 504#endif
505 505
506void MonthViewCell::setDate( const QDate &date ) 506void MonthViewCell::setDate( const QDate &date )
507{ 507{
508 // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; 508 // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl;
509 mDate = date; 509 mDate = date;
510 510
511 511
512 512
513 //resizeEvent( 0 ); 513 //resizeEvent( 0 );
514} 514}
515 515
516QDate MonthViewCell::date() const 516QDate MonthViewCell::date() const
517{ 517{
518 return mDate; 518 return mDate;
519} 519}
520 520
521void MonthViewCell::setPrimary( bool primary ) 521void MonthViewCell::setPrimary( bool primary )
522{ 522{
523 mPrimary = primary; 523 mPrimary = primary;
524 //setMyPalette(); 524 //setMyPalette();
525} 525}
526void MonthViewCell::setMyPalette() 526void MonthViewCell::setMyPalette()
527{ 527{
528 528
529 if ( mHoliday) { 529 if ( mHoliday) {
530 if ( currentPalette == 1 ) return; 530 if ( currentPalette == 1 ) return;
531 mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) )); 531 mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) ));
532 setPalette( mHolidayPalette ); 532 setPalette( mHolidayPalette );
533 //mLabel->setPalette( mHolidayPalette ); 533 //mLabel->setPalette( mHolidayPalette );
534 currentPalette = 1; 534 currentPalette = 1;
535 535
536 } else { 536 } else {
537 if ( mPrimary ) { 537 if ( mPrimary ) {
538 if ( currentPalette == 2 ) return; 538 if ( currentPalette == 2 ) return;
539 mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); 539 mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) ));
540 //mLabel->setPalette( mPrimaryPalette ); 540 //mLabel->setPalette( mPrimaryPalette );
541 setPalette( mPrimaryPalette ); 541 setPalette( mPrimaryPalette );
542 currentPalette = 2; 542 currentPalette = 2;
543 543
544 } else { 544 } else {
545 if ( currentPalette == 3 ) return; 545 if ( currentPalette == 3 ) return;
546 setPalette( mNonPrimaryPalette ); 546 setPalette( mNonPrimaryPalette );
547 mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); 547 mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) ));
548 //mLabel->setPalette( mNonPrimaryPalette );; 548 //mLabel->setPalette( mNonPrimaryPalette );;
549 currentPalette = 3; 549 currentPalette = 3;
550 } 550 }
551 } 551 }
552 //QPalette pal = palette(); 552 //QPalette pal = palette();
553 553
554 //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); 554 //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) ));
555} 555}
556QPalette MonthViewCell::getPalette () 556QPalette MonthViewCell::getPalette ()
557{ 557{
558 if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) 558 if ( !KOPrefs::instance()->mMonthViewUsesDayColors )
559 return mStandardPalette; 559 return mStandardPalette;
560 if ( mHoliday) { 560 if ( mHoliday) {
561 return mHolidayPalette ; 561 return mHolidayPalette ;
562 } else { 562 } else {
563 if ( mPrimary ) { 563 if ( mPrimary ) {
564 return mPrimaryPalette ; 564 return mPrimaryPalette ;
565 } 565 }
566 } 566 }
567 return mNonPrimaryPalette; 567 return mNonPrimaryPalette;
568} 568}
569bool MonthViewCell::isPrimary() const 569bool MonthViewCell::isPrimary() const
570{ 570{
571 return mPrimary; 571 return mPrimary;
572} 572}
573 573
574void MonthViewCell::setHoliday( bool holiday ) 574void MonthViewCell::setHoliday( bool holiday )
575{ 575{
576 mHoliday = holiday; 576 mHoliday = holiday;
577 //setMyPalette(); 577 //setMyPalette();
578} 578}
579 579
580void MonthViewCell::setHoliday( const QString &holiday ) 580void MonthViewCell::setHoliday( const QString &holiday )
581{ 581{
582 mHolidayString = holiday; 582 mHolidayString = holiday;
583 583
584 if ( !holiday.isEmpty() ) { 584 if ( !holiday.isEmpty() ) {
585 setHoliday( true ); 585 setHoliday( true );
586 } 586 }
587} 587}
588 588
589void MonthViewCell::startUpdateCell() 589void MonthViewCell::startUpdateCell()
590{ 590{
591 mdayCount = 0; 591 mdayCount = 0;
592 setFocusPolicy(NoFocus); 592 setFocusPolicy(NoFocus);
593 if ( !mMonthView->isUpdatePossible() ) 593 if ( !mMonthView->isUpdatePossible() )
594 return; 594 return;
595 MonthViewItem *mitem = (MonthViewItem*) firstItem (); 595 MonthViewItem *mitem = (MonthViewItem*) firstItem ();
596 while ( mitem ) { 596 while ( mitem ) {
597 mitem->setBlockRepaint( true ); 597 mitem->setBlockRepaint( true );
598 mitem = (MonthViewItem *)mitem->next(); 598 mitem = (MonthViewItem *)mitem->next();
599 } 599 }
600 if ( mAvailItemList.count() > 20 ) { 600 if ( mAvailItemList.count() > 20 ) {
601 mAvailItemList.setAutoDelete( true ); 601 mAvailItemList.setAutoDelete( true );
602 mAvailItemList.clear(); 602 mAvailItemList.clear();
603 mAvailItemList.setAutoDelete( false ); 603 mAvailItemList.setAutoDelete( false );
604 } 604 }
605 /* 605 /*
606 if ( !isVisible() ){ 606 if ( !isVisible() ){
607 return; 607 return;
608 } 608 }
609 */ 609 */
610 // qDebug("MonthViewCell::updateCell() "); 610 // qDebug("MonthViewCell::updateCell() ");
611 setPrimary( mDate.month()%2 ); 611 setPrimary( mDate.month()%2 );
612 setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); 612 setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays);
613 if ( mDate == QDate::currentDate() ) { 613 if ( mDate == QDate::currentDate() ) {
614 setLineWidth( 3 ); 614 setLineWidth( 3 );
615 } else { 615 } else {
616 setLineWidth( 1 ); 616 setLineWidth( 1 );
617 } 617 }
618 MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem (); 618 MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem ();
619 //clear(); 619 //clear();
620 while ( CurrentAvailItem ) { 620 while ( CurrentAvailItem ) {
621 MonthViewItem *item = CurrentAvailItem; 621 MonthViewItem *item = CurrentAvailItem;
622 CurrentAvailItem = (MonthViewItem *)item->next(); 622 CurrentAvailItem = (MonthViewItem *)item->next();
623 mAvailItemList.append( item ); 623 mAvailItemList.append( item );
624 takeItem ( item ); 624 takeItem ( item );
625 } 625 }
626 626
627#ifdef DESKTOP_VERSION 627#ifdef DESKTOP_VERSION
628 QToolTip::remove(this); 628 QToolTip::remove(this);
629#endif 629#endif
630 mToolTip.clear(); 630 mToolTip.clear();
631 //qApp->processEvents(); 631 //qApp->processEvents();
632#if 0 632#if 0
633 if ( !mHolidayString.isEmpty() ) { 633 if ( !mHolidayString.isEmpty() ) {
634 MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); 634 MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString );
635 item->setPalette( mHolidayPalette ); 635 item->setPalette( mHolidayPalette );
636 insertItem( item ); 636 insertItem( item );
637 mToolTip.append ( mHolidayString ); 637 mToolTip.append ( mHolidayString );
638 } 638 }
639#endif 639#endif
640} 640}
641 641
642int MonthViewCell::insertEvent(Event *event) 642int MonthViewCell::insertEvent(Event *event)
643{ 643{
644 bool useToolTips = true; 644 bool useToolTips = true;
645#ifndef DEKSTOP_VERSION 645#ifndef DESKTOP_VERSION
646 useToolTips = false; 646 useToolTips = false;
647#endif 647#endif
648 QString mToolTipText; 648 QString mToolTipText;
649 setFocusPolicy(WheelFocus); 649 setFocusPolicy(WheelFocus);
650 if ( !(event->doesRecur() == Recurrence::rNone) ) { 650 if ( !(event->doesRecur() == Recurrence::rNone) ) {
651 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) 651 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily )
652 return mdayCount; 652 return mdayCount;
653 else 653 else
654 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) 654 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly )
655 return mdayCount; 655 return mdayCount;
656 } 656 }
657 657
658 if ( event->isHoliday()) { 658 if ( event->isHoliday()) {
659 setHoliday( true ); 659 setHoliday( true );
660 if ( mDate.dayOfWeek() == 7 ) 660 if ( mDate.dayOfWeek() == 7 )
661 setLineWidth( 3 ); 661 setLineWidth( 3 );
662 } 662 }
663 QString text; 663 QString text;
664 int multiday = 0;// 1 = start, 2 = midddle, 3 = end day 664 int multiday = 0;// 1 = start, 2 = midddle, 3 = end day
665 if (event->isMultiDay()) { 665 if (event->isMultiDay()) {
666 QString prefix = "<->";multiday = 2; 666 QString prefix = "<->";multiday = 2;
667 QString time; 667 QString time;
668 if ( event->doesRecur() ) { 668 if ( event->doesRecur() ) {
669 if ( event->recursOn( mDate) ) { 669 if ( event->recursOn( mDate) ) {
670 prefix ="->" ;multiday = 1; 670 prefix ="->" ;multiday = 1;
671 } 671 }
672 else { 672 else {
673 int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); 673 int days = event->dtStart().date().daysTo ( event->dtEnd().date() );
674 if ( event->recursOn( mDate.addDays( -days)) ) { 674 if ( event->recursOn( mDate.addDays( -days)) ) {
675 prefix ="<-" ;multiday = 3; 675 prefix ="<-" ;multiday = 3;
676 } 676 }
677 } 677 }
678 678
679 } else { 679 } else {
680 if (mDate == event->dtStart().date()) { 680 if (mDate == event->dtStart().date()) {
681 prefix ="->" ;multiday = 1; 681 prefix ="->" ;multiday = 1;
682 } else if (mDate == event->dtEnd().date()) { 682 } else if (mDate == event->dtEnd().date()) {
683 prefix ="<-" ;multiday = 3; 683 prefix ="<-" ;multiday = 3;
684 } 684 }
685 } 685 }
686 if ( !event->doesFloat() ) { 686 if ( !event->doesFloat() ) {
687 if ( mDate == event->dtStart().date () ) 687 if ( mDate == event->dtStart().date () )
688 time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; 688 time = KGlobal::locale()->formatTime(event->dtStart().time())+" ";
689 else if ( mDate == event->dtEnd().date () ) 689 else if ( mDate == event->dtEnd().date () )
690 time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; 690 time = KGlobal::locale()->formatTime(event->dtEnd().time())+" ";
691 691
692 } 692 }
693 text = time + event->summary(); 693 text = time + event->summary();
694 if ( useToolTips ) 694 if ( useToolTips )
695 mToolTipText += prefix + text; 695 mToolTipText += prefix + text;
696 } else { 696 } else {
697 if (event->doesFloat()) { 697 if (event->doesFloat()) {
698 text = event->summary(); 698 text = event->summary();
699 if ( useToolTips ) 699 if ( useToolTips )
700 mToolTipText += text; 700 mToolTipText += text;
701 } 701 }
702 else { 702 else {
703 text = KGlobal::locale()->formatTime(event->dtStart().time()); 703 text = KGlobal::locale()->formatTime(event->dtStart().time());
704 text += " " + event->summary(); 704 text += " " + event->summary();
705 if ( useToolTips ) 705 if ( useToolTips )
706 mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); 706 mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary();
707 } 707 }
708 } 708 }
709 if ( useToolTips && ! event->location().isEmpty() ) { 709 if ( useToolTips && ! event->location().isEmpty() ) {
710 mToolTipText += " (" + event->location() +")"; 710 mToolTipText += " (" + event->location() +")";
711 } 711 }
712 MonthViewItem *item ; 712 MonthViewItem *item ;
713 713
714 if ( mAvailItemList.count() ) { 714 if ( mAvailItemList.count() ) {
715 item = mAvailItemList.first(); 715 item = mAvailItemList.first();
716 mAvailItemList.remove( item ); 716 mAvailItemList.remove( item );
717 item->recycle( event, mDate, text ); 717 item->recycle( event, mDate, text );
718 } else { 718 } else {
719 item = new MonthViewItem( event, mDate, text ); 719 item = new MonthViewItem( event, mDate, text );
720 } 720 }
721 721
722 QPalette pal; 722 QPalette pal;
723 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { 723 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
724 QStringList categories = event->categories(); 724 QStringList categories = event->categories();
725 QString cat = categories.first(); 725 QString cat = categories.first();
726 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { 726 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) {
727 pal = getPalette(); 727 pal = getPalette();
728 if (cat.isEmpty()) { 728 if (cat.isEmpty()) {
729 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); 729 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
730 } else { 730 } else {
731 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); 731 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
732 } 732 }
733 733
734 } else { 734 } else {
735 if (cat.isEmpty()) { 735 if (cat.isEmpty()) {
736 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); 736 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
737 } else { 737 } else {
738 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); 738 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
739 } 739 }
740 } 740 }
741 741
742 } else { 742 } else {
743 pal = mStandardPalette ; 743 pal = mStandardPalette ;
744 } 744 }
745 item->setPalette( pal ); 745 item->setPalette( pal );
746 item->setRecur( event->recurrence()->doesRecur() ); 746 item->setRecur( event->recurrence()->doesRecur() );
747 item->setAlarm( event->isAlarmEnabled() && multiday < 2 ); 747 item->setAlarm( event->isAlarmEnabled() && multiday < 2 );
748 item->setMoreInfo( event->description().length() > 0 ); 748 item->setMoreInfo( event->description().length() > 0 );
749#ifdef DESKTOP_VERSION 749#ifdef DESKTOP_VERSION
750 Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, 750 Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails,
751 KOPrefs::instance()->email()); 751 KOPrefs::instance()->email());
752 if ( me != 0 ) { 752 if ( me != 0 ) {
753 if ( me->status() == Attendee::NeedsAction && me->RSVP()) 753 if ( me->status() == Attendee::NeedsAction && me->RSVP())
754 item->setReply(true && multiday < 2); 754 item->setReply(true && multiday < 2);
755 else 755 else
756 item->setReply(false); 756 item->setReply(false);
757 } else 757 } else
758 item->setReply(false); 758 item->setReply(false);
759#endif 759#endif
760 item->setMultiDay( multiday ); 760 item->setMultiDay( multiday );
761 if ( multiday ) { 761 if ( multiday ) {
762 insertItem( item ,mdayCount); 762 insertItem( item ,mdayCount);
763 ++mdayCount; 763 ++mdayCount;
764 } else { 764 } else {
765 uint i; 765 uint i;
766 int pos = mdayCount; 766 int pos = mdayCount;
767 for ( i = mdayCount; i < count();++i ) { 767 for ( i = mdayCount; i < count();++i ) {
768 QListBoxItem* it = this->item ( i ); 768 QListBoxItem* it = this->item ( i );
769 if ( text < it->text() ) { 769 if ( text < it->text() ) {
770 pos = i; 770 pos = i;
771 break; 771 break;
772 } 772 }
773 ++pos; 773 ++pos;
774 } 774 }
775 insertItem( item ,pos); 775 insertItem( item ,pos);
776 } 776 }
777 if ( useToolTips ) 777 if ( useToolTips ) {
778 mToolTip.append( mToolTipText ); 778 mToolTip.append( mToolTipText );
779 }
779 return mdayCount; 780 return mdayCount;
780} 781}
781void MonthViewCell::insertTodo(Todo *todo) 782void MonthViewCell::insertTodo(Todo *todo)
782{ 783{
783 setFocusPolicy(WheelFocus); 784 setFocusPolicy(WheelFocus);
784 QString text; 785 QString text;
785 if (todo->hasDueDate()) { 786 if (todo->hasDueDate()) {
786 if (!todo->doesFloat()) { 787 if (!todo->doesFloat()) {
787 text += KGlobal::locale()->formatTime(todo->dtDue().time()); 788 text += KGlobal::locale()->formatTime(todo->dtDue().time());
788 text += " "; 789 text += " ";
789 } 790 }
790 } 791 }
791 text += todo->summary(); 792 text += todo->summary();
792 MonthViewItem *item ; 793 MonthViewItem *item ;
793 if ( mAvailItemList.count() ) { 794 if ( mAvailItemList.count() ) {
794 item = mAvailItemList.first(); 795 item = mAvailItemList.first();
795 mAvailItemList.remove( item ); 796 mAvailItemList.remove( item );
796 item->recycle( todo, mDate, text ); 797 item->recycle( todo, mDate, text );
797 } else { 798 } else {
798 item = new MonthViewItem( todo, mDate, text ); 799 item = new MonthViewItem( todo, mDate, text );
799 } 800 }
800 //MonthViewItem *item = new MonthViewItem( todo, mDate, text ); 801 //MonthViewItem *item = new MonthViewItem( todo, mDate, text );
801 //item->setPalette( mStandardPalette ); 802 //item->setPalette( mStandardPalette );
802 QPalette pal; 803 QPalette pal;
803 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { 804 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
804 QStringList categories = todo->categories(); 805 QStringList categories = todo->categories();
805 QString cat = categories.first(); 806 QString cat = categories.first();
806 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { 807 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) {
807 pal = getPalette(); 808 pal = getPalette();
808 if (cat.isEmpty()) { 809 if (cat.isEmpty()) {
809 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); 810 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
810 } else { 811 } else {
811 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); 812 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
812 } 813 }
813 814
814 } else { 815 } else {
815 if (cat.isEmpty()) { 816 if (cat.isEmpty()) {
816 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); 817 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
817 } else { 818 } else {
818 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); 819 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
819 } 820 }
820 } 821 }
821 822
822 } else { 823 } else {
823 pal = mStandardPalette ; 824 pal = mStandardPalette ;
824 } 825 }
825 item->setPalette( pal ); 826 item->setPalette( pal );
826 item->setRecur( todo->recurrence()->doesRecur() ); 827 item->setRecur( todo->recurrence()->doesRecur() );
827 item->setAlarm( todo->isAlarmEnabled() ); 828 item->setAlarm( todo->isAlarmEnabled() );
828 item->setMoreInfo( todo->description().length() > 0 ); 829 item->setMoreInfo( todo->description().length() > 0 );
829 insertItem( item , count()); 830 insertItem( item , count());
830#ifdef DESKTOP_VERSION 831#ifdef DESKTOP_VERSION
831 mToolTip.append( text ); 832 mToolTip.append( text );
832#endif 833#endif
833} 834}
834void MonthViewCell::repaintfinishUpdateCell() 835void MonthViewCell::repaintfinishUpdateCell()
835{ 836{
836 MonthViewItem *mitem = (MonthViewItem*) firstItem (); 837 MonthViewItem *mitem = (MonthViewItem*) firstItem ();
837 while ( mitem ) { 838 while ( mitem ) {
838 mitem->setBlockRepaint( false ); 839 mitem->setBlockRepaint( false );
839 updateItem ( mitem ); 840 updateItem ( mitem );
840 mitem = (MonthViewItem *)mitem->next(); 841 mitem = (MonthViewItem *)mitem->next();
841 } 842 }
842} 843}
843void MonthViewCell::finishUpdateCell() 844void MonthViewCell::finishUpdateCell()
844{ 845{
845 846
846 847
847 848
848#ifdef DESKTOP_VERSION 849#ifdef DESKTOP_VERSION
849 if (mToolTip.count() > 0 ) { 850 if (mToolTip.count() > 0 ) {
850 mToolTip.sort(); 851 mToolTip.sort();
851 QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),""); 852 QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),"");
852 } 853 }
853#endif 854#endif
854 //sort(); 855 //sort();
855 //setMyPalette(); 856 //setMyPalette();
856 setMyPalette(); 857 setMyPalette();
857 858
858 resizeEvent( 0 ); 859 resizeEvent( 0 );
859 860
860} 861}
861void MonthViewCell::updateCell() 862void MonthViewCell::updateCell()
862{ 863{
863 //qDebug("MonthViewCell::updateCell() "); 864 //qDebug("MonthViewCell::updateCell() ");
864 if ( !mMonthView->isUpdatePossible() ) 865 if ( !mMonthView->isUpdatePossible() )
865 return; 866 return;
866 startUpdateCell(); 867 startUpdateCell();
867 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 868 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
868 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); 869 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true );
869 Event *event; 870 Event *event;
870 for( event = events.first(); event; event = events.next() ) { // for event 871 for( event = events.first(); event; event = events.next() ) { // for event
871 insertEvent(event); 872 insertEvent(event);
872 } 873 }
873 // insert due todos 874 // insert due todos
874 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); 875 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate );
875 Todo *todo; 876 Todo *todo;
876 for(todo = todos.first(); todo; todo = todos.next()) { 877 for(todo = todos.first(); todo; todo = todos.next()) {
877 insertTodo( todo ); 878 insertTodo( todo );
878 } 879 }
879 finishUpdateCell(); 880 finishUpdateCell();
880 // if ( isVisible()) 881 // if ( isVisible())
881 //qApp->processEvents(); 882 //qApp->processEvents();
882} 883}
883 884
884void MonthViewCell::updateConfig( bool bigFont ) // = false 885void MonthViewCell::updateConfig( bool bigFont ) // = false
885{ 886{
886 887
887 if ( bigFont ) { 888 if ( bigFont ) {
888 QFont fo = KOPrefs::instance()->mMonthViewFont; 889 QFont fo = KOPrefs::instance()->mMonthViewFont;
889 int ps = fo.pointSize() + 2; 890 int ps = fo.pointSize() + 2;
890 if ( ps < 18 ) 891 if ( ps < 18 )
891 ps += 2; 892 ps += 2;
892 fo.setPointSize( ps ); 893 fo.setPointSize( ps );
893 setFont( fo ); 894 setFont( fo );
894 } else 895 } else
895 setFont( KOPrefs::instance()->mMonthViewFont ); 896 setFont( KOPrefs::instance()->mMonthViewFont );
896 897
897 QFontMetrics fm( font() ); 898 QFontMetrics fm( font() );
898 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); 899 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 );
899 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); 900 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 );
900 mHolidayPalette = mStandardPalette; 901 mHolidayPalette = mStandardPalette;
901 mPrimaryPalette = mStandardPalette; 902 mPrimaryPalette = mStandardPalette;
902 mNonPrimaryPalette = mStandardPalette; 903 mNonPrimaryPalette = mStandardPalette;
903 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { 904 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) {
904 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); 905 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor );
905 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); 906 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor );
906 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); 907 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark());
907 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); 908 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark());
908 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); 909 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor);
909 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); 910 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor);
910 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); 911 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark());
911 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); 912 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor);
912 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); 913 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor);
913 } 914 }
914 //updateCell(); 915 //updateCell();
915} 916}
916 917
917void MonthViewCell::enableScrollBars( bool enabled ) 918void MonthViewCell::enableScrollBars( bool enabled )
918{ 919{
919 920
920 return; 921 return;
921 if ( enabled ) { 922 if ( enabled ) {
922 QListBoxItem *fi = firstItem (); 923 QListBoxItem *fi = firstItem ();
923 if (fi ) { 924 if (fi ) {
924 int ihei = fi->height( this ); 925 int ihei = fi->height( this );
925 int hei = numRows () * ihei; 926 int hei = numRows () * ihei;
926 if ( hei < height() - horizontalScrollBar()->height () ) { 927 if ( hei < height() - horizontalScrollBar()->height () ) {
927 setVScrollBarMode(QScrollView::AlwaysOff); 928 setVScrollBarMode(QScrollView::AlwaysOff);
928 } 929 }
929 else 930 else
930 setVScrollBarMode(QScrollView::Auto); 931 setVScrollBarMode(QScrollView::Auto);
931 if ( ihei *3 > height() ) { 932 if ( ihei *3 > height() ) {
932 setHScrollBarMode(QScrollView::AlwaysOff); 933 setHScrollBarMode(QScrollView::AlwaysOff);
933 } 934 }
934 else { 935 else {
935 setHScrollBarMode(QScrollView::Auto); 936 setHScrollBarMode(QScrollView::Auto);
936 } 937 }
937 } else { 938 } else {
938 setVScrollBarMode(QScrollView::Auto); 939 setVScrollBarMode(QScrollView::Auto);
939 setHScrollBarMode(QScrollView::Auto); 940 setHScrollBarMode(QScrollView::Auto);
940 } 941 }
941 } else { 942 } else {
942 setVScrollBarMode(QScrollView::AlwaysOff); 943 setVScrollBarMode(QScrollView::AlwaysOff);
943 setHScrollBarMode(QScrollView::AlwaysOff); 944 setHScrollBarMode(QScrollView::AlwaysOff);
944 } 945 }
945} 946}
946 947
947Incidence *MonthViewCell::selectedIncidence() 948Incidence *MonthViewCell::selectedIncidence()
948{ 949{
949 int index = currentItem(); 950 int index = currentItem();
950 if ( index < 0 ) return 0; 951 if ( index < 0 ) return 0;
951 952
952 MonthViewItem *mitem = 953 MonthViewItem *mitem =
953 static_cast<MonthViewItem *>( item( index ) ); 954 static_cast<MonthViewItem *>( item( index ) );
954 955
955 if ( !mitem ) return 0; 956 if ( !mitem ) return 0;
956 957
957 return mitem->incidence(); 958 return mitem->incidence();
958} 959}
959 960
960QDate MonthViewCell::selectedIncidenceDate() 961QDate MonthViewCell::selectedIncidenceDate()
961{ 962{
962 QDate qd; 963 QDate qd;
963 int index = currentItem(); 964 int index = currentItem();
964 if ( index < 0 ) return qd; 965 if ( index < 0 ) return qd;
965 966
966 MonthViewItem *mitem = 967 MonthViewItem *mitem =
967 static_cast<MonthViewItem *>( item( index ) ); 968 static_cast<MonthViewItem *>( item( index ) );
968 969
969 if ( !mitem ) return qd; 970 if ( !mitem ) return qd;
970 971