summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--korganizer/calendarview.cpp31
-rw-r--r--korganizer/calendarview.h4
-rw-r--r--korganizer/koeventviewer.cpp34
-rw-r--r--korganizer/koeventviewer.h1
-rw-r--r--korganizer/main.cpp26
5 files changed, 67 insertions, 29 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index bf98ad4..c3c3d47 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -410,135 +410,142 @@ void CalendarView::init()
410 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), 410 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ),
411 this, SLOT ( moveIncidence( Incidence * ) ) ); 411 this, SLOT ( moveIncidence( Incidence * ) ) );
412 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), 412 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ),
413 this, SLOT ( beamIncidence( Incidence * ) ) ); 413 this, SLOT ( beamIncidence( Incidence * ) ) );
414 414
415 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), 415 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ),
416 this, SLOT ( todo_unsub( Todo * ) ) ); 416 this, SLOT ( todo_unsub( Todo * ) ) );
417 417
418 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, 418 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList,
419 SLOT( updateTodo( Todo *, int ) ) ); 419 SLOT( updateTodo( Todo *, int ) ) );
420 connect( this, SIGNAL( todoModified( Todo *, int )), this, 420 connect( this, SIGNAL( todoModified( Todo *, int )), this,
421 SLOT( changeTodoDisplay( Todo *, int ) ) ); 421 SLOT( changeTodoDisplay( Todo *, int ) ) );
422 422
423 423
424 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); 424 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) );
425 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); 425 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) );
426 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); 426 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) );
427 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); 427 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) );
428 428
429 429
430 430
431 431
432 432
433 connect(QApplication::clipboard(),SIGNAL(dataChanged()), 433 connect(QApplication::clipboard(),SIGNAL(dataChanged()),
434 SLOT(checkClipboard())); 434 SLOT(checkClipboard()));
435 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), 435 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ),
436 SLOT( processTodoListSelection( Incidence * ) ) ); 436 SLOT( processTodoListSelection( Incidence * ) ) );
437 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); 437 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool)));
438 438
439 // kdDebug() << "CalendarView::CalendarView() done" << endl; 439 // kdDebug() << "CalendarView::CalendarView() done" << endl;
440 440
441 mDateFrame = new QVBox(0,0,WType_Popup); 441 mDateFrame = new QVBox(0,0,WType_Popup);
442 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 442 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
443 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); 443 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised );
444 mDateFrame->setLineWidth(3); 444 mDateFrame->setLineWidth(3);
445 mDateFrame->hide(); 445 mDateFrame->hide();
446 mDateFrame->setCaption( i18n( "Pick a date to display")); 446 mDateFrame->setCaption( i18n( "Pick a date to display"));
447 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); 447 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() );
448 448
449 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); 449 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate)));
450 450
451 mEventEditor = mDialogManager->getEventEditor(); 451 mEventEditor = mDialogManager->getEventEditor();
452 mTodoEditor = mDialogManager->getTodoEditor(); 452 mTodoEditor = mDialogManager->getTodoEditor();
453 453
454 mFlagEditDescription = false; 454 mFlagEditDescription = false;
455 455
456 mSuspendTimer = new QTimer( this ); 456 mSuspendTimer = new QTimer( this );
457 mAlarmTimer = new QTimer( this ); 457 mAlarmTimer = new QTimer( this );
458 mRecheckAlarmTimer = new QTimer( this );
459 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) );
458 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); 460 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
459 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); 461 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
460 mAlarmDialog = new AlarmDialog( this ); 462 mAlarmDialog = new AlarmDialog( this );
461 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); 463 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) );
462 mAlarmDialog->setServerNotification( false ); 464 mAlarmDialog->setServerNotification( false );
463 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); 465 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
464} 466}
465 467
466 468
467CalendarView::~CalendarView() 469CalendarView::~CalendarView()
468{ 470{
469 // kdDebug() << "~CalendarView()" << endl; 471 // kdDebug() << "~CalendarView()" << endl;
470 //qDebug("CalendarView::~CalendarView() "); 472 //qDebug("CalendarView::~CalendarView() ");
471 delete mDialogManager; 473 delete mDialogManager;
472 delete mViewManager; 474 delete mViewManager;
473 delete mStorage; 475 delete mStorage;
474 delete mDateFrame ; 476 delete mDateFrame ;
475 delete beamDialog; 477 delete beamDialog;
476 //kdDebug() << "~CalendarView() done" << endl; 478 //kdDebug() << "~CalendarView() done" << endl;
477} 479}
478void CalendarView::timerAlarm() 480void CalendarView::timerAlarm()
479{ 481{
480 //qDebug("CalendarView::timerAlarm() "); 482 //qDebug("CalendarView::timerAlarm() ");
481 computeAlarm(mAlarmNotification ); 483 computeAlarm(mAlarmNotification );
482} 484}
483 485
484void CalendarView::suspendAlarm() 486void CalendarView::suspendAlarm()
485{ 487{
486 //qDebug(" CalendarView::suspendAlarm() "); 488 //qDebug(" CalendarView::suspendAlarm() ");
487 computeAlarm(mSuspendAlarmNotification ); 489 computeAlarm(mSuspendAlarmNotification );
488 490
489} 491}
490 492
491void CalendarView::startAlarm( QString mess , QString filename) 493void CalendarView::startAlarm( QString mess , QString filename)
492{ 494{
493 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); 495 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount );
496 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) );
494 497
495} 498}
496 499
500void CalendarView::checkNextTimerAlarm()
501{
502 mCalendar->checkAlarmForIncidence( 0, true );
503}
497 504
498void CalendarView::computeAlarm( QString msg ) 505void CalendarView::computeAlarm( QString msg )
499{ 506{
500 507
501 QString mess = msg; 508 QString mess = msg;
502 QString mAlarmMessage = mess.mid( 9 ); 509 QString mAlarmMessage = mess.mid( 9 );
503 QString filename = MainWindow::resourcePath(); 510 QString filename = MainWindow::resourcePath();
504 filename += "koalarm.wav"; 511 filename += "koalarm.wav";
505 QString tempfilename; 512 QString tempfilename;
506 if ( mess.left( 13 ) == "suspend_alarm") { 513 if ( mess.left( 13 ) == "suspend_alarm") {
507 bool error = false; 514 bool error = false;
508 int len = mess.mid( 13 ).find("+++"); 515 int len = mess.mid( 13 ).find("+++");
509 if ( len < 2 ) 516 if ( len < 2 )
510 error = true; 517 error = true;
511 else { 518 else {
512 tempfilename = mess.mid( 13, len ); 519 tempfilename = mess.mid( 13, len );
513 if ( !QFile::exists( tempfilename ) ) 520 if ( !QFile::exists( tempfilename ) )
514 error = true; 521 error = true;
515 } 522 }
516 if ( ! error ) { 523 if ( ! error ) {
517 filename = tempfilename; 524 filename = tempfilename;
518 } 525 }
519 mAlarmMessage = mess.mid( 13+len+3 ); 526 mAlarmMessage = mess.mid( 13+len+3 );
520 //qDebug("suspend file %s ",tempfilename.latin1() ); 527 //qDebug("suspend file %s ",tempfilename.latin1() );
521 startAlarm( mAlarmMessage, filename); 528 startAlarm( mAlarmMessage, filename);
522 return; 529 return;
523 } 530 }
524 if ( mess.left( 11 ) == "timer_alarm") { 531 if ( mess.left( 11 ) == "timer_alarm") {
525 //mTimerTime = 0; 532 //mTimerTime = 0;
526 startAlarm( mess.mid( 11 ), filename ); 533 startAlarm( mess.mid( 11 ), filename );
527 return; 534 return;
528 } 535 }
529 if ( mess.left( 10 ) == "proc_alarm") { 536 if ( mess.left( 10 ) == "proc_alarm") {
530 bool error = false; 537 bool error = false;
531 int len = mess.mid( 10 ).find("+++"); 538 int len = mess.mid( 10 ).find("+++");
532 if ( len < 2 ) 539 if ( len < 2 )
533 error = true; 540 error = true;
534 else { 541 else {
535 tempfilename = mess.mid( 10, len ); 542 tempfilename = mess.mid( 10, len );
536 if ( !QFile::exists( tempfilename ) ) 543 if ( !QFile::exists( tempfilename ) )
537 error = true; 544 error = true;
538 } 545 }
539 if ( error ) { 546 if ( error ) {
540 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 547 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
541 mAlarmMessage += mess.mid( 10+len+3+9 ); 548 mAlarmMessage += mess.mid( 10+len+3+9 );
542 } else { 549 } else {
543 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 550 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
544 //qDebug("-----system command %s ",tempfilename.latin1() ); 551 //qDebug("-----system command %s ",tempfilename.latin1() );
@@ -559,102 +566,120 @@ void CalendarView::computeAlarm( QString msg )
559 566
560 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 567 //qDebug("+++++++system command %s ",tempfilename.latin1() );
561 } 568 }
562 if ( mess.left( 11 ) == "audio_alarm") { 569 if ( mess.left( 11 ) == "audio_alarm") {
563 bool error = false; 570 bool error = false;
564 int len = mess.mid( 11 ).find("+++"); 571 int len = mess.mid( 11 ).find("+++");
565 if ( len < 2 ) 572 if ( len < 2 )
566 error = true; 573 error = true;
567 else { 574 else {
568 tempfilename = mess.mid( 11, len ); 575 tempfilename = mess.mid( 11, len );
569 if ( !QFile::exists( tempfilename ) ) 576 if ( !QFile::exists( tempfilename ) )
570 error = true; 577 error = true;
571 } 578 }
572 if ( ! error ) { 579 if ( ! error ) {
573 filename = tempfilename; 580 filename = tempfilename;
574 } 581 }
575 mAlarmMessage = mess.mid( 11+len+3+9 ); 582 mAlarmMessage = mess.mid( 11+len+3+9 );
576 //qDebug("audio file command %s ",tempfilename.latin1() ); 583 //qDebug("audio file command %s ",tempfilename.latin1() );
577 } 584 }
578 if ( mess.left( 9 ) == "cal_alarm") { 585 if ( mess.left( 9 ) == "cal_alarm") {
579 mAlarmMessage = mess.mid( 9 ) ; 586 mAlarmMessage = mess.mid( 9 ) ;
580 } 587 }
581 588
582 startAlarm( mAlarmMessage, filename ); 589 startAlarm( mAlarmMessage, filename );
583 590
584 591
585} 592}
586 593
587void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti ) 594void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti )
588{ 595{
589 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 596 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
590 597
591 mSuspendAlarmNotification = noti; 598 mSuspendAlarmNotification = noti;
592 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 599 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000;
593 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); 600 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000);
594 mSuspendTimer->start( ms , true ); 601 mSuspendTimer->start( ms , true );
595 602
596} 603}
597 604
598void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti ) 605void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti )
599{ 606{
600 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 607 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
601 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 608 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
602#ifndef DESKTOP_VERSION 609#ifndef DESKTOP_VERSION
603 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); 610 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() );
604#endif 611#endif
605 return; 612 return;
606 } 613 }
614 int maxSec;
615 //maxSec = 5; //testing only
616 maxSec = 86400+3600; // one day+1hour
607 mAlarmNotification = noti; 617 mAlarmNotification = noti;
608 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 618 int sec = QDateTime::currentDateTime().secsTo( qdt );
609 //qDebug("Alarm timer started with secs: %d ", ms/1000); 619 if ( sec > maxSec ) {
610 mAlarmTimer->start( ms , true ); 620 mRecheckAlarmTimer->start( maxSec * 1000 );
621 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec );
622 return;
623 } else {
624 mRecheckAlarmTimer->stop();
625 }
626 //qDebug("Alarm timer started with secs: %d ", sec);
627 mAlarmTimer->start( sec *1000 , true );
611 628
612} 629}
630// called by mRecheckAlarmTimer to get next alarm
631// we need this, because a QTimer has only a max range of 25 days
632void CalendarView::recheckTimerAlarm()
633{
634 mAlarmTimer->stop();
635 mRecheckAlarmTimer->stop();
636 mCalendar->checkAlarmForIncidence( 0, true );
637}
613void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti ) 638void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
614{ 639{
615 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 640 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
616 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 641 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
617#ifndef DESKTOP_VERSION 642#ifndef DESKTOP_VERSION
618 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); 643 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() );
619#endif 644#endif
620 return; 645 return;
621 } 646 }
622 mAlarmTimer->stop(); 647 mAlarmTimer->stop();
623} 648}
624void CalendarView::selectWeekNum ( int num ) 649void CalendarView::selectWeekNum ( int num )
625{ 650{
626 dateNavigator()->selectWeek( num ); 651 dateNavigator()->selectWeek( num );
627 mViewManager->showWeekView(); 652 mViewManager->showWeekView();
628} 653}
629KOViewManager *CalendarView::viewManager() 654KOViewManager *CalendarView::viewManager()
630{ 655{
631 return mViewManager; 656 return mViewManager;
632} 657}
633 658
634KODialogManager *CalendarView::dialogManager() 659KODialogManager *CalendarView::dialogManager()
635{ 660{
636 return mDialogManager; 661 return mDialogManager;
637} 662}
638 663
639QDate CalendarView::startDate() 664QDate CalendarView::startDate()
640{ 665{
641 DateList dates = mNavigator->selectedDates(); 666 DateList dates = mNavigator->selectedDates();
642 667
643 return dates.first(); 668 return dates.first();
644} 669}
645 670
646QDate CalendarView::endDate() 671QDate CalendarView::endDate()
647{ 672{
648 DateList dates = mNavigator->selectedDates(); 673 DateList dates = mNavigator->selectedDates();
649 674
650 return dates.last(); 675 return dates.last();
651} 676}
652 677
653 678
654void CalendarView::createPrinter() 679void CalendarView::createPrinter()
655{ 680{
656#ifndef KORG_NOPRINTER 681#ifndef KORG_NOPRINTER
657 if (!mCalPrinter) { 682 if (!mCalPrinter) {
658 mCalPrinter = new CalPrinter(this, mCalendar); 683 mCalPrinter = new CalPrinter(this, mCalendar);
659 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); 684 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
660 } 685 }
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h
index e7aa351..fda02f7 100644
--- a/korganizer/calendarview.h
+++ b/korganizer/calendarview.h
@@ -126,97 +126,98 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser
126 child windows can also close. */ 126 child windows can also close. */
127 void closingDown(); 127 void closingDown();
128 /** emitted right before we die */ 128 /** emitted right before we die */
129 void closed(QWidget *); 129 void closed(QWidget *);
130 130
131 /** Emitted when state of modified flag changes */ 131 /** Emitted when state of modified flag changes */
132 void modifiedChanged(bool); 132 void modifiedChanged(bool);
133 void signalmodified(); 133 void signalmodified();
134 134
135 /** Emitted when state of read-only flag changes */ 135 /** Emitted when state of read-only flag changes */
136 void readOnlyChanged(bool); 136 void readOnlyChanged(bool);
137 137
138 /** Emitted when the unit of navigation changes */ 138 /** Emitted when the unit of navigation changes */
139 void changeNavStringPrev(const QString &); 139 void changeNavStringPrev(const QString &);
140 void changeNavStringNext(const QString &); 140 void changeNavStringNext(const QString &);
141 141
142 /** Emitted when state of events selection has changed and user is organizer*/ 142 /** Emitted when state of events selection has changed and user is organizer*/
143 void organizerEventsSelected(bool); 143 void organizerEventsSelected(bool);
144 /** Emitted when state of events selection has changed and user is attendee*/ 144 /** Emitted when state of events selection has changed and user is attendee*/
145 void groupEventsSelected(bool); 145 void groupEventsSelected(bool);
146 /** 146 /**
147 Emitted when an incidence gets selected. If the selection is cleared the 147 Emitted when an incidence gets selected. If the selection is cleared the
148 signal is emitted with 0 as argument. 148 signal is emitted with 0 as argument.
149 */ 149 */
150 void incidenceSelected( Incidence * ); 150 void incidenceSelected( Incidence * );
151 /** Emitted, when a todoitem is selected or deselected. */ 151 /** Emitted, when a todoitem is selected or deselected. */
152 void todoSelected( bool ); 152 void todoSelected( bool );
153 153
154 /** 154 /**
155 Emitted, when clipboard content changes. Parameter indicates if paste 155 Emitted, when clipboard content changes. Parameter indicates if paste
156 is possible or not. 156 is possible or not.
157 */ 157 */
158 void pasteEnabled(bool); 158 void pasteEnabled(bool);
159 159
160 /** Emitted, when the number of incoming messages has changed. */ 160 /** Emitted, when the number of incoming messages has changed. */
161 void numIncomingChanged(int); 161 void numIncomingChanged(int);
162 162
163 /** Emitted, when the number of outgoing messages has changed. */ 163 /** Emitted, when the number of outgoing messages has changed. */
164 void numOutgoingChanged(int); 164 void numOutgoingChanged(int);
165 165
166 /** Send status message, which can e.g. be displayed in the status bar. */ 166 /** Send status message, which can e.g. be displayed in the status bar. */
167 void statusMessage(const QString &); 167 void statusMessage(const QString &);
168 168
169 void calendarViewExpanded( bool ); 169 void calendarViewExpanded( bool );
170 void updateSearchDialog(); 170 void updateSearchDialog();
171 171
172 172
173 public slots: 173 public slots:
174 174 void recheckTimerAlarm();
175 void checkNextTimerAlarm();
175 void addAlarm(const QDateTime &qdt, const QString &noti ); 176 void addAlarm(const QDateTime &qdt, const QString &noti );
176 void addSuspendAlarm(const QDateTime &qdt, const QString &noti ); 177 void addSuspendAlarm(const QDateTime &qdt, const QString &noti );
177 void removeAlarm(const QDateTime &qdt, const QString &noti ); 178 void removeAlarm(const QDateTime &qdt, const QString &noti );
178 179
179 /** options dialog made a changed to the configuration. we catch this 180 /** options dialog made a changed to the configuration. we catch this
180 * and notify all widgets which need to update their configuration. */ 181 * and notify all widgets which need to update their configuration. */
181 void updateConfig(); 182 void updateConfig();
182 183
183 /** 184 /**
184 Load calendar from file \a filename. If \a merge is true, load 185 Load calendar from file \a filename. If \a merge is true, load
185 calendar into existing one, if it is false, clear calendar, before 186 calendar into existing one, if it is false, clear calendar, before
186 loading. Return true, if calendar could be successfully loaded. 187 loading. Return true, if calendar could be successfully loaded.
187 */ 188 */
188 bool openCalendar(QString filename, bool merge=false); 189 bool openCalendar(QString filename, bool merge=false);
189 bool syncCalendar(QString filename,int mode = 0 ); 190 bool syncCalendar(QString filename,int mode = 0 );
190 191
191 /** 192 /**
192 Save calendar data to file. Return true if calendar could be 193 Save calendar data to file. Return true if calendar could be
193 successfully saved. 194 successfully saved.
194 */ 195 */
195 bool saveCalendar(QString filename); 196 bool saveCalendar(QString filename);
196 197
197 /** 198 /**
198 Close calendar. Clear calendar data and reset views to display an empty 199 Close calendar. Clear calendar data and reset views to display an empty
199 calendar. 200 calendar.
200 */ 201 */
201 void closeCalendar(); 202 void closeCalendar();
202 203
203 /** Archive old events of calendar */ 204 /** Archive old events of calendar */
204 void archiveCalendar(); 205 void archiveCalendar();
205 206
206 void showIncidence(); 207 void showIncidence();
207 void editIncidence(); 208 void editIncidence();
208 void editIncidenceDescription(); 209 void editIncidenceDescription();
209 void deleteIncidence(); 210 void deleteIncidence();
210 211
211 /** create an editeventwin with supplied date/time, and if bool is true, 212 /** create an editeventwin with supplied date/time, and if bool is true,
212 * make the event take all day. */ 213 * make the event take all day. */
213 void newEvent(QDateTime, QDateTime, bool allDay = false); 214 void newEvent(QDateTime, QDateTime, bool allDay = false);
214 void newEvent(QDateTime fh); 215 void newEvent(QDateTime fh);
215 void newEvent(QDate dt); 216 void newEvent(QDate dt);
216 /** create new event without having a date hint. Takes current date as 217 /** create new event without having a date hint. Takes current date as
217 default hint. */ 218 default hint. */
218 void newEvent(); 219 void newEvent();
219 void newFloatingEvent(); 220 void newFloatingEvent();
220 221
221 /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ 222 /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/
222 void showIncidence(Incidence *); 223 void showIncidence(Incidence *);
@@ -429,96 +430,97 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser
429 void beamCalendar() ; 430 void beamCalendar() ;
430 void beamFilteredCalendar() ; 431 void beamFilteredCalendar() ;
431 void beamIncidenceList(QPtrList<Incidence>) ; 432 void beamIncidenceList(QPtrList<Incidence>) ;
432 void manageCategories(); 433 void manageCategories();
433 int addCategories(); 434 int addCategories();
434 void removeCategories(); 435 void removeCategories();
435 void setSyncDevice( QString ); 436 void setSyncDevice( QString );
436 void setSyncName( QString ); 437 void setSyncName( QString );
437 protected slots: 438 protected slots:
438 void timerAlarm(); 439 void timerAlarm();
439 void suspendAlarm(); 440 void suspendAlarm();
440 void beamDone( Ir *ir ); 441 void beamDone( Ir *ir );
441 /** Select a view or adapt the current view to display the specified dates. */ 442 /** Select a view or adapt the current view to display the specified dates. */
442 void showDates( const KCal::DateList & ); 443 void showDates( const KCal::DateList & );
443 void selectWeekNum ( int ); 444 void selectWeekNum ( int );
444 445
445 public: 446 public:
446 // show a standard warning 447 // show a standard warning
447 // returns KMsgBox::yesNoCancel() 448 // returns KMsgBox::yesNoCancel()
448 int msgCalModified(); 449 int msgCalModified();
449 void confSync(); 450 void confSync();
450 void setLoadedFileVersion(QDateTime); 451 void setLoadedFileVersion(QDateTime);
451 bool checkFileVersion(QString fn); 452 bool checkFileVersion(QString fn);
452 bool checkFileChanged(QString fn); 453 bool checkFileChanged(QString fn);
453 Event* getLastSyncEvent(); 454 Event* getLastSyncEvent();
454 /** Adapt navigation units correpsonding to step size of navigation of the 455 /** Adapt navigation units correpsonding to step size of navigation of the
455 * current view. 456 * current view.
456 */ 457 */
457 void adaptNavigationUnits(); 458 void adaptNavigationUnits();
458 bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); 459 bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode );
459 int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); 460 int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false );
460 //Attendee* getYourAttendee(Event *event); 461 //Attendee* getYourAttendee(Event *event);
461 protected: 462 protected:
462 void schedule(Scheduler::Method, Incidence *incidence = 0); 463 void schedule(Scheduler::Method, Incidence *incidence = 0);
463 464
464 // returns KMsgBox::OKCandel() 465 // returns KMsgBox::OKCandel()
465 int msgItemDelete(); 466 int msgItemDelete();
466 void showEventEditor(); 467 void showEventEditor();
467 void showTodoEditor(); 468 void showTodoEditor();
468 void writeLocale(); 469 void writeLocale();
469 Todo *selectedTodo(); 470 Todo *selectedTodo();
470 471
471 private: 472 private:
472 AlarmDialog * mAlarmDialog; 473 AlarmDialog * mAlarmDialog;
473 QString mAlarmNotification; 474 QString mAlarmNotification;
474 QString mSuspendAlarmNotification; 475 QString mSuspendAlarmNotification;
475 QTimer* mSuspendTimer; 476 QTimer* mSuspendTimer;
476 QTimer* mAlarmTimer; 477 QTimer* mAlarmTimer;
478 QTimer* mRecheckAlarmTimer;
477 void computeAlarm( QString ); 479 void computeAlarm( QString );
478 void startAlarm( QString, QString ); 480 void startAlarm( QString, QString );
479 void setSyncEventsReadOnly(); 481 void setSyncEventsReadOnly();
480 482
481 QDateTime loadedFileVersion; 483 QDateTime loadedFileVersion;
482 void checkSharpEvent( Event* lastSync, Incidence* toDelete ); 484 void checkSharpEvent( Event* lastSync, Incidence* toDelete );
483 QPtrList<KSyncProfile> mSyncProfiles; 485 QPtrList<KSyncProfile> mSyncProfiles;
484 QStringList mSyncProfileNames; 486 QStringList mSyncProfileNames;
485 void checkZaurusId( int id, bool todo = false ); 487 void checkZaurusId( int id, bool todo = false );
486 int mGlobalSyncMode; 488 int mGlobalSyncMode;
487 QString mCurrentSyncDevice; 489 QString mCurrentSyncDevice;
488 QString mCurrentSyncName; 490 QString mCurrentSyncName;
489 KOBeamPrefs* beamDialog; 491 KOBeamPrefs* beamDialog;
490 void init(); 492 void init();
491 int mDatePickerMode; 493 int mDatePickerMode;
492 bool mFlagEditDescription; 494 bool mFlagEditDescription;
493 QDateTime mLastCalendarSync; 495 QDateTime mLastCalendarSync;
494 void createPrinter(); 496 void createPrinter();
495 497
496 void calendarModified( bool, Calendar * ); 498 void calendarModified( bool, Calendar * );
497 499
498 CalPrinter *mCalPrinter; 500 CalPrinter *mCalPrinter;
499 501
500 QSplitter *mPanner; 502 QSplitter *mPanner;
501 QSplitter *mLeftSplitter; 503 QSplitter *mLeftSplitter;
502 QWidget *mLeftFrame; 504 QWidget *mLeftFrame;
503 QWidgetStack *mRightFrame; 505 QWidgetStack *mRightFrame;
504 506
505 KDatePicker* mDatePicker; 507 KDatePicker* mDatePicker;
506 QVBox* mDateFrame; 508 QVBox* mDateFrame;
507 NavigatorBar *mNavigatorBar; 509 NavigatorBar *mNavigatorBar;
508 510
509 KDateNavigator *mDateNavigator; // widget showing small month view. 511 KDateNavigator *mDateNavigator; // widget showing small month view.
510 512
511 KOFilterView *mFilterView; 513 KOFilterView *mFilterView;
512 514
513 ResourceView *mResourceView; 515 ResourceView *mResourceView;
514 516
515 // calendar object for this viewing instance 517 // calendar object for this viewing instance
516 Calendar *mCalendar; 518 Calendar *mCalendar;
517 519
518 CalendarResourceManager *mResourceManager; 520 CalendarResourceManager *mResourceManager;
519 521
520 FileStorage *mStorage; 522 FileStorage *mStorage;
521 523
522 DateNavigator *mNavigator; 524 DateNavigator *mNavigator;
523 525
524 KOViewManager *mViewManager; 526 KOViewManager *mViewManager;
diff --git a/korganizer/koeventviewer.cpp b/korganizer/koeventviewer.cpp
index bac66d3..1f69700 100644
--- a/korganizer/koeventviewer.cpp
+++ b/korganizer/koeventviewer.cpp
@@ -5,354 +5,385 @@
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20#include <qcstring.h> 20#include <qcstring.h>
21#include <qwhatsthis.h> 21#include <qwhatsthis.h>
22#include <qdialog.h> 22#include <qdialog.h>
23#include <qapplication.h> 23#include <qapplication.h>
24#include <qlabel.h> 24#include <qlabel.h>
25#include <qlayout.h> 25#include <qlayout.h>
26 26
27#include <klocale.h> 27#include <klocale.h>
28#include <kapplication.h> 28#include <kapplication.h>
29#include <libkcal/event.h> 29#include <libkcal/event.h>
30#include <libkcal/todo.h> 30#include <libkcal/todo.h>
31#include <kdebug.h> 31#include <kdebug.h>
32#include <kiconloader.h> 32#include <kiconloader.h>
33#include <krun.h> 33#include <krun.h>
34#include <kglobal.h> 34#include <kglobal.h>
35#include <kprocess.h> 35#include <kprocess.h>
36#include "koprefs.h" 36#include "koprefs.h"
37 37
38#include <libkdepim/addresseeview.h> 38#include <libkdepim/addresseeview.h>
39#include <kabc/stdaddressbook.h> 39#include <kabc/stdaddressbook.h>
40 40
41#ifndef KORG_NODCOP 41#ifndef KORG_NODCOP
42#include <dcopclient.h> 42#include <dcopclient.h>
43#include "korganizer.h" 43#include "korganizer.h"
44#include "koprefs.h" 44#include "koprefs.h"
45#include "actionmanager.h" 45#include "actionmanager.h"
46#endif 46#endif
47 47
48#include "koeventviewer.h" 48#include "koeventviewer.h"
49#ifndef KORG_NOKABC 49#ifndef KORG_NOKABC
50#include <kabc/stdaddressbook.h> 50#include <kabc/stdaddressbook.h>
51#define size count 51#define size count
52#endif 52#endif
53#ifndef DESKTOP_VERSION
54#include <qtopia/qcopenvelope_qws.h>
55#endif
56
53KOEventViewer::KOEventViewer(QWidget *parent,const char *name) 57KOEventViewer::KOEventViewer(QWidget *parent,const char *name)
54 : QTextBrowser(parent,name) 58 : QTextBrowser(parent,name)
55{ 59{
56 mSyncMode = false; 60 mSyncMode = false;
57 mColorMode = 0; 61 mColorMode = 0;
58} 62}
59 63
60KOEventViewer::~KOEventViewer() 64KOEventViewer::~KOEventViewer()
61{ 65{
62} 66}
63 67
64void KOEventViewer::setSource(const QString& n) 68void KOEventViewer::setSource(const QString& n)
65{ 69{
70
71 if ( n.left(3) == "uid" ) {
66 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 72 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
67 KABC::AddressBook::Iterator it; 73 KABC::AddressBook::Iterator it;
68 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 74 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
69 // LR I do not understand, why the uid string is different on zaurus and desktop 75 // LR I do not understand, why the uid string is different on zaurus and desktop
70#ifdef DESKTOP_VERSION 76#ifdef DESKTOP_VERSION
71 QString uid = "uid://"+(*it).uid(); 77 QString uid = "uid://"+(*it).uid();
72#else 78#else
73 QString uid = "uid:"+(*it).uid(); 79 QString uid = "uid:"+(*it).uid();
74#endif 80#endif
75 //qDebug("for *%s* +%s+ ", n.latin1(), uid.latin1()); 81 //qDebug("for *%s* +%s+ ", n.latin1(), uid.latin1());
76 if (n == uid ) { 82 if (n == uid ) {
77 //qDebug("found %s ",(*it).mobileHomePhone().latin1() ); 83 //qDebug("found %s ",(*it).mobileHomePhone().latin1() );
78 QDialog dia( this,"dia123", true ); 84 QDialog dia( this,"dia123", true );
79 dia.setCaption( i18n("Details of attendee") ); 85 dia.setCaption( i18n("Details of attendee") );
80 QVBoxLayout lay ( &dia ); 86 QVBoxLayout lay ( &dia );
81 KPIM::AddresseeView av ( &dia ); 87 KPIM::AddresseeView av ( &dia );
82 av.setAddressee( (*it) ); 88 av.setAddressee( (*it) );
83 lay.addWidget( &av ); 89 lay.addWidget( &av );
84 if ( QApplication::desktop()->width() < 480 ) 90 if ( QApplication::desktop()->width() < 480 )
85 dia.resize( 220, 240); 91 dia.resize( 220, 240);
86 else { 92 else {
87 dia.resize( 400,400); 93 dia.resize( 400,400);
88 94
89 } 95 }
90 dia.exec(); 96 dia.exec();
91 break; 97 break;
92 } 98 }
93 } 99 }
100 return;
101 }
102 if ( n.left(6) == "mailto" ) {
103 // qDebug("KOEventViewer::setSource %s ", n.mid(7).latin1());
104#ifndef DESKTOP_VERSION
105 QCopEnvelope e("QPE/Application/kmpi", "newMail(QString)" );
106 e << n.mid(7);
107#endif
108
109 }
94 110
95 111
96#ifndef KORG_NODCOP 112#ifndef KORG_NODCOP
97 kdDebug() << "KOEventViewer::setSource(): " << n << endl; 113 kdDebug() << "KOEventViewer::setSource(): " << n << endl;
98 QString tmpStr; 114 QString tmpStr;
99 if (n.startsWith("mailto:")) { 115 if (n.startsWith("mailto:")) {
100 KApplication::kApplication()->invokeMailer(n.mid(7),QString::null); 116 KApplication::kApplication()->invokeMailer(n.mid(7),QString::null);
101 //emit showIncidence(n); 117 //emit showIncidence(n);
102 return; 118 return;
103 } else if (n.startsWith("uid:")) { 119 } else if (n.startsWith("uid:")) {
104 DCOPClient *client = KApplication::kApplication()->dcopClient(); 120 DCOPClient *client = KApplication::kApplication()->dcopClient();
105 const QByteArray noParamData; 121 const QByteArray noParamData;
106 const QByteArray paramData; 122 const QByteArray paramData;
107 QByteArray replyData; 123 QByteArray replyData;
108 QCString replyTypeStr; 124 QCString replyTypeStr;
109#define PING_ABBROWSER (client->call("kaddressbook", "KAddressBookIface", "interfaces()", noParamData, replyTypeStr, replyData)) 125#define PING_ABBROWSER (client->call("kaddressbook", "KAddressBookIface", "interfaces()", noParamData, replyTypeStr, replyData))
110 bool foundAbbrowser = PING_ABBROWSER; 126 bool foundAbbrowser = PING_ABBROWSER;
111 127
112 if (foundAbbrowser) { 128 if (foundAbbrowser) {
113 //KAddressbook is already running, so just DCOP to it to bring up the contact editor 129 //KAddressbook is already running, so just DCOP to it to bring up the contact editor
114 //client->send("kaddressbook","KAddressBookIface", 130 //client->send("kaddressbook","KAddressBookIface",
115 QDataStream arg(paramData, IO_WriteOnly); 131 QDataStream arg(paramData, IO_WriteOnly);
116 arg << n.mid(6); 132 arg << n.mid(6);
117 client->send("kaddressbook", "KAddressBookIface", "showContactEditor( QString )", paramData); 133 client->send("kaddressbook", "KAddressBookIface", "showContactEditor( QString )", paramData);
118 return; 134 return;
119 } else { 135 } else {
120 /* 136 /*
121 KaddressBook is not already running. Pass it the UID of the contact via the command line while starting it - its neater. 137 KaddressBook is not already running. Pass it the UID of the contact via the command line while starting it - its neater.
122 We start it without its main interface 138 We start it without its main interface
123 */ 139 */
124 KIconLoader* iconLoader = new KIconLoader(); 140 KIconLoader* iconLoader = new KIconLoader();
125 QString iconPath = iconLoader->iconPath("go",KIcon::Small); 141 QString iconPath = iconLoader->iconPath("go",KIcon::Small);
126 ActionManager::setStartedKAddressBook(true); 142 ActionManager::setStartedKAddressBook(true);
127 tmpStr = "kaddressbook --editor-only --uid "; 143 tmpStr = "kaddressbook --editor-only --uid ";
128 tmpStr += KProcess::quote(n.mid(6)); 144 tmpStr += KProcess::quote(n.mid(6));
129 KRun::runCommand(tmpStr,"KAddressBook",iconPath); 145 KRun::runCommand(tmpStr,"KAddressBook",iconPath);
130 return; 146 return;
131 } 147 }
132 } else { 148 } else {
133 //QTextBrowser::setSource(n); 149 //QTextBrowser::setSource(n);
134 } 150 }
135#endif 151#endif
136} 152}
137 153
138void KOEventViewer::addTag(const QString & tag,const QString & text) 154void KOEventViewer::addTag(const QString & tag,const QString & text)
139{ 155{
140 int number=text.contains("\n"); 156 int number=text.contains("\n");
141 QString str = "<" + tag + ">"; 157 QString str = "<" + tag + ">";
142 QString tmpText=text; 158 QString tmpText=text;
143 QString tmpStr=str; 159 QString tmpStr=str;
144 if(number !=-1) 160 if(number !=-1)
145 { 161 {
146 if (number > 0) { 162 if (number > 0) {
147 int pos=0; 163 int pos=0;
148 QString tmp; 164 QString tmp;
149 for(int i=0;i<=number;i++) { 165 for(int i=0;i<=number;i++) {
150 pos=tmpText.find("\n"); 166 pos=tmpText.find("\n");
151 tmp=tmpText.left(pos); 167 tmp=tmpText.left(pos);
152 tmpText=tmpText.right(tmpText.length()-pos-1); 168 tmpText=tmpText.right(tmpText.length()-pos-1);
153 tmpStr+=tmp+"<br>"; 169 tmpStr+=tmp+"<br>";
154 } 170 }
155 } 171 }
156 else tmpStr += tmpText; 172 else tmpStr += tmpText;
157 tmpStr+="</" + tag + ">"; 173 tmpStr+="</" + tag + ">";
158 mText.append(tmpStr); 174 mText.append(tmpStr);
159 } 175 }
160 else 176 else
161 { 177 {
162 str += text + "</" + tag + ">"; 178 str += text + "</" + tag + ">";
163 mText.append(str); 179 mText.append(str);
164 } 180 }
165} 181}
166 182
167void KOEventViewer::setColorMode( int m ) 183void KOEventViewer::setColorMode( int m )
168{ 184{
169 mColorMode = m; 185 mColorMode = m;
170} 186}
171void KOEventViewer::appendEvent(Event *event, int mode ) 187void KOEventViewer::appendEvent(Event *event, int mode )
172{ 188{
189 mMailSubject = "";
173 mCurrentIncidence = event; 190 mCurrentIncidence = event;
174 bool shortDate = KOPrefs::instance()->mShortDateInViewer; 191 bool shortDate = KOPrefs::instance()->mShortDateInViewer;
175 topLevelWidget()->setCaption(i18n("Event Viewer")); 192 topLevelWidget()->setCaption(i18n("Event Viewer"));
176 if ( mode == 0 ) { 193 if ( mode == 0 ) {
177 addTag("h2",event->summary()); 194 addTag("h2",event->summary());
178 } 195 }
179 else { 196 else {
180 if ( mColorMode == 1 ) { 197 if ( mColorMode == 1 ) {
181 mText +="<font color=\"#00A000\">"; 198 mText +="<font color=\"#00A000\">";
182 } 199 }
183 if ( mColorMode == 2 ) { 200 if ( mColorMode == 2 ) {
184 mText +="<font color=\"#C00000\">"; 201 mText +="<font color=\"#C00000\">";
185 } 202 }
186 // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; 203 // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>";
187 if ( mode == 1 ) { 204 if ( mode == 1 ) {
188 addTag("h2",i18n( "Local: " ) +event->summary()); 205 addTag("h2",i18n( "Local: " ) +event->summary());
189 } else { 206 } else {
190 addTag("h2",i18n( "Remote: " ) +event->summary()); 207 addTag("h2",i18n( "Remote: " ) +event->summary());
191 } 208 }
192 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); 209 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) );
193 if ( mColorMode ) 210 if ( mColorMode )
194 mText += "</font>"; 211 mText += "</font>";
195 } 212 }
213 mMailSubject += i18n( "Meeting " )+ event->summary();
196 if (event->cancelled ()) { 214 if (event->cancelled ()) {
197 mText +="<font color=\"#B00000\">"; 215 mText +="<font color=\"#B00000\">";
198 addTag("i",i18n("This event has been cancelled!")); 216 addTag("i",i18n("This event has been cancelled!"));
199 mText.append("<br>"); 217 mText.append("<br>");
200 mText += "</font>"; 218 mText += "</font>";
219 mMailSubject += i18n("(cancelled)");
201 } 220 }
202 if (!event->location().isEmpty()) { 221 if (!event->location().isEmpty()) {
203 addTag("b",i18n("Location: ")); 222 addTag("b",i18n("Location: "));
204 mText.append(event->location()+"<br>"); 223 mText.append(event->location()+"<br>");
224 mMailSubject += i18n(" at ") + event->location();
205 } 225 }
206 if (event->doesFloat()) { 226 if (event->doesFloat()) {
207 if (event->isMultiDay()) { 227 if (event->isMultiDay()) {
208 mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>") 228 mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>")
209 .arg(event->dtStartDateStr(shortDate)) 229 .arg(event->dtStartDateStr(shortDate))
210 .arg(event->dtEndDateStr(shortDate))); 230 .arg(event->dtEndDateStr(shortDate)));
211 } else { 231 } else {
212 mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate ))); 232 mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate )));
213 } 233 }
214 } else { 234 } else {
215 if (event->isMultiDay()) { 235 if (event->isMultiDay()) {
216 mText.append(i18n("<p><b>From:</b> %1</p> ") 236 mText.append(i18n("<p><b>From:</b> %1</p> ")
217 .arg(event->dtStartStr( shortDate))); 237 .arg(event->dtStartStr( shortDate)));
218 mText.append(i18n("<p><b>To:</b> %1</p>") 238 mText.append(i18n("<p><b>To:</b> %1</p>")
219 .arg(event->dtEndStr(shortDate))); 239 .arg(event->dtEndStr(shortDate)));
220 } else { 240 } else {
221 mText.append(i18n("<p><b>On:</b> %1</p> ") 241 mText.append(i18n("<p><b>On:</b> %1</p> ")
222 .arg(event->dtStartDateStr( shortDate ))); 242 .arg(event->dtStartDateStr( shortDate )));
223 mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>") 243 mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>")
224 .arg(event->dtStartTimeStr()) 244 .arg(event->dtStartTimeStr())
225 .arg(event->dtEndTimeStr())); 245 .arg(event->dtEndTimeStr()));
226 } 246 }
227 } 247 }
228 248
229 if (event->recurrence()->doesRecur()) { 249 if (event->recurrence()->doesRecur()) {
230 250
231 QString recurText = event->recurrence()->recurrenceText(); 251 QString recurText = event->recurrence()->recurrenceText();
232 addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>"); 252 addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>");
233 bool last; 253 bool last;
234 QDate start = QDate::currentDate(); 254 QDate start = QDate::currentDate();
235 QDate next; 255 QDate next;
236 next = event->recurrence()->getPreviousDate( start , &last ); 256 next = event->recurrence()->getPreviousDate( start , &last );
237 if ( !last ) { 257 if ( !last ) {
238 next = event->recurrence()->getNextDate( start.addDays( - 1 ) ); 258 next = event->recurrence()->getNextDate( start.addDays( - 1 ) );
239 addTag("p",i18n("<b>Next recurrence is on:</b>") ); 259 addTag("p",i18n("<b>Next recurrence is on:</b>") );
240 addTag("p", KGlobal::locale()->formatDate( next, shortDate )); 260 addTag("p", KGlobal::locale()->formatDate( next, shortDate ));
261 QDateTime nextdt = QDateTime( next, event->dtStart().time());
262 mMailSubject += i18n(" - " )+ KGlobal::locale()->formatDateTime( nextdt, true );
263
241 } else { 264 } else {
242 addTag("p",i18n("<b>Last recurrence was on:</b>") ); 265 addTag("p",i18n("<b>Last recurrence was on:</b>") );
243 addTag("p", KGlobal::locale()->formatDate( next, shortDate )); 266 addTag("p", KGlobal::locale()->formatDate( next, shortDate ));
244 } 267 }
268 } else {
269 mMailSubject += i18n(" - " )+event->dtStartStr( true );
270
245 } 271 }
246 272
247 273
248 if (event->isAlarmEnabled()) { 274 if (event->isAlarmEnabled()) {
249 Alarm *alarm =event->alarms().first() ; 275 Alarm *alarm =event->alarms().first() ;
250 QDateTime t = alarm->time(); 276 QDateTime t = alarm->time();
251 int min = t.secsTo( event->dtStart() )/60; 277 int min = t.secsTo( event->dtStart() )/60;
252 QString s =i18n("( %1 min before )").arg( min ); 278 QString s =i18n("( %1 min before )").arg( min );
253 addTag("p",i18n("<b>Alarm on: ") + s +" </b>"); 279 addTag("p",i18n("<b>Alarm on: ") + s +" </b>");
254 addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); 280 addTag("p", KGlobal::locale()->formatDateTime( t, shortDate ));
255 //addTag("p",s); 281 //addTag("p",s);
256 } 282 }
257 283
258 addTag("b",i18n("Access: ")); 284 addTag("b",i18n("Access: "));
259 mText.append(event->secrecyStr()+"<br>"); 285 mText.append(event->secrecyStr()+"<br>");
260 if (!event->description().isEmpty()) { 286 if (!event->description().isEmpty()) {
261 addTag("p",i18n("<b>Details: </b>")); 287 addTag("p",i18n("<b>Details: </b>"));
262 addTag("p",event->description()); 288 addTag("p",event->description());
263 } 289 }
264 290
265 formatCategories(event); 291 formatCategories(event);
266 292
267 formatReadOnly(event); 293 formatReadOnly(event);
268 formatAttendees(event); 294 formatAttendees(event);
269 295
270 setText(mText); 296 setText(mText);
271 //QWhatsThis::add(this,mText); 297 //QWhatsThis::add(this,mText);
272 298
273} 299}
274 300
275void KOEventViewer::appendTodo(Todo *event, int mode ) 301void KOEventViewer::appendTodo(Todo *event, int mode )
276{ 302{
303 mMailSubject = "";
277 mCurrentIncidence = event; 304 mCurrentIncidence = event;
278 topLevelWidget()->setCaption(i18n("Todo Viewer")); 305 topLevelWidget()->setCaption(i18n("Todo Viewer"));
279 bool shortDate = KOPrefs::instance()->mShortDateInViewer; 306 bool shortDate = KOPrefs::instance()->mShortDateInViewer;
280 if (mode == 0 ) 307 if (mode == 0 )
281 addTag("h2",event->summary()); 308 addTag("h2",event->summary());
282 else { 309 else {
283 if ( mColorMode == 1 ) { 310 if ( mColorMode == 1 ) {
284 mText +="<font color=\"#00A000\">"; 311 mText +="<font color=\"#00A000\">";
285 } 312 }
286 if ( mColorMode == 2 ) { 313 if ( mColorMode == 2 ) {
287 mText +="<font color=\"#B00000\">"; 314 mText +="<font color=\"#B00000\">";
288 } 315 }
289 if ( mode == 1 ) { 316 if ( mode == 1 ) {
290 addTag("h2",i18n( "Local: " ) +event->summary()); 317 addTag("h2",i18n( "Local: " ) +event->summary());
291 } else { 318 } else {
292 addTag("h2",i18n( "Remote: " ) +event->summary()); 319 addTag("h2",i18n( "Remote: " ) +event->summary());
293 } 320 }
294 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); 321 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) );
295 if ( mColorMode ) 322 if ( mColorMode )
296 mText += "</font>"; 323 mText += "</font>";
297 } 324 }
325 mMailSubject += i18n( "Todo " )+ event->summary();
298 if (event->cancelled ()) { 326 if (event->cancelled ()) {
299 mText +="<font color=\"#B00000\">"; 327 mText +="<font color=\"#B00000\">";
300 addTag("i",i18n("This todo has been cancelled!")); 328 addTag("i",i18n("This todo has been cancelled!"));
301 mText.append("<br>"); 329 mText.append("<br>");
302 mText += "</font>"; 330 mText += "</font>";
331 mMailSubject += i18n("(cancelled)");
303 } 332 }
304 333
305 if (!event->location().isEmpty()) { 334 if (!event->location().isEmpty()) {
306 addTag("b",i18n("Location: ")); 335 addTag("b",i18n("Location: "));
307 mText.append(event->location()+"<br>"); 336 mText.append(event->location()+"<br>");
337 mMailSubject += i18n(" at ") + event->location();
308 } 338 }
309 if (event->hasDueDate()) { 339 if (event->hasDueDate()) {
310 mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(KOPrefs::instance()->mShortDateInViewer))); 340 mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(KOPrefs::instance()->mShortDateInViewer)));
341 mMailSubject += i18n(" - " )+event->dtDueStr( true );
311 } 342 }
312 addTag("b",i18n("Access: ")); 343 addTag("b",i18n("Access: "));
313 mText.append(event->secrecyStr()+"<br>"); 344 mText.append(event->secrecyStr()+"<br>");
314 if (!event->description().isEmpty()) { 345 if (!event->description().isEmpty()) {
315 addTag("p",i18n("<b>Details: </b>")); 346 addTag("p",i18n("<b>Details: </b>"));
316 addTag("p",event->description()); 347 addTag("p",event->description());
317 } 348 }
318 349
319 formatCategories(event); 350 formatCategories(event);
320 351
321 mText.append(i18n("<p><b>Priority:</b> %2</p>") 352 mText.append(i18n("<p><b>Priority:</b> %2</p>")
322 .arg(QString::number(event->priority()))); 353 .arg(QString::number(event->priority())));
323 354
324 mText.append(i18n("<p><i>%1 % completed</i></p>") 355 mText.append(i18n("<p><i>%1 % completed</i></p>")
325 .arg(event->percentComplete())); 356 .arg(event->percentComplete()));
326 357
327 formatReadOnly(event); 358 formatReadOnly(event);
328 formatAttendees(event); 359 formatAttendees(event);
329 360
330 setText(mText); 361 setText(mText);
331} 362}
332 363
333void KOEventViewer::formatCategories(Incidence *event) 364void KOEventViewer::formatCategories(Incidence *event)
334{ 365{
335 if (!event->categoriesStr().isEmpty()) { 366 if (!event->categoriesStr().isEmpty()) {
336 if (event->categories().count() == 1) { 367 if (event->categories().count() == 1) {
337 addTag("h3",i18n("Category")); 368 addTag("h3",i18n("Category"));
338 } else { 369 } else {
339 addTag("h3",i18n("Categories")); 370 addTag("h3",i18n("Categories"));
340 } 371 }
341 addTag("p",event->categoriesStr()); 372 addTag("p",event->categoriesStr());
342 } 373 }
343} 374}
344void KOEventViewer::formatAttendees(Incidence *event) 375void KOEventViewer::formatAttendees(Incidence *event)
345{ 376{
346 QPtrList<Attendee> attendees = event->attendees(); 377 QPtrList<Attendee> attendees = event->attendees();
347 if (attendees.count()) { 378 if (attendees.count()) {
348 379
349 380
350 QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); 381 QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small);
351 addTag("h3",i18n("Organizer")); 382 addTag("h3",i18n("Organizer"));
352 mText.append("<ul><li>"); 383 mText.append("<ul><li>");
353#ifndef KORG_NOKABC 384#ifndef KORG_NOKABC
354 385
355 KABC::AddressBook *add_book = KABC::StdAddressBook::self(); 386 KABC::AddressBook *add_book = KABC::StdAddressBook::self();
356 KABC::Addressee::List addressList; 387 KABC::Addressee::List addressList;
357 addressList = add_book->findByEmail(event->organizer()); 388 addressList = add_book->findByEmail(event->organizer());
358 KABC::Addressee o = addressList.first(); 389 KABC::Addressee o = addressList.first();
@@ -360,99 +391,100 @@ void KOEventViewer::formatAttendees(Incidence *event)
360 mText += "<a href=\"uid:" + o.uid() + "\">"; 391 mText += "<a href=\"uid:" + o.uid() + "\">";
361 mText += o.formattedName(); 392 mText += o.formattedName();
362 mText += "</a>\n"; 393 mText += "</a>\n";
363 } else { 394 } else {
364 mText.append(event->organizer()); 395 mText.append(event->organizer());
365 } 396 }
366#else 397#else
367 mText.append(event->organizer()); 398 mText.append(event->organizer());
368#endif 399#endif
369 400
370 if (iconPath) { 401 if (iconPath) {
371 mText += " <a href=\"mailto:" + event->organizer() + "\">"; 402 mText += " <a href=\"mailto:" + event->organizer() + "\">";
372 mText += "<IMG src=\"" + iconPath + "\">"; 403 mText += "<IMG src=\"" + iconPath + "\">";
373 mText += "</a>\n"; 404 mText += "</a>\n";
374 } 405 }
375 mText.append("</li></ul>"); 406 mText.append("</li></ul>");
376 407
377 addTag("h3",i18n("Attendees")); 408 addTag("h3",i18n("Attendees"));
378 Attendee *a; 409 Attendee *a;
379 mText.append("<ul>"); 410 mText.append("<ul>");
380 for(a=attendees.first();a;a=attendees.next()) { 411 for(a=attendees.first();a;a=attendees.next()) {
381#ifndef KORG_NOKABC 412#ifndef KORG_NOKABC
382 if (a->name().isEmpty()) { 413 if (a->name().isEmpty()) {
383 addressList = add_book->findByEmail(a->email()); 414 addressList = add_book->findByEmail(a->email());
384 KABC::Addressee o = addressList.first(); 415 KABC::Addressee o = addressList.first();
385 if (!o.isEmpty() && addressList.size()<2) { 416 if (!o.isEmpty() && addressList.size()<2) {
386 mText += "<a href=\"uid:" + o.uid() + "\">"; 417 mText += "<a href=\"uid:" + o.uid() + "\">";
387 mText += o.formattedName(); 418 mText += o.formattedName();
388 mText += "</a>\n"; 419 mText += "</a>\n";
389 } else { 420 } else {
390 mText += "<li>"; 421 mText += "<li>";
391 mText.append(a->email()); 422 mText.append(a->email());
392 mText += "\n"; 423 mText += "\n";
393 } 424 }
394 } else { 425 } else {
395 mText += "<li><a href=\"uid:" + a->uid() + "\">"; 426 mText += "<li><a href=\"uid:" + a->uid() + "\">";
396 if (!a->name().isEmpty()) mText += a->name(); 427 if (!a->name().isEmpty()) mText += a->name();
397 else mText += a->email(); 428 else mText += a->email();
398 mText += "</a>\n"; 429 mText += "</a>\n";
399 } 430 }
400#else 431#else
401 //qDebug("nokabc "); 432 //qDebug("nokabc ");
402 mText += "<li><a href=\"uid:" + a->uid() + "\">"; 433 mText += "<li><a href=\"uid:" + a->uid() + "\">";
403 if (!a->name().isEmpty()) mText += a->name(); 434 if (!a->name().isEmpty()) mText += a->name();
404 else mText += a->email(); 435 else mText += a->email();
405 mText += "</a>\n"; 436 mText += "</a>\n";
406#endif 437#endif
407 438
439
408 if (!a->email().isEmpty()) { 440 if (!a->email().isEmpty()) {
409 if (iconPath) { 441 if (iconPath) {
410 mText += "<a href=\"mailto:" + a->name() +" "+ "<" + a->email() + ">" + "\">"; 442 mText += "<a href=\"mailto:" + a->name() +" <" + a->email() + ">:" + mMailSubject + "\">";
411 mText += "<IMG src=\"" + iconPath + "\">"; 443 mText += "<IMG src=\"" + iconPath + "\">";
412 mText += "</a>\n"; 444 mText += "</a>\n";
413 } 445 }
414 } 446 }
415 if (a->status() != Attendee::NeedsAction ) 447 if (a->status() != Attendee::NeedsAction )
416 mText +="[" + a->statusStr() + "] "; 448 mText +="[" + a->statusStr() + "] ";
417 if (a->role() == Attendee::Chair ) 449 if (a->role() == Attendee::Chair )
418 mText +="(" + a->roleStr().left(1) + ".)"; 450 mText +="(" + a->roleStr().left(1) + ".)";
419 } 451 }
420 mText.append("</li></ul>"); 452 mText.append("</li></ul>");
421 } 453 }
422 454
423} 455}
424void KOEventViewer::appendJournal(Journal *jour, int mode ) 456void KOEventViewer::appendJournal(Journal *jour, int mode )
425{ 457{
426 bool shortDate = KOPrefs::instance()->mShortDateInViewer; 458 bool shortDate = KOPrefs::instance()->mShortDateInViewer;
427 if (mode == 0 ) 459 if (mode == 0 )
428 addTag("h2",i18n("Journal from: ")); 460 addTag("h2",i18n("Journal from: "));
429 else { 461 else {
430 if ( mode == 1 ) { 462 if ( mode == 1 ) {
431 addTag("h2",i18n( "Local: " ) +i18n("Journal from: ")); 463 addTag("h2",i18n( "Local: " ) +i18n("Journal from: "));
432 } else { 464 } else {
433 addTag("h2",i18n( "Remote: " ) +i18n("Journal from: ")); 465 addTag("h2",i18n( "Remote: " ) +i18n("Journal from: "));
434 } 466 }
435 addTag("h3",i18n( "Last modified " ) + KGlobal::locale()->formatDateTime(jour->lastModified(),shortDate ) ); 467 addTag("h3",i18n( "Last modified " ) + KGlobal::locale()->formatDateTime(jour->lastModified(),shortDate ) );
436 } 468 }
437 topLevelWidget()->setCaption("Journal Viewer"); 469 topLevelWidget()->setCaption("Journal Viewer");
438 mText.append(i18n("<h3> %1 </h3> ").arg(jour->dtStartDateStr(KOPrefs::instance()->mShortDateInViewer))); 470 mText.append(i18n("<h3> %1 </h3> ").arg(jour->dtStartDateStr(KOPrefs::instance()->mShortDateInViewer)));
439 if (!jour->description().isEmpty()) { 471 if (!jour->description().isEmpty()) {
440 addTag("p",jour->description()); 472 addTag("p",jour->description());
441 } 473 }
442 setText(mText); 474 setText(mText);
443} 475}
444 476
445void KOEventViewer::formatReadOnly(Incidence *event) 477void KOEventViewer::formatReadOnly(Incidence *event)
446{ 478{
447 if (event->isReadOnly()) { 479 if (event->isReadOnly()) {
448 addTag("p","<em>(" + i18n("read-only") + ")</em>"); 480 addTag("p","<em>(" + i18n("read-only") + ")</em>");
449 } 481 }
450} 482}
451void KOEventViewer::setSyncMode( bool b ) 483void KOEventViewer::setSyncMode( bool b )
452{ 484{
453 mSyncMode = b; 485 mSyncMode = b;
454} 486}
455 487
456 488
457void KOEventViewer::setTodo(Todo *event, bool clearV ) 489void KOEventViewer::setTodo(Todo *event, bool clearV )
458{ 490{
diff --git a/korganizer/koeventviewer.h b/korganizer/koeventviewer.h
index 74f1135..0cd3f33 100644
--- a/korganizer/koeventviewer.h
+++ b/korganizer/koeventviewer.h
@@ -20,54 +20,55 @@
20#define KOEVENTVIEWER_H 20#define KOEVENTVIEWER_H
21// 21//
22// Viewer widget for events. 22// Viewer widget for events.
23// 23//
24 24
25#include <qtextbrowser.h> 25#include <qtextbrowser.h>
26 26
27#include <libkcal/event.h> 27#include <libkcal/event.h>
28#include <libkcal/journal.h> 28#include <libkcal/journal.h>
29 29
30 30
31using namespace KCal; 31using namespace KCal;
32 32
33class KOEventViewer : public QTextBrowser { 33class KOEventViewer : public QTextBrowser {
34 Q_OBJECT 34 Q_OBJECT
35 public: 35 public:
36 KOEventViewer(QWidget *parent=0,const char *name=0); 36 KOEventViewer(QWidget *parent=0,const char *name=0);
37 virtual ~KOEventViewer(); 37 virtual ~KOEventViewer();
38 38
39 void setSource(const QString &); 39 void setSource(const QString &);
40 void setEvent(Event *event); 40 void setEvent(Event *event);
41 void addEvent(Event *event); 41 void addEvent(Event *event);
42 void setTodo(Todo *event, bool clearV = true ); 42 void setTodo(Todo *event, bool clearV = true );
43 void setJournal(Journal *jour, bool clearV = true ); 43 void setJournal(Journal *jour, bool clearV = true );
44 44
45 void appendEvent(Event *event, int mode = 0 ); 45 void appendEvent(Event *event, int mode = 0 );
46 void appendTodo(Todo *event, int mode = 0 ); 46 void appendTodo(Todo *event, int mode = 0 );
47 void appendJournal(Journal *jour, int mode = 0 ); 47 void appendJournal(Journal *jour, int mode = 0 );
48 48
49 void clearEvents(bool now=false); 49 void clearEvents(bool now=false);
50 50
51 void addText(QString text); 51 void addText(QString text);
52 void setSyncMode( bool ); 52 void setSyncMode( bool );
53 void setColorMode( int ); 53 void setColorMode( int );
54 54
55 protected: 55 protected:
56 int mColorMode; 56 int mColorMode;
57 void addTag(const QString & tag,const QString & text); 57 void addTag(const QString & tag,const QString & text);
58 58
59 void formatCategories(Incidence *event); 59 void formatCategories(Incidence *event);
60 void formatAttendees(Incidence *event); 60 void formatAttendees(Incidence *event);
61 void formatReadOnly(Incidence *event); 61 void formatReadOnly(Incidence *event);
62 62
63 private: 63 private:
64 QTextBrowser *mEventTextView; 64 QTextBrowser *mEventTextView;
65 bool mSyncMode; 65 bool mSyncMode;
66 66
67 QString mText; 67 QString mText;
68 QString mMailSubject;
68 Incidence* mCurrentIncidence; 69 Incidence* mCurrentIncidence;
69 signals: 70 signals:
70 void launchaddressbook(QString uid); 71 void launchaddressbook(QString uid);
71}; 72};
72 73
73#endif 74#endif
diff --git a/korganizer/main.cpp b/korganizer/main.cpp
index a357988..69ef294 100644
--- a/korganizer/main.cpp
+++ b/korganizer/main.cpp
@@ -8,102 +8,80 @@
8#include <qapplication.h> 8#include <qapplication.h>
9#include <qstring.h> 9#include <qstring.h>
10#include <qwindowsstyle.h> 10#include <qwindowsstyle.h>
11#include <qplatinumstyle.h> 11#include <qplatinumstyle.h>
12#include <qsgistyle.h> 12#include <qsgistyle.h>
13#endif 13#endif
14 14
15#include <qdir.h> 15#include <qdir.h>
16#include <kstandarddirs.h> 16#include <kstandarddirs.h>
17#include <kglobal.h> 17#include <kglobal.h>
18#include <stdio.h> 18#include <stdio.h>
19#include "mainwindow.h" 19#include "mainwindow.h"
20 20
21int main( int argc, char **argv ) 21int main( int argc, char **argv )
22{ 22{
23#ifndef DESKTOP_VERSION 23#ifndef DESKTOP_VERSION
24 QPEApplication a( argc, argv ); 24 QPEApplication a( argc, argv );
25 a.setKeepRunning (); 25 a.setKeepRunning ();
26#else 26#else
27 QApplication a( argc, argv ); 27 QApplication a( argc, argv );
28 QApplication::setStyle( new QPlatinumStyle ()); 28 QApplication::setStyle( new QPlatinumStyle ());
29#endif 29#endif
30 bool exitHelp = false; 30 bool exitHelp = false;
31 if ( argc > 1 ) { 31 if ( argc > 1 ) {
32 QString command = argv[1]; 32 QString command = argv[1];
33 if ( command == "-help" ){ 33 if ( command == "-help" ){
34 printf("KO/Pi command line commands:\n"); 34 printf("KO/Pi command line commands:\n");
35 printf(" no command: Start KO/Pi in usual way\n"); 35 printf(" no command: Start KO/Pi in usual way\n");
36 printf(" -help: This output\n"); 36 printf(" -help: This output\n");
37 printf("Next Option: Open or Show after start:\n"); 37 printf("Next Option: Open or Show after start:\n");
38 printf(" -newTodo: New Todo dialog\n"); 38 printf(" -newTodo: New Todo dialog\n");
39 printf(" -newEvent: New Event dialog\n"); 39 printf(" -newEvent: New Event dialog\n");
40 printf(" -showList: List view\n"); 40 printf(" -showList: List view\n");
41 printf(" -showDay: Day view\n"); 41 printf(" -showDay: Day view\n");
42 printf(" -showWWeek: Work Week view\n"); 42 printf(" -showWWeek: Work Week view\n");
43 printf(" -showWeek: Week view\n"); 43 printf(" -showWeek: Week view\n");
44 printf(" -showTodo: Todo view\n"); 44 printf(" -showTodo: Todo view\n");
45 printf(" -showJournal: Journal view\n"); 45 printf(" -showJournal: Journal view\n");
46 printf(" -showKO: Next Days view\n"); 46 printf(" -showKO: Next Days view\n");
47 printf(" -showWNext: What's Next view\n"); 47 printf(" -showWNext: What's Next view\n");
48 printf(" -showNextXView: Next X View\n"); 48 printf(" -showNextXView: Next X View\n");
49 printf(" -new[Y] and -show[X] may be used togehther\n"); 49 printf(" -new[Y] and -show[X] may be used togehther\n");
50 printf(" KO/Pi is exiting now. Bye!\n"); 50 printf(" KO/Pi is exiting now. Bye!\n");
51 exitHelp = true; 51 exitHelp = true;
52 } 52 }
53 } 53 }
54 if ( ! exitHelp ) { 54 if ( ! exitHelp ) {
55 KGlobal::setAppName( "korganizer" ); 55 KGlobal::setAppName( "korganizer" );
56
57
58 QString fileName ; 56 QString fileName ;
59#ifndef DESKTOP_VERSION 57#ifndef DESKTOP_VERSION
60 QString appdir = QDir::homeDirPath() + "/kdepim/apps/" + KGlobal::getAppName();
61 KStandardDirs::setAppDir( appdir );
62
63 fileName = getenv("QPEDIR"); 58 fileName = getenv("QPEDIR");
64 KGlobal::iconLoader()->setIconPath( fileName +"/pics/kdepim/korganizer/"); 59 KGlobal::iconLoader()->setIconPath( fileName +"/pics/kdepim/korganizer/");
65#else 60#else
66
67#ifndef _WIN32_
68 fileName = qApp->applicationDirPath () + "/kdepim/korganizer/"; 61 fileName = qApp->applicationDirPath () + "/kdepim/korganizer/";
69#else 62 KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName));
70 fileName = qApp->applicationDirPath () + "\\kdepim\\korganizer\\";
71#endif
72
73 KGlobal::iconLoader()->setIconPath(fileName);
74
75 QString appdir = QDir::homeDirPath();
76 //appdir = "C:\\";
77 if ( appdir.right(1) == "\\" || appdir.right(1) == "/" )
78 appdir += "korganizer";
79 else
80 appdir += "/korganizer";
81 KStandardDirs::setAppDir( QDir::convertSeparators( appdir ));
82 // qDebug(" %s ",KStandardDirs::appDir().latin1() );
83#endif 63#endif
84 QDir app_dir; 64 KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "korganizer")));
85 if ( !app_dir.exists(KStandardDirs::appDir()) )
86 app_dir.mkdir (KStandardDirs::appDir());
87 MainWindow m; 65 MainWindow m;
88#ifndef DESKTOP_VERSION 66#ifndef DESKTOP_VERSION
89 QObject::connect( &a, SIGNAL (appMessage ( const QCString &, const QByteArray & )),&m, SLOT(recieve( const QCString&, const QByteArray& ))); 67 QObject::connect( &a, SIGNAL (appMessage ( const QCString &, const QByteArray & )),&m, SLOT(recieve( const QCString&, const QByteArray& )));
90 a.showMainWidget(&m ); 68 a.showMainWidget(&m );
91#else 69#else
92 a.setMainWidget(&m ); 70 a.setMainWidget(&m );
93 m.show(); 71 m.show();
94 //m.resize( 800, 600 ); 72 //m.resize( 800, 600 );
95 QObject::connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit())); 73 QObject::connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
96#endif 74#endif
97 if ( argc > 1 ) { 75 if ( argc > 1 ) {
98 QCString command = argv[1]; 76 QCString command = argv[1];
99 if ( argc > 2 ) 77 if ( argc > 2 )
100 command += argv[2]; 78 command += argv[2];
101 qApp->processEvents(); 79 qApp->processEvents();
102 m.recieve(command, QByteArray() ); 80 m.recieve(command, QByteArray() );
103 81
104 } 82 }
105 a.exec(); 83 a.exec();
106 84
107 } 85 }
108 qDebug("KO: Bye! "); 86 qDebug("KO: Bye! ");
109} 87}