kpilot Library API Documentation

todo-setup.cc

00001 /* todo-setup.cc                        KPilot
00002 **
00003 ** Copyright (C) 2001 by Dan Pilone
00004 **
00005 ** This file defines the factory for the todo-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 <qpushbutton.h>
00032 #include <qtabwidget.h>
00033 #include <qlineedit.h>
00034 #include <qcheckbox.h>
00035 #include <qbuttongroup.h>
00036 
00037 #include <kconfig.h>
00038 #include <kinstance.h>
00039 #include <kaboutdata.h>
00040 #include <kfiledialog.h>
00041 
00042 #include "korganizertodoConduit.h"
00043 #include "todo-factory.h"
00044 #include "todo-setup.moc"
00045 
00046 
00047 
00048 ToDoWidgetSetup::ToDoWidgetSetup(QWidget *w, const char *n,
00049         const QStringList & a) :
00050         ConduitConfig(w,n,a)
00051 {
00052         FUNCTIONSETUP;
00053 
00054         fConfigWidget = new ToDoWidget(widget());
00055         setTabWidget(fConfigWidget->tabWidget);
00056         addAboutPage(false,ToDoConduitFactory::about());
00057 
00058         fConfigWidget->tabWidget->adjustSize();
00059         fConfigWidget->resize(fConfigWidget->tabWidget->size());
00060 
00061         // This is a little hack to force the config dialog to the
00062         // correct size, since the designer dialog is so small.
00063         //
00064         //
00065 //      QSize s = fConfigWidget->size() + QSize(SPACING,SPACING);
00066 //      fConfigWidget->resize(s);
00067 //      fConfigWidget->setMinimumSize(s);
00068 
00069         QObject::connect(fConfigWidget->fCalBrowse,SIGNAL(clicked()),
00070                 this,SLOT(slotBrowseCalendar()));
00071 }
00072 
00073 ToDoWidgetSetup::~ToDoWidgetSetup()
00074 {
00075         FUNCTIONSETUP;
00076 }
00077 
00078 /* virtual */ void ToDoWidgetSetup::commitChanges()
00079 {
00080         FUNCTIONSETUP;
00081 
00082         if (!fConfig) return;
00083 
00084         KConfigGroupSaver s(fConfig, ToDoConduitFactory::group);
00085 
00086         fConfig->writeEntry(VCalConduitFactoryBase::calendarFile, fConfigWidget->fCalendarFile->text());
00087         fConfig->writeEntry(VCalConduitFactoryBase::archive, fConfigWidget->fArchive->isChecked());
00088         fConfig->writeEntry(VCalConduitFactoryBase::conflictResolution,
00089                 fConfigWidget->conflictResolution->id(fConfigWidget->conflictResolution->selected()));
00090 
00091         int act=fConfigWidget->syncAction->id(fConfigWidget->syncAction->selected())+1;
00092         if (act>SYNC_MAX)
00093         {
00094                 fConfig->writeEntry(VCalConduitFactoryBase::nextSyncAction, act-SYNC_MAX);
00095         }
00096         else
00097         {
00098                 fConfig->writeEntry(VCalConduitFactoryBase::nextSyncAction, 0);
00099                 fConfig->writeEntry(VCalConduitFactoryBase::syncAction, act);
00100         }
00101 }
00102 
00103 /* virtual */ void ToDoWidgetSetup::readSettings()
00104 {
00105         FUNCTIONSETUP;
00106 
00107         if (!fConfig) return;
00108 
00109         KConfigGroupSaver s(fConfig,ToDoConduitFactory::group);
00110 
00111         fConfigWidget->fCalendarFile->setText( fConfig->readEntry(VCalConduitFactoryBase::calendarFile,QString::null));
00112         fConfigWidget->fArchive->setChecked( fConfig->readBoolEntry(VCalConduitFactoryBase::archive, true));
00113         fConfigWidget->conflictResolution->setButton( fConfig->readNumEntry(VCalConduitFactoryBase::conflictResolution, RES_ASK));
00114 
00115         int nextAction=fConfig->readNumEntry(VCalConduitFactoryBase::nextSyncAction, 0);
00116         if (nextAction)
00117         {
00118                 fConfigWidget->syncAction->setButton( SYNC_MAX+nextAction-1);
00119         }
00120         else
00121         {
00122                 fConfigWidget->syncAction->setButton( fConfig->readNumEntry(VCalConduitFactoryBase::syncAction, SYNC_FAST)-1);
00123         }
00124 
00125 }
00126 
00127 void ToDoWidgetSetup::slotBrowseCalendar()
00128 {
00129         FUNCTIONSETUP;
00130 
00131         QString fileName = KFileDialog::getOpenFileName(CSL1("::calendar"), CSL1("*.vcs *ics|ICalendars"),this);
00132         if(fileName.isNull()) return;
00133         fConfigWidget->fCalendarFile->setText(fileName);
00134 }
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