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) {
|
||||
|
||||
disconnect(m_designClient, SIGNAL(currentObjectsChanged(QList<QDeclarativeDebugObjectReference>)),
|
||||
this, SIGNAL(selectedItemsChanged(QList<QDeclarativeDebugObjectReference>)));
|
||||
disconnect(m_designClient, SIGNAL(currentObjectsChanged(QList<int>)),
|
||||
this, SLOT(onCurrentObjectsChanged(QList<int>)));
|
||||
disconnect(m_designClient,
|
||||
SIGNAL(colorPickerActivated()), this, SIGNAL(colorPickerActivated()));
|
||||
disconnect(m_designClient,
|
||||
@@ -113,6 +113,37 @@ bool ClientProxy::connectToViewer(const QString &host, quint16 port)
|
||||
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()
|
||||
{
|
||||
m_conn->disconnectFromHost();
|
||||
@@ -162,8 +193,8 @@ void ClientProxy::connectionStateChanged()
|
||||
emit connected(m_client);
|
||||
|
||||
connect(m_designClient,
|
||||
SIGNAL(currentObjectsChanged(QList<QDeclarativeDebugObjectReference>)),
|
||||
SIGNAL(selectedItemsChanged(QList<QDeclarativeDebugObjectReference>)));
|
||||
SIGNAL(currentObjectsChanged(QList<int>)),
|
||||
SLOT(onCurrentObjectsChanged(QList<int>)));
|
||||
connect(m_designClient,
|
||||
SIGNAL(colorPickerActivated()), SIGNAL(colorPickerActivated()));
|
||||
connect(m_designClient,
|
||||
|
||||
@@ -112,6 +112,7 @@ private slots:
|
||||
void connectionStateChanged();
|
||||
void connectionError();
|
||||
|
||||
void onCurrentObjectsChanged(const QList<int> &debugIds);
|
||||
void updateEngineList();
|
||||
void objectTreeFetched(QDeclarativeDebugQuery::State state = QDeclarativeDebugQuery::Completed);
|
||||
|
||||
|
||||
@@ -61,21 +61,20 @@ void QmlJSDesignDebugClient::messageReceived(const QByteArray &message)
|
||||
QByteArray type;
|
||||
ds >> type;
|
||||
|
||||
QList<QDeclarativeDebugObjectReference> references;
|
||||
|
||||
if (type == "CURRENT_OBJECTS_CHANGED") {
|
||||
int objectCount;
|
||||
ds >> objectCount;
|
||||
QList<int> debugIds;
|
||||
|
||||
for(int i = 0; i < objectCount; ++i) {
|
||||
int debugId;
|
||||
ds >> debugId;
|
||||
if (debugId != -1) {
|
||||
QDeclarativeDebugObjectReference ref = ClientProxy::instance()->objectReferenceForId(debugId);
|
||||
if (ref.debugId() != -1)
|
||||
references << ref;
|
||||
debugIds << debugId;
|
||||
}
|
||||
}
|
||||
emit currentObjectsChanged(references);
|
||||
|
||||
emit currentObjectsChanged(debugIds);
|
||||
} else if (type == "TOOL_CHANGED") {
|
||||
int toolId;
|
||||
ds >> toolId;
|
||||
|
||||
@@ -68,7 +68,7 @@ public:
|
||||
void applyChangesFromQmlFile();
|
||||
|
||||
signals:
|
||||
void currentObjectsChanged(const QList<QDeclarativeDebugObjectReference> ¤tObjects);
|
||||
void currentObjectsChanged(const QList<int> &debugIds);
|
||||
void colorPickerActivated();
|
||||
void selectToolActivated();
|
||||
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 (m_debugIds.isEmpty())
|
||||
m_debugIds = m_initialTable.value(doc->fileName());
|
||||
|
||||
Delta delta;
|
||||
m_debugIds = delta(m_previousDoc, doc, m_debugIds);
|
||||
|
||||
|
||||
@@ -68,20 +68,12 @@ void SelectionIndicator::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)
|
||||
{
|
||||
// ### remove this if statement when QTBUG-12172 gets fixed
|
||||
if (item->boundingRect() != QRectF(0,0,0,0))
|
||||
polygon = polygon.united(item->mapToScene(item->boundingRect()));
|
||||
|
||||
foreach(QGraphicsItem *child, item->childItems()) {
|
||||
if (!m_view->isEditorItem(child))
|
||||
addBoundingRectToPolygon(child, polygon);
|
||||
@@ -104,7 +96,6 @@ void SelectionIndicator::setItems(const QList<QGraphicsObject*> &itemList)
|
||||
|
||||
QPolygonF boundingRectInLayerItemSpace = m_layerItem->mapFromScene(boundingShapeInSceneSpace);
|
||||
|
||||
|
||||
QPen pen;
|
||||
pen.setColor(QColor(108, 141, 221));
|
||||
newSelectionIndicatorGraphicsItem->setData(Constants::EditorItemDataKey, QVariant(true));
|
||||
|
||||
@@ -120,11 +120,8 @@ void QDeclarativeDesignView::mouseReleaseEvent(QMouseEvent *event)
|
||||
m_cursorPos = event->pos();
|
||||
m_currentTool->mouseReleaseEvent(event);
|
||||
|
||||
if (event->buttons() & Qt::LeftButton) {
|
||||
qDebug() << "setting current objects";
|
||||
qmlDesignDebugServer()->setCurrentObjects(AbstractFormEditorTool::toObjectList(selectedItems()));
|
||||
}
|
||||
}
|
||||
|
||||
void QDeclarativeDesignView::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
@@ -447,17 +444,18 @@ QList<QGraphicsItem*> QDeclarativeDesignView::filterForCurrentContext(QList<QGra
|
||||
foreach(QGraphicsItem *item, itemlist) {
|
||||
|
||||
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 (QGraphicsItem *contextParent = m_subcomponentEditorTool->firstChildOfContext(item)) {
|
||||
if (index >= 0) {
|
||||
itemlist.replace(index, contextParent);
|
||||
if (contextParent != item) {
|
||||
if (itemlist.contains(contextParent)) {
|
||||
itemlist.removeOne(item);
|
||||
} else {
|
||||
itemlist.append(contextParent);
|
||||
itemlist.replace(itemlist.indexOf(item), contextParent);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
itemlist.removeAt(index);
|
||||
itemlist.removeOne(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user