1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
|
Description: Fix unsaved changes when changing hash keys
See description in debian bug.
Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=681353
Forwarded: yes
Origin: upstream
Applied-Upstream: yes
--- a/lib/Config/Model/ListId.pm
+++ b/lib/Config/Model/ListId.pm
@@ -234,6 +234,7 @@
if ($ok or $check eq 'no') {
$self->_store($to, $moved) ;
$moved->index_value($to) ;
+ $self->notify_change(note => "moved from index $from to $to") ;
my $imode = $self->instance->get_data_mode ;
$self->set_data_mode( $to, $imode ) ;
}
@@ -304,8 +305,7 @@
$self->{data}[$ida] = $objb ;
$self->{data}[$idb] = $obja ;
- $self->notify_change(index => $ida) ;
- $self->notify_change(index => $idb) ;
+ $self->notify_change(note => "swapped index $ida and $idb") ;
}
#die "check index number after wap";
--- a/lib/Config/Model/HashId.pm
+++ b/lib/Config/Model/HashId.pm
@@ -280,6 +280,8 @@
delete $self->{warning_hash}{$from} ;
# update index_value attribute in moved objects
$self->{data}{$to}->index_value($to) ;
+
+ $self->notify_change(note => "rename key from $from to $to");
# data_mode is preset or layered or user. Actually only user
# mode makes sense here
@@ -333,6 +335,7 @@
my $list = $self->{list} ;
+ my $msg ;
if (defined $ref_key) {
for (my $idx = 0; $idx <= $#$list; $idx ++ ) {
if ($list->[$idx] eq $ref_key) {
@@ -340,9 +343,16 @@
last;
}
}
+
+ $msg = "moved key $key_to_move after $ref_key" ;
} else {
unshift @$list , $key_to_move ;
+ $msg = "moved key $key_to_move at beginning" ;
}
+
+
+ $self->notify_change( note => $msg ) ;
+
}
@@ -363,9 +373,13 @@
if ($list->[$idx] eq $key) {
$list->[$idx] = $list->[$idx-1];
$list->[$idx-1] = $key ;
+ $self->notify_change(note => "moved up key $key") ;
last ;
}
}
+
+ # notify_change is placed in the loop so the notification
+ # is not sent if the user tries to move up idx 0
}
@@ -386,9 +400,13 @@
if ($list->[$idx] eq $key) {
$list->[$idx] = $list->[$idx+1];
$list->[$idx+1] = $key ;
+ $self->notify_change(note => "moved down key $key") ;
last ;
}
}
+
+ # notify_change is placed in the loop so the notification
+ # is not sent if the user tries to move past last idx
}
|