Skip to content

Commit e215e6f

Browse files
committed
LP-567 use common timestamp when updating an object and its field
this ensures that highlihhting will be synchronized
1 parent f27258a commit e215e6f

5 files changed

Lines changed: 21 additions & 21 deletions

File tree

ground/gcs/src/plugins/uavobjectbrowser/fieldtreeitem.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class FieldTreeItem : public TreeItem {
7878
TreeItem::setData(value, column);
7979
}
8080

81-
void update()
81+
void update(const QTime &ts)
8282
{
8383
bool updated = false;
8484

@@ -90,7 +90,7 @@ class FieldTreeItem : public TreeItem {
9090
}
9191
}
9292
if (changed() || updated) {
93-
setHighlighted(true);
93+
setHighlighted(true, ts);
9494
}
9595
}
9696

ground/gcs/src/plugins/uavobjectbrowser/treeitem.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -238,10 +238,10 @@ void TreeItem::setData(QVariant value, int column)
238238
m_itemData.replace(column, value);
239239
}
240240

241-
void TreeItem::update()
241+
void TreeItem::update(const QTime &ts)
242242
{
243243
foreach(TreeItem * child, children()) {
244-
child->update();
244+
child->update(ts);
245245
}
246246
}
247247

@@ -255,7 +255,7 @@ void TreeItem::apply()
255255
/*
256256
* Called after a value has changed to trigger highlighting of tree item.
257257
*/
258-
void TreeItem::setHighlighted(bool highlighted)
258+
void TreeItem::setHighlighted(bool highlighted, const QTime &ts)
259259
{
260260
m_changed = false;
261261
if (m_highlighted != highlighted) {
@@ -264,7 +264,7 @@ void TreeItem::setHighlighted(bool highlighted)
264264
// Add to highlight manager
265265
m_highlightManager->add(this);
266266
// Update expiration timeout
267-
m_highlightExpires = QTime::currentTime().addMSecs(m_highlightTimeMs);
267+
m_highlightExpires = ts.addMSecs(m_highlightTimeMs);
268268
// start expiration timer if necessary
269269
m_highlightManager->startTimer(m_highlightExpires);
270270
} else {
@@ -276,8 +276,7 @@ void TreeItem::setHighlighted(bool highlighted)
276276
// This will ensure that the root of a leaf that is changed also is highlighted.
277277
// Only updates that really changes values will trigger highlight of parents.
278278
if (m_parentItem) {
279-
// FIXME: need to pass m_highlightExpires
280-
m_parentItem->setHighlighted(highlighted);
279+
m_parentItem->setHighlighted(highlighted, ts);
281280
}
282281
}
283282

ground/gcs/src/plugins/uavobjectbrowser/treeitem.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ class TreeItem {
139139
return false;
140140
}
141141

142-
virtual void update();
142+
virtual void update(const QTime &ts);
143143
virtual void apply();
144144

145145
bool changed() const
@@ -157,7 +157,7 @@ class TreeItem {
157157
return m_highlighted;
158158
}
159159

160-
void setHighlighted(bool highlighted);
160+
void setHighlighted(bool highlighted, const QTime &ts);
161161

162162
static void setHighlightTime(int time)
163163
{
@@ -275,13 +275,13 @@ class DataObjectTreeItem : public ObjectTreeItem {
275275
}
276276
}
277277

278-
virtual void update()
278+
virtual void update(const QTime &ts)
279279
{
280280
foreach(TreeItem * child, children()) {
281281
MetaObjectTreeItem *metaChild = dynamic_cast<MetaObjectTreeItem *>(child);
282282

283283
if (!metaChild) {
284-
child->update();
284+
child->update(ts);
285285
}
286286
}
287287
}
@@ -301,14 +301,14 @@ class InstanceTreeItem : public DataObjectTreeItem {
301301
DataObjectTreeItem(object, data)
302302
{}
303303

304-
virtual void apply()
304+
virtual void update(const QTime &ts)
305305
{
306-
TreeItem::apply();
306+
TreeItem::update(ts);
307307
}
308308

309-
virtual void update()
309+
virtual void apply()
310310
{
311-
TreeItem::update();
311+
TreeItem::apply();
312312
}
313313
};
314314

ground/gcs/src/plugins/uavobjectbrowser/uavobjectbrowserwidget.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,10 @@ class UAVObjectBrowserWidget : public QWidget {
7979
m_recentlyUpdatedTimeout = timeout;
8080
m_model->setRecentlyUpdatedTimeout(timeout);
8181
}
82-
void setOnlyHighlightChangedValues(bool hilight)
82+
void setOnlyHighlightChangedValues(bool highlight)
8383
{
84-
m_onlyHighlightChangedValues = hilight;
85-
m_model->setOnlyHighlightChangedValues(hilight);
84+
m_onlyHighlightChangedValues = highlight;
85+
m_model->setOnlyHighlightChangedValues(highlight);
8686
}
8787
void setViewOptions(bool showCategories, bool showMetadata, bool useScientificNotation, bool showDescription);
8888
void setSplitterState(QByteArray state);

ground/gcs/src/plugins/uavobjectbrowser/uavobjecttreemodel.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -634,9 +634,10 @@ void UAVObjectTreeModel::updateObject(UAVObject *obj)
634634
ObjectTreeItem *item = findObjectTreeItem(obj->getObjID());
635635
Q_ASSERT(item);
636636
// TODO don't update meta object if they are not shown
637-
item->update();
637+
QTime ts = QTime::currentTime();
638+
item->update(ts);
638639
if (!onlyHighlightChangedValues()) {
639-
item->setHighlighted(true);
640+
item->setHighlighted(true, ts);
640641
}
641642
}
642643

0 commit comments

Comments
 (0)