Go to the documentation of this file.
24#include <QtGui/QPixmap>
25#include <QtCore/QDebug>
27#include <kjs/object.h>
28#include <kjs/interpreter.h>
29#include <kjs/PropertyNameArray.h>
34 KJS::JSObject *instance;
56 return Qt::ItemIsEnabled;
57 return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
63 KJS::ExecState *exec = m_js->globalExec();
64 KJS::PropertyNameArray props;
66 m_root->getPropertyNames(exec, props);
69 Node *item =
static_cast<Node*
>(
parent.internalPointer());
70 item->instance->getPropertyNames(exec, props);
83 if (orientation == Qt::Horizontal && role == Qt::DisplayRole)
95 KJS::JSObject *parentInstance = 0;
97 KJS::ExecState *exec = m_js->globalExec();
102 parentInstance = m_root;
104 return QModelIndex();
107 parentInstance =
static_cast<Node*
>(
parent.internalPointer())->instance;
109 KJS::PropertyNameArray props;
110 parentInstance->getPropertyNames(exec, props);
111 for( KJS::PropertyNameArrayIterator ref = props.begin(); ref != props.end(); ref++)
115 childItem =
new Node;
116 childItem->name = ref->ascii();
117 childItem->instance = parentInstance->get( exec,
118 childItem->name.constData() )->toObject(exec);
119 childItem->parent =
static_cast<Node*
>(
parent.internalPointer());
125 return createIndex(row, column, childItem);
127 return QModelIndex();
132 if (!
index.isValid())
134 Node *node =
new Node;
135 node->instance = m_root;
136 node->name =
"Objects";
138 return createIndex(0,
index.column(), node);
141 Node *parentItem =
static_cast<Node*
>(
index.internalPointer())->
parent;
144 Node *node =
new Node;
145 node->instance = parentItem->instance;
146 node->name = parentItem->name;
147 node->parent = parentItem->parent;
148 return createIndex(0,
index.column(), node);
151 return QModelIndex();
156 if (!
index.isValid())
159 Node *item =
static_cast<Node*
>(
index.internalPointer());
160 KJS::JSObject *instance = item->instance;
162 if (role == Qt::DecorationRole )
164 if( instance->implementsConstruct() )
165 return QPixmap(
":/images/class.png");
166 else if( instance->implementsCall() )
167 return QPixmap(
":/images/method.png");
169 return QPixmap(
":/images/property.png");
171 if( role == Qt::TextColorRole )
173 if( instance->implementsConstruct() )
174 return QColor(
"blue");
175 else if( instance->implementsCall() )
176 return QColor(
"green");
178 return QColor(
"black");
180 if (role == Qt::DisplayRole)
185#include "kjs_object_model.moc"
QModelIndex parent(const QModelIndex &index) const
QVariant data(const QModelIndex &index, int role) const
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
int columnCount(const QModelIndex &parent=QModelIndex()) const
int rowCount(const QModelIndex &parent=QModelIndex()) const
KJSObjectModel(KJS::Interpreter *js, QObject *parent=0)
Qt::ItemFlags flags(const QModelIndex &index) const
void updateModel(KJS::JSObject *m_root)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Thu Jul 18 2024 00:00:00 by
doxygen 1.11.0 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.