diff options
author | Maarten Vanraes <alien@mageia.org> | 2016-03-22 00:40:31 +0100 |
---|---|---|
committer | Maarten Vanraes <alien@mageia.org> | 2016-05-14 09:25:24 +0200 |
commit | 197dba13ea9c0ca3057bfe1950dcd4f9d51b57ad (patch) | |
tree | 1114afc5aa4eaf372e00441655c9774d4dfafb81 | |
parent | e4b0392f4eabd911e40c3e950fd463361834b31d (diff) | |
download | manatools-197dba13ea9c0ca3057bfe1950dcd4f9d51b57ad.tar manatools-197dba13ea9c0ca3057bfe1950dcd4f9d51b57ad.tar.gz manatools-197dba13ea9c0ca3057bfe1950dcd4f9d51b57ad.tar.bz2 manatools-197dba13ea9c0ca3057bfe1950dcd4f9d51b57ad.tar.xz manatools-197dba13ea9c0ca3057bfe1950dcd4f9d51b57ad.zip |
Disk module: recursively do Parts for now
-rw-r--r-- | lib/ManaTools/Module/Disk.pm | 78 |
1 files changed, 54 insertions, 24 deletions
diff --git a/lib/ManaTools/Module/Disk.pm b/lib/ManaTools/Module/Disk.pm index 9525cbb9..87b1877e 100644 --- a/lib/ManaTools/Module/Disk.pm +++ b/lib/ManaTools/Module/Disk.pm @@ -240,7 +240,7 @@ sub _rebuildTab { my $tab = ManaTools::Shared::GUI::ExtTab->new(eventHandler => $eventHandler, parentWidget => $container); for my $io (@items) { $tab->addSelectorItem($io->label(), $io, sub { - my $self = shift;# eventHandler + my $self = shift;# tab my $parent = shift; my $io = shift; my $dialog = $self->parentDialog(); @@ -249,9 +249,10 @@ sub _rebuildTab { # create content my $vbox = $factory->createVBox($parent); - $self->addWidget($io->label() .': button 1', $factory->createPushButton($vbox, $io->label() .': button 1'), sub { my $backendItem = shift; print STDERR "backendItem: ". $backendItem->label() ."::button1\n"; }); - $self->addWidget($io->label() .': button 2', $factory->createPushButton($vbox, $io->label() .': button 2'), sub { my $backendItem = shift; print STDERR "backendItem: ". $backendItem->label() ."::button2\n"; }); - $self->addWidget($io->label() .': button 3', $factory->createPushButton($vbox, $io->label() .': button 3'), sub { my $backendItem = shift; print STDERR "backendItem: ". $backendItem->label() ."::button3\n"; }); + $module->_rebuildItem($io, $self->eventHandler(), $vbox); + #$self->addWidget($io->label() .': button 1', $factory->createPushButton($vbox, $io->label() .': button 1'), sub { my $backendItem = shift; print STDERR "backendItem: ". $backendItem->label() ."::button1\n"; }); + #$self->addWidget($io->label() .': button 2', $factory->createPushButton($vbox, $io->label() .': button 2'), sub { my $backendItem = shift; print STDERR "backendItem: ". $backendItem->label() ."::button2\n"; }); + #$self->addWidget($io->label() .': button 3', $factory->createPushButton($vbox, $io->label() .': button 3'), sub { my $backendItem = shift; print STDERR "backendItem: ". $backendItem->label() ."::button3\n"; }); $factory->createHStretch($vbox); $factory->createVStretch($vbox); @@ -328,16 +329,52 @@ sub _rebuildItems { my $info = shift; my $eventHandler = shift; my $container = shift; - if ($info->{type} eq 'tab') { - return $self->_rebuildTab($eventHandler, $container, @{$info->{items}}); + for my $i (@{$info}) { + if ($i->{type} eq 'tab') { + return $self->_rebuildTab($eventHandler, $container, @{$i->{items}}); + } + if ($i->{type} eq 'list') { + return $self->_rebuildList($eventHandler, $container, @{$i->{items}}); + } + if ($i->{type} eq 'tree') { + return $self->_rebuildTree($eventHandler, $container, @{$i->{items}}); + } } - if ($info->{type} eq 'list') { - return $self->_rebuildList($eventHandler, $container, @{$info->{items}}); + return undef; +} + +sub _expandItem { + my $self = shift; + my $io = shift; + my $infos = []; + my $type = 'list'; + my @items; + + # get parts + if (defined $io) { + @items = $io->findin(); } - if ($info->{type} eq 'tree') { - return $self->_rebuildTree($eventHandler, $container, @{$info->{items}}); + else { + my $backend = $self->backend(); + @items = $backend->findnoin(); } - return undef; + + # merge all outs from these Parts + for my $p (@items) { + if ($p->type() eq 'Disks') { + $type = 'tab'; + } + push @{$infos}, {io => $io, part=> $p, type => $type, items => [sort {$a->label() cmp $b->label()} $p->out_list()]}; + } + return $infos; +} + +sub _rebuildItem { + my $self = shift; + my $item = shift; + my $eventHandler = shift; + my $container = shift; + return $self->_rebuildItems($self->_expandItem($item), $eventHandler, $container); } sub _rebuildParts { @@ -497,7 +534,7 @@ sub _adminDiskPanel { # set the replacepoint in module $module->content($replacepoint); - ## TODO: buttons to be initialized dynamically + ## build the parts $module->_rebuildParts(); }, restoreValues => sub { @@ -513,18 +550,11 @@ sub _adminDiskPanel { # fs has a list of endpoints and in a tree (mount/swap?): ie: Parts without out ## start the info structure - my $info = {disks => {type => 'tab', items => []}, unused => {type => 'list', items => []}, fs => {type => 'tree', items => []}}; - - ## disks Part, and others - my @items = $backend->findnoin(); - # merge all outs from these Parts - for my $i (@items) { - for my $j (sort {$a->label() cmp $b->label()} $i->out_list()) { - push @{$info->{disks}->{items}}, $j; - } - } - - ## unused, i donno yet, parts without out? or ins without part? + my $info = { + disks => $module->_expandItem(), + unused => {type => 'list', items => sort {$a->label() cmp $b->label()} grep {scalar($_->findin()) == 0} values %{$backend->ios()}}, + fs => {type => 'tree', items => []} + }; ## fs Part should be linked to all the mounts (hierarchial) |