void SceneTreeModel::setAsNotVisible(const TreePath& path) { boost::any value = path.getLastPathComponent(); if(value.type() == typeid(Scene* const)) { dettachChangeHandler(boost::any_cast<Scene* const>(value), path.getParentPath(), path); } else if(value.type() == typeid(Light* const)) { dettachChangeHandler(boost::any_cast<Light* const>(value), path.getParentPath(), path); } else if(value.type() == typeid(Foreground* const)) { dettachChangeHandler(boost::any_cast<Foreground* const>(value), path.getParentPath(), path); } else if(value.type() == typeid(SceneObject* const)) { dettachChangeHandler(boost::any_cast<SceneObject* const>(value), path.getParentPath(), path); } }
UInt32 FixedHeightTreeModelLayout::getVisibleChildCount(const TreePath& path) const { if(isVisible(path) || (path.getPathCount() == 1 && isExpanded(path))) { return _TreeModel->getChildCount(path.getLastPathComponent()); } else { return 0; } }
ModelTreeNodeRefPtr DefaultTreeModel::getNodeForPath(const TreePath& ThePath) const { try { ModelTreeNodeRefPtr TheNode = boost::any_cast<ModelTreeNodeRefPtr>(ThePath.getLastPathComponent()); return TheNode; } catch(boost::bad_any_cast &) { return NULL; } }
void FixedHeightTreeModelLayout::setExpanded(const TreePath& path, bool Expand) { if(!_TreeModel->isLeaf(path.getLastPathComponent())) { if(Expand) { _VetoPathExpantion = false; if(!isExpanded(path)) { produceTreeWillExpand(path); if(!_VetoPathExpantion) { _ExpandedPathSet.insert(path); insertVisibleDecendents(path); produceTreeExpanded(path); } } } else { _VetoPathCollapse = false; if(isExpanded(path)) { produceTreeWillCollapse(path); if(!_VetoPathCollapse) { _ExpandedPathSet.erase(path); removeVisibleDecendents(path); produceTreeCollapsed(path); } } } } }
/*public*/ void CPTreeSelectionListener::valueChanged(TreeSelectionEvent* e) { TreePath* path = e->getPath(); CatalogTreeNode* n = (CatalogTreeNode*)path->getLastPathComponent(); cp->log->debug(tr("%1 ").arg(e->getPath()->toString())); NamedIcon* icon = cp->getSelectedIcon(); if (!cp->dTree->isSelectionEmpty() && cp->dTree->getSelectionPath() != NULL && icon != NULL) { // somebody has been selected //cp->preview->setIcon(cp->getSelectedIcon()); QPixmap p =QPixmap(icon->getFilename()); // // get label dimensions // int w = cp->preview->width(); // int h = cp->preview->height(); // cp->preview->setPixmap(p.scaled(w,h,Qt::KeepAspectRatio)); cp->preview->resize(p.size()); cp->preview->setPixmap(p); } else { cp->preview->setPixmap(QPixmap()); } }
void SceneGraphTreeModel::valueForPathChanged(TreePath path, const boost::any& newValue) { try { NodeUnrecPtr NewNode = boost::any_cast<NodeUnrecPtr>(newValue); NodeUnrecPtr OldNode = boost::any_cast<NodeUnrecPtr>(path.getLastPathComponent()); if(NewNode != NULL && OldNode != NULL && NewNode != OldNode && OldNode->getParent() != NULL) { NodeUnrecPtr ParentNode(OldNode->getParent()); if(ParentNode->replaceChildBy(OldNode, NewNode)) { UInt32 ChildIndex(ParentNode->findChild(NewNode)); produceTreeStructureChanged(path.getParentPath(),std::vector<UInt32>(1, ChildIndex),std::vector<boost::any>(1, newValue)); } } } catch(boost::bad_any_cast &ex) { SWARNING << "Bad any cast: " << ex.what() << std::endl; } }
void ComponentTreeModel::valueForPathChanged(TreePath path, const boost::any& newValue) { try { ComponentWeakPtr NewComponent = boost::any_cast<ComponentWeakPtr>(newValue); ComponentWeakPtr OldComponent = boost::any_cast<ComponentWeakPtr>(path.getLastPathComponent()); if(NewComponent != NULL && OldComponent != NULL && NewComponent != OldComponent && OldComponent->getParentContainer() != NULL) { ComponentContainerRefPtr ParentContainer(OldComponent->getParentContainer()); Int32 ChildIndex(ParentContainer->getChildIndex(OldComponent)); if(ChildIndex >= 0) { (*ParentContainer->editMFChildren())[ChildIndex] = NewComponent; produceTreeStructureChanged(path.getParentPath(),std::vector<UInt32>(1, ChildIndex),std::vector<boost::any>(1, newValue)); } } } catch(boost::bad_any_cast &) { } }