kpilot Library API Documentation

kpilotConfigDialog.cc

00001 /* kpilotConfigDialog.cc                KPilot
00002 **
00003 ** Copyright (C) 2001 by Dan Pilone
00004 **
00005 ** This file defines a specialization of KPilotDeviceLink
00006 ** that can actually handle some HotSync tasks, like backup
00007 ** and restore. It does NOT do conduit stuff.
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., 59 Temple Place, Suite 330, Boston,
00024 ** MA 02111-1307, USA.
00025 */
00026 
00027 /*
00028 ** Bug reports and questions can be sent to kde-pim@kde.org
00029 */
00030 
00031 static const char *kpilotconfigdialog_id = 
00032         "$Id: kpilotConfigDialog.cc,v 1.7.4.2 2003/03/12 23:31:14 adridg Exp $";
00033 
00034 #include "options.h"
00035 
00036 #include <pi-version.h>
00037 
00038 #include <qcombobox.h>
00039 #include <qcheckbox.h>
00040 #include <qradiobutton.h>
00041 #include <qlineedit.h>
00042 #include <qtabwidget.h>
00043 
00044 #include <kmessagebox.h>
00045 
00046 #include "kpilotConfig.h"
00047 
00048 #include "kpilotConfigDialog_base.h"
00049 #include "kpilotConfigDialog.moc"
00050 
00051 KPilotConfigDialog::KPilotConfigDialog(QWidget * w, const char *n,
00052         bool m) : UIDialog(w, n, m)
00053 {
00054         FUNCTIONSETUP;
00055 
00056         fConfigWidget = new KPilotConfigWidget(widget());
00057         fConfigWidget->tabWidget->adjustSize();
00058         fConfigWidget->resize(fConfigWidget->tabWidget->size());
00059         setTabWidget(fConfigWidget->tabWidget);
00060 
00061 #if defined(PILOT_LINK_VERSION) && defined(PILOT_LINK_MAJOR) && defined(PILOT_LINK_MINOR)
00062 #if (PILOT_LINK_VERSION * 100 + PILOT_LINK_MAJOR * 10 + PILOT_LINK_MINOR) < 100
00063         fConfigWidget->fPilotDevice->setMaxLength(13);
00064 #endif
00065 #endif
00066 
00067         disableUnusedOptions();
00068         readConfig();
00069 
00070 
00071         addAboutPage(false);
00072 
00073         (void) kpilotconfigdialog_id;
00074 }
00075 
00076 KPilotConfigDialog::~KPilotConfigDialog()
00077 {
00078         FUNCTIONSETUP;
00079 }
00080 
00081 void KPilotConfigDialog::disableUnusedOptions()
00082 {
00083         FUNCTIONSETUP;
00084 
00085         fConfigWidget->fOverwriteRemote->setEnabled(false);
00086         fConfigWidget->fForceFirstTime->setEnabled(false);
00087         fConfigWidget->fFullBackupCheck->setEnabled(false);
00088         fConfigWidget->fPreferFastSync->setEnabled(false);
00089 }
00090 
00091 void KPilotConfigDialog::readConfig()
00092 {
00093         FUNCTIONSETUP;
00094 
00095         KPilotConfigSettings & c = KPilotConfig::getConfig();
00096         c.resetGroup();
00097 
00098         (void) c.getPilotDevice(fConfigWidget->fPilotDevice);
00099         (void) c.getPilotSpeed(fConfigWidget->fPilotSpeed);
00100         (void) c.getUser(fConfigWidget->fUserName);
00101         (void) c.getStartDaemonAtLogin(fConfigWidget->fStartDaemonAtLogin);
00102         (void) c.getKillDaemonOnExit(fConfigWidget->fKillDaemonOnExit);
00103         (void) c.getDockDaemon(fConfigWidget->fDockDaemon);
00104 
00105         (void) c.getShowSecrets(fConfigWidget->fUseSecret);
00106         (void) c.getBackupOnly(fConfigWidget->fBackupOnly);
00107         (void) c.getSkip(fConfigWidget->fSkipDB);
00108 
00109         (void) c.getSyncFiles(fConfigWidget->fSyncFiles);
00110 
00111         c.setAddressGroup();
00112         (void) c.getUseKeyField(fConfigWidget->fUseKeyField);
00113         setAddressDisplay(c.getAddressDisplayMode());
00114 
00115         c.resetGroup();
00116 }
00117 
00118 /* virtual */ bool KPilotConfigDialog::validate()
00119 {
00120         int r = KMessageBox::Yes;
00121 
00122 #if defined(PILOT_LINK_VERSION) && defined(PILOT_LINK_MAJOR) && defined(PILOT_LINK_MINOR)
00123 #if (PILOT_LINK_VERSION * 100 + PILOT_LINK_MAJOR * 10 + PILOT_LINK_MINOR) < 100
00124         QString d = fConfigWidget->fPilotDevice->text();
00125 
00126         if (d.length() > 13)
00127         {
00128         r = KMessageBox::questionYesNo(
00129                 this,
00130                 i18n("<qt>The device name you entered (<i>%1</i>) "
00131                         "is longer than 13 characters. This is "
00132                         "probably unsupported and can cause problems. "
00133                         "Are you sure you want to use this device name?</qt>")
00134                         .arg(d),
00135                 i18n("Device Name too Long")
00136                 ) ;
00137         }
00138 #endif
00139 #endif
00140 
00141         return KMessageBox::Yes == r;
00142 }
00143 
00144 /* virtual */ void KPilotConfigDialog::commitChanges()
00145 {
00146         FUNCTIONSETUP;
00147 
00148         KPilotConfigSettings & c = KPilotConfig::getConfig();
00149         c.resetGroup();
00150 
00151         // General page
00152         c.setPilotDevice(fConfigWidget->fPilotDevice);
00153         c.setPilotSpeed(fConfigWidget->fPilotSpeed);
00154         c.setUser(fConfigWidget->fUserName);
00155         c.setStartDaemonAtLogin(fConfigWidget->fStartDaemonAtLogin);
00156         c.setKillDaemonOnExit(fConfigWidget->fKillDaemonOnExit);
00157         c.setDockDaemon(fConfigWidget->fDockDaemon);
00158 
00159         // DB specials page
00160         c.setShowSecrets(fConfigWidget->fUseSecret);
00161         c.setBackupOnly(fConfigWidget->fBackupOnly);
00162         c.setSkip(fConfigWidget->fSkipDB);
00163 
00164         // Sync page
00165         c.setSyncFiles(fConfigWidget->fSyncFiles);
00166 
00167         // Address page
00168         c.setAddressGroup();
00169         c.setUseKeyField(fConfigWidget->fUseKeyField);
00170         c.setAddressDisplayMode(getAddressDisplay());
00171         c.resetGroup();
00172 
00173         KPilotConfig::updateConfigVersion();
00174 
00175         c.sync();
00176 }
00177 
00178 int KPilotConfigDialog::getAddressDisplay() const
00179 {
00180         FUNCTIONSETUP;
00181 
00182         if (fConfigWidget->fNormalDisplay->isChecked())
00183                 return 0;
00184         if (fConfigWidget->fCompanyDisplay->isChecked())
00185                 return 1;
00186 
00187         return 0;
00188 }
00189 
00190 void KPilotConfigDialog::setAddressDisplay(int i)
00191 {
00192         FUNCTIONSETUP;
00193 
00194         switch (i)
00195         {
00196         case 0:
00197                 fConfigWidget->fNormalDisplay->setChecked(true);
00198                 break;
00199         case 1:
00200                 fConfigWidget->fCompanyDisplay->setChecked(true);
00201                 break;
00202         default:
00203                 fConfigWidget->fNormalDisplay->setChecked(true);
00204                 break;
00205         }
00206 }
00207 
00208 
00209 /* slot */ void KPilotConfigDialog::changePortType(int i)
00210 {
00211         FUNCTIONSETUP;
00212 
00213         switch (i)
00214         {
00215         case 0:
00216                 fConfigWidget->fPilotSpeed->setEnabled(true);
00217                 break;
00218         case 1:
00219         case 2:
00220                 fConfigWidget->fPilotSpeed->setEnabled(false);
00221                 break;
00222         default:
00223                 kdWarning() << k_funcinfo
00224                         << ": Unknown port type " << i << endl;
00225         }
00226 }
00227 
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Sun Feb 15 11:40:43 2004 by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2001