summaryrefslogtreecommitdiffabout
path: root/korganizer
Unidiff
Diffstat (limited to 'korganizer') (more/less context) (show whitespace changes)
-rw-r--r--korganizer/calendarview.cpp39
1 files changed, 30 insertions, 9 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 8f5de4d..753d81f 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -597,103 +597,106 @@ void CalendarView::init()
597 mDateFrame->setCaption( i18n( "Pick a date to display")); 597 mDateFrame->setCaption( i18n( "Pick a date to display"));
598 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); 598 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() );
599 599
600 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); 600 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate)));
601 601
602 mEventEditor = mDialogManager->getEventEditor(); 602 mEventEditor = mDialogManager->getEventEditor();
603 mTodoEditor = mDialogManager->getTodoEditor(); 603 mTodoEditor = mDialogManager->getTodoEditor();
604 604
605 mFlagEditDescription = false; 605 mFlagEditDescription = false;
606 606
607 mSuspendTimer = new QTimer( this ); 607 mSuspendTimer = new QTimer( this );
608 mAlarmTimer = new QTimer( this ); 608 mAlarmTimer = new QTimer( this );
609 mRecheckAlarmTimer = new QTimer( this ); 609 mRecheckAlarmTimer = new QTimer( this );
610 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); 610 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) );
611 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); 611 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
612 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); 612 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
613 mAlarmDialog = new AlarmDialog( this ); 613 mAlarmDialog = new AlarmDialog( this );
614 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); 614 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) );
615 mAlarmDialog->setServerNotification( false ); 615 mAlarmDialog->setServerNotification( false );
616 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); 616 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
617 617
618 618
619#ifndef DESKTOP_VERSION 619#ifndef DESKTOP_VERSION
620//US listen for arriving address resultsets 620//US listen for arriving address resultsets
621 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), 621 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)),
622 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); 622 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)));
623#endif 623#endif
624 mDateNavigator->setCalendar( mCalendar ); 624 mDateNavigator->setCalendar( mCalendar );
625} 625}
626 626
627 627
628CalendarView::~CalendarView() 628CalendarView::~CalendarView()
629{ 629{
630 // kdDebug() << "~CalendarView()" << endl; 630 // kdDebug() << "~CalendarView()" << endl;
631 //qDebug("CalendarView::~CalendarView() "); 631 //qDebug("CalendarView::~CalendarView() ");
632 delete mDialogManager; 632 delete mDialogManager;
633 delete mViewManager; 633 delete mViewManager;
634 delete mStorage; 634 delete mStorage;
635 delete mDateFrame ; 635 delete mDateFrame ;
636 delete beamDialog; 636 delete beamDialog;
637 delete mEventViewerDialog; 637 delete mEventViewerDialog;
638 //kdDebug() << "~CalendarView() done" << endl; 638 //kdDebug() << "~CalendarView() done" << endl;
639} 639}
640void CalendarView::checkAlarms() 640void CalendarView::checkAlarms()
641{ 641{
642 KConfig *config = KOGlobals::config(); 642 KConfig *config = KOGlobals::config();
643 config->setGroup( "AppRun" ); 643 config->setGroup( "AppRun" );
644 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); 644 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) );
645 int daysto = dt.daysTo( QDate::currentDate() );
646 int days = config->readNumEntry( "LatestProgramStopDays" , daysto);
647 dt = dt.addDays( days );
645 int secto = dt.secsTo( QDateTime::currentDateTime() ); 648 int secto = dt.secsTo( QDateTime::currentDateTime() );
646 int secs = config->readNumEntry( "LatestProgramStop" , secto) - 30; 649 int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30;
647 qDebug("KO: Reading program stop %d ", secs); 650 //qDebug("KO: Reading program stop %d ", secs);
648 //secs -= ( 3600 * 24*3 ); // debug only 651 //secs -= ( 3600 * 24*3 ); // debug only
649 QDateTime latest = dt.addSecs ( secs ); 652 QDateTime latest = dt.addSecs ( secs );
650 qDebug("KO: Last termination on %s ", latest.toString().latin1()); 653 qDebug("KO: Last termination on %s ", latest.toString().latin1());
651 qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); 654 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() );
652 QPtrList<Incidence> el = mCalendar->rawIncidences(); 655 QPtrList<Incidence> el = mCalendar->rawIncidences();
653 QPtrList<Incidence> al; 656 QPtrList<Incidence> al;
654 Incidence* inL = el.first(); 657 Incidence* inL = el.first();
655 QDateTime cur = QDateTime::currentDateTime().addSecs(-59); 658 QDateTime cur = QDateTime::currentDateTime().addSecs(-59);
656 qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); 659 qDebug("KO: Checking alarm until %s ", cur.toString().latin1());
657 while ( inL ) { 660 while ( inL ) {
658 bool ok = false; 661 bool ok = false;
659 int offset = 0; 662 int offset = 0;
660 QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; 663 QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ;
661 if ( ok ) { 664 if ( ok ) {
662 //qDebug("OK %s",next.toString().latin1()); 665 //qDebug("OK %s",next.toString().latin1());
663 if ( next < cur ) { 666 if ( next < cur ) {
664 al.append( inL ); 667 al.append( inL );
665 //qDebug("found missed alarm: %s ", inL->summary().latin1() ); 668 //qDebug("found missed alarm: %s ", inL->summary().latin1() );
666 } 669 }
667 } 670 }
668 inL = el.next(); 671 inL = el.next();
669 } 672 }
670 if ( al.count() ) { 673 if ( al.count() ) {
671 QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); 674 QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop );
672 dia->setCaption( i18n("KO/Pi: Missing alarms!") ); 675 dia->setCaption( i18n("KO/Pi: Missing alarms!") );
673 QVBoxLayout* lay = new QVBoxLayout( dia ); 676 QVBoxLayout* lay = new QVBoxLayout( dia );
674 lay->setSpacing( 0 ); 677 lay->setSpacing( 0 );
675 lay->setMargin( 0 ); 678 lay->setMargin( 0 );
676 MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); 679 MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest );
677 connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); 680 connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) ));
678 lay->addWidget( matb ); 681 lay->addWidget( matb );
679 if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { 682 if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) {
680 int wid = 210; 683 int wid = 210;
681 int x = QApplication::desktop()->width() - wid - 7; 684 int x = QApplication::desktop()->width() - wid - 7;
682 int y = QApplication::desktop()->height() - wid - 70; 685 int y = QApplication::desktop()->height() - wid - 70;
683 dia->setGeometry ( x,y,wid,wid); 686 dia->setGeometry ( x,y,wid,wid);
684 } else { 687 } else {
685 int si = 220; 688 int si = 220;
686 if ( QApplication::desktop()->width() > 470 ) 689 if ( QApplication::desktop()->width() > 470 )
687 si = 400; 690 si = 400;
688 dia->resize(si,si/2); 691 dia->resize(si,si/2);
689 } 692 }
690 dia->setBackgroundColor( QColor( 255, 255, 255 ) ); 693 dia->setBackgroundColor( QColor( 255, 255, 255 ) );
691 dia->show(); 694 dia->show();
692 695
693 } 696 }
694} 697}
695void CalendarView::showDay( QDate d ) 698void CalendarView::showDay( QDate d )
696{ 699{
697 dateNavigator()->blockSignals( true ); 700 dateNavigator()->blockSignals( true );
698 dateNavigator()->selectDate( d ); 701 dateNavigator()->selectDate( d );
699 dateNavigator()->blockSignals( false ); 702 dateNavigator()->blockSignals( false );
@@ -2113,106 +2116,124 @@ void CalendarView::readSettings()
2113 sizes = config->readIntListEntry("Main Splitter Frame"); 2116 sizes = config->readIntListEntry("Main Splitter Frame");
2114 resetval = 0; 2117 resetval = 0;
2115 maxVal = 0; 2118 maxVal = 0;
2116 if (sizes.count() != 2) { 2119 if (sizes.count() != 2) {
2117 if ( !KOPrefs::instance()->mVerticalScreen ) { 2120 if ( !KOPrefs::instance()->mVerticalScreen ) {
2118 resetval = mDateNavigator->sizeHint().width()+2; 2121 resetval = mDateNavigator->sizeHint().width()+2;
2119 } else { 2122 } else {
2120 resetval = mDateNavigator->sizeHint().height()+2; 2123 resetval = mDateNavigator->sizeHint().height()+2;
2121 } 2124 }
2122 } 2125 }
2123 if ( resetval ) { 2126 if ( resetval ) {
2124 sizes.clear(); 2127 sizes.clear();
2125 if ( !KOPrefs::instance()->mVerticalScreen ) { 2128 if ( !KOPrefs::instance()->mVerticalScreen ) {
2126 maxVal = QApplication::desktop()->width() -10; 2129 maxVal = QApplication::desktop()->width() -10;
2127 } else { 2130 } else {
2128 maxVal = QApplication::desktop()->height()-10; 2131 maxVal = QApplication::desktop()->height()-10;
2129 } 2132 }
2130 sizes << resetval; 2133 sizes << resetval;
2131 if ( maxVal < resetval + resetval) 2134 if ( maxVal < resetval + resetval)
2132 resetval = maxVal - resetval; 2135 resetval = maxVal - resetval;
2133 sizes << resetval; 2136 sizes << resetval;
2134 } 2137 }
2135 mMainFrame->setSizes(sizes); 2138 mMainFrame->setSizes(sizes);
2136 if ( dateCount == 5 ) mNavigator->selectWorkWeek(); 2139 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
2137 else if ( dateCount == 7 ) mNavigator->selectWeek(); 2140 else if ( dateCount == 7 ) mNavigator->selectWeek();
2138 else mNavigator->selectDates( dateCount ); 2141 else mNavigator->selectDates( dateCount );
2139 // mViewManager->readSettings( config ); 2142 // mViewManager->readSettings( config );
2140 updateConfig(); 2143 updateConfig();
2141 globalFlagBlockAgenda = 2; 2144 globalFlagBlockAgenda = 2;
2142 mViewManager->readSettings( config ); 2145 mViewManager->readSettings( config );
2143 QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); 2146 QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) );
2144} 2147}
2145 2148
2146 2149
2147void CalendarView::writeSettings() 2150void CalendarView::writeSettings()
2148{ 2151{
2149 // kdDebug() << "CalendarView::writeSettings" << endl; 2152 // kdDebug() << "CalendarView::writeSettings" << endl;
2150 2153
2151 KConfig *config = KOGlobals::config(); 2154 KConfig *config = KOGlobals::config();
2152 2155
2153 mViewManager->writeSettings( config ); 2156 mViewManager->writeSettings( config );
2154 mTodoList->saveLayout(config,QString("Todo Layout")); 2157 mTodoList->saveLayout(config,QString("Todo Layout"));
2155 mDialogManager->writeSettings( config ); 2158 mDialogManager->writeSettings( config );
2156 //KOPrefs::instance()->usrWriteConfig(); 2159 //KOPrefs::instance()->usrWriteConfig();
2157 KOPrefs::instance()->writeConfig(); 2160 KOPrefs::instance()->writeConfig();
2158 2161
2159 writeFilterSettings(config); 2162 writeFilterSettings(config);
2160 config->setGroup( "AppRun" ); 2163 config->setGroup( "AppRun" );
2161 QDateTime dt ( QDate (2005,3,1), QTime( 0,0,0 ) ); 2164 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) );
2165 int days = dt.daysTo( QDate::currentDate() );
2166 dt = dt.addDays( days );
2162 int secs = dt.secsTo( QDateTime::currentDateTime() ); 2167 int secs = dt.secsTo( QDateTime::currentDateTime() );
2163 config->writeEntry( "LatestProgramStop", secs ); 2168 config->writeEntry( "LatestProgramStopDays", days );
2164 qDebug("KO: Writing stop time: %d ", secs); 2169 config->writeEntry( "LatestProgramStopSecs", secs );
2165 qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); 2170 //qDebug("KO: Writing stop time: %d ", secs);
2166 QDateTime latest = dt.addSecs ( secs ); 2171 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() );
2167 qDebug("KO: Test termination on %s ", latest.toString().latin1()); 2172 //QDateTime latest = dt.addSecs ( secs );
2173 //qDebug("KO: Termination on %s ", latest.toString().latin1());
2168 config->setGroup( "Views" ); 2174 config->setGroup( "Views" );
2169 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); 2175 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
2170 2176
2177#if 0
2178 qDebug("********************* ");
2179 qDebug("Testcode secsto ");
2180 QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) );
2181 QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) );
2182 int secsto = dt_nodaylight.secsTo( dt_daylight );
2183 QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto );
2184 qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() );
2185 qDebug("dt daylight %s ",dt_daylight.toString().latin1() );
2186 qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() );
2187 qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600);
2188 qDebug("********************* testcode end");
2189
2190#endif
2191
2171 QValueList<int> listINT = mLeftFrame->sizes(); 2192 QValueList<int> listINT = mLeftFrame->sizes();
2172 config->writeEntry("Left Splitter Frame",listINT); 2193 config->writeEntry("Left Splitter Frame",listINT);
2173 QValueList<int> listINT2 = mMainFrame->sizes(); 2194 QValueList<int> listINT2 = mMainFrame->sizes();
2174 config->writeEntry("Main Splitter Frame",listINT2); 2195 config->writeEntry("Main Splitter Frame",listINT2);
2175#ifdef DESKTOP_VERSION 2196#ifdef DESKTOP_VERSION
2176 config->setGroup("WidgetLayout"); 2197 config->setGroup("WidgetLayout");
2177 QStringList list ;//= config->readListEntry("MainLayout"); 2198 QStringList list ;//= config->readListEntry("MainLayout");
2178 int x,y,w,h; 2199 int x,y,w,h;
2179 QWidget* wid; 2200 QWidget* wid;
2180 wid = topLevelWidget(); 2201 wid = topLevelWidget();
2181 x = wid->geometry().x(); 2202 x = wid->geometry().x();
2182 y = wid->geometry().y(); 2203 y = wid->geometry().y();
2183 w = wid->width(); 2204 w = wid->width();
2184 h = wid->height(); 2205 h = wid->height();
2185 list.clear(); 2206 list.clear();
2186 list << QString::number( x ); 2207 list << QString::number( x );
2187 list << QString::number( y ); 2208 list << QString::number( y );
2188 list << QString::number( w ); 2209 list << QString::number( w );
2189 list << QString::number( h ); 2210 list << QString::number( h );
2190 config->writeEntry("MainLayout",list ); 2211 config->writeEntry("MainLayout",list );
2191 2212
2192 wid = mEventEditor; 2213 wid = mEventEditor;
2193 x = wid->geometry().x(); 2214 x = wid->geometry().x();
2194 y = wid->geometry().y(); 2215 y = wid->geometry().y();
2195 w = wid->width(); 2216 w = wid->width();
2196 h = wid->height(); 2217 h = wid->height();
2197 list.clear(); 2218 list.clear();
2198 list << QString::number( x ); 2219 list << QString::number( x );
2199 list << QString::number( y ); 2220 list << QString::number( y );
2200 list << QString::number( w ); 2221 list << QString::number( w );
2201 list << QString::number( h ); 2222 list << QString::number( h );
2202 config->writeEntry("EditEventLayout",list ); 2223 config->writeEntry("EditEventLayout",list );
2203 2224
2204 wid = mTodoEditor; 2225 wid = mTodoEditor;
2205 x = wid->geometry().x(); 2226 x = wid->geometry().x();
2206 y = wid->geometry().y(); 2227 y = wid->geometry().y();
2207 w = wid->width(); 2228 w = wid->width();
2208 h = wid->height(); 2229 h = wid->height();
2209 list.clear(); 2230 list.clear();
2210 list << QString::number( x ); 2231 list << QString::number( x );
2211 list << QString::number( y ); 2232 list << QString::number( y );
2212 list << QString::number( w ); 2233 list << QString::number( w );
2213 list << QString::number( h ); 2234 list << QString::number( h );
2214 config->writeEntry("EditTodoLayout",list ); 2235 config->writeEntry("EditTodoLayout",list );
2215 wid = getEventViewerDialog(); 2236 wid = getEventViewerDialog();
2216 x = wid->geometry().x(); 2237 x = wid->geometry().x();
2217 y = wid->geometry().y(); 2238 y = wid->geometry().y();
2218 w = wid->width(); 2239 w = wid->width();