kpilot
pluginfactory.hGo to the documentation of this file.00001 #ifndef _KPILOT_PLUGINFACTORY_H
00002 #define _KPILOT_PLUGINFACTORY_H
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
00030 #include <qwidget.h>
00031
00032 #include <kdebug.h>
00033 #include <klibloader.h>
00034
00035 #include "options.h"
00036
00039 class KPilotLink;
00040
00041
00042
00045 template <class Widget, class Action> class ConduitFactory : public KLibFactory
00046 {
00047 public:
00048 ConduitFactory(QObject *parent = 0, const char *name = 0) :
00049 KLibFactory(parent,name)
00050 { fInstance = new KInstance(name); } ;
00051 virtual ~ConduitFactory()
00052 { delete fInstance; } ;
00053
00054 protected:
00055 virtual QObject *createObject(
00056 QObject* parent = 0,
00057 const char* name = 0,
00058 const char* classname = "QObject",
00059 const QStringList &args = QStringList() )
00060 {
00061 if (qstrcmp(classname,"ConduitConfigBase")==0)
00062 {
00063 QWidget *w = dynamic_cast<QWidget *>(parent);
00064 if (w) return new Widget(w,name);
00065 else
00066 {
00067 WARNINGKPILOT << "Could not cast parent to widget." << endl;
00068 return 0L;
00069 }
00070 }
00071
00072 if (qstrcmp(classname,"SyncAction")==0)
00073 {
00074 KPilotLink *d = 0L;
00075 if (parent) d = dynamic_cast<KPilotLink *>(parent);
00076
00077 if (d || !parent)
00078 {
00079 if (!parent)
00080 {
00081 kdDebug() << k_funcinfo << ": Using NULL device." << endl;
00082 }
00083 return new Action(d,name,args);
00084 }
00085 else
00086 {
00087 WARNINGKPILOT << "Could not cast parent to KPilotLink" << endl;
00088 return 0L;
00089 }
00090 }
00091 return 0L;
00092 }
00093
00094 KInstance *fInstance;
00095 } ;
00096
00097 #endif
00098
|