Commit fd66f686 authored by Christiaan Janssen's avatar Christiaan Janssen

QmlDebugger: Watchers

Reviewed-by: hjk
parent 6b123c98
......@@ -1844,6 +1844,7 @@ void DebuggerPluginPrivate::connectEngine(DebuggerEngine *engine)
m_threadBox->setModel(engine->threadsModel());
m_threadBox->setModelColumn(ThreadData::NameColumn);
m_watchersWindow->setModel(engine->watchersModel());
engine->watchHandler()->rebuildModel();
}
static void changeFontSize(QWidget *widget, qreal size)
......
......@@ -231,6 +231,8 @@ void QmlEngine::connectionEstablished()
showMessage(tr("QML Debugger connected."), StatusBar);
synchronizeWatchers();
notifyEngineRunAndInferiorRunOk();
}
......@@ -687,22 +689,29 @@ void QmlEngine::updateWatchData(const WatchData &data,
}
if (!data.name.isEmpty() && data.isChildrenNeeded()
&& watchHandler()->isExpandedIName(data.iname))
&& watchHandler()->isExpandedIName(data.iname)) {
expandObject(data.iname, data.id);
}
synchronizeWatchers();
{
if (!data.isSomethingNeeded())
watchHandler()->insertData(data);
}
void QmlEngine::synchronizeWatchers()
{
if (!watchHandler()->watcherNames().isEmpty()) {
// send watchers list
QByteArray reply;
QDataStream rs(&reply, QIODevice::WriteOnly);
QByteArray cmd = "WATCH_EXPRESSIONS";
rs << cmd;
rs << watchHandler()->watchedExpressions();
logMessage(LogSend, QString("%1 %2").arg(
QString(cmd), watchHandler()->watchedExpressions().join(", ")));
QString(cmd), watchHandler()->watchedExpressions().join(", ")));
sendMessage(reply);
}
if (!data.isSomethingNeeded())
watchHandler()->insertData(data);
}
void QmlEngine::expandObject(const QByteArray &iname, quint64 objectId)
......
......@@ -146,6 +146,8 @@ private:
const QString &oldBasePath, const QString &newBasePath) const;
QString qmlImportPath() const;
void synchronizeWatchers();
enum LogDirection {
LogSend,
LogReceive
......
......@@ -1656,5 +1656,26 @@ void WatchHandler::removeTooltip()
m_tooltips->emitAllChanged();
}
void WatchHandler::rebuildModel()
{
beginCycle();
const QList<WatchItem *> watches = m_watchers->rootItem()->children;
for (int i = watches.size() - 1; i >= 0; i--)
m_watchers->destroyItem(watches.at(i));
foreach (const QString &exp, watchedExpressions()) {
WatchData data;
data.exp = exp.toLatin1();
data.name = exp;
data.iname = watcherName(data.exp);
data.setAllUnneeded();
insertData(data);
}
endCycle();
}
} // namespace Internal
} // namespace Debugger
......@@ -163,6 +163,7 @@ public:
void loadSessionData();
void saveSessionData();
void removeTooltip();
void rebuildModel();
bool isExpandedIName(const QByteArray &iname) const
{ return m_expandedINames.contains(iname); }
......
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