summaryrefslogtreecommitdiffabout
path: root/korganizer/kodaymatrix.cpp
Unidiff
Diffstat (limited to 'korganizer/kodaymatrix.cpp') (more/less context) (show whitespace changes)
-rw-r--r--korganizer/kodaymatrix.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp
index dfc6af7..c55f7d7 100644
--- a/korganizer/kodaymatrix.cpp
+++ b/korganizer/kodaymatrix.cpp
@@ -196,192 +196,193 @@ QString KODayMatrix::getWhatsThisText( QPoint p )
196 mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); 196 mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary();
197 } 197 }
198 } 198 }
199 if ( !event->location().isEmpty() ) 199 if ( !event->location().isEmpty() )
200 mToolTipText += " (" + event->location() + ")"; 200 mToolTipText += " (" + event->location() + ")";
201#if QT_VERSION >= 0x030000 201#if QT_VERSION >= 0x030000
202 mToolTipText.replace( '<' , "&lt;" ); 202 mToolTipText.replace( '<' , "&lt;" );
203 mToolTipText.replace( '>' , "&gt;" ); 203 mToolTipText.replace( '>' , "&gt;" );
204#else 204#else
205 if ( mToolTipText.find ('<') >= 0 ) { 205 if ( mToolTipText.find ('<') >= 0 ) {
206 mToolTipText.replace( QRegExp("<") , "&lt;" ); 206 mToolTipText.replace( QRegExp("<") , "&lt;" );
207 } 207 }
208 if ( mToolTipText.find ('>') >= 0 ) { 208 if ( mToolTipText.find ('>') >= 0 ) {
209 mToolTipText.replace( QRegExp(">") , "&gt;" ); 209 mToolTipText.replace( QRegExp(">") , "&gt;" );
210 } 210 }
211#endif 211#endif
212 //qDebug("TTT: %s ", mToolTipText.latin1()); 212 //qDebug("TTT: %s ", mToolTipText.latin1());
213 mToolTip.append( mToolTipText ); 213 mToolTip.append( mToolTipText );
214 } 214 }
215 mToolTip.sort(); 215 mToolTip.sort();
216 return "<b>"+KGlobal::locale()->formatDate(days[tmp]) + "</b><br>" + mToolTip.join("<br>"); 216 return "<b>"+KGlobal::locale()->formatDate(days[tmp]) + "</b><br>" + mToolTip.join("<br>");
217} 217}
218void KODayMatrix::setCalendar( Calendar *cal ) 218void KODayMatrix::setCalendar( Calendar *cal )
219{ 219{
220 mCalendar = cal; 220 mCalendar = cal;
221 221
222 setAcceptDrops( mCalendar ); 222 setAcceptDrops( mCalendar );
223 223
224 updateEvents(); 224 updateEvents();
225} 225}
226 226
227QColor KODayMatrix::getShadedColor(QColor color) 227QColor KODayMatrix::getShadedColor(QColor color)
228{ 228{
229 QColor shaded; 229 QColor shaded;
230 int h=0; 230 int h=0;
231 int s=0; 231 int s=0;
232 int v=0; 232 int v=0;
233 color.hsv(&h,&s,&v); 233 color.hsv(&h,&s,&v);
234 s = s/4; 234 s = s/4;
235 v = 192+v/4; 235 v = 192+v/4;
236 shaded.setHsv(h,s,v); 236 shaded.setHsv(h,s,v);
237 237
238 return shaded; 238 return shaded;
239} 239}
240 240
241KODayMatrix::~KODayMatrix() 241KODayMatrix::~KODayMatrix()
242{ 242{
243 // delete mKODaymatrixWhatsThis; 243 // delete mKODaymatrixWhatsThis;
244 delete [] days; 244 delete [] days;
245 delete [] daylbls; 245 delete [] daylbls;
246 //delete [] events; 246 //delete [] events;
247 delete mToolTip; 247 delete mToolTip;
248} 248}
249 249
250/* 250/*
251void KODayMatrix::setStartDate(QDate start) 251void KODayMatrix::setStartDate(QDate start)
252{ 252{
253 updateView(start); 253 updateView(start);
254} 254}
255*/ 255*/
256 256
257void KODayMatrix::addSelectedDaysTo(DateList& selDays) 257void KODayMatrix::addSelectedDaysTo(DateList& selDays)
258{ 258{
259 259
260 if (mSelStart == NOSELECTION) { 260 if (mSelStart == NOSELECTION) {
261 return; 261 return;
262 } 262 }
263 263
264 //cope with selection being out of matrix limits at top (< 0) 264 //cope with selection being out of matrix limits at top (< 0)
265 int i0 = mSelStart; 265 int i0 = mSelStart;
266 if (i0 < 0) { 266 if (i0 < 0) {
267 for (int i = i0; i < 0; i++) { 267 for (int i = i0; i < 0; i++) {
268 selDays.append(days[0].addDays(i)); 268 selDays.append(days[0].addDays(i));
269 } 269 }
270 i0 = 0; 270 i0 = 0;
271 } 271 }
272 272
273 //cope with selection being out of matrix limits at bottom (> NUMDAYS-1) 273 //cope with selection being out of matrix limits at bottom (> NUMDAYS-1)
274 if (mSelEnd > NUMDAYS-1) { 274 if (mSelEnd > NUMDAYS-1) {
275 for (int i = i0; i <= NUMDAYS-1; i++) { 275 for (int i = i0; i <= NUMDAYS-1; i++) {
276 selDays.append(days[i]); 276 selDays.append(days[i]);
277 } 277 }
278 for (int i = NUMDAYS; i < mSelEnd; i++) { 278 for (int i = NUMDAYS; i < mSelEnd; i++) {
279 selDays.append(days[0].addDays(i)); 279 selDays.append(days[0].addDays(i));
280 } 280 }
281 281
282 // apply normal routine to selection being entirely within matrix limits 282 // apply normal routine to selection being entirely within matrix limits
283 } else { 283 } else {
284 for (int i = i0; i <= mSelEnd; i++) { 284 for (int i = i0; i <= mSelEnd; i++) {
285 selDays.append(days[i]); 285 selDays.append(days[i]);
286 } 286 }
287 } 287 }
288} 288}
289 289
290bool KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end) 290bool KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end)
291{ 291{
292 mRedrawNeeded = true;
292 bool noSel = (mSelEnd == NOSELECTION && mSelStart == NOSELECTION ); 293 bool noSel = (mSelEnd == NOSELECTION && mSelStart == NOSELECTION );
293 mSelStart = startdate.daysTo(start); 294 mSelStart = startdate.daysTo(start);
294 if ( mSelStart < 0 ) 295 if ( mSelStart < 0 )
295 mSelStart = 0; 296 mSelStart = 0;
296 mSelEnd = startdate.daysTo(end); 297 mSelEnd = startdate.daysTo(end);
297 if ( mSelEnd > NUMDAYS-1 ) 298 if ( mSelEnd > NUMDAYS-1 )
298 mSelEnd = NUMDAYS-1; 299 mSelEnd = NUMDAYS-1;
299 if ( mSelEnd < 0 || mSelStart > NUMDAYS-1 ) { 300 if ( mSelEnd < 0 || mSelStart > NUMDAYS-1 ) {
300 clearSelection(); 301 clearSelection();
301 if ( noSel ) 302 if ( noSel )
302 return false; 303 return false;
303 } 304 }
304 305
305 return true; 306 return true;
306} 307}
307void KODayMatrix::clearSelection() 308void KODayMatrix::clearSelection()
308{ 309{
309 mSelEnd = mSelStart = NOSELECTION; 310 mSelEnd = mSelStart = NOSELECTION;
310} 311}
311 312
312 313
313void KODayMatrix::recalculateToday() 314void KODayMatrix::recalculateToday()
314{ 315{
315 today = -1; 316 today = -1;
316 for (int i=0; i<NUMDAYS; i++) { 317 for (int i=0; i<NUMDAYS; i++) {
317 //events[i] = 0; 318 //events[i] = 0;
318 days[i] = startdate.addDays(i); 319 days[i] = startdate.addDays(i);
319 daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] )); 320 daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] ));
320 321
321 // if today is in the currently displayed month, hilight today 322 // if today is in the currently displayed month, hilight today
322 if (days[i].year() == QDate::currentDate().year() && 323 if (days[i].year() == QDate::currentDate().year() &&
323 days[i].month() == QDate::currentDate().month() && 324 days[i].month() == QDate::currentDate().month() &&
324 days[i].day() == QDate::currentDate().day()) { 325 days[i].day() == QDate::currentDate().day()) {
325 today = i; 326 today = i;
326 } 327 }
327 } 328 }
328 // qDebug(QString("Today is visible at %1.").arg(today)); 329 // qDebug(QString("Today is visible at %1.").arg(today));
329} 330}
330 331
331void KODayMatrix::updateView() 332void KODayMatrix::updateView()
332{ 333{
333 updateView(startdate); 334 updateView(startdate);
334} 335}
335void KODayMatrix::repaintViewTimed() 336void KODayMatrix::repaintViewTimed()
336{ 337{
337 mRepaintTimer->stop(); 338 mRepaintTimer->stop();
338 repaint(false); 339 repaint(false);
339} 340}
340void KODayMatrix::updateViewTimed() 341void KODayMatrix::updateViewTimed()
341{ 342{
342 mUpdateTimer->stop(); 343 mUpdateTimer->stop();
343 if ( !mCalendar ) { 344 if ( !mCalendar ) {
344 qDebug("NOT CAL "); 345 qDebug("NOT CAL ");
345 return; 346 return;
346 } 347 }
347 //qDebug("KODayMatrix::updateViewTimed "); 348 //qDebug("KODayMatrix::updateViewTimed ");
348 for(int i = 0; i < NUMDAYS; i++) { 349 for(int i = 0; i < NUMDAYS; i++) {
349 // if events are set for the day then remember to draw it bold 350 // if events are set for the day then remember to draw it bold
350 QPtrList<Event> eventlist = mCalendar->events(days[i]); 351 QPtrList<Event> eventlist = mCalendar->events(days[i]);
351 Event *event; 352 Event *event;
352 int numEvents = eventlist.count(); 353 int numEvents = eventlist.count();
353 QString holiStr = ""; 354 QString holiStr = "";
354 bDays.clearBit(i); 355 bDays.clearBit(i);
355 hDays.clearBit(i); 356 hDays.clearBit(i);
356 eDays.clearBit(i); 357 eDays.clearBit(i);
357 for(event=eventlist.first();event != 0;event=eventlist.next()) { 358 for(event=eventlist.first();event != 0;event=eventlist.next()) {
358 ushort recurType = event->recurrence()->doesRecur(); 359 ushort recurType = event->recurrence()->doesRecur();
359 if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || 360 if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) ||
360 (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { 361 (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) {
361 numEvents--; 362 numEvents--;
362 } 363 }
363 if ( event->isHoliday()) { 364 if ( event->isHoliday()) {
364 hDays.setBit(i); 365 hDays.setBit(i);
365 if ( !holiStr.isEmpty() ) 366 if ( !holiStr.isEmpty() )
366 holiStr += "\n"; 367 holiStr += "\n";
367 holiStr += event->summary(); 368 holiStr += event->summary();
368 if ( !event->location().isEmpty() ) 369 if ( !event->location().isEmpty() )
369 holiStr += " (" + event->location() + ")"; 370 holiStr += " (" + event->location() + ")";
370 } 371 }
371 if ( event->isBirthday()) { 372 if ( event->isBirthday()) {
372 if ( !holiStr.isEmpty() ) 373 if ( !holiStr.isEmpty() )
373 holiStr += "\n"; 374 holiStr += "\n";
374 holiStr += i18n("Birthday") + ": "+event->summary(); 375 holiStr += i18n("Birthday") + ": "+event->summary();
375 if ( !event->location().isEmpty() ) 376 if ( !event->location().isEmpty() )
376 holiStr += " (" + event->location() + ")"; 377 holiStr += " (" + event->location() + ")";
377 bDays.setBit(i); 378 bDays.setBit(i);
378 } 379 }
379 } 380 }
380 if ( numEvents ) 381 if ( numEvents )
381 eDays.setBit(i); 382 eDays.setBit(i);
382 //if it is a holy day then draw it red. Sundays are consider holidays, too 383 //if it is a holy day then draw it red. Sundays are consider holidays, too
383 if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || 384 if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) ||
384 !holiStr.isEmpty()) { 385 !holiStr.isEmpty()) {
385 mHolidays[i] = holiStr; 386 mHolidays[i] = holiStr;
386 } else { 387 } else {
387 mHolidays[i] = QString::null; 388 mHolidays[i] = QString::null;
@@ -418,237 +419,240 @@ void KODayMatrix::updateView(QDate actdate)
418 if( mSelEnd > NUMDAYS || mSelEnd < 0 ) 419 if( mSelEnd > NUMDAYS || mSelEnd < 0 )
419 mSelEnd = mSelEnd + tmp; 420 mSelEnd = mSelEnd + tmp;
420 } 421 }
421 } 422 }
422 startdate = actdate; 423 startdate = actdate;
423 mDayChanged = true; 424 mDayChanged = true;
424 recalculateToday(); 425 recalculateToday();
425 mRedrawNeeded = true; 426 mRedrawNeeded = true;
426 } 427 }
427 //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() ); 428 //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() );
428 if ( !isVisible() ) { 429 if ( !isVisible() ) {
429 mPendingUpdateBeforeRepaint = true; 430 mPendingUpdateBeforeRepaint = true;
430 } else { 431 } else {
431#ifdef DESKTOP_VERSION 432#ifdef DESKTOP_VERSION
432 //mRepaintTimer->start( 100 ); 433 //mRepaintTimer->start( 100 );
433 //updateViewTimed(); 434 //updateViewTimed();
434 mUpdateTimer->start( 50 ); 435 mUpdateTimer->start( 50 );
435#else 436#else
436 mRepaintTimer->start( 350 ); 437 mRepaintTimer->start( 350 );
437 mUpdateTimer->start( 1200 ); 438 mUpdateTimer->start( 1200 );
438#endif 439#endif
439 } 440 }
440} 441}
441void KODayMatrix::updateEvents() 442void KODayMatrix::updateEvents()
442{ 443{
443 if ( !mCalendar ) return; 444 if ( !mCalendar ) return;
444 445
445 for( int i = 0; i < NUMDAYS; i++ ) { 446 for( int i = 0; i < NUMDAYS; i++ ) {
446 // if events are set for the day then remember to draw it bold 447 // if events are set for the day then remember to draw it bold
447 QPtrList<Event> eventlist = mCalendar->events( days[ i ] ); 448 QPtrList<Event> eventlist = mCalendar->events( days[ i ] );
448 int numEvents = eventlist.count(); 449 int numEvents = eventlist.count();
449 Event *event; 450 Event *event;
450 for( event = eventlist.first(); event != 0;event=eventlist.next()) { 451 for( event = eventlist.first(); event != 0;event=eventlist.next()) {
451 ushort recurType = event->doesRecur(); 452 ushort recurType = event->doesRecur();
452 453
453 if ( ( recurType == Recurrence::rDaily && 454 if ( ( recurType == Recurrence::rDaily &&
454 !KOPrefs::instance()->mDailyRecur ) || 455 !KOPrefs::instance()->mDailyRecur ) ||
455 ( recurType == Recurrence::rWeekly && 456 ( recurType == Recurrence::rWeekly &&
456 !KOPrefs::instance()->mWeeklyRecur ) ) { 457 !KOPrefs::instance()->mWeeklyRecur ) ) {
457 numEvents--; 458 numEvents--;
458 } 459 }
459 } 460 }
460 if ( numEvents ) 461 if ( numEvents )
461 eDays.setBit(i); 462 eDays.setBit(i);
462 else 463 else
463 eDays.clearBit(i); 464 eDays.clearBit(i);
464 } 465 }
465} 466}
466 467
467const QDate& KODayMatrix::getDate(int offset) 468const QDate& KODayMatrix::getDate(int offset)
468{ 469{
469 if (offset < 0 || offset > NUMDAYS-1) { 470 if (offset < 0 || offset > NUMDAYS-1) {
470 qDebug("Wrong offset2 %d", offset); 471 qDebug("Wrong offset2 %d", offset);
471 return days[0]; 472 return days[0];
472 } 473 }
473 return days[offset]; 474 return days[offset];
474} 475}
475 476
476QString KODayMatrix::getHolidayLabel(int offset) 477QString KODayMatrix::getHolidayLabel(int offset)
477{ 478{
478 if (offset < 0 || offset > NUMDAYS-1) { 479 if (offset < 0 || offset > NUMDAYS-1) {
479 qDebug("Wrong offset1 %d", offset); 480 qDebug("Wrong offset1 %d", offset);
480 return QString(); 481 return QString();
481 } 482 }
482 return mHolidays[offset]; 483 return mHolidays[offset];
483} 484}
484 485
485int KODayMatrix::getDayIndexFrom(int x, int y) 486int KODayMatrix::getDayIndexFrom(int x, int y)
486{ 487{
487 int colModulo = (width()-2) % 7; 488 int colModulo = (width()-2) % 7;
488 int rowModulo = (height()-2) % 6; 489 int rowModulo = (height()-2) % 6;
489#if 0 490#if 0
490 return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ? 491 return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ?
491 6 - x/daysize.width() : x/daysize.width()); 492 6 - x/daysize.width() : x/daysize.width());
492#endif 493#endif
493 int xVal = (x-colModulo/2-2)/daysize.width(); 494 int xVal = (x-colModulo/2-2)/daysize.width();
494 int yVal = (y-rowModulo/2-2)/daysize.height(); 495 int yVal = (y-rowModulo/2-2)/daysize.height();
495 496
496 497
497 return 7*(yVal) + xVal; 498 return 7*(yVal) + xVal;
498 499
499} 500}
500 501
501// ---------------------------------------------------------------------------- 502// ----------------------------------------------------------------------------
502// M O U S E E V E N T H A N D L I N G 503// M O U S E E V E N T H A N D L I N G
503// ---------------------------------------------------------------------------- 504// ----------------------------------------------------------------------------
504 505
505void KODayMatrix::mousePressEvent (QMouseEvent* e) 506void KODayMatrix::mousePressEvent (QMouseEvent* e)
506{ 507{
507 508
508 if ( e->button() == LeftButton ) 509 if ( e->button() == LeftButton )
509 mouseDown = true; 510 mouseDown = true;
510 mSelStart = getDayIndexFrom(e->x(), e->y()); 511 mSelStart = getDayIndexFrom(e->x(), e->y());
511 if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1; 512 if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1;
512 mSelInit = mSelStart; 513 mSelInit = mSelStart;
513 mSelEnd = mSelStart; 514 mSelEnd = mSelStart;
515 mRedrawNeeded = true;
514 repaint(false); 516 repaint(false);
515} 517}
516 518
517void KODayMatrix::mouseReleaseEvent (QMouseEvent* e) 519void KODayMatrix::mouseReleaseEvent (QMouseEvent* e)
518{ 520{
521 mRedrawNeeded = true;
519 if ( e->button() == LeftButton ) 522 if ( e->button() == LeftButton )
520 if ( ! mouseDown ) { 523 if ( ! mouseDown ) {
521 return; 524 return;
522 } 525 }
523 else 526 else
524 mouseDown = false; 527 mouseDown = false;
525 int tmp = getDayIndexFrom(e->x(), e->y()); 528 int tmp = getDayIndexFrom(e->x(), e->y());
526 if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; 529 if (tmp > NUMDAYS-1) tmp=NUMDAYS-1;
527 530
528 if (mSelInit > tmp) { 531 if (mSelInit > tmp) {
529 mSelEnd = mSelInit; 532 mSelEnd = mSelInit;
530 if (tmp != mSelStart) { 533 if (tmp != mSelStart) {
531 mSelStart = tmp; 534 mSelStart = tmp;
532 repaint(false); 535 repaint(false);
533 } 536 }
534 } else { 537 } else {
535 mSelStart = mSelInit; 538 mSelStart = mSelInit;
536 539
537 //repaint only if selection has changed 540 //repaint only if selection has changed
538 if (tmp != mSelEnd) { 541 if (tmp != mSelEnd) {
539 mSelEnd = tmp; 542 mSelEnd = tmp;
540 repaint(false); 543 repaint(false);
541 } 544 }
542 } 545 }
543 546
544 DateList daylist; 547 DateList daylist;
545 if ( mSelStart < 0 ) 548 if ( mSelStart < 0 )
546 mSelStart = 0; 549 mSelStart = 0;
547 for (int i = mSelStart; i <= mSelEnd; i++) { 550 for (int i = mSelStart; i <= mSelEnd; i++) {
548 daylist.append(days[i]); 551 daylist.append(days[i]);
549 } 552 }
550 emit selected((const DateList)daylist); 553 emit selected((const DateList)daylist);
551 554
552} 555}
553 556
554void KODayMatrix::mouseMoveEvent (QMouseEvent* e) 557void KODayMatrix::mouseMoveEvent (QMouseEvent* e)
555{ 558{
556 if ( ! mouseDown ) { 559 if ( ! mouseDown ) {
557 return; 560 return;
558 } 561 }
562 mRedrawNeeded = true;
559 int tmp = getDayIndexFrom(e->x(), e->y()); 563 int tmp = getDayIndexFrom(e->x(), e->y());
560 if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; 564 if (tmp > NUMDAYS-1) tmp=NUMDAYS-1;
561 565
562 if (mSelInit > tmp) { 566 if (mSelInit > tmp) {
563 mSelEnd = mSelInit; 567 mSelEnd = mSelInit;
564 if (tmp != mSelStart) { 568 if (tmp != mSelStart) {
565 mSelStart = tmp; 569 mSelStart = tmp;
566 repaint(false); 570 repaint(false);
567 } 571 }
568 } else { 572 } else {
569 mSelStart = mSelInit; 573 mSelStart = mSelInit;
570 574
571 //repaint only if selection has changed 575 //repaint only if selection has changed
572 if (tmp != mSelEnd) { 576 if (tmp != mSelEnd) {
573 mSelEnd = tmp; 577 mSelEnd = tmp;
574 repaint(false); 578 repaint(false);
575 } 579 }
576 } 580 }
577} 581}
578 582
579// ---------------------------------------------------------------------------- 583// ----------------------------------------------------------------------------
580// D R A G ' N D R O P H A N D L I N G 584// D R A G ' N D R O P H A N D L I N G
581// ---------------------------------------------------------------------------- 585// ----------------------------------------------------------------------------
582 586
583void KODayMatrix::dragEnterEvent(QDragEnterEvent *e) 587void KODayMatrix::dragEnterEvent(QDragEnterEvent *e)
584{ 588{
585#ifndef KORG_NODND 589#ifndef KORG_NODND
586 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { 590 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) {
587 e->ignore(); 591 e->ignore();
588 return; 592 return;
589 } 593 }
590 594
591 // some visual feedback 595 // some visual feedback
592// oldPalette = palette(); 596// oldPalette = palette();
593// setPalette(my_HilitePalette); 597// setPalette(my_HilitePalette);
594// update(); 598// update();
595#endif 599#endif
596} 600}
597 601
598void KODayMatrix::dragMoveEvent(QDragMoveEvent *e) 602void KODayMatrix::dragMoveEvent(QDragMoveEvent *e)
599{ 603{
600#ifndef KORG_NODND 604#ifndef KORG_NODND
601 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { 605 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) {
602 e->ignore(); 606 e->ignore();
603 return; 607 return;
604 } 608 }
605 609
606 e->accept(); 610 e->accept();
607#endif 611#endif
608} 612}
609 613
610void KODayMatrix::dragLeaveEvent(QDragLeaveEvent */*dl*/) 614void KODayMatrix::dragLeaveEvent(QDragLeaveEvent */*dl*/)
611{ 615{
612#ifndef KORG_NODND 616#ifndef KORG_NODND
613// setPalette(oldPalette); 617// setPalette(oldPalette);
614// update(); 618// update();
615#endif 619#endif
616} 620}
617 621
618void KODayMatrix::dropEvent(QDropEvent *e) 622void KODayMatrix::dropEvent(QDropEvent *e)
619{ 623{
620#ifndef KORG_NODND 624#ifndef KORG_NODND
621// kdDebug() << "KODayMatrix::dropEvent(e) begin" << endl; 625// kdDebug() << "KODayMatrix::dropEvent(e) begin" << endl;
622 626
623 if (!mCalendar || !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { 627 if (!mCalendar || !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) {
624 e->ignore(); 628 e->ignore();
625 return; 629 return;
626 } 630 }
627 631
628 DndFactory factory( mCalendar ); 632 DndFactory factory( mCalendar );
629 Event *event = factory.createDrop(e); 633 Event *event = factory.createDrop(e);
630 634
631 if (event) { 635 if (event) {
632 e->acceptAction(); 636 e->acceptAction();
633 637
634 Event *existingEvent = mCalendar->event(event->uid()); 638 Event *existingEvent = mCalendar->event(event->uid());
635 639
636 if(existingEvent) { 640 if(existingEvent) {
637 // uniquify event 641 // uniquify event
638 event->recreate(); 642 event->recreate();
639/* 643/*
640 KMessageBox::sorry(this, 644 KMessageBox::sorry(this,
641 i18n("Event already exists in this calendar."), 645 i18n("Event already exists in this calendar."),
642 i18n("Drop Event")); 646 i18n("Drop Event"));
643 delete event; 647 delete event;
644 return; 648 return;
645*/ 649*/
646 } 650 }
647// kdDebug() << "Drop new Event" << endl; 651// kdDebug() << "Drop new Event" << endl;
648 // Adjust date 652 // Adjust date
649 QDateTime start = event->dtStart(); 653 QDateTime start = event->dtStart();
650 QDateTime end = event->dtEnd(); 654 QDateTime end = event->dtEnd();
651 int duration = start.daysTo(end); 655 int duration = start.daysTo(end);
652 int idx = getDayIndexFrom(e->pos().x(), e->pos().y()); 656 int idx = getDayIndexFrom(e->pos().x(), e->pos().y());
653 657
654 start.setDate(days[idx]); 658 start.setDate(days[idx]);