File: ExampleSourceViewer_8C-source.html

package info (click to toggle)
witty 3.1.2-3
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 45,512 kB
  • ctags: 35,832
  • sloc: cpp: 69,469; ansic: 66,945; xml: 4,383; sh: 594; perl: 108; makefile: 106
file content (384 lines) | stat: -rw-r--r-- 50,567 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Wt examples: /home/koen/project/wt/public-git/wt/examples/wt-homepage/ExampleSourceViewer.C Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.6 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.html"><span>Main&nbsp;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><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
<h1>/home/koen/project/wt/public-git/wt/examples/wt-homepage/ExampleSourceViewer.C</h1><a href="ExampleSourceViewer_8C.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment"> * Copyright (C) 2009 Emweb bvba</span>
<a name="l00003"></a>00003 <span class="comment"> *</span>
<a name="l00004"></a>00004 <span class="comment"> * See the LICENSE file for terms of use.</span>
<a name="l00005"></a>00005 <span class="comment"> */</span>
<a name="l00006"></a>00006 
<a name="l00007"></a>00007 <span class="preprocessor">#include &lt;iostream&gt;</span>
<a name="l00008"></a>00008 <span class="preprocessor">#include &lt;stdlib.h&gt;</span>
<a name="l00009"></a>00009 <span class="preprocessor">#include &lt;algorithm&gt;</span>
<a name="l00010"></a>00010 
<a name="l00011"></a>00011 <span class="preprocessor">#include &lt;Wt/WApplication&gt;</span>
<a name="l00012"></a>00012 <span class="preprocessor">#include &lt;Wt/WContainerWidget&gt;</span>
<a name="l00013"></a>00013 <span class="preprocessor">#include &lt;Wt/WEnvironment&gt;</span>
<a name="l00014"></a>00014 <span class="preprocessor">#include &lt;Wt/WLineEdit&gt;</span>
<a name="l00015"></a>00015 <span class="preprocessor">#include &lt;Wt/WGridLayout&gt;</span>
<a name="l00016"></a>00016 <span class="preprocessor">#include &lt;Wt/WHBoxLayout&gt;</span>
<a name="l00017"></a>00017 <span class="preprocessor">#include &lt;Wt/WPushButton&gt;</span>
<a name="l00018"></a>00018 <span class="preprocessor">#include &lt;Wt/WTable&gt;</span>
<a name="l00019"></a>00019 <span class="preprocessor">#include &lt;Wt/WText&gt;</span>
<a name="l00020"></a>00020 <span class="preprocessor">#include &lt;Wt/WTreeView&gt;</span>
<a name="l00021"></a>00021 <span class="preprocessor">#include &lt;Wt/WVBoxLayout&gt;</span>
<a name="l00022"></a>00022 <span class="preprocessor">#include &lt;Wt/WViewWidget&gt;</span>
<a name="l00023"></a>00023 
<a name="l00024"></a>00024 <span class="preprocessor">#include &lt;boost/filesystem/operations.hpp&gt;</span>
<a name="l00025"></a>00025 <span class="preprocessor">#include &lt;boost/filesystem/exception.hpp&gt;</span>
<a name="l00026"></a>00026 <span class="preprocessor">#include &lt;boost/filesystem/convenience.hpp&gt;</span>
<a name="l00027"></a>00027 <span class="preprocessor">#include &lt;boost/algorithm/string.hpp&gt;</span>
<a name="l00028"></a>00028 
<a name="l00029"></a>00029 <span class="preprocessor">#include "<a class="code" href="ExampleSourceViewer_8h.html">ExampleSourceViewer.h</a>"</span>
<a name="l00030"></a>00030 <span class="preprocessor">#include "<a class="code" href="FileItem_8h.html">FileItem.h</a>"</span>
<a name="l00031"></a>00031 
<a name="l00032"></a>00032 <span class="keyword">using namespace </span>Wt; 
<a name="l00033"></a>00033 <span class="keyword">namespace </span>fs = boost::filesystem;
<a name="l00034"></a>00034 
<a name="l00035"></a>00035 <span class="comment">// Same as p.filename() in latest boost::filesystem</span>
<a name="l00036"></a><a class="code" href="ExampleSourceViewer_8C.html#90d62aee81b34c117b8f494a54bee4d4">00036</a> <span class="keyword">static</span> std::string <a class="code" href="ExampleSourceViewer_8C.html#90d62aee81b34c117b8f494a54bee4d4">filename</a>(<span class="keyword">const</span> fs::path&amp; p)
<a name="l00037"></a>00037 {
<a name="l00038"></a>00038   <span class="keywordflow">return</span> p.empty() ? std::string() : *--p.end();
<a name="l00039"></a>00039 }
<a name="l00040"></a>00040 
<a name="l00041"></a>00041 <span class="comment">// Same as p.stem() in latest boost::filesystem</span>
<a name="l00042"></a><a class="code" href="ExampleSourceViewer_8C.html#2fb90126657b786f14062b06f995583c">00042</a> <span class="keyword">static</span> std::string <a class="code" href="ExampleSourceViewer_8C.html#2fb90126657b786f14062b06f995583c">stem</a>(<span class="keyword">const</span> fs::path&amp; p)
<a name="l00043"></a>00043 {
<a name="l00044"></a>00044   std::string fn = <a class="code" href="ExampleSourceViewer_8C.html#90d62aee81b34c117b8f494a54bee4d4">filename</a>(p);
<a name="l00045"></a>00045   std::size_t pos = fn.find(<span class="charliteral">'.'</span>);
<a name="l00046"></a>00046   <span class="keywordflow">if</span> (pos == std::string::npos)
<a name="l00047"></a>00047     <span class="keywordflow">return</span> fn;
<a name="l00048"></a>00048   <span class="keywordflow">else</span>
<a name="l00049"></a>00049     <span class="keywordflow">return</span> fn.substr(0, pos);
<a name="l00050"></a>00050 }
<a name="l00051"></a>00051 
<a name="l00052"></a>00052 <span class="comment">// Should be same as p.parent_path() in latest boost::filesystem</span>
<a name="l00053"></a>00053 <span class="comment">// This is not entirely according to fs::path::parent_path() in 1.39.0</span>
<a name="l00054"></a><a class="code" href="ExampleSourceViewer_8C.html#e19c9a4a8bd0a5e02a00d6e17707a342">00054</a> fs::path <a class="code" href="ExampleSourceViewer_8C.html#e19c9a4a8bd0a5e02a00d6e17707a342">parent_path</a>(<span class="keyword">const</span> fs::path&amp; p)
<a name="l00055"></a>00055 {
<a name="l00056"></a>00056   std::string fn = <a class="code" href="ExampleSourceViewer_8C.html#90d62aee81b34c117b8f494a54bee4d4">filename</a>(p);
<a name="l00057"></a>00057   std::string path = p.string();
<a name="l00058"></a>00058 
<a name="l00059"></a>00059   <span class="keywordflow">return</span> path.substr(0, path.length() - fn.length() - 1);
<a name="l00060"></a>00060 }
<a name="l00061"></a>00061 
<a name="l00062"></a><a class="code" href="ExampleSourceViewer_8C.html#cb92ccbf2405b113c0b8b66cec63aaae">00062</a> <span class="keyword">static</span> <span class="keywordtype">bool</span> <a class="code" href="ExampleSourceViewer_8C.html#cb92ccbf2405b113c0b8b66cec63aaae">comparePaths</a>(<span class="keyword">const</span> fs::path&amp; p1, <span class="keyword">const</span> fs::path&amp; p2)
<a name="l00063"></a>00063 {
<a name="l00064"></a>00064   <span class="keywordflow">return</span> <a class="code" href="ExampleSourceViewer_8C.html#90d62aee81b34c117b8f494a54bee4d4">filename</a>(p1) &gt; <a class="code" href="ExampleSourceViewer_8C.html#90d62aee81b34c117b8f494a54bee4d4">filename</a>(p2);
<a name="l00065"></a>00065 }
<a name="l00066"></a>00066 
<a name="l00067"></a><a class="code" href="classExampleSourceViewer.html#3ab5978077589e8dbf6d8cfdb6da36d4">00067</a> <a class="code" href="classExampleSourceViewer.html#3ab5978077589e8dbf6d8cfdb6da36d4" title="Constructor.">ExampleSourceViewer::ExampleSourceViewer</a>(<span class="keyword">const</span> std::string&amp; deployPath,
<a name="l00068"></a>00068                                          <span class="keyword">const</span> std::string&amp; examplesRoot,
<a name="l00069"></a>00069                                          <span class="keyword">const</span> std::string&amp; examplesType)
<a name="l00070"></a>00070   : deployPath_(deployPath),
<a name="l00071"></a>00071     examplesRoot_(examplesRoot),
<a name="l00072"></a>00072     examplesType_(examplesType)
<a name="l00073"></a>00073 {
<a name="l00074"></a>00074   wApp-&gt;internalPathChanged().connect
<a name="l00075"></a>00075     (SLOT(<span class="keyword">this</span>, <a class="code" href="classExampleSourceViewer.html#8aeb783e81242455f97f83d259919a20">ExampleSourceViewer::handlePathChange</a>));
<a name="l00076"></a>00076 
<a name="l00077"></a>00077   <a class="code" href="classExampleSourceViewer.html#8aeb783e81242455f97f83d259919a20">handlePathChange</a>();
<a name="l00078"></a>00078 }
<a name="l00079"></a>00079 
<a name="l00080"></a><a class="code" href="classExampleSourceViewer.html#8aeb783e81242455f97f83d259919a20">00080</a> <span class="keywordtype">void</span> <a class="code" href="classExampleSourceViewer.html#8aeb783e81242455f97f83d259919a20">ExampleSourceViewer::handlePathChange</a>()
<a name="l00081"></a>00081 {
<a name="l00082"></a>00082   <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WApplication.html">WApplication</a> *app = wApp;
<a name="l00083"></a>00083 
<a name="l00084"></a>00084   <span class="keywordflow">if</span> (app-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WApplication.html#ed54bd83339bc80b3cffba9067ab1e39">internalPathMatches</a>(<a class="code" href="classExampleSourceViewer.html#49e72c4bc9714e8fdf9fad810f0d79b1">deployPath_</a>)) {
<a name="l00085"></a>00085     std::string example = app-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WApplication.html#95e6b5e4dc9084d45e166264b10b3c46">internalPathNextPart</a>(<a class="code" href="classExampleSourceViewer.html#49e72c4bc9714e8fdf9fad810f0d79b1">deployPath_</a>);
<a name="l00086"></a>00086 
<a name="l00087"></a>00087     <span class="keywordflow">if</span> (example.find(<span class="stringliteral">".."</span>) != std::string::npos
<a name="l00088"></a>00088         || example.find(<span class="charliteral">'/'</span>) != std::string::npos
<a name="l00089"></a>00089         || example.find(<span class="charliteral">'\\'</span>) != std::string::npos)
<a name="l00090"></a>00090       <a class="code" href="classExampleSourceViewer.html#04710b0af789b12346a22a2f7ba2bccf">setExample</a>(<span class="stringliteral">"INVALID_DIR"</span>, <span class="stringliteral">"INVALID"</span>);
<a name="l00091"></a>00091     <span class="keywordflow">else</span>
<a name="l00092"></a>00092       <a class="code" href="classExampleSourceViewer.html#04710b0af789b12346a22a2f7ba2bccf">setExample</a>(<a class="code" href="classExampleSourceViewer.html#7e33f7d49055157d7d26d036f91d2891">examplesRoot_</a> + example, example);
<a name="l00093"></a>00093   }
<a name="l00094"></a>00094 }
<a name="l00095"></a>00095 
<a name="l00096"></a><a class="code" href="classExampleSourceViewer.html#04710b0af789b12346a22a2f7ba2bccf">00096</a> <span class="keywordtype">void</span> <a class="code" href="classExampleSourceViewer.html#04710b0af789b12346a22a2f7ba2bccf">ExampleSourceViewer::setExample</a>(<span class="keyword">const</span> std::string&amp; exampleDir,
<a name="l00097"></a>00097                                      <span class="keyword">const</span> std::string&amp; example)
<a name="l00098"></a>00098 {
<a name="l00099"></a>00099   <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WContainerWidget.html#608f748cbdda763f1a11556ddad9fbe1">clear</a>();
<a name="l00100"></a>00100 
<a name="l00101"></a>00101   <span class="keywordtype">bool</span> exists = <span class="keyword">false</span>;
<a name="l00102"></a>00102   <span class="keywordflow">try</span> {
<a name="l00103"></a>00103     exists = fs::exists(exampleDir);
<a name="l00104"></a>00104   } <span class="keywordflow">catch</span> (std::exception&amp;) {
<a name="l00105"></a>00105   }
<a name="l00106"></a>00106 
<a name="l00107"></a>00107   <span class="keywordflow">if</span> (!exists) {
<a name="l00108"></a>00108     <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WContainerWidget.html#2cfe66d9b62940f889e99538a9f478d2">addWidget</a>(<span class="keyword">new</span> <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WText.html">WText</a>(<span class="stringliteral">"No such example: "</span> + exampleDir));
<a name="l00109"></a>00109     <span class="keywordflow">return</span>;
<a name="l00110"></a>00110   }
<a name="l00111"></a>00111 
<a name="l00112"></a>00112   <a class="code" href="classExampleSourceViewer.html#09d648f3a6b7aa3ebeeac775f8a197cc">model_</a> = <span class="keyword">new</span> <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WStandardItemModel.html">WStandardItemModel</a>(0, 1, <span class="keyword">this</span>);
<a name="l00113"></a>00113   <span class="keywordflow">if</span> (<a class="code" href="classExampleSourceViewer.html#7aaeb2ded7907e864f3ea804f19307cd">examplesType_</a> == <span class="stringliteral">"CPP"</span>) {
<a name="l00114"></a>00114     <a class="code" href="classExampleSourceViewer.html#e10b86e9ea10445cb5f4cac95e168c82">cppTraverseDir</a>(<a class="code" href="classExampleSourceViewer.html#09d648f3a6b7aa3ebeeac775f8a197cc">model_</a>-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WStandardItemModel.html#5fdc79e8100020d98a77ad3543019477">invisibleRootItem</a>(), exampleDir);
<a name="l00115"></a>00115   } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="classExampleSourceViewer.html#7aaeb2ded7907e864f3ea804f19307cd">examplesType_</a> == <span class="stringliteral">"JAVA"</span>) {
<a name="l00116"></a>00116     <a class="code" href="classExampleSourceViewer.html#bdf6cba77785ba83e5cb04b78d7f9532">javaTraverseDir</a>(<a class="code" href="classExampleSourceViewer.html#09d648f3a6b7aa3ebeeac775f8a197cc">model_</a>-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WStandardItemModel.html#5fdc79e8100020d98a77ad3543019477">invisibleRootItem</a>(), exampleDir);
<a name="l00117"></a>00117   }
<a name="l00118"></a>00118 
<a name="l00119"></a>00119   WApplication::instance()-&gt;setTitle(<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WWidget.html#a651f107ec7cf080faef6c435705fc44">tr</a>(<span class="stringliteral">"srcview.title."</span> + example));
<a name="l00120"></a>00120   <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WText.html">WText</a> *title = 
<a name="l00121"></a>00121     <span class="keyword">new</span> <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WText.html">WText</a>(<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WWidget.html#a651f107ec7cf080faef6c435705fc44">tr</a>(<span class="stringliteral">"srcview.title."</span> + <a class="code" href="classExampleSourceViewer.html#7aaeb2ded7907e864f3ea804f19307cd">examplesType_</a> + <span class="stringliteral">"."</span> + example));
<a name="l00122"></a>00122 
<a name="l00123"></a>00123   <a class="code" href="classExampleSourceViewer.html#548859a1b20480151f542ebbcc82e5d0">exampleView_</a> = <span class="keyword">new</span> <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WTreeView.html">WTreeView</a>();
<a name="l00124"></a>00124   <a class="code" href="classExampleSourceViewer.html#548859a1b20480151f542ebbcc82e5d0">exampleView_</a>-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WTreeView.html#2367f47b0c80ec909d8e4d7626955a83">setHeaderHeight</a>(0);
<a name="l00125"></a>00125   <a class="code" href="classExampleSourceViewer.html#548859a1b20480151f542ebbcc82e5d0">exampleView_</a>-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WTreeView.html#482314306c8404d7ed941fd986e32623">resize</a>(300, 300);
<a name="l00126"></a>00126   <a class="code" href="classExampleSourceViewer.html#548859a1b20480151f542ebbcc82e5d0">exampleView_</a>-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WAbstractItemView.html#e1c86a0f37f97f63aed3b00fd8ffad7c">setSortingEnabled</a>(<span class="keyword">false</span>);
<a name="l00127"></a>00127   <a class="code" href="classExampleSourceViewer.html#548859a1b20480151f542ebbcc82e5d0">exampleView_</a>-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WTreeView.html#390300f766472476e6a0df5aefaa2ef0">setModel</a>(<a class="code" href="classExampleSourceViewer.html#09d648f3a6b7aa3ebeeac775f8a197cc">model_</a>);
<a name="l00128"></a>00128   <a class="code" href="classExampleSourceViewer.html#548859a1b20480151f542ebbcc82e5d0">exampleView_</a>-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WTreeView.html#dd40d3e05352ae094f6fe2b9c879c2c7">expandToDepth</a>(1);
<a name="l00129"></a>00129   <a class="code" href="classExampleSourceViewer.html#548859a1b20480151f542ebbcc82e5d0">exampleView_</a>-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WAbstractItemView.html#f6fcd9761e2f7a3b497d3563c849d320">setSelectionMode</a>(<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/namespaceWt.html#74b3f7eb1689a3cbf0ea514ffd20bccc4fd3c5ba6ce5289a1e732d85f002882a">SingleSelection</a>);
<a name="l00130"></a>00130   <a class="code" href="classExampleSourceViewer.html#548859a1b20480151f542ebbcc82e5d0">exampleView_</a>-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WTreeView.html#48f74194ae6bd63c08a6ff76ecb3e39c">setAlternatingRowColors</a>(<span class="keyword">false</span>);
<a name="l00131"></a>00131   <a class="code" href="classExampleSourceViewer.html#548859a1b20480151f542ebbcc82e5d0">exampleView_</a>-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WAbstractItemView.html#9ed7710caa82e030db59020f4add4025">selectionChanged</a>().<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1Signal.html#6fc9536d2e7f59684ec32f3734b01f38">connect</a>
<a name="l00132"></a>00132     (SLOT(<span class="keyword">this</span>, <a class="code" href="classExampleSourceViewer.html#7f10a65267869bb570fec25bc19348ac" title="Displayed the currently selected file.">ExampleSourceViewer::showFile</a>));
<a name="l00133"></a>00133 
<a name="l00134"></a>00134   <a class="code" href="classExampleSourceViewer.html#efc329bfd3d8f7ae11c3f452a5744ab9">sourceView_</a> = <span class="keyword">new</span> <a class="code" href="classSourceView.html" title="View class for source code.">SourceView</a>(<a class="code" href="classFileItem.html#e072fe0aa9a614bfc39a9f59cf987771">FileItem::FileNameRole</a>, 
<a name="l00135"></a>00135                                <a class="code" href="classFileItem.html#e1dbc221110c06627765b421c30df2ab">FileItem::ContentsRole</a>,
<a name="l00136"></a>00136                                <a class="code" href="classFileItem.html#a8d601340669b5628a8bac8e35ccd936">FileItem::FilePathRole</a>);
<a name="l00137"></a>00137   <a class="code" href="classExampleSourceViewer.html#efc329bfd3d8f7ae11c3f452a5744ab9">sourceView_</a>-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WWebWidget.html#6fd43dced1a62f7e79bc3522eeb16216">setStyleClass</a>(<span class="stringliteral">"source-view"</span>);
<a name="l00138"></a>00138 
<a name="l00139"></a>00139   <span class="comment">/*</span>
<a name="l00140"></a>00140 <span class="comment">   * Expand path to first file, to show something in the source viewer</span>
<a name="l00141"></a>00141 <span class="comment">   */</span>
<a name="l00142"></a>00142   <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WStandardItem.html">WStandardItem</a> *w = <a class="code" href="classExampleSourceViewer.html#09d648f3a6b7aa3ebeeac775f8a197cc">model_</a>-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WStandardItemModel.html#32d755ace793c2110b0fa5d650a0d577">item</a>(0);
<a name="l00143"></a>00143   <span class="keywordflow">do</span> {
<a name="l00144"></a>00144     <a class="code" href="classExampleSourceViewer.html#548859a1b20480151f542ebbcc82e5d0">exampleView_</a>-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WTreeView.html#49566dd5cc8d1d0d95bad4783dd4e11a">setExpanded</a>(w-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WStandardItem.html#8afc6170ff2544d385823795b4dded37">index</a>(), <span class="keyword">true</span>);
<a name="l00145"></a>00145     <span class="keywordflow">if</span> (w-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WStandardItem.html#0b025885afc1500285359821f52bb531">rowCount</a>() &gt; 0)
<a name="l00146"></a>00146       w = w-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WStandardItem.html#874247b52596f31126882ee8ea53d3ca">child</a>(0);
<a name="l00147"></a>00147     <span class="keywordflow">else</span> {
<a name="l00148"></a>00148       <a class="code" href="classExampleSourceViewer.html#548859a1b20480151f542ebbcc82e5d0">exampleView_</a>-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WAbstractItemView.html#4423d5412ff1b4bc67f0a8f443f12136">select</a>(w-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WStandardItem.html#8afc6170ff2544d385823795b4dded37">index</a>(), <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/namespaceWt.html#1ec974261fb0e2b80498473dcb6c91ed5317beeb399a97e111e7c99dee9161d5">Select</a>);
<a name="l00149"></a>00149       w = 0;
<a name="l00150"></a>00150     }
<a name="l00151"></a>00151   } <span class="keywordflow">while</span> (w);
<a name="l00152"></a>00152 
<a name="l00153"></a>00153   <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WVBoxLayout.html">WVBoxLayout</a> *topLayout = <span class="keyword">new</span> <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WVBoxLayout.html">WVBoxLayout</a>();
<a name="l00154"></a>00154   topLayout-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WBoxLayout.html#7c1ec58e25d0b7add93f5f4342844db6">addWidget</a>(title, 0, <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/namespaceWt.html#b8f772c69bc8180c31f9e4f4593b143f58fe5182bd266132c59718c6d30945a9">AlignTop</a> | <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/namespaceWt.html#b8f772c69bc8180c31f9e4f4593b143f18cdf9d975a5a41afa182aabfde0de88">AlignJustify</a>);
<a name="l00155"></a>00155 
<a name="l00156"></a>00156   <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WHBoxLayout.html">WHBoxLayout</a> *gitLayout = <span class="keyword">new</span> <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WHBoxLayout.html">WHBoxLayout</a>();
<a name="l00157"></a>00157   gitLayout-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WBoxLayout.html#7c1ec58e25d0b7add93f5f4342844db6">addWidget</a>(<a class="code" href="classExampleSourceViewer.html#548859a1b20480151f542ebbcc82e5d0">exampleView_</a>, 0);
<a name="l00158"></a>00158   gitLayout-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WBoxLayout.html#7c1ec58e25d0b7add93f5f4342844db6">addWidget</a>(<a class="code" href="classExampleSourceViewer.html#efc329bfd3d8f7ae11c3f452a5744ab9">sourceView_</a>, 1);
<a name="l00159"></a>00159   topLayout-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WBoxLayout.html#062d26b432841995a0be7b7d7aac6413">addLayout</a>(gitLayout, 1);
<a name="l00160"></a>00160   gitLayout-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WBoxLayout.html#00bdfb4d442bd8e8ad9c33b72692763f">setResizable</a>(0);
<a name="l00161"></a>00161 
<a name="l00162"></a>00162   <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WContainerWidget.html#1c84e0ffe330d4798f0ce217f75be08c">setLayout</a>(topLayout);
<a name="l00163"></a>00163   <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WWebWidget.html#6fd43dced1a62f7e79bc3522eeb16216">setStyleClass</a>(<span class="stringliteral">"maindiv"</span>);
<a name="l00164"></a>00164 }
<a name="l00165"></a>00165 
<a name="l00166"></a>00166 <span class="comment">/*</span>
<a name="l00167"></a>00167 <span class="comment"> * Return the companion implementation/header file for a C++ source file.</span>
<a name="l00168"></a>00168 <span class="comment"> */</span>
<a name="l00169"></a><a class="code" href="ExampleSourceViewer_8C.html#0c61a4a8c171f6b23a9fc3872c2e9e5d">00169</a> <span class="keyword">static</span> fs::path <a class="code" href="ExampleSourceViewer_8C.html#0c61a4a8c171f6b23a9fc3872c2e9e5d">getCompanion</a>(<span class="keyword">const</span> fs::path&amp; path) 
<a name="l00170"></a>00170 {
<a name="l00171"></a>00171   std::string ext = fs::extension(path);
<a name="l00172"></a>00172 
<a name="l00173"></a>00173   <span class="keywordflow">if</span> (ext == <span class="stringliteral">".h"</span>)
<a name="l00174"></a>00174     <span class="keywordflow">return</span> <a class="code" href="ExampleSourceViewer_8C.html#e19c9a4a8bd0a5e02a00d6e17707a342">parent_path</a>(path) / (<a class="code" href="ExampleSourceViewer_8C.html#2fb90126657b786f14062b06f995583c">stem</a>(path) + <span class="stringliteral">".C"</span>);
<a name="l00175"></a>00175   <span class="keywordflow">else</span> <span class="keywordflow">if</span> (ext == <span class="stringliteral">".C"</span> || ext == <span class="stringliteral">".cpp"</span>)
<a name="l00176"></a>00176     <span class="keywordflow">return</span> <a class="code" href="ExampleSourceViewer_8C.html#e19c9a4a8bd0a5e02a00d6e17707a342">parent_path</a>(path) / (<a class="code" href="ExampleSourceViewer_8C.html#2fb90126657b786f14062b06f995583c">stem</a>(path) + <span class="stringliteral">".h"</span>);
<a name="l00177"></a>00177   <span class="keywordflow">else</span>
<a name="l00178"></a>00178     <span class="keywordflow">return</span> fs::path();
<a name="l00179"></a>00179 }
<a name="l00180"></a>00180 
<a name="l00181"></a>00181 <span class="keywordtype">void</span> <a class="code" href="classExampleSourceViewer.html#e10b86e9ea10445cb5f4cac95e168c82">ExampleSourceViewer::cppTraverseDir</a>(<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WStandardItem.html">WStandardItem</a>* <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WWidget.html#3461e31818c4d2f516641bdaf508312a">parent</a>, 
<a name="l00182"></a>00182                                          <span class="keyword">const</span> fs::path&amp; path)
<a name="l00183"></a>00183 {
<a name="l00184"></a>00184   <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span> *supportedFiles[] = {
<a name="l00185"></a>00185     <span class="stringliteral">".C"</span>, <span class="stringliteral">".cpp"</span>, <span class="stringliteral">".h"</span>, <span class="stringliteral">".css"</span>, <span class="stringliteral">".xml"</span>, <span class="stringliteral">".png"</span>, <span class="stringliteral">".gif"</span>, <span class="stringliteral">".csv"</span>, <span class="stringliteral">".ico"</span>, 0
<a name="l00186"></a>00186   };
<a name="l00187"></a>00187 
<a name="l00188"></a>00188   <a class="code" href="classFileItem.html" title="WStandardItem which stores a file.">FileItem</a>* dir = <span class="keyword">new</span> <a class="code" href="classFileItem.html" title="WStandardItem which stores a file.">FileItem</a>(<span class="stringliteral">"icons/yellow-folder-open.png"</span>, <a class="code" href="ExampleSourceViewer_8C.html#90d62aee81b34c117b8f494a54bee4d4">filename</a>(path),
<a name="l00189"></a>00189                                <span class="stringliteral">""</span>);
<a name="l00190"></a>00190   parent-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WStandardItem.html#bd54c7797f40c036b38300ba9cdf69b5">appendRow</a>(dir);
<a name="l00191"></a>00191   parent = dir;
<a name="l00192"></a>00192   <span class="keywordflow">try</span> {
<a name="l00193"></a>00193     std::set&lt;fs::path&gt; paths;
<a name="l00194"></a>00194 
<a name="l00195"></a>00195     fs::directory_iterator end_itr;
<a name="l00196"></a>00196     <span class="keywordflow">for</span> (fs::directory_iterator i(path); i != end_itr; ++i) 
<a name="l00197"></a>00197       paths.insert(*i);
<a name="l00198"></a>00198 
<a name="l00199"></a>00199     std::vector&lt;FileItem*&gt; classes, files;
<a name="l00200"></a>00200     std::vector&lt;fs::path&gt; dirs;
<a name="l00201"></a>00201 
<a name="l00202"></a>00202     <span class="keywordflow">while</span> (!paths.empty()) {
<a name="l00203"></a>00203       fs::path p = *paths.begin();
<a name="l00204"></a>00204       paths.erase(p);
<a name="l00205"></a>00205 
<a name="l00206"></a>00206       <span class="comment">// skip symbolic links and other files</span>
<a name="l00207"></a>00207       <span class="keywordflow">if</span> (fs::is_symlink(p))
<a name="l00208"></a>00208         <span class="keywordflow">continue</span>;
<a name="l00209"></a>00209 
<a name="l00210"></a>00210       <span class="comment">// skip files with an extension we do not want to handle</span>
<a name="l00211"></a>00211       <span class="keywordflow">if</span> (fs::is_regular(p)) {
<a name="l00212"></a>00212         std::string ext = fs::extension(p);
<a name="l00213"></a>00213         <span class="keywordtype">bool</span> supported = <span class="keyword">false</span>;
<a name="l00214"></a>00214         <span class="keywordflow">for</span> (<span class="keyword">const</span> <span class="keywordtype">char</span> **s = supportedFiles; *s != 0; ++s)
<a name="l00215"></a>00215           <span class="keywordflow">if</span> (*s == ext) {
<a name="l00216"></a>00216             supported = <span class="keyword">true</span>;
<a name="l00217"></a>00217             <span class="keywordflow">break</span>;
<a name="l00218"></a>00218           }
<a name="l00219"></a>00219         
<a name="l00220"></a>00220         <span class="keywordflow">if</span> (!supported)
<a name="l00221"></a>00221           <span class="keywordflow">continue</span>;
<a name="l00222"></a>00222       }
<a name="l00223"></a>00223 
<a name="l00224"></a>00224       <span class="comment">// see if we have one file of a class (.C, .h)</span>
<a name="l00225"></a>00225       fs::path companion = <a class="code" href="ExampleSourceViewer_8C.html#0c61a4a8c171f6b23a9fc3872c2e9e5d">getCompanion</a>(p);
<a name="l00226"></a>00226       <span class="keywordflow">if</span> (!companion.empty()) {
<a name="l00227"></a>00227         std::set&lt;fs::path&gt;::iterator it_companion = paths.find(companion);
<a name="l00228"></a>00228  
<a name="l00229"></a>00229           <span class="keywordflow">if</span> (it_companion != paths.end()) {
<a name="l00230"></a>00230             std::string className = <a class="code" href="ExampleSourceViewer_8C.html#2fb90126657b786f14062b06f995583c">stem</a>(p);
<a name="l00231"></a>00231             <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WWebWidget.html#94abba3bda8fc934ae86db54c577b428">escapeText</a>(className);
<a name="l00232"></a>00232             std::string label = <span class="stringliteral">"&lt;i&gt;class&lt;/i&gt; "</span> + className;
<a name="l00233"></a>00233 
<a name="l00234"></a>00234             <a class="code" href="classFileItem.html" title="WStandardItem which stores a file.">FileItem</a> *classItem = 
<a name="l00235"></a>00235               <span class="keyword">new</span> <a class="code" href="classFileItem.html" title="WStandardItem which stores a file.">FileItem</a>(<span class="stringliteral">"icons/cppclass.png"</span>, label, std::string());
<a name="l00236"></a>00236             classItem-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WStandardItem.html#edf80dfed644a525e5d726a4b6e74b94">setFlags</a>(classItem-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WStandardItem.html#81bc3d55f8117f5c80edcb3c9c6b871a">flags</a>() | <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/group__modelview.html#gg1d77c4de293aebfacbdde124de06b8b08ce71c5a5f185d9097b4bd596c71315e">ItemIsXHTMLText</a>);
<a name="l00237"></a>00237 
<a name="l00238"></a>00238             <a class="code" href="classFileItem.html" title="WStandardItem which stores a file.">FileItem</a> *header = <span class="keyword">new</span> <a class="code" href="classFileItem.html" title="WStandardItem which stores a file.">FileItem</a>(<span class="stringliteral">"icons/document.png"</span>, <a class="code" href="ExampleSourceViewer_8C.html#90d62aee81b34c117b8f494a54bee4d4">filename</a>(p),
<a name="l00239"></a>00239                                             p.string());
<a name="l00240"></a>00240             <a class="code" href="classFileItem.html" title="WStandardItem which stores a file.">FileItem</a> *cpp = <span class="keyword">new</span> <a class="code" href="classFileItem.html" title="WStandardItem which stores a file.">FileItem</a>(<span class="stringliteral">"icons/document.png"</span>,
<a name="l00241"></a>00241                                          <a class="code" href="ExampleSourceViewer_8C.html#90d62aee81b34c117b8f494a54bee4d4">filename</a>(*it_companion),
<a name="l00242"></a>00242                                          (*it_companion).string());
<a name="l00243"></a>00243             classItem-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WStandardItem.html#bd54c7797f40c036b38300ba9cdf69b5">appendRow</a>(header);
<a name="l00244"></a>00244             classItem-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WStandardItem.html#bd54c7797f40c036b38300ba9cdf69b5">appendRow</a>(cpp);
<a name="l00245"></a>00245           
<a name="l00246"></a>00246             classes.push_back(classItem);
<a name="l00247"></a>00247             paths.erase(it_companion);
<a name="l00248"></a>00248           } <span class="keywordflow">else</span> {
<a name="l00249"></a>00249             <a class="code" href="classFileItem.html" title="WStandardItem which stores a file.">FileItem</a> *file = <span class="keyword">new</span> <a class="code" href="classFileItem.html" title="WStandardItem which stores a file.">FileItem</a>(<span class="stringliteral">"icons/document.png"</span>, <a class="code" href="ExampleSourceViewer_8C.html#90d62aee81b34c117b8f494a54bee4d4">filename</a>(p),
<a name="l00250"></a>00250                                           p.string());
<a name="l00251"></a>00251             files.push_back(file);
<a name="l00252"></a>00252           }
<a name="l00253"></a>00253       } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (fs::is_directory(p)) {
<a name="l00254"></a>00254         dirs.push_back(p);
<a name="l00255"></a>00255       } <span class="keywordflow">else</span> {
<a name="l00256"></a>00256         <a class="code" href="classFileItem.html" title="WStandardItem which stores a file.">FileItem</a> *file = <span class="keyword">new</span> <a class="code" href="classFileItem.html" title="WStandardItem which stores a file.">FileItem</a>(<span class="stringliteral">"icons/document.png"</span>, <a class="code" href="ExampleSourceViewer_8C.html#90d62aee81b34c117b8f494a54bee4d4">filename</a>(p),
<a name="l00257"></a>00257                                       p.string());
<a name="l00258"></a>00258         files.push_back(file);
<a name="l00259"></a>00259       }
<a name="l00260"></a>00260     }
<a name="l00261"></a>00261 
<a name="l00262"></a>00262     std::sort(dirs.begin(), dirs.end(), <a class="code" href="ExampleSourceViewer_8C.html#cb92ccbf2405b113c0b8b66cec63aaae">comparePaths</a>);
<a name="l00263"></a>00263 
<a name="l00264"></a>00264     <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i = 0; i &lt; classes.size(); i++)
<a name="l00265"></a>00265       parent-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WStandardItem.html#bd54c7797f40c036b38300ba9cdf69b5">appendRow</a>(classes[i]);
<a name="l00266"></a>00266 
<a name="l00267"></a>00267     <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i = 0; i &lt; files.size(); i++)
<a name="l00268"></a>00268       parent-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WStandardItem.html#bd54c7797f40c036b38300ba9cdf69b5">appendRow</a>(files[i]);
<a name="l00269"></a>00269 
<a name="l00270"></a>00270     <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i = 0; i &lt; dirs.size(); i++)
<a name="l00271"></a>00271       <a class="code" href="classExampleSourceViewer.html#e10b86e9ea10445cb5f4cac95e168c82">cppTraverseDir</a>(parent, dirs[i]);
<a name="l00272"></a>00272   } <span class="keywordflow">catch</span> (fs::filesystem_error&amp; e) {
<a name="l00273"></a>00273     std::cerr &lt;&lt; e.what() &lt;&lt; std::endl;
<a name="l00274"></a>00274   }
<a name="l00275"></a>00275 }
<a name="l00276"></a>00276 
<a name="l00277"></a>00277 <span class="keywordtype">void</span> <a class="code" href="classExampleSourceViewer.html#23473a614f1d14bfc3a1bf2c9e688712">ExampleSourceViewer::javaTraversePackages</a>(<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WStandardItem.html">WStandardItem</a> *parent,
<a name="l00278"></a>00278                                                <span class="keyword">const</span> fs::path&amp; srcPath,
<a name="l00279"></a>00279                                                <span class="keyword">const</span> std::string packageName)
<a name="l00280"></a>00280 {
<a name="l00281"></a>00281   fs::directory_iterator end_itr;
<a name="l00282"></a>00282 
<a name="l00283"></a>00283   <a class="code" href="classFileItem.html" title="WStandardItem which stores a file.">FileItem</a> *packageItem = 0;
<a name="l00284"></a>00284   <span class="keywordflow">for</span> (fs::directory_iterator i(srcPath); i != end_itr; ++i) {
<a name="l00285"></a>00285     fs::path p = *i;
<a name="l00286"></a>00286     <span class="keywordflow">if</span> (fs::is_regular(p)) {
<a name="l00287"></a>00287       <span class="keywordflow">if</span> (!packageItem) {
<a name="l00288"></a>00288         packageItem = <span class="keyword">new</span> <a class="code" href="classFileItem.html" title="WStandardItem which stores a file.">FileItem</a>(<span class="stringliteral">"icons/package.png"</span>, packageName, <span class="stringliteral">""</span>);
<a name="l00289"></a>00289         parent-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WStandardItem.html#bd54c7797f40c036b38300ba9cdf69b5">appendRow</a>(packageItem);
<a name="l00290"></a>00290       }
<a name="l00291"></a>00291 
<a name="l00292"></a>00292       <a class="code" href="classFileItem.html" title="WStandardItem which stores a file.">FileItem</a> *file = <span class="keyword">new</span> <a class="code" href="classFileItem.html" title="WStandardItem which stores a file.">FileItem</a>(<span class="stringliteral">"icons/javaclass.png"</span>, <a class="code" href="ExampleSourceViewer_8C.html#90d62aee81b34c117b8f494a54bee4d4">filename</a>(p),
<a name="l00293"></a>00293                                     p.string());
<a name="l00294"></a>00294       packageItem-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WStandardItem.html#bd54c7797f40c036b38300ba9cdf69b5">appendRow</a>(file);
<a name="l00295"></a>00295     }
<a name="l00296"></a>00296   }
<a name="l00297"></a>00297 
<a name="l00298"></a>00298   <span class="keywordflow">for</span> (fs::directory_iterator i(srcPath); i != end_itr; ++i) {
<a name="l00299"></a>00299     fs::path p = *i;
<a name="l00300"></a>00300     <span class="keywordflow">if</span> (fs::is_directory(p)) {  
<a name="l00301"></a>00301       std::string pn = packageName;
<a name="l00302"></a>00302       <span class="keywordflow">if</span> (!pn.empty())
<a name="l00303"></a>00303         pn += <span class="stringliteral">"."</span>;
<a name="l00304"></a>00304       pn += <a class="code" href="ExampleSourceViewer_8C.html#90d62aee81b34c117b8f494a54bee4d4">filename</a>(p);
<a name="l00305"></a>00305 
<a name="l00306"></a>00306       <a class="code" href="classExampleSourceViewer.html#23473a614f1d14bfc3a1bf2c9e688712">javaTraversePackages</a>(parent, p, pn);
<a name="l00307"></a>00307     }
<a name="l00308"></a>00308   }
<a name="l00309"></a>00309 }
<a name="l00310"></a>00310 
<a name="l00311"></a>00311 <span class="keywordtype">void</span> <a class="code" href="classExampleSourceViewer.html#bdf6cba77785ba83e5cb04b78d7f9532">ExampleSourceViewer::javaTraverseDir</a>(<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WStandardItem.html">WStandardItem</a>* parent, 
<a name="l00312"></a>00312                                           <span class="keyword">const</span> fs::path&amp; path)
<a name="l00313"></a>00313 {
<a name="l00314"></a>00314   <a class="code" href="classFileItem.html" title="WStandardItem which stores a file.">FileItem</a>* dir = <span class="keyword">new</span> <a class="code" href="classFileItem.html" title="WStandardItem which stores a file.">FileItem</a>(<span class="stringliteral">"icons/yellow-folder-open.png"</span>, <a class="code" href="ExampleSourceViewer_8C.html#90d62aee81b34c117b8f494a54bee4d4">filename</a>(path),
<a name="l00315"></a>00315                                <span class="stringliteral">""</span>);
<a name="l00316"></a>00316   parent-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WStandardItem.html#bd54c7797f40c036b38300ba9cdf69b5">appendRow</a>(dir);
<a name="l00317"></a>00317   parent = dir;
<a name="l00318"></a>00318 
<a name="l00319"></a>00319   std::vector&lt;fs::path&gt; files, dirs;
<a name="l00320"></a>00320 
<a name="l00321"></a>00321   fs::directory_iterator end_itr;
<a name="l00322"></a>00322   <span class="keywordflow">for</span> (fs::directory_iterator i(path); i != end_itr; ++i) {
<a name="l00323"></a>00323     fs::path p = *i;
<a name="l00324"></a>00324     <span class="keywordflow">if</span> (fs::is_directory(p)) {
<a name="l00325"></a>00325       <span class="keywordflow">if</span> (<a class="code" href="ExampleSourceViewer_8C.html#90d62aee81b34c117b8f494a54bee4d4">filename</a>(p) == <span class="stringliteral">"src"</span>) {
<a name="l00326"></a>00326         <a class="code" href="classFileItem.html" title="WStandardItem which stores a file.">FileItem</a>* dir = <span class="keyword">new</span> <a class="code" href="classFileItem.html" title="WStandardItem which stores a file.">FileItem</a>(<span class="stringliteral">"icons/package-folder-open.png"</span>,
<a name="l00327"></a>00327                                      <a class="code" href="ExampleSourceViewer_8C.html#90d62aee81b34c117b8f494a54bee4d4">filename</a>(p), <span class="stringliteral">""</span>);
<a name="l00328"></a>00328         parent-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WStandardItem.html#bd54c7797f40c036b38300ba9cdf69b5">appendRow</a>(dir);
<a name="l00329"></a>00329         <a class="code" href="classExampleSourceViewer.html#23473a614f1d14bfc3a1bf2c9e688712">javaTraversePackages</a>(dir, p, <span class="stringliteral">""</span>);
<a name="l00330"></a>00330       } <span class="keywordflow">else</span>
<a name="l00331"></a>00331         dirs.push_back(p);
<a name="l00332"></a>00332     } <span class="keywordflow">else</span> {
<a name="l00333"></a>00333       files.push_back(p);
<a name="l00334"></a>00334     }
<a name="l00335"></a>00335   }
<a name="l00336"></a>00336 
<a name="l00337"></a>00337   std::sort(dirs.begin(), dirs.end(), <a class="code" href="ExampleSourceViewer_8C.html#cb92ccbf2405b113c0b8b66cec63aaae">comparePaths</a>);
<a name="l00338"></a>00338   std::sort(files.begin(), files.end(), <a class="code" href="ExampleSourceViewer_8C.html#cb92ccbf2405b113c0b8b66cec63aaae">comparePaths</a>);
<a name="l00339"></a>00339 
<a name="l00340"></a>00340   <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i = 0; i &lt; dirs.size(); i++)
<a name="l00341"></a>00341     <a class="code" href="classExampleSourceViewer.html#bdf6cba77785ba83e5cb04b78d7f9532">javaTraverseDir</a>(parent, dirs[i]);
<a name="l00342"></a>00342 
<a name="l00343"></a>00343   <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i = 0; i &lt; files.size(); i++) {
<a name="l00344"></a>00344     <a class="code" href="classFileItem.html" title="WStandardItem which stores a file.">FileItem</a> *file = <span class="keyword">new</span> <a class="code" href="classFileItem.html" title="WStandardItem which stores a file.">FileItem</a>(<span class="stringliteral">"icons/document.png"</span>, <a class="code" href="ExampleSourceViewer_8C.html#90d62aee81b34c117b8f494a54bee4d4">filename</a>(files[i]),
<a name="l00345"></a>00345                                   files[i].<span class="keywordtype">string</span>());
<a name="l00346"></a>00346     parent-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WStandardItem.html#bd54c7797f40c036b38300ba9cdf69b5">appendRow</a>(file);
<a name="l00347"></a>00347   }
<a name="l00348"></a>00348 }
<a name="l00349"></a>00349 
<a name="l00352"></a><a class="code" href="classExampleSourceViewer.html#7f10a65267869bb570fec25bc19348ac">00352</a> <span class="keywordtype">void</span> <a class="code" href="classExampleSourceViewer.html#7f10a65267869bb570fec25bc19348ac" title="Displayed the currently selected file.">ExampleSourceViewer::showFile</a>() {
<a name="l00353"></a>00353   <span class="keywordflow">if</span> (<a class="code" href="classExampleSourceViewer.html#548859a1b20480151f542ebbcc82e5d0">exampleView_</a>-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WAbstractItemView.html#fde08bb75862592d81dc93f30ed7dcd6">selectedIndexes</a>().empty())
<a name="l00354"></a>00354     <span class="keywordflow">return</span>;
<a name="l00355"></a>00355 
<a name="l00356"></a>00356   <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WModelIndex.html">WModelIndex</a> selected = *<a class="code" href="classExampleSourceViewer.html#548859a1b20480151f542ebbcc82e5d0">exampleView_</a>-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WAbstractItemView.html#fde08bb75862592d81dc93f30ed7dcd6">selectedIndexes</a>().begin();
<a name="l00357"></a>00357 
<a name="l00358"></a>00358   <span class="comment">// expand a folder when clicked</span>
<a name="l00359"></a>00359   <span class="keywordflow">if</span> (<a class="code" href="classExampleSourceViewer.html#548859a1b20480151f542ebbcc82e5d0">exampleView_</a>-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WAbstractItemView.html#bd583faed8e2fc3936d1b5545c4bbf84">model</a>()-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WAbstractItemModel.html#b0709a8f71fd5df882f29bb29fd055f0">rowCount</a>(selected) &gt; 0
<a name="l00360"></a>00360       &amp;&amp; !<a class="code" href="classExampleSourceViewer.html#548859a1b20480151f542ebbcc82e5d0">exampleView_</a>-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WTreeView.html#48eac450ec46ac1eea41822bfd227e9b">isExpanded</a>(selected))
<a name="l00361"></a>00361     <a class="code" href="classExampleSourceViewer.html#548859a1b20480151f542ebbcc82e5d0">exampleView_</a>-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WTreeView.html#49566dd5cc8d1d0d95bad4783dd4e11a">setExpanded</a>(selected, <span class="keyword">true</span>);
<a name="l00362"></a>00362 
<a name="l00363"></a>00363   <span class="comment">// (for a file,) load data in source viewer</span>
<a name="l00364"></a>00364   <a class="code" href="classExampleSourceViewer.html#efc329bfd3d8f7ae11c3f452a5744ab9">sourceView_</a>-&gt;<a class="code" href="classSourceView.html#10f2b88b0b8ea6b9563077e7958bc4d0" title="Sets the model index.">setIndex</a>(selected);
<a name="l00365"></a>00365 }
</pre></div></div>
<hr size="1"><address style="align: right;"><small>
Generated on Fri Mar 26 17:12:12 2010 for <a href="http://www.webtoolkit.eu/wt/">Wt</a> by&nbsp;<a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.6</small></address>
</body>
</html>