Debugger: Remove most remaining occurrences of WatchData

... in WatchHandler and DebuggerEngine interface.
Adjust using code.

Change-Id: I6371f3e96ba46a783e23a5767cdde24a10d3fce7
Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
Reviewed-by: hjk <hjk@theqtcompany.com>
This commit is contained in:
hjk
2015-03-19 12:42:53 +01:00
parent b08e5a9bc3
commit b3f88df41d
28 changed files with 468 additions and 568 deletions

View File

@@ -125,13 +125,13 @@ void QmlInspectorAgent::updateWatchData(const WatchData &data)
}
}
void QmlInspectorAgent::watchDataSelected(const WatchData *data)
void QmlInspectorAgent::watchDataSelected(quint64 id)
{
qCDebug(qmlInspectorLog) << __FUNCTION__ << '(' << data->id << ')';
qCDebug(qmlInspectorLog) << __FUNCTION__ << '(' << id << ')';
if (data->id) {
QTC_ASSERT(m_debugIdLocations.keys().contains(data->id), return);
emit jumpToObjectDefinition(m_debugIdLocations.value(data->id), data->id);
if (id) {
QTC_ASSERT(m_debugIdLocations.keys().contains(id), return);
emit jumpToObjectDefinition(m_debugIdLocations.value(id), id);
}
}
@@ -154,7 +154,7 @@ bool QmlInspectorAgent::selectObjectInTree(int debugId)
using namespace QmlDebug::Constants;
if (m_engineClient->objectName() == QLatin1String(QDECLARATIVE_ENGINE)) {
// reset current Selection
QByteArray root = m_debuggerEngine->watchHandler()->watchData(QModelIndex())->iname;
QByteArray root = m_debuggerEngine->watchHandler()->watchItem(QModelIndex())->iname;
m_debuggerEngine->watchHandler()->setCurrentItem(root);
} else {
fetchObject(debugId);
@@ -256,8 +256,8 @@ ObjectReference QmlInspectorAgent::objectForName(
const WatchHandler *watchHandler = m_debuggerEngine->watchHandler();
while (iter.hasNext()) {
iter.next();
const WatchData *wd = watchHandler->findData(iter.value());
if (wd && wd->name == objectId)
const WatchItem *item = watchHandler->findItem(iter.value());
if (item && item->name == objectId)
return ObjectReference(iter.key());
}
}
@@ -313,13 +313,11 @@ QHash<int,QString> QmlInspectorAgent::rootObjectIds() const
{
QHash<int,QString> rIds;
const WatchHandler *watchHandler = m_debuggerEngine->watchHandler();
foreach (const QByteArray &in, m_debugIdToIname) {
const WatchData *data = watchHandler->findData(in);
if (!data)
continue;
int debugId = data->id;
QString className = QLatin1String(data->type);
rIds.insert(debugId, className);
foreach (const QByteArray &iname, m_debugIdToIname) {
if (const WatchItem *item = watchHandler->findItem(iname)) {
int debugId = item->id;
rIds.insert(debugId, QLatin1String(item->type));
}
}
return rIds;
}
@@ -415,10 +413,10 @@ QString QmlInspectorAgent::displayName(int objectDebugId) const
return QString();
if (m_debugIdToIname.contains(objectDebugId)) {
const WatchData *data = m_debuggerEngine->watchHandler()->findData(
const WatchItem *item = m_debuggerEngine->watchHandler()->findItem(
m_debugIdToIname.value(objectDebugId));
QTC_ASSERT(data, return QString());
return data->name;
QTC_ASSERT(item, return QString());
return item->name;
}
return QString();
}
@@ -505,14 +503,12 @@ void QmlInspectorAgent::onValueChanged(int debugId, const QByteArray &propertyNa
const QByteArray iname = m_debugIdToIname.value(debugId) +
".[properties]." + propertyName;
WatchHandler *watchHandler = m_debuggerEngine->watchHandler();
const WatchData *data = watchHandler->findData(iname);
qCDebug(qmlInspectorLog)
<< __FUNCTION__ << '(' << debugId << ')' << iname
<< value.toString();
if (data) {
WatchData d(*data);
d.value = value.toString();
watchHandler->insertData(d);
if (WatchItem *item = watchHandler->findItem(iname)) {
item->value = value.toString();
item->update();
}
}
@@ -745,7 +741,6 @@ void QmlInspectorAgent::addWatchData(const ObjectReference &obj,
QByteArray objIname = buildIName(parentIname, objDebugId);
if (append) {
WatchData objWatch;
QString name = obj.idString();
if (name.isEmpty())
name = obj.className();
@@ -754,17 +749,16 @@ void QmlInspectorAgent::addWatchData(const ObjectReference &obj,
return;
// object
objWatch.id = objDebugId;
objWatch.exp = name.toLatin1();
objWatch.name = name;
objWatch.iname = objIname;
objWatch.type = obj.className().toLatin1();
objWatch.value = _("object");
objWatch.setHasChildren(true);
objWatch.setAllUnneeded();
auto objWatch = new WatchItem(objIname, name);
objWatch->id = objDebugId;
objWatch->exp = name.toLatin1();
objWatch->type = obj.className().toLatin1();
objWatch->value = _("object");
objWatch->wantsChildren = true;
objWatch->setAllUnneeded();
m_debuggerEngine->watchHandler()->insertData(objWatch);
addObjectWatch(objWatch.id);
m_debuggerEngine->watchHandler()->insertItem(objWatch);
addObjectWatch(objWatch->id);
if (m_debugIdToIname.contains(objDebugId)) {
// The data needs to be removed since we now know the parent and
// hence we can insert the data in the correct position
@@ -786,22 +780,22 @@ void QmlInspectorAgent::addWatchData(const ObjectReference &obj,
if (append && obj.properties().count()) {
QByteArray iname = objIname + ".[properties]";
auto propertiesWatch = new WatchItem(iname, tr("Properties"));
propertiesWatch->d.id = objDebugId;
propertiesWatch->d.value = _("list");
propertiesWatch->d.setHasChildren(true);
propertiesWatch->d.setAllUnneeded();
propertiesWatch->id = objDebugId;
propertiesWatch->value = _("list");
propertiesWatch->wantsChildren = true;
propertiesWatch->setAllUnneeded();
foreach (const PropertyReference &property, obj.properties()) {
const QString propertyName = property.name();
if (propertyName.isEmpty())
continue;
auto propertyWatch = new WatchItem(buildIName(iname, propertyName), propertyName);
propertyWatch->d.id = objDebugId;
propertyWatch->d.exp = propertyName.toLatin1();
propertyWatch->d.type = property.valueTypeName().toLatin1();
propertyWatch->d.value = property.value().toString();
propertyWatch->d.setAllUnneeded();
propertyWatch->d.setHasChildren(false);
propertyWatch->id = objDebugId;
propertyWatch->exp = propertyName.toLatin1();
propertyWatch->type = property.valueTypeName().toLatin1();
propertyWatch->value = property.value().toString();
propertyWatch->wantsChildren = false;
propertyWatch->setAllUnneeded();
propertiesWatch->appendChild(propertyWatch);
}