OSDN Git Service

debugger: centralize check for changed display entries
authorhjk <qtc-committer@nokia.com>
Fri, 19 Aug 2011 14:06:31 +0000 (16:06 +0200)
committerhjk <qthjk@ovi.com>
Mon, 22 Aug 2011 16:24:38 +0000 (18:24 +0200)
Change-Id: I22c58812990925102aeeb80571bb877fd0a2924b
Reviewed-on: http://codereview.qt.nokia.com/3330
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: hjk <qthjk@ovi.com>
src/plugins/debugger/watchdata.cpp
src/plugins/debugger/watchdata.h
src/plugins/debugger/watchhandler.cpp

index 242eaf1..7a878e5 100644 (file)
@@ -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
 
index 0492f3b..15a66b0 100644 (file)
@@ -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
index 0dceeac..e6eb4a7 100644 (file)
@@ -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", "<not in scope>");
-
 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<WatchData> &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;
         }