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
|
<!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.h 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 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.h</h1><a href="GitModel_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">// This may look like C code, but it's really -*- C++ -*-</span>
<a name="l00002"></a>00002 <span class="comment">/*</span>
<a name="l00003"></a>00003 <span class="comment"> * Copyright (C) 2008 Emweb bvba, Kessel-Lo, Belgium.</span>
<a name="l00004"></a>00004 <span class="comment"> *</span>
<a name="l00005"></a>00005 <span class="comment"> * See the LICENSE file for terms of use.</span>
<a name="l00006"></a>00006 <span class="comment"> */</span>
<a name="l00007"></a>00007 <span class="preprocessor">#ifndef GIT_MODEL_H_</span>
<a name="l00008"></a>00008 <span class="preprocessor"></span><span class="preprocessor">#define GIT_MODEL_H_</span>
<a name="l00009"></a>00009 <span class="preprocessor"></span>
<a name="l00010"></a>00010 <span class="preprocessor">#include <Wt/WAbstractItemModel></span>
<a name="l00011"></a>00011
<a name="l00012"></a>00012 <span class="preprocessor">#include "<a class="code" href="Git_8h.html">Git.h</a>"</span>
<a name="l00013"></a>00013
<a name="l00018"></a>00018
<a name="l00036"></a><a class="code" href="classGitModel.html">00036</a> <span class="keyword">class </span><a class="code" href="classGitModel.html" title="A model that retrieves revision trees from a git repository.">GitModel</a> : <span class="keyword">public</span> Wt::<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WAbstractItemModel.html#ceb39c2027dc4dc464ac5942798e62e6">WAbstractItemModel</a>
<a name="l00037"></a>00037 {
<a name="l00038"></a>00038 <span class="keyword">public</span>:
<a name="l00041"></a><a class="code" href="classGitModel.html#49c30024f0241738b30cf4cec589b292">00041</a> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">int</span> <a class="code" href="classGitModel.html#49c30024f0241738b30cf4cec589b292" title="The role which may be used on a file to retrieve its contents.">ContentsRole</a> = <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/group__modelview.html#gg0ae864e12320f9f89172735e075ed0689b7eae9fc07ea4fd8afe7bc97954162c">Wt::UserRole</a>;
<a name="l00042"></a><a class="code" href="classGitModel.html#9419f872ce68506009748f0595400ef7">00042</a> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">int</span> <a class="code" href="classGitModel.html#9419f872ce68506009748f0595400ef7">FilePathRole</a> = <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/group__modelview.html#gg0ae864e12320f9f89172735e075ed0689b7eae9fc07ea4fd8afe7bc97954162c">Wt::UserRole</a> + 1;
<a name="l00043"></a>00043
<a name="l00046"></a>00046 <a class="code" href="classGitModel.html#056f5d6c45226ca08ada28e72eed294a" title="Constructor.">GitModel</a>(<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WObject.html">Wt::WObject</a> *<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WObject.html#2af8f7ec8d3807d434e1f70d1245c6b4">parent</a> = 0);
<a name="l00047"></a>00047
<a name="l00050"></a>00050 <span class="keywordtype">void</span> <a class="code" href="classGitModel.html#ac776e532822827e59a2233645995e65" title="Set the repository and load its &#39;master&#39; revision.">setRepositoryPath</a>(<span class="keyword">const</span> std::string& repositoryPath);
<a name="l00051"></a>00051
<a name="l00057"></a>00057 <span class="keywordtype">void</span> <a class="code" href="classGitModel.html#f78bddbae2d7b76ec1e49d8626dc7526" title="Load a particular revision.">loadRevision</a>(<span class="keyword">const</span> std::string& revName);
<a name="l00058"></a>00058
<a name="l00063"></a>00063 <span class="keyword">virtual</span> <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WModelIndex.html">Wt::WModelIndex</a> <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WObject.html#2af8f7ec8d3807d434e1f70d1245c6b4">parent</a>(<span class="keyword">const</span> <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WModelIndex.html">Wt::WModelIndex</a>& <a class="code" href="classGitModel.html#47f5ebf88be96b003b4bf31bfafff141" title="Returns a child index.">index</a>) <span class="keyword">const</span>;
<a name="l00064"></a>00064
<a name="l00069"></a>00069 <span class="keyword">virtual</span> <span class="keywordtype">int</span> <a class="code" href="classGitModel.html#78b52d35048396dc60aa660b1d5bcf55" title="Returns the column count.">columnCount</a>(<span class="keyword">const</span> <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WModelIndex.html">Wt::WModelIndex</a>& <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WObject.html#2af8f7ec8d3807d434e1f70d1245c6b4">parent</a> = <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WModelIndex.html">Wt::WModelIndex</a>())
<a name="l00070"></a>00070 <span class="keyword">const</span>;
<a name="l00071"></a>00071
<a name="l00077"></a>00077 <span class="keyword">virtual</span> <span class="keywordtype">int</span> <a class="code" href="classGitModel.html#a5f75edbb291d0b03c22fc8a608a3171" title="Returns the row count.">rowCount</a>(<span class="keyword">const</span> <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WModelIndex.html">Wt::WModelIndex</a>& <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WObject.html#2af8f7ec8d3807d434e1f70d1245c6b4">parent</a> = <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WModelIndex.html">Wt::WModelIndex</a>()) <span class="keyword">const</span>;
<a name="l00078"></a>00078
<a name="l00085"></a>00085 <span class="keyword">virtual</span> <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WModelIndex.html">Wt::WModelIndex</a>
<a name="l00086"></a>00086 <a class="code" href="classGitModel.html#47f5ebf88be96b003b4bf31bfafff141" title="Returns a child index.">index</a>(<span class="keywordtype">int</span> row, <span class="keywordtype">int</span> column, <span class="keyword">const</span> <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WModelIndex.html">Wt::WModelIndex</a>& <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WObject.html#2af8f7ec8d3807d434e1f70d1245c6b4">parent</a> = <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WModelIndex.html">Wt::WModelIndex</a>())
<a name="l00087"></a>00087 <span class="keyword">const</span>;
<a name="l00088"></a>00088
<a name="l00093"></a>00093 <span class="keyword">virtual</span> boost::any
<a name="l00094"></a>00094 <a class="code" href="classGitModel.html#6e30f8cddbb1039d7d749eaafa1120a8" title="Returns data.">data</a>(<span class="keyword">const</span> <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WModelIndex.html">Wt::WModelIndex</a>& <a class="code" href="classGitModel.html#47f5ebf88be96b003b4bf31bfafff141" title="Returns a child index.">index</a>, <span class="keywordtype">int</span> role = <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/group__modelview.html#gg0ae864e12320f9f89172735e075ed0685ed17aded8a0e3b712698cf85a218f1f">Wt::DisplayRole</a>) <span class="keyword">const</span>;
<a name="l00095"></a>00095
<a name="l00098"></a>00098 <span class="keyword">virtual</span> boost::any
<a name="l00099"></a>00099 <a class="code" href="classGitModel.html#23fb9ef292e416fbdf20790a2a93c016" title="Returns header data.">headerData</a>(<span class="keywordtype">int</span> section, <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/namespaceWt.html#2a8d45559e16a0185bf61bfad0a67912">Wt::Orientation</a> orientation = <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/namespaceWt.html#2a8d45559e16a0185bf61bfad0a67912c2ebf22b096a22b18eef23e736aa2e28">Wt::Horizontal</a>,
<a name="l00100"></a>00100 <span class="keywordtype">int</span> role = <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/group__modelview.html#gg0ae864e12320f9f89172735e075ed0685ed17aded8a0e3b712698cf85a218f1f">Wt::DisplayRole</a>) <span class="keyword">const</span>;
<a name="l00101"></a>00101
<a name="l00102"></a>00102 <span class="keyword">using</span> WAbstractItemModel::data;
<a name="l00103"></a>00103
<a name="l00104"></a>00104 <span class="keyword">private</span>:
<a name="l00106"></a><a class="code" href="classGitModel.html#fc8ff43e47ae51ce2af04d63a162be8e">00106</a> <a class="code" href="classGit.html" title="Git utility class for browsing git archives.">Git</a> <a class="code" href="classGitModel.html#fc8ff43e47ae51ce2af04d63a162be8e" title="The git repository.">git_</a>;
<a name="l00107"></a>00107
<a name="l00112"></a><a class="code" href="structGitModel_1_1ChildIndex.html">00112</a> <span class="keyword">struct </span><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 name="l00113"></a><a class="code" href="structGitModel_1_1ChildIndex.html#94e6e7cda51ae9de96be217b3a4138e3">00113</a> <span class="keywordtype">int</span> <a class="code" href="structGitModel_1_1ChildIndex.html#94e6e7cda51ae9de96be217b3a4138e3">parentId</a>;
<a name="l00114"></a><a class="code" href="structGitModel_1_1ChildIndex.html#6b3f83929ab40d80f3e19c81a747f7c2">00114</a> <span class="keywordtype">int</span> <a class="code" href="structGitModel_1_1ChildIndex.html#6b3f83929ab40d80f3e19c81a747f7c2">index</a>;
<a name="l00115"></a>00115
<a name="l00116"></a><a class="code" href="structGitModel_1_1ChildIndex.html#d69cd4e97985edfec0c7b1fba0319b9b">00116</a> <a class="code" href="structGitModel_1_1ChildIndex.html#d69cd4e97985edfec0c7b1fba0319b9b">ChildIndex</a>(<span class="keywordtype">int</span> aParent, <span class="keywordtype">int</span> anIndex)
<a name="l00117"></a>00117 : <a class="code" href="structGitModel_1_1ChildIndex.html#94e6e7cda51ae9de96be217b3a4138e3">parentId</a>(aParent), <a class="code" href="structGitModel_1_1ChildIndex.html#6b3f83929ab40d80f3e19c81a747f7c2">index</a>(anIndex) { }
<a name="l00118"></a>00118
<a name="l00119"></a><a class="code" href="structGitModel_1_1ChildIndex.html#b17c0f59139f31840e63c1ac87021296">00119</a> <span class="keywordtype">bool</span> <a class="code" href="structGitModel_1_1ChildIndex.html#b17c0f59139f31840e63c1ac87021296">operator< </a>(<span class="keyword">const</span> <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>& other)<span class="keyword"> const </span>{
<a name="l00120"></a>00120 <span class="keywordflow">if</span> (<a class="code" href="structGitModel_1_1ChildIndex.html#94e6e7cda51ae9de96be217b3a4138e3">parentId</a> < other.<a class="code" href="structGitModel_1_1ChildIndex.html#94e6e7cda51ae9de96be217b3a4138e3">parentId</a>)
<a name="l00121"></a>00121 <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00122"></a>00122 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="structGitModel_1_1ChildIndex.html#94e6e7cda51ae9de96be217b3a4138e3">parentId</a> > other.<a class="code" href="structGitModel_1_1ChildIndex.html#94e6e7cda51ae9de96be217b3a4138e3">parentId</a>)
<a name="l00123"></a>00123 <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00124"></a>00124 <span class="keywordflow">else</span> <span class="keywordflow">return</span> <a class="code" href="structGitModel_1_1ChildIndex.html#6b3f83929ab40d80f3e19c81a747f7c2">index</a> < other.<a class="code" href="structGitModel_1_1ChildIndex.html#6b3f83929ab40d80f3e19c81a747f7c2">index</a>;
<a name="l00125"></a>00125 }
<a name="l00126"></a>00126 };
<a name="l00127"></a>00127
<a name="l00131"></a><a class="code" href="classGitModel_1_1Tree.html">00131</a> <span class="keyword">class </span><a class="code" href="classGitModel_1_1Tree.html" title="Used to uniquely locate a folder within the folder hierarchy.">Tree</a> {
<a name="l00132"></a>00132 <span class="keyword">public</span>:
<a name="l00135"></a><a class="code" href="classGitModel_1_1Tree.html#32500db026354af9ff4d9b75f46d63c0">00135</a> <a class="code" href="classGitModel_1_1Tree.html#32500db026354af9ff4d9b75f46d63c0" title="Constructor.">Tree</a>(<span class="keywordtype">int</span> <a class="code" href="classGitModel_1_1Tree.html#83d9cb3d07454c2e4ab4364c4522d431" title="Returns the parent id.">parentId</a>, <span class="keywordtype">int</span> <a class="code" href="classGitModel_1_1Tree.html#116166e6c25a27f7d63346f3f6f89e74" title="Returns the child index within the parent folder.">index</a>, <span class="keyword">const</span> <a class="code" href="classGit_1_1ObjectId.html" title="Git object Id.">Git::ObjectId</a>& <span class="keywordtype">object</span>)
<a name="l00136"></a>00136 : <a class="code" href="classGitModel_1_1Tree.html#c535b85766567aec88bd147d3b831567">index_</a>(parentId, index),
<a name="l00137"></a>00137 <a class="code" href="classGitModel_1_1Tree.html#fc45a4383267540d6d411a18b453c533">treeObject_</a>(object)
<a name="l00138"></a>00138 { }
<a name="l00139"></a>00139
<a name="l00144"></a><a class="code" href="classGitModel_1_1Tree.html#83d9cb3d07454c2e4ab4364c4522d431">00144</a> <span class="keywordtype">int</span> <a class="code" href="classGitModel_1_1Tree.html#83d9cb3d07454c2e4ab4364c4522d431" title="Returns the parent id.">parentId</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classGitModel_1_1Tree.html#c535b85766567aec88bd147d3b831567">index_</a>.<a class="code" href="structGitModel_1_1ChildIndex.html#94e6e7cda51ae9de96be217b3a4138e3">parentId</a>; }
<a name="l00145"></a>00145
<a name="l00150"></a><a class="code" href="classGitModel_1_1Tree.html#116166e6c25a27f7d63346f3f6f89e74">00150</a> <span class="keywordtype">int</span> <a class="code" href="classGitModel_1_1Tree.html#116166e6c25a27f7d63346f3f6f89e74" title="Returns the child index within the parent folder.">index</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classGitModel_1_1Tree.html#c535b85766567aec88bd147d3b831567">index_</a>.<a class="code" href="structGitModel_1_1ChildIndex.html#6b3f83929ab40d80f3e19c81a747f7c2">index</a>; }
<a name="l00151"></a>00151
<a name="l00154"></a><a class="code" href="classGitModel_1_1Tree.html#963ec0ca3e067d01ba9fd98359c44216">00154</a> <span class="keyword">const</span> <a class="code" href="classGit_1_1ObjectId.html" title="Git object Id.">Git::ObjectId</a>& <a class="code" href="classGitModel_1_1Tree.html#963ec0ca3e067d01ba9fd98359c44216" title="Returns the SHA1 id for the git tree object.">treeObject</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classGitModel_1_1Tree.html#fc45a4383267540d6d411a18b453c533">treeObject_</a>; }
<a name="l00155"></a>00155
<a name="l00156"></a>00156 <span class="keyword">private</span>:
<a name="l00157"></a><a class="code" href="classGitModel_1_1Tree.html#c535b85766567aec88bd147d3b831567">00157</a> <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_1_1Tree.html#c535b85766567aec88bd147d3b831567">index_</a>;
<a name="l00158"></a><a class="code" href="classGitModel_1_1Tree.html#fc45a4383267540d6d411a18b453c533">00158</a> <a class="code" href="classGit_1_1ObjectId.html" title="Git object Id.">Git::ObjectId</a> <a class="code" href="classGitModel_1_1Tree.html#fc45a4383267540d6d411a18b453c533">treeObject_</a>;
<a name="l00159"></a>00159 };
<a name="l00160"></a>00160
<a name="l00161"></a><a class="code" href="classGitModel.html#5bdd5d3dea3e158889afc795b455d103">00161</a> <span class="keyword">typedef</span> std::map<ChildIndex, int> <a class="code" href="classGitModel.html#5bdd5d3dea3e158889afc795b455d103">ChildPointerMap</a>;
<a name="l00162"></a>00162
<a name="l00175"></a><a class="code" href="classGitModel.html#59307dfceb1f5712914e0754144422e4">00175</a> <span class="keyword">mutable</span> std::vector<Tree> <a class="code" href="classGitModel.html#59307dfceb1f5712914e0754144422e4" title="List of folder objects.">treeData_</a>;
<a name="l00176"></a>00176
<a name="l00185"></a><a class="code" href="classGitModel.html#4f3e07cf6dddd098c4c4f0978be0fe90">00185</a> <span class="keyword">mutable</span> <a class="code" href="classGitModel.html#5bdd5d3dea3e158889afc795b455d103">ChildPointerMap</a> <a class="code" href="classGitModel.html#4f3e07cf6dddd098c4c4f0978be0fe90" title="Maps child indexes to tree indexes.">childPointer_</a>;
<a name="l00186"></a>00186
<a name="l00193"></a>00193 <span class="keywordtype">int</span> <a class="code" href="classGitModel.html#b2efe3ae663dfbd670dc41dd3cb8d2a0" title="Get or allocate an id for a folder.">getTreeId</a>(<span class="keywordtype">int</span> parentId, <span class="keywordtype">int</span> childIndex) <span class="keyword">const</span>;
<a name="l00194"></a>00194
<a name="l00197"></a>00197 <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.">getObject</a>(<span class="keyword">const</span> <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WModelIndex.html">Wt::WModelIndex</a>& <a class="code" href="classGitModel.html#47f5ebf88be96b003b4bf31bfafff141" title="Returns a child index.">index</a>) <span class="keyword">const</span>;
<a name="l00198"></a>00198 };
<a name="l00199"></a>00199
<a name="l00202"></a>00202 <span class="preprocessor">#endif // GIT_MODEL_H_</span>
</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 <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>
|