Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members  

KJSEmbed::JSObjectProxy Class Reference

A JS object that provides a binding to a QObject. More...

#include <jsobjectproxy.h>

Inheritance diagram for KJSEmbed::JSObjectProxy::

KJS::ObjectImp List of all members.

Public Methods

 JSObjectProxy (KJS::Interpreter *js, QObject *target)
 JSObjectProxy (KJS::Interpreter *js, QObject *target, QObject *root)
 JSObjectProxy (KJS::Interpreter *js, QObject *target, QObject *root, const JSSecurityPolicy *sp)
 ~JSObjectProxy ()
virtual void addBindings (KJS::ExecState *state, KJS::Object &object)
KJS::Object createSubProxy (QObject *target, KJS::ExecState *state=0) const
KJS::Interpreter * jscript () const
QObjectrootObject () const
QObjectobject () const
const JSSecurityPolicysecurityPolicy () const
void setSecurityPolicy (const JSSecurityPolicy *sp)
virtual KJS::Value get (KJS::ExecState *state, const KJS::UString &p) const
virtual void put (KJS::ExecState *state, const KJS::UString &p, const KJS::Value &v, int attr=KJS::None)
virtual KJS::UString toString (KJS::ExecState *exec) const
int findSignature (const QString &sig) const

Detailed Description

A JS object that provides a binding to a QObject.

Introduction

This class defines a KJS::ObjectImp that allows scripts to access the properties of a QObject. The scripts can also create child objects, load dialogs from .ui files created by Designer and navigate the object tree in a similar manner to the DCOP/QObject bridge.

Example Usage

The following example creates a KJS::ObjectImp that provides a binding to the properties of a QLineEdit . This binding is then used to create a property 'edit' for the object 'jsparent'.

   QLineEdit *edit = new QLineEdit();
   KJSEmbed::JSObjectProxy *proxy = new KJSEmbed::JSObjectProxy( js, edit );
   jsparent.put( js->globalExec(), "edit", proxy );

 

API Provided To Scripts

By default, the following methods are available to scripts for traversing and manipulating the QObject tree: Note that the methods above are restricted to a subset of the widget hierarchy by the security policy.

Security Facilities

In order to ensure scripts don't run amok and to ensure the script interpreter used by KHTML remains secure, JSObjectProxy applies a security policy. Every time a script tries to access an object or property the following tests are performed: The KJSEmbed::SecurityPolicy class decides if the request should be granted. The security policy is automatically inherited by any child proxies created using the object tree accessor methods.

See also:
KJSEmbed::Factory
Author:
Richard Moore, rich@kde.org
Id:
jsobjectproxy.h,v 1.9 2003/01/31 23:52:29 rich Exp


Constructor & Destructor Documentation

JSObjectProxy KJS::Interpreter * js,
QObject * target
 

Create a JS binding to the target object.

The binding will allow scripts to access any QObject that is descended the target and no others.

JSObjectProxy KJS::Interpreter * js,
QObject * target,
QObject * root
 

Create a JS binding to the target object.

The binding will allow scripts to access any QObject that is descended from the specified root. If the specified root is 0 then access is granted to all objects.

JSObjectProxy KJS::Interpreter * js,
QObject * target,
QObject * root,
const JSSecurityPolicy * sp
 

Create a JS binding to the target object.

The binding will allow scripts to access any QObject that is descended from the specified root, according to the specified JSSecurityPolicy . If the specified root is 0 then access is granted to all objects.


Member Function Documentation

virtual void addBindings KJS::ExecState * state,
KJS::Object & object
[virtual]
 

Adds methods for traversing the QObject tree to the specified KJS::Object .

Only QObjects descended from the root specified in the constructor can be reached through JS proxies created with these bindings.

KJS::Interpreter* jscript const [inline]
 

Returns the interpreter in which this proxy lives.

QObject* rootObject const [inline]
 

Returns the root object that defines the limit of the scope of this proxy.

QObject* object const [inline]
 

Returns the QObject the proxy is attached to.

const JSSecurityPolicy* securityPolicy const [inline]
 

Returns the JSSecurityPolicy of the proxy.

void setSecurityPolicy const JSSecurityPolicy * sp
 

Specifies the JSSecurityPolicy that should be applied to this proxy.

Setting the policy to 0 restores the default policy.

virtual KJS::Value get KJS::ExecState * state,
const KJS::UString & p
const [virtual]
 

Reimplemented to return the value of the specified property if present.

virtual void put KJS::ExecState * state,
const KJS::UString & p,
const KJS::Value & v,
int attr = KJS::None
[virtual]
 

Reimplemented to set the value of the specified property if possible.

virtual KJS::UString toString KJS::ExecState * exec const [virtual]
 

Reimplemented to return the name and class of the target.


The documentation for this class was generated from the following file:
Generated at Sat Feb 1 03:23:36 2003 for KJSEmbed by doxygen1.2.9.1 written by Dimitri van Heesch, © 1997-2001