File: GitModel_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 (199 lines) | stat: -rw-r--r-- 29,629 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
<!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/gitmodel/GitModel.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/gitmodel/GitModel.C</h1><a href="GitModel_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) 2008 Emweb bvba, Kessel-Lo, Belgium.</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 "<a class="code" href="GitModel_8h.html">GitModel.h</a>"</span>
<a name="l00008"></a>00008 
<a name="l00009"></a>00009 <span class="keyword">using namespace </span>Wt;
<a name="l00010"></a>00010 
<a name="l00011"></a><a class="code" href="classGitModel.html#056f5d6c45226ca08ada28e72eed294a">00011</a> <a class="code" href="classGitModel.html#056f5d6c45226ca08ada28e72eed294a" title="Constructor.">GitModel::GitModel</a>(<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WObject.html">WObject</a> *parent)
<a name="l00012"></a>00012   : <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WAbstractItemModel.html">WAbstractItemModel</a>(parent)
<a name="l00013"></a>00013 { }
<a name="l00014"></a>00014 
<a name="l00015"></a><a class="code" href="classGitModel.html#ac776e532822827e59a2233645995e65">00015</a> <span class="keywordtype">void</span> <a class="code" href="classGitModel.html#ac776e532822827e59a2233645995e65" title="Set the repository and load its &amp;#39;master&amp;#39; revision.">GitModel::setRepositoryPath</a>(<span class="keyword">const</span> std::string&amp; gitRepositoryPath)
<a name="l00016"></a>00016 {
<a name="l00017"></a>00017   <a class="code" href="classGitModel.html#fc8ff43e47ae51ce2af04d63a162be8e" title="The git repository.">git_</a>.<a class="code" href="classGit.html#b21f8d442557b07321a274b5e976f1ac" title="Set the git repository path.">setRepositoryPath</a>(gitRepositoryPath);
<a name="l00018"></a>00018   <a class="code" href="classGitModel.html#f78bddbae2d7b76ec1e49d8626dc7526" title="Load a particular revision.">loadRevision</a>(<span class="stringliteral">"master"</span>);
<a name="l00019"></a>00019 }
<a name="l00020"></a>00020 
<a name="l00021"></a><a class="code" href="classGitModel.html#f78bddbae2d7b76ec1e49d8626dc7526">00021</a> <span class="keywordtype">void</span> <a class="code" href="classGitModel.html#f78bddbae2d7b76ec1e49d8626dc7526" title="Load a particular revision.">GitModel::loadRevision</a>(<span class="keyword">const</span> std::string&amp; revName)
<a name="l00022"></a>00022 {
<a name="l00023"></a>00023   <a class="code" href="classGit_1_1ObjectId.html" title="Git object Id.">Git::ObjectId</a> treeRoot = <a class="code" href="classGitModel.html#fc8ff43e47ae51ce2af04d63a162be8e" title="The git repository.">git_</a>.<a class="code" href="classGit.html#521bba51875ea14c9e39a14fcde01e04" title="Get the tree for a particular revision.">getCommitTree</a>(revName);
<a name="l00024"></a>00024 
<a name="l00025"></a>00025   <span class="comment">// You need to call this method before invalidating all existing</span>
<a name="l00026"></a>00026   <span class="comment">// model indexes. Anyone listening for this event could temporarily</span>
<a name="l00027"></a>00027   <span class="comment">// convert some model indexes to a raw index pointer, but this model</span>
<a name="l00028"></a>00028   <span class="comment">// does not reimplement these methods.</span>
<a name="l00029"></a>00029   <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WAbstractItemModel.html#abe99309231808a48c8f1db2c462f8e2">layoutAboutToBeChanged</a>().<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1Signal.html#b9ec97260c79e7b546b7235ad2ffd627">emit</a>();
<a name="l00030"></a>00030 
<a name="l00031"></a>00031   <a class="code" href="classGitModel.html#59307dfceb1f5712914e0754144422e4" title="List of folder objects.">treeData_</a>.clear();
<a name="l00032"></a>00032   <a class="code" href="classGitModel.html#4f3e07cf6dddd098c4c4f0978be0fe90" title="Maps child indexes to tree indexes.">childPointer_</a>.clear();
<a name="l00033"></a>00033 
<a name="l00034"></a>00034   <span class="comment">// Store the tree root as treeData_[0]</span>
<a name="l00035"></a>00035   <a class="code" href="classGitModel.html#59307dfceb1f5712914e0754144422e4" title="List of folder objects.">treeData_</a>.push_back(<a class="code" href="classGitModel_1_1Tree.html" title="Used to uniquely locate a folder within the folder hierarchy.">Tree</a>(-1, -1, treeRoot));
<a name="l00036"></a>00036 
<a name="l00037"></a>00037   <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WAbstractItemModel.html#5a6a3810afb5333405887df52827db02">layoutChanged</a>().<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1Signal.html#b9ec97260c79e7b546b7235ad2ffd627">emit</a>();
<a name="l00038"></a>00038 }
<a name="l00039"></a>00039 
<a name="l00040"></a><a class="code" href="classGitModel.html#d707c92d586f8232f5e452b2b3cecc1b">00040</a> <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WModelIndex.html">WModelIndex</a> <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WObject.html#2af8f7ec8d3807d434e1f70d1245c6b4">GitModel::parent</a>(<span class="keyword">const</span> <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WModelIndex.html">WModelIndex</a>&amp; <a class="code" href="classGitModel.html#47f5ebf88be96b003b4bf31bfafff141" title="Returns a child index.">index</a>)<span class="keyword"> const</span>
<a name="l00041"></a>00041 <span class="keyword"></span>{
<a name="l00042"></a>00042   <span class="comment">// treeData_[0] indicates the top-level parent.</span>
<a name="l00043"></a>00043   <span class="keywordflow">if</span> (!index.<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WModelIndex.html#1d4b05ee51c5c6961d6123565fd77c82">isValid</a>() || index.<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WModelIndex.html#f0fedac552dfeb6162f10d26d0876c85">internalId</a>() == 0)
<a name="l00044"></a>00044     <span class="keywordflow">return</span> <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WModelIndex.html">WModelIndex</a>();
<a name="l00045"></a>00045   <span class="keywordflow">else</span> {
<a name="l00046"></a>00046     <span class="comment">// get the item that corresponds to the parent ...</span>
<a name="l00047"></a>00047     <span class="keyword">const</span> <a class="code" href="classGitModel_1_1Tree.html" title="Used to uniquely locate a folder within the folder hierarchy.">Tree</a>&amp; item = <a class="code" href="classGitModel.html#59307dfceb1f5712914e0754144422e4" title="List of folder objects.">treeData_</a>[index.<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WModelIndex.html#f0fedac552dfeb6162f10d26d0876c85">internalId</a>()];
<a name="l00048"></a>00048 
<a name="l00049"></a>00049     <span class="comment">// ... and construct that identifies the parent:</span>
<a name="l00050"></a>00050     <span class="comment">//   row = child index in the grand parent</span>
<a name="l00051"></a>00051     <span class="comment">//   internalId = id of the grand parent</span>
<a name="l00052"></a>00052     <span class="keywordflow">return</span> <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WAbstractItemModel.html#c837a73fe423255035ffb076946de122">createIndex</a>(item.<a class="code" href="classGitModel_1_1Tree.html#116166e6c25a27f7d63346f3f6f89e74" title="Returns the child index within the parent folder.">index</a>(), 0, item.<a class="code" href="classGitModel_1_1Tree.html#83d9cb3d07454c2e4ab4364c4522d431" title="Returns the parent id.">parentId</a>()); 
<a name="l00053"></a>00053   }
<a name="l00054"></a>00054 }
<a name="l00055"></a>00055 
<a name="l00056"></a><a class="code" href="classGitModel.html#47f5ebf88be96b003b4bf31bfafff141">00056</a> <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WModelIndex.html">WModelIndex</a> <a class="code" href="classGitModel.html#47f5ebf88be96b003b4bf31bfafff141" title="Returns a child index.">GitModel::index</a>(<span class="keywordtype">int</span> row, <span class="keywordtype">int</span> column,
<a name="l00057"></a>00057                             <span class="keyword">const</span> <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WModelIndex.html">WModelIndex</a>&amp; <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WObject.html#2af8f7ec8d3807d434e1f70d1245c6b4">parent</a>)<span class="keyword"> const</span>
<a name="l00058"></a>00058 <span class="keyword"></span>{
<a name="l00059"></a>00059   <span class="keywordtype">int</span> parentId;
<a name="l00060"></a>00060 
<a name="l00061"></a>00061   <span class="comment">// the top-level parent has id=0.</span>
<a name="l00062"></a>00062   <span class="keywordflow">if</span> (!parent.<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WModelIndex.html#1d4b05ee51c5c6961d6123565fd77c82">isValid</a>())
<a name="l00063"></a>00063     parentId = 0;
<a name="l00064"></a>00064   <span class="keywordflow">else</span> {
<a name="l00065"></a>00065     <span class="comment">// the internal id of the parent identifies the grand parent</span>
<a name="l00066"></a>00066     <span class="keywordtype">int</span> grandParentId = parent.<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WModelIndex.html#f0fedac552dfeb6162f10d26d0876c85">internalId</a>();
<a name="l00067"></a>00067 
<a name="l00068"></a>00068     <span class="comment">// lookup the parent id for the parent himself, based on grand parent</span>
<a name="l00069"></a>00069     <span class="comment">// and child-index (=row) within the grand parent</span>
<a name="l00070"></a>00070     parentId = <a class="code" href="classGitModel.html#b2efe3ae663dfbd670dc41dd3cb8d2a0" title="Get or allocate an id for a folder.">getTreeId</a>(grandParentId, parent.<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WModelIndex.html#a4f1385223391c46ee200a57672f6046">row</a>());
<a name="l00071"></a>00071   }
<a name="l00072"></a>00072 
<a name="l00073"></a>00073   <span class="keywordflow">return</span> <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WAbstractItemModel.html#c837a73fe423255035ffb076946de122">createIndex</a>(row, column, parentId);
<a name="l00074"></a>00074 }
<a name="l00075"></a>00075 
<a name="l00076"></a><a class="code" href="classGitModel.html#b2efe3ae663dfbd670dc41dd3cb8d2a0">00076</a> <span class="keywordtype">int</span> <a class="code" href="classGitModel.html#b2efe3ae663dfbd670dc41dd3cb8d2a0" title="Get or allocate an id for a folder.">GitModel::getTreeId</a>(<span class="keywordtype">int</span> parentId, <span class="keywordtype">int</span> childIndex)<span class="keyword"> const</span>
<a name="l00077"></a>00077 <span class="keyword"></span>{
<a name="l00078"></a>00078   <a class="code" href="structGitModel_1_1ChildIndex.html" title="Index usable as a key to a map, that identifies a child/row within a tree.">ChildIndex</a> <a class="code" href="classGitModel.html#47f5ebf88be96b003b4bf31bfafff141" title="Returns a child index.">index</a>(parentId, childIndex);
<a name="l00079"></a>00079 
<a name="l00080"></a>00080   ChildPointerMap::const_iterator i = <a class="code" href="classGitModel.html#4f3e07cf6dddd098c4c4f0978be0fe90" title="Maps child indexes to tree indexes.">childPointer_</a>.find(index);
<a name="l00081"></a>00081   <span class="keywordflow">if</span> (i == <a class="code" href="classGitModel.html#4f3e07cf6dddd098c4c4f0978be0fe90" title="Maps child indexes to tree indexes.">childPointer_</a>.end()) {
<a name="l00082"></a>00082     <span class="comment">// no tree object was already allocated, so do that now.</span>
<a name="l00083"></a>00083 
<a name="l00084"></a>00084     <span class="comment">// lookup the git SHA1 object Id (within the parent)</span>
<a name="l00085"></a>00085     <span class="keyword">const</span> <a class="code" href="classGitModel_1_1Tree.html" title="Used to uniquely locate a folder within the folder hierarchy.">Tree</a>&amp; parentItem = <a class="code" href="classGitModel.html#59307dfceb1f5712914e0754144422e4" title="List of folder objects.">treeData_</a>[parentId];
<a name="l00086"></a>00086     <a class="code" href="structGit_1_1Object.html" title="Git object.">Git::Object</a> o = <a class="code" href="classGitModel.html#fc8ff43e47ae51ce2af04d63a162be8e" title="The git repository.">git_</a>.<a class="code" href="classGit.html#910f3a6123b494897cdedf7ba4ef648b" title="Get some info on a tree object.">treeGetObject</a>(parentItem.<a class="code" href="classGitModel_1_1Tree.html#963ec0ca3e067d01ba9fd98359c44216" title="Returns the SHA1 id for the git tree object.">treeObject</a>(), childIndex);
<a name="l00087"></a>00087 
<a name="l00088"></a>00088     <span class="comment">// and add to treeData_ and childPointer_ data structures</span>
<a name="l00089"></a>00089     <a class="code" href="classGitModel.html#59307dfceb1f5712914e0754144422e4" title="List of folder objects.">treeData_</a>.push_back(<a class="code" href="classGitModel_1_1Tree.html" title="Used to uniquely locate a folder within the folder hierarchy.">Tree</a>(parentId, childIndex, o.<a class="code" href="structGit_1_1Object.html#2e3989983524516e4a936714b55736ff">id</a>));
<a name="l00090"></a>00090     <span class="keywordtype">int</span> result = <a class="code" href="classGitModel.html#59307dfceb1f5712914e0754144422e4" title="List of folder objects.">treeData_</a>.size() - 1;
<a name="l00091"></a>00091     <a class="code" href="classGitModel.html#4f3e07cf6dddd098c4c4f0978be0fe90" title="Maps child indexes to tree indexes.">childPointer_</a>[index] = result;
<a name="l00092"></a>00092     <span class="keywordflow">return</span> result;
<a name="l00093"></a>00093   } <span class="keywordflow">else</span>
<a name="l00094"></a>00094     <span class="keywordflow">return</span> i-&gt;second;
<a name="l00095"></a>00095 }
<a name="l00096"></a>00096 
<a name="l00097"></a><a class="code" href="classGitModel.html#78b52d35048396dc60aa660b1d5bcf55">00097</a> <span class="keywordtype">int</span> <a class="code" href="classGitModel.html#78b52d35048396dc60aa660b1d5bcf55" title="Returns the column count.">GitModel::columnCount</a>(<span class="keyword">const</span> <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WModelIndex.html">WModelIndex</a>&amp; <a class="code" href="classGitModel.html#47f5ebf88be96b003b4bf31bfafff141" title="Returns a child index.">index</a>)<span class="keyword"> const</span>
<a name="l00098"></a>00098 <span class="keyword"></span>{
<a name="l00099"></a>00099   <span class="comment">// currently only one column</span>
<a name="l00100"></a>00100   <span class="keywordflow">return</span> 1;
<a name="l00101"></a>00101 }
<a name="l00102"></a>00102 
<a name="l00103"></a><a class="code" href="classGitModel.html#a5f75edbb291d0b03c22fc8a608a3171">00103</a> <span class="keywordtype">int</span> <a class="code" href="classGitModel.html#a5f75edbb291d0b03c22fc8a608a3171" title="Returns the row count.">GitModel::rowCount</a>(<span class="keyword">const</span> <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WModelIndex.html">WModelIndex</a>&amp; <a class="code" href="classGitModel.html#47f5ebf88be96b003b4bf31bfafff141" title="Returns a child index.">index</a>)<span class="keyword"> const</span>
<a name="l00104"></a>00104 <span class="keyword"></span>{
<a name="l00105"></a>00105   <span class="comment">// we are looking for the git SHA1 id of a tree object (since only folders</span>
<a name="l00106"></a>00106   <span class="comment">// may contain children).</span>
<a name="l00107"></a>00107   <a class="code" href="classGit_1_1ObjectId.html" title="Git object Id.">Git::ObjectId</a> objectId;
<a name="l00108"></a>00108 
<a name="l00109"></a>00109   <span class="keywordflow">if</span> (index.<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WModelIndex.html#1d4b05ee51c5c6961d6123565fd77c82">isValid</a>()) {
<a name="l00110"></a>00110     <span class="comment">// only column 0 items may contain children</span>
<a name="l00111"></a>00111     <span class="keywordflow">if</span> (index.<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WModelIndex.html#0e6568dd7113662c3c378e2084729581">column</a>() != 0)
<a name="l00112"></a>00112       <span class="keywordflow">return</span> 0;
<a name="l00113"></a>00113 
<a name="l00114"></a>00114     <a class="code" href="structGit_1_1Object.html" title="Git object.">Git::Object</a> o = <a class="code" href="classGitModel.html#0eec46284e84c7deeb1a39eb7185d1d1" title="Get the Git::Object that corresponds to an index.">getObject</a>(index);
<a name="l00115"></a>00115     <span class="keywordflow">if</span> (o.<a class="code" href="structGit_1_1Object.html#2ea77791af4fa6012b350469654332cc">type</a> == <a class="code" href="classGit.html#b282f46c36a47ddff9bc7be7c993041ae94d3a7ff6594f6b3b0dc121fbd01564">Git::Tree</a>) {
<a name="l00116"></a>00116       objectId = o.<a class="code" href="structGit_1_1Object.html#2e3989983524516e4a936714b55736ff">id</a>;
<a name="l00117"></a>00117     } <span class="keywordflow">else</span>
<a name="l00118"></a>00118       <span class="comment">// not a folder: no children</span>
<a name="l00119"></a>00119       <span class="keywordflow">return</span> 0;
<a name="l00120"></a>00120   } <span class="keywordflow">else</span>
<a name="l00121"></a>00121     <span class="comment">// the index corresponds to the root object</span>
<a name="l00122"></a>00122     <span class="keywordflow">if</span> (<a class="code" href="classGitModel.html#59307dfceb1f5712914e0754144422e4" title="List of folder objects.">treeData_</a>.empty())
<a name="l00123"></a>00123       <span class="comment">// model not yet loaded !</span>
<a name="l00124"></a>00124       <span class="keywordflow">return</span> 0;
<a name="l00125"></a>00125     <span class="keywordflow">else</span>
<a name="l00126"></a>00126       objectId = <a class="code" href="classGitModel.html#59307dfceb1f5712914e0754144422e4" title="List of folder objects.">treeData_</a>[0].treeObject();
<a name="l00127"></a>00127 
<a name="l00128"></a>00128   <span class="keywordflow">return</span> <a class="code" href="classGitModel.html#fc8ff43e47ae51ce2af04d63a162be8e" title="The git repository.">git_</a>.<a class="code" href="classGit.html#be86381afbbab0adb0680ae268752f1f" title="Return the number of objects inside a tree object.">treeSize</a>(objectId);
<a name="l00129"></a>00129 }
<a name="l00130"></a>00130 
<a name="l00131"></a><a class="code" href="classGitModel.html#6e30f8cddbb1039d7d749eaafa1120a8">00131</a> boost::any <a class="code" href="classGitModel.html#6e30f8cddbb1039d7d749eaafa1120a8" title="Returns data.">GitModel::data</a>(<span class="keyword">const</span> <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WModelIndex.html">WModelIndex</a>&amp; <a class="code" href="classGitModel.html#47f5ebf88be96b003b4bf31bfafff141" title="Returns a child index.">index</a>, <span class="keywordtype">int</span> role)<span class="keyword"> const</span>
<a name="l00132"></a>00132 <span class="keyword"></span>{
<a name="l00133"></a>00133   <span class="keywordflow">if</span> (!index.<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WModelIndex.html#1d4b05ee51c5c6961d6123565fd77c82">isValid</a>())
<a name="l00134"></a>00134     <span class="keywordflow">return</span> boost::any();
<a name="l00135"></a>00135 
<a name="l00136"></a>00136   <span class="comment">/* Only 3 data roles on column 0 data are supported:</span>
<a name="l00137"></a>00137 <span class="comment">   * - DisplayRole: the file name</span>
<a name="l00138"></a>00138 <span class="comment">   * - DecorationRole: an icon (folder or file)</span>
<a name="l00139"></a>00139 <span class="comment">   * - ContentsRole: the file contents</span>
<a name="l00140"></a>00140 <span class="comment">   */</span>
<a name="l00141"></a>00141   <span class="keywordflow">if</span> (index.<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WModelIndex.html#0e6568dd7113662c3c378e2084729581">column</a>() == 0) {
<a name="l00142"></a>00142     <a class="code" href="structGit_1_1Object.html" title="Git object.">Git::Object</a> <span class="keywordtype">object</span> = <a class="code" href="classGitModel.html#0eec46284e84c7deeb1a39eb7185d1d1" title="Get the Git::Object that corresponds to an index.">getObject</a>(index);
<a name="l00143"></a>00143     <span class="keywordflow">if</span> (role == <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/group__modelview.html#gg0ae864e12320f9f89172735e075ed0685ed17aded8a0e3b712698cf85a218f1f">DisplayRole</a>) {
<a name="l00144"></a>00144       <span class="keywordflow">if</span> (<span class="keywordtype">object</span>.type == <a class="code" href="classGit.html#b282f46c36a47ddff9bc7be7c993041ae94d3a7ff6594f6b3b0dc121fbd01564">Git::Tree</a>)
<a name="l00145"></a>00145         <span class="keywordflow">return</span> <span class="keywordtype">object</span>.name + <span class="charliteral">'/'</span>;
<a name="l00146"></a>00146       <span class="keywordflow">else</span>
<a name="l00147"></a>00147         <span class="keywordflow">return</span> <span class="keywordtype">object</span>.name;
<a name="l00148"></a>00148     } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (role == <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/group__modelview.html#gg0ae864e12320f9f89172735e075ed068ab6678fc176854f7990d6cff4eed779e">DecorationRole</a>) {
<a name="l00149"></a>00149       <span class="keywordflow">if</span> (<span class="keywordtype">object</span>.type == <a class="code" href="classGit.html#b282f46c36a47ddff9bc7be7c993041a64c3a7b641cdc0cb2c4203fc0bef1a4a">Git::Blob</a>)
<a name="l00150"></a>00150         <span class="keywordflow">return</span> <span class="stringliteral">"icons/git-blob.png"</span>;
<a name="l00151"></a>00151       <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<span class="keywordtype">object</span>.type == <a class="code" href="classGit.html#b282f46c36a47ddff9bc7be7c993041ae94d3a7ff6594f6b3b0dc121fbd01564">Git::Tree</a>)
<a name="l00152"></a>00152         <span class="keywordflow">return</span> <span class="stringliteral">"icons/git-tree.png"</span>;
<a name="l00153"></a>00153     } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (role == <a class="code" href="classGitModel.html#49c30024f0241738b30cf4cec589b292" title="The role which may be used on a file to retrieve its contents.">ContentsRole</a>) {
<a name="l00154"></a>00154       <span class="keywordflow">if</span> (<span class="keywordtype">object</span>.type == <a class="code" href="classGit.html#b282f46c36a47ddff9bc7be7c993041a64c3a7b641cdc0cb2c4203fc0bef1a4a">Git::Blob</a>)
<a name="l00155"></a>00155         <span class="keywordflow">return</span> <a class="code" href="classGitModel.html#fc8ff43e47ae51ce2af04d63a162be8e" title="The git repository.">git_</a>.<a class="code" href="classGit.html#cf2d699d9f9bdfb42afb0f61e85b2f88" title="Return the raw contents of a git object.">catFile</a>(<span class="keywordtype">object</span>.<span class="keywordtype">id</span>);
<a name="l00156"></a>00156     } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (role == <a class="code" href="classGitModel.html#9419f872ce68506009748f0595400ef7">FilePathRole</a>) {
<a name="l00157"></a>00157       <span class="keywordflow">return</span> boost::any();
<a name="l00158"></a>00158     }
<a name="l00159"></a>00159   }
<a name="l00160"></a>00160 
<a name="l00161"></a>00161   <span class="keywordflow">return</span> boost::any();
<a name="l00162"></a>00162 }
<a name="l00163"></a>00163 
<a name="l00164"></a><a class="code" href="classGitModel.html#23fb9ef292e416fbdf20790a2a93c016">00164</a> boost::any <a class="code" href="classGitModel.html#23fb9ef292e416fbdf20790a2a93c016" title="Returns header data.">GitModel::headerData</a>(<span class="keywordtype">int</span> section, <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/namespaceWt.html#2a8d45559e16a0185bf61bfad0a67912">Orientation</a> orientation,
<a name="l00165"></a>00165                                 <span class="keywordtype">int</span> role)<span class="keyword"> const</span>
<a name="l00166"></a>00166 <span class="keyword"></span>{
<a name="l00167"></a>00167   <span class="keywordflow">if</span> (orientation == <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/namespaceWt.html#2a8d45559e16a0185bf61bfad0a67912c2ebf22b096a22b18eef23e736aa2e28">Horizontal</a> &amp;&amp; role == <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/group__modelview.html#gg0ae864e12320f9f89172735e075ed0685ed17aded8a0e3b712698cf85a218f1f">DisplayRole</a>)
<a name="l00168"></a>00168     <span class="keywordflow">return</span> <span class="stringliteral">"File"</span>;
<a name="l00169"></a>00169   <span class="keywordflow">else</span>
<a name="l00170"></a>00170     <span class="keywordflow">return</span> boost::any();
<a name="l00171"></a>00171 }
<a name="l00172"></a>00172 
<a name="l00173"></a><a class="code" href="classGitModel.html#0eec46284e84c7deeb1a39eb7185d1d1">00173</a> <a class="code" href="structGit_1_1Object.html" title="Git object.">Git::Object</a> <a class="code" href="classGitModel.html#0eec46284e84c7deeb1a39eb7185d1d1" title="Get the Git::Object that corresponds to an index.">GitModel::getObject</a>(<span class="keyword">const</span> <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WModelIndex.html">WModelIndex</a>&amp; <a class="code" href="classGitModel.html#47f5ebf88be96b003b4bf31bfafff141" title="Returns a child index.">index</a>)<span class="keyword"> const</span>
<a name="l00174"></a>00174 <span class="keyword"></span>{
<a name="l00175"></a>00175   <span class="keywordtype">int</span> parentId = index.<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WModelIndex.html#f0fedac552dfeb6162f10d26d0876c85">internalId</a>();
<a name="l00176"></a>00176   <span class="keyword">const</span> <a class="code" href="classGitModel_1_1Tree.html" title="Used to uniquely locate a folder within the folder hierarchy.">Tree</a>&amp; parentItem = <a class="code" href="classGitModel.html#59307dfceb1f5712914e0754144422e4" title="List of folder objects.">treeData_</a>[parentId];
<a name="l00177"></a>00177   <span class="keywordflow">return</span> <a class="code" href="classGitModel.html#fc8ff43e47ae51ce2af04d63a162be8e" title="The git repository.">git_</a>.<a class="code" href="classGit.html#910f3a6123b494897cdedf7ba4ef648b" title="Get some info on a tree object.">treeGetObject</a>(parentItem.<a class="code" href="classGitModel_1_1Tree.html#963ec0ca3e067d01ba9fd98359c44216" title="Returns the SHA1 id for the git tree object.">treeObject</a>(), index.<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WModelIndex.html#a4f1385223391c46ee200a57672f6046">row</a>());
<a name="l00178"></a>00178 }
</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>