• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdepim
  • Sitemap
  • Contact Us
 

kpilot

config_pages.cc

Go to the documentation of this file.
00001 /* KPilot
00002 **
00003 ** Copyright (C) 2001 by Dan Pilone <dan@kpilot.org>
00004 ** Copyright (C) 2002-2004 by Adriaan de Groot <groot@kde.org>
00005 ** Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
00006 **
00007 ** This file defines the pages that make up part of the configuration dialog.
00008 */
00009 
00010 /*
00011 ** This program is free software; you can redistribute it and/or modify
00012 ** it under the terms of the GNU General Public License as published by
00013 ** the Free Software Foundation; either version 2 of the License, or
00014 ** (at your option) any later version.
00015 **
00016 ** This program is distributed in the hope that it will be useful,
00017 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
00018 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00019 ** GNU General Public License for more details.
00020 **
00021 ** You should have received a copy of the GNU General Public License
00022 ** along with this program in a file called COPYING; if not, write to
00023 ** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
00024 ** MA 02110-1301, USA.
00025 */
00026 
00027 /*
00028 ** Bug reports and questions can be sent to kde-pim@kde.org
00029 */
00030 
00031 #include "options.h"
00032 
00033 #include <kcharsets.h>
00034 #include <kautostart.h>
00035 
00036 #include "syncAction.h"
00037 
00038 #include "kpilotConfig.h"
00039 #include "kpilotSettings.h"
00040 
00041 #include "config_dialog_probe.h"
00042 #include "config_dialog_dbselection.h"
00043 
00044 #include "config_pages.moc"
00045 
00046 /* virtual */ QString ConfigPage::maybeSaveText() const
00047 {
00048     return i18n("<qt>The settings for configuration page <i>%1</i> have been changed. Do you "
00049         "want to save the changes before continuing?</qt>", this->conduitName());
00050 }
00051 
00052 DeviceConfigPage::DeviceConfigPage(QWidget * w, QVariantList &args ) 
00053     : ConfigPage( w, args )
00054 {
00055     FUNCTIONSETUP;
00056 
00057     fWidget = new QWidget(w);
00058     fConfigWidget.setupUi( fWidget );
00059     
00060     // Fill the encodings list
00061     {
00062         QStringList l = KGlobal::charsets()->descriptiveEncodingNames();
00063         for ( QStringList::Iterator it = l.begin(); it != l.end(); ++it )
00064         {
00065             fConfigWidget.fPilotEncoding->addItem(*it);
00066         }
00067     }
00068     
00069     connect( fConfigWidget.fDeviceAutodetect, SIGNAL(clicked()), this
00070         , SLOT(autoDetectDevice()));
00071 
00072 #define CM(a,b) connect(fConfigWidget.a,b,this,SLOT(modified()));
00073     CM(fPilotDevice, SIGNAL(textChanged(const QString &)));
00074     CM(fPilotSpeed, SIGNAL(activated(int)));
00075     CM(fPilotEncoding, SIGNAL(textChanged(const QString &)));
00076     CM(fUserName, SIGNAL(textChanged(const QString &)));
00077     CM(fWorkaround, SIGNAL(activated(int)));
00078 #undef CM
00079 
00080     fConduitName = i18n("Device");
00081 }
00082 
00083 void DeviceConfigPage::load()
00084 {
00085     FUNCTIONSETUP;
00086     KPilotSettings::self()->readConfig();
00087 
00088     /* General tab in the setup dialog */
00089     fConfigWidget.fPilotDevice->setText(KPilotSettings::pilotDevice());
00090     fConfigWidget.fPilotSpeed->setCurrentIndex(KPilotSettings::pilotSpeed());
00091     getEncoding();
00092     fConfigWidget.fUserName->setText(KPilotSettings::userName());
00093 
00094     switch(KPilotSettings::workarounds())
00095     {
00096     case KPilotSettings::eWorkaroundNone :
00097         fConfigWidget.fWorkaround->setCurrentIndex(0);
00098         break;
00099     case KPilotSettings::eWorkaroundUSB :
00100         fConfigWidget.fWorkaround->setCurrentIndex(1);
00101         break;
00102     default:
00103         WARNINGKPILOT << "Unknown workaround number "
00104             << (int) KPilotSettings::workarounds();
00105         KPilotSettings::setWorkarounds(KPilotSettings::eWorkaroundNone);
00106         fConfigWidget.fWorkaround->setCurrentIndex(0);
00107     }
00108     unmodified();
00109 }
00110 
00111 /* virtual */ void DeviceConfigPage::commit()
00112 {
00113     FUNCTIONSETUP;
00114 
00115     // General page
00116     KPilotSettings::setPilotDevice(fConfigWidget.fPilotDevice->text());
00117     KPilotSettings::setPilotSpeed(fConfigWidget.fPilotSpeed->currentIndex());
00118     setEncoding();
00119     KPilotSettings::setUserName(fConfigWidget.fUserName->text());
00120 
00121     switch(fConfigWidget.fWorkaround->currentIndex())
00122     {
00123     case 0 :
00124         KPilotSettings::setWorkarounds(KPilotSettings::eWorkaroundNone);
00125         break;
00126     case 1 :
00127         KPilotSettings::setWorkarounds(KPilotSettings::eWorkaroundUSB);
00128         break;
00129     default :
00130         WARNINGKPILOT << "Unknown workaround number "
00131             << fConfigWidget.fWorkaround->currentIndex();
00132         KPilotSettings::setWorkarounds(KPilotSettings::eWorkaroundNone);
00133     }
00134     KPilotConfig::updateConfigVersion();
00135     KPilotSettings::self()->writeConfig();
00136     unmodified();
00137 }
00138 
00139 /* slot */ void DeviceConfigPage::changePortType(int i)
00140 {
00141     FUNCTIONSETUP;
00142 
00143     switch (i)
00144     {
00145     case 0:
00146         fConfigWidget.fPilotSpeed->setEnabled(true);
00147         break;
00148     case 1:
00149     case 2:
00150         fConfigWidget.fPilotSpeed->setEnabled(false);
00151         break;
00152     default:
00153         WARNINGKPILOT << "Unknown port type" << i;
00154     }
00155 }
00156 
00157 void DeviceConfigPage::getEncoding()
00158 {
00159     FUNCTIONSETUP;
00160     QString e = KPilotSettings::encoding();
00161     if (e.isEmpty())
00162     {
00163         fConfigWidget.fPilotEncoding->setEditText(CSL1("ISO8859-15"));
00164     }
00165     else
00166     {
00167         fConfigWidget.fPilotEncoding->setEditText(e);
00168     }
00169 }
00170 
00171 void DeviceConfigPage::setEncoding()
00172 {
00173     FUNCTIONSETUP;
00174 
00175     QString enc = fConfigWidget.fPilotEncoding->currentText();
00176     if (enc.isEmpty())
00177     {
00178         WARNINGKPILOT << "Empty encoding. Will ignore it.";
00179     }
00180     else
00181     {
00182         KPilotSettings::setEncoding(enc);
00183     }
00184 }
00185 
00186 
00187 void DeviceConfigPage::autoDetectDevice()
00188 {
00189     FUNCTIONSETUP;
00190     ProbeDialog *d = new ProbeDialog( fWidget );
00191     d->show();
00192     d->exec();
00193     if (d->detected())
00194     {
00195         fConfigWidget.fUserName->setText( d->userName() );
00196         fConfigWidget.fPilotDevice->setText( d->device() );
00197     }
00198 }
00199 
00200 
00201 SyncConfigPage::SyncConfigPage(QWidget * w, QVariantList &args)
00202     : ConfigPage( w, args )
00203 {
00204     FUNCTIONSETUP;
00205 
00206     fConfigWidget = new SyncConfigWidget( w );
00207     fConfigWidget->resize(fConfigWidget->size());
00208     fWidget = fConfigWidget;
00209 
00210 #define CM(a,b) connect(fConfigWidget->a,b,this,SLOT(modified()));
00211     CM(fSpecialSync, SIGNAL(activated(int)));
00212     CM(fFullSyncCheck, SIGNAL(toggled(bool)));
00213     CM(fScreenlockSecure, SIGNAL(toggled(bool)));
00214     CM(fConflictResolution, SIGNAL(activated(int)));
00215 #undef CM
00216 
00217     fConduitName = i18n("HotSync");
00218 }
00219 
00220 #define MENU_ITEM_COUNT (4)
00221 static SyncAction::SyncMode::Mode syncTypeMap[MENU_ITEM_COUNT] = {
00222     SyncAction::SyncMode::eHotSync,
00223     SyncAction::SyncMode::eFullSync,
00224     SyncAction::SyncMode::eCopyPCToHH,
00225     SyncAction::SyncMode::eCopyHHToPC
00226     } ;
00227 
00228 void SyncConfigPage::load()
00229 {
00230     FUNCTIONSETUP;
00231     KPilotSettings::self()->readConfig();
00232 
00233     /* Sync tab */
00234     int synctype=KPilotSettings::syncType();
00235     if (synctype<0) synctype=(int) SyncAction::SyncMode::eHotSync;
00236     for (unsigned int i=0; i<MENU_ITEM_COUNT; ++i)
00237     {
00238         if (syncTypeMap[i] == synctype)
00239         {
00240             fConfigWidget->fSpecialSync->setCurrentIndex(i);
00241             synctype=-1;
00242             break;
00243         }
00244     }
00245     if (synctype != -1)
00246     {
00247         fConfigWidget->fSpecialSync->setCurrentIndex(0); /* HotSync */
00248     }
00249 
00250     fConfigWidget->fFullSyncCheck->setChecked(KPilotSettings::fullSyncOnPCChange());
00251     fConfigWidget->fConflictResolution->setCurrentIndex(KPilotSettings::conflictResolution());
00252     fConfigWidget->fScreenlockSecure->setChecked(KPilotSettings::screenlockSecure());
00253 
00254     unmodified();
00255 }
00256 
00257 /* virtual */ void SyncConfigPage::commit()
00258 {
00259     FUNCTIONSETUP;
00260 
00261     /* Sync tab */
00262     int synctype = -1;
00263     unsigned int selectedsync = fConfigWidget->fSpecialSync->currentIndex();
00264     if (selectedsync < MENU_ITEM_COUNT)
00265     {
00266         synctype = syncTypeMap[selectedsync];
00267     }
00268     if (synctype < 0)
00269     {
00270         synctype = SyncAction::SyncMode::eHotSync;
00271     }
00272 
00273     KPilotSettings::setSyncType(synctype);
00274     KPilotSettings::setFullSyncOnPCChange(fConfigWidget->fFullSyncCheck->isChecked());
00275     KPilotSettings::setConflictResolution(fConfigWidget->fConflictResolution->currentIndex());
00276     KPilotSettings::setScreenlockSecure(fConfigWidget->fScreenlockSecure->isChecked());
00277 
00278     KPilotConfig::updateConfigVersion();
00279     KPilotSettings::self()->writeConfig();
00280     unmodified();
00281 }
00282 
00283 
00284 BackupConfigPage::BackupConfigPage(QWidget * w, QVariantList &args )
00285     : ConfigPage( w, args )
00286 {
00287     FUNCTIONSETUP;
00288 
00289     fWidget = new QWidget(w);
00290     fConfigWidget.setupUi(fWidget);
00291 
00292     connect(fConfigWidget.fBackupOnlyChooser, SIGNAL( clicked() ),
00293         SLOT( slotSelectNoBackupDBs() ) );
00294     connect(fConfigWidget.fSkipDBChooser, SIGNAL(clicked()),
00295         SLOT(slotSelectNoRestoreDBs()));
00296 
00297 #define CM(a,b) connect(fConfigWidget.a,b,this,SLOT(modified()));
00298     CM(fBackupOnly, SIGNAL(textChanged(const QString &)));
00299     CM(fSkipDB, SIGNAL(textChanged(const QString &)));
00300     CM(fBackupFrequency, SIGNAL(activated(int)));
00301 #undef CM
00302 
00303     fConduitName = i18n("Backup");
00304 }
00305 
00306 void BackupConfigPage::load()
00307 {
00308     FUNCTIONSETUP;
00309     KPilotSettings::self()->readConfig();
00310 
00311     /* Backup tab */
00312     fConfigWidget.fBackupOnly->setText(KPilotSettings::skipBackupDB().join(CSL1(",")));
00313     fConfigWidget.fSkipDB->setText(KPilotSettings::skipRestoreDB().join(CSL1(",")));
00314     fConfigWidget.fRunConduitsWithBackup->setChecked(
00315         KPilotSettings::runConduitsWithBackup());
00316 
00317     int backupfreq = KPilotSettings::backupFrequency();
00318 
00319     fConfigWidget.fBackupFrequency->setCurrentIndex(backupfreq);
00320 
00321     unmodified();
00322 }
00323 
00324 /* virtual */ void BackupConfigPage::commit()
00325 {
00326     FUNCTIONSETUP;
00327 
00328     /* Backup tab */
00329     KPilotSettings::setSkipBackupDB(
00330         fConfigWidget.fBackupOnly->text().split( ',' ) );
00331     KPilotSettings::setSkipRestoreDB(
00332         fConfigWidget.fSkipDB->text().split( ',' ) );
00333     KPilotSettings::setRunConduitsWithBackup(
00334         fConfigWidget.fRunConduitsWithBackup->isChecked());
00335     KPilotSettings::setBackupFrequency(
00336         fConfigWidget.fBackupFrequency->currentIndex());
00337 
00338     KPilotConfig::updateConfigVersion();
00339     KPilotSettings::self()->writeConfig();
00340     unmodified();
00341 }
00342 
00343 void BackupConfigPage::slotSelectNoBackupDBs()
00344 {
00345     FUNCTIONSETUP;
00346 
00347     QStringList selectedDBs(fConfigWidget.fBackupOnly->text().split(','));
00348 
00349     QStringList deviceDBs = KPilotSettings::deviceDBs();
00350     QStringList addedDBs = KPilotSettings::addedDBs();
00351     KPilotDBSelectionDialog *dlg = new KPilotDBSelectionDialog(selectedDBs
00352         , deviceDBs, addedDBs, 0, "NoBackupDBs");
00353     if (dlg && (dlg->exec() == QDialog::Accepted) )
00354     {
00355         fConfigWidget.fBackupOnly->setText(
00356             dlg->getSelectedDBs().join(CSL1(",")));
00357         KPilotSettings::setAddedDBs( dlg->getAddedDBs() );
00358     }
00359     KPILOT_DELETE(dlg);
00360 }
00361 
00362 void BackupConfigPage::slotSelectNoRestoreDBs()
00363 {
00364     FUNCTIONSETUP;
00365 
00366     QStringList selectedDBs(fConfigWidget.fSkipDB->text().split(','));
00367 
00368     QStringList deviceDBs = KPilotSettings::deviceDBs();
00369     QStringList addedDBs = KPilotSettings::addedDBs();
00370     KPilotDBSelectionDialog *dlg = new KPilotDBSelectionDialog(selectedDBs
00371         , deviceDBs, addedDBs, 0, "NoRestoreDBs");
00372     
00373     if (dlg && (dlg->exec() == QDialog::Accepted) )
00374     {
00375         fConfigWidget.fSkipDB->setText(
00376             dlg->getSelectedDBs().join(CSL1(",")));
00377         KPilotSettings::setAddedDBs( dlg->getAddedDBs() );
00378     }
00379     KPILOT_DELETE(dlg);
00380 }
00381 
00382 
00383 
00384 
00385 
00386 
00387 
00388 
00389 
00390 StartExitConfigPage::StartExitConfigPage(QWidget * w, QVariantList &args )
00391     : ConfigPage( w, args )
00392 {
00393     FUNCTIONSETUP;
00394 
00395     fWidget = new QWidget(w);
00396     fConfigWidget.setupUi(fWidget);
00397 
00398 #define CM(a,b) connect(fConfigWidget.a,b,this,SLOT(modified()));
00399     CM(fStartDaemonAtLogin, SIGNAL(toggled(bool)));
00400     CM(fKillDaemonOnExit, SIGNAL(toggled(bool)));
00401     CM(fDockDaemon, SIGNAL(toggled(bool)));
00402     CM(fQuitAfterSync, SIGNAL(toggled(bool)));
00403 #undef CM
00404 
00405     fConduitName = i18n("Startup and Exit");
00406 }
00407 
00408 void StartExitConfigPage::load()
00409 {
00410     FUNCTIONSETUP;
00411     KPilotSettings::self()->readConfig();
00412 
00413     fConfigWidget.fStartDaemonAtLogin->setChecked(KPilotSettings::startDaemonAtLogin());
00414     fConfigWidget.fDockDaemon->setChecked(KPilotSettings::dockDaemon());
00415     fConfigWidget.fKillDaemonOnExit->setChecked(KPilotSettings::killDaemonAtExit());
00416     fConfigWidget.fQuitAfterSync->setChecked(KPilotSettings::quitAfterSync());
00417     unmodified();
00418 }
00419 
00420 
00421 /* virtual */ void StartExitConfigPage::commit()
00422 {
00423     FUNCTIONSETUP;
00424 
00425     KPilotSettings::setStartDaemonAtLogin(fConfigWidget.fStartDaemonAtLogin->isChecked());
00426     KAutostart autostart( CSL1("KPilotDaemon") );
00427     autostart.setAutostarts( KPilotSettings::startDaemonAtLogin() );
00428     autostart.setStartPhase( KAutostart::Applications );
00429 
00430     KPilotSettings::setDockDaemon(fConfigWidget.fDockDaemon->isChecked());
00431     KPilotSettings::setKillDaemonAtExit(fConfigWidget.fKillDaemonOnExit->isChecked());
00432     KPilotSettings::setQuitAfterSync(fConfigWidget.fQuitAfterSync->isChecked());
00433     KPilotConfig::updateConfigVersion();
00434     KPilotSettings::self()->writeConfig();
00435     unmodified();
00436 }
00437 

kpilot

Skip menu "kpilot"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdepim

Skip menu "kdepim"
  • akonadi
  •   clients
  •   kabc
  •   kcal
  •   kcm
  • akregator
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt
  • kdgantt1
  • kjots
  • kleopatra
  • kmail
  • kmobiletools
  • knode
  • knotes
  • kontact
  • kontactinterfaces
  • korganizer
  •   korgac
  • kpilot
  • ktimetracker
  •   doc
  • libkdepim
  • libkholidays
  • libkleo
  • libkpgp
  • maildir
Generated for kdepim by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal