Pagination task definition for text plugin. The pagination task is responsible for calculating start position and end position for a specified page, and calculating total pages. More...
#include <text_tasks.h>
Public Member Functions | |
PaginationTask (TextView *view, const Position &_start, bool _is_child) | |
Constructors and destructors. | |
virtual | ~PaginationTask () |
virtual void | execute () |
Execute task with task context. | |
Data Fields | |
utils::Signal< const Position & > | abort_signal |
Abort signal. |
Pagination task definition for text plugin. The pagination task is responsible for calculating start position and end position for a specified page, and calculating total pages.
Definition at line 78 of file text_tasks.h.
Constructors and destructors.
Definition at line 64 of file text_tasks.cpp.
text::PaginationTask::~PaginationTask | ( | ) | [virtual] |
Definition at line 69 of file text_tasks.cpp.
void text::PaginationTask::execute | ( | ) | [virtual] |
Execute task with task context.
Implements common::Task.
Definition at line 73 of file text_tasks.cpp.
References abort_signal, utils::Signal< A1, A2, A3, A4, A5 >::broadcast(), text::TextView::get_current_page_index(), text::TextView::get_page_count(), common::Task::is_aborted(), LOGPRINTF, text::TextView::paginate(), text::TextView::pagination_end_signal, text::TextView::pagination_start_signal, and total_pages.
00074 { 00075 if (!is_child) 00076 { 00077 // Tell listener that pagination starts. 00078 LOGPRINTF("About to send pagination start signal."); 00079 text_view->pagination_start_signal.broadcast(1); 00080 } 00081 00082 bool pagination_done = false; 00083 while (!is_aborted()) 00084 { 00085 if (text_view->paginate(start_pos)) 00086 { 00087 // Pagination is complete. 00088 pagination_done = true; 00089 break; 00090 } 00091 } 00092 00093 if (pagination_done) 00094 { 00095 // Tell listener that pagination is done. 00096 unsigned int total_pages = text_view->get_page_count(); 00097 unsigned int current_page = text_view->get_current_page_index(); 00098 LOGPRINTF("About to send pagination done signal."); 00099 text_view->pagination_end_signal.broadcast(current_page, total_pages); 00100 } 00101 else 00102 { 00103 // We are aborted. 00104 LOGPRINTF("Pagination aborted..."); 00105 abort_signal.broadcast(start_pos); 00106 } 00107 }
Abort signal.
Definition at line 87 of file text_tasks.h.
Referenced by execute(), and text::TextController::paginate().