text::TextController Class Reference

#include <text_controller.h>

Collaboration diagram for text::TextController:
Collaboration graph
[legend]

Public Member Functions

 TextController (TextModel *_model, TextView *_view)
 Constructors and destructors.
 ~TextController ()
void start ()
 Start working thread.
void stop ()
 Stop working thread.
void render (unsigned int id, unsigned int page_index, void *data, unsigned char *bmp)
 Render specified page.
void render (unsigned int id, const Position &start_pos, void *data, unsigned char *bmp)
 Render a page start with start_pos.
void paginate (const Position &start, bool send_start_notification)
 Paginate.
void search (SearchContext *sc)
 Search specified pattern in text model.
void pause_pagination ()
 Pause pagination.
void restart_pagination ()
 Restart pagination again after it was paused.

Detailed Description

Definition at line 37 of file text_controller.h.


Constructor & Destructor Documentation

text::TextController::TextController ( TextModel _model,
TextView _view 
)

Constructors and destructors.

Definition at line 35 of file text_controller.cpp.

References text::TextView::set_controller().

00036 : model(_model)
00037 , view(_view)
00038 , pagination_paused(false)
00039 {
00040     // Set controller for view.
00041     view->set_controller(this);
00042 }

Here is the call graph for this function:

text::TextController::~TextController (  ) 

Definition at line 44 of file text_controller.cpp.

00045 {
00046 }


Member Function Documentation

void text::TextController::paginate ( const Position start,
bool  send_start_notification 
)

Paginate.

Definition at line 80 of file text_controller.cpp.

References text::PaginationTask::abort_signal, utils::Signal< A1, A2, A3, A4, A5 >::add_slot(), common::Thread::append_task(), and text::TextView::pagination_end_signal.

Referenced by text::TextView::render(), and restart_pagination().

00081 {
00082     pagination_pending = true;
00083     PaginationTask *task = new PaginationTask(view, start, !send_start_notification);
00084     task->abort_signal.add_slot(this, &TextController::on_pagination_aborted);
00085     view->pagination_end_signal.add_slot(this, &TextController::on_pagination_finished);
00086     thread.append_task(task);
00087 }

Here is the call graph for this function:

Here is the caller graph for this function:

void text::TextController::pause_pagination (  ) 

Pause pagination.

Called when document window is deactivated

Definition at line 112 of file text_controller.cpp.

References utils::Signal< A1, A2, A3, A4, A5 >::broadcast(), text::TextView::get_current_page_index(), text::TextView::get_page_count(), text::TextView::pagination_end_signal, common::Thread::prepend_task(), total_pages, and TRACEFUNCTION.

00113 {
00114     TRACEFUNCTION();
00115 
00116     if (pagination_pending)
00117     {
00118         pagination_paused = true;
00119         
00120         unsigned int total_pages = view->get_page_count();
00121         unsigned int current_page = view->get_current_page_index();
00122         
00123         // Reporting pagination done to UDS through our internal pagination end signal
00124         // UDS probably doesn't receive this event because the document window is
00125         // about to be deactivated (hence, UDS will unsubscribe from plugin events),
00126         // however I still think it is good practice to try to notify UDS anyway.
00127         // [MdB]
00128         view->pagination_end_signal.broadcast(current_page, total_pages);  
00129     
00130         PaginationAbortTask *task = new PaginationAbortTask(view);
00131         thread.prepend_task(task, true /* Cancel running task */);
00132     }
00133 }

Here is the call graph for this function:

void text::TextController::render ( unsigned int  id,
const Position start_pos,
void *  data,
unsigned char *  bmp 
)

Render a page start with start_pos.

Definition at line 73 of file text_controller.cpp.

References text::TextView::check_page_table(), LOGPRINTF, and common::Thread::prepend_task().

00074 {
00075     LOGPRINTF("About to launch render task.");
00076     view->check_page_table(start_pos);
00077     thread.prepend_task(new RenderTask(id, view, start_pos, data, bmp), true);
00078 }

Here is the call graph for this function:

void text::TextController::render ( unsigned int  id,
unsigned int  page_index,
void *  data,
unsigned char *  bmp 
)

Render specified page.

Definition at line 60 of file text_controller.cpp.

References ERRORPRINTF, and text::TextView::get_anchor_by_page().

Referenced by main(), and widget_event_handler().

00061 {
00062     Position start_pos;
00063     if (view->get_anchor_by_page(page_index, start_pos))
00064     {
00065         render(id, start_pos, data, bmp);
00066     }
00067     else
00068     {
00069         ERRORPRINTF("Can't render page %d because it does not exist.\n", page_index);
00070     }
00071 }

Here is the call graph for this function:

Here is the caller graph for this function:

void text::TextController::restart_pagination (  ) 

Restart pagination again after it was paused.

Called when document windows is activated again

Definition at line 135 of file text_controller.cpp.

References text::TextView::check_page_table(), paginate(), and TRACEFUNCTION.

00136 {
00137      TRACEFUNCTION();
00138 
00139    
00140     // Only restart pagination if there is a need
00141     if (pagination_pending)
00142     {
00143         pagination_paused = false;
00144 
00145         Position start_pos;
00146         view->check_page_table(start_pos);
00147         paginate(start_pos, false /* don't send pagination start notification */);
00148     }
00149 }

Here is the call graph for this function:

void text::TextController::search ( SearchContext sc  ) 

Search specified pattern in text model.

Parameters:
search_context Search type and search criteria.

Definition at line 152 of file text_controller.cpp.

References text::SearchTask::abort_signal, utils::Signal< A1, A2, A3, A4, A5 >::add_slot(), and common::Thread::prepend_task().

Referenced by main().

00153 {
00154     SearchTask* task = new SearchTask(model, search_context);
00155     task->abort_signal.add_slot(this, &TextController::on_search_aborted);
00156     thread.prepend_task(task, true);
00157 }

Here is the call graph for this function:

Here is the caller graph for this function:

void text::TextController::start (  ) 

Start working thread.

Definition at line 48 of file text_controller.cpp.

References common::Thread::start().

00049 {
00050     // Launch worker thread.
00051     thread.start();
00052 }

Here is the call graph for this function:

void text::TextController::stop ( void   ) 

Stop working thread.

Definition at line 54 of file text_controller.cpp.

References common::Thread::stop().

00055 {
00056     // Stop worker thread, wait until all tasks done.
00057     thread.stop();
00058 }

Here is the call graph for this function:


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