<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <title>Wt examples: SourceView Class Reference</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <link href="doxygen.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="top"><!-- do not remove this div! --> <div id="titlearea"> <table cellspacing="0" cellpadding="0"> <tbody> <tr style="height: 56px;"> <td style="padding-left: 0.5em;"> <div id="projectname">Wt examples  <span id="projectnumber">3.2.3</span> </div> </td> </tr> </tbody> </table> </div> <!-- Generated by Doxygen 1.7.5.1 --> <div id="navrow1" class="tabs"> <ul class="tablist"> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="modules.html"><span>Modules</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li class="current"><a href="annotated.html"><span>Classes</span></a></li> <li><a href="files.html"><span>Files</span></a></li> </ul> </div> <div id="navrow2" class="tabs2"> <ul class="tablist"> <li><a href="annotated.html"><span>Class List</span></a></li> <li><a href="inherits.html"><span>Class Hierarchy</span></a></li> <li><a href="functions.html"><span>Class Members</span></a></li> </ul> </div> </div> <div class="header"> <div class="summary"> <a href="#pub-methods">Public Member Functions</a> | <a href="#pri-methods">Private Member Functions</a> | <a href="#pri-attribs">Private Attributes</a> </div> <div class="headertitle"> <div class="title">SourceView Class Reference<div class="ingroups"><a class="el" href="group__gitmodelexample.html">Git model example</a></div></div> </div> </div> <div class="contents"> <!-- doxytag: class="SourceView" --><!-- doxytag: inherits="Wt::WViewWidget" --> <p>View class for source code. <a href="classSourceView.html#details">More...</a></p> <p><code>#include <<a class="el" href="SourceView_8h_source.html">SourceView.h</a>></code></p> <div class="dynheader"> Inheritance diagram for SourceView:</div> <div class="dyncontent"> <div class="center"><img src="classSourceView__inherit__graph.png" border="0" usemap="#SourceView_inherit__map" alt="Inheritance graph"/></div> <map name="SourceView_inherit__map" id="SourceView_inherit__map"> <area shape="rect" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WViewWidget.html" title="Wt::WViewWidget" alt="" coords="5,229,133,256"/><area shape="rect" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WWebWidget.html" title="Wt::WWebWidget" alt="" coords="5,155,133,181"/><area shape="rect" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WWidget.html" title="Wt::WWidget" alt="" coords="20,80,119,107"/><area shape="rect" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WObject.html" title="Wt::WObject" alt="" coords="21,5,117,32"/></map> <center><span class="legend">[<a href="graph_legend.html">legend</a>]</span></center></div> <p><a href="classSourceView-members.html">List of all members.</a></p> <table class="memberdecls"> <tr><td colspan="2"><h2><a name="pub-methods"></a> Public Member Functions</h2></td></tr> <tr><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classSourceView.html#abf613f5f07d2f82e337c42d9b5d92887">SourceView</a> (int fileNameRole, int contentRole, int filePathRole)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Constructor. <a href="#abf613f5f07d2f82e337c42d9b5d92887"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">virtual </td><td class="memItemRight" valign="bottom"><a class="el" href="classSourceView.html#aee500dba1590df1506a972b245a65f37">~SourceView</a> ()</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Destructor. <a href="#aee500dba1590df1506a972b245a65f37"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classSourceView.html#a10f2b88b0b8ea6b9563077e7958bc4d0">setIndex</a> (const <a class="elRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WModelIndex.html">Wt::WModelIndex</a> &index)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Sets the model index. <a href="#a10f2b88b0b8ea6b9563077e7958bc4d0"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">virtual <a class="elRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WWidget.html">Wt::WWidget</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="classSourceView.html#a9be1e72f0c562430de10742d9775c164">renderView</a> ()</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Returns the widget that renders the view. <a href="#a9be1e72f0c562430de10742d9775c164"></a><br/></td></tr> <tr><td colspan="2"><h2><a name="pri-methods"></a> Private Member Functions</h2></td></tr> <tr><td class="memItemLeft" align="right" valign="top">std::string </td><td class="memItemRight" valign="bottom"><a class="el" href="classSourceView.html#a74bb7ab280cd3f32ab507b65ba74fc63">imageExtension</a> (const std::string &fileName)</td></tr> <tr><td colspan="2"><h2><a name="pri-attribs"></a> Private Attributes</h2></td></tr> <tr><td class="memItemLeft" align="right" valign="top"><a class="elRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WModelIndex.html">Wt::WModelIndex</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="classSourceView.html#a94a8d44f1ef76dd99af7fb73ca754068">index_</a></td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">The index that is currently displayed. <a href="#a94a8d44f1ef76dd99af7fb73ca754068"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="classSourceView.html#a763d5eb3f0dd84613ccdd389eb90efe0">fileNameRole_</a></td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">The role that is currently displayed. <a href="#a763d5eb3f0dd84613ccdd389eb90efe0"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="classSourceView.html#a9ceb4e47cef2433d2d0da517f1ddbf2b">contentRole_</a></td></tr> <tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="classSourceView.html#ad399598fd48c236b0c7bb44478e59bd5">filePathRole_</a></td></tr> <tr><td class="memItemLeft" align="right" valign="top"><a class="elRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WMemoryResource.html">Wt::WMemoryResource</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="classSourceView.html#ad421de7452a92147305787e617aee41a">imageResource_</a></td></tr> </table> <hr/><a name="details" id="details"></a><h2>Detailed Description</h2> <div class="textblock"><p>View class for source code. </p> <p>A view class is used so that no server-side memory is used while displaying a potentially large file. </p> <p>Definition at line <a class="el" href="SourceView_8h_source.html#l00026">26</a> of file <a class="el" href="SourceView_8h_source.html">SourceView.h</a>.</p> </div><hr/><h2>Constructor & Destructor Documentation</h2> <a class="anchor" id="abf613f5f07d2f82e337c42d9b5d92887"></a><!-- doxytag: member="SourceView::SourceView" ref="abf613f5f07d2f82e337c42d9b5d92887" args="(int fileNameRole, int contentRole, int filePathRole)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">SourceView::SourceView </td> <td>(</td> <td class="paramtype">int </td> <td class="paramname"><em>fileNameRole</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int </td> <td class="paramname"><em>contentRole</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int </td> <td class="paramname"><em>filePathRole</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div> <div class="memdoc"> <p>Constructor. </p> <p>The <em>fileNameRole</em> will be used to retrieve data from a file to be displayed. If no data is set for this role, then <em>contentRole</em> should hold the data as a string. </p> <p>Definition at line <a class="el" href="SourceView_8C_source.html#l00020">20</a> of file <a class="el" href="SourceView_8C_source.html">SourceView.C</a>.</p> <div class="fragment"><pre class="fragment"> : <a class="code" href="classSourceView.html#a763d5eb3f0dd84613ccdd389eb90efe0" title="The role that is currently displayed.">fileNameRole_</a>(fileNameRole), <a class="code" href="classSourceView.html#a9ceb4e47cef2433d2d0da517f1ddbf2b">contentRole_</a>(contentRole), <a class="code" href="classSourceView.html#ad399598fd48c236b0c7bb44478e59bd5">filePathRole_</a>(filePathRole), <a class="code" href="classSourceView.html#ad421de7452a92147305787e617aee41a">imageResource_</a>(0) {} </pre></div> </div> </div> <a class="anchor" id="aee500dba1590df1506a972b245a65f37"></a><!-- doxytag: member="SourceView::~SourceView" ref="aee500dba1590df1506a972b245a65f37" args="()" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">SourceView::~SourceView </td> <td>(</td> <td class="paramname"></td><td>)</td> <td><code> [virtual]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Destructor. </p> <p>Definition at line <a class="el" href="SourceView_8C_source.html#l00027">27</a> of file <a class="el" href="SourceView_8C_source.html">SourceView.C</a>.</p> <div class="fragment"><pre class="fragment">{ } </pre></div> </div> </div> <hr/><h2>Member Function Documentation</h2> <a class="anchor" id="a74bb7ab280cd3f32ab507b65ba74fc63"></a><!-- doxytag: member="SourceView::imageExtension" ref="a74bb7ab280cd3f32ab507b65ba74fc63" args="(const std::string &fileName)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">std::string SourceView::imageExtension </td> <td>(</td> <td class="paramtype">const std::string & </td> <td class="paramname"><em>fileName</em></td><td>)</td> <td><code> [private]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Definition at line <a class="el" href="SourceView_8C_source.html#l00204">204</a> of file <a class="el" href="SourceView_8C_source.html">SourceView.C</a>.</p> <div class="fragment"><pre class="fragment">{ <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span> *imageExtensions[] = { <span class="stringliteral">".png"</span>, <span class="stringliteral">".gif"</span>, <span class="stringliteral">".jpg"</span>, <span class="stringliteral">"jpeg"</span>, <span class="stringliteral">".ico"</span>, 0 }; fs::path p(fileName); std::string extension = fs::extension(p); <span class="keywordflow">for</span> (<span class="keyword">const</span> <span class="keywordtype">char</span> **s = imageExtensions; *s != 0; ++s) <span class="keywordflow">if</span> (*s == extension) <span class="keywordflow">return</span> extension.substr(1); <span class="keywordflow">return</span> std::string(); } </pre></div> </div> </div> <a class="anchor" id="a9be1e72f0c562430de10742d9775c164"></a><!-- doxytag: member="SourceView::renderView" ref="a9be1e72f0c562430de10742d9775c164" args="()" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname"><a class="elRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WWidget.html">WWidget</a> * SourceView::renderView </td> <td>(</td> <td class="paramname"></td><td>)</td> <td><code> [virtual]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Returns the widget that renders the view. </p> <p>Returns he view contents: renders the file to a WText widget. WViewWidget deletes this widget after every rendering step. </p> <p>Implements <a class="elRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WViewWidget.html#af7df983ff1ca6e1368579f254b85fcd6">Wt::WViewWidget</a>.</p> <p>Definition at line <a class="el" href="SourceView_8C_source.html#l00095">95</a> of file <a class="el" href="SourceView_8C_source.html">SourceView.C</a>.</p> <div class="fragment"><pre class="fragment">{ <span class="keywordflow">if</span> (!<a class="code" href="classSourceView.html#a94a8d44f1ef76dd99af7fb73ca754068" title="The index that is currently displayed.">index_</a>.<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WModelIndex.html#a1d4b05ee51c5c6961d6123565fd77c82">isValid</a>()) { <span class="comment">// no content</span> <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WText.html">WText</a> *result = <span class="keyword">new</span> <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WText.html">WText</a>(); result-><a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WWebWidget.html#ad0957c892e70c6bf5399cf71e66f3e11">setInline</a>(<span class="keyword">false</span>); <span class="keywordflow">return</span> result; } <span class="comment">/*</span> <span class="comment"> * read the contents, from string or file name</span> <span class="comment"> */</span> boost::any contentsData = <a class="code" href="classSourceView.html#a94a8d44f1ef76dd99af7fb73ca754068" title="The index that is currently displayed.">index_</a>.<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WModelIndex.html#a7f05920329ca4b7fdbb10931afdb634e">data</a>(<a class="code" href="classSourceView.html#a9ceb4e47cef2433d2d0da517f1ddbf2b">contentRole_</a>); std::string content; <span class="keywordflow">if</span> (!contentsData.empty()) content = boost::any_cast<const std::string&>(contentsData); boost::any fileNameData = <a class="code" href="classSourceView.html#a94a8d44f1ef76dd99af7fb73ca754068" title="The index that is currently displayed.">index_</a>.<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WModelIndex.html#a7f05920329ca4b7fdbb10931afdb634e">data</a>(<a class="code" href="classSourceView.html#a763d5eb3f0dd84613ccdd389eb90efe0" title="The role that is currently displayed.">fileNameRole_</a>); std::string fileName = boost::any_cast<<span class="keyword">const</span> std::string&>(fileNameData); boost::any filePathData = <a class="code" href="classSourceView.html#a94a8d44f1ef76dd99af7fb73ca754068" title="The index that is currently displayed.">index_</a>.<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WModelIndex.html#a7f05920329ca4b7fdbb10931afdb634e">data</a>(<a class="code" href="classSourceView.html#ad399598fd48c236b0c7bb44478e59bd5">filePathRole_</a>); std::string filePath; <span class="keywordflow">if</span> (!filePathData.empty()) filePath = boost::any_cast<const std::string&>(filePathData); <span class="comment">/*</span> <span class="comment"> * determine source language, for source highlight</span> <span class="comment"> */</span> std::string lang = <a class="code" href="SourceView_8C.html#a8fe8775b5b65da2de2254166ecdcc74e">getLanguageFromFileExtension</a>(fileName); <span class="keywordflow">if</span> (content != <span class="stringliteral">""</span> && content.substr(0, 100).find(<span class="stringliteral">"-*- C++ -*-"</span>) != std::string::npos) lang = <span class="stringliteral">"cpp"</span>; std::string outputFileName; <span class="keywordflow">if</span> (lang != <span class="stringliteral">""</span>) { std::string inputFileName; <span class="keywordflow">if</span> (!filePathData.empty()) inputFileName = filePath; <span class="keywordflow">else</span> { inputFileName = <a class="code" href="SourceView_8C.html#ae50d5388ee0cfd7d80f931509dc435cc">tempFileName</a>(); std::ofstream out(inputFileName.c_str(), std::ios::out | std::ios::binary); out.write(content.c_str(), (std::streamsize)content.length()); out.close(); } outputFileName = <a class="code" href="SourceView_8C.html#ae50d5388ee0cfd7d80f931509dc435cc">tempFileName</a>(); std::string sourceHighlightCommand = <span class="stringliteral">"source-highlight "</span>; sourceHighlightCommand += <span class="stringliteral">"--src-lang="</span> + lang + <span class="stringliteral">" "</span>; sourceHighlightCommand += <span class="stringliteral">"--out-format=xhtml "</span>; sourceHighlightCommand += <span class="stringliteral">"--input="</span> + inputFileName + <span class="stringliteral">" "</span>; sourceHighlightCommand += <span class="stringliteral">"--output="</span> + outputFileName + <span class="stringliteral">" "</span>; std::cerr << sourceHighlightCommand << std::endl; <span class="keywordtype">bool</span> sourceHighlightOk = system(sourceHighlightCommand.c_str()) == 0; <span class="keywordflow">if</span> (sourceHighlightOk) content = <a class="code" href="SourceView_8C.html#a5df67bacd4ae6a5fd90b7bfd5a16f263">readFileToString</a>(outputFileName); <span class="keywordflow">else</span> { content = <a class="code" href="SourceView_8C.html#a5df67bacd4ae6a5fd90b7bfd5a16f263">readFileToString</a>(inputFileName); lang = <span class="stringliteral">""</span>; } unlink(outputFileName.c_str()); <span class="keywordflow">if</span> (filePathData.empty()) unlink(inputFileName.c_str()); } <span class="keywordflow">if</span> (content == <span class="stringliteral">""</span>) <span class="comment">// do not load binary files, we would need to perform proper UTF-8</span> <span class="comment">// transcoding to display them</span> <span class="keywordflow">if</span> (!boost::iends_with(fileName, <span class="stringliteral">".jar"</span>) && !boost::iends_with(fileName, <span class="stringliteral">".war"</span>) && !boost::iends_with(fileName, <span class="stringliteral">".class"</span>)) content = <a class="code" href="SourceView_8C.html#a5df67bacd4ae6a5fd90b7bfd5a16f263">readFileToString</a>(fileName); <span class="keyword">delete</span> <a class="code" href="classSourceView.html#ad421de7452a92147305787e617aee41a">imageResource_</a>; <a class="code" href="classSourceView.html#ad421de7452a92147305787e617aee41a">imageResource_</a> = 0; <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WWidget.html">WWidget</a> *result = 0; <span class="keywordflow">if</span> (!<a class="code" href="classSourceView.html#a74bb7ab280cd3f32ab507b65ba74fc63">imageExtension</a>(fileName).empty()) { <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WImage.html">WImage</a> *image = <span class="keyword">new</span> <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WImage.html">WImage</a>(); <a class="code" href="classSourceView.html#ad421de7452a92147305787e617aee41a">imageResource_</a> = <span class="keyword">new</span> <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WMemoryResource.html">WMemoryResource</a>(<span class="keyword">this</span>); <a class="code" href="classSourceView.html#ad421de7452a92147305787e617aee41a">imageResource_</a>-><a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WMemoryResource.html#a057ea5ac18daacf2894c28e5bfbbde60">setMimeType</a>(<span class="stringliteral">"mime/"</span> + <a class="code" href="classSourceView.html#a74bb7ab280cd3f32ab507b65ba74fc63">imageExtension</a>(fileName)); <a class="code" href="classSourceView.html#ad421de7452a92147305787e617aee41a">imageResource_</a>-><a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WMemoryResource.html#a330bf924bd2d01de7dfce15778b56d48">setData</a>((<span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span>*)content.data(), (int)content.length()); image-><a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WImage.html#ab3b0e9034aefca28cbda7d8943738aca">setImageLink</a>(<a class="code" href="classSourceView.html#ad421de7452a92147305787e617aee41a">imageResource_</a>); result = image; } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (lang != <span class="stringliteral">""</span>) { <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WText.html">WText</a> *text = <span class="keyword">new</span> <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WText.html">WText</a>(); text-><a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WText.html#af22c64c4c5fed3d2aef0915a7e5c5866">setTextFormat</a>(XHTMLUnsafeText); text-><a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WText.html#a2f788aa524d51b3962642c9f565e66e6">setText</a>(WString::fromUTF8(content)); result = text; } <span class="keywordflow">else</span> { <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WText.html">WText</a> *text = <span class="keyword">new</span> <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WText.html">WText</a>(); text-><a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WText.html#af22c64c4c5fed3d2aef0915a7e5c5866">setTextFormat</a>(PlainText); text-><a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WText.html#a2f788aa524d51b3962642c9f565e66e6">setText</a>(WString::fromUTF8(content)); result = text; } result-><a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WWidget.html#ac78e3af143883334c82031790c87416e">setInline</a>(<span class="keyword">false</span>); WApplication::instance() ->doJavaScript(result-><a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WWidget.html#aa2b7078b3b43d53a85e5244b45d504f7">jsRef</a>() + <span class="stringliteral">".parentNode.scrollTop = 0;"</span>); <span class="keywordflow">return</span> result; } </pre></div> </div> </div> <a class="anchor" id="a10f2b88b0b8ea6b9563077e7958bc4d0"></a><!-- doxytag: member="SourceView::setIndex" ref="a10f2b88b0b8ea6b9563077e7958bc4d0" args="(const Wt::WModelIndex &index)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">bool SourceView::setIndex </td> <td>(</td> <td class="paramtype">const <a class="elRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WModelIndex.html">Wt::WModelIndex</a> & </td> <td class="paramname"><em>index</em></td><td>)</td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Sets the model index. </p> <p>Returns true whether the view will be rerendered. The view will only be rerendered if the index contains new data. </p> <p>Definition at line <a class="el" href="SourceView_8C_source.html#l00030">30</a> of file <a class="el" href="SourceView_8C_source.html">SourceView.C</a>.</p> <div class="fragment"><pre class="fragment">{ <span class="keywordflow">if</span> (index != <a class="code" href="classSourceView.html#a94a8d44f1ef76dd99af7fb73ca754068" title="The index that is currently displayed.">index_</a> && index.<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WModelIndex.html#a1d4b05ee51c5c6961d6123565fd77c82">isValid</a>()) { std::string fp = index.<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WModelIndex.html#a7f05920329ca4b7fdbb10931afdb634e">data</a>(<a class="code" href="classSourceView.html#ad399598fd48c236b0c7bb44478e59bd5">filePathRole_</a>).empty() ? std::string() : boost::any_cast<std::string>(index.data(<a class="code" href="classSourceView.html#ad399598fd48c236b0c7bb44478e59bd5">filePathRole_</a>)); <span class="keywordflow">if</span> (!index.<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WModelIndex.html#a7f05920329ca4b7fdbb10931afdb634e">data</a>(<a class="code" href="classSourceView.html#a9ceb4e47cef2433d2d0da517f1ddbf2b">contentRole_</a>).empty() || (!fp.empty() && !fs::is_directory(fp))) { <a class="code" href="classSourceView.html#a94a8d44f1ef76dd99af7fb73ca754068" title="The index that is currently displayed.">index_</a> = index; <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WViewWidget.html#a7dcbc05eb15c4d4168141871d5908e37">update</a>(); <span class="keywordflow">return</span> <span class="keyword">true</span>; } } <span class="keywordflow">return</span> <span class="keyword">false</span>; } </pre></div> </div> </div> <hr/><h2>Member Data Documentation</h2> <a class="anchor" id="a9ceb4e47cef2433d2d0da517f1ddbf2b"></a><!-- doxytag: member="SourceView::contentRole_" ref="a9ceb4e47cef2433d2d0da517f1ddbf2b" args="" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int <a class="el" href="classSourceView.html#a9ceb4e47cef2433d2d0da517f1ddbf2b">SourceView::contentRole_</a><code> [private]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Definition at line <a class="el" href="SourceView_8h_source.html#l00061">61</a> of file <a class="el" href="SourceView_8h_source.html">SourceView.h</a>.</p> </div> </div> <a class="anchor" id="a763d5eb3f0dd84613ccdd389eb90efe0"></a><!-- doxytag: member="SourceView::fileNameRole_" ref="a763d5eb3f0dd84613ccdd389eb90efe0" args="" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int <a class="el" href="classSourceView.html#a763d5eb3f0dd84613ccdd389eb90efe0">SourceView::fileNameRole_</a><code> [private]</code></td> </tr> </table> </div> <div class="memdoc"> <p>The role that is currently displayed. </p> <p>Definition at line <a class="el" href="SourceView_8h_source.html#l00060">60</a> of file <a class="el" href="SourceView_8h_source.html">SourceView.h</a>.</p> </div> </div> <a class="anchor" id="ad399598fd48c236b0c7bb44478e59bd5"></a><!-- doxytag: member="SourceView::filePathRole_" ref="ad399598fd48c236b0c7bb44478e59bd5" args="" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int <a class="el" href="classSourceView.html#ad399598fd48c236b0c7bb44478e59bd5">SourceView::filePathRole_</a><code> [private]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Definition at line <a class="el" href="SourceView_8h_source.html#l00062">62</a> of file <a class="el" href="SourceView_8h_source.html">SourceView.h</a>.</p> </div> </div> <a class="anchor" id="ad421de7452a92147305787e617aee41a"></a><!-- doxytag: member="SourceView::imageResource_" ref="ad421de7452a92147305787e617aee41a" args="" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname"><a class="elRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WMemoryResource.html">Wt::WMemoryResource</a>* <a class="el" href="classSourceView.html#ad421de7452a92147305787e617aee41a">SourceView::imageResource_</a><code> [private]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Definition at line <a class="el" href="SourceView_8h_source.html#l00064">64</a> of file <a class="el" href="SourceView_8h_source.html">SourceView.h</a>.</p> </div> </div> <a class="anchor" id="a94a8d44f1ef76dd99af7fb73ca754068"></a><!-- doxytag: member="SourceView::index_" ref="a94a8d44f1ef76dd99af7fb73ca754068" args="" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname"><a class="elRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WModelIndex.html">Wt::WModelIndex</a> <a class="el" href="classSourceView.html#a94a8d44f1ef76dd99af7fb73ca754068">SourceView::index_</a><code> [private]</code></td> </tr> </table> </div> <div class="memdoc"> <p>The index that is currently displayed. </p> <p>Definition at line <a class="el" href="SourceView_8h_source.html#l00057">57</a> of file <a class="el" href="SourceView_8h_source.html">SourceView.h</a>.</p> </div> </div> <hr/>The documentation for this class was generated from the following files:<ul> <li>/home/koen/project/wt/public-git/wt/examples/wt-homepage/<a class="el" href="SourceView_8h_source.html">SourceView.h</a></li> <li>/home/koen/project/wt/public-git/wt/examples/wt-homepage/<a class="el" href="SourceView_8C_source.html">SourceView.C</a></li> </ul> </div> <hr size="1"><address style="text-align: right; margin: 3px"><small> Generated on Thu Nov 1 2012 for <a href="http://www.webtoolkit.eu/wt">the C++ Web Toolkit (Wt)</a> by <a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" border="0" style="vertical-align: middle; display: inline-block; height: 2em"></a> 1.7.5.1</small></address> </body> </html>