Fixed ::setData, part I
This commit is contained in:
@@ -241,7 +241,6 @@ namespace znode
|
||||
int add_child_at( int idx, const zshared_node& node )
|
||||
{
|
||||
// _fixme! was ist, wenn da schon ein elternknoten ist?
|
||||
|
||||
_children.insert(children().begin() + idx, node );
|
||||
node->_parent = this->shared_from_this();
|
||||
return int(children().size() - 1);
|
||||
@@ -254,10 +253,9 @@ namespace znode
|
||||
parent()->add_child_at( offset, this->shared_from_this() );
|
||||
else
|
||||
throw std::runtime_error("add_me_at(offset): no parent node");
|
||||
|
||||
}
|
||||
|
||||
//! fügt einen shard_ptr von 'mir' in die kinderliste des übergebenen knotens ein
|
||||
//! fügt einen shared_ptr von 'mir' in die kinderliste des übergebenen knotens ein
|
||||
//! und macht diesen zu meinem elternknoten.
|
||||
void add_me_at( int offset, const zshared_node& parent_node )
|
||||
{
|
||||
@@ -270,18 +268,17 @@ namespace znode
|
||||
{
|
||||
throw std::runtime_error("add_me_at(offset,parent): no parent node");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
//! findet die eigene position im eltern-knoten
|
||||
int own_pos()
|
||||
{
|
||||
if( parent())
|
||||
return parent()->child_pos( this->shared_from_this() );
|
||||
return -1;
|
||||
|
||||
}
|
||||
|
||||
//int child_pos(zbasic_node* child)
|
||||
//! findet die postion eines kind-knotens
|
||||
int child_pos(const zshared_node& child)
|
||||
{
|
||||
//auto pos = std::find_if(children().begin(), children().end(), match_node(child) );
|
||||
@@ -291,7 +288,7 @@ namespace znode
|
||||
return -1;
|
||||
}
|
||||
|
||||
//zshared_node unlink_child( zbasic_node* node )
|
||||
//! findet die postion eines kind-knotens
|
||||
zshared_node unlink_child( const zshared_node& node )
|
||||
{
|
||||
auto it = std::find(_children.begin(), _children.end(), node);
|
||||
@@ -319,11 +316,10 @@ namespace znode
|
||||
{
|
||||
for( auto child : _children )
|
||||
{
|
||||
qDebug() << " --#- " << child->name() << " : " << child->has_attribute( attrkey, attrvalue );
|
||||
if( child->has_attribute( attrkey, attrvalue ))
|
||||
return child;
|
||||
}
|
||||
return zshared_node();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//
|
||||
@@ -334,7 +330,7 @@ namespace znode
|
||||
if( child->tag_name() == tagname )
|
||||
return child;
|
||||
}
|
||||
return zshared_node();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
zshared_node find_child_by_id( int id )
|
||||
@@ -344,46 +340,7 @@ namespace znode
|
||||
if (child->_id == id)
|
||||
return child;
|
||||
}
|
||||
return zshared_node();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void dump(int indent = 0) const
|
||||
{
|
||||
|
||||
// fix_me!
|
||||
qDebug() << std::string(indent * 2, ' ').c_str() << this->to_string();
|
||||
//qDebug() << to_string();
|
||||
//qDebug() << '\n';// std::endl;
|
||||
|
||||
if (!children().empty())
|
||||
{
|
||||
for (auto child : _children)
|
||||
{
|
||||
//qDebug() << " --- type: " << typeid(child).name();
|
||||
child.get()->dump( indent + 1 );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool for_each_x( T func, int depth = 0 )
|
||||
//bool for_each( auto func ) const
|
||||
{
|
||||
if( !apply( func, depth ) )
|
||||
return false;
|
||||
|
||||
if( !children().empty() )
|
||||
{
|
||||
for( auto child : _children )
|
||||
{
|
||||
if( !child->for_each( func, depth+1 ) )
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// find ...
|
||||
@@ -396,22 +353,6 @@ namespace znode
|
||||
|
||||
};
|
||||
|
||||
|
||||
class zbasic_node_walker
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void begin()
|
||||
{}
|
||||
|
||||
template<typename str_t>
|
||||
void for_each_node( zbasic_node<str_t>* node );
|
||||
|
||||
virtual void end()
|
||||
{}
|
||||
|
||||
};
|
||||
|
||||
} //namespace znode
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user