From aec9c7f4bd4f3e4b6e54ab34ced613f5becfa674 Mon Sep 17 00:00:00 2001 From: Maarten Vanraes Date: Tue, 10 May 2016 19:08:03 +0200 Subject: selectItem helper attribute --- lib/ManaTools/Module/Disk.pm | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'lib') diff --git a/lib/ManaTools/Module/Disk.pm b/lib/ManaTools/Module/Disk.pm index 396fdbec..300696c6 100644 --- a/lib/ManaTools/Module/Disk.pm +++ b/lib/ManaTools/Module/Disk.pm @@ -180,6 +180,15 @@ has ioProperties => ( }, ); +has selectedItem => ( + is => 'rw', + isa => 'Maybe[ManaTools::Shared::disk_backend::IO]', + default => undef, + init_arg => undef, +); + +around 'selectedItem' => \&_selectedItem; + sub _SharedGUIInitialize { my $self = shift; @@ -218,6 +227,38 @@ sub start { $self->_adminDiskPanel(); } +sub _selectItem { + my $orig = shift; + my $self = shift; + my $old = $self->$orig(); + + return $old unless @_; + + my $new = shift; + my @parts = $new->findin(); + while (scalar(@parts) > 0) { + } + # if $new has children, get the first one instead + # if $new is an ancestor of $old, we're not gonna change it + return $self->$orig($new); +}; + +sub _showSelectedItem { + my $self = shift; + my $module = $self->module(); + my $io = $self->selectedItem(); + my $ioProperties = $module->ioProperties(); + $ioProperties->properties($io); + + my $propbox = $module->propertiesBox(); + # properties + # parent properties + + my $actionbox = $module->actionsBox(); + # actions + # parent actions +} + sub _rebuildTab { my $self = shift; my $eventHandler = shift; -- cgit v1.2.1