kpilot

memofile-factory.cc

Go to the documentation of this file.
00001 /* memofile-factory.cc                      KPilot
00002 **
00003 ** Copyright (C) 2004-2007 by Jason 'vanRijn' Kasper
00004 **
00005 ** This file defines the factory for the memofile-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 Lesser General Public License as published by
00011 ** the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
00018 **
00019 ** You should have received a copy of the GNU Lesser General Public License
00020 ** along with this program in a file called COPYING; if not, write to
00021 ** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
00022 ** MA 02110-1301, 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 
00035 #include <kconfig.h>
00036 #include <kinstance.h>
00037 #include <kaboutdata.h>
00038 #include <kurlrequester.h>
00039 
00040 #include "setup_base.h"
00041 #include "memofile-conduit.h"
00042 #include "memofileSettings.h"
00043 
00044 #include "pluginfactory.h"
00045 
00046 class MemofileConduitConfig : public ConduitConfigBase
00047 {
00048 public:
00049     MemofileConduitConfig(QWidget *parent=0L, const char *n=0L);
00050     virtual void commit();
00051     virtual void load();
00052 protected:
00053     MemofileWidget *fConfigWidget;
00054 } ;
00055 
00056 MemofileConduitConfig::MemofileConduitConfig(QWidget *p, const char *n) :
00057     ConduitConfigBase(p,n),
00058     fConfigWidget(new MemofileWidget(p))
00059 {
00060     FUNCTIONSETUP;
00061     fConduitName = i18n("Memofile");
00062     KAboutData *about = new KAboutData("MemofileConduit",
00063         I18N_NOOP("Memofile Conduit for KPilot"),
00064         KPILOT_VERSION,
00065         I18N_NOOP("Configures the Memofile Conduit for KPilot"),
00066         KAboutData::License_GPL,
00067         "(C) 2004, Jason 'vanRijn' Kasper");
00068     about->addAuthor("Jason 'vanRijn' Kasper",
00069         I18N_NOOP("Primary Author"),
00070         "vR@movingparts.net",
00071         "http://www.cs.kun.nl/~adridg/kpilot");
00072 
00073     ConduitConfigBase::addAboutPage(fConfigWidget->tabWidget,about);
00074     fWidget=fConfigWidget;
00075     QObject::connect(fConfigWidget->fDirectory,SIGNAL(textChanged(const QString&)),
00076         this,SLOT(modified()));
00077     QObject::connect(fConfigWidget->fSyncPrivate,SIGNAL(toggled(bool)),
00078                      this,SLOT(modified()));
00079     
00080 }
00081 
00082 /* virtual */ void MemofileConduitConfig::commit()
00083 {
00084     FUNCTIONSETUP;
00085 
00086     DEBUGKPILOT << fname
00087         << ": Directory="
00088         << fConfigWidget->fDirectory->url()
00089         << endl;
00090 
00091     MemofileConduitSettings::setDirectory( fConfigWidget->fDirectory->url() );
00092     MemofileConduitSettings::setSyncPrivate( fConfigWidget->fSyncPrivate->isChecked() );
00093     MemofileConduitSettings::self()->writeConfig();
00094     unmodified();
00095 }
00096 
00097 /* virtual */ void MemofileConduitConfig::load()
00098 {
00099     FUNCTIONSETUP;
00100     MemofileConduitSettings::self()->readConfig();
00101 
00102     fConfigWidget->fDirectory->setURL( MemofileConduitSettings::directory() );
00103     fConfigWidget->fSyncPrivate->setChecked( MemofileConduitSettings::syncPrivate() );
00104 
00105     DEBUGKPILOT << fname
00106         << ": Read Directory: ["
00107         << fConfigWidget->fDirectory->url()
00108         << "], sync private records: ["
00109         << fConfigWidget->fSyncPrivate
00110         << "]" << endl;
00111 
00112     unmodified();
00113 }
00114 
00115 
00116 
00117 extern "C"
00118 {
00119 
00120 void *init_conduit_memofile()
00121 {
00122     return new ConduitFactory<MemofileConduitConfig,MemofileConduit>(0,"memofileconduit");
00123 }
00124 
00125 unsigned long version_conduit_memofile = Pilot::PLUGIN_API;
00126 
00127 }
00128