SourceView Class Reference
[Git model example]

View class for source code. More...

Inheritance diagram for SourceView:

Inheritance graph
[legend]

List of all members.

Public Member Functions

 SourceView (int role)
 Constructor.
void setIndex (const WModelIndex &index)
 Set model index.
virtual WWidgetrenderView ()
 Return the widget that renders the view.

Private Attributes

WModelIndex index_
 The index that is currently displayed.
int role_
 The role that is currently displayed.


Detailed Description

View class for source code.

A view class is used so that no server-side memory is used while displaying a potentially large file.

Definition at line 37 of file GitView.C.


Constructor & Destructor Documentation

SourceView::SourceView ( int  role  )  [inline]

Constructor.

The role will be used to retrieve data from a model index to be displayed.

Definition at line 45 of file GitView.C.

00046     : role_(role)
00047   { }


Member Function Documentation

void SourceView::setIndex ( const WModelIndex index  )  [inline]

Set model index.

The view is rerendered if the index contains new data.

Definition at line 53 of file GitView.C.

00053                                           {
00054     if (index != index_
00055         && (!index.isValid() || !index.data(role_).empty())) {
00056       index_ = index;
00057       update();
00058     }
00059   }

virtual WWidget* SourceView::renderView (  )  [inline, virtual]

Return the widget that renders the view.

Returns he view contents: renders the file to a WText widget. WViewWidget deletes this widget after every rendering step.

Implements Wt::WViewWidget.

Definition at line 66 of file GitView.C.

00066                                 {
00067     WText *result = new WText();
00068     result->setInline(false);
00069 
00070     if (!index_.isValid())
00071       return result;
00072 
00073     boost::any d = index_.data(role_);
00074     const std::string& t = boost::any_cast<const std::string&>(d);
00075 
00076     result->setTextFormat(PlainText);
00077     result->setText(t);
00078 
00079     return result;
00080   }


Member Data Documentation

The index that is currently displayed.

Definition at line 84 of file GitView.C.

int SourceView::role_ [private]

The role that is currently displayed.

Definition at line 87 of file GitView.C.


The documentation for this class was generated from the following file:

Generated on Mon Mar 9 08:28:57 2009 for Wt by doxygen 1.5.6