Wx-Perl-TreeView
view release on metacpan or search on metacpan
lib/Wx/Perl/TreeView.pm view on Meta::CPAN
$tree->DeleteChildren( $item );
my $count = $model->get_child_count( $cookie );
if( $count == 0 ) {
$tree->SetItemHasChildren( $item, 0 );
return;
}
for( my $i = 0; $i < $count; ++$i ) {
my( $ccookie, $cstring, $cimage, $ccdata ) =
$model->get_child( $cookie, $i );
my $child = $tree->AppendItem
( $item, $cstring, ( defined $cimage ? $cimage : -1 ), -1,
Wx::TreeItemData->new( { cookie => $ccookie, data => $ccdata } ) );
$tree->SetItemHasChildren( $child, $model->has_children( $ccookie ) );
}
}
=head2 reload
$treeview->reload;
Deletes all tree items and readds root node(s) from the model.
lib/Wx/Perl/TreeView.pm view on Meta::CPAN
$self->_refresh( $tree->GetRootItem, $data );
} else {
$self->reload;
}
$self->_on_item_expanding( $_ ) foreach @$is_expanding;
return $can_refresh;
}
sub _check {
my( $self, $pitem, $pcookie, $pstring, $pimage, $pcdata,
$is_expanding ) = @_;
my( $model, $tree ) = ( $self->model, $self->treectrl );
my $data = { text => $pstring,
image => $pimage,
cookie => $pcookie,
data => $pcdata,
childs => [],
};
return ( 1, $data ) if grep $_ == $pitem, @$is_expanding;
return ( 1, $data ) unless $tree->IsExpanded( $pitem );
my $cchilds = $tree->GetChildrenCount( $pitem, 0 );
my $mchilds = $model->get_child_count( $pcookie );
return ( 0, undef ) if $cchilds != $mchilds;
my( $child, $cookie ) = $tree->GetFirstChild( $pitem );
my $index = 0;
while( $child->IsOk ) {
my( $ccookie, $cstring, $cimage, $ccdata ) =
$model->get_child( $pcookie, $index );
my( $can_refresh, $cdata ) = $self->_check
( $child, $ccookie, $cstring, $cimage, $ccdata, $is_expanding );
return ( 0, undef ) unless $can_refresh;
push @{$data->{childs}}, $cdata;
( $child, $cookie ) = $tree->GetNextChild( $pitem, $cookie );
++$index;
}
return ( 1, $data );
}
sub _refresh {
my( $self, $item, $data ) = @_;
my $tree = $self->treectrl;
( run in 0.700 second using v1.01-cache-2.11-cpan-454fe037f31 )