From 53453a23809d141b79a93678902f67f189f94ccf Mon Sep 17 00:00:00 2001 From: hjk Date: Fri, 19 Aug 2011 16:06:31 +0200 Subject: [PATCH] debugger: centralize check for changed display entries Change-Id: I22c58812990925102aeeb80571bb877fd0a2924b Reviewed-on: http://codereview.qt.nokia.com/3330 Reviewed-by: Qt Sanity Bot Reviewed-by: hjk --- src/plugins/debugger/watchdata.cpp | 8 ++++++-- src/plugins/debugger/watchdata.h | 1 + src/plugins/debugger/watchhandler.cpp | 13 ++----------- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/src/plugins/debugger/watchdata.cpp b/src/plugins/debugger/watchdata.cpp index 242eaf1b49..7a878e5d18 100644 --- a/src/plugins/debugger/watchdata.cpp +++ b/src/plugins/debugger/watchdata.cpp @@ -383,8 +383,7 @@ QString WatchData::toToolTip() const formatToolTipRow(str, tr("Referencing Address"), QString::fromAscii(hexReferencingAddress())); if (size) - formatToolTipRow(str, tr("Size"), - QString::number(size)); + formatToolTipRow(str, tr("Size"), QString::number(size)); formatToolTipRow(str, tr("Internal ID"), iname); formatToolTipRow(str, tr("Generation"), QString::number(generation)); @@ -437,6 +436,11 @@ QByteArray WatchData::hexReferencingAddress() const return QByteArray(); } +bool WatchData::hasChanged(const WatchData &old) const +{ + return !value.isEmpty() && value != old.value && value != msgNotInScope(); +} + } // namespace Internal } // namespace Debugger diff --git a/src/plugins/debugger/watchdata.h b/src/plugins/debugger/watchdata.h index 0492f3b9a4..15a66b08f5 100644 --- a/src/plugins/debugger/watchdata.h +++ b/src/plugins/debugger/watchdata.h @@ -113,6 +113,7 @@ public: quint64 coreAddress() const; QByteArray hexAddress() const; QByteArray hexReferencingAddress() const; + bool hasChanged(const WatchData &old) const; public: quint64 id; // Token for the engine for internal mapping diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp index 0dceeacb4f..e6eb4a7e53 100644 --- a/src/plugins/debugger/watchhandler.cpp +++ b/src/plugins/debugger/watchhandler.cpp @@ -71,9 +71,6 @@ enum { debugModel = 0 }; #define MODEL_DEBUG(s) do { if (debugModel) qDebug() << s; } while (0) #define MODEL_DEBUGX(s) qDebug() << s -static const QString strNotInScope = - QCoreApplication::translate("Debugger::Internal::WatchData", ""); - static int watcherCounter = 0; static int generationCounter = 0; @@ -1008,11 +1005,8 @@ void WatchModel::insertData(const WatchData &data) if (WatchItem *oldItem = findItem(data.iname, parent)) { bool hadChildren = oldItem->hasChildren; // Overwrite old entry. - bool changed = !data.value.isEmpty() - && data.value != oldItem->value - && data.value != strNotInScope; oldItem->setData(data); - oldItem->changed = changed; + oldItem->changed = data.hasChanged(*oldItem); oldItem->generation = generationCounter; QModelIndex idx = watchIndex(oldItem); emit dataChanged(idx, idx.sibling(idx.row(), 2)); @@ -1096,10 +1090,7 @@ void WatchModel::insertBulkData(const QList &list) data.generation = generationCounter; newList.insert(oldSortKey, data); } else { - bool changed = !it->value.isEmpty() - && it->value != oldItem->value - && it->value != strNotInScope; - it->changed = changed; + it->changed = it->hasChanged(*oldItem); if (it->generation == -1) it->generation = generationCounter; } -- 2.11.0