-rw-r--r-- | libkdepim/kpimprefs.h | 18 | ||||
-rw-r--r-- | libkdepim/ksyncmanager.cpp | 100 | ||||
-rw-r--r-- | libkdepim/ksyncmanager.h | 20 |
3 files changed, 69 insertions, 69 deletions
diff --git a/libkdepim/kpimprefs.h b/libkdepim/kpimprefs.h index 01c57a3..6f92919 100644 --- a/libkdepim/kpimprefs.h +++ b/libkdepim/kpimprefs.h @@ -51,33 +51,17 @@ class KPimPrefs : public KPrefs /** Write preferences to config file */ void usrWriteConfig(); public: QStringList mCustomCategories; - // sync stuff - QString mLocalMachineName; - QStringList mExternSyncProfiles; - QStringList mSyncProfileNames; - bool mAskForPreferences; - bool mShowSyncSummary; - bool mShowSyncEvents; - bool mShowTodoInAgenda; - bool mWriteBackExistingOnly; - int mSyncAlgoPrefs; - int mRingSyncAlgoPrefs; - bool mWriteBackFile; - int mWriteBackInFuture; - QString mPhoneDevice; - QString mPhoneConnection; - QString mPhoneModel; - QString mLastSyncedLocalFile; // save! + protected: virtual void setCategoryDefaults(); }; diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp index 07e6761..c0cc840 100644 --- a/libkdepim/ksyncmanager.cpp +++ b/libkdepim/ksyncmanager.cpp @@ -47,17 +47,17 @@ #include <qlayout.h> #include <klocale.h> #include <kglobal.h> #include <kconfig.h> #include <kfiledialog.h> KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu) - : QObject(), mParent(parent), mImplementation(implementation), mTargetApp(ta), mPrefs(prefs), mSyncMenu(syncmenu) + : QObject(), mParent(parent), mImplementation(implementation), mTargetApp(ta), mSyncMenu(syncmenu) { bar = new QProgressBar ( 1, 0 ); bar->setCaption (""); int w = 300; if ( QApplication::desktop()->width() < 320 ) w = 220; int h = bar->sizeHint().height() ; @@ -81,17 +81,17 @@ void KSyncManager::fillSyncMenu() mSyncMenu->insertItem( i18n("Configure..."), 0 ); mSyncMenu->insertSeparator(); mSyncMenu->insertItem( i18n("Multiple sync"), 1 ); mSyncMenu->insertSeparator(); KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); config.setGroup("General"); QStringList prof = config.readListEntry("SyncProfileNames"); - mPrefs->mLocalMachineName = config.readEntry("LocalMachineName","undefined"); + mLocalMachineName = config.readEntry("LocalMachineName","undefined"); if ( prof.count() < 3 ) { prof.clear(); prof << i18n("Sharp_DTM"); prof << i18n("Local_file"); prof << i18n("Last_file"); KSyncProfile* temp = new KSyncProfile (); temp->setName( prof[0] ); temp->writeConfig(&config); @@ -100,34 +100,32 @@ void KSyncManager::fillSyncMenu() temp->setName( prof[2] ); temp->writeConfig(&config); config.setGroup("General"); config.writeEntry("SyncProfileNames",prof); config.writeEntry("ExternSyncProfiles","Sharp_DTM"); config.sync(); delete temp; } - mPrefs->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); - mPrefs->mSyncProfileNames = prof; + mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); + mSyncProfileNames = prof; unsigned int i; for ( i = 0; i < prof.count(); ++i ) { mSyncMenu->insertItem( prof[i], 1000+i ); if ( i == 2 ) mSyncMenu->insertSeparator(); } QDir app_dir; //US do not display SharpDTM if app is pwmpi, or no sharpfiles available if ( mTargetApp == PWMPI) { mSyncMenu->removeItem( 1000 ); } else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { mSyncMenu->setItemEnabled( 1000, false ); } - //probaly useless - //mView->setupExternSyncProfiles(); } void KSyncManager::slotSyncMenu( int action ) { //qDebug("syncaction %d ", action); if ( action == 0 ) { // seems to be a Qt2 event handling bug @@ -145,79 +143,79 @@ void KSyncManager::slotSyncMenu( int action ) } if (blockSave()) return; setBlockSave(true); mCurrentSyncProfile = action - 1000 ; - mCurrentSyncDevice = mPrefs->mSyncProfileNames[mCurrentSyncProfile] ; - mCurrentSyncName = mPrefs->mLocalMachineName ; + mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ; + mCurrentSyncName = mLocalMachineName ; KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); KSyncProfile* temp = new KSyncProfile (); - temp->setName(mPrefs->mSyncProfileNames[mCurrentSyncProfile]); + temp->setName(mSyncProfileNames[mCurrentSyncProfile]); temp->readConfig(&config); - mPrefs->mAskForPreferences = temp->getAskForPreferences(); - mPrefs->mSyncAlgoPrefs = temp->getSyncPrefs(); - mPrefs->mWriteBackFile = temp->getWriteBackFile(); - mPrefs->mWriteBackExistingOnly = temp->getWriteBackExisting(); - mPrefs->mWriteBackInFuture = 0; + mAskForPreferences = temp->getAskForPreferences(); + mSyncAlgoPrefs = temp->getSyncPrefs(); + mWriteBackFile = temp->getWriteBackFile(); + mWriteBackExistingOnly = temp->getWriteBackExisting(); + mWriteBackInFuture = 0; if ( temp->getWriteBackFuture() ) - mPrefs->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); - mPrefs->mShowSyncSummary = temp->getShowSummaryAfterSync(); + mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); + mShowSyncSummary = temp->getShowSummaryAfterSync(); if ( action == 1000 ) { syncSharp(); } else if ( action == 1001 ) { syncLocalFile(); } else if ( action == 1002 ) { quickSyncLocalFile(); } else if ( action >= 1003 ) { if ( temp->getIsLocalFileSync() ) { switch(mTargetApp) { case (KAPI): if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) - mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); + mLastSyncedLocalFile = temp->getRemoteFileNameAB(); break; case (KOPI): if ( syncWithFile( temp->getRemoteFileName( ), false ) ) - mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); + mLastSyncedLocalFile = temp->getRemoteFileName(); break; case (PWMPI): if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) - mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); + mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); break; default: qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); break; } } else { if ( temp->getIsPhoneSync() ) { - mPrefs->mPhoneDevice = temp->getPhoneDevice( ) ; - mPrefs->mPhoneConnection = temp->getPhoneConnection( ); - mPrefs->mPhoneModel = temp->getPhoneModel( ); + mPhoneDevice = temp->getPhoneDevice( ) ; + mPhoneConnection = temp->getPhoneConnection( ); + mPhoneModel = temp->getPhoneModel( ); syncPhone(); } else syncRemote( temp ); } } delete temp; setBlockSave(false); } void KSyncManager::syncLocalFile() { - QString fn =mPrefs->mLastSyncedLocalFile; + QString fn =mLastSyncedLocalFile; QString ext; switch(mTargetApp) { case (KAPI): ext = "(*.vcf)"; break; case (KOPI): @@ -258,34 +256,34 @@ bool KSyncManager::syncWithFile( QString fn , bool quick ) mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); result = QMessageBox::warning( mParent, i18n("Warning!"), mess, i18n("Sync"), i18n("Cancel"), 0, 0, 1 ); if ( result ) return false; } - if ( mPrefs->mAskForPreferences ) + if ( mAskForPreferences ) edit_sync_options(); if ( result == 0 ) { //qDebug("Now sycing ... "); - if ( ret = mImplementation->sync( this, fn, mPrefs->mSyncAlgoPrefs ) ) + if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) ) mParent->setCaption( i18n("Synchronization successful") ); else mParent->setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); if ( ! quick ) - mPrefs->mLastSyncedLocalFile = fn; + mLastSyncedLocalFile = fn; mImplementation->sync_setModified(); } return ret; } void KSyncManager::quickSyncLocalFile() { - if ( syncWithFile( mPrefs->mLastSyncedLocalFile, false ) ) { + if ( syncWithFile( mLastSyncedLocalFile, false ) ) { qDebug("quick syncLocalFile() successful "); } } void KSyncManager::multiSync( bool askforPrefs ) { if (blockSave()) return; @@ -295,20 +293,20 @@ void KSyncManager::multiSync( bool askforPrefs ) question, i18n("Yes"), i18n("No"), 0, 0 ) != 0 ) { setBlockSave(false); mParent->setCaption(i18n("Aborted! Nothing synced!")); return; } mCurrentSyncDevice = i18n("Multiple profiles") ; - mPrefs->mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; + mSyncAlgoPrefs = mRingSyncAlgoPrefs; if ( askforPrefs ) { edit_sync_options(); - mPrefs->mRingSyncAlgoPrefs = mPrefs->mSyncAlgoPrefs; + mRingSyncAlgoPrefs = mSyncAlgoPrefs; } mParent->setCaption(i18n("Multiple sync started.") ); qApp->processEvents(); int num = ringSync() ; if ( num > 1 ) ringSync(); setBlockSave(false); if ( num ) @@ -320,19 +318,19 @@ void KSyncManager::multiSync( bool askforPrefs ) return; } int KSyncManager::ringSync() { int syncedProfiles = 0; unsigned int i; QTime timer; KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); - QStringList syncProfileNames = mPrefs->mSyncProfileNames; + QStringList syncProfileNames = mSyncProfileNames; KSyncProfile* temp = new KSyncProfile (); - mPrefs->mAskForPreferences = false; + mAskForPreferences = false; for ( i = 0; i < syncProfileNames.count(); ++i ) { mCurrentSyncProfile = i; temp->setName(syncProfileNames[mCurrentSyncProfile]); temp->readConfig(&config); QString includeInRingSync; switch(mTargetApp) { @@ -350,52 +348,52 @@ int KSyncManager::ringSync() break; } if ( includeInRingSync && ( i < 1 || i > 2 )) { mParent->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); ++syncedProfiles; - // mPrefs->mAskForPreferences = temp->getAskForPreferences(); - mPrefs->mWriteBackFile = temp->getWriteBackFile(); - mPrefs->mWriteBackExistingOnly = temp->getWriteBackExisting(); - mPrefs->mWriteBackInFuture = 0; + // mAskForPreferences = temp->getAskForPreferences(); + mWriteBackFile = temp->getWriteBackFile(); + mWriteBackExistingOnly = temp->getWriteBackExisting(); + mWriteBackInFuture = 0; if ( temp->getWriteBackFuture() ) - mPrefs->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); - mPrefs->mShowSyncSummary = false; + mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); + mShowSyncSummary = false; mCurrentSyncDevice = syncProfileNames[i] ; - mCurrentSyncName = mPrefs->mLocalMachineName; + mCurrentSyncName = mLocalMachineName; if ( i == 0 ) { syncSharp(); } else { if ( temp->getIsLocalFileSync() ) { switch(mTargetApp) { case (KAPI): if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) - mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); + mLastSyncedLocalFile = temp->getRemoteFileNameAB(); break; case (KOPI): if ( syncWithFile( temp->getRemoteFileName( ), false ) ) - mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); + mLastSyncedLocalFile = temp->getRemoteFileName(); break; case (PWMPI): if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) - mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); + mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); break; default: qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); break; } } else { if ( temp->getIsPhoneSync() ) { - mPrefs->mPhoneDevice = temp->getPhoneDevice( ) ; - mPrefs->mPhoneConnection = temp->getPhoneConnection( ); - mPrefs->mPhoneModel = temp->getPhoneModel( ); + mPhoneDevice = temp->getPhoneDevice( ) ; + mPhoneConnection = temp->getPhoneConnection( ); + mPhoneModel = temp->getPhoneModel( ); syncPhone(); } else syncRemote( temp, false ); } } timer.start(); mParent->setCaption(i18n("Multiple sync in progress ... please wait!") ); @@ -486,17 +484,17 @@ void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) if ( syncWithFile( localTempFile, true ) ) { // Event* e = mView->getLastSyncEvent(); // e->setReadOnly( false ); // e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); // e->setReadOnly( true ); - if ( mPrefs->mWriteBackFile ) { + if ( mWriteBackFile ) { int fi; if ( (fi = postCommand.find("$PWD$")) > 0 ) { QString pwd = getPassword(); postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); } mParent->setCaption ( i18n( "Writing back file ..." ) ); result = system ( postCommand ); @@ -510,17 +508,17 @@ void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) } } return; } void KSyncManager::edit_sync_options() { //mDialogManager->showSyncOptions(); - //mPrefs->mSyncAlgoPrefs + //mSyncAlgoPrefs QDialog dia( mParent, "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 ); @@ -528,17 +526,17 @@ void KSyncManager::edit_sync_options() 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 ( mPrefs->mSyncAlgoPrefs ) { + switch ( mSyncAlgoPrefs ) { case 0: loc.setChecked( true); break; case 1: rem.setChecked( true ); break; case 2: newest.setChecked( true); @@ -554,17 +552,17 @@ void KSyncManager::edit_sync_options() break; case 6: // both.setChecked( true); break; default: break; } if ( dia.exec() ) { - mPrefs->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; + mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; } } QString KSyncManager::getPassword( ) { QString retfile = ""; QDialog dia ( mParent, "input-dialog", true ); @@ -598,33 +596,33 @@ void KSyncManager::confSync() } sp->usrReadConfig(); #ifndef DESKTOP_VERSION sp->showMaximized(); #else sp->show(); #endif sp->exec(); - mPrefs->mSyncProfileNames = sp->getSyncProfileNames(); - mPrefs->mLocalMachineName = sp->getLocalMachineName (); + mSyncProfileNames = sp->getSyncProfileNames(); + mLocalMachineName = sp->getLocalMachineName (); fillSyncMenu(); } void KSyncManager::syncSharp() { if ( ! syncExternalApplication("sharp") ) qDebug("ERROR sync sharp ");; } bool KSyncManager::syncExternalApplication(QString resource) { if ( mImplementation->sync_isModified() ) mImplementation->sync_save(); - if ( mPrefs->mAskForPreferences ) + if ( mAskForPreferences ) edit_sync_options(); qDebug("sync %s", resource.latin1()); bool syncOK = mImplementation->syncExternal(this, resource); return syncOK; diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h index 9761107..6b10016 100644 --- a/libkdepim/ksyncmanager.h +++ b/libkdepim/ksyncmanager.h @@ -54,16 +54,35 @@ class KSyncManager : public QObject QString getCurrentSyncDevice() { return mCurrentSyncDevice; } QString getCurrentSyncName() { return mCurrentSyncName; } void showProgressBar(int percentage, QString caption = QString::null, int total=100); void hideProgressBar(); bool isProgressBarCanceled(); + // sync stuff + QString mLocalMachineName; + QStringList mExternSyncProfiles; + QStringList mSyncProfileNames; + bool mAskForPreferences; + bool mShowSyncSummary; + bool mShowSyncEvents; + bool mShowTodoInAgenda; + bool mWriteBackExistingOnly; + int mSyncAlgoPrefs; + int mRingSyncAlgoPrefs; + bool mWriteBackFile; + int mWriteBackInFuture; + QString mPhoneDevice; + QString mPhoneConnection; + QString mPhoneModel; + QString mLastSyncedLocalFile; // save! + + public slots: void slotSyncMenu( int ); private: // LR ******************************* // sync stuff! QString mCurrentSyncDevice; @@ -87,17 +106,16 @@ class KSyncManager : public QObject private: bool mBlockSaveFlag; QWidget* mParent; KSyncInterface* mImplementation; TargetApp mTargetApp; - KPimPrefs* mPrefs; QPopupMenu* mSyncMenu; QProgressBar* bar; |