1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-11-29 07:24:13 +01:00

LP-567 use common timestamp when updating an object and its field

this ensures that highlihhting will be synchronized
This commit is contained in:
Philippe Renon 2018-03-25 19:32:18 +02:00
parent f27258a598
commit e215e6fd2e
5 changed files with 22 additions and 22 deletions

View File

@ -78,7 +78,7 @@ public:
TreeItem::setData(value, column);
}
void update()
void update(const QTime &ts)
{
bool updated = false;
@ -90,7 +90,7 @@ public:
}
}
if (changed() || updated) {
setHighlighted(true);
setHighlighted(true, ts);
}
}

View File

@ -238,10 +238,10 @@ void TreeItem::setData(QVariant value, int column)
m_itemData.replace(column, value);
}
void TreeItem::update()
void TreeItem::update(const QTime &ts)
{
foreach(TreeItem * child, children()) {
child->update();
child->update(ts);
}
}
@ -255,7 +255,7 @@ void TreeItem::apply()
/*
* Called after a value has changed to trigger highlighting of tree item.
*/
void TreeItem::setHighlighted(bool highlighted)
void TreeItem::setHighlighted(bool highlighted, const QTime &ts)
{
m_changed = false;
if (m_highlighted != highlighted) {
@ -264,7 +264,7 @@ void TreeItem::setHighlighted(bool highlighted)
// Add to highlight manager
m_highlightManager->add(this);
// Update expiration timeout
m_highlightExpires = QTime::currentTime().addMSecs(m_highlightTimeMs);
m_highlightExpires = ts.addMSecs(m_highlightTimeMs);
// start expiration timer if necessary
m_highlightManager->startTimer(m_highlightExpires);
} else {
@ -276,8 +276,7 @@ void TreeItem::setHighlighted(bool highlighted)
// This will ensure that the root of a leaf that is changed also is highlighted.
// Only updates that really changes values will trigger highlight of parents.
if (m_parentItem) {
// FIXME: need to pass m_highlightExpires
m_parentItem->setHighlighted(highlighted);
m_parentItem->setHighlighted(highlighted, ts);
}
}

View File

@ -139,7 +139,7 @@ public:
return false;
}
virtual void update();
virtual void update(const QTime &ts);
virtual void apply();
bool changed() const
@ -157,7 +157,7 @@ public:
return m_highlighted;
}
void setHighlighted(bool highlighted);
void setHighlighted(bool highlighted, const QTime &ts);
static void setHighlightTime(int time)
{
@ -275,13 +275,13 @@ public:
}
}
virtual void update()
virtual void update(const QTime &ts)
{
foreach(TreeItem * child, children()) {
MetaObjectTreeItem *metaChild = dynamic_cast<MetaObjectTreeItem *>(child);
if (!metaChild) {
child->update();
child->update(ts);
}
}
}
@ -301,15 +301,15 @@ public:
DataObjectTreeItem(object, data)
{}
virtual void update(const QTime &ts)
{
TreeItem::update(ts);
}
virtual void apply()
{
TreeItem::apply();
}
virtual void update()
{
TreeItem::update();
}
};
class ArrayFieldTreeItem : public TreeItem {

View File

@ -79,10 +79,10 @@ public:
m_recentlyUpdatedTimeout = timeout;
m_model->setRecentlyUpdatedTimeout(timeout);
}
void setOnlyHighlightChangedValues(bool hilight)
void setOnlyHighlightChangedValues(bool highlight)
{
m_onlyHighlightChangedValues = hilight;
m_model->setOnlyHighlightChangedValues(hilight);
m_onlyHighlightChangedValues = highlight;
m_model->setOnlyHighlightChangedValues(highlight);
}
void setViewOptions(bool showCategories, bool showMetadata, bool useScientificNotation, bool showDescription);
void setSplitterState(QByteArray state);

View File

@ -634,9 +634,10 @@ void UAVObjectTreeModel::updateObject(UAVObject *obj)
ObjectTreeItem *item = findObjectTreeItem(obj->getObjID());
Q_ASSERT(item);
// TODO don't update meta object if they are not shown
item->update();
QTime ts = QTime::currentTime();
item->update(ts);
if (!onlyHighlightChangedValues()) {
item->setHighlighted(true);
item->setHighlighted(true, ts);
}
}