Changeset 5184

Show
Ignore:
Timestamp:
03/19/10 06:50:48 (3 years ago)
Author:
ronosman
Message:

Feature 1520 added : ability to set photo default caption after the photo is added.

Location:
extensions/pLoader/trunk/src/Uploader
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • extensions/pLoader/trunk/src/Uploader/GUI/DlgCommon.pm

    r5041 r5184  
    4646        'Wx::CheckBox' => sub { my ( $ctrl ) = @_; Wx::Event::EVT_CHECKBOX( $ctrl, $ctrl, sub { $self->OnCheckBox(@_) } ); }, 
    4747        'Wx::DatePickerCtrl' => sub { my ( $ctrl ) = @_; Wx::Event::EVT_DATE_CHANGED( $ctrl, $ctrl, sub { $self->OnDatePicker(@_) } ); }, 
     48        'Wx::ComboBox' => sub { my ( $ctrl ) = @_; 
     49                              Wx::Event::EVT_COMBOBOX( $ctrl, $ctrl, sub { $self->OnComboBox(@_) } ); 
     50                              Wx::Event::EVT_TEXT( $ctrl, $ctrl, sub { $self->OnComboBoxText(@_) } ); 
     51                          }, 
    4852    }; 
    4953     
     
    8387 
    8488 
     89sub OnComboBoxText { 
     90    my ( $self, $ctrl, $event ) = @_; 
     91 
     92    if( exists $ctrl->{_value}){ 
     93        $event->Skip(1); 
     94    } 
     95    else{ 
     96        my $id = $ctrl->GetId; 
     97        # change the property value 
     98        $self->properties->{$id}->{value}->( 
     99            $event->GetString 
     100        ) if exists $self->properties->{$id}->{value}; 
     101 
     102        # exec the callback 
     103        $self->properties->{$id}->{frame_callback}->($self, $ctrl, $event) if exists 
     104            $self->properties->{$id}->{frame_callback};     
     105    } 
     106 
     107} 
     108 
     109 
    85110# what does happen when the text changes 
    86111sub OnTextCtrl { 
     
    97122        $self->properties->{$id}->{frame_callback};     
    98123     
    99     $event->Skip; 
    100124} 
    101125 
     
    163187    $event->Skip; 
    164188} 
     189 
     190 
     191sub OnComboBox { 
     192    my ( $self, $ctrl, $event ) = @_; 
     193      
     194    my $id = $ctrl->GetId; 
     195 
     196    $ctrl->{_multi_selection_mode} = $self->properties->{$id}->{multi_selection_mode}->() 
     197        if exists $self->properties->{$id}->{multi_selection_mode}; 
     198 
     199    my $selection = exists $self->properties->{$id}->{string_selection} ? $event->GetString : $event->GetSelection; 
     200 
     201    my $value = $self->properties->{$id}->{pre_process}->( $selection ) if exists 
     202        $self->properties->{$id}->{pre_process};     
     203 
     204    if( exists $self->properties->{$id}->{value} ){ 
     205        $value = $self->properties->{$id}->{value}->( 
     206            $value, 
     207            $selection, 
     208        ); 
     209        # the item selected in the list is not the real value 
     210        # we place here the actual value 
     211        # to use in EVT_IDLE event, and overwrite the text field with it 
     212        $ctrl->{_value} = $value; 
     213    } 
     214 
     215    # exec the callback 
     216    $self->properties->{$id}->{frame_callback}->($self, $ctrl, $event) if exists 
     217        $self->properties->{$id}->{frame_callback};     
     218} 
     219 
    165220 
    166221sub OnDatePicker { 
     
    196251                                  $ctrl->SetValue($date); 
    197252                            }, 
     253    'Wx::ComboBox' => sub {  
     254                          my ($ctrl, $value ) = @_;  
     255                          $ctrl->SetValue($value) ;  
     256                      }, 
    198257}; 
    199258 
     
    210269        my $ctrl =$self->FindWindow($_); 
    211270        if(defined $ctrl){ 
     271            #printf("%s\n", $ctrl); 
    212272            # checkbox, static text 
    213273            $change_value->{ref $ctrl}->( 
     
    269329    my ( $self ) = @_; 
    270330 
    271         map { 
     331    map { 
    272332        my $ctrl =$self->FindWindow($_); 
    273333        #printf("ctrl %s : %s\n", $_, $ctrl);         
  • extensions/pLoader/trunk/src/Uploader/GUI/Frame.pm

    r5155 r5184  
    309309        { 
    310310            $main::CAPTION => { label=>gettext("Caption")}, 
    311             $main::PHOTO_PROPERTIES_CAPTION => {  
     311            $main::PHOTO_PROPERTIES_CAPTION => { 
     312                multi_selection_mode => sub { $self->multi_selection_mode }, 
     313                string_selection => sub { return 1; }, 
    312314                value => sub { 
     315                    $self->imagelist->SetImageSelectionName(@_); 
    313316                    $self->multi_selection_mode ? 
    314                     $self->imagelist->SetImageSelectionName(@_): 
    315                     $self->imagelist->current_image->site_name(@_)  
     317                    $self->imagelist->image_selection_name : 
     318                    $self->imagelist->current_image->site_name; 
    316319                }, 
     320                pre_process => sub { sub { $self->imagelist->GetCurrentImageDefaultName(@_); } }, 
     321                choices => 
     322                [ 
     323                    map { gettext $_ } @{wxTheApp->default_photo_names} 
     324                ], 
    317325                frame_callback => sub { $self->imageviewer_item_refresh(1); }, 
    318326            }, 
  • extensions/pLoader/trunk/src/Uploader/GUI/Layout/PhotoPropertiesCategoriesTags.pm

    r5122 r5184  
    1212use Wx qw( wxALIGN_RIGHT wxALIGN_BOTTOM wxALIGN_CENTER wxALIGN_CENTER_VERTICAL wxALIGN_CENTER_HORIZONTAL ); 
    1313use Wx qw( wxTR_HAS_BUTTONS wxTR_LINES_AT_ROOT wxSUNKEN_BORDER wxLI_HORIZONTAL wxTE_MULTILINE ); 
    14 use Wx qw( wxDP_DROPDOWN ); 
     14use Wx qw( wxDP_DROPDOWN wxCB_READONLY); 
    1515 
    1616# Bitmap functions 
     
    117117    my $topsizer = Wx::BoxSizer->new( wxVERTICAL ); 
    118118 
    119     $topsizer->Add(  
    120         TextField( 
     119    $topsizer->Add( 
     120        ComboField( 
    121121            $parent, 
    122122            $main::CAPTION, 
     
    314314} 
    315315 
     316 
     317sub ComboField { 
     318    my ( $parent, $id_label, $id_ctrl, $expand ) = @_; 
     319 
     320    $expand ||=0; 
     321 
     322    my( $sizer ) = Wx::BoxSizer->new( wxVERTICAL ); 
     323 
     324    $expand||=0; 
     325     
     326    $sizer->Add(  
     327        Wx::StaticText->new( 
     328            $parent, 
     329            $id_label, 
     330            "text", 
     331            wxDefaultPosition, 
     332            wxDefaultSize, 
     333            0 
     334        ), 
     335        0, 
     336        wxALL, 
     337        1  
     338    ); 
     339 
     340    my $ctrl = Wx::ComboBox->new( 
     341        $parent, 
     342        $id_ctrl, 
     343        "", 
     344        wxDefaultPosition, 
     345        [-1,-1], 
     346        [], 
     347         
     348    ); 
     349 
     350    # the EVT_COMBOBOX has set _value if we need to overwrite the default 
     351    # text. The list contains function names. We want to have the value returned by the function 
     352    # in the text field 
     353    Wx::Event::EVT_IDLE( 
     354        $ctrl, 
     355        sub {  
     356            my ( $ctrl, $event ) = @_; 
     357            if(exists $ctrl->{_value}){ 
     358                $ctrl->SetValue($ctrl->{_value}) if !$ctrl->{_multi_selection_mode}; 
     359                delete $ctrl->{_value}; 
     360                delete $ctrl->{_multi_selection_mode}; 
     361            } 
     362        }  
     363    ); 
     364 
     365 
     366    $sizer->Add( 
     367        $ctrl, 
     368        $expand, 
     369        wxEXPAND|wxALL, 
     370        1  
     371    ); 
     372 
     373 
     374 
     375    $sizer; 
     376} 
     377 
     378 
    316379sub _multi_selection_mode_panel_layout{ 
    317380    my ( $panel ) = @_; 
     
    335398 
    336399} 
     400 
     4011; 
     402 
  • extensions/pLoader/trunk/src/Uploader/ImageList.pm

    r5155 r5184  
    3030use Digest::MD5::File qw/file_md5_hex md5_hex/; 
    3131use Wx::Locale qw/:default/; 
    32 use Wx; 
     32use Wx qw/wxTheApp/; 
    3333 
    3434# this class implements a collection of image files with associated data 
     
    342342} 
    343343 
     344sub GetCurrentImageDefaultName { 
     345    my ( $self, $index, $pattern ) = @_; 
     346 
     347    $pattern = wxTheApp->eng_default_photo_names->{$pattern}; 
     348 
     349    $self->SetCurrentImage($index); 
     350 
     351    my $img = $self->current_image; 
     352 
     353    $self->_photo_name_from_pattern( 
     354        $img->file, 
     355        $img->create_date, 
     356        $index, 
     357        $pattern 
     358    ); 
     359} 
    344360 
    345361sub _default_photo_name { 
    346362    my ( $self, $file, $info, $i ) = @_; 
    347      
    348      
     363 
     364    my $create_date = $info->{CreateDate}; 
     365     
     366     
     367    $self->_photo_name_from_pattern($file, $create_date, $i, $self->default_photo_name); 
     368} 
     369 
     370 
     371sub _photo_name_from_pattern { 
     372    my ( $self, $file, $create_date, $i, $pattern ) = @_; 
     373 
     374    my ( $yyyy, $mm, $dd, $hh, $mi, $ss ) = split /[:\s]/, $create_date ; 
     375   
     376    my $chrono = join('', $yyyy, $mm, $dd); 
     377 
    349378    my $name; 
    350     my $create_date = $info->{CreateDate}; 
    351379    my $ext; 
    352380    my ( $vol, $path, $filename ) = File::Spec->splitpath($file); 
    353381    ( $filename, $ext ) = split /\.\w+$/, $filename; 
    354382     
    355     my ( $yyyy, $mm, $dd, $hh, $mi, $ss ) = split /[:\s]/, $create_date ; 
    356    
    357     my $chrono = join('', $yyyy, $mm, $dd); 
    358     if('Prefix' eq $self->default_photo_name){ 
     383 
     384    if('Prefix' eq $pattern){ 
    359385        $name = $self->default_name_prefix 
    360386    } 
    361     elsif('File name' eq $self->default_photo_name){ 
     387    elsif('File name' eq $pattern){ 
    362388        $name = $filename 
    363389    } 
    364     elsif('File path and name' eq $self->default_photo_name){ 
     390    elsif('File path and name' eq $pattern){ 
    365391        $name = sprintf( 
    366392            "%s",  
     
    368394        )         
    369395    }     
    370     elsif('Prefix + rank number' eq $self->default_photo_name){ 
     396    elsif('Prefix + rank number' eq $pattern){ 
    371397        $name = sprintf( 
    372398            "%s%s",  
     
    375401        )         
    376402    }     
    377     elsif('Rank number + prefix' eq $self->default_photo_name){ 
     403    elsif('Rank number + prefix' eq $pattern){ 
    378404        $name = sprintf( 
    379405            "%s%s",  
     
    382408        )         
    383409    }     
    384     elsif('Prefix + create date chrono' eq $self->default_photo_name){ 
     410    elsif('Prefix + create date chrono' eq $pattern){ 
    385411        $name = sprintf( 
    386412            "%s%s",  
     
    389415        )         
    390416    }     
    391     elsif('Create date chrono + prefix' eq $self->default_photo_name){ 
     417    elsif('Create date chrono + prefix' eq $pattern){ 
    392418        $name = sprintf( 
    393419            "%s%s",  
     
    14221448    $self->image_selection_tags($tags) if 'ARRAY' eq ref $tags; 
    14231449 
    1424     #print Dumper $self->image_selection_tags; 
    14251450    # append to each image 
    14261451    # if multiple selection 
     
    14661491} 
    14671492 
     1493 
    14681494sub SetImageSelectionName { 
    1469     my ( $self, $name ) = @_; 
    1470  
    1471     # append to each image 
    1472     # if multiple selection 
    1473     if($self->multi_selection_mode){ 
    1474         if(defined $name){ 
    1475             $self->image_selection_name($name); 
    1476             map { 
    1477                 $self->GetImage($_)->site_name( 
    1478                     $name 
    1479                 ) ; 
    1480             }@{$self->image_selection} 
    1481         }; 
    1482     } 
    1483  
    1484     $self->image_selection_name; 
     1495    my ( $self, $name, $param ) = @_; 
     1496     
     1497    # works in single and multi selection mode 
     1498    if(defined $name){ 
     1499        map { 
     1500            my $_name = 'CODE' eq ref $name ? 
     1501                $name->($_, $param) : 
     1502                $name; 
     1503            $self->image_selection_name($_name); 
     1504 
     1505            $self->GetImage($_)->site_name( 
     1506                $_name 
     1507            ) ; 
     1508        }@{$self->image_selection} 
     1509    } 
    14851510} 
    14861511