-rw-r--r-- | korganizer/calendarview.cpp | 19 | ||||
-rw-r--r-- | korganizer/calendarview.h | 2 | ||||
-rw-r--r-- | korganizer/koprefs.cpp | 10 | ||||
-rw-r--r-- | korganizer/koprefs.h | 1 |
4 files changed, 28 insertions, 4 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 31e103d..8965d3b 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp @@ -1933,97 +1933,96 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mSyncManager->mWriteBackFile = false; return syncOK; } } return syncOK; } void CalendarView::setSyncDevice( QString s ) { mCurrentSyncDevice= s; } void CalendarView::setSyncName( QString s ) { mCurrentSyncName= s; } bool CalendarView::syncCalendar(QString filename, int mode) { //qDebug("syncCalendar %s ", filename.latin1()); mGlobalSyncMode = SYNC_MODE_NORMAL; CalendarLocal* calendar = new CalendarLocal(); calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); FileStorage* storage = new FileStorage( calendar ); bool syncOK = false; storage->setFileName( filename ); // qDebug("loading ... "); if ( storage->load() ) { getEventViewerDialog()->setSyncMode( true ); syncOK = synchronizeCalendar( mCalendar, calendar, mode ); getEventViewerDialog()->setSyncMode( false ); if ( syncOK ) { if ( mSyncManager->mWriteBackFile ) { storage->setSaveFormat( new ICalFormat() ); storage->save(); } } setModified( true ); } delete storage; delete calendar; if ( syncOK ) updateView(); return syncOK; } void CalendarView::syncExternal( int mode ) { mGlobalSyncMode = SYNC_MODE_EXTERNAL; - qApp->processEvents(); CalendarLocal* calendar = new CalendarLocal(); calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); bool syncOK = false; bool loadSuccess = false; PhoneFormat* phoneFormat = 0; emit tempDisableBR(true); #ifndef DESKTOP_VERSION SharpFormat* sharpFormat = 0; if ( mode == 0 ) { // sharp sharpFormat = new SharpFormat () ; loadSuccess = sharpFormat->load( calendar, mCalendar ); } else #endif if ( mode == 1 ) { // phone phoneFormat = new PhoneFormat (mCurrentSyncDevice, mSyncManager->mPhoneDevice, mSyncManager->mPhoneConnection, mSyncManager->mPhoneModel); loadSuccess = phoneFormat->load( calendar,mCalendar); } else { emit tempDisableBR(false); return; } if ( loadSuccess ) { getEventViewerDialog()->setSyncMode( true ); syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); getEventViewerDialog()->setSyncMode( false ); qApp->processEvents(); if ( syncOK ) { if ( mSyncManager->mWriteBackFile ) { QPtrList<Incidence> iL = mCalendar->rawIncidences(); Incidence* inc = iL.first(); if ( phoneFormat ) { while ( inc ) { inc->removeID(mCurrentSyncDevice); inc = iL.next(); } } #ifndef DESKTOP_VERSION if ( sharpFormat ) sharpFormat->save(calendar); #endif if ( phoneFormat ) phoneFormat->save(calendar); @@ -4989,107 +4988,121 @@ bool CalendarView::removeCompletedSubTodos( Todo* t ) 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; 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("CalendarView::keyPressEvent "); e->ignore(); } -bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) +bool CalendarView::sync(KSyncManager* manager, QString filename, int mode,QString resource) { 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 ); + if ( !resource.isEmpty() ) { + int exclusiveSyncResource = KOPrefs::instance()->getFuzzyCalendarID( resource ); + qDebug( "KO: Sync request for resource: %s", resource.latin1() ); + + if ( !exclusiveSyncResource ) { + qDebug( "KO: Requested sync resource not found: %s", resource.latin1() ); + return false; + } + mCalendar->setDefaultCalendar( exclusiveSyncResource ); + mCalendar->setDefaultCalendarEnabledOnly(); + } + bool result = syncCalendar( filename, mode ); + if ( !resource.isEmpty() ) + restoreCalendarSettings(); + return result; } 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() "); Incidence* undo = mCalendar->undoIncidence(); if ( !undo ) { KMessageBox::sorry(this,i18n("There is nothing to undo!"), i18n("KO/Pi")); return; } if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( undo->summary(),0 ) + i18n("\nAre you sure you want\nto restore this?"), i18n("KO/Pi Confirmation"),i18n("Restore"))) { mCalendar->undoDeleteIncidence(); updateView(); } } void CalendarView::slotViewerClosed() { QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); } diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h index 80f7ed4..f85b6a3 100644 --- a/korganizer/calendarview.h +++ b/korganizer/calendarview.h @@ -473,97 +473,97 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser void processMainViewSelection( Incidence * ); void processTodoListSelection( Incidence * ); void processIncidenceSelection( Incidence * ); void purgeCompleted(); bool removeCompletedSubTodos( Todo* ); void slotCalendarChanged(); bool importBday(); bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); bool importQtopia( const QString &categoriesFile, const QString &datebookFile, const QString &tasklistFile ); void syncExternal( int mode ); void slotSelectPickerDate( QDate ) ; void showDatePicker() ; void showDatePickerPopup() ; void moveIncidence(Incidence *) ; void beamIncidence(Incidence *) ; void beamCalendar() ; void beamFilteredCalendar() ; void beamIncidenceList(QPtrList<Incidence>) ; void manageCategories(); void editCategories(); int addCategories(); void removeCategories(); void setSyncDevice( QString ); void setSyncName( QString ); void showDay( QDate ); void undo_delete(); protected slots: void resetFocus(); void scrollBarValue(int); void slotViewerClosed(); void timerAlarm(); void suspendAlarm(); void beamDone( Ir *ir ); /** Select a view or adapt the current view to display the specified dates. */ void showDates( const KCal::DateList & ); void selectWeekNum ( int ); void checkConflictForEvent(); public: void createRunningDate4Todo( Todo * runT, QDateTime start , QDateTime end, int secLenRunning, int secLenPausing,int dayInterval ); // show a standard warning // returns KMsgBox::yesNoCancel() int msgCalModified(); - virtual bool sync(KSyncManager* manager, QString filename, int mode); + virtual bool sync(KSyncManager* manager, QString filename, int mode, QString resource); virtual bool syncExternal(KSyncManager* manager, QString resource); virtual void removeSyncInfo( QString syncProfile); void setSyncManager(KSyncManager* manager); void setLoadedFileVersion(QDateTime); bool checkFileVersion(QString fn); bool checkAllFileVersions(); bool checkFileChanged(QString fn); Event* getLastSyncEvent(); /** Adapt navigation units correpsonding to step size of navigation of the * current view. */ void adaptNavigationUnits(); bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); //Attendee* getYourAttendee(Event *event); void setBlockShowDates( bool b ) { mBlockShowDates = b ;} void setScrollBarStep(int val ); protected: Event *mConflictingEvent; void schedule(Scheduler::Method, Incidence *incidence = 0); // returns KMsgBox::OKCandel() int msgItemDelete(const QString name); void showEventEditor(); void showTodoEditor(); Todo *selectedTodo(); private: #ifdef DESKTOP_VERSION QScrollBar * mDateScrollBar; #endif bool flag_blockConflict; bool flag_blockScrollBar; bool flag_checkFileFirsttime; bool flag_clearallviewsEventDisplay; bool flag_clearallviewsupdateView; QDateTime mNextAlarmDateTime; bool mViewerCallerIsSearchDialog; bool mBlockShowDates; KSyncManager* mSyncManager; AlarmDialog * mAlarmDialog; QString mAlarmNotification; QString mSuspendAlarmNotification; QTimer* mSuspendTimer; QTimer* mAlarmTimer; QTimer* mRecheckAlarmTimer; void computeAlarm( QString ); diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp index 1b0e5f4..31ef338 100644 --- a/korganizer/koprefs.cpp +++ b/korganizer/koprefs.cpp @@ -483,96 +483,106 @@ void KOPrefs::usrReadConfig() } if ( kkf->isRelative ) kkf->mFileName = QDir::convertSeparators( KGlobalSettings::calendarDir() + kkf->mSavedFileName ); } KPimPrefs::usrReadConfig(); } KopiCalendarFile * KOPrefs::getCalendar( int num ) { return mDefCalColors[num-1]; } KopiCalendarFile * KOPrefs::getNewCalendar() { KopiCalendarFile * kkf = new KopiCalendarFile(); kkf->mCalNumber = mNextAvailableCalendar; mDefCalColors.resize( mNextAvailableCalendar ); mDefCalColors[mNextAvailableCalendar-1] = kkf; ++mNextAvailableCalendar; kkf->mDefaultColor = mEventColor; kkf->mName = i18n("New Calendar"); mCalendars.append( kkf ); return kkf; } void KOPrefs::deleteCalendar( int num ) { KopiCalendarFile * kkf = mCalendars.first(); while ( kkf ) { if ( kkf->mCalNumber == num ) { qDebug("KOPrefs::deleteCalendar %d ", num ); mCalendars.remove( kkf ); delete kkf; return; } kkf = mCalendars.next(); } } int KOPrefs::getCalendarID( const QString & name ) { KopiCalendarFile * kkf = mCalendars.first(); while ( kkf ) { if ( name == kkf->mName) return kkf->mCalNumber; kkf = mCalendars.next(); } return 1; } +int KOPrefs::getFuzzyCalendarID( const QString & name ) +{ + KopiCalendarFile * kkf = mCalendars.first(); + while ( kkf ) { + if ( name.lower() == kkf->mName.lower()) + return kkf->mCalNumber; + kkf = mCalendars.next(); + } + return 0; +} QString KOPrefs::calName( int calNum) const { return (mDefCalColors[calNum-1])->mName; } QColor KOPrefs::defaultColor( int calNum ) const { if ( calNum == 1 ) return mEventColor; return (mDefCalColors[calNum-1])->mDefaultColor; } void KOPrefs::usrWriteConfig() { config()->setGroup("General"); config()->writeEntry("Custom Categories",mCustomCategories); config()->setGroup("Personal Settings"); config()->writeEntry("user_name",mName); config()->writeEntry("user_email",mEmail); config()->setGroup("Category Colors"); QDictIterator<QColor> it(mCategoryColors); while (it.current()) { config()->writeEntry(it.currentKey(),*(it.current())); ++it; } KConfig fc (locateLocal("config","kopicalendarrc")); fc.setGroup("CC"); fc.deleteGroup( "CC"); fc.setGroup("CC"); fc.writeEntry("NumberCalendars",mCalendars.count()); int numCal = 1; int writeCal = 0; while ( numCal < mNextAvailableCalendar ) { KopiCalendarFile * kkf = mCalendars.first(); while ( kkf ) { //qDebug("cal num %d %d ", kkf->mCalNumber, numCal); if ( kkf->mCalNumber == numCal ) { ++writeCal; //qDebug("Write calendar %d %d ", numCal , writeCal); QString prefix = "Cal_" + QString::number( writeCal ); fc.writeEntry( prefix+"_isStandard", kkf->isStandard ); fc.writeEntry( prefix+"_isEnabled", kkf->isEnabled ); fc.writeEntry( prefix+"_isAlarmEnabled", kkf->isAlarmEnabled ); fc.writeEntry( prefix+"_isReadOnly", kkf->isReadOnly ); fc.writeEntry( prefix+"_isRelative", kkf->isRelative ); fc.writeEntry( prefix+"_Name", kkf->mName); fc.writeEntry( prefix+"_FileName", kkf->mFileName); fc.writeEntry( prefix+"_SavedFileName", kkf->mSavedFileName); fc.writeEntry( prefix+"_Color",kkf->mDefaultColor); diff --git a/korganizer/koprefs.h b/korganizer/koprefs.h index bac8010..70da096 100644 --- a/korganizer/koprefs.h +++ b/korganizer/koprefs.h @@ -60,96 +60,97 @@ class KopiCalendarFile : public QObject mErrorOnLoad = false; isRelative = false; } bool isStandard; bool isEnabled; bool isAlarmEnabled; bool isReadOnly; bool mErrorOnLoad; QString mName; QString mFileName; QString mSavedFileName; bool isRelative; int mCalNumber; QColor mDefaultColor; QDateTime mLoadDt; }; class KOPrefs : public KPimPrefs { public: enum { FormatVCalendar, FormatICalendar }; enum { MailClientKMail, MailClientSendmail }; enum { IMIPDummy, IMIPKMail }; enum { IMIPOutbox, IMIPdirectsend }; enum { neverAuto, addressbookAuto, selectedAuto }; enum { standardDestination, askDestination }; virtual ~KOPrefs(); /** Get instance of KOPrefs. It is made sure that there is only one instance. */ static KOPrefs *instance(); /** Set preferences to default values */ void usrSetDefaults(); /** Read preferences from config file */ void usrReadConfig(); /** Write preferences to config file */ void usrWriteConfig(); void setCategoryDefaults(); void setAllDefaults(); KopiCalendarFile * getNewCalendar(); KopiCalendarFile * getCalendar( int ); void deleteCalendar( int ); QColor defaultColor( int ) const; QString calName( int ) const; int getCalendarID( const QString & name ); + int getFuzzyCalendarID( const QString & name ); protected: void setTimeZoneIdDefault(); /** Fill empty mail fields with default values. */ void fillMailDefaults(); private: /** Constructor disabled for public. Use instance() to create a KOPrefs object. */ KOPrefs(); static KOPrefs *mInstance; QStringList getDefaultList(); QStringList getLocationDefaultList(); public: // preferences data KConfig* getConfig(); void setFullName(const QString &); QString fullName(); void setEmail(const QString &); QString email(); QString mAdditional; bool mEmailControlCenter; bool mBcc; bool mAutoSave; int mAutoSaveInterval; bool mConfirm; bool mEnableGroupScheduling; bool mEnableProjectView; int mDefaultFormat; int mMailClient; int mStartTime; int mDefaultDuration; int mAlarmTime; int mWorkingHoursStart; int mWorkingHoursEnd; bool mExcludeHolidays; bool mExcludeSaturdays; bool mMarcusBainsShowSeconds; QFont mTimeBarFont; |