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

KJSEmbed::JSObjectProxy Class Reference

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

#include <jsobjectproxy.h>

Inheritance diagram for KJSEmbed::JSObjectProxy:

KJSEmbed::JSProxy List of all members.

Public Methods

 JSObjectProxy (KJSEmbedPart *part, QObject *target)
 JSObjectProxy (KJSEmbedPart *part, QObject *target, QObject *root)
 JSObjectProxy (KJSEmbedPart *part, QObject *target, QObject *root, const JSSecurityPolicy *sp)
virtual ~JSObjectProxy ()
KJSEmbedPartpart () const
KJS::Interpreter * interpreter () const
QObject * rootObject () const
QObject * object () const
QWidget * widget () const
const JSSecurityPolicysecurityPolicy () const
void setSecurityPolicy (const JSSecurityPolicy *sp)
virtual KJS::Value get (KJS::ExecState *exec, const KJS::Identifier &p) const
virtual void put (KJS::ExecState *exec, const KJS::Identifier &p, const KJS::Value &v, int attr=KJS::None)
virtual KJS::UString toString (KJS::ExecState *exec) const
virtual void addBindings (KJS::ExecState *exec, KJS::Object &object)

Protected Methods

void addBindingsClass (KJS::ExecState *exec, KJS::Object &object)
void addBindingsEnum (KJS::ExecState *exec, KJS::Object &object)
void addBindingsSlots (KJS::ExecState *exec, KJS::Object &object)

Friends

class Bindings::JSObjectProxyImp

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 );

 

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::JSSecurityPolicy 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::JSFactory
Author:
Richard Moore, rich@kde.org
Id:
jsobjectproxy.h,v 1.28 2003/10/18 23:43:28 rich Exp


Constructor & Destructor Documentation

KJSEmbed::JSObjectProxy::JSObjectProxy KJSEmbedPart   part,
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.

KJSEmbed::JSObjectProxy::JSObjectProxy KJSEmbedPart   part,
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.

KJSEmbed::JSObjectProxy::JSObjectProxy KJSEmbedPart   part,
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.

virtual KJSEmbed::JSObjectProxy::~JSObjectProxy   [inline, virtual]
 


Member Function Documentation

virtual void KJSEmbed::JSObjectProxy::addBindings KJS::ExecState *    exec,
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.

  • properties()
  • create(...)

void KJSEmbed::JSObjectProxy::addBindingsClass KJS::ExecState *    exec,
KJS::Object &    object
[protected]
 

void KJSEmbed::JSObjectProxy::addBindingsEnum KJS::ExecState *    exec,
KJS::Object &    object
[protected]
 

Adds bindings for the constants defined by enums of the target.

void KJSEmbed::JSObjectProxy::addBindingsSlots KJS::ExecState *    exec,
KJS::Object &    object
[protected]
 

Adds bindings for slots defined by the target of the proxy.

virtual KJS::Value KJSEmbed::JSObjectProxy::get KJS::ExecState *    exec,
const KJS::Identifier &    p
const [virtual]
 

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

KJS::Interpreter* KJSEmbed::JSObjectProxy::interpreter   const [inline]
 

Returns the interpreter in which this proxy lives.

QObject* KJSEmbed::JSObjectProxy::object   const [inline]
 

Returns the QObject the proxy is attached to.

KJSEmbedPart* KJSEmbed::JSObjectProxy::part   const [inline]
 

Returns the KJSEmbedPart in which this proxy lives.

virtual void KJSEmbed::JSObjectProxy::put KJS::ExecState *    exec,
const KJS::Identifier &    p,
const KJS::Value &    v,
int    attr = KJS::None
[virtual]
 

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

QObject* KJSEmbed::JSObjectProxy::rootObject   const [inline]
 

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

const JSSecurityPolicy* KJSEmbed::JSObjectProxy::securityPolicy   const [inline]
 

Returns the JSSecurityPolicy of the proxy.

void KJSEmbed::JSObjectProxy::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::UString KJSEmbed::JSObjectProxy::toString KJS::ExecState *    exec const [virtual]
 

Reimplemented to return the name and class of the target.

QWidget* KJSEmbed::JSObjectProxy::widget   const [inline]
 

Returns the associated QWidget, or 0 if the object is not a widget.


Friends And Related Function Documentation

friend class Bindings::JSObjectProxyImp [friend]
 


The documentation for this class was generated from the following file:
Generated on Sun Jan 11 02:29:54 2004 for KJSEmbed by doxygen1.2.18