kpilot
factory.ccGo to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
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 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 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
|