kpilot Library API Documentation

vcal-setup.cc

00001 /* vcal-setup.cc                        KPilot
00002 **
00003 ** Copyright (C) 2001 by Dan Pilone
00004 **
00005 ** This file defines the setup dialog for the vcal-conduit plugin.
00006 */
00007 
00008 /*
00009 ** This program is free software; you can redistribute it and/or modify
00010 ** it under the terms of the GNU General Public License as published by
00011 ** the Free Software Foundation; either version 2 of the License, or
00012 ** (at your option) any later version.
00013 **
00014 ** This program is distributed in the hope that it will be useful,
00015 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00017 ** GNU General Public License for more details.
00018 **
00019 ** You should have received a copy of the GNU General Public License
00020 ** along with this program in a file called COPYING; if not, write to
00021 ** the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
00022 ** MA 02111-1307, USA.
00023 */
00024 
00025 /*
00026 ** Bug reports and questions can be sent to kde-pim@kde.org
00027 */
00028 
00029 #include "options.h"
00030 
00031 #include <qtabwidget.h>
00032 #include <qlineedit.h>
00033 #include <qcheckbox.h>
00034 #include <qbuttongroup.h>
00035 
00036 #include <kconfig.h>
00037 #include <kfiledialog.h>
00038 
00039 #include "korganizerConduit.h"
00040 #include "vcal-factory.h"
00041 #include "vcal-setup.moc"
00042 
00043 
00044 VCalWidgetSetup::VCalWidgetSetup(QWidget *w, const char *n,
00045         const QStringList & a) :
00046         ConduitConfig(w,n,a)
00047 {
00048         FUNCTIONSETUP;
00049 
00050         fConfigWidget = new VCalWidget(widget());
00051         setTabWidget(fConfigWidget->tabWidget);
00052         addAboutPage(false,VCalConduitFactory::about());
00053 
00054         fConfigWidget->tabWidget->adjustSize();
00055         fConfigWidget->resize(fConfigWidget->tabWidget->size());
00056 
00057         // This is a little hack to force the config dialog to the
00058         // correct size, since the designer dialog is so small.
00059         //
00060         //
00061 //      QSize s = fConfigWidget->size() + QSize(SPACING,SPACING);
00062 //      fConfigWidget->resize(s);
00063 //      fConfigWidget->setMinimumSize(s);
00064 
00065         QObject::connect((QObject*)fConfigWidget->fCalBrowse,SIGNAL(clicked()),
00066                 this,SLOT(slotBrowseCalendar()));
00067 }
00068 
00069 VCalWidgetSetup::~VCalWidgetSetup()
00070 {
00071         FUNCTIONSETUP;
00072 }
00073 
00074 /* virtual */ void VCalWidgetSetup::commitChanges()
00075 {
00076         FUNCTIONSETUP;
00077 
00078         if (!fConfig) return;
00079 
00080         KConfigGroupSaver s(fConfig,VCalConduitFactory::group);
00081 
00082         fConfig->writeEntry(VCalConduitFactoryBase::calendarFile, fConfigWidget->fCalendarFile->text());
00083         fConfig->writeEntry(VCalConduitFactoryBase::archive, fConfigWidget->fArchive->isChecked());
00084         fConfig->writeEntry(VCalConduitFactoryBase::conflictResolution,
00085                 fConfigWidget->conflictResolution->id(fConfigWidget->conflictResolution->selected()));
00086 
00087         int act=fConfigWidget->syncAction->id(fConfigWidget->syncAction->selected())+1;
00088         if (act>SYNC_MAX)
00089         {
00090                 fConfig->writeEntry(VCalConduitFactoryBase::nextSyncAction, act-SYNC_MAX);
00091         }
00092         else
00093         {
00094                 fConfig->writeEntry(VCalConduitFactoryBase::nextSyncAction, 0);
00095                 fConfig->writeEntry(VCalConduitFactoryBase::syncAction, act);
00096         }
00097 }
00098 
00099 /* virtual */ void VCalWidgetSetup::readSettings()
00100 {
00101         FUNCTIONSETUP;
00102 
00103         if (!fConfig) return;
00104 
00105         KConfigGroupSaver s(fConfig,VCalConduitFactory::group);
00106         fConfigWidget->fCalendarFile->setText( fConfig->readEntry(VCalConduitFactoryBase::calendarFile,QString::null));
00107         fConfigWidget->fArchive->setChecked( fConfig->readBoolEntry(VCalConduitFactoryBase::archive, true));
00108         fConfigWidget->conflictResolution->setButton( fConfig->readNumEntry(VCalConduitFactoryBase::conflictResolution, RES_ASK));
00109 
00110         int nextAction=fConfig->readNumEntry(VCalConduitFactoryBase::nextSyncAction, 0);
00111         if (nextAction)
00112         {
00113                 fConfigWidget->syncAction->setButton( SYNC_MAX+nextAction-1);
00114         }
00115         else
00116         {
00117                 fConfigWidget->syncAction->setButton( fConfig->readNumEntry(VCalConduitFactoryBase::syncAction, SYNC_FAST)-1);
00118         }
00119 
00120 }
00121 
00122 void VCalWidgetSetup::slotBrowseCalendar()
00123 {
00124         FUNCTIONSETUP;
00125 
00126         QString fileName = KFileDialog::getOpenFileName(CSL1("::calendar"), CSL1("*.vcs *ics|ICalendars"),this);
00127         if(fileName.isNull()) return;
00128         fConfigWidget->fCalendarFile->setText(fileName);
00129 }
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.4.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Sat Oct 18 02:47:15 2003 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001