diff options
author | Angelo Naselli <anaselli@linux.it> | 2014-11-27 17:57:09 +0100 |
---|---|---|
committer | Angelo Naselli <anaselli@linux.it> | 2014-11-27 17:57:09 +0100 |
commit | 27bed37935370a2b4f5ad7e2d0dc99bb7e5ad687 (patch) | |
tree | 895cf9b0d5c7fd23fdf1549fa2c11b43c6343082 | |
parent | 5c9e03406db337887d1217d77b715fbf823b36e4 (diff) | |
download | manatools-27bed37935370a2b4f5ad7e2d0dc99bb7e5ad687.tar manatools-27bed37935370a2b4f5ad7e2d0dc99bb7e5ad687.tar.gz manatools-27bed37935370a2b4f5ad7e2d0dc99bb7e5ad687.tar.bz2 manatools-27bed37935370a2b4f5ad7e2d0dc99bb7e5ad687.tar.xz manatools-27bed37935370a2b4f5ad7e2d0dc99bb7e5ad687.zip |
first attempt to add and remove a group from tree tree
-rw-r--r-- | lib/AdminPanel/Rpmdragora/gui.pm | 45 | ||||
-rwxr-xr-x | modules/rpmdragora/rpmdragora | 16 |
2 files changed, 56 insertions, 5 deletions
diff --git a/lib/AdminPanel/Rpmdragora/gui.pm b/lib/AdminPanel/Rpmdragora/gui.pm index aa97435b..e9f39b6c 100644 --- a/lib/AdminPanel/Rpmdragora/gui.pm +++ b/lib/AdminPanel/Rpmdragora/gui.pm @@ -611,6 +611,41 @@ sub add_parent { $tree->rebuildTree(); } + +#============================================================= + +=head2 add_tree_item + +=head3 INPUT + +=item B<$tree> YTree for the group of the rpm packages + +=item B<$item> string containing a group (to be added as leaf node) + +=item B<$selected> if the new item is selected + + +=head3 DESCRIPTION + + This function add a group to the tree view + +=cut + +#============================================================= +sub add_tree_item { + my ($tree, $item, $selected) = @_; + + $tree or return undef; + + $tree->startMultipleChanges(); + my $treeItem = new yui::YTreeItem($item, get_icon_path($item, 0), 0); + $treeItem->setSelected($selected); + + $tree->addItem($treeItem); + $tree->rebuildTree(); + $tree->doneMultipleChanges(); +} + #============================================================= =head2 add_package_item @@ -1041,9 +1076,15 @@ our $find_entry; sub reset_search() { return if !$common; - $common->{delete_category}->($_) foreach $results_ok, $results_none; + +# TODO $common->{delete_category}->($_) foreach $results_ok, $results_none; # clear package list: - $common->{add_nodes}->(); + yui::YUI::app()->busyCursor(); + my $wdgt = $common->{widgets}; + $wdgt->{detail_list}->startMultipleChanges(); + $wdgt->{detail_list}->deleteAllItems(); + $wdgt->{detail_list}->doneMultipleChanges(); + yui::YUI::app()->normalCursor(); } sub is_a_package { diff --git a/modules/rpmdragora/rpmdragora b/modules/rpmdragora/rpmdragora index 6bb949f1..47d8393c 100755 --- a/modules/rpmdragora/rpmdragora +++ b/modules/rpmdragora/rpmdragora @@ -246,7 +246,12 @@ sub _do_search($$$$$$) { $entry =~ s/^\s*$//; } my $entry_rx = eval { qr/$entry/i } or return; + reset_search(); + # TODO FIXME speed up, we cannot remove an item but rebuilding all is slow + # We could just rebuild the tree items + $options->{rebuild_tree}->(); + $options->{state}{flat} and $options->{delete_all}->(); # TODO: write a collapse_all method #$tree->collapse_all; @@ -381,11 +386,13 @@ sub _do_search($$$$$$) { $searchw->destroy; } - my $iter; +# my $iter; if (@search_results) { @search_results = sort_packages(@search_results); $elems{$results_ok} = [ map { [ $_, $results_ok ] } @search_results ]; - $iter = $options->{add_parent}->($tree, $results_ok); +# $iter = $options->{add_parent}->($tree, $results_ok); + + AdminPanel::Rpmdragora::gui::add_tree_item($tree, $results_ok, 1); $options->{add_nodes}->(map { [ $_, $results_ok . ($options->{tree_mode} eq 'by_presence' ? '|' . ($pkgs->{$_}{pkg}->flag_installed ? $loc->N("Upgradable") : $loc->N("Addable")) : ($options->{tree_mode} eq 'by_selection' @@ -393,7 +400,8 @@ sub _do_search($$$$$$) { : '')) ] } @search_results); } else { - $iter = $options->{add_parent}->($tree, $results_none); + AdminPanel::Rpmdragora::gui::add_tree_item($tree, $results_none, 1); +# $iter = $options->{add_parent}->($tree, $results_none); # clear package list: $options->{add_nodes}->(); my $string = $default_list_mode eq 'all' && $filter->[0] eq 'all' ? $loc->N("No search results.") : @@ -1181,7 +1189,9 @@ sub run_treeview_dialog { reset_search(); } elsif ($widget == $find_button) { + yui::YUI::app()->busyCursor(); _do_search($find_entry, $tree, $options, $current_search_type, $urpm, $pkgs); + yui::YUI::app()->normalCursor(); } elsif ($widget == $select_all_button) { toggle_all($options, 1); |