00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef KJSEMBEDFACTORY_H
00023 #define KJSEMBEDFACTORY_H
00024
00025 #include <qmap.h>
00026 #include <qdict.h>
00027 #include <qstringlist.h>
00028
00029 #include <kjs/interpreter.h>
00030 #include <kjs/object.h>
00031
00032 class QEvent;
00033 class QObject;
00034 class QWidget;
00035 class QTextStream;
00036
00037 namespace KParts {
00038 class ReadOnlyPart;
00039 class ReadWritePart;
00040 }
00041
00045 namespace KJSEmbed {
00046
00047 namespace Bindings { class JSFactoryImp;
00048 class JSBindingPlugin; }
00049
00050 class KJSEmbedPart;
00051 class JSEventMapper;
00052 class JSOpaqueProxy;
00053 class JSObjectProxy;
00054
00060 class JSFactory
00061 {
00062 public:
00067 enum ProxyTypes {
00068 TypeInvalid=0,
00069 TypeQObject=1,
00070 TypeValue=2,
00071 TypeOpaque=4,
00072 TypePlugin=8,
00073 TypeQObjectPlugin=9
00074 };
00075
00077 JSFactory( KJSEmbedPart *part );
00078
00080 virtual ~JSFactory();
00081
00086 JSEventMapper *eventMapper() const { return evmapper; }
00087
00089 KJSEmbedPart *part() const { return jspart; }
00090
00091
00092
00093
00094
00096 KJS::Object create( KJS::ExecState *exec, const QString &classname, const KJS::List &args );
00097
00099 KJS::Object createProxy( KJS::ExecState *exec, QObject *target,
00100 const JSObjectProxy *context=0 ) const;
00101
00103 KJS::Object createProxy( KJS::ExecState *exec, QTextStream *target,
00104 const JSObjectProxy *context=0 ) const;
00105
00107 KJS::Object createProxy( KJS::ExecState *exec, QEvent *target,
00108 const JSObjectProxy *context ) const;
00109
00110
00111
00112
00113
00120 KParts::ReadOnlyPart *createROPart( const QString &svc, QObject *parent=0, const char *name=0 );
00121
00126 KParts::ReadOnlyPart *createROPart( const QString &svc, const QString &constraint,
00127 QObject *parent=0, const char *name=0 );
00128
00133 KParts::ReadOnlyPart *createROPart( const QString &svc, const QString &constraint,
00134 QObject *parent, const char *name,
00135 const QStringList &args );
00136
00143 KParts::ReadWritePart *createRWPart( const QString &svc, QObject *parent=0, const char *name=0 );
00144
00149 KParts::ReadWritePart *createRWPart( const QString &svc, const QString &constraint,
00150 QObject *parent=0, const char *name=0 );
00151
00156 KParts::ReadWritePart *createRWPart( const QString &svc, const QString &constraint,
00157 QObject *parent, const char *name,
00158 const QStringList &args );
00159
00164 QWidget *loadUI( const QString &uiFile, QObject *connector=0, QWidget *parent=0, const char *name=0 );
00165
00170 QStringList listBindingPlugins( KJS::ExecState *exec, KJS::Object &self);
00171
00172
00173
00177 void addBindingPluginTypes(KJS::ExecState *exec, KJS::Object &parent);
00178 bool isBindingPlugin(const QString &classname) const;
00182 KJS::Object createBindingPlugin(KJS::ExecState *exec, const QString &classname, const KJS::List &args );
00187 bool isSupported( const QString &clazz ) const;
00188
00193 bool isQObject( const QString &clazz ) const;
00194
00199 bool isValue( const QString &clazz ) const;
00200
00205 bool isOpaque( const QString &clazz ) const;
00206
00212 uint proxyType( const QString &clazz ) const;
00213
00214
00219 void addQObjectPlugin(const QString &classname, KJSEmbed::Bindings::JSBindingPlugin* plugin);
00220
00221 void addBindingsPlugin(KJS::ExecState *exec, KJS::Object &target) const;
00222
00228 void addType( const QString &clazz, uint proxytype=JSFactory::TypeQObject );
00229
00231 void addTypes( KJS::ExecState *exec, KJS::Object &parent );
00232
00233 QStringList types() const;
00234
00235 protected:
00237 KJS::Object extendProxy( KJS::ExecState *exec, KJS::Object &target ) const;
00238
00240 KJS::Object createValue( KJS::ExecState *exec, const QString &cname, const KJS::List &args );
00241
00246 QObject *create( const QString &classname, QObject *parent=0, const char *name=0 );
00247
00249 KJS::Object createOpaque( KJS::ExecState *exec, const QString &cname, const KJS::List &args );
00250
00251
00253 QObject *createBinding( const QString &cname, QObject *parent, const char *name );
00254
00259 QObject *createObject( const QString &cname, QObject *parent, const char *name );
00260
00265 QWidget *createWidget( const QString &cname, QWidget *parent, const char *name );
00266
00267 private:
00269 void addWidgetFactoryTypes( KJS::ExecState *exec, KJS::Object &parent );
00270
00272 void addCustomTypes( KJS::ExecState *exec, KJS::Object &parent );
00273
00275 void addBindingTypes( KJS::ExecState *exec, KJS::Object &parent );
00276
00281 void addObjectTypes( KJS::ExecState *exec, KJS::Object &parent );
00282
00283 void addOpaqueTypes( KJS::ExecState *exec, KJS::Object &parent );
00284
00285 void addValueTypes( KJS::ExecState *exec, KJS::Object &parent );
00286
00287 private:
00288 KJSEmbedPart *jspart;
00289 JSEventMapper *evmapper;
00290 QMap<QString,uint> objtypes;
00291 class JSFactoryPrivate *d;
00292 };
00293
00294 }
00295
00296 #endif // KJSEMBEDFACTORY_H
00297
00298
00299
00300