forked from qt-creator/qt-creator
Updating selection after new tree is fetched & code cleanup
This commit is contained in:
@@ -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.
|
// So the only choice that remains is to update the complete tree when we have an unknown debug id.
|
||||||
if (!m_objectTreeQuery) {
|
if (!m_objectTreeQuery) {
|
||||||
m_objectTreeQuery = m_client->queryObjectRecursive(m_rootObject, this);
|
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()
|
void ClientProxy::disconnectFromViewer()
|
||||||
@@ -358,49 +360,58 @@ void ClientProxy::objectTreeFetched(QDeclarativeDebugQuery::State state)
|
|||||||
m_objectTreeQuery = 0;
|
m_objectTreeQuery = 0;
|
||||||
|
|
||||||
emit objectTreeUpdated(m_rootObject);
|
emit objectTreeUpdated(m_rootObject);
|
||||||
|
|
||||||
|
if (isDesignClientConnected() && !m_designClient->selectedItemIds().isEmpty()) {
|
||||||
|
onCurrentObjectsChanged(m_designClient->selectedItemIds());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientProxy::reloadQmlViewer()
|
void ClientProxy::reloadQmlViewer()
|
||||||
{
|
{
|
||||||
if (m_designClient && m_conn->isConnected())
|
if (isDesignClientConnected())
|
||||||
m_designClient->reloadViewer();
|
m_designClient->reloadViewer();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientProxy::setDesignModeBehavior(bool inDesignMode)
|
void ClientProxy::setDesignModeBehavior(bool inDesignMode)
|
||||||
{
|
{
|
||||||
if (m_designClient && m_conn->isConnected())
|
if (isDesignClientConnected())
|
||||||
m_designClient->setDesignModeBehavior(inDesignMode);
|
m_designClient->setDesignModeBehavior(inDesignMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientProxy::setAnimationSpeed(qreal slowdownFactor)
|
void ClientProxy::setAnimationSpeed(qreal slowdownFactor)
|
||||||
{
|
{
|
||||||
if (m_designClient && m_conn->isConnected())
|
if (isDesignClientConnected())
|
||||||
m_designClient->setAnimationSpeed(slowdownFactor);
|
m_designClient->setAnimationSpeed(slowdownFactor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientProxy::changeToColorPickerTool()
|
void ClientProxy::changeToColorPickerTool()
|
||||||
{
|
{
|
||||||
if (m_designClient && m_conn->isConnected())
|
if (isDesignClientConnected())
|
||||||
m_designClient->changeToColorPickerTool();
|
m_designClient->changeToColorPickerTool();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientProxy::changeToZoomTool()
|
void ClientProxy::changeToZoomTool()
|
||||||
{
|
{
|
||||||
if (m_designClient && m_conn->isConnected())
|
if (isDesignClientConnected())
|
||||||
m_designClient->changeToZoomTool();
|
m_designClient->changeToZoomTool();
|
||||||
}
|
}
|
||||||
void ClientProxy::changeToSelectTool()
|
void ClientProxy::changeToSelectTool()
|
||||||
{
|
{
|
||||||
if (m_designClient && m_conn->isConnected())
|
if (isDesignClientConnected())
|
||||||
m_designClient->changeToSelectTool();
|
m_designClient->changeToSelectTool();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientProxy::changeToSelectMarqueeTool()
|
void ClientProxy::changeToSelectMarqueeTool()
|
||||||
{
|
{
|
||||||
if (m_designClient && m_conn->isConnected())
|
if (isDesignClientConnected())
|
||||||
m_designClient->changeToSelectMarqueeTool();
|
m_designClient->changeToSelectMarqueeTool();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ClientProxy::isDesignClientConnected() const
|
||||||
|
{
|
||||||
|
return (m_designClient && m_conn->isConnected());
|
||||||
|
}
|
||||||
|
|
||||||
void ClientProxy::reloadEngines()
|
void ClientProxy::reloadEngines()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -117,6 +117,7 @@ private slots:
|
|||||||
void objectTreeFetched(QDeclarativeDebugQuery::State state = QDeclarativeDebugQuery::Completed);
|
void objectTreeFetched(QDeclarativeDebugQuery::State state = QDeclarativeDebugQuery::Completed);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool isDesignClientConnected() const;
|
||||||
void reloadEngines();
|
void reloadEngines();
|
||||||
QList<QDeclarativeDebugObjectReference> objectReferences(const QUrl &url, const QDeclarativeDebugObjectReference &objectRef) const;
|
QList<QDeclarativeDebugObjectReference> objectReferences(const QUrl &url, const QDeclarativeDebugObjectReference &objectRef) const;
|
||||||
QDeclarativeDebugObjectReference objectReferenceForId(int debugId, const QDeclarativeDebugObjectReference &ref) const;
|
QDeclarativeDebugObjectReference objectReferenceForId(int debugId, const QDeclarativeDebugObjectReference &ref) const;
|
||||||
|
|||||||
@@ -64,17 +64,17 @@ void QmlJSDesignDebugClient::messageReceived(const QByteArray &message)
|
|||||||
if (type == "CURRENT_OBJECTS_CHANGED") {
|
if (type == "CURRENT_OBJECTS_CHANGED") {
|
||||||
int objectCount;
|
int objectCount;
|
||||||
ds >> objectCount;
|
ds >> objectCount;
|
||||||
QList<int> debugIds;
|
m_selectedItemIds.clear();
|
||||||
|
|
||||||
for(int i = 0; i < objectCount; ++i) {
|
for(int i = 0; i < objectCount; ++i) {
|
||||||
int debugId;
|
int debugId;
|
||||||
ds >> debugId;
|
ds >> debugId;
|
||||||
if (debugId != -1) {
|
if (debugId != -1) {
|
||||||
debugIds << debugId;
|
m_selectedItemIds << debugId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
emit currentObjectsChanged(debugIds);
|
emit currentObjectsChanged(m_selectedItemIds);
|
||||||
} else if (type == "TOOL_CHANGED") {
|
} else if (type == "TOOL_CHANGED") {
|
||||||
int toolId;
|
int toolId;
|
||||||
ds >> 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)
|
void QmlJSDesignDebugClient::setSelectedItemsByObjectId(const QList<QDeclarativeDebugObjectReference> &objects)
|
||||||
{
|
{
|
||||||
if (!m_connection || !m_connection->isConnected())
|
if (!m_connection || !m_connection->isConnected())
|
||||||
|
|||||||
@@ -67,6 +67,8 @@ public:
|
|||||||
void applyChangesToQmlFile();
|
void applyChangesToQmlFile();
|
||||||
void applyChangesFromQmlFile();
|
void applyChangesFromQmlFile();
|
||||||
|
|
||||||
|
QList<int> selectedItemIds() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void currentObjectsChanged(const QList<int> &debugIds);
|
void currentObjectsChanged(const QList<int> &debugIds);
|
||||||
void colorPickerActivated();
|
void colorPickerActivated();
|
||||||
@@ -80,6 +82,7 @@ protected:
|
|||||||
virtual void messageReceived(const QByteArray &);
|
virtual void messageReceived(const QByteArray &);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
QList<int> m_selectedItemIds;
|
||||||
QDeclarativeDebugConnection *m_connection;
|
QDeclarativeDebugConnection *m_connection;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user