author | zautrix <zautrix> | 2005-07-01 17:57:30 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-07-01 17:57:30 (UTC) |
commit | 98d29d15275c4b8e9a3348742925f6e6d03f7a07 (patch) (side-by-side diff) | |
tree | ea0af6d2100287c696bb00e1197d6c99f29f41e8 /korganizer/calendarview.cpp | |
parent | f330b9d0a7f755660ddd59739e3ab9b98d60bc18 (diff) | |
download | kdepimpi-98d29d15275c4b8e9a3348742925f6e6d03f7a07.zip kdepimpi-98d29d15275c4b8e9a3348742925f6e6d03f7a07.tar.gz kdepimpi-98d29d15275c4b8e9a3348742925f6e6d03f7a07.tar.bz2 |
fixx
-rw-r--r-- | korganizer/calendarview.cpp | 47 |
1 files changed, 26 insertions, 21 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index fd026fa..70a1d2d 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp @@ -762,49 +762,49 @@ void CalendarView::showDay( QDate d ) mViewManager->showDayView(); //dateNavigator()->selectDate( d ); } void CalendarView::timerAlarm() { //qDebug("CalendarView::timerAlarm() "); computeAlarm(mAlarmNotification ); } void CalendarView::suspendAlarm() { //qDebug(" CalendarView::suspendAlarm() "); computeAlarm(mSuspendAlarmNotification ); } void CalendarView::startAlarm( QString mess , QString filename) { topLevelWidget()->showNormal(); topLevelWidget()->setActiveWindow(); topLevelWidget()->raise(); mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); - QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); + QTimer::singleShot( 2000, this, SLOT( checkNextTimerAlarm() ) ); } void CalendarView::checkNextTimerAlarm() { mCalendar->checkAlarmForIncidence( 0, true ); } void CalendarView::computeAlarm( QString msg ) { QString mess = msg; QString mAlarmMessage = mess.mid( 9 ); QString filename = MainWindow::resourcePath(); filename += "koalarm.wav"; QString tempfilename; if ( mess.left( 13 ) == "suspend_alarm") { bool error = false; int len = mess.mid( 13 ).find("+++"); if ( len < 2 ) error = true; else { tempfilename = mess.mid( 13, len ); if ( !QFile::exists( tempfilename ) ) @@ -905,54 +905,58 @@ void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) int maxSec; //maxSec = 5; //testing only maxSec = 86400+3600; // one day+1hour mAlarmNotification = noti; int sec = QDateTime::currentDateTime().secsTo( qdt ); if ( sec > maxSec ) { mRecheckAlarmTimer->start( maxSec * 1000 ); // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); return; } else { mRecheckAlarmTimer->stop(); } //qDebug("Alarm timer started with secs: %d ", sec); mAlarmTimer->start( sec *1000 , true ); } // called by mRecheckAlarmTimer to get next alarm // we need this, because a QTimer has only a max range of 25 days void CalendarView::recheckTimerAlarm() { mAlarmTimer->stop(); mRecheckAlarmTimer->stop(); mCalendar->checkAlarmForIncidence( 0, true ); } +#ifndef DESKTOP_VERSION void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) +#else +void CalendarView::removeAlarm(const QDateTime &, const QString & ) +#endif { //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { #ifndef DESKTOP_VERSION - AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); + AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.utf8() ); #endif return; } mAlarmTimer->stop(); } void CalendarView::selectWeekNum ( int num ) { dateNavigator()->blockSignals( true ); dateNavigator()->selectWeek( num ); dateNavigator()->blockSignals( false ); mViewManager->showWeekView(); } KOViewManager *CalendarView::viewManager() { return mViewManager; } KODialogManager *CalendarView::dialogManager() { return mDialogManager; } QDate CalendarView::startDate() { @@ -1189,49 +1193,48 @@ void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* t } } void CalendarView::checkExternalId( Incidence * inc ) { QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; checkExternSyncEvent( lastSync, inc ); } bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) { bool syncOK = true; int addedEvent = 0; int addedEventR = 0; int deletedEventR = 0; int deletedEventL = 0; int changedLocal = 0; int changedRemote = 0; int filteredIN = 0; int filteredOUT = 0; //QPtrList<Event> el = local->rawEvents(); Event* eventR; QString uid; int take; - Event* eventL; Event* eventRSync; Event* eventLSync; clearAllViews(); QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); bool fullDateRange = false; local->resetTempSyncStat(); mLastCalendarSync = QDateTime::currentDateTime(); if ( mSyncManager->syncWithDesktop() ) { remote->resetPilotStat(1); if ( KSyncManager::mRequestedSyncEvent.isValid() ) { mLastCalendarSync = KSyncManager::mRequestedSyncEvent; qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); } else { qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); } } QDateTime modifiedCalendar = mLastCalendarSync; eventLSync = getLastSyncEvent(); eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); if ( eventR ) { eventRSync = (Event*) eventR->clone(); remote->deleteEvent(eventR ); @@ -2289,53 +2292,58 @@ void CalendarView::readSettings() } if ( resetval ) { sizes.clear(); if ( !KOPrefs::instance()->mVerticalScreen ) { maxVal = QApplication::desktop()->width() -10; } else { maxVal = QApplication::desktop()->height()-10; } sizes << resetval; if ( maxVal < resetval + resetval) resetval = maxVal - resetval; sizes << resetval; } mMainFrame->setSizes(sizes); if ( dateCount == 5 ) mNavigator->selectWorkWeek(); else if ( dateCount == 7 ) mNavigator->selectWeek(); else mNavigator->selectDates( dateCount ); // mViewManager->readSettings( config ); updateConfig(); globalFlagBlockAgenda = 2; mViewManager->readSettings( config ); QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); } - +void CalendarView::checkSuspendAlarm() +{ + if ( mSuspendTimer->isActive() ) { + KMessageBox::information( this, i18n("<b>WARNING:</b> There is a pending suspended alarm!"), i18n("Pending Suspend Alarm")); + } +} void CalendarView::writeSettings() { // kdDebug() << "CalendarView::writeSettings" << endl; - + KConfig *config = KOGlobals::config(); mViewManager->writeSettings( config ); mTodoList->saveLayout(config,QString("Todo Layout")); mDialogManager->writeSettings( config ); //KOPrefs::instance()->usrWriteConfig(); KOPrefs::instance()->writeConfig(); writeFilterSettings(config); config->setGroup( "AppRun" ); QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); int days = dt.daysTo( QDate::currentDate() ); dt = dt.addDays( days ); int secs = dt.secsTo( QDateTime::currentDateTime() ); config->writeEntry( "LatestProgramStopDays", days ); config->writeEntry( "LatestProgramStopSecs", secs ); //qDebug("KO: Writing stop time: %d ", secs); //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); //QDateTime latest = dt.addSecs ( secs ); //qDebug("KO: Termination on %s ", latest.toString().latin1()); config->setGroup( "Views" ); config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); #if 0 @@ -2773,70 +2781,69 @@ void CalendarView::slotSelectPickerDate( QDate d) emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); mMoveIncidence = newInc; #endif } QTime tim = mMoveIncidence->dtStart().time(); int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); QDateTime dt ( d,tim ); mMoveIncidence->setDtStart( dt ); ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); } mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); } } void CalendarView::removeCategories() { QPtrList<Incidence> incList = mCalendar->rawIncidences(); QStringList catList = KOPrefs::instance()->mCustomCategories; QStringList catIncList; QStringList newCatList; Incidence* inc = incList.first(); - int i; - int count = 0; + uint i; while ( inc ) { newCatList.clear(); catIncList = inc->categories() ; for( i = 0; i< catIncList.count(); ++i ) { if ( catList.contains (catIncList[i])) newCatList.append( catIncList[i] ); } newCatList.sort(); inc->setCategories( newCatList.join(",") ); inc = incList.next(); } } int CalendarView::addCategories() { QPtrList<Incidence> incList = mCalendar->rawIncidences(); QStringList catList = KOPrefs::instance()->mCustomCategories; QStringList catIncList; Incidence* inc = incList.first(); - int i; + uint i; int count = 0; while ( inc ) { catIncList = inc->categories() ; for( i = 0; i< catIncList.count(); ++i ) { if ( !catList.contains (catIncList[i])) { catList.append( catIncList[i] ); //qDebug("add cat %s ", catIncList[i].latin1()); ++count; } } inc = incList.next(); } catList.sort(); KOPrefs::instance()->mCustomCategories = catList; return count; } void CalendarView::editCategories() { qDebug("CalendarView::editCategories() "); KPIM::CategoryEditDialog ced (KOPrefs::instance(),this ); ced.exec(); } void CalendarView::manageCategories() @@ -2924,57 +2931,59 @@ void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) description += in->summary() + "\n"; cal->addIncidence( in ); incidence = delSel.next(); } if ( beamDialog.beamVcal() ) { fn += ".vcs"; FileStorage storage( cal, fn, new VCalFormat ); storage.save(); } else { fn += ".ics"; FileStorage storage( cal, fn, new ICalFormat( ) ); storage.save(); } delete cal; mes = i18n("KO/Pi: Ready for beaming"); topLevelWidget()->setCaption(mes); KApplication::convert2latin1( fn ); #ifndef DESKTOP_VERSION Ir *ir = new Ir( this ); connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); ir->send( fn, description, "text/x-vCalendar" ); #endif } } + +#ifndef DESKTOP_VERSION void CalendarView::beamDone( Ir *ir ) { -#ifndef DESKTOP_VERSION delete ir; -#endif topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); topLevelWidget()->raise(); } - +#else +void CalendarView::beamDone( Ir *){;} +#endif void CalendarView::moveIncidence(Incidence * inc ) { if ( !inc ) return; showDatePickerPopup(); mDatePickerMode = 2; mMoveIncidence = inc ; QDate da; if ( mMoveIncidence->typeID() == todoID ) { Todo * to = (Todo *) mMoveIncidence; if ( to->hasDueDate() ) da = to->dtDue().date(); else da = QDate::currentDate(); } else { da = mMoveIncidence->dtStart().date(); } //PENDING set date for recurring incidence to date of recurrence //mMoveIncidenceOldDate; mDatePicker->setDate( da ); } void CalendarView::showDatePickerPopup() { if ( mDateFrame->isVisible() ) mDateFrame->hide(); @@ -4286,53 +4295,48 @@ void CalendarView::toggleExpand() mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); //mViewManager->showView( 0, true ); } void CalendarView::calendarModified( bool modified, Calendar * ) { setModified( modified ); } Todo *CalendarView::selectedTodo() { Incidence *incidence = currentSelection(); if ( incidence && incidence->typeID() == todoID ) { return static_cast<Todo *>( incidence ); } incidence = mTodoList->selectedIncidences().first(); if ( incidence && incidence->typeID() == todoID ) { return static_cast<Todo *>( incidence ); } return 0; } -void CalendarView::dialogClosing(Incidence *in) -{ - // mDialogList.remove(in); -} - void CalendarView::showIncidence() { mViewerCallerIsSearchDialog = false; Incidence *incidence = currentSelection(); if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); if ( incidence ) { ShowIncidenceVisitor v; v.act( incidence, this ); } } void CalendarView::editIncidenceDescription() { mFlagEditDescription = true; editIncidence(); mFlagEditDescription = false; } void CalendarView::editIncidence() { // qDebug("editIncidence() "); Incidence *incidence = currentSelection(); if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); if ( incidence ) { EditIncidenceVisitor v; v.act( incidence, this ); @@ -4411,90 +4415,91 @@ bool CalendarView::removeCompletedSubTodos( Todo* t ) deleteTodo = false; } if ( deleteTodo ) { if ( t->isCompleted() && !t->doesRecur()) { checkExternalId( t ); mCalendar->deleteTodo( t ); changeTodoDisplay( t,KOGlobals::EVENTDELETED ); } else deleteTodo = false; } return deleteTodo; } void CalendarView::purgeCompleted() { int result = KMessageBox::warningContinueCancel(this, i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge")); if (result == KMessageBox::Continue) { QPtrList<Todo> todoCal; QPtrList<Todo> rootTodos; //QPtrList<Incidence> rel; - Todo *aTodo;//, *rTodo; - Incidence *rIncidence; - bool childDelete = false; - bool deletedOne = true; + Todo *aTodo; todoCal = calendar()->todos(); for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { if ( !aTodo->relatedTo() ) rootTodos.append( aTodo ); } for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { removeCompletedSubTodos( aTodo ); } updateView(); } } void CalendarView::slotCalendarChanged() { ; } void CalendarView::keyPressEvent ( QKeyEvent *e) { //qDebug(" alendarView::keyPressEvent "); e->ignore(); } bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) { - // mSyncManager = manager; + + if ( manager != mSyncManager) + qDebug("KO: Internal error-1. SyncManager mismatch "); if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { qDebug("KO: SyncKDE request detected!"); } mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); mCurrentSyncName = mSyncManager->getCurrentSyncName(); return syncCalendar( filename, mode ); } bool CalendarView::syncExternal(KSyncManager* manager, QString resource) { //mSyncManager = manager; + if ( manager != mSyncManager) + qDebug("KO: Internal error-2. SyncManager mismatch "); mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); mCurrentSyncName = mSyncManager->getCurrentSyncName(); if ( resource == "sharp" ) syncExternal( 0 ); if ( resource == "phone" ) syncExternal( 1 ); // pending setmodified return true; } void CalendarView::setSyncManager(KSyncManager* manager) { mSyncManager = manager; } void CalendarView::removeSyncInfo( QString syncProfile) { qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); mCalendar->removeSyncInfo( syncProfile ); } void CalendarView::undo_delete() { //qDebug("undo_delete() "); |