kpilot/lib
pluginfactory.h00001 #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
00037 class KPilotLink;
00038
00039
00040
00043 template <class Widget, class Action> class ConduitFactory : public KLibFactory
00044 {
00045 public:
00046 ConduitFactory(QObject *parent = 0, const char *name = 0) :
00047 KLibFactory(parent,name)
00048 { fInstance = new KInstance(name); } ;
00049 virtual ~ConduitFactory()
00050 { delete fInstance; } ;
00051
00052 protected:
00053 virtual QObject *createObject(
00054 QObject* parent = 0,
00055 const char* name = 0,
00056 const char* classname = "QObject",
00057 const QStringList &args = QStringList() )
00058 {
00059 if (qstrcmp(classname,"ConduitConfigBase")==0)
00060 {
00061 QWidget *w = dynamic_cast<QWidget *>(parent);
00062 if (w) return new Widget(w,name);
00063 else
00064 {
00065 WARNINGKPILOT << "Could not cast parent to widget." << endl;
00066 return 0L;
00067 }
00068 }
00069
00070 if (qstrcmp(classname,"SyncAction")==0)
00071 {
00072 KPilotLink *d = 0L;
00073 if (parent) d = dynamic_cast<KPilotLink *>(parent);
00074
00075 if (d || !parent)
00076 {
00077 if (!parent)
00078 {
00079 kdDebug() << k_funcinfo << ": Using NULL device." << endl;
00080 }
00081 return new Action(d,name,args);
00082 }
00083 else
00084 {
00085 WARNINGKPILOT << "Could not cast parent to KPilotLink" << endl;
00086 return 0L;
00087 }
00088 }
00089 return 0L;
00090 }
00091
00092 KInstance *fInstance;
00093 } ;
00094
00095 #endif
00096
|