kpilot

abbrowser-setup.cc

Go to the documentation of this file.
00001 /* KPilot
00002 **
00003 ** Copyright (C) 2001 by Dan Pilone
00004 ** Copyright (C) 2002-2003 Reinhold Kainhofer
00005 **
00006 ** This file defines the setup dialog for the abbrowser-conduit plugin.
00007 */
00008 
00009 /*
00010 ** This program is free software; you can redistribute it and/or modify
00011 ** it under the terms of the GNU General Public License as published by
00012 ** the Free Software Foundation; either version 2 of the License, or
00013 ** (at your option) any later version.
00014 **
00015 ** This program is distributed in the hope that it will be useful,
00016 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00018 ** GNU General Public License for more details.
00019 **
00020 ** You should have received a copy of the GNU General Public License
00021 ** along with this program in a file called COPYING; if not, write to
00022 ** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
00023 ** MA 02110-1301, USA.
00024 */
00025 
00026 /*
00027 ** Bug reports and questions can be sent to kde-pim@kde.org
00028 */
00029 
00030 #include "options.h"
00031 
00032 #include <qcheckbox.h>
00033 #include <qcombobox.h>
00034 #include <qbuttongroup.h>
00035 
00036 #include <kurlrequester.h>
00037 #include <kaboutdata.h>
00038 
00039 #include "kaddressbookConduit.h"
00040 #include "abbrowser-setup.h"
00041 #include "abbrowserSettings.h"
00042 
00043 
00044 
00045 static KAboutData *createAbout()
00046 {
00047     KAboutData *fAbout = new KAboutData("abbrowserconduit",
00048         I18N_NOOP("Abbrowser Conduit for KPilot"),
00049         KPILOT_VERSION,
00050         I18N_NOOP("Configures the Abbrowser Conduit for KPilot"),
00051         KAboutData::License_GPL,
00052         "(C) 2001, Dan Pilone\n(C) 2002-2003, Reinhold Kainhofer");
00053     fAbout->addAuthor("Greg Stern",
00054         I18N_NOOP("Primary Author"));
00055     fAbout->addAuthor("Adriaan de Groot",
00056         I18N_NOOP("Maintainer"),
00057         "groot@kde.org",
00058         "http://www.cs.kun.nl/~adridg/kpilot");
00059     fAbout->addAuthor("Reinhold Kainhofer", I18N_NOOP("Maintainer"),
00060         "reinhold@kainhofer.com", "http://reinhold.kainhofer.com");
00061     fAbout->addCredit("David Bishop", I18N_NOOP("UI"));
00062     return fAbout;
00063 }
00064 
00065 AbbrowserWidgetSetup::AbbrowserWidgetSetup(QWidget *w, const char *n) :
00066     ConduitConfigBase(w,n),
00067     fConfigWidget(new AbbrowserWidget(w))
00068 {
00069     FUNCTIONSETUP;
00070 
00071     fConduitName=i18n("Addressbook");
00072     fAbout = createAbout();
00073     ConduitConfigBase::addAboutPage(fConfigWidget->tabWidget,fAbout);
00074     fWidget=fConfigWidget;
00075     fConfigWidget->fAbookFile->setMode(KFile::File);
00076 #define CM(a,b) connect(fConfigWidget->a,b,this,SLOT(modified()));
00077     CM(fSyncDestination,SIGNAL(clicked(int)));
00078     CM(fAbookFile,SIGNAL(textChanged(const QString &)));
00079     CM(fArchive,SIGNAL(toggled(bool)));
00080     CM(fConflictResolution,SIGNAL(activated(int)));
00081     CM(fOtherPhone,SIGNAL(activated(int)));
00082     CM(fAddress,SIGNAL(activated(int)));
00083     CM(fFax,SIGNAL(activated(int)));
00084     CM(fCustom0,SIGNAL(activated(int)));
00085     CM(fCustom1,SIGNAL(activated(int)));
00086     CM(fCustom2,SIGNAL(activated(int)));
00087     CM(fCustom3,SIGNAL(activated(int)));
00088     CM(fCustomDate, SIGNAL(activated(int)));
00089     CM(fCustomDate, SIGNAL(textChanged(const QString&)));
00090 #undef CM
00091 }
00092 
00093 AbbrowserWidgetSetup::~AbbrowserWidgetSetup()
00094 {
00095     FUNCTIONSETUP;
00096 }
00097 
00098 /* virtual */ void AbbrowserWidgetSetup::commit()
00099 {
00100     FUNCTIONSETUP;
00101 
00102     QButtonGroup*grp=fConfigWidget->fSyncDestination;
00103     AbbrowserSettings::setAddressbookType(grp->id(grp->selected()));
00104     AbbrowserSettings::setFileName(fConfigWidget->fAbookFile->url());
00105     AbbrowserSettings::setArchiveDeleted(fConfigWidget->fArchive->isChecked());
00106 
00107     // Conflicts page
00108     AbbrowserSettings::setConflictResolution(
00109         fConfigWidget->fConflictResolution->currentItem()+SyncAction::eCROffset);
00110 
00111     // Fields page
00112     AbbrowserSettings::setPilotOther(fConfigWidget->fOtherPhone->currentItem());
00113     AbbrowserSettings::setPilotStreet(fConfigWidget->fAddress->currentItem());
00114     AbbrowserSettings::setPilotFax(fConfigWidget->fFax->currentItem());
00115 
00116     // Custom fields page
00117     AbbrowserSettings::setCustom0(fConfigWidget->fCustom0->currentItem());
00118     AbbrowserSettings::setCustom1(fConfigWidget->fCustom1->currentItem());
00119     AbbrowserSettings::setCustom2(fConfigWidget->fCustom2->currentItem());
00120     AbbrowserSettings::setCustom3(fConfigWidget->fCustom3->currentItem());
00121 #ifdef DEBUG
00122     DEBUGKPILOT <<fname<<
00123       "Custom0: "<<fConfigWidget->fCustom0->currentItem()<<"   "<<
00124       "Custom1: "<<fConfigWidget->fCustom1->currentItem()<<"   "<<
00125       "Custom2: "<<fConfigWidget->fCustom2->currentItem()<<"   "<<
00126       "Custom3: "<<fConfigWidget->fCustom3->currentItem()<<"   "
00127         << " eCustom[0]=" << AbbrowserSettings::custom0()<<"    "
00128         << " eCustom[1]=" << AbbrowserSettings::custom1()<<"    "
00129         << " eCustom[2]=" << AbbrowserSettings::custom2()<<"    "
00130         << " eCustom[3]=" << AbbrowserSettings::custom3()<<"    "<<
00131         endl;
00132 #endif
00133     int fmtindex=fConfigWidget->fCustomDate->currentItem();
00134     AbbrowserSettings::setCustomDateFormat(
00135       (fmtindex==0)?(QString::null):fConfigWidget->fCustomDate->currentText() );
00136 
00137     AbbrowserSettings::self()->writeConfig();
00138     unmodified();
00139 }
00140 
00141 /* virtual */ void AbbrowserWidgetSetup::load()
00142 {
00143     FUNCTIONSETUP;
00144     AbbrowserSettings::self()->readConfig();
00145 
00146 #ifdef DEBUG
00147     DEBUGKPILOT << fname
00148         << ": Settings "
00149         << " fPilotStreetHome=" << AbbrowserSettings::pilotStreet()
00150         << " fPilotFaxHome=" << AbbrowserSettings::pilotFax()
00151         << " fArchive=" << AbbrowserSettings::archiveDeleted()
00152         << " eCustom[0]=" << AbbrowserSettings::custom0()
00153         << " eCustom[1]=" << AbbrowserSettings::custom1()
00154         << " eCustom[2]=" << AbbrowserSettings::custom2()
00155         << " eCustom[3]=" << AbbrowserSettings::custom3()
00156         << endl;
00157 #endif
00158 
00159     // General page
00160     fConfigWidget->fSyncDestination->setButton(AbbrowserSettings::addressbookType());
00161     fConfigWidget->fAbookFile->setURL(AbbrowserSettings::fileName());
00162     fConfigWidget->fArchive->setChecked(AbbrowserSettings::archiveDeleted());
00163 
00164     // Conflicts page
00165     fConfigWidget->fConflictResolution->setCurrentItem(
00166       AbbrowserSettings::conflictResolution() - SyncAction::eCROffset );
00167 
00168     // Fields page
00169     fConfigWidget->fOtherPhone->setCurrentItem(AbbrowserSettings::pilotOther());
00170     fConfigWidget->fAddress->setCurrentItem(AbbrowserSettings::pilotStreet());
00171     fConfigWidget->fFax->setCurrentItem(AbbrowserSettings::pilotFax());
00172 
00173     // Custom fields page
00174     fConfigWidget->fCustom0->setCurrentItem(AbbrowserSettings::custom0());
00175     fConfigWidget->fCustom1->setCurrentItem(AbbrowserSettings::custom1());
00176     fConfigWidget->fCustom2->setCurrentItem(AbbrowserSettings::custom2());
00177     fConfigWidget->fCustom3->setCurrentItem(AbbrowserSettings::custom3());
00178     QString datefmt=AbbrowserSettings::customDateFormat();
00179     if (datefmt.isEmpty())
00180     {
00181         fConfigWidget->fCustomDate->setCurrentItem(0);
00182     }
00183     else
00184     {
00185         fConfigWidget->fCustomDate->setCurrentText(datefmt);
00186     }
00187 
00188     unmodified();
00189 }
00190 
00191 /* static */ ConduitConfigBase *AbbrowserWidgetSetup::create(QWidget *w, const char *n)
00192 {
00193     return new AbbrowserWidgetSetup(w,n);
00194 }
00195