QmlJSDebugClient: Update library to latest changes in qt

Protocol / classes changed with commit fd9771c29d

Reviewed-by: Christiaan Janssen
This commit is contained in:
Kai Koehne
2010-09-27 12:45:56 +02:00
parent 9a49ad003a
commit 141ca58827
6 changed files with 242 additions and 129 deletions

View File

@@ -51,18 +51,22 @@ public:
QDeclarativeEngineDebugClient(QDeclarativeDebugConnection *client, QDeclarativeEngineDebugPrivate *p);
protected:
virtual void statusChanged(Status status);
virtual void messageReceived(const QByteArray &);
private:
QDeclarativeEngineDebugPrivate *priv;
friend class QDeclarativeEngineDebugPrivate;
};
class QDeclarativeEngineDebugPrivate
{
// Q_DECLARE_PUBLIC(QDeclarativeEngineDebug)
public:
QDeclarativeEngineDebugPrivate(QDeclarativeDebugConnection *);
QDeclarativeEngineDebugPrivate(QDeclarativeEngineDebug *, QDeclarativeDebugConnection *);
~QDeclarativeEngineDebugPrivate();
void statusChanged(QDeclarativeEngineDebug::Status status);
void message(const QByteArray &);
QDeclarativeEngineDebugClient *client;
@@ -90,19 +94,31 @@ QDeclarativeEngineDebugClient::QDeclarativeEngineDebugClient(QDeclarativeDebugCo
QDeclarativeEngineDebugPrivate *p)
: QDeclarativeDebugClient(QLatin1String("QDeclarativeEngine"), client), priv(p)
{
setEnabled(true);
}
void QDeclarativeEngineDebugClient::statusChanged(Status status)
{
if (priv)
priv->statusChanged(static_cast<QDeclarativeEngineDebug::Status>(status));
}
void QDeclarativeEngineDebugClient::messageReceived(const QByteArray &data)
{
priv->message(data);
if (priv)
priv->message(data);
}
QDeclarativeEngineDebugPrivate::QDeclarativeEngineDebugPrivate(QDeclarativeDebugConnection *c)
: client(new QDeclarativeEngineDebugClient(c, this)), nextId(0)
QDeclarativeEngineDebugPrivate::QDeclarativeEngineDebugPrivate(QDeclarativeEngineDebug *q, QDeclarativeDebugConnection *c)
: client(new QDeclarativeEngineDebugClient(c, this)), q_ptr(q), nextId(0)
{
}
QDeclarativeEngineDebugPrivate::~QDeclarativeEngineDebugPrivate()
{
if (client)
client->priv = 0;
}
int QDeclarativeEngineDebugPrivate::getId()
{
return nextId++;
@@ -116,7 +132,7 @@ void QDeclarativeEngineDebugPrivate::remove(QDeclarativeEngineDebug *c, QDeclara
}
}
void QDeclarativeEngineDebugPrivate::remove(QDeclarativeEngineDebug *c,
void QDeclarativeEngineDebugPrivate::remove(QDeclarativeEngineDebug *c,
QDeclarativeDebugRootContextQuery *q)
{
if (c && q) {
@@ -125,6 +141,44 @@ void QDeclarativeEngineDebugPrivate::remove(QDeclarativeEngineDebug *c,
}
}
// from qdeclarativeenginedebug_p.h
struct QDeclarativeObjectData {
QUrl url;
int lineNumber;
int columnNumber;
QString idString;
QString objectName;
QString objectType;
int objectId;
int contextId;
};
QDataStream &operator>>(QDataStream &ds, QDeclarativeObjectData &data)
{
ds >> data.url >> data.lineNumber >> data.columnNumber >> data.idString
>> data.objectName >> data.objectType >> data.objectId >> data.contextId;
return ds;
}
struct QDeclarativeObjectProperty {
enum Type { Unknown, Basic, Object, List, SignalProperty };
Type type;
QString name;
QVariant value;
QString valueTypeName;
QString binding;
bool hasNotifySignal;
};
QDataStream &operator>>(QDataStream &ds, QDeclarativeObjectProperty &data)
{
int type;
ds >> type >> data.name >> data.value >> data.valueTypeName
>> data.binding >> data.hasNotifySignal;
data.type = (QDeclarativeObjectProperty::Type)type;
return ds;
}
void QDeclarativeEngineDebugPrivate::remove(QDeclarativeEngineDebug *c, QDeclarativeDebugObjectQuery *q)
{
if (c && q) {
@@ -141,41 +195,6 @@ void QDeclarativeEngineDebugPrivate::remove(QDeclarativeEngineDebug *c, QDeclara
}
}
//from qdeclarativeenginedebug.cpp
struct QDeclarativeObjectData {
QUrl url;
int lineNumber;
int columnNumber;
QString idString;
QString objectName;
QString objectType;
int objectId;
int contextId;
};
QDataStream &operator>>(QDataStream &ds, QDeclarativeObjectData &data)
{
ds >> data.url >> data.lineNumber >> data.columnNumber >> data.idString
>> data.objectName >> data.objectType >> data.objectId >> data.contextId;
return ds;
}
struct QDeclarativeObjectProperty {
enum Type { Unknown, Basic, Object, List, SignalProperty };
Type type;
QString name;
QVariant value;
QString valueTypeName;
QString binding;
bool hasNotifySignal;
};
QDataStream &operator>>(QDataStream &ds, QDeclarativeObjectProperty &data)
{
int type;
ds >> type >> data.name >> data.value >> data.valueTypeName
>> data.binding >> data.hasNotifySignal;
data.type = (QDeclarativeObjectProperty::Type)type;
return ds;
}
void QDeclarativeEngineDebugPrivate::decode(QDataStream &ds, QDeclarativeDebugObjectReference &o,
bool simple)
{
@@ -260,6 +279,11 @@ void QDeclarativeEngineDebugPrivate::decode(QDataStream &ds, QDeclarativeDebugCo
}
}
void QDeclarativeEngineDebugPrivate::statusChanged(QDeclarativeEngineDebug::Status status)
{
emit q_ptr->statusChanged(status);
}
void QDeclarativeEngineDebugPrivate::message(const QByteArray &data)
{
QDataStream ds(data);
@@ -378,18 +402,25 @@ void QDeclarativeEngineDebugPrivate::message(const QByteArray &data)
}
QDeclarativeEngineDebug::QDeclarativeEngineDebug(QDeclarativeDebugConnection *client, QObject *parent)
: QObject(parent), d_ptr(new QDeclarativeEngineDebugPrivate(client))
: QObject(parent), d_ptr(new QDeclarativeEngineDebugPrivate(this, client))
{
d_ptr->q_ptr = this;
}
QDeclarativeEngineDebug::~QDeclarativeEngineDebug() {}
QDeclarativeEngineDebug::~QDeclarativeEngineDebug() { }
QDeclarativeEngineDebug::Status QDeclarativeEngineDebug::status() const
{
Q_D(const QDeclarativeEngineDebug);
return static_cast<QDeclarativeEngineDebug::Status>(d->client->status());
}
QDeclarativeDebugPropertyWatch *QDeclarativeEngineDebug::addWatch(const QDeclarativeDebugPropertyReference &property, QObject *parent)
{
Q_D(QDeclarativeEngineDebug);
QDeclarativeDebugPropertyWatch *watch = new QDeclarativeDebugPropertyWatch(parent);
if (d->client->isConnected()) {
if (d->client->status() == QDeclarativeDebugClient::Enabled) {
int queryId = d->getId();
watch->m_queryId = queryId;
watch->m_client = this;
@@ -418,7 +449,7 @@ QDeclarativeDebugObjectExpressionWatch *QDeclarativeEngineDebug::addWatch(const
{
Q_D(QDeclarativeEngineDebug);
QDeclarativeDebugObjectExpressionWatch *watch = new QDeclarativeDebugObjectExpressionWatch(parent);
if (d->client->isConnected()) {
if (d->client->status() == QDeclarativeDebugClient::Enabled) {
int queryId = d->getId();
watch->m_queryId = queryId;
watch->m_client = this;
@@ -441,7 +472,7 @@ QDeclarativeDebugWatch *QDeclarativeEngineDebug::addWatch(const QDeclarativeDebu
Q_D(QDeclarativeEngineDebug);
QDeclarativeDebugWatch *watch = new QDeclarativeDebugWatch(parent);
if (d->client->isConnected()) {
if (d->client->status() == QDeclarativeDebugClient::Enabled) {
int queryId = d->getId();
watch->m_queryId = queryId;
watch->m_client = this;
@@ -477,7 +508,7 @@ void QDeclarativeEngineDebug::removeWatch(QDeclarativeDebugWatch *watch)
d->watched.remove(watch->queryId());
if (d->client && d->client->isConnected()) {
if (d->client && d->client->status() == QDeclarativeDebugClient::Enabled) {
QByteArray message;
QDataStream ds(&message, QIODevice::WriteOnly);
ds << QByteArray("NO_WATCH") << watch->queryId();
@@ -490,7 +521,7 @@ QDeclarativeDebugEnginesQuery *QDeclarativeEngineDebug::queryAvailableEngines(QO
Q_D(QDeclarativeEngineDebug);
QDeclarativeDebugEnginesQuery *query = new QDeclarativeDebugEnginesQuery(parent);
if (d->client->isConnected()) {
if (d->client->status() == QDeclarativeDebugClient::Enabled) {
query->m_client = this;
int queryId = d->getId();
query->m_queryId = queryId;
@@ -512,7 +543,7 @@ QDeclarativeDebugRootContextQuery *QDeclarativeEngineDebug::queryRootContexts(co
Q_D(QDeclarativeEngineDebug);
QDeclarativeDebugRootContextQuery *query = new QDeclarativeDebugRootContextQuery(parent);
if (d->client->isConnected() && engine.debugId() != -1) {
if (d->client->status() == QDeclarativeDebugClient::Enabled && engine.debugId() != -1) {
query->m_client = this;
int queryId = d->getId();
query->m_queryId = queryId;
@@ -534,7 +565,7 @@ QDeclarativeDebugObjectQuery *QDeclarativeEngineDebug::queryObject(const QDeclar
Q_D(QDeclarativeEngineDebug);
QDeclarativeDebugObjectQuery *query = new QDeclarativeDebugObjectQuery(parent);
if (d->client->isConnected() && object.debugId() != -1) {
if (d->client->status() == QDeclarativeDebugClient::Enabled && object.debugId() != -1) {
query->m_client = this;
int queryId = d->getId();
query->m_queryId = queryId;
@@ -557,7 +588,7 @@ QDeclarativeDebugObjectQuery *QDeclarativeEngineDebug::queryObjectRecursive(cons
Q_D(QDeclarativeEngineDebug);
QDeclarativeDebugObjectQuery *query = new QDeclarativeDebugObjectQuery(parent);
if (d->client->isConnected() && object.debugId() != -1) {
if (d->client->status() == QDeclarativeDebugClient::Enabled && object.debugId() != -1) {
query->m_client = this;
int queryId = d->getId();
query->m_queryId = queryId;
@@ -566,9 +597,7 @@ QDeclarativeDebugObjectQuery *QDeclarativeEngineDebug::queryObjectRecursive(cons
QByteArray message;
QDataStream ds(&message, QIODevice::WriteOnly);
ds << QByteArray("FETCH_OBJECT") << queryId << object.debugId()
<< true << true; // Note: dumping all the properties is slow, and make noticable lags.
// TODO: Find an alternative to this when they are needed by the live preview
<< true << true;
d->client->sendMessage(message);
} else {
query->m_state = QDeclarativeDebugQuery::Error;
@@ -582,7 +611,7 @@ QDeclarativeDebugExpressionQuery *QDeclarativeEngineDebug::queryExpressionResult
Q_D(QDeclarativeEngineDebug);
QDeclarativeDebugExpressionQuery *query = new QDeclarativeDebugExpressionQuery(parent);
if (d->client->isConnected() && objectDebugId != -1) {
if (d->client->status() == QDeclarativeDebugClient::Enabled && objectDebugId != -1) {
query->m_client = this;
query->m_expr = expr;
int queryId = d->getId();
@@ -606,7 +635,7 @@ bool QDeclarativeEngineDebug::setBindingForObject(int objectDebugId, const QStri
{
Q_D(QDeclarativeEngineDebug);
if (d->client->isConnected() && objectDebugId != -1) {
if (d->client->status() == QDeclarativeDebugClient::Enabled && objectDebugId != -1) {
QByteArray message;
QDataStream ds(&message, QIODevice::WriteOnly);
ds << QByteArray("SET_BINDING") << objectDebugId << propertyName << bindingExpression << isLiteralValue;
@@ -621,7 +650,7 @@ bool QDeclarativeEngineDebug::resetBindingForObject(int objectDebugId, const QSt
{
Q_D(QDeclarativeEngineDebug);
if (d->client->isConnected() && objectDebugId != -1) {
if (d->client->status() == QDeclarativeDebugClient::Enabled && objectDebugId != -1) {
QByteArray message;
QDataStream ds(&message, QIODevice::WriteOnly);
ds << QByteArray("RESET_BINDING") << objectDebugId << propertyName;
@@ -637,7 +666,7 @@ bool QDeclarativeEngineDebug::setMethodBody(int objectDebugId, const QString &me
{
Q_D(QDeclarativeEngineDebug);
if (d->client->isConnected() && objectDebugId != -1) {
if (d->client->status() == QDeclarativeDebugClient::Enabled && objectDebugId != -1) {
QByteArray message;
QDataStream ds(&message, QIODevice::WriteOnly);
ds << QByteArray("SET_METHOD_BODY") << objectDebugId << methodName << methodBody;
@@ -701,6 +730,7 @@ QString QDeclarativeDebugObjectExpressionWatch::expression() const
return m_expr;
}
QDeclarativeDebugQuery::QDeclarativeDebugQuery(QObject *parent)
: QObject(parent), m_state(Waiting)
{
@@ -1025,4 +1055,3 @@ bool QDeclarativeDebugPropertyReference::hasNotifySignal() const
}
}