------------------------------------------------------------------------------
| 3850 | |
| 3851 | //------------------------------------------------------------------------------ |
| 3852 | bool GuiTreeViewCtrl::scrollVisibleByObjectId(S32 objID) |
| 3853 | { |
| 3854 | S32 itemID = findItemByObjectId(objID); |
| 3855 | |
| 3856 | if(itemID == -1) |
| 3857 | { |
| 3858 | // we did not find the item in our current items |
| 3859 | // we should try to find and show the parent of the item. |
| 3860 | SimObject *obj = Sim::findObject(objID); |
| 3861 | |
| 3862 | if(!obj || !obj->getGroup()) |
| 3863 | return false; |
| 3864 | |
| 3865 | // if we can't show the parent, we fail. |
| 3866 | if(! scrollVisibleByObjectId(obj->getGroup()->getId()) ) |
| 3867 | return false; |
| 3868 | |
| 3869 | // get the parent. expand the parent. rebuild the tree. this ensures that |
| 3870 | // we'll be able to find the child item we're targeting. |
| 3871 | S32 parentID = findItemByObjectId(obj->getGroup()->getId()); |
| 3872 | AssertFatal(parentID != -1, "We were able to show the parent, but could not then find the parent. This should not happen."); |
| 3873 | Item *parentItem = getItem(parentID); |
| 3874 | parentItem->setExpanded(true); |
| 3875 | buildVisibleTree(); |
| 3876 | |
| 3877 | // NOW we should be able to find the object. if not... something's wrong. |
| 3878 | itemID = findItemByObjectId(objID); |
| 3879 | AssertWarn(itemID != -1,"GuiTreeViewCtrl::scrollVisibleByObjectId() found the parent, but can't find it's immediate child. This should not happen."); |
| 3880 | if(itemID == -1) |
| 3881 | return false; |
| 3882 | } |
| 3883 | |
| 3884 | // ok, item found. scroll to it. |
| 3885 | scrollVisible(itemID); |
| 3886 | |
| 3887 | return true; |
| 3888 | } |
| 3889 | |
| 3890 | //------------------------------------------------------------------------------ |
| 3891 | ConsoleMethod(GuiTreeViewCtrl, scrollVisibleByObjectId, S32, 3, 3, "(show item by object id. returns true if sucessful.)") |
no test coverage detected