forked from qt-creator/qt-creator
QmlJsDelta: Add ability to remove object
This commit is contained in:
@@ -439,6 +439,13 @@ void ClientProxy::createQmlObject(const QString &qmlText, const QDeclarativeDebu
|
||||
m_designClient->createQmlObject(qmlText, parentRef, imports, filename);
|
||||
}
|
||||
|
||||
void QmlJSInspector::Internal::ClientProxy::destroyQmlObject(int debugId)
|
||||
{
|
||||
if (isDesignClientConnected())
|
||||
m_designClient->destroyQmlObject(debugId);
|
||||
}
|
||||
|
||||
|
||||
bool ClientProxy::isDesignClientConnected() const
|
||||
{
|
||||
return (m_designClient && m_conn->isConnected());
|
||||
|
@@ -106,6 +106,7 @@ public slots:
|
||||
void changeToSelectMarqueeTool();
|
||||
void createQmlObject(const QString &qmlText, const QDeclarativeDebugObjectReference &parent,
|
||||
const QStringList &imports, const QString &filename = QString());
|
||||
void destroyQmlObject(int debugId);
|
||||
|
||||
private slots:
|
||||
void contextChanged();
|
||||
|
@@ -310,7 +310,7 @@ void Delta::insert(UiObjectMember *member, UiObjectMember *parentMember, const Q
|
||||
}
|
||||
}
|
||||
|
||||
void QmlJSInspector::Internal::Delta::update(UiObjectDefinition* oldObject, const QmlJS::Document::Ptr& oldDoc,
|
||||
void Delta::update(UiObjectDefinition* oldObject, const QmlJS::Document::Ptr& oldDoc,
|
||||
UiObjectDefinition* newObject, const QmlJS::Document::Ptr& newDoc,
|
||||
const QList< QDeclarativeDebugObjectReference >& debugReferences)
|
||||
{
|
||||
@@ -396,6 +396,15 @@ void QmlJSInspector::Internal::Delta::update(UiObjectDefinition* oldObject, cons
|
||||
}
|
||||
}
|
||||
|
||||
void Delta::remove(const QList< QDeclarativeDebugObjectReference >& debugReferences)
|
||||
{
|
||||
foreach (const QDeclarativeDebugObjectReference &ref, debugReferences) {
|
||||
if (ref.debugId() != -1)
|
||||
ClientProxy::instance()->destroyQmlObject(ref.debugId()); // ### remove
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Delta::DebugIdMap Delta::operator()(const Document::Ptr &doc1, const Document::Ptr &doc2, const DebugIdMap &debugIds)
|
||||
@@ -438,7 +447,6 @@ Delta::DebugIdMap Delta::operator()(const Document::Ptr &doc1, const Document::P
|
||||
}
|
||||
//qDebug() << "Delta::operator(): match "<< label(x, doc1) << "with parent " << label(parents1.parent.value(x), doc1)
|
||||
// << " to "<< label(y, doc2) << "with parent " << label(parents2.parent.value(y), doc2);
|
||||
|
||||
|
||||
if (!M.contains(parents1.parent.value(x),parents2.parent.value(y))) {
|
||||
qDebug () << "Delta::operator(): move " << label(y, doc2) << " from " << label(parents1.parent.value(x), doc1)
|
||||
@@ -454,7 +462,10 @@ Delta::DebugIdMap Delta::operator()(const Document::Ptr &doc1, const Document::P
|
||||
if (!cast<UiObjectDefinition *>(x))
|
||||
continue;
|
||||
if (!M.way1.contains(x)) {
|
||||
qDebug () << "Delta::operator(): remove " << label(x, doc1) << " ### TODO";
|
||||
qDebug () << "Delta::operator(): remove " << label(x, doc1);
|
||||
QList< QDeclarativeDebugObjectReference > ids = debugIds.value(x);
|
||||
if (!ids.isEmpty())
|
||||
remove(ids);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@@ -72,9 +72,15 @@ public:
|
||||
static bool compare(QmlJS::AST::UiQualifiedId *id, QmlJS::AST::UiQualifiedId *other);
|
||||
static QmlJS::AST::UiObjectMemberList *objectMembers(QmlJS::AST::UiObjectMember *object);
|
||||
|
||||
|
||||
private:
|
||||
void insert(UiObjectMember *member, UiObjectMember *parentMember,
|
||||
const QList<QDeclarativeDebugObjectReference> &debugReferences, const Document::Ptr &doc);
|
||||
void update(UiObjectDefinition* oldObject, const QmlJS::Document::Ptr& oldDoc,
|
||||
UiObjectDefinition* newObject, const QmlJS::Document::Ptr& newDoc,
|
||||
const QList<QDeclarativeDebugObjectReference >& debugReferences);
|
||||
void remove(const QList< QDeclarativeDebugObjectReference > &debugReferences);
|
||||
|
||||
void updateScriptBinding(const QDeclarativeDebugObjectReference &objectReference,
|
||||
QmlJS::AST::UiScriptBinding *scriptBinding,
|
||||
const QString &propertyName,
|
||||
@@ -84,9 +90,6 @@ private:
|
||||
const QString &methodName,
|
||||
const QString &methodBody);
|
||||
|
||||
void update(UiObjectDefinition* oldObject, const QmlJS::Document::Ptr& oldDoc,
|
||||
UiObjectDefinition* newObject, const QmlJS::Document::Ptr& newDoc,
|
||||
const QList<QDeclarativeDebugObjectReference >& debugReferences);
|
||||
|
||||
private:
|
||||
QmlJS::Document::Ptr _doc;
|
||||
|
@@ -231,6 +231,19 @@ void QmlJSDesignDebugClient::createQmlObject(const QString &qmlText, const QDecl
|
||||
sendMessage(message);
|
||||
}
|
||||
|
||||
void QmlJSDesignDebugClient::destroyQmlObject(int debugId)
|
||||
{
|
||||
if (!m_connection || !m_connection->isConnected())
|
||||
return;
|
||||
QByteArray message;
|
||||
QDataStream ds(&message, QIODevice::WriteOnly);
|
||||
|
||||
ds << QByteArray("DESTROY_OBJECT") << debugId;
|
||||
|
||||
sendMessage(message);
|
||||
}
|
||||
|
||||
|
||||
void QmlJSDesignDebugClient::applyChangesToQmlFile()
|
||||
{
|
||||
if (!m_connection || !m_connection->isConnected())
|
||||
|
@@ -66,6 +66,7 @@ public:
|
||||
|
||||
void createQmlObject(const QString &qmlText, const QDeclarativeDebugObjectReference &parentRef,
|
||||
const QStringList &imports, const QString &filename);
|
||||
void destroyQmlObject(int debugId);
|
||||
|
||||
void applyChangesToQmlFile();
|
||||
void applyChangesFromQmlFile();
|
||||
|
@@ -60,6 +60,11 @@ void QDeclarativeDesignDebugServer::messageReceived(const QByteArray &message)
|
||||
QStringList imports;
|
||||
ds >> qml >> parentId >> imports >> filename;
|
||||
emit objectCreationRequested(qml, objectForId(parentId), imports, filename);
|
||||
} else if (type == "DESTROY_OBJECT") {
|
||||
int debugId;
|
||||
ds >> debugId;
|
||||
if (QObject* obj = objectForId(debugId))
|
||||
obj->deleteLater();
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user