text::SearchTask Class Reference

Search task definition for text plugin. The search task is responsible for find the previous/next/all occurrence of specified pattern. More...

#include <text_tasks.h>

Inheritance diagram for text::SearchTask:
Inheritance graph
[legend]
Collaboration diagram for text::SearchTask:
Collaboration graph
[legend]

Public Member Functions

 SearchTask (TextModel *_model, SearchContext *_sc)
 Constructors and destructors.
virtual ~SearchTask ()
virtual void execute ()
 Execute task with task context.

Data Fields

utils::Signal< SearchContext * > abort_signal

Detailed Description

Search task definition for text plugin. The search task is responsible for find the previous/next/all occurrence of specified pattern.

Definition at line 144 of file text_tasks.h.


Constructor & Destructor Documentation

text::SearchTask::SearchTask ( TextModel _model,
SearchContext _sc 
)

Constructors and destructors.

Definition at line 159 of file text_tasks.cpp.

00160 : text_model(_model), sc(_sc)
00161 {
00162 }

text::SearchTask::~SearchTask (  )  [virtual]

Definition at line 164 of file text_tasks.cpp.

00165 {
00166 }


Member Function Documentation

void text::SearchTask::execute (  )  [virtual]

Execute task with task context.

Implements common::Task.

Definition at line 168 of file text_tasks.cpp.

References abort_signal, utils::Signal< A1, A2, A3, A4, A5 >::broadcast(), text::TextModel::get_aborting_search_task_id(), common::Task::is_aborted(), LOGPRINTF, result_ranges, text::TextModel::search(), text::TextModel::search_done_signal, and text::SearchContext::search_id.

00169 {
00170     std::vector<Range> result_ranges;
00171     bool search_done = false;
00172     while (!is_aborted() &&
00173            text_model->get_aborting_search_task_id() != sc->search_id)
00174     {
00175         if (text_model->search(result_ranges, sc))
00176         {
00177             // We reached the start/end of the document, 
00178             // or we find an occurrence if the SearchType is SEARCH_NEXT.
00179             search_done = true;
00180             break;
00181         }
00182     }
00183 
00184     if (is_aborted())
00185     {
00186         LOGPRINTF("Search task is aborted by another task...");
00187         abort_signal.broadcast(sc);
00188     }
00189 
00190     if (search_done)
00191     {
00192         // Tell listeners search task is done.
00193         text_model->search_done_signal.broadcast(result_ranges, sc);
00194     }
00195     else
00196     {
00197         // We are aborted, do nothing.
00198         LOGPRINTF("Search task is aborted by user...");
00199     }
00200 }

Here is the call graph for this function:


Field Documentation

Definition at line 152 of file text_tasks.h.

Referenced by execute(), and text::TextController::search().


The documentation for this class was generated from the following files:
Generated by  doxygen 1.6.2-20100208