App-Chart
view release on metacpan or search on metacpan
lib/App/Chart/Gtk2/WatchlistModel.pm view on Meta::CPAN
} elsif ($col == COL_WHEN) {
$str = $latest->short_datetime;
} elsif ($col == COL_NOTE) {
my @notes = ();
my $dividend = $latest->{'dividend'};
if (defined $dividend) {
push @notes, __x('ex {dividend}', dividend => $dividend);
}
if ($latest->{'halt'}) { push @notes, __('halt'); }
if ($latest->{'limit_up'}) { push @notes, __('limit up'); }
if ($latest->{'limit_down'}) { push @notes, __('limit down'); }
if (my $note = $latest->{'note'}) { push @notes, $note; }
if (my $error = $latest->{'error'}) { push @notes, $error; }
$str = join (', ', @notes);
} elsif ($col == COL_COLOUR) {
require App::Chart::Gtk2::Job::Latest;
if ($App::Chart::Gtk2::Job::Latest::inprogress{$symbol}) {
$str = '#00007F';
} else {
my $change = $latest->{'change'};
if (defined $change) {
if ($change > 0) { $str = '#007F00'; }
elsif ($change < 0) { $str = '#7F0000'; }
}
}
} elsif ($col == COL_TOOLTIP) {
$str = $symbol;
require App::Chart::Database;
if (my $name = ($latest->{'name'}
|| App::Chart::Database->symbol_name ($symbol))) {
$str .= ' - ' . $name;
}
$str .= "\n";
if (my $quote_date = $latest->{'quote_date'}) {
my $quote_time = $latest->{'quote_time'} || '';
$str .= __x("Quote: {quote_date} {quote_time}",
quote_date => $quote_date,
quote_time => $quote_time);
$str .= "\n";
}
if (my $last_date = $latest->{'last_date'}) {
my $last_time = $latest->{'last_time'} || '';
$str .= __x("Last: {last_date} {last_time}",
last_date => $last_date,
last_time => $last_time);
$str .= "\n";
}
require App::Chart::TZ;
my $timezone = App::Chart::TZ->for_symbol($symbol);
$str .= __x("{location} time; source {source}",
location => $timezone->name,
source => $latest->{'source'});
# tip is markup format, though that's not actually documented as of 2.12
$str = Glib::Markup::escape_text ($str);
}
return ($cache->[$col] = $str);
}
sub format_price {
my ($str) = @_;
if (! defined $str) { return ''; }
my $nf = App::Chart::number_formatter();
return eval { $nf->format_number ($str, App::Chart::count_decimals($str), 1) }
// __('[bad]');
}
sub get_symlist {
my ($self) = @_;
return $self->get_model;
}
1;
__END__
=for stopwords watchlist symlist ie
=head1 NAME
App::Chart::Gtk2::WatchlistModel -- watchlist data model object
=for test_synopsis my ($symlist)
=head1 SYNOPSIS
use App::Chart::Gtk2::WatchlistModel;
my $model = App::Chart::Gtk2::WatchlistModel->new ($symlist);
=head1 OBJECT HIERARCHY
C<App::Chart::Gtk2::WatchlistModel> is a subclass of C<Gtk2::TreeModelFilter>,
Glib::Object
Gtk2::TreeModelFilter
App::Chart::Gtk2::WatchlistModel
=head1 DESCRIPTION
A C<App::Chart::Gtk2::WatchlistModel> object presents the data from a given
C<App::Chart::Gtk2::Symlist> in a form suitable for
C<App::Chart::Gtk2::WatchlistDialog> dialog. Currently this is its sole
use.
=head1 FUNCTIONS
=over 4
=item C<< App::Chart::Gtk2::WatchlistModel->new ($symlist) >>
Create and return a C<App::Chart::Gtk2::WatchlistModel> object presenting the
symbols in C<$symlist>.
=back
( run in 0.849 second using v1.01-cache-2.11-cpan-39bf76dae61 )