1
package Padre::Wx::Panel::TaskList;
6
use Padre::Role::Task ();
7
use Padre::Wx::Role::Idle ();
8
use Padre::Wx::Role::View ();
9
use Padre::Wx::Role::Context ();
10
use Padre::Wx::FBP::TaskList ();
12
our $VERSION = '0.96';
13
our $COMPATIBLE = '0.95';
18
Padre::Wx::Role::Context
19
Padre::Wx::FBP::TaskList
26
######################################################################
32
my $panel = shift || $main->bottom;
33
my $self = $class->SUPER::new($panel);
35
# Temporary store for the task list.
38
# Remember the last document we were looking at
39
$self->{document} = '';
41
# Create the image list even though we don't use much of it
42
my $images = Wx::ImageList->new( 16, 16 );
44
folder => $images->Add(
45
Wx::ArtProvider::GetBitmap(
52
Wx::ArtProvider::GetBitmap(
58
result => $images->Add(
59
Wx::ArtProvider::GetBitmap(
66
$self->{tree}->AssignImageList($images);
68
Wx::Event::EVT_TREE_ITEM_ACTIVATED(
72
$_[0]->idle_method( item_clicked => $_[1]->GetItem );
76
# Register for refresh calls
77
$main->add_refresh_listener($self);
88
######################################################################
89
# Padre::Wx::Role::View Methods
96
Wx::gettext('Task List');
101
$_[0]->main->show_tasks(0);
108
######################################################################
109
# Padre::Wx::Role::Context Methods
115
$self->context_append_options( $menu => 'main_tasks_panel' );
124
######################################################################
129
my $current = shift or return;
130
my $document = $current->document;
131
my $search = $self->{search};
132
my $tree = $self->{tree};
134
# Flush and hide the list if there is no active document
136
my $lock = $self->lock_update;
141
$self->{document} = '';
145
# Ensure the widget is visible
149
# Clear search when it is a different document
150
my $id = Scalar::Util::refaddr($document);
151
if ( $id ne $self->{document} ) {
152
$search->ChangeValue('');
153
$self->{document} = $id;
156
# Unlike the Function List widget we copied to make this,
157
# don't bother with a background task, since this is much quicker.
158
my $regexp = $current->config->main_tasks_regexp;
159
my $text = $document->text_get;
164
while ( $text =~ /$regexp/gim )
166
push @items, { text => $1 || '<no text>', 'pos' => pos($text) };
171
Wx::gettext('%s in TODO regex, check your config.'),
176
while ( $text =~ /#\s*(Ticket #\d+.*?)$/gim ) {
177
push @items, { text => $1, 'pos' => pos($text) };
186
# Update the model and rerender
187
$self->{model} = \@items;
191
# Populate the list with search results
194
my $model = $self->{model};
195
my $search = $self->{search};
196
my $tree = $self->{tree};
198
# Quote the search string to make it safer
199
my $string = $search->GetValue;
200
if ( $string eq '' ) {
203
$string = quotemeta $string;
206
# Show the components and populate the function list
208
my $lock = $self->lock_update;
212
foreach my $task ( reverse @$model ) {
213
my $text = $task->{text};
214
if ( $text =~ /$string/i ) {
215
$tree->Insert( $text, 0 );
227
######################################################################
232
my $item = shift or return;
233
my $tree = $self->{tree};
234
my $data = $tree->GetPlData($item) or return;
235
my $line = $data->{line} or return;
236
my $editor = $self->current->editor or return;
237
$editor->goto_pos_centerize($line);
243
# Copyright 2008-2012 The Padre development team as listed in Padre.pm.
245
# This program is free software; you can redistribute it and/or
246
# modify it under the same terms as Perl 5 itself.