42 #include "private/qdeclarativeenginedebugservice_p.h" 44 #include "private/qdeclarativeboundsignal_p.h" 46 #include "private/qdeclarativemetatype_p.h" 48 #include "private/qdeclarativeproperty_p.h" 49 #include "private/qdeclarativebinding_p.h" 50 #include "private/qdeclarativecontext_p.h" 51 #include "private/qdeclarativewatcher_p.h" 52 #include "private/qdeclarativevaluetype_p.h" 53 #include "private/qdeclarativevmemetaobject_p.h" 54 #include "private/qdeclarativeexpression_p.h" 55 #include "private/qdeclarativepropertychanges_p.h" 57 #include <QtCore/qdebug.h> 58 #include <QtCore/qmetaobject.h> 66 return qmlEngineDebugService();
126 signalName[0] = signalName.
at(0).
toLower();
164 value = prop.
read(obj);
178 int count = list.
size();
179 for (
int i = 0; i < count; i++)
186 QMapIterator<QString, QVariant> i(value.
toMap());
187 while (i.hasNext()) {
211 QObject *
object,
bool recur,
bool dumpProperties)
217 int childrenCount = children.
count();
218 for (
int ii = 0; ii < children.
count(); ++ii) {
223 message << childrenCount << recur;
227 for (
int ii = 0; ii < children.
count(); ++ii) {
229 if (qobject_cast<QDeclarativeContext*>(child))
239 if (!dumpProperties) {
245 for (
int ii = 0; ii <
object->metaObject()->propertyCount(); ++ii) {
247 propertyIndexes << ii;
250 for (
int ii = 0; ii < children.
count(); ++ii) {
252 if (qobject_cast<QDeclarativeContext*>(child))
273 fakeProperties << prop;
277 message << propertyIndexes.
size() + fakeProperties.
count();
279 for (
int ii = 0; ii < propertyIndexes.
size(); ++ii)
282 for (
int ii = 0; ii < fakeProperties.
count(); ++ii)
283 message << fakeProperties[ii];
291 for (
int ii = 0; ii < children.
count(); ++ii) {
305 message << ctxtName << ctxtId;
351 child = child->nextChild;
362 for (
int ii = 0; ii < children.
count(); ++ii) {
414 ds >> type >> queryId;
419 if (type ==
"LIST_ENGINES") {
429 rs << engineName << engineId;
432 }
else if (type ==
"LIST_OBJECTS") {
439 rs <<
QByteArray(
"LIST_OBJECTS_R") << queryId;
446 }
else if (type ==
"FETCH_OBJECT") {
449 bool dumpProperties =
true;
451 ds >> objectId >> recurse >> dumpProperties;
455 rs <<
QByteArray(
"FETCH_OBJECT_R") << queryId;
463 }
else if (type ==
"WATCH_OBJECT") {
469 rs <<
QByteArray(
"WATCH_OBJECT_R") << queryId << ok;
471 }
else if (type ==
"WATCH_PROPERTY") {
478 rs <<
QByteArray(
"WATCH_PROPERTY_R") << queryId << ok;
480 }
else if (type ==
"WATCH_EXPR_OBJECT") {
484 ds >> debugId >> expr;
487 rs <<
QByteArray(
"WATCH_EXPR_OBJECT_R") << queryId << ok;
489 }
else if (type ==
"NO_WATCH") {
492 }
else if (type ==
"EVAL_EXPRESSION") {
496 ds >> objectId >> expr;
501 if (
object && context) {
503 bool undefined =
false;
513 rs <<
QByteArray(
"EVAL_EXPRESSION_R") << queryId << result;
515 }
else if (type ==
"SET_BINDING") {
522 ds >> objectId >> propertyName >> expr >> isLiteralValue;
524 ds >> filename >> line;
526 setBinding(objectId, propertyName, expr, isLiteralValue, filename, line);
530 }
else if (type ==
"RESET_BINDING") {
533 ds >> objectId >> propertyName;
538 }
else if (type ==
"SET_METHOD_BODY") {
542 ds >> objectId >> methodName >> methodBody;
560 if (
object && context) {
564 bool inBaseState =
true;
569 if (state->isStateActive() && state->containsPropertyInRevertList(
object, propertyName)) {
573 if (!isLiteralValue) {
580 state->changeBindingInRevertList(
object, propertyName, newBinding);
583 state->changeValueInRevertList(
object, propertyName, expression);
589 if (isLiteralValue) {
590 property.write(expression);
605 qWarning() <<
"QDeclarativeEngineDebugService::setBinding: unable to set property" << propertyName <<
"on object" << object;
612 if (isLiteralValue) {
613 propertyChanges->changeValue(propertyName, expression);
615 propertyChanges->changeExpression(propertyName, expression.
toString());
618 qWarning() <<
"QDeclarativeEngineDebugService::setBinding: unable to set property" << propertyName <<
"on object" << object;
629 if (
object && context) {
647 if (
QObject *emptyObject = objType->create()) {
648 if (emptyObject->property(propertyName.
toLatin1()).isValid()) {
651 setBinding(objectId, propertyName, defaultValue,
true);
663 propertyChanges->removeProperty(propertyName);
673 if (!
object || !context || !context->
engine())
690 for (
int ii = 0; ii < paramNames.
count(); ++ii) {
746 rs <<
QByteArray(
"OBJECT_CREATED") << -1 << engineId << objectId << parentId;
QDeclarativeContextData * outerContext
The QVariant class acts like a union for the most common Qt data types.
static QDeclarativeData * get(const QObject *object, bool create=false)
bool isLetter() const
Returns true if the character is a letter (Letter_* categories); otherwise returns false...
bool isResettable() const
Returns true if the property is resettable, otherwise false.
#define QT_END_NAMESPACE
This macro expands to.
void addEngine(QDeclarativeEngine *)
static QObject * objectForId(int)
Returns the object for unique id.
void buildStatesList(QDeclarativeContext *, bool)
const QChar at(int i) const
Returns the character at the given index position in the string.
QMap< QString, QVariant > toMap() const
Returns the variant as a QMap<QString, QVariant> if the variant has type() Map ; otherwise returns an...
QString toString(FormattingOptions options=None) const
Returns the human-displayable string representation of the URL.
QString objectName
the name of this object
static QDeclarativeBoundSignal * cast(QObject *)
bool atEnd() const
Returns true if the I/O device has reached the end position (end of the stream or file) or if there i...
The QByteArray class provides an array of bytes.
int length() const
Returns the number of characters in this string.
static QMetaMethod findSignalByName(const QMetaObject *mo, const QByteArray &)
Return the signal corresponding to name.
QString toUpper() const Q_REQUIRED_RESULT
Returns an uppercase copy of the string.
QVariant valueContents(const QVariant &defaultValue) const
QDataStream & operator>>(QDataStream &ds, QDeclarativeEngineDebugService::QDeclarativeObjectData &data)
void setTarget(const QDeclarativeProperty &)
virtual void destroy(DestroyMode mode=DisconnectBinding)
Destroy the binding.
static QDeclarativeAbstractBinding * binding(QObject *, int coreIndex, int valueTypeIndex)
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
QList< QVariant > toList() const
Returns the variant as a QVariantList if the variant has type() List or StringList ; otherwise return...
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
QVariant evaluate(bool *valueIsUndefined=0)
Evaulates the expression, returning the result of the evaluation, or an invalid QVariant if the expre...
int count(const T &t) const
Returns the number of occurrences of value in the list.
The QString class provides a Unicode character string.
T * qobject_cast(QObject *object)
The QObject class is the base class of all Qt objects.
Q_DECLARATIVE_EXPORT QDeclarativeContext * qmlContext(const QObject *)
bool isValid() const
Returns true if the QDeclarativeProperty refers to a valid property, otherwise false.
static QObjectPrivate * get(QObject *o)
bool addWatch(int id, quint32 objectId)
void setNotifyOnValueChanged(bool)
Sets whether the valueChanged() signal is emitted when the expression's evaluated value changes...
void propertyChanged(int id, int objectId, const QMetaProperty &property, const QVariant &value)
void buildObjectList(QDataStream &, QDeclarativeContext *)
void append(const T &t)
Inserts value at the end of the list.
#define QT_BEGIN_NAMESPACE
This macro expands to.
QBool contains(const T &t) const
Returns true if the list contains an occurrence of value; otherwise returns false.
QDeclarativeObjectProperty propertyData(QObject *, int)
virtual void update(QDeclarativePropertyPrivate::WriteFlags flags)
static QScriptValue evalInObjectScope(QDeclarativeContextData *, QObject *, const QString &, const QString &, int, QScriptValue *)
QString left(int n) const Q_REQUIRED_RESULT
Returns a substring that contains the n leftmost characters of the string.
QDeclarativeObjectData objectData(QObject *)
static bool hasValidSignal(QObject *object, const QString &propertyName)
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
void message(const QByteArray &)
Q_DECLARATIVE_EXPORT void qmlExecuteDeferred(QObject *)
const T & at(int i) const
Returns the item at index position i in the list.
Data * property(const QScriptDeclarativeClass::Identifier &id) const
QDeclarativeContextData * nextChild
static QString fromUtf8(const char *, int size=-1)
Returns a QString initialized with the first size bytes of the UTF-8 string str.
Q_CORE_EXPORT void qWarning(const char *,...)
Q_GLOBAL_STATIC(QDeclarativeEngineDebugService, qmlEngineDebugService)
QDeclarativeContext * rootContext() const
Returns the engine's root context.
static const char * data(const QByteArray &arr)
int indexOf(QChar c, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
static QMetaMethod metaMethod(const QMetaObject *meta, QMetaMethod::MethodType type, int index)
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
void clear()
Removes all items from the list.
static QDeclarativeAbstractBinding * setBinding(QObject *, int coreIndex, int valueTypeIndex, QDeclarativeAbstractBinding *, WriteFlags flags=DontRemoveBinding)
virtual void messageReceived(const QByteArray &)
QDeclarativeExpression * expression() const
Returns the signal expression.
void resetBinding(int objectId, const QString &propertyName)
bool isUpper() const
Returns true if the character is an uppercase letter, i.
QList< QPointer< QObject > > instances
QString findObjectId(const QObject *obj) const
QString expression() const
Returns the expression string.
static QDeclarativeContextPrivate * get(QDeclarativeContext *context)
QList< QDeclarativeEngine * > m_engines
static int idForObject(QObject *)
Returns a unique id for object.
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
QDeclarativeEngineDebugService(QObject *=0)
int userType() const
Returns the storage type of the value stored in the variant.
QString & append(QChar c)
QObject * scopeObject() const
Returns the expression's scope object, if provided, otherwise 0.
void setBinding(int objectId, const QString &propertyName, const QVariant &expression, bool isLiteralValue, QString filename=QString(), int line=-1)
static bool isValueType(int)
void remEngine(QDeclarativeEngine *)
The QDeclarativeEngine class provides an environment for instantiating QML components.
int lastIndexOf(QChar c, int from=-1, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Type type() const
Returns the storage type of the value stored in the variant.
static QDeclarativeEngineDebugService * instance()
iterator insert(const Key &key, const T &value)
Inserts a new item with the key key and a value of value.
QDeclarativeContext * asQDeclarativeContext()
QObject * parent() const
Returns a pointer to the parent object.
virtual QString expression() const
int size() const
Returns the number of items in the list.
void prepareDeferredObjects(QObject *)
static QByteArray methodName(const char *signature, int nameLength)
Makes a deep copy of the first nameLength characters of the given method signature and returns the co...
QString objectName() const
QDataStream & operator<<(QDataStream &ds, const QDeclarativeEngineDebugService::QDeclarativeObjectData &data)
QDeclarativeWatcher * m_watch
void setMethodBody(int objectId, const QString &method, const QString &body)
const QObjectList & children() const
Returns a list of child objects.
The QDeclarativeContext class defines a context within a QML engine.
void setSourceLocation(const QString &fileName, int line)
Set the location of this expression to line of url.
void objectCreated(QDeclarativeEngine *, QObject *)
QVariant property(const char *name) const
Returns the value of the object's name property.
QDeclarativeEngine * engine() const
Return the context's QDeclarativeEngine, or 0 if the context has no QDeclarativeEngine or the QDeclar...
static bool isSignalPropertyName(const QString &signalName)
The QDeclarativeProperty class abstracts accessing properties on objects created from QML...
static QDeclarativeExpression * setSignalExpression(const QDeclarativeProperty &that, QDeclarativeExpression *)
Set the signal expression associated with this signal property to expr.
The QDataStream class provides serialization of binary data to a QIODevice.
The QDeclarativeExpression class evaluates JavaScript in a QML context.
bool isValid() const
Returns true if the storage type of this variant is not QVariant::Invalid; otherwise returns false...
QChar toLower() const
Returns the lowercase equivalent if the character is uppercase or titlecase; otherwise returns the ch...
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.
void sendMessage(const QByteArray &)
The QWeakPointer class holds a weak reference to a shared pointer.
bool isProperty() const
Returns true if this QDeclarativeProperty represents a regular Qt property.
QList< QWeakPointer< QDeclarativeState > > m_allStates
QVariant read() const
Returns the property value.
void buildObjectDump(QDataStream &, QObject *, bool, bool)
int removeAll(const T &t)
Removes all occurrences of value in the list and returns the number of entries removed.
QDeclarativeContextData * childContexts
static QDeclarativeContextData * get(QDeclarativeContext *context)
void removeAt(int i)
Removes the item at index position i.