Changeset 12412
- Timestamp:
- 08/31/10 02:54:16 (18 months ago)
- File:
-
- 1 edited
-
trunk/Padre/lib/Padre/Wx/Directory.pm (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Padre/lib/Padre/Wx/Directory.pm
r12406 r12412 259 259 my $files = delete $self->{files} or return; 260 260 my $expand = delete $self->{expand} or return; 261 my $lock = $self->main->lock('UPDATE'); 261 262 my @stack = (); 262 my $lock = $self->main->lock('UPDATE');263 263 shift @$files; 264 264 foreach my $path ( @$files ) { … … 434 434 while ( @_ ) { 435 435 if ( $child->IsOk ) { 436 437 # We are not past the last entry 438 my $current = $tree->GetPlData($child); 439 if ( $current->name eq $_[0]->name ) { 440 # Already exists, discard the duplicate 441 shift; 442 } elsif ( 443 $current->is_directory < $_[0]->is_directory 444 and 445 lc($current->name) gt lc($_[0]->name) 446 ) { 436 # Are we before, after, or a duplicate 437 my $compare = $self->compare( $_[0], $tree->GetPlData($child) ); 438 if ( $compare > 0 ) { 439 # Deleted entry, remove the current position 440 my $delete = $child; 441 ($child, $cookie) = $tree->GetNextChild($cursor, $cookie); 442 $tree->Delete($delete); 443 444 } elsif ( $compare < 0 ) { 445 # New entry, insert before the current position 447 446 my $path = shift; 448 447 $tree->InsertItem( … … 454 453 Wx::TreeItemData->new($path), # Embedded data 455 454 ); 456 $position += 1; 455 $position++; 456 457 457 } else { 458 # Already exists, discard the duplicate 458 459 ($child, $cookie) = $tree->GetNextChild($cursor, $cookie); 459 $position += 1; 460 $position++; 461 shift @_; 460 462 } 461 463 … … 652 654 } 653 655 656 # Compare two paths to see which should be first 657 sub compare { 658 my $self = shift; 659 my $left = shift; 660 my $right = shift; 661 return ( 662 $right->is_directory <=> $left->is_directory 663 or 664 lc($left->name) cmp lc($right->name) 665 ); 666 } 667 654 668 1; 655 669
Note: See TracChangeset
for help on using the changeset viewer.
