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>
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 |
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.
text::SearchTask::SearchTask | ( | TextModel * | _model, | |
SearchContext * | _sc | |||
) |
Constructors and destructors.
Definition at line 159 of file text_tasks.cpp.
text::SearchTask::~SearchTask | ( | ) | [virtual] |
Definition at line 164 of file text_tasks.cpp.
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 }
Definition at line 152 of file text_tasks.h.
Referenced by execute(), and text::TextController::search().