Changeset 6707 for extensions/pLoader/trunk/src/Uploader/Images.pm
- Timestamp:
- Jul 26, 2010, 11:21:44 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/pLoader/trunk/src/Uploader/Images.pm
r6538 r6707 31 31 author 32 32 type 33 global_rank 34 global_rank_indx 33 35 /; 34 36 … … 37 39 /; 38 40 41 my @tmp_properties = qw/ 42 to_be_removed_grank 43 /; 44 45 39 46 __PACKAGE__->mk_accessors(@cbk_properties); 40 47 __PACKAGE__->mk_accessors(@storable_properties); 41 48 __PACKAGE__->mk_accessors(@app_properties); 42 43 my $_global_rank = -1; 49 __PACKAGE__->mk_accessors(@tmp_properties); 50 44 51 45 52 sub Init { … … 49 56 $self->ordered_image_ids([]) if !defined $self->ordered_image_ids; 50 57 $self->selection([]) if !defined $self->selection; 58 $self->global_rank(-1) if !defined $self->global_rank; 59 $self->global_rank_indx({}) if !defined $self->global_rank_indx; 60 $self->to_be_removed_grank([]) if !defined $self->to_be_removed_grank; 51 61 } 52 62 … … 90 100 $self->ordered_image_ids->[$i] = $image_id ; 91 101 102 $self->global_rank( 103 1+$self->global_rank 104 ); 105 106 $self->global_rank_indx->{ 107 $self->global_rank 108 } = $i; 92 109 93 110 my $image = $self->_images->{ … … 104 121 site_tags => [], 105 122 site_high_file => $file->{ANSIPathName}, 106 global_rank => ++$_global_rank,123 global_rank => $self->global_rank, 107 124 } 108 125 ); … … 176 193 my ( $self, $indx ) = @_; 177 194 195 return unless defined $indx; 178 196 my $id = $self->ordered_image_ids->[$indx]; 179 197 … … 222 240 223 241 242 sub remove_processed { 243 my ( $self ) = @_; 244 245 return if ( $self->is_empty ); 246 return if (! defined $self->to_be_removed_grank ); 247 248 my $to_remove_indx = []; 249 # check if the global rank correspond 250 # the image may have changed 251 foreach(@{$self->to_be_removed_grank}) { 252 my $indx = $self->global_rank_indx->{$_}; 253 my $img; 254 if(defined $indx){ 255 $img = $self->get_image($indx); 256 } 257 if(defined $img){ 258 push @$to_remove_indx, $indx if 259 $img->global_rank == $_; 260 } 261 } 262 263 $self->_remove_selection($to_remove_indx); 264 # clear image selection 265 $self->to_be_removed_grank([]); 266 } 267 268 224 269 sub _remove_selection { 225 270 my ( $self, $list ) = @_; 271 printf("_remove_selection %s\n", Dumper $list); 226 272 # the list is sorted, ascendant 227 273 # we reverse it to have … … 238 284 } 239 285 286 287 # postpone actual removal. 288 sub set_to_be_removed { 289 my ( $self, $global_rank ) = @_; 290 291 push @{$self->to_be_removed_grank}, $global_rank; 292 } 293 294 240 295 sub delete_image { 241 296 my ( $self, $indx ) = @_; … … 245 300 # have to check if that id is used more than once 246 301 my $count = grep { $id eq $_} @{$self->ordered_image_ids}; 302 303 # global rank is unique 304 delete $self->global_rank_indx->{ 305 $self->_images->{$id}->global_rank 306 }; 247 307 248 308 delete $self->_images->{$id} unless $count > 1; … … 517 577 518 578 579 # when the progress list is cleared 519 580 sub reset_add_rank { 520 581 my ( $self ) = @_;
Note: See TracChangeset
for help on using the changeset viewer.