Commit f8fc9084 authored by Lasse Holmstedt's avatar Lasse Holmstedt

Updating selection after new tree is fetched & code cleanup

parent 032e7dc4
......@@ -128,20 +128,22 @@ void ClientProxy::onCurrentObjectsChanged(const QList<int> &debugIds)
// So the only choice that remains is to update the complete tree when we have an unknown debug id.
if (!m_objectTreeQuery) {
m_objectTreeQuery = m_client->queryObjectRecursive(m_rootObject, this);
if (!m_objectTreeQuery->isWaiting()) {
objectTreeFetched();
} else {
connect(m_objectTreeQuery,
SIGNAL(stateChanged(QDeclarativeDebugQuery::State)),
SLOT(objectTreeFetched(QDeclarativeDebugQuery::State)));
}
}
}
}
emit selectedItemsChanged(selectedItems);
if (m_objectTreeQuery) {
if (!m_objectTreeQuery->isWaiting()) {
objectTreeFetched();
} else {
connect(m_objectTreeQuery,
SIGNAL(stateChanged(QDeclarativeDebugQuery::State)),
SLOT(objectTreeFetched(QDeclarativeDebugQuery::State)));
}
} else {
emit selectedItemsChanged(selectedItems);
}
}
void ClientProxy::disconnectFromViewer()
......@@ -358,49 +360,58 @@ void ClientProxy::objectTreeFetched(QDeclarativeDebugQuery::State state)
m_objectTreeQuery = 0;
emit objectTreeUpdated(m_rootObject);
if (isDesignClientConnected() && !m_designClient->selectedItemIds().isEmpty()) {
onCurrentObjectsChanged(m_designClient->selectedItemIds());
}
}
void ClientProxy::reloadQmlViewer()
{
if (m_designClient && m_conn->isConnected())
if (isDesignClientConnected())
m_designClient->reloadViewer();
}
void ClientProxy::setDesignModeBehavior(bool inDesignMode)
{
if (m_designClient && m_conn->isConnected())
if (isDesignClientConnected())
m_designClient->setDesignModeBehavior(inDesignMode);
}
void ClientProxy::setAnimationSpeed(qreal slowdownFactor)
{
if (m_designClient && m_conn->isConnected())
if (isDesignClientConnected())
m_designClient->setAnimationSpeed(slowdownFactor);
}
void ClientProxy::changeToColorPickerTool()
{
if (m_designClient && m_conn->isConnected())
if (isDesignClientConnected())
m_designClient->changeToColorPickerTool();
}
void ClientProxy::changeToZoomTool()
{
if (m_designClient && m_conn->isConnected())
if (isDesignClientConnected())
m_designClient->changeToZoomTool();
}
void ClientProxy::changeToSelectTool()
{
if (m_designClient && m_conn->isConnected())
if (isDesignClientConnected())
m_designClient->changeToSelectTool();
}
void ClientProxy::changeToSelectMarqueeTool()
{
if (m_designClient && m_conn->isConnected())
if (isDesignClientConnected())
m_designClient->changeToSelectMarqueeTool();
}
bool ClientProxy::isDesignClientConnected() const
{
return (m_designClient && m_conn->isConnected());
}
void ClientProxy::reloadEngines()
{
......
......@@ -117,6 +117,7 @@ private slots:
void objectTreeFetched(QDeclarativeDebugQuery::State state = QDeclarativeDebugQuery::Completed);
private:
bool isDesignClientConnected() const;
void reloadEngines();
QList<QDeclarativeDebugObjectReference> objectReferences(const QUrl &url, const QDeclarativeDebugObjectReference &objectRef) const;
QDeclarativeDebugObjectReference objectReferenceForId(int debugId, const QDeclarativeDebugObjectReference &ref) const;
......
......@@ -64,17 +64,17 @@ void QmlJSDesignDebugClient::messageReceived(const QByteArray &message)
if (type == "CURRENT_OBJECTS_CHANGED") {
int objectCount;
ds >> objectCount;
QList<int> debugIds;
m_selectedItemIds.clear();
for(int i = 0; i < objectCount; ++i) {
int debugId;
ds >> debugId;
if (debugId != -1) {
debugIds << debugId;
m_selectedItemIds << debugId;
}
}
emit currentObjectsChanged(debugIds);
emit currentObjectsChanged(m_selectedItemIds);
} else if (type == "TOOL_CHANGED") {
int toolId;
ds >> toolId;
......@@ -99,6 +99,11 @@ void QmlJSDesignDebugClient::messageReceived(const QByteArray &message)
}
}
QList<int> QmlJSDesignDebugClient::selectedItemIds() const
{
return m_selectedItemIds;
}
void QmlJSDesignDebugClient::setSelectedItemsByObjectId(const QList<QDeclarativeDebugObjectReference> &objects)
{
if (!m_connection || !m_connection->isConnected())
......
......@@ -67,6 +67,8 @@ public:
void applyChangesToQmlFile();
void applyChangesFromQmlFile();
QList<int> selectedItemIds() const;
signals:
void currentObjectsChanged(const QList<int> &debugIds);
void colorPickerActivated();
......@@ -80,6 +82,7 @@ protected:
virtual void messageReceived(const QByteArray &);
private:
QList<int> m_selectedItemIds;
QDeclarativeDebugConnection *m_connection;
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment