-rw-r--r-- | korganizer/calendarview.cpp | 136 |
1 files changed, 48 insertions, 88 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index ea9607d..b56f1f9 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp @@ -700,19 +700,7 @@ void CalendarView::createPrinter() void CalendarView::confSync() { - static KSyncPrefsDialog* sp = 0; - if ( ! sp ) { - sp = new KSyncPrefsDialog( this, "syncprefs", true ); - } - sp->usrReadConfig(); -#ifndef DESKTOP_VERSION - sp->showMaximized(); -#else - sp->show(); -#endif - sp->exec(); - KOPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); - KOPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); + //DELETE } @@ -877,7 +865,7 @@ Event* CalendarView::getLastSyncEvent() lse = new Event(); lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); QString sum = ""; - if ( KOPrefs::instance()->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) + if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) sum = "E: "; lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); lse->setDtStart( mLastCalendarSync ); @@ -1119,7 +1107,7 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int local->deleteIncidence( inL ); ++deletedEventL; } else { - if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { + if ( ! mSyncManager->mWriteBackExistingOnly ) { inL->removeID(mCurrentSyncDevice ); ++addedEventR; //qDebug("remote added Incidence %s ", inL->summary().latin1()); @@ -1135,7 +1123,7 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int local->deleteIncidence( inL ); ++deletedEventL; } else { - if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { + if ( ! mSyncManager->mWriteBackExistingOnly ) { ++addedEventR; inL->setLastModified( modifiedCalendar ); remote->addIncidence( inL->clone() ); @@ -1147,12 +1135,12 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int inL = el.next(); } int delFut = 0; - if ( KOPrefs::instance()->mWriteBackInFuture ) { + if ( mSyncManager->mWriteBackInFuture ) { er = remote->rawIncidences(); inR = er.first(); QDateTime dt; QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); - QDateTime end = cur.addDays( (KOPrefs::instance()->mWriteBackInFuture +1 ) *7 ); + QDateTime end = cur.addDays( (mSyncManager->mWriteBackInFuture +1 ) *7 ); while ( inR ) { if ( inR->type() == "Todo" ) { Todo * t = (Todo*)inR; @@ -1192,10 +1180,10 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR ); QString delmess; if ( delFut ) { - delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\n"),delFut, KOPrefs::instance()->mWriteBackInFuture ); + delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\n"),delFut, mSyncManager->mWriteBackInFuture ); mes += delmess; } - if ( KOPrefs::instance()->mShowSyncSummary ) { + if ( mSyncManager->mShowSyncSummary ) { KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); } qDebug( mes ); @@ -1225,7 +1213,7 @@ bool CalendarView::syncCalendar(QString filename, int mode) syncOK = synchronizeCalendar( mCalendar, calendar, mode ); getEventViewerDialog()->setSyncMode( false ); if ( syncOK ) { - if ( KOPrefs::instance()->mWriteBackFile ) + if ( mSyncManager->mWriteBackFile ) { storage->setSaveFormat( new ICalFormat() ); storage->save(); @@ -1241,14 +1229,12 @@ bool CalendarView::syncCalendar(QString filename, int mode) } void CalendarView::syncPhone() { - syncExternal( 1 ); + //DELETE } void CalendarView::syncExternal( int mode ) { mGlobalSyncMode = SYNC_MODE_EXTERNAL; - //mCurrentSyncDevice = "sharp-DTM"; - if ( KOPrefs::instance()->mAskForPreferences ) - edit_sync_options(); + qApp->processEvents(); CalendarLocal* calendar = new CalendarLocal(); calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); @@ -1265,20 +1251,20 @@ void CalendarView::syncExternal( int mode ) #endif if ( mode == 1 ) { // phone phoneFormat = new PhoneFormat (mCurrentSyncDevice, - KOPrefs::instance()->mPhoneDevice, - KOPrefs::instance()->mPhoneConnection, - KOPrefs::instance()->mPhoneModel); + mSyncManager->mPhoneDevice, + mSyncManager->mPhoneConnection, + mSyncManager->mPhoneModel); loadSuccess = phoneFormat->load( calendar,mCalendar); } else return; if ( loadSuccess ) { getEventViewerDialog()->setSyncMode( true ); - syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); + syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); getEventViewerDialog()->setSyncMode( false ); qApp->processEvents(); if ( syncOK ) { - if ( KOPrefs::instance()->mWriteBackFile ) + if ( mSyncManager->mWriteBackFile ) { QPtrList<Incidence> iL = mCalendar->rawIncidences(); Incidence* inc = iL.first(); @@ -1329,7 +1315,7 @@ void CalendarView::syncExternal( int mode ) } void CalendarView::syncSharp() { - syncExternal( 0 ); + //DELETE } @@ -1517,7 +1503,7 @@ bool CalendarView::importQtopia( const QString &categories, #if 0 mGlobalSyncMode = SYNC_MODE_QTOPIA; mCurrentSyncDevice = "qtopia-XML"; - if ( KOPrefs::instance()->mAskForPreferences ) + if ( mSyncManager->mAskForPreferences ) edit_sync_options(); qApp->processEvents(); CalendarLocal* calendar = new CalendarLocal(); @@ -1535,11 +1521,11 @@ bool CalendarView::importQtopia( const QString &categories, if ( loadOk ) { getEventViewerDialog()->setSyncMode( true ); - syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); + syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); getEventViewerDialog()->setSyncMode( false ); qApp->processEvents(); if ( syncOK ) { - if ( KOPrefs::instance()->mWriteBackFile ) + if ( mSyncManager->mWriteBackFile ) { // write back XML file @@ -1683,11 +1669,11 @@ bool CalendarView::checkFileVersion(QString fn) return true; setSyncDevice("deleteaftersync" ); - KOPrefs::instance()->mAskForPreferences = true; - KOPrefs::instance()->mSyncAlgoPrefs = 3; - KOPrefs::instance()->mWriteBackFile = false; - KOPrefs::instance()->mWriteBackExistingOnly = false; - KOPrefs::instance()->mShowSyncSummary = false; + mSyncManager->mAskForPreferences = true; + mSyncManager->mSyncAlgoPrefs = 3; + mSyncManager->mWriteBackFile = false; + mSyncManager->mWriteBackExistingOnly = false; + mSyncManager->mShowSyncSummary = false; syncCalendar( fn, 3 ); Event * e = getLastSyncEvent(); mCalendar->deleteEvent ( e ); @@ -2198,53 +2184,7 @@ void CalendarView::edit_options() } void CalendarView::edit_sync_options() { - //mDialogManager->showSyncOptions(); - //KOPrefs::instance()->mSyncAlgoPrefs - QDialog dia( this, "dia", true ); - dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); - QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); - QVBoxLayout lay ( &dia ); - lay.setSpacing( 2 ); - lay.setMargin( 3 ); - lay.addWidget(&gr); - QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); - QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); - QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); - QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); - QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); - QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); - //QRadioButton both( i18n("Take both on conflict"), &gr ); - QPushButton pb ( "OK", &dia); - lay.addWidget( &pb ); - connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); - switch ( KOPrefs::instance()->mSyncAlgoPrefs ) { - case 0: - loc.setChecked( true); - break; - case 1: - rem.setChecked( true ); - break; - case 2: - newest.setChecked( true); - break; - case 3: - ask.setChecked( true); - break; - case 4: - f_loc.setChecked( true); - break; - case 5: - f_rem.setChecked( true); - break; - case 6: - // both.setChecked( true); - break; - default: - break; - } - if ( dia.exec() ) { - KOPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; - } + // DELETE } @@ -3768,6 +3708,26 @@ void CalendarView::keyPressEvent ( QKeyEvent *e) e->ignore(); } -//#include "calendarview.moc" -//#include "calendarviewbase.moc" +bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) +{ + // mSyncManager = manager; + mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); + mCurrentSyncName = mSyncManager->getCurrentSyncName(); + return syncCalendar( filename, mode ); +} +bool CalendarView::syncExternal(KSyncManager* manager, QString resource) +{ + //mSyncManager = manager; + mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); + mCurrentSyncName = mSyncManager->getCurrentSyncName(); + if ( resource == "sharp" ) + syncExternal( 0 ); + if ( resource == "phone" ) + syncExternal( 1 ); + // pending setmodified +} +void CalendarView::setSyncManager(KSyncManager* manager) +{ + mSyncManager = manager; +} |