From c9446f1fd5002af964e3f619e14b028a952ad198 Mon Sep 17 00:00:00 2001 From: ephy Date: Thu, 15 Apr 2010 17:25:56 +0000 Subject: [PATCH] OP-9 GCS/uavobjectbrowser: Fix problem with editing objects. git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@504 ebee16cc-31ac-478f-84a7-5cbb03baadba --- .../uavobjectbrowser/uavobjecttreemodel.cpp | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/ground/src/plugins/uavobjectbrowser/uavobjecttreemodel.cpp b/ground/src/plugins/uavobjectbrowser/uavobjecttreemodel.cpp index 7013d8146..a3d7ad0a8 100644 --- a/ground/src/plugins/uavobjectbrowser/uavobjecttreemodel.cpp +++ b/ground/src/plugins/uavobjectbrowser/uavobjecttreemodel.cpp @@ -235,17 +235,18 @@ QModelIndex UAVObjectTreeModel::index(int row, int column, const QModelIndex &pa QModelIndex UAVObjectTreeModel::index(TreeItem *item) { - QModelIndex root; if (item->parent() == 0) - root = QModelIndex(); - else - root = index(item->parent()); + return QModelIndex(); + + QModelIndex root = index(item->parent()); for (int i = 0; i < rowCount(root); ++i) { - TreeItem *parentItem = static_cast(root.child(i, 0).internalPointer()); - if (parentItem == item) - return createIndex(i, 0, item); + QModelIndex childIndex = index(i, 0, root); + TreeItem *child = static_cast(childIndex.internalPointer()); + if (child == item) + return childIndex; } + Q_ASSERT(false); return QModelIndex(); } @@ -365,7 +366,9 @@ void UAVObjectTreeModel::highlightUpdatedObject(UAVObject *obj) item->setHighlight(true); item->update(); QModelIndex itemIndex = index(item); + Q_ASSERT(itemIndex != QModelIndex()); emit dataChanged(itemIndex, itemIndex); + emit dataChanged(itemIndex.child(0, 0), itemIndex.child(rowCount(itemIndex)-1, TreeItem::dataColumn)); } ObjectTreeItem *UAVObjectTreeModel::findObjectTreeItem(UAVObject *object) @@ -419,7 +422,8 @@ DataObjectTreeItem *UAVObjectTreeModel::findDataObjectTreeItem(UAVDataObject *ob void UAVObjectTreeModel::removeHighlight(TreeItem *item) { QModelIndex itemIndex = index(item); - emit dataChanged(itemIndex, itemIndex.sibling(itemIndex.row(), item->dataColumn)); + Q_ASSERT(itemIndex != QModelIndex()); + emit dataChanged(itemIndex, itemIndex.sibling(itemIndex.row(), TreeItem::dataColumn)); }