forked from qt-creator/qt-creator
update object tree when unknown debug id is received
This commit is contained in:
committed by
Olivier Goffart
parent
6532fe5c28
commit
4a4fc8584f
@@ -66,8 +66,8 @@ bool ClientProxy::connectToViewer(const QString &host, quint16 port)
|
|||||||
|
|
||||||
if (m_designClient) {
|
if (m_designClient) {
|
||||||
|
|
||||||
disconnect(m_designClient, SIGNAL(currentObjectsChanged(QList<QDeclarativeDebugObjectReference>)),
|
disconnect(m_designClient, SIGNAL(currentObjectsChanged(QList<int>)),
|
||||||
this, SIGNAL(selectedItemsChanged(QList<QDeclarativeDebugObjectReference>)));
|
this, SLOT(onCurrentObjectsChanged(QList<int>)));
|
||||||
disconnect(m_designClient,
|
disconnect(m_designClient,
|
||||||
SIGNAL(colorPickerActivated()), this, SIGNAL(colorPickerActivated()));
|
SIGNAL(colorPickerActivated()), this, SIGNAL(colorPickerActivated()));
|
||||||
disconnect(m_designClient,
|
disconnect(m_designClient,
|
||||||
@@ -113,6 +113,37 @@ bool ClientProxy::connectToViewer(const QString &host, quint16 port)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ClientProxy::onCurrentObjectsChanged(const QList<int> &debugIds)
|
||||||
|
{
|
||||||
|
QList<QDeclarativeDebugObjectReference> selectedItems;
|
||||||
|
|
||||||
|
foreach(int debugId, debugIds) {
|
||||||
|
QDeclarativeDebugObjectReference ref = objectReferenceForId(debugId);
|
||||||
|
if (ref.debugId() != -1) {
|
||||||
|
selectedItems << ref;
|
||||||
|
} else {
|
||||||
|
// ### FIXME right now, there's no way in the protocol to
|
||||||
|
// a) get some item and know its parent (although that's possible by adding it to a separate plugin)
|
||||||
|
// b) add children to part of an existing tree.
|
||||||
|
// 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);
|
||||||
|
}
|
||||||
|
|
||||||
void ClientProxy::disconnectFromViewer()
|
void ClientProxy::disconnectFromViewer()
|
||||||
{
|
{
|
||||||
m_conn->disconnectFromHost();
|
m_conn->disconnectFromHost();
|
||||||
@@ -162,8 +193,8 @@ void ClientProxy::connectionStateChanged()
|
|||||||
emit connected(m_client);
|
emit connected(m_client);
|
||||||
|
|
||||||
connect(m_designClient,
|
connect(m_designClient,
|
||||||
SIGNAL(currentObjectsChanged(QList<QDeclarativeDebugObjectReference>)),
|
SIGNAL(currentObjectsChanged(QList<int>)),
|
||||||
SIGNAL(selectedItemsChanged(QList<QDeclarativeDebugObjectReference>)));
|
SLOT(onCurrentObjectsChanged(QList<int>)));
|
||||||
connect(m_designClient,
|
connect(m_designClient,
|
||||||
SIGNAL(colorPickerActivated()), SIGNAL(colorPickerActivated()));
|
SIGNAL(colorPickerActivated()), SIGNAL(colorPickerActivated()));
|
||||||
connect(m_designClient,
|
connect(m_designClient,
|
||||||
|
|||||||
@@ -112,6 +112,7 @@ private slots:
|
|||||||
void connectionStateChanged();
|
void connectionStateChanged();
|
||||||
void connectionError();
|
void connectionError();
|
||||||
|
|
||||||
|
void onCurrentObjectsChanged(const QList<int> &debugIds);
|
||||||
void updateEngineList();
|
void updateEngineList();
|
||||||
void objectTreeFetched(QDeclarativeDebugQuery::State state = QDeclarativeDebugQuery::Completed);
|
void objectTreeFetched(QDeclarativeDebugQuery::State state = QDeclarativeDebugQuery::Completed);
|
||||||
|
|
||||||
|
|||||||
@@ -61,21 +61,20 @@ void QmlJSDesignDebugClient::messageReceived(const QByteArray &message)
|
|||||||
QByteArray type;
|
QByteArray type;
|
||||||
ds >> type;
|
ds >> type;
|
||||||
|
|
||||||
QList<QDeclarativeDebugObjectReference> references;
|
|
||||||
|
|
||||||
if (type == "CURRENT_OBJECTS_CHANGED") {
|
if (type == "CURRENT_OBJECTS_CHANGED") {
|
||||||
int objectCount;
|
int objectCount;
|
||||||
ds >> objectCount;
|
ds >> objectCount;
|
||||||
|
QList<int> debugIds;
|
||||||
|
|
||||||
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) {
|
||||||
QDeclarativeDebugObjectReference ref = ClientProxy::instance()->objectReferenceForId(debugId);
|
debugIds << debugId;
|
||||||
if (ref.debugId() != -1)
|
|
||||||
references << ref;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
emit currentObjectsChanged(references);
|
|
||||||
|
emit currentObjectsChanged(debugIds);
|
||||||
} else if (type == "TOOL_CHANGED") {
|
} else if (type == "TOOL_CHANGED") {
|
||||||
int toolId;
|
int toolId;
|
||||||
ds >> toolId;
|
ds >> toolId;
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ public:
|
|||||||
void applyChangesFromQmlFile();
|
void applyChangesFromQmlFile();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void currentObjectsChanged(const QList<QDeclarativeDebugObjectReference> ¤tObjects);
|
void currentObjectsChanged(const QList<int> &debugIds);
|
||||||
void colorPickerActivated();
|
void colorPickerActivated();
|
||||||
void selectToolActivated();
|
void selectToolActivated();
|
||||||
void selectMarqueeToolActivated();
|
void selectMarqueeToolActivated();
|
||||||
|
|||||||
@@ -143,6 +143,7 @@ void QmlJSLiveTextPreview::documentChanged(QmlJS::Document::Ptr doc)
|
|||||||
if (doc && m_previousDoc && doc->fileName() == m_previousDoc->fileName() && doc->qmlProgram() && m_previousDoc->qmlProgram()) {
|
if (doc && m_previousDoc && doc->fileName() == m_previousDoc->fileName() && doc->qmlProgram() && m_previousDoc->qmlProgram()) {
|
||||||
if (m_debugIds.isEmpty())
|
if (m_debugIds.isEmpty())
|
||||||
m_debugIds = m_initialTable.value(doc->fileName());
|
m_debugIds = m_initialTable.value(doc->fileName());
|
||||||
|
|
||||||
Delta delta;
|
Delta delta;
|
||||||
m_debugIds = delta(m_previousDoc, doc, m_debugIds);
|
m_debugIds = delta(m_previousDoc, doc, m_debugIds);
|
||||||
|
|
||||||
|
|||||||
@@ -68,20 +68,12 @@ void SelectionIndicator::clear()
|
|||||||
m_indicatorShapeHash.clear();
|
m_indicatorShapeHash.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
//static void alignVertices(QPolygonF &polygon, double factor)
|
|
||||||
//{
|
|
||||||
// QMutableVectorIterator<QPointF> iterator(polygon);
|
|
||||||
// while (iterator.hasNext()) {
|
|
||||||
// QPointF &vertex = iterator.next();
|
|
||||||
// vertex.setX(std::floor(vertex.x()) + factor);
|
|
||||||
// vertex.setY(std::floor(vertex.y()) + factor);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//}
|
|
||||||
|
|
||||||
QPolygonF SelectionIndicator::addBoundingRectToPolygon(QGraphicsItem *item, QPolygonF &polygon)
|
QPolygonF SelectionIndicator::addBoundingRectToPolygon(QGraphicsItem *item, QPolygonF &polygon)
|
||||||
{
|
{
|
||||||
|
// ### remove this if statement when QTBUG-12172 gets fixed
|
||||||
|
if (item->boundingRect() != QRectF(0,0,0,0))
|
||||||
polygon = polygon.united(item->mapToScene(item->boundingRect()));
|
polygon = polygon.united(item->mapToScene(item->boundingRect()));
|
||||||
|
|
||||||
foreach(QGraphicsItem *child, item->childItems()) {
|
foreach(QGraphicsItem *child, item->childItems()) {
|
||||||
if (!m_view->isEditorItem(child))
|
if (!m_view->isEditorItem(child))
|
||||||
addBoundingRectToPolygon(child, polygon);
|
addBoundingRectToPolygon(child, polygon);
|
||||||
@@ -104,7 +96,6 @@ void SelectionIndicator::setItems(const QList<QGraphicsObject*> &itemList)
|
|||||||
|
|
||||||
QPolygonF boundingRectInLayerItemSpace = m_layerItem->mapFromScene(boundingShapeInSceneSpace);
|
QPolygonF boundingRectInLayerItemSpace = m_layerItem->mapFromScene(boundingShapeInSceneSpace);
|
||||||
|
|
||||||
|
|
||||||
QPen pen;
|
QPen pen;
|
||||||
pen.setColor(QColor(108, 141, 221));
|
pen.setColor(QColor(108, 141, 221));
|
||||||
newSelectionIndicatorGraphicsItem->setData(Constants::EditorItemDataKey, QVariant(true));
|
newSelectionIndicatorGraphicsItem->setData(Constants::EditorItemDataKey, QVariant(true));
|
||||||
|
|||||||
@@ -120,11 +120,8 @@ void QDeclarativeDesignView::mouseReleaseEvent(QMouseEvent *event)
|
|||||||
m_cursorPos = event->pos();
|
m_cursorPos = event->pos();
|
||||||
m_currentTool->mouseReleaseEvent(event);
|
m_currentTool->mouseReleaseEvent(event);
|
||||||
|
|
||||||
if (event->buttons() & Qt::LeftButton) {
|
|
||||||
qDebug() << "setting current objects";
|
|
||||||
qmlDesignDebugServer()->setCurrentObjects(AbstractFormEditorTool::toObjectList(selectedItems()));
|
qmlDesignDebugServer()->setCurrentObjects(AbstractFormEditorTool::toObjectList(selectedItems()));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void QDeclarativeDesignView::keyPressEvent(QKeyEvent *event)
|
void QDeclarativeDesignView::keyPressEvent(QKeyEvent *event)
|
||||||
{
|
{
|
||||||
@@ -447,17 +444,18 @@ QList<QGraphicsItem*> QDeclarativeDesignView::filterForCurrentContext(QList<QGra
|
|||||||
foreach(QGraphicsItem *item, itemlist) {
|
foreach(QGraphicsItem *item, itemlist) {
|
||||||
|
|
||||||
if (isEditorItem(item) || !m_subcomponentEditorTool->isDirectChildOfContext(item)) {
|
if (isEditorItem(item) || !m_subcomponentEditorTool->isDirectChildOfContext(item)) {
|
||||||
int index = itemlist.indexOf(item);
|
|
||||||
|
|
||||||
// if we're a child, but not directly, replace with the parent that is directly in context.
|
// if we're a child, but not directly, replace with the parent that is directly in context.
|
||||||
if (QGraphicsItem *contextParent = m_subcomponentEditorTool->firstChildOfContext(item)) {
|
if (QGraphicsItem *contextParent = m_subcomponentEditorTool->firstChildOfContext(item)) {
|
||||||
if (index >= 0) {
|
if (contextParent != item) {
|
||||||
itemlist.replace(index, contextParent);
|
if (itemlist.contains(contextParent)) {
|
||||||
|
itemlist.removeOne(item);
|
||||||
} else {
|
} else {
|
||||||
itemlist.append(contextParent);
|
itemlist.replace(itemlist.indexOf(item), contextParent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
itemlist.removeAt(index);
|
itemlist.removeOne(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user