kpilot

factory.cc

Go to the documentation of this file.
00001 /* KPilot
00002 **
00003 ** Copyright (C) 2005 by Adriaan de Groot
00004 **
00005 ** This file defines the factory for the recordconduit 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 
00039 #include "pluginfactory.h"
00040 #include "pilotDatabase.h"
00041 #include "recordConduit.h"
00042 
00043 #include "setup_base.h"
00044 #include "factory.h"
00045 #include "settings.h"
00046 
00047 
00048 class ConduitConfig : public ConduitConfigBase
00049 {
00050 public:
00051     ConduitConfig(QWidget *parent=0L, const char *n=0L);
00052     virtual void commit();
00053     virtual void load();
00054 protected:
00055     RecordWidget *fConfigWidget;
00056     KAboutData *fAbout;
00057 } ;
00058 
00059 ConduitConfig::ConduitConfig(QWidget *p, const char *n) :
00060     ConduitConfigBase(p,n),
00061     fConfigWidget(new RecordWidget(p))
00062 {
00063     FUNCTIONSETUP;
00064     fConduitName = i18n("Record Conduit");
00065     fAbout = new KAboutData("recordConduit",
00066         I18N_NOOP("Record Conduit for KPilot"),
00067         KPILOT_VERSION,
00068         I18N_NOOP("Configures the Record Conduit for KPilot"),
00069         KAboutData::License_GPL,
00070         "(C) 2005, Adriaan de Groot");
00071     fAbout->addAuthor("Adriaan de Groot",
00072         I18N_NOOP("Primary Author"),
00073         "groot@kde.org",
00074         "http://people.fruitsalad.org/adridg/");
00075 
00076     ConduitConfigBase::addAboutPage(fConfigWidget->tabWidget,fAbout);
00077     fWidget=fConfigWidget;
00078     QObject::connect(fConfigWidget->fLogMessage,SIGNAL(textChanged(const QString&)),
00079         this,SLOT(modified()));
00080     QObject::connect(fConfigWidget->fDatabases,SIGNAL(textChanged(const QString&)),
00081         this,SLOT(modified()));
00082     QObject::connect(fConfigWidget->fFailImmediately,SIGNAL(toggled(bool)),
00083         this,SLOT(modified()));
00084 }
00085 
00086 /* virtual */ void ConduitConfig::commit()
00087 {
00088     FUNCTIONSETUP;
00089 
00090 #ifdef DEBUG
00091     DEBUGKPILOT << fname
00092         << ": Message="
00093         << fConfigWidget->fLogMessage->text()
00094         << endl;
00095     DEBUGKPILOT << fname
00096         << ": Databases="
00097         << fConfigWidget->fDatabases->text()
00098         << endl;
00099 #endif
00100 
00101     ConduitSettings::setLogMessage( fConfigWidget->fLogMessage->text() );
00102     ConduitSettings::setDatabases( fConfigWidget->fDatabases->text() );
00103     ConduitSettings::setFailImmediately( fConfigWidget->fFailImmediately->isChecked());
00104     ConduitSettings::self()->writeConfig();
00105     unmodified();
00106 }
00107 
00108 /* virtual */ void ConduitConfig::load()
00109 {
00110     FUNCTIONSETUP;
00111     ConduitSettings::self()->readConfig();
00112 
00113     fConfigWidget->fLogMessage->setText( ConduitSettings::logMessage() );
00114     fConfigWidget->fDatabases->setText( ConduitSettings::databases().join(",") );
00115     fConfigWidget->fFailImmediately->setChecked( ConduitSettings::failImmediately() );
00116 
00117 #ifdef DEBUG
00118     DEBUGKPILOT << fname
00119         << ": Read Message="
00120         << fConfigWidget->fLogMessage->text()
00121         << endl;
00122     DEBUGKPILOT << fname
00123         << ": Read Database="
00124         << fConfigWidget->fDatabases->text()
00125         << endl;
00126 #endif
00127 
00128     unmodified();
00129 }
00130 
00131 typedef PilotDatabase PilotDatabaseContainer;
00132 
00133 typedef RecordConduit<PilotRecord, PilotDatabaseContainer, PilotRecord, PilotAppInfoBase, NullMapper<PilotRecord> > RecordAction;
00134 
00135 extern "C"
00136 {
00137 
00138 void *init_conduit_record()
00139 {
00140     return new ConduitFactory<ConduitConfig,RecordAction>(0,"recordconduit");
00141 }
00142 
00143 }
00144