summaryrefslogtreecommitdiff
authordrw <drw>2005-03-07 16:52:17 (UTC)
committer drw <drw>2005-03-07 16:52:17 (UTC)
commit5ab00b78b199b1a03d3f27faa8b1dcffd9a86ff7 (patch) (unidiff)
treebebec7df2d48f82b79a1ff3a98e05791dc444556
parent61b9d5f646faa5bd84391318f6440bee6cbefcd8 (diff)
downloadopie-5ab00b78b199b1a03d3f27faa8b1dcffd9a86ff7.zip
opie-5ab00b78b199b1a03d3f27faa8b1dcffd9a86ff7.tar.gz
opie-5ab00b78b199b1a03d3f27faa8b1dcffd9a86ff7.tar.bz2
Use popup menu for edit, duplicate, delete and beam in week list view - patch courtesy of Thomas Schnetzer
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/datebook.cpp3
-rw-r--r--core/pim/datebook/datebookweeklst.cpp43
-rw-r--r--core/pim/datebook/datebookweeklst.h35
3 files changed, 72 insertions, 9 deletions
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp
index 0a47bb8..a18a5b4 100644
--- a/core/pim/datebook/datebook.cpp
+++ b/core/pim/datebook/datebook.cpp
@@ -310,512 +310,515 @@ QString DateBook::checkEvent(const Event &e)
310 current_date = next.date(); 310 current_date = next.date();
311 } 311 }
312 312
313 if(checkFailed) 313 if(checkFailed)
314 return tr("Event duration is potentially longer\n" 314 return tr("Event duration is potentially longer\n"
315 "than interval between repeats."); 315 "than interval between repeats.");
316 316
317 return QString::null; 317 return QString::null;
318} 318}
319 319
320QDate DateBook::currentDate() 320QDate DateBook::currentDate()
321{ 321{
322 QDate d = QDate::currentDate(); 322 QDate d = QDate::currentDate();
323 323
324 if ( dayView && views->visibleWidget() == dayView ) { 324 if ( dayView && views->visibleWidget() == dayView ) {
325 d = dayView->date(); 325 d = dayView->date();
326 } else if ( weekView && views->visibleWidget() == weekView ) { 326 } else if ( weekView && views->visibleWidget() == weekView ) {
327 d = weekView->date(); 327 d = weekView->date();
328 } else if ( weekLstView && views->visibleWidget() == weekLstView ) { 328 } else if ( weekLstView && views->visibleWidget() == weekLstView ) {
329 d = weekLstView->date(); 329 d = weekLstView->date();
330 } else if ( monthView && views->visibleWidget() == monthView ) { 330 } else if ( monthView && views->visibleWidget() == monthView ) {
331 d = monthView->selectedDate(); 331 d = monthView->selectedDate();
332 } 332 }
333 333
334 return d; 334 return d;
335} 335}
336 336
337void DateBook::view(int v, const QDate &d) { 337void DateBook::view(int v, const QDate &d) {
338 if (v==DAY) { 338 if (v==DAY) {
339 initDay(); 339 initDay();
340 dayAction->setOn( TRUE ); 340 dayAction->setOn( TRUE );
341 dayView->setDate( d ); 341 dayView->setDate( d );
342 views->raiseWidget( dayView ); 342 views->raiseWidget( dayView );
343 dayView->redraw(); 343 dayView->redraw();
344 } else if (v==WEEK) { 344 } else if (v==WEEK) {
345 initWeek(); 345 initWeek();
346 weekAction->setOn( TRUE ); 346 weekAction->setOn( TRUE );
347 weekView->setDate( d ); 347 weekView->setDate( d );
348 views->raiseWidget( weekView ); 348 views->raiseWidget( weekView );
349 weekView->redraw(); 349 weekView->redraw();
350 } else if (v==WEEKLST) { 350 } else if (v==WEEKLST) {
351 initWeekLst(); 351 initWeekLst();
352 weekLstAction->setOn( TRUE ); 352 weekLstAction->setOn( TRUE );
353 weekLstView->setDate(d); 353 weekLstView->setDate(d);
354 views->raiseWidget( weekLstView ); 354 views->raiseWidget( weekLstView );
355 weekLstView->redraw(); 355 weekLstView->redraw();
356 } else if (v==MONTH) { 356 } else if (v==MONTH) {
357 initMonth(); 357 initMonth();
358 monthAction->setOn( TRUE ); 358 monthAction->setOn( TRUE );
359 monthView->setDate( d.year(), d.month(), d.day() ); 359 monthView->setDate( d.year(), d.month(), d.day() );
360 views->raiseWidget( monthView ); 360 views->raiseWidget( monthView );
361 monthView->redraw(); 361 monthView->redraw();
362 } 362 }
363} 363}
364 364
365void DateBook::viewDefault(const QDate &d) { 365void DateBook::viewDefault(const QDate &d) {
366 view(defaultView,d); 366 view(defaultView,d);
367} 367}
368 368
369void DateBook::viewDay() { 369void DateBook::viewDay() {
370 view(DAY,currentDate()); 370 view(DAY,currentDate());
371} 371}
372 372
373void DateBook::viewWeek() { 373void DateBook::viewWeek() {
374 view(WEEK,currentDate()); 374 view(WEEK,currentDate());
375} 375}
376 376
377void DateBook::viewWeekLst() { 377void DateBook::viewWeekLst() {
378 view(WEEKLST,currentDate()); 378 view(WEEKLST,currentDate());
379} 379}
380 380
381void DateBook::viewMonth() { 381void DateBook::viewMonth() {
382 view(MONTH,currentDate()); 382 view(MONTH,currentDate());
383} 383}
384 384
385void DateBook::insertEvent( const Event &e ) 385void DateBook::insertEvent( const Event &e )
386{ 386{
387 Event dupEvent=e; 387 Event dupEvent=e;
388 if(!dupEvent.isValidUid() ) // tkcRom seems to be different 388 if(!dupEvent.isValidUid() ) // tkcRom seems to be different
389 dupEvent.assignUid(); 389 dupEvent.assignUid();
390 dupEvent.setLocation(defaultLocation); 390 dupEvent.setLocation(defaultLocation);
391 dupEvent.setCategories(defaultCategories); 391 dupEvent.setCategories(defaultCategories);
392 db->addEvent(dupEvent); 392 db->addEvent(dupEvent);
393 emit newEvent(); 393 emit newEvent();
394} 394}
395 395
396void DateBook::duplicateEvent( const Event &e ) 396void DateBook::duplicateEvent( const Event &e )
397{ 397{
398 // Alot of code duplication, as this is almost like editEvent(); 398 // Alot of code duplication, as this is almost like editEvent();
399 if (syncing) { 399 if (syncing) {
400 QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); 400 QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") );
401 return; 401 return;
402 } 402 }
403 403
404 Event dupevent(e);// Make a duplicate. 404 Event dupevent(e);// Make a duplicate.
405 405
406 // workaround added for text input. 406 // workaround added for text input.
407 QDialog editDlg( this, 0, TRUE ); 407 QDialog editDlg( this, 0, TRUE );
408 DateEntry *entry; 408 DateEntry *entry;
409 editDlg.setCaption( tr("Duplicate Event") ); 409 editDlg.setCaption( tr("Duplicate Event") );
410 QVBoxLayout *vb = new QVBoxLayout( &editDlg ); 410 QVBoxLayout *vb = new QVBoxLayout( &editDlg );
411 QScrollView *sv = new QScrollView( &editDlg, "scrollview" ); 411 QScrollView *sv = new QScrollView( &editDlg, "scrollview" );
412 sv->setResizePolicy( QScrollView::AutoOneFit ); 412 sv->setResizePolicy( QScrollView::AutoOneFit );
413 // KLUDGE!!! 413 // KLUDGE!!!
414 sv->setHScrollBarMode( QScrollView::AlwaysOff ); 414 sv->setHScrollBarMode( QScrollView::AlwaysOff );
415 vb->addWidget( sv ); 415 vb->addWidget( sv );
416 entry = new DateEntry( onMonday, dupevent, ampm, &editDlg, "editor" ); 416 entry = new DateEntry( onMonday, dupevent, ampm, &editDlg, "editor" );
417 entry->timezone->setEnabled( FALSE ); 417 entry->timezone->setEnabled( FALSE );
418 sv->addChild( entry ); 418 sv->addChild( entry );
419 419
420 while ( QPEApplication::execDialog( &editDlg ) ) { 420 while ( QPEApplication::execDialog( &editDlg ) ) {
421 Event newEv = entry->event(); 421 Event newEv = entry->event();
422 QString error = checkEvent(newEv); 422 QString error = checkEvent(newEv);
423 if (!error.isNull()) { 423 if (!error.isNull()) {
424 if (QMessageBox::warning(this, tr("error box"), error, tr("Fix it"), tr("Continue"), 0, 0, 1) == 0) 424 if (QMessageBox::warning(this, tr("error box"), error, tr("Fix it"), tr("Continue"), 0, 0, 1) == 0)
425 continue; 425 continue;
426 } 426 }
427 /* 427 /*
428 * The problem: 428 * The problem:
429 * DateBookDB does remove repeating events not by uid but by the time 429 * DateBookDB does remove repeating events not by uid but by the time
430 * the recurrence was created 430 * the recurrence was created
431 * so we need to update that time as well 431 * so we need to update that time as well
432 */ 432 */
433 Event::RepeatPattern rp = newEv.repeatPattern(); 433 Event::RepeatPattern rp = newEv.repeatPattern();
434 rp.createTime = ::time( NULL ); 434 rp.createTime = ::time( NULL );
435 newEv.setRepeat( TRUE, rp ); // has repeat and repeatPattern... 435 newEv.setRepeat( TRUE, rp ); // has repeat and repeatPattern...
436 if( newEv.uid() == e.uid() || !newEv.isValidUid() ) 436 if( newEv.uid() == e.uid() || !newEv.isValidUid() )
437 newEv.assignUid(); 437 newEv.assignUid();
438 438
439 db->addEvent(newEv); 439 db->addEvent(newEv);
440 emit newEvent(); 440 emit newEvent();
441 break; 441 break;
442 } 442 }
443} 443}
444 444
445void DateBook::editEvent( const Event &e ) 445void DateBook::editEvent( const Event &e )
446{ 446{
447 if (syncing) { 447 if (syncing) {
448 QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); 448 QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") );
449 return; 449 return;
450 } 450 }
451 451
452 // workaround added for text input. 452 // workaround added for text input.
453 QDialog editDlg( this, 0, TRUE ); 453 QDialog editDlg( this, 0, TRUE );
454 DateEntry *entry; 454 DateEntry *entry;
455 editDlg.setCaption( tr("Edit Event") ); 455 editDlg.setCaption( tr("Edit Event") );
456 QVBoxLayout *vb = new QVBoxLayout( &editDlg ); 456 QVBoxLayout *vb = new QVBoxLayout( &editDlg );
457 QScrollView *sv = new QScrollView( &editDlg, "scrollview" ); 457 QScrollView *sv = new QScrollView( &editDlg, "scrollview" );
458 sv->setResizePolicy( QScrollView::AutoOneFit ); 458 sv->setResizePolicy( QScrollView::AutoOneFit );
459 // KLUDGE!!! 459 // KLUDGE!!!
460 sv->setHScrollBarMode( QScrollView::AlwaysOff ); 460 sv->setHScrollBarMode( QScrollView::AlwaysOff );
461 vb->addWidget( sv ); 461 vb->addWidget( sv );
462 entry = new DateEntry( onMonday, e, ampm, &editDlg, "editor" ); 462 entry = new DateEntry( onMonday, e, ampm, &editDlg, "editor" );
463 entry->timezone->setEnabled( FALSE ); 463 entry->timezone->setEnabled( FALSE );
464 sv->addChild( entry ); 464 sv->addChild( entry );
465 465
466 while ( QPEApplication::execDialog( &editDlg ) ) { 466 while ( QPEApplication::execDialog( &editDlg ) ) {
467 Event newEv = entry->event(); 467 Event newEv = entry->event();
468 if(newEv.description().isEmpty() && newEv.notes().isEmpty() ) 468 if(newEv.description().isEmpty() && newEv.notes().isEmpty() )
469 break; 469 break;
470 newEv.setUid(e.uid()); // FIXME: Hack not to clear uid 470 newEv.setUid(e.uid()); // FIXME: Hack not to clear uid
471 QString error = checkEvent(newEv); 471 QString error = checkEvent(newEv);
472 if (!error.isNull()) { 472 if (!error.isNull()) {
473 if (QMessageBox::warning(this, tr("error box"), error, tr("Fix it"), tr("Continue"), 0, 0, 1) == 0) continue; 473 if (QMessageBox::warning(this, tr("error box"), error, tr("Fix it"), tr("Continue"), 0, 0, 1) == 0) continue;
474 } 474 }
475 db->editEvent(e, newEv); 475 db->editEvent(e, newEv);
476 emit newEvent(); 476 emit newEvent();
477 break; 477 break;
478 } 478 }
479} 479}
480 480
481void DateBook::removeEvent( const Event &e ) 481void DateBook::removeEvent( const Event &e )
482{ 482{
483 if (syncing) { 483 if (syncing) {
484 QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); 484 QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") );
485 return; 485 return;
486 } 486 }
487 487
488 QString strName = e.description(); 488 QString strName = e.description();
489 489
490 if ( !QPEMessageBox::confirmDelete( this, tr( "Calendar" ),strName ) ) 490 if ( !QPEMessageBox::confirmDelete( this, tr( "Calendar" ),strName ) )
491 return; 491 return;
492 492
493 db->removeEvent( e ); 493 db->removeEvent( e );
494 if ( views->visibleWidget() == dayView && dayView ) 494 if ( views->visibleWidget() == dayView && dayView )
495 dayView->redraw(); 495 dayView->redraw();
496 496
497} 497}
498 498
499void DateBook::addEvent( const Event &e ) 499void DateBook::addEvent( const Event &e )
500{ 500{
501 QDate d = e.start().date(); 501 QDate d = e.start().date();
502 initDay(); 502 initDay();
503 dayView->setDate( d ); 503 dayView->setDate( d );
504} 504}
505 505
506void DateBook::showDay( int year, int month, int day ) 506void DateBook::showDay( int year, int month, int day )
507{ 507{
508 QDate d(year, month, day); 508 QDate d(year, month, day);
509 view(DAY,d); 509 view(DAY,d);
510} 510}
511 511
512void DateBook::initDay() 512void DateBook::initDay()
513{ 513{
514 if ( !dayView ) { 514 if ( !dayView ) {
515 dayView = new DateBookDay( ampm, onMonday, db, views, "day view" ); 515 dayView = new DateBookDay( ampm, onMonday, db, views, "day view" );
516 views->addWidget( dayView, DAY ); 516 views->addWidget( dayView, DAY );
517 dayView->setJumpToCurTime( bJumpToCurTime ); 517 dayView->setJumpToCurTime( bJumpToCurTime );
518 dayView->setStartViewTime( startTime ); 518 dayView->setStartViewTime( startTime );
519 dayView->setRowStyle( rowStyle ); 519 dayView->setRowStyle( rowStyle );
520 connect( this, SIGNAL( newEvent() ), dayView, SLOT( redraw() ) ); 520 connect( this, SIGNAL( newEvent() ), dayView, SLOT( redraw() ) );
521 connect( dayView, SIGNAL( newEvent() ), this, SLOT( fileNew() ) ); 521 connect( dayView, SIGNAL( newEvent() ), this, SLOT( fileNew() ) );
522 connect( dayView, SIGNAL( removeEvent(const Event&) ), this, SLOT( removeEvent(const Event&) ) ); 522 connect( dayView, SIGNAL( removeEvent(const Event&) ), this, SLOT( removeEvent(const Event&) ) );
523 connect( dayView, SIGNAL( editEvent(const Event&) ), this, SLOT( editEvent(const Event&) ) ); 523 connect( dayView, SIGNAL( editEvent(const Event&) ), this, SLOT( editEvent(const Event&) ) );
524 connect( dayView, SIGNAL( duplicateEvent(const Event&) ), this, SLOT( duplicateEvent(const Event&) ) ); 524 connect( dayView, SIGNAL( duplicateEvent(const Event&) ), this, SLOT( duplicateEvent(const Event&) ) );
525 connect( dayView, SIGNAL( beamEvent(const Event&) ), this, SLOT( beamEvent(const Event&) ) ); 525 connect( dayView, SIGNAL( beamEvent(const Event&) ), this, SLOT( beamEvent(const Event&) ) );
526 connect( dayView, SIGNAL(sigNewEvent(const QString&)), this, SLOT(slotNewEventFromKey(const QString&)) ); 526 connect( dayView, SIGNAL(sigNewEvent(const QString&)), this, SLOT(slotNewEventFromKey(const QString&)) );
527 } 527 }
528} 528}
529 529
530void DateBook::initWeek() 530void DateBook::initWeek()
531{ 531{
532 if ( !weekView ) { 532 if ( !weekView ) {
533 weekView = new DateBookWeek( ampm, onMonday, db, views, "week view" ); 533 weekView = new DateBookWeek( ampm, onMonday, db, views, "week view" );
534 weekView->setStartViewTime( startTime ); 534 weekView->setStartViewTime( startTime );
535 views->addWidget( weekView, WEEK ); 535 views->addWidget( weekView, WEEK );
536 connect( weekView, SIGNAL( showDate(int,int,int) ), this, SLOT( showDay(int,int,int) ) ); 536 connect( weekView, SIGNAL( showDate(int,int,int) ), this, SLOT( showDay(int,int,int) ) );
537 connect( this, SIGNAL( newEvent() ), weekView, SLOT( redraw() ) ); 537 connect( this, SIGNAL( newEvent() ), weekView, SLOT( redraw() ) );
538 } 538 }
539 539
540 //But also get it right: the year that we display can be different 540 //But also get it right: the year that we display can be different
541 //from the year of the current date. So, first find the year 541 //from the year of the current date. So, first find the year
542 //number of the current week. 542 //number of the current week.
543 int yearNumber, totWeeks; 543 int yearNumber, totWeeks;
544 calcWeek( currentDate(), totWeeks, yearNumber, onMonday ); 544 calcWeek( currentDate(), totWeeks, yearNumber, onMonday );
545 545
546 QDate d = QDate( yearNumber, 12, 31 ); 546 QDate d = QDate( yearNumber, 12, 31 );
547 calcWeek( d, totWeeks, yearNumber, onMonday ); 547 calcWeek( d, totWeeks, yearNumber, onMonday );
548 548
549 while ( totWeeks == 1 ) { 549 while ( totWeeks == 1 ) {
550 d = d.addDays( -1 ); 550 d = d.addDays( -1 );
551 calcWeek( d, totWeeks, yearNumber, onMonday ); 551 calcWeek( d, totWeeks, yearNumber, onMonday );
552 } 552 }
553} 553}
554 554
555void DateBook::initWeekLst() { 555void DateBook::initWeekLst() {
556 if ( !weekLstView ) { 556 if ( !weekLstView ) {
557 weekLstView = new DateBookWeekLst( ampm, onMonday, db, views, "weeklst view" ); 557 weekLstView = new DateBookWeekLst( ampm, onMonday, db, views, "weeklst view" );
558 views->addWidget( weekLstView, WEEKLST ); 558 views->addWidget( weekLstView, WEEKLST );
559 559
560 //weekLstView->setStartViewTime( startTime ); 560 //weekLstView->setStartViewTime( startTime );
561 connect( weekLstView, SIGNAL( showDate(int,int,int) ), this, SLOT( showDay(int,int,int) ) ); 561 connect( weekLstView, SIGNAL( showDate(int,int,int) ), this, SLOT( showDay(int,int,int) ) );
562 connect( weekLstView, SIGNAL( addEvent(const QDateTime&,const QDateTime&,const QString&, const QString&) ), 562 connect( weekLstView, SIGNAL( addEvent(const QDateTime&,const QDateTime&,const QString&, const QString&) ),
563 this, SLOT( slotNewEntry(const QDateTime&,const QDateTime&,const QString&, const QString&) ) ); 563 this, SLOT( slotNewEntry(const QDateTime&,const QDateTime&,const QString&, const QString&) ) );
564 connect( this, SIGNAL( newEvent() ), weekLstView, SLOT( redraw() ) ); 564 connect( this, SIGNAL( newEvent() ), weekLstView, SLOT( redraw() ) );
565 connect( weekLstView, SIGNAL( editEvent(const Event&) ), this, SLOT( editEvent(const Event&) ) ); 565 connect( weekLstView, SIGNAL( editEvent(const Event&) ), this, SLOT( editEvent(const Event&) ) );
566 connect( weekLstView, SIGNAL( duplicateEvent( const Event & ) ), this, SLOT( duplicateEvent( const Event & ) ) );
567 connect( weekLstView, SIGNAL( beamEvent(const Event&) ), this, SLOT( beamEvent(const Event&) ) );
568 connect( weekLstView, SIGNAL( removeEvent( const Event & ) ), this, SLOT( removeEvent( const Event & ) ) );
566 } 569 }
567} 570}
568 571
569 572
570void DateBook::initMonth() 573void DateBook::initMonth()
571{ 574{
572 if ( !monthView ) { 575 if ( !monthView ) {
573 monthView = new DateBookMonth( views, "month view", FALSE, db ); 576 monthView = new DateBookMonth( views, "month view", FALSE, db );
574 views->addWidget( monthView, MONTH ); 577 views->addWidget( monthView, MONTH );
575 connect( monthView, SIGNAL( dateClicked(int,int,int) ), this, SLOT( showDay(int,int,int) ) ); 578 connect( monthView, SIGNAL( dateClicked(int,int,int) ), this, SLOT( showDay(int,int,int) ) );
576 connect( this, SIGNAL( newEvent() ), monthView, SLOT( redraw() ) ); 579 connect( this, SIGNAL( newEvent() ), monthView, SLOT( redraw() ) );
577 qApp->processEvents(); 580 qApp->processEvents();
578 } 581 }
579} 582}
580 583
581void DateBook::loadSettings() 584void DateBook::loadSettings()
582{ 585{
583 Config qpeconfig( "qpe" ); 586 Config qpeconfig( "qpe" );
584 qpeconfig.setGroup("Time"); 587 qpeconfig.setGroup("Time");
585 ampm = qpeconfig.readBoolEntry( "AMPM", TRUE ); 588 ampm = qpeconfig.readBoolEntry( "AMPM", TRUE );
586 onMonday = qpeconfig.readBoolEntry( "MONDAY" ); 589 onMonday = qpeconfig.readBoolEntry( "MONDAY" );
587 590
588 Config config("DateBook"); 591 Config config("DateBook");
589 config.setGroup("Main"); 592 config.setGroup("Main");
590 startTime = config.readNumEntry("startviewtime", 8); 593 startTime = config.readNumEntry("startviewtime", 8);
591 aPreset = config.readBoolEntry("alarmpreset"); 594 aPreset = config.readBoolEntry("alarmpreset");
592 presetTime = config.readNumEntry("presettime"); 595 presetTime = config.readNumEntry("presettime");
593 bJumpToCurTime = config.readBoolEntry("jumptocurtime"); 596 bJumpToCurTime = config.readBoolEntry("jumptocurtime");
594 rowStyle = config.readNumEntry("rowstyle"); 597 rowStyle = config.readNumEntry("rowstyle");
595 defaultView = config.readNumEntry("defaultview",DAY); 598 defaultView = config.readNumEntry("defaultview",DAY);
596 weeklistviewconfig = config.readNumEntry("weeklistviewconfig",NORMAL); 599 weeklistviewconfig = config.readNumEntry("weeklistviewconfig",NORMAL);
597 600
598 defaultLocation=config.readEntry("defaultLocation"); 601 defaultLocation=config.readEntry("defaultLocation");
599 QString tmpString=config.readEntry("defaultCategories"); 602 QString tmpString=config.readEntry("defaultCategories");
600 QStringList tmpStringList=QStringList::split(",",tmpString); 603 QStringList tmpStringList=QStringList::split(",",tmpString);
601 defaultCategories.truncate(0); 604 defaultCategories.truncate(0);
602 605
603 for( QStringList::Iterator i=tmpStringList.begin(); i!=tmpStringList.end(); i++) { 606 for( QStringList::Iterator i=tmpStringList.begin(); i!=tmpStringList.end(); i++) {
604 defaultCategories.resize(defaultCategories.count()+1); 607 defaultCategories.resize(defaultCategories.count()+1);
605 defaultCategories[defaultCategories.count()-1]=(*i).toInt(); 608 defaultCategories[defaultCategories.count()-1]=(*i).toInt();
606 } 609 }
607} 610}
608 611
609void DateBook::saveSettings() 612void DateBook::saveSettings()
610{ 613{
611 Config config( "qpe" ); 614 Config config( "qpe" );
612 Config configDB( "DateBook" ); 615 Config configDB( "DateBook" );
613 configDB.setGroup( "Main" ); 616 configDB.setGroup( "Main" );
614 configDB.writeEntry("startviewtime",startTime); 617 configDB.writeEntry("startviewtime",startTime);
615 configDB.writeEntry("alarmpreset",aPreset); 618 configDB.writeEntry("alarmpreset",aPreset);
616 configDB.writeEntry("presettime",presetTime); 619 configDB.writeEntry("presettime",presetTime);
617 configDB.writeEntry("jumptocurtime", bJumpToCurTime); 620 configDB.writeEntry("jumptocurtime", bJumpToCurTime);
618 configDB.writeEntry("rowstyle", rowStyle); 621 configDB.writeEntry("rowstyle", rowStyle);
619 configDB.writeEntry("defaultview",defaultView); 622 configDB.writeEntry("defaultview",defaultView);
620 configDB.writeEntry("weeklistviewconfig",weeklistviewconfig); 623 configDB.writeEntry("weeklistviewconfig",weeklistviewconfig);
621 624
622 configDB.writeEntry("defaultLocation",defaultLocation); 625 configDB.writeEntry("defaultLocation",defaultLocation);
623 QStringList tmpStringList; 626 QStringList tmpStringList;
624 for( uint i=0; i<defaultCategories.count(); i++) { 627 for( uint i=0; i<defaultCategories.count(); i++) {
625 tmpStringList << QString::number(defaultCategories[i]); 628 tmpStringList << QString::number(defaultCategories[i]);
626 } 629 }
627 configDB.writeEntry("defaultCategories",tmpStringList.join(",")); 630 configDB.writeEntry("defaultCategories",tmpStringList.join(","));
628} 631}
629 632
630void DateBook::appMessage(const QCString& msg, const QByteArray& data) 633void DateBook::appMessage(const QCString& msg, const QByteArray& data)
631{ 634{
632 bool needShow = FALSE; 635 bool needShow = FALSE;
633 if ( msg == "alarm(QDateTime,int)" ) { 636 if ( msg == "alarm(QDateTime,int)" ) {
634 QDataStream ds(data,IO_ReadOnly); 637 QDataStream ds(data,IO_ReadOnly);
635 QDateTime when; int warn; 638 QDateTime when; int warn;
636 ds >> when >> warn; 639 ds >> when >> warn;
637 640
638 // check to make it's okay to continue, 641 // check to make it's okay to continue,
639 // this is the case that the time was set ahead, and 642 // this is the case that the time was set ahead, and
640 // we are forced given a stale alarm... 643 // we are forced given a stale alarm...
641 QDateTime current = QDateTime::currentDateTime(); 644 QDateTime current = QDateTime::currentDateTime();
642 if ( current.time().hour() != when.time().hour() && current.time().minute() != when.time().minute() ) 645 if ( current.time().hour() != when.time().hour() && current.time().minute() != when.time().minute() )
643 return; 646 return;
644 647
645 QValueList<EffectiveEvent> list = db->getEffectiveEvents(when.addSecs(warn*60)); 648 QValueList<EffectiveEvent> list = db->getEffectiveEvents(when.addSecs(warn*60));
646 if ( list.count() > 0 ) { 649 if ( list.count() > 0 ) {
647 QString msg; 650 QString msg;
648 bool bSound = FALSE; 651 bool bSound = FALSE;
649 int stopTimer = 0; 652 int stopTimer = 0;
650 bool found = FALSE; 653 bool found = FALSE;
651 for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); it!=list.end(); ++it ) { 654 for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); it!=list.end(); ++it ) {
652 if ( (*it).event().hasAlarm() ) { 655 if ( (*it).event().hasAlarm() ) {
653 found = TRUE; 656 found = TRUE;
654 msg += "<CENTER><B>" + (*it).description() + "</B>" 657 msg += "<CENTER><B>" + (*it).description() + "</B>"
655 + "<BR>" + (*it).location() + "<BR>" 658 + "<BR>" + (*it).location() + "<BR>"
656 + TimeString::dateString((*it).event().start(),ampm) 659 + TimeString::dateString((*it).event().start(),ampm)
657 + (warn 660 + (warn
658 ? tr(" (in " + QString::number(warn) 661 ? tr(" (in " + QString::number(warn)
659 + tr(" minutes)")) 662 + tr(" minutes)"))
660 : QString("")) 663 : QString(""))
661 + "<BR>" 664 + "<BR>"
662 + (*it).notes() + "</CENTER>"; 665 + (*it).notes() + "</CENTER>";
663 if ( (*it).event().alarmSound() != Event::Silent ) { 666 if ( (*it).event().alarmSound() != Event::Silent ) {
664 bSound = TRUE; 667 bSound = TRUE;
665 } 668 }
666 } 669 }
667 } 670 }
668 if ( found ) { 671 if ( found ) {
669 if ( bSound ) { 672 if ( bSound ) {
670 Sound::soundAlarm(); 673 Sound::soundAlarm();
671 alarmCounter = 0; 674 alarmCounter = 0;
672 stopTimer = startTimer( 5000 ); 675 stopTimer = startTimer( 5000 );
673 } 676 }
674 QDialog dlg( this, 0, TRUE ); 677 QDialog dlg( this, 0, TRUE );
675 QVBoxLayout *vb = new QVBoxLayout( &dlg ); 678 QVBoxLayout *vb = new QVBoxLayout( &dlg );
676 QScrollView *view = new QScrollView( &dlg, "scrollView"); 679 QScrollView *view = new QScrollView( &dlg, "scrollView");
677 view->setResizePolicy( QScrollView::AutoOneFit ); 680 view->setResizePolicy( QScrollView::AutoOneFit );
678 vb->addWidget( view ); 681 vb->addWidget( view );
679 QLabel *lblMsg = new QLabel( msg, &dlg ); 682 QLabel *lblMsg = new QLabel( msg, &dlg );
680 view->addChild( lblMsg ); 683 view->addChild( lblMsg );
681 QPushButton *cmdOk = new QPushButton( tr("OK"), &dlg ); 684 QPushButton *cmdOk = new QPushButton( tr("OK"), &dlg );
682 connect( cmdOk, SIGNAL(clicked()), &dlg, SLOT(accept()) ); 685 connect( cmdOk, SIGNAL(clicked()), &dlg, SLOT(accept()) );
683 vb->addWidget( cmdOk ); 686 vb->addWidget( cmdOk );
684 687
685 needShow = QPEApplication::execDialog( &dlg ); 688 needShow = QPEApplication::execDialog( &dlg );
686 689
687 if ( bSound ) 690 if ( bSound )
688 killTimer( stopTimer ); 691 killTimer( stopTimer );
689 } 692 }
690 } 693 }
691 } else if ( msg == "nextView()" ) { 694 } else if ( msg == "nextView()" ) {
692 needShow = true; 695 needShow = true;
693 if ( !qApp-> activeWindow ( )) { 696 if ( !qApp-> activeWindow ( )) {
694 needShow = TRUE; 697 needShow = TRUE;
695 } else { 698 } else {
696 QWidget* cur = views->visibleWidget(); 699 QWidget* cur = views->visibleWidget();
697 if ( cur ) { 700 if ( cur ) {
698 if ( cur == dayView ) 701 if ( cur == dayView )
699 viewWeek(); 702 viewWeek();
700 else if ( cur == weekView ) 703 else if ( cur == weekView )
701 viewWeekLst(); 704 viewWeekLst();
702 else if ( cur == weekLstView ) 705 else if ( cur == weekLstView )
703 viewMonth(); 706 viewMonth();
704 else if ( cur == monthView ) 707 else if ( cur == monthView )
705 viewDay(); 708 viewDay();
706 needShow = TRUE; 709 needShow = TRUE;
707 } 710 }
708 } 711 }
709 } else if (msg == "editEvent(int)") { 712 } else if (msg == "editEvent(int)") {
710 /* simple copy from receive */ 713 /* simple copy from receive */
711 QDataStream stream(data,IO_ReadOnly); 714 QDataStream stream(data,IO_ReadOnly);
712 int uid; 715 int uid;
713 stream >> uid; 716 stream >> uid;
714 Event e=db->eventByUID(uid); 717 Event e=db->eventByUID(uid);
715 editEvent(e); 718 editEvent(e);
716 } else if (msg == "viewDefault(QDate)"){ 719 } else if (msg == "viewDefault(QDate)"){
717 /* simple copy from receive */ 720 /* simple copy from receive */
718 QDataStream stream(data,IO_ReadOnly); 721 QDataStream stream(data,IO_ReadOnly);
719 QDate day; 722 QDate day;
720 stream >> day; 723 stream >> day;
721 viewDefault(day); 724 viewDefault(day);
722 needShow = true; 725 needShow = true;
723 } 726 }
724 727
725 if ( needShow ) { 728 if ( needShow ) {
726#if defined(Q_WS_QWS) || defined(_WS_QWS_) 729#if defined(Q_WS_QWS) || defined(_WS_QWS_)
727 // showMaximized(); 730 // showMaximized();
728#else 731#else
729 // show(); 732 // show();
730#endif 733#endif
731 // raise(); 734 // raise();
732 QPEApplication::setKeepRunning(); 735 QPEApplication::setKeepRunning();
733 // setActiveWindow(); 736 // setActiveWindow();
734 } 737 }
735} 738}
736 739
737void DateBook::reload() 740void DateBook::reload()
738{ 741{
739 db->reload(); 742 db->reload();
740 if ( dayAction->isOn() ) viewDay(); 743 if ( dayAction->isOn() ) viewDay();
741 else if ( weekAction->isOn() ) viewWeek(); 744 else if ( weekAction->isOn() ) viewWeek();
742 else if ( monthAction->isOn() ) viewMonth(); 745 else if ( monthAction->isOn() ) viewMonth();
743 syncing = FALSE; 746 syncing = FALSE;
744} 747}
745 748
746void DateBook::flush() 749void DateBook::flush()
747{ 750{
748 syncing = TRUE; 751 syncing = TRUE;
749 db->save(); 752 db->save();
750} 753}
751 754
752void DateBook::timerEvent( QTimerEvent *e ) 755void DateBook::timerEvent( QTimerEvent *e )
753{ 756{
754 if ( alarmCounter < 10 ) { 757 if ( alarmCounter < 10 ) {
755 alarmCounter++; 758 alarmCounter++;
756 Sound::soundAlarm(); 759 Sound::soundAlarm();
757 } else { 760 } else {
758 killTimer( e->timerId() ); 761 killTimer( e->timerId() );
759 } 762 }
760} 763}
761 764
762void DateBook::changeClock( bool newClock ) 765void DateBook::changeClock( bool newClock )
763{ 766{
764 ampm = newClock; 767 ampm = newClock;
765 // repaint the affected objects... 768 // repaint the affected objects...
766 if (dayView) dayView->redraw(); 769 if (dayView) dayView->redraw();
767 if (weekView) weekView->redraw(); 770 if (weekView) weekView->redraw();
768 if (weekLstView) weekLstView->redraw(); 771 if (weekLstView) weekLstView->redraw();
769} 772}
770 773
771void DateBook::changeWeek( bool m ) 774void DateBook::changeWeek( bool m )
772{ 775{
773 /* no need to redraw, each widget catches. Do need to 776 /* no need to redraw, each widget catches. Do need to
774 store though for widgets we haven't made yet */ 777 store though for widgets we haven't made yet */
775 onMonday = m; 778 onMonday = m;
776} 779}
777 780
778void DateBook::slotToday() 781void DateBook::slotToday()
779{ 782{
780 // we need to view today using default view 783 // we need to view today using default view
781 view(defaultView,QDate::currentDate()); 784 view(defaultView,QDate::currentDate());
782} 785}
783 786
784void DateBook::closeEvent( QCloseEvent *e ) 787void DateBook::closeEvent( QCloseEvent *e )
785{ 788{
786 if(syncing) { 789 if(syncing) {
787 /* no need to save, did that at flush */ 790 /* no need to save, did that at flush */
788 e->accept(); 791 e->accept();
789 return; 792 return;
790 } 793 }
791 794
792 // save settings will generate it's own error messages, no 795 // save settings will generate it's own error messages, no
793 // need to do checking ourselves. 796 // need to do checking ourselves.
794 saveSettings(); 797 saveSettings();
795 if ( db->save() ) { 798 if ( db->save() ) {
796 e->accept(); 799 e->accept();
797 } else { 800 } else {
798 if ( QMessageBox::critical( this, tr( "Out of space" ), 801 if ( QMessageBox::critical( this, tr( "Out of space" ),
799 tr("Calendar was unable to save\n" 802 tr("Calendar was unable to save\n"
800 "your changes.\n" 803 "your changes.\n"
801 "Free up some space and try again.\n" 804 "Free up some space and try again.\n"
802 "\nQuit anyway?"), 805 "\nQuit anyway?"),
803 QMessageBox::Yes|QMessageBox::Escape, 806 QMessageBox::Yes|QMessageBox::Escape,
804 QMessageBox::No|QMessageBox::Default ) 807 QMessageBox::No|QMessageBox::Default )
805 != QMessageBox::No ) 808 != QMessageBox::No )
806 e->accept(); 809 e->accept();
807 else 810 else
808 e->ignore(); 811 e->ignore();
809 } 812 }
810} 813}
811 814
812// Entering directly from the "keyboard" 815// Entering directly from the "keyboard"
813void DateBook::slotNewEventFromKey( const QString &str ) 816void DateBook::slotNewEventFromKey( const QString &str )
814{ 817{
815 if (syncing) { 818 if (syncing) {
816 QMessageBox::warning( this, tr("Calendar"), 819 QMessageBox::warning( this, tr("Calendar"),
817 tr( "Can not edit data, currently syncing") ); 820 tr( "Can not edit data, currently syncing") );
818 return; 821 return;
819 } 822 }
820 823
821 // We get to here from a key pressed in the Day View 824 // We get to here from a key pressed in the Day View
diff --git a/core/pim/datebook/datebookweeklst.cpp b/core/pim/datebook/datebookweeklst.cpp
index fe2ab51..771aa00 100644
--- a/core/pim/datebook/datebookweeklst.cpp
+++ b/core/pim/datebook/datebookweeklst.cpp
@@ -1,397 +1,436 @@
1#include "namespace_hack.h" 1#include "namespace_hack.h"
2#include "datebookweeklst.h" 2#include "datebookweeklst.h"
3 3
4#include "datebook.h" 4#include "datebook.h"
5 5
6#include <opie2/odebug.h> 6#include <opie2/odebug.h>
7 7
8#include <qpe/datebookmonth.h> 8#include <qpe/datebookmonth.h>
9#include <qpe/config.h> 9#include <qpe/config.h>
10#include <qpe/ir.h>
10#include <qpe/resource.h> 11#include <qpe/resource.h>
11 12
12#include <qlayout.h> 13#include <qlayout.h>
13#include <qtoolbutton.h> 14#include <qtoolbutton.h>
14#include <qtl.h> 15#include <qtl.h>
15 16
16bool calcWeek(const QDate &d, int &week, int &year,bool startOnMonday = false); 17bool calcWeek(const QDate &d, int &week, int &year,bool startOnMonday = false);
17 18
18using namespace Opie::Ui; 19using namespace Opie::Ui;
19DateBookWeekLstHeader::DateBookWeekLstHeader(bool onM, QWidget* parent, const char* name, WFlags fl) 20DateBookWeekLstHeader::DateBookWeekLstHeader(bool onM, QWidget* parent, const char* name, WFlags fl)
20 : DateBookWeekLstHeaderBase(parent, name, fl) 21 : DateBookWeekLstHeaderBase(parent, name, fl)
21{ 22{
22 setBackgroundMode( PaletteButton ); 23 setBackgroundMode( PaletteButton );
23 labelDate->setBackgroundMode( PaletteButton ); 24 labelDate->setBackgroundMode( PaletteButton );
24 forwardweek->setBackgroundMode( PaletteButton ); 25 forwardweek->setBackgroundMode( PaletteButton );
25 forwardweek->setPixmap( Resource::loadPixmap("forward") ); 26 forwardweek->setPixmap( Resource::loadPixmap("forward") );
26 forwardmonth->setBackgroundMode( PaletteButton ); 27 forwardmonth->setBackgroundMode( PaletteButton );
27 forwardmonth->setPixmap( Resource::loadPixmap("fastforward") ); 28 forwardmonth->setPixmap( Resource::loadPixmap("fastforward") );
28 backweek->setBackgroundMode( PaletteButton ); 29 backweek->setBackgroundMode( PaletteButton );
29 backweek->setPixmap( Resource::loadPixmap("back") ); 30 backweek->setPixmap( Resource::loadPixmap("back") );
30 backmonth->setBackgroundMode( PaletteButton ); 31 backmonth->setBackgroundMode( PaletteButton );
31 backmonth->setPixmap( Resource::loadPixmap("fastback") ); 32 backmonth->setPixmap( Resource::loadPixmap("fastback") );
32 DateBookWeekLstHeaderBaseLayout->setSpacing(0); 33 DateBookWeekLstHeaderBaseLayout->setSpacing(0);
33 DateBookWeekLstHeaderBaseLayout->setMargin(0); 34 DateBookWeekLstHeaderBaseLayout->setMargin(0);
34 //setSizePolicy(QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding)); 35 //setSizePolicy(QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding));
35 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); 36 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed));
36 37
37 connect(backmonth, SIGNAL(clicked()), this, SLOT(prevMonth())); 38 connect(backmonth, SIGNAL(clicked()), this, SLOT(prevMonth()));
38 connect(backweek, SIGNAL(clicked()), this, SLOT(prevWeek())); 39 connect(backweek, SIGNAL(clicked()), this, SLOT(prevWeek()));
39 connect(forwardweek, SIGNAL(clicked()), this, SLOT(nextWeek())); 40 connect(forwardweek, SIGNAL(clicked()), this, SLOT(nextWeek()));
40 connect(forwardmonth, SIGNAL(clicked()), this, SLOT(nextMonth())); 41 connect(forwardmonth, SIGNAL(clicked()), this, SLOT(nextMonth()));
41 connect(labelDate, SIGNAL(clicked()), this, SLOT(pickDate())); 42 connect(labelDate, SIGNAL(clicked()), this, SLOT(pickDate()));
42 connect(dbl, SIGNAL(toggled(bool)), this, SIGNAL(setDbl(bool))); 43 connect(dbl, SIGNAL(toggled(bool)), this, SIGNAL(setDbl(bool)));
43 bStartOnMonday=onM; 44 bStartOnMonday=onM;
44} 45}
45DateBookWeekLstHeader::~DateBookWeekLstHeader(){} 46DateBookWeekLstHeader::~DateBookWeekLstHeader(){}
46 47
47void DateBookWeekLstHeader::setDate(const QDate &d) { 48void DateBookWeekLstHeader::setDate(const QDate &d) {
48 int year,week,dayofweek; 49 int year,week,dayofweek;
49 date=d; 50 date=d;
50 dayofweek=d.dayOfWeek(); 51 dayofweek=d.dayOfWeek();
51 if(bStartOnMonday) 52 if(bStartOnMonday)
52 dayofweek--; 53 dayofweek--;
53 else if( dayofweek == 7 ) 54 else if( dayofweek == 7 )
54 /* we already have the right day -7 would lead to the same week */ 55 /* we already have the right day -7 would lead to the same week */
55 dayofweek = 0; 56 dayofweek = 0;
56 57
57 date=date.addDays(-dayofweek); 58 date=date.addDays(-dayofweek);
58 59
59 calcWeek(date,week,year,bStartOnMonday); 60 calcWeek(date,week,year,bStartOnMonday);
60 QDate start=date; 61 QDate start=date;
61 QDate stop=start.addDays(6); 62 QDate stop=start.addDays(6);
62 labelDate->setText( QString::number(start.day()) + "." + 63 labelDate->setText( QString::number(start.day()) + "." +
63 Calendar::nameOfMonth( start.month() ) + "-" + 64 Calendar::nameOfMonth( start.month() ) + "-" +
64 QString::number(stop.day()) + "." + 65 QString::number(stop.day()) + "." +
65 Calendar::nameOfMonth( stop.month()) +" ("+ 66 Calendar::nameOfMonth( stop.month()) +" ("+
66 tr("w")+":"+QString::number( week ) +")"); 67 tr("w")+":"+QString::number( week ) +")");
67 date = d; // bugfix: 0001126 - date has to be the selected date, not monday! 68 date = d; // bugfix: 0001126 - date has to be the selected date, not monday!
68 emit dateChanged(date); 69 emit dateChanged(date);
69} 70}
70 71
71void DateBookWeekLstHeader::pickDate() { 72void DateBookWeekLstHeader::pickDate() {
72 static QPopupMenu *m1 = 0; 73 static QPopupMenu *m1 = 0;
73 static DateBookMonth *picker = 0; 74 static DateBookMonth *picker = 0;
74 if ( !m1 ) { 75 if ( !m1 ) {
75 m1 = new QPopupMenu( this ); 76 m1 = new QPopupMenu( this );
76 picker = new DateBookMonth( m1, 0, TRUE ); 77 picker = new DateBookMonth( m1, 0, TRUE );
77 m1->insertItem( picker ); 78 m1->insertItem( picker );
78 connect( picker, SIGNAL( dateClicked(int,int,int) ),this, SLOT( setDate(int,int,int) ) ); 79 connect( picker, SIGNAL( dateClicked(int,int,int) ),this, SLOT( setDate(int,int,int) ) );
79 //connect( m1, SIGNAL( aboutToHide() ), 80 //connect( m1, SIGNAL( aboutToHide() ),
80 //this, SLOT( gotHide() ) ); 81 //this, SLOT( gotHide() ) );
81 } 82 }
82 picker->setDate( date.year(), date.month(), date.day() ); 83 picker->setDate( date.year(), date.month(), date.day() );
83 m1->popup(mapToGlobal(labelDate->pos()+QPoint(0,labelDate->height()))); 84 m1->popup(mapToGlobal(labelDate->pos()+QPoint(0,labelDate->height())));
84 picker->setFocus(); 85 picker->setFocus();
85} 86}
86void DateBookWeekLstHeader::setDate(int y, int m, int d) { 87void DateBookWeekLstHeader::setDate(int y, int m, int d) {
87 setDate(QDate(y,m,d)); 88 setDate(QDate(y,m,d));
88} 89}
89 90
90void DateBookWeekLstHeader::nextWeek() { 91void DateBookWeekLstHeader::nextWeek() {
91 setDate(date.addDays(7)); 92 setDate(date.addDays(7));
92} 93}
93void DateBookWeekLstHeader::prevWeek() { 94void DateBookWeekLstHeader::prevWeek() {
94 setDate(date.addDays(-7)); 95 setDate(date.addDays(-7));
95} 96}
96void DateBookWeekLstHeader::nextMonth() 97void DateBookWeekLstHeader::nextMonth()
97{ 98{
98 setDate(date.addDays(28)); 99 setDate(date.addDays(28));
99} 100}
100void DateBookWeekLstHeader::prevMonth() 101void DateBookWeekLstHeader::prevMonth()
101{ 102{
102 setDate(date.addDays(-28)); 103 setDate(date.addDays(-28));
103} 104}
104 105
105DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool /* onM */, 106DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool /* onM */,
106 QWidget* parent, 107 QWidget* parent,
107 const char* name, 108 const char* name,
108 WFlags fl ) 109 WFlags fl )
109 : DateBookWeekLstDayHdrBase(parent, name, fl) { 110 : DateBookWeekLstDayHdrBase(parent, name, fl) {
110 111
111 date=d; 112 date=d;
112 113
113 static const QString wdays=tr("MTWTFSSM", "Week days"); 114 static const QString wdays=tr("MTWTFSSM", "Week days");
114 char day=wdays[d.dayOfWeek()-1]; 115 char day=wdays[d.dayOfWeek()-1];
115 116
116 //dont use dayOfWeek() to save space ! 117 //dont use dayOfWeek() to save space !
117 label->setText( QString(QObject::tr(QString(QChar(day)))) + " " +QString::number(d.day()) ); 118 label->setText( QString(QObject::tr(QString(QChar(day)))) + " " +QString::number(d.day()) );
118 119
119 add->setText("+"); 120 add->setText("+");
120 121
121 if (d == QDate::currentDate()) { 122 if (d == QDate::currentDate()) {
122 QPalette pal=label->palette(); 123 QPalette pal=label->palette();
123 pal.setColor(QColorGroup::Foreground, QColor(0,0,255)); 124 pal.setColor(QColorGroup::Foreground, QColor(0,0,255));
124 label->setPalette(pal); 125 label->setPalette(pal);
125 126
126 /* 127 /*
127 QFont f=label->font(); 128 QFont f=label->font();
128 f.setItalic(true); 129 f.setItalic(true);
129 label->setFont(f); 130 label->setFont(f);
130 label->setPalette(QPalette(QColor(0,0,255),label->backgroundColor())); 131 label->setPalette(QPalette(QColor(0,0,255),label->backgroundColor()));
131 */ 132 */
132 } else if (d.dayOfWeek() == 7) { // FIXME: Match any holiday 133 } else if (d.dayOfWeek() == 7) { // FIXME: Match any holiday
133 QPalette pal=label->palette(); 134 QPalette pal=label->palette();
134 pal.setColor(QColorGroup::Foreground, QColor(255,0,0)); 135 pal.setColor(QColorGroup::Foreground, QColor(255,0,0));
135 label->setPalette(pal); 136 label->setPalette(pal);
136 } 137 }
137 138
138 connect (label, SIGNAL(clicked()), this, SLOT(showDay())); 139 connect (label, SIGNAL(clicked()), this, SLOT(showDay()));
139 connect (add, SIGNAL(clicked()), this, SLOT(newEvent())); 140 connect (add, SIGNAL(clicked()), this, SLOT(newEvent()));
140} 141}
141 142
142void DateBookWeekLstDayHdr::showDay() { 143void DateBookWeekLstDayHdr::showDay() {
143 emit showDate(date.year(), date.month(), date.day()); 144 emit showDate(date.year(), date.month(), date.day());
144} 145}
145 146
146void DateBookWeekLstDayHdr::newEvent() { 147void DateBookWeekLstDayHdr::newEvent() {
147 QDateTime start, stop; 148 QDateTime start, stop;
148 start=stop=date; 149 start=stop=date;
149 start.setTime(QTime(10,0)); 150 start.setTime(QTime(10,0));
150 stop.setTime(QTime(12,0)); 151 stop.setTime(QTime(12,0));
151 152
152 emit addEvent(start,stop,"",0); 153 emit addEvent(start,stop,"",0);
153} 154}
154DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev, 155DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev,
155 int weeklistviewconfig, 156 int weeklistviewconfig,
156 QWidget* parent, 157 QWidget* parent,
157 const char* name, 158 const char* name,
158 WFlags fl ) : OClickableLabel(parent,name,fl), event(ev) 159 WFlags fl ) : OClickableLabel(parent,name,fl), event(ev)
159{ 160{
160 // old values... lastday = "__|__", middle=" |---", Firstday="00:00", 161 // old values... lastday = "__|__", middle=" |---", Firstday="00:00",
161 QString s,start,middle,end,day; 162 QString s,start,middle,end,day;
162 163
163 odebug << "weeklistviewconfig=" << weeklistviewconfig << oendl; 164 odebug << "weeklistviewconfig=" << weeklistviewconfig << oendl;
164 if(weeklistviewconfig==NONE) {// No times displayed. 165 if(weeklistviewconfig==NONE) {// No times displayed.
165 // start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute()); 166 // start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute());
166 // middle.sprintf("<--->"); 167 // middle.sprintf("<--->");
167 // end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute()); 168 // end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute());
168 // day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute()); 169 // day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute());
169 } else if(weeklistviewconfig==NORMAL) {// "Normal", only display start time. 170 } else if(weeklistviewconfig==NORMAL) {// "Normal", only display start time.
170 start.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute()); 171 start.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute());
171 middle.sprintf(" |---"); 172 middle.sprintf(" |---");
172 end.sprintf("__|__"); 173 end.sprintf("__|__");
173 day.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute()); 174 day.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute());
174 } else if(weeklistviewconfig==EXTENDED) { // Extended mode, display start and end times. 175 } else if(weeklistviewconfig==EXTENDED) { // Extended mode, display start and end times.
175 start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute()); 176 start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute());
176 middle.sprintf("<--->"); 177 middle.sprintf("<--->");
177 end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute()); 178 end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute());
178 day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute()); 179 day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute());
179 } 180 }
180 181
181 if(ev.event().type() == Event::Normal) { 182 if(ev.event().type() == Event::Normal) {
182 if(ev.startDate()==ev.date() && ev.endDate()==ev.date()) {// day event. 183 if(ev.startDate()==ev.date() && ev.endDate()==ev.date()) {// day event.
183 s=day; 184 s=day;
184 } else if(ev.startDate()==ev.date()) {// start event. 185 } else if(ev.startDate()==ev.date()) {// start event.
185 s=start; 186 s=start;
186 } else if(ev.endDate()==ev.date()) { // end event. 187 } else if(ev.endDate()==ev.date()) { // end event.
187 s=end; 188 s=end;
188 } else {// middle day. 189 } else {// middle day.
189 s=middle; 190 s=middle;
190 } 191 }
191 } else { 192 } else {
192 s=""; 193 s="";
193 } 194 }
194 setText(QString(s) + " " + ev.description()); 195 setText(QString(s) + " " + ev.description());
195 connect(this, SIGNAL(clicked()), this, SLOT(editMe())); 196 //connect(this, SIGNAL(clicked()), this, SLOT(editMe()));
196 setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); 197 setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) );
197} 198}
198void DateBookWeekLstEvent::editMe() { 199void DateBookWeekLstEvent::editMe() {
199 emit editEvent(event.event()); 200 emit editEvent(event.event());
200} 201}
201 202void DateBookWeekLstEvent::duplicateMe()
203{
204 emit duplicateEvent(event.event());
205}
206void DateBookWeekLstEvent::deleteMe()
207{
208 emit removeEvent(event.event());
209 emit redraw();
210}
211void DateBookWeekLstEvent::beamMe()
212{
213 emit beamEvent( event.event() );
214}
215void DateBookWeekLstEvent::mousePressEvent( QMouseEvent *e )
216{
217 popmenue = new QPopupMenu;
218 popmenue->insertItem( tr( "Edit" ), this, SLOT(editMe()));
219 popmenue->insertItem( tr( "Duplicate" ), this, SLOT(duplicateMe()));
220 popmenue->insertItem( tr( "Delete" ), this, SLOT(deleteMe()));
221 if(Ir::supported())
222 popmenue->insertItem( tr( "Beam" ), this, SLOT(beamMe()));
223 popmenue->popup( mapToGlobal( e->pos() ));
224}
202 225
203DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev, 226DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev,
204 const QDate &d, bool onM, 227 const QDate &d, bool onM,
205 QWidget* parent, 228 QWidget* parent,
206 const char* name, WFlags fl) 229 const char* name, WFlags fl)
207 : QWidget( parent, name, fl ) 230 : QWidget( parent, name, fl )
208{ 231{
209 Config config("DateBook"); 232 Config config("DateBook");
210 config.setGroup("Main"); 233 config.setGroup("Main");
211 int weeklistviewconfig=config.readNumEntry("weeklistviewconfig", NORMAL); 234 int weeklistviewconfig=config.readNumEntry("weeklistviewconfig", NORMAL);
212 odebug << "weeklistviewconfig: " << weeklistviewconfig << oendl; 235 odebug << "weeklistviewconfig: " << weeklistviewconfig << oendl;
213 236
214 bStartOnMonday=onM; 237 bStartOnMonday=onM;
215 setPalette(white); 238 setPalette(white);
216 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding)); 239 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding));
217 240
218 QVBoxLayout *layout = new QVBoxLayout( this ); 241 QVBoxLayout *layout = new QVBoxLayout( this );
219 242
220 qBubbleSort(ev); 243 qBubbleSort(ev);
221 QValueListIterator<EffectiveEvent> it; 244 QValueListIterator<EffectiveEvent> it;
222 it=ev.begin(); 245 it=ev.begin();
223 246
224 int dayOrder[7]; 247 int dayOrder[7];
225 if (bStartOnMonday) { 248 if (bStartOnMonday) {
226 for (int d=0; d<7; d++) dayOrder[d]=d+1; 249 for (int d=0; d<7; d++) dayOrder[d]=d+1;
227 } else { 250 } else {
228 for (int d=0; d<7; d++) dayOrder[d]=d; 251 for (int d=0; d<7; d++) dayOrder[d]=d;
229 dayOrder[0]=7; 252 dayOrder[0]=7;
230 } 253 }
231 254
232 // Calculate offset to first day of week. 255 // Calculate offset to first day of week.
233 int dayoffset=d.dayOfWeek(); 256 int dayoffset=d.dayOfWeek();
234 if(bStartOnMonday) dayoffset--; 257 if(bStartOnMonday) dayoffset--;
235 else if( dayoffset == 7 ) dayoffset = 0; 258 else if( dayoffset == 7 ) dayoffset = 0;
236 259
237 for (int i=0; i<7; i++) { 260 for (int i=0; i<7; i++) {
238 // Header 261 // Header
239 DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i-dayoffset), bStartOnMonday,this); 262 DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i-dayoffset), bStartOnMonday,this);
240 connect(hdr, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); 263 connect(hdr, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
241 connect(hdr, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), 264 connect(hdr, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
242 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); 265 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
243 layout->addWidget(hdr); 266 layout->addWidget(hdr);
244 267
245 // Events 268 // Events
246 while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) { 269 while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) {
247 if(!(((*it).end().hour()==0) && ((*it).end().minute()==0) && ((*it).startDate()!=(*it).date()))) {// Skip events ending at 00:00 starting at another day. 270 if(!(((*it).end().hour()==0) && ((*it).end().minute()==0) && ((*it).startDate()!=(*it).date()))) {// Skip events ending at 00:00 starting at another day.
248 DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,weeklistviewconfig,this); 271 DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,weeklistviewconfig,this);
249 layout->addWidget(l); 272 layout->addWidget(l);
250 connect (l, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); 273 connect (l, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&)));
274 connect (l, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &)));
275 connect (l, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &)));
276 connect (l, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &)));
277 connect (l, SIGNAL(redraw()), this, SIGNAL(redraw()));
251 } 278 }
252 it++; 279 it++;
253 } 280 }
254 layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); 281 layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding));
255 } 282 }
256} 283}
257DateBookWeekLstView::~DateBookWeekLstView(){} 284DateBookWeekLstView::~DateBookWeekLstView(){}
258void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) {e->ignore();} 285void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) {e->ignore();}
259 286
260DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, 287DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1,
261 QValueList<EffectiveEvent> &ev2, 288 QValueList<EffectiveEvent> &ev2,
262 QDate &d, bool onM, 289 QDate &d, bool onM,
263 QWidget* parent, 290 QWidget* parent,
264 const char* name, WFlags fl) 291 const char* name, WFlags fl)
265 : QWidget( parent, name, fl ) 292 : QWidget( parent, name, fl )
266{ 293{
267 QHBoxLayout *layout = new QHBoxLayout( this ); 294 QHBoxLayout *layout = new QHBoxLayout( this );
268 295
269 DateBookWeekLstView *w=new DateBookWeekLstView(ev1,d,onM,this); 296 DateBookWeekLstView *w=new DateBookWeekLstView(ev1,d,onM,this);
270 layout->addWidget(w); 297 layout->addWidget(w);
271 connect (w, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); 298 connect (w, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&)));
299 connect (w, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &)));
300 connect (w, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &)));
301 connect (w, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &)));
302 connect (w, SIGNAL(redraw()), this, SIGNAL(redraw()));
272 connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); 303 connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
273 connect (w, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), 304 connect (w, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
274 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); 305 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
275 306
276 307
277 w=new DateBookWeekLstView(ev2,d.addDays(7),onM,this); 308 w=new DateBookWeekLstView(ev2,d.addDays(7),onM,this);
278 layout->addWidget(w); 309 layout->addWidget(w);
279 connect (w, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); 310 connect (w, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&)));
311 connect (w, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &)));
312 connect (w, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &)));
313 connect (w, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &)));
314 connect (w, SIGNAL(redraw()), this, SIGNAL(redraw()));
280 connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); 315 connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
281 connect (w, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), 316 connect (w, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
282 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); 317 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
283} 318}
284 319
285DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB, 320DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB,
286 QWidget *parent, 321 QWidget *parent,
287 const char *name ) 322 const char *name )
288 : QWidget( parent, name ), 323 : QWidget( parent, name ),
289 db( newDB ), 324 db( newDB ),
290 startTime( 0 ), 325 startTime( 0 ),
291 ampm( ap ), 326 ampm( ap ),
292 bStartOnMonday(onM) 327 bStartOnMonday(onM)
293{ 328{
294 setFocusPolicy(StrongFocus); 329 setFocusPolicy(StrongFocus);
295 layout = new QVBoxLayout( this ); 330 layout = new QVBoxLayout( this );
296 layout->setMargin(0); 331 layout->setMargin(0);
297 332
298 header=new DateBookWeekLstHeader(onM, this); 333 header=new DateBookWeekLstHeader(onM, this);
299 layout->addWidget( header ); 334 layout->addWidget( header );
300 connect(header, SIGNAL(dateChanged(QDate&)), this, SLOT(dateChanged(QDate&))); 335 connect(header, SIGNAL(dateChanged(QDate&)), this, SLOT(dateChanged(QDate&)));
301 connect(header, SIGNAL(setDbl(bool)), this, SLOT(setDbl(bool))); 336 connect(header, SIGNAL(setDbl(bool)), this, SLOT(setDbl(bool)));
302 337
303 scroll=new QScrollView(this); 338 scroll=new QScrollView(this);
304 scroll->setResizePolicy(QScrollView::AutoOneFit); 339 scroll->setResizePolicy(QScrollView::AutoOneFit);
305 layout->addWidget(scroll); 340 layout->addWidget(scroll);
306 341
307 view=NULL; 342 view=NULL;
308 Config config("DateBook"); 343 Config config("DateBook");
309 config.setGroup("Main"); 344 config.setGroup("Main");
310 dbl=config.readBoolEntry("weeklst_dbl", false); 345 dbl=config.readBoolEntry("weeklst_dbl", false);
311 header->dbl->setOn(dbl); 346 header->dbl->setOn(dbl);
312} 347}
313DateBookWeekLst::~DateBookWeekLst(){ 348DateBookWeekLst::~DateBookWeekLst(){
314 Config config("DateBook"); 349 Config config("DateBook");
315 config.setGroup("Main"); 350 config.setGroup("Main");
316 config.writeEntry("weeklst_dbl", dbl); 351 config.writeEntry("weeklst_dbl", dbl);
317} 352}
318 353
319void DateBookWeekLst::setDate(const QDate &d) { 354void DateBookWeekLst::setDate(const QDate &d) {
320 bdate=d; 355 bdate=d;
321 header->setDate(d); 356 header->setDate(d);
322} 357}
323 358
324void DateBookWeekLst::setDbl(bool on) { 359void DateBookWeekLst::setDbl(bool on) {
325 dbl=on; 360 dbl=on;
326 redraw(); 361 redraw();
327} 362}
328void DateBookWeekLst::redraw() {getEvents();} 363void DateBookWeekLst::redraw() {getEvents();}
329 364
330QDate DateBookWeekLst::date() { 365QDate DateBookWeekLst::date() {
331 return bdate; 366 return bdate;
332} 367}
333 368
334// return the date at the beginning of the week... 369// return the date at the beginning of the week...
335// copied from DateBookWeek 370// copied from DateBookWeek
336QDate DateBookWeekLst::weekDate() const 371QDate DateBookWeekLst::weekDate() const
337{ 372{
338 QDate d=bdate; 373 QDate d=bdate;
339 374
340 // Calculate offset to first day of week. 375 // Calculate offset to first day of week.
341 int dayoffset=d.dayOfWeek(); 376 int dayoffset=d.dayOfWeek();
342 if(bStartOnMonday) dayoffset--; 377 if(bStartOnMonday) dayoffset--;
343 else if( dayoffset == 7 ) 378 else if( dayoffset == 7 )
344 dayoffset = 0; 379 dayoffset = 0;
345 380
346 return d.addDays(-dayoffset); 381 return d.addDays(-dayoffset);
347} 382}
348 383
349void DateBookWeekLst::getEvents() { 384void DateBookWeekLst::getEvents() {
350 QDate start = weekDate(); //date(); 385 QDate start = weekDate(); //date();
351 QDate stop = start.addDays(6); 386 QDate stop = start.addDays(6);
352 QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop); 387 QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop);
353 388
354 if (view) delete view; 389 if (view) delete view;
355 if (dbl) { 390 if (dbl) {
356 QDate start2=start.addDays(7); 391 QDate start2=start.addDays(7);
357 stop=start2.addDays(6); 392 stop=start2.addDays(6);
358 QValueList<EffectiveEvent> el2 = db->getEffectiveEvents(start2, stop); 393 QValueList<EffectiveEvent> el2 = db->getEffectiveEvents(start2, stop);
359 view=new DateBookWeekLstDblView(el,el2,start,bStartOnMonday,scroll); 394 view=new DateBookWeekLstDblView(el,el2,start,bStartOnMonday,scroll);
360 } else { 395 } else {
361 view=new DateBookWeekLstView(el,start,bStartOnMonday,scroll); 396 view=new DateBookWeekLstView(el,start,bStartOnMonday,scroll);
362 } 397 }
363 398
364 connect (view, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); 399 connect (view, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&)));
400 connect (view, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &)));
401 connect (view, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &)));
402 connect (view, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &)));
403 connect (view, SIGNAL(redraw()), this, SLOT(redraw()));
365 connect (view, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); 404 connect (view, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
366 connect (view, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), 405 connect (view, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
367 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); 406 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
368 407
369 scroll->addChild(view); 408 scroll->addChild(view);
370 view->show(); 409 view->show();
371 scroll->updateScrollBars(); 410 scroll->updateScrollBars();
372} 411}
373 412
374void DateBookWeekLst::dateChanged(QDate &newdate) { 413void DateBookWeekLst::dateChanged(QDate &newdate) {
375 bdate=newdate; 414 bdate=newdate;
376 getEvents(); 415 getEvents();
377} 416}
378 417
379void DateBookWeekLst::keyPressEvent(QKeyEvent *e) 418void DateBookWeekLst::keyPressEvent(QKeyEvent *e)
380{ 419{
381 switch(e->key()) { 420 switch(e->key()) {
382 case Key_Up: 421 case Key_Up:
383 scroll->scrollBy(0, -20); 422 scroll->scrollBy(0, -20);
384 break; 423 break;
385 case Key_Down: 424 case Key_Down:
386 scroll->scrollBy(0, 20); 425 scroll->scrollBy(0, 20);
387 break; 426 break;
388 case Key_Left: 427 case Key_Left:
389 header->prevWeek(); 428 header->prevWeek();
390 break; 429 break;
391 case Key_Right: 430 case Key_Right:
392 header->nextWeek(); 431 header->nextWeek();
393 break; 432 break;
394 default: 433 default:
395 e->ignore(); 434 e->ignore();
396 } 435 }
397} 436}
diff --git a/core/pim/datebook/datebookweeklst.h b/core/pim/datebook/datebookweeklst.h
index 32fa23f..3bc7f2f 100644
--- a/core/pim/datebook/datebookweeklst.h
+++ b/core/pim/datebook/datebookweeklst.h
@@ -1,156 +1,177 @@
1#ifndef DATEBOOKWEEKLST 1#ifndef DATEBOOKWEEKLST
2#define DATEBOOKWEEKLST 2#define DATEBOOKWEEKLST
3 3
4#include <qwidget.h> 4#include <qwidget.h>
5#include <qdatetime.h> 5#include <qdatetime.h>
6#include <qpe/event.h> 6#include <qpe/event.h>
7#include <qlabel.h> 7#include <qlabel.h>
8#include <qscrollview.h> 8#include <qscrollview.h>
9 9
10#include "datebookweeklstheader.h" 10#include "datebookweeklstheader.h"
11#include "datebookweeklstdayhdr.h" 11#include "datebookweeklstdayhdr.h"
12 12
13#include <opie2/oclickablelabel.h> 13#include <opie2/oclickablelabel.h>
14 14
15class QDateTime; 15class QDateTime;
16class DateBookDB; 16class DateBookDB;
17 17
18class DateBookWeekLstHeader: public DateBookWeekLstHeaderBase 18class DateBookWeekLstHeader: public DateBookWeekLstHeaderBase
19{ 19{
20 Q_OBJECT 20 Q_OBJECT
21public: 21public:
22 DateBookWeekLstHeader(bool onM, QWidget* parent = 0, const char* name = 0, 22 DateBookWeekLstHeader(bool onM, QWidget* parent = 0, const char* name = 0,
23 WFlags fl = 0 ); 23 WFlags fl = 0 );
24 ~DateBookWeekLstHeader(); 24 ~DateBookWeekLstHeader();
25 void setDate(const QDate &d); 25 void setDate(const QDate &d);
26 26
27public slots: 27public slots:
28 void nextWeek(); 28 void nextWeek();
29 void prevWeek(); 29 void prevWeek();
30 void nextMonth(); 30 void nextMonth();
31 void prevMonth(); 31 void prevMonth();
32 void pickDate(); 32 void pickDate();
33 void setDate(int y, int m, int d); 33 void setDate(int y, int m, int d);
34signals: 34signals:
35 void dateChanged(QDate &newdate); 35 void dateChanged(QDate &newdate);
36 void setDbl(bool on); 36 void setDbl(bool on);
37private: 37private:
38 QDate date; 38 QDate date;
39 //bool onMonday; 39 //bool onMonday;
40 bool bStartOnMonday; 40 bool bStartOnMonday;
41}; 41};
42 42
43class DateBookWeekLstDayHdr: public DateBookWeekLstDayHdrBase 43class DateBookWeekLstDayHdr: public DateBookWeekLstDayHdrBase
44{ 44{
45 Q_OBJECT 45 Q_OBJECT
46public: 46public:
47 DateBookWeekLstDayHdr(const QDate &d, bool onM, 47 DateBookWeekLstDayHdr(const QDate &d, bool onM,
48 QWidget* parent = 0, const char* name = 0, 48 QWidget* parent = 0, const char* name = 0,
49 WFlags fl = 0 ); 49 WFlags fl = 0 );
50public slots: 50public slots:
51 void showDay(); 51 void showDay();
52 void newEvent(); 52 void newEvent();
53signals: 53signals:
54 void showDate(int y, int m, int d); 54 void showDate(int y, int m, int d);
55 void addEvent(const QDateTime &start, const QDateTime &stop, 55 void addEvent(const QDateTime &start, const QDateTime &stop,
56 const QString &str, const QString &location); 56 const QString &str, const QString &location);
57private: 57private:
58 QDate date; 58 QDate date;
59}; 59};
60 60
61class DateBookWeekLstEvent: public Opie::Ui::OClickableLabel 61class DateBookWeekLstEvent: public Opie::Ui::OClickableLabel
62{ 62{
63 Q_OBJECT 63 Q_OBJECT
64public: 64public:
65 DateBookWeekLstEvent(const EffectiveEvent &ev, int weeklistviewconfig =1, 65 DateBookWeekLstEvent(const EffectiveEvent &ev, int weeklistviewconfig =1,
66 QWidget* parent = 0, const char* name = 0, 66 QWidget* parent = 0, const char* name = 0,
67 WFlags fl = 0); 67 WFlags fl = 0);
68signals: 68signals:
69 void editEvent(const Event &e); 69 void editEvent(const Event &e);
70 void duplicateEvent(const Event &e);
71 void removeEvent(const Event &e);
72 void beamEvent(const Event &e);
73 void redraw();
70private slots: 74private slots:
71 void editMe(); 75 void editMe();
76 void duplicateMe();
77 void deleteMe();
78 void beamMe();
72private: 79private:
73 const EffectiveEvent event; 80 const EffectiveEvent event;
81 QPopupMenu* popmenue;
82protected:
83 void mousePressEvent( QMouseEvent *e );
74}; 84};
75 85
76class DateBookWeekLstView: public QWidget 86class DateBookWeekLstView: public QWidget
77{ 87{
78 Q_OBJECT 88 Q_OBJECT
79public: 89public:
80 DateBookWeekLstView(QValueList<EffectiveEvent> &ev, const QDate &d, bool onM, 90 DateBookWeekLstView(QValueList<EffectiveEvent> &ev, const QDate &d, bool onM,
81 QWidget* parent = 0, const char* name = 0, 91 QWidget* parent = 0, const char* name = 0,
82 WFlags fl = 0 ); 92 WFlags fl = 0 );
83 ~DateBookWeekLstView(); 93 ~DateBookWeekLstView();
84signals: 94signals:
85 void editEvent(const Event &e); 95 void editEvent(const Event &e);
96 void duplicateEvent(const Event &e);
97 void removeEvent(const Event &e);
98 void beamEvent(const Event &e);
99 void redraw();
86 void showDate(int y, int m, int d); 100 void showDate(int y, int m, int d);
87 void addEvent(const QDateTime &start, const QDateTime &stop, 101 void addEvent(const QDateTime &start, const QDateTime &stop,
88 const QString &str, const QString &location); 102 const QString &str, const QString &location);
89private: 103private:
90 bool bStartOnMonday; 104 bool bStartOnMonday;
91protected slots: 105protected slots:
92 void keyPressEvent(QKeyEvent *); 106 void keyPressEvent(QKeyEvent *);
93}; 107};
94 108
95class DateBookWeekLstDblView: public QWidget { 109class DateBookWeekLstDblView: public QWidget {
96 Q_OBJECT 110 Q_OBJECT
97public: 111public:
98 DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, 112 DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1,
99 QValueList<EffectiveEvent> &ev2, 113 QValueList<EffectiveEvent> &ev2,
100 QDate &d, bool onM, 114 QDate &d, bool onM,
101 QWidget* parent = 0, const char* name = 0, 115 QWidget* parent = 0, const char* name = 0,
102 WFlags fl = 0 ); 116 WFlags fl = 0 );
103signals: 117signals:
104 void editEvent(const Event &e); 118 void editEvent(const Event &e);
119 void duplicateEvent(const Event &e);
120 void removeEvent(const Event &e);
121 void beamEvent(const Event &e);
122 void redraw();
105 void showDate(int y, int m, int d); 123 void showDate(int y, int m, int d);
106 void addEvent(const QDateTime &start, const QDateTime &stop, 124 void addEvent(const QDateTime &start, const QDateTime &stop,
107 const QString &str, const QString &location); 125 const QString &str, const QString &location);
108}; 126};
109 127
110class DateBookWeekLst : public QWidget 128class DateBookWeekLst : public QWidget
111{ 129{
112 Q_OBJECT 130 Q_OBJECT
113 131
114public: 132public:
115 DateBookWeekLst( bool ampm, bool onM, DateBookDB *newDB, 133 DateBookWeekLst( bool ampm, bool onM, DateBookDB *newDB,
116 QWidget *parent = 0, 134 QWidget *parent = 0,
117 const char *name = 0 ); 135 const char *name = 0 );
118 ~DateBookWeekLst(); 136 ~DateBookWeekLst();
119 void setDate( int y, int w ); 137 void setDate( int y, int w );
120 void setDate(const QDate &d ); 138 void setDate(const QDate &d );
121 int week() const { return _week; }; 139 int week() const { return _week; };
122 QDate date(); 140 QDate date();
123 QDate weekDate() const; 141 QDate weekDate() const;
124 142
125public slots: 143public slots:
126 void redraw(); 144 void redraw();
127 void dateChanged(QDate &date); 145 void dateChanged(QDate &date);
128 146
129protected slots: 147protected slots:
130 void keyPressEvent(QKeyEvent *); 148 void keyPressEvent(QKeyEvent *);
131 void setDbl(bool on); 149 void setDbl(bool on);
132 150
133signals: 151signals:
134 void showDate(int y, int m, int d); 152 void showDate(int y, int m, int d);
135 void addEvent(const QDateTime &start, const QDateTime &stop, 153 void addEvent(const QDateTime &start, const QDateTime &stop,
136 const QString &str, const QString &location); 154 const QString &str, const QString &location);
137 void editEvent(const Event &e); 155 void editEvent(const Event &e);
156 void duplicateEvent(const Event &e);
157 void removeEvent(const Event &e);
158 void beamEvent(const Event &e);
138 159
139private: 160private:
140 DateBookDB *db; 161 DateBookDB *db;
141 int startTime; 162 int startTime;
142 bool ampm; 163 bool ampm;
143 bool bStartOnMonday; 164 bool bStartOnMonday;
144 bool dbl; 165 bool dbl;
145 QDate bdate; 166 QDate bdate;
146 int year, _week,dow; 167 int year, _week,dow;
147 DateBookWeekLstHeader *header; 168 DateBookWeekLstHeader *header;
148 QWidget *view; 169 QWidget *view;
149 QVBoxLayout *layout; 170 QVBoxLayout *layout;
150 QScrollView *scroll; 171 QScrollView *scroll;
151 172
152 void getEvents(); 173 void getEvents();
153}; 174};
154 175
155#endif 176#endif
156 177