author | zautrix <zautrix> | 2004-08-01 12:56:11 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-08-01 12:56:11 (UTC) |
commit | cc2643f4be54269db8c24f66fdcbbf6954d5f537 (patch) (side-by-side diff) | |
tree | 3562598dac624305dfb9fd1911a4b314ae40945d | |
parent | c31e99f265dbe8762efca20667f8ccd973840f8f (diff) | |
download | kdepimpi-cc2643f4be54269db8c24f66fdcbbf6954d5f537.zip kdepimpi-cc2643f4be54269db8c24f66fdcbbf6954d5f537.tar.gz kdepimpi-cc2643f4be54269db8c24f66fdcbbf6954d5f537.tar.bz2 |
Made sync profile dialog korganizer independent
-rw-r--r-- | korganizer/calendarview.cpp | 28 | ||||
-rw-r--r-- | korganizer/calendarview.h | 2 | ||||
-rw-r--r-- | korganizer/kosyncprefsdialog.cpp | 44 | ||||
-rw-r--r-- | korganizer/kosyncprefsdialog.h | 4 | ||||
-rw-r--r-- | korganizer/mainwindow.cpp | 21 |
5 files changed, 47 insertions, 52 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index b543eca..c75d10e 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp @@ -233,13 +233,12 @@ void CalendarView::init() mViewManager = new KOViewManager( this ); mDialogManager = new KODialogManager( this ); mEventViewerDialog = 0; mModified = false; mReadOnly = false; mSelectedIncidence = 0; - mSyncProfiles.setAutoDelete(true); mCalPrinter = 0; mFilters.setAutoDelete(true); mCalendar->registerObserver( this ); // TODO: Make sure that view is updated, when calendar is changed. @@ -687,20 +686,22 @@ void CalendarView::createPrinter() void CalendarView::confSync() { static KOSyncPrefsDialog* sp = 0; if ( ! sp ) { sp = new KOSyncPrefsDialog( this, "syncprefs", true ); } + sp->setLocalMachineName ( KOPrefs::instance()->mLocalMachineName ); sp->usrReadConfig(); #ifndef DESKTOP_VERSION sp->showMaximized(); #else sp->show(); #endif sp->exec(); - + KOPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); + KOPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); } //KOPrefs::instance()->mWriteBackFile //KOPrefs::instance()->mWriteBackExistingOnly @@ -1560,35 +1561,12 @@ void CalendarView::readSettings() w = list[2].toInt(); h = list[3].toInt(); getEventViewerDialog()->setGeometry(x,y,w,h); } #endif - - // pending read sync settings; - mSyncProfileNames.clear(); - mSyncProfileNames << "Profile_1"; - mSyncProfileNames << "Profile_2"; - mSyncProfileNames << "Profile_3"; - mSyncProfileNames << "Profile_4"; - mSyncProfileNames << "Profile_5"; - KSyncProfile* temp = new KSyncProfile (); - temp->setName("Profile_1" ); - mSyncProfiles.append( temp ); - temp = new KSyncProfile (); - temp->setName("Profile_2" ); - mSyncProfiles.append( temp ); - temp = new KSyncProfile (); - temp->setName("Profile_3" ); - mSyncProfiles.append( temp ); - temp = new KSyncProfile (); - temp->setName("Profile_4" ); - mSyncProfiles.append( temp ); - temp = new KSyncProfile (); - temp->setName("Profile_5" ); - mSyncProfiles.append( temp ); } void CalendarView::writeSettings() { // kdDebug() << "CalendarView::writeSettings" << endl; diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h index fda02f7..8aa5e1c 100644 --- a/korganizer/calendarview.h +++ b/korganizer/calendarview.h @@ -479,14 +479,12 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser void computeAlarm( QString ); void startAlarm( QString, QString ); void setSyncEventsReadOnly(); QDateTime loadedFileVersion; void checkSharpEvent( Event* lastSync, Incidence* toDelete ); - QPtrList<KSyncProfile> mSyncProfiles; - QStringList mSyncProfileNames; void checkZaurusId( int id, bool todo = false ); int mGlobalSyncMode; QString mCurrentSyncDevice; QString mCurrentSyncName; KOBeamPrefs* beamDialog; void init(); diff --git a/korganizer/kosyncprefsdialog.cpp b/korganizer/kosyncprefsdialog.cpp index b7e4265..7c838f5 100644 --- a/korganizer/kosyncprefsdialog.cpp +++ b/korganizer/kosyncprefsdialog.cpp @@ -26,12 +26,13 @@ #include <qgroupbox.h> #include <qbuttongroup.h> #include <qlineedit.h> #include <qfont.h> #include <qslider.h> #include <qfile.h> +#include <qdir.h> #include <qtextstream.h> #include <qcombobox.h> #include <qvbox.h> #include <qhbox.h> #include <qspinbox.h> #include <qdatetime.h> @@ -56,16 +57,16 @@ #include <kurlrequester.h> #include <klineedit.h> #include <libkdepim/ksyncprofile.h> -#include "koprefs.h" +//#include "koprefs.h" #include "kosyncprefsdialog.h" -#include "koglobals.h" +//#include "koglobals.h" KOSyncPrefsDialog::KOSyncPrefsDialog(QWidget *parent, char *name, bool modal) : KDialog(parent,name,true) { @@ -230,13 +231,13 @@ void KOSyncPrefsDialog::slotOK() void KOSyncPrefsDialog::accept() { slotOK(); } void KOSyncPrefsDialog::chooseFile() { - QString fn =KOPrefs::instance()->mLastSyncedLocalFile; + QString fn = QDir::homeDirPath(); fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); if ( fn == "" ) return; mRemoteFile->setText( fn ); } @@ -410,43 +411,58 @@ void KOSyncPrefsDialog::cloneProfile() if ( currentSelection >= 0 ) addProfile (mSyncProfiles.at(currentSelection)->clone()) ; else newProfile(); } +void KOSyncPrefsDialog::setLocalMachineName ( const QString& name ) +{ + mMyMachineName->setText( name ); +} +QString KOSyncPrefsDialog::getLocalMachineName ( ) +{ + return mMyMachineName->text(); +} + +QStringList KOSyncPrefsDialog::getSyncProfileNames() +{ + return mSyncProfileNames; +} void KOSyncPrefsDialog::usrReadConfig() { - KConfig *config = KOGlobals::config(); - config->setGroup("SyncProfiles"); - mSyncProfileNames = KOPrefs::instance()->mSyncProfileNames; + //KConfig *config = KOGlobals::config(); + KConfig config ( locateLocal( "config","syncprofilesrc" ) ); + config.setGroup("SyncProfiles"); + mSyncProfileNames =config.readListEntry("SyncProfileNames"); int i; KSyncProfile* temp ; mSyncProfiles.clear(); for ( i = 0; i < mSyncProfileNames.count();++i ) { temp = new KSyncProfile (); temp->setName( mSyncProfileNames[i] ); - temp->readConfig( config ); + temp->readConfig( &config ); mSyncProfiles.append( temp ); } insertProfiles(); - mMyMachineName->setText(KOPrefs::instance()->mLocalMachineName ); + //mMyMachineName->setText(KOPrefs::instance()->mLocalMachineName ); } void KOSyncPrefsDialog::usrWriteConfig() { saveProfile(); if ( currentSelection >= 0 ) profileChanged(currentSelection); - KConfig *config = KOGlobals::config(); - config->setGroup("SyncProfiles"); + //KConfig *config = KOGlobals::config(); + KConfig config ( locateLocal( "config","syncprofilesrc" ) ); + config.setGroup("SyncProfiles"); KSyncProfile* prof = mSyncProfiles.first(); while ( prof ) { - prof->writeConfig(config); + prof->writeConfig(&config); prof = mSyncProfiles.next(); } - KOPrefs::instance()->mSyncProfileNames = mSyncProfileNames; - KOPrefs::instance()->mLocalMachineName = mMyMachineName->text(); - config->writeEntry("SyncProfileNames",&mSyncProfileNames); + //KOPrefs::instance()->mSyncProfileNames = mSyncProfileNames; + //KOPrefs::instance()->mLocalMachineName = mMyMachineName->text(); + config.writeEntry("SyncProfileNames",&mSyncProfileNames); } diff --git a/korganizer/kosyncprefsdialog.h b/korganizer/kosyncprefsdialog.h index d2d8c6f..541d18b 100644 --- a/korganizer/kosyncprefsdialog.h +++ b/korganizer/kosyncprefsdialog.h @@ -52,12 +52,16 @@ class KOSyncPrefsDialog : public KDialog Q_OBJECT public: /** Initialize dialog and pages */ KOSyncPrefsDialog(QWidget *parent=0,char *name=0,bool modal=false); ~KOSyncPrefsDialog(); void usrReadConfig(); + void setLocalMachineName ( const QString& name ); + QString getLocalMachineName ( ); + + QStringList getSyncProfileNames(); public slots: protected slots: void accept(); void deleteProfile(); void newProfile(); diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index a487f14..589ab2d 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp @@ -815,33 +815,32 @@ void MainWindow::fillSyncMenu() { syncMenu->clear(); syncMenu->insertItem( i18n("Configure..."), 0 ); syncMenu->insertSeparator(); syncMenu->insertItem( i18n("Multiple sync"), 1 ); syncMenu->insertSeparator(); - - QStringList prof = KOPrefs::instance()->mSyncProfileNames; - + KConfig config ( locateLocal( "config","syncprofilesrc" ) ); + config.setGroup("SyncProfiles"); + QStringList prof = config.readListEntry("SyncProfileNames"); + if ( prof.count() < 3 ) { - KConfig *config = KOGlobals::config(); 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); + temp->writeConfig(&config); temp->setName( prof[1] ); - temp->writeConfig(config); + temp->writeConfig(&config); temp->setName( prof[2] ); - temp->writeConfig(config); - config->sync(); + temp->writeConfig(&config); + config.sync(); delete temp; - KOPrefs::instance()->mSyncProfileNames = prof; } - + KOPrefs::instance()->mSyncProfileNames = prof; int i; for ( i = 0; i < prof.count(); ++i ) { syncMenu->insertItem( prof[i], 1000+i ); if ( i == 2 ) syncMenu->insertSeparator(); @@ -1797,13 +1796,13 @@ void MainWindow::quickSyncLocalFile() } void MainWindow::confSync() { mView->confSync(); fillSyncMenu(); - mView->writeSettings(); + //mView->writeSettings(); } void MainWindow::syncRemote( KSyncProfile* prof, bool ask) { QString question; |