Beispiel #1
0
Gtk::TreeIter
ConfigTreeView::search_path( const char* path )
{
  Gtk::TreeModel::Children children = m_config_tree->children();
  Gtk::TreeModel::iterator iter = children.begin();
  
  while ( iter != children.end() )
  {
    Gtk::TreeModel::Row row = *iter;
    Glib::ustring p = row[ m_config_record.path ];
    size_t len = strlen( p.c_str() );

    if ( strncmp( p.c_str(), path, len) == 0 )
    {
      if ( strcmp( p.c_str(), path ) == 0 )
      { return iter; }
      else
      { iter = iter->children().begin(); }
    }
    else
    { ++iter; }
  }

  return m_config_tree->children().end();
}
const GraphTreeNodePtr& GraphTreeModel::insert(const scene::INodePtr& node)
{
	// Create a new GraphTreeNode
	GraphTreeNodePtr gtNode(new GraphTreeNode(node));

	// Insert this iterator below a possible parent iterator
	Gtk::TreeModel::iterator parentIter = findParentIter(node);

	gtNode->getIter() = parentIter ? _model->append(parentIter->children()) : _model->append();

	// Fill in the values
	Gtk::TreeModel::Row row = *gtNode->getIter();

	row[_columns.node] = node.get();
	row[_columns.name] = node->name();

	// Insert this iterator into the node map to facilitate lookups
	std::pair<NodeMap::iterator, bool> result = _nodemap.insert(
		NodeMap::value_type(scene::INodeWeakPtr(node), gtNode)
	);

	// Return the GraphTreeNode reference
	return result.first->second;
}