home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / usr / share / perl5 / Debconf / Element / Kde / Multiselect.pm < prev    next >
Encoding:
Perl POD Document  |  2006-07-24  |  1.4 KB  |  62 lines

  1. #!/usr/bin/perl -w
  2. # This file was preprocessed, do not edit!
  3.  
  4.  
  5. package Debconf::Element::Kde::Multiselect;
  6. use strict;
  7. use Qt;
  8. use base qw(Debconf::Element::Kde Debconf::Element::Multiselect);
  9. use Debconf::Encoding qw(to_Unicode);
  10.  
  11.  
  12. sub create {
  13.     my $this=shift;
  14.     
  15.     my @choices = $this->question->choices_split;
  16.     my %default = map { $_ => 1 } $this->translate_default;
  17.     
  18.     $this->SUPER::create(@_);
  19.     $this->startsect;
  20.     $this->addhelp;
  21.     $this->adddescription;
  22.     
  23.     my @buttons;
  24.     my $vbox = Qt::VBoxLayout($this -> widget);
  25.     for (my $i=0; $i <= $#choices; $i++) {
  26.         $buttons[$i] = Qt::CheckBox($this->cur->top);
  27.         $buttons[$i]->setText(to_Unicode($choices[$i]));
  28.         $buttons[$i]->show;
  29.         $buttons[$i]->setChecked($default{$choices[$i]} ? 1 : 0);
  30.         $buttons[$i]->setSizePolicy(Qt::SizePolicy(1, 1, 0, 0,
  31.         $buttons[$i]->sizePolicy()->hasHeightForWidth()));
  32.         $this->addwidget($buttons[$i]);
  33.     }
  34.     
  35.     $vbox->addItem($this -> vspacer);
  36.     $this->buttons(\@buttons);
  37.     $this->endsect;
  38. }
  39.  
  40.  
  41. sub value {
  42.     my $this = shift;
  43.     my @buttons = @{$this->buttons};
  44.     my ($ret, $val);
  45.     my @vals;
  46.     $this->question->template->i18n('');
  47.     my @choices=$this->question->choices_split;
  48.     $this->question->template->i18n(1);
  49.     
  50.     for (my $i = 0; $i <= $#choices; $i++) {
  51.     if ($buttons [$i] -> isChecked()) {
  52.         push @vals, $choices[$i];
  53.     }
  54.     }
  55.     return join(', ', $this->order_values(@vals));
  56. }
  57.  
  58. *visible = \&Debconf::Element::Multiselect::visible;
  59.  
  60.  
  61. 1
  62.