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
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>Wt examples: FolderView Class Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td style="padding-left: 0.5em;">
<div id="projectname">Wt examples
 <span id="projectnumber">3.2.1</span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- Generated by Doxygen 1.7.5.1 -->
<div id="navrow1" class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Main Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="namespaces.html"><span>Namespaces</span></a></li>
<li class="current"><a href="annotated.html"><span>Classes</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
<div id="navrow2" class="tabs2">
<ul class="tablist">
<li><a href="annotated.html"><span>Class List</span></a></li>
<li><a href="inherits.html"><span>Class Hierarchy</span></a></li>
<li><a href="functions.html"><span>Class Members</span></a></li>
</ul>
</div>
</div>
<div class="header">
<div class="summary">
<a href="#pub-methods">Public Member Functions</a> |
<a href="#pub-static-attribs">Static Public Attributes</a> |
<a href="#pro-methods">Protected Member Functions</a> </div>
<div class="headertitle">
<div class="title">FolderView Class Reference<div class="ingroups"><a class="el" href="group__treeviewdragdrop.html">Drag and drop in WTreeView example</a></div></div> </div>
</div>
<div class="contents">
<!-- doxytag: class="FolderView" --><!-- doxytag: inherits="Wt::WTreeView" -->
<p>A specialized treeview that supports a custom drop event.
<a href="classFolderView.html#details">More...</a></p>
<p><code>#include <<a class="el" href="FolderView_8h_source.html">FolderView.h</a>></code></p>
<div class="dynheader">
Inheritance diagram for FolderView:</div>
<div class="dyncontent">
<div class="center"><img src="classFolderView__inherit__graph.png" border="0" usemap="#FolderView_inherit__map" alt="Inheritance graph"/></div>
<map name="FolderView_inherit__map" id="FolderView_inherit__map">
<area shape="rect" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WTreeView.html" title="Wt::WTreeView" alt="" coords="31,304,143,331"/><area shape="rect" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WAbstractItemView.html" title="Wt::WAbstractItemView" alt="" coords="7,229,167,256"/><area shape="rect" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WCompositeWidget.html" title="Wt::WCompositeWidget" alt="" coords="5,155,168,181"/><area shape="rect" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WWidget.html" title="Wt::WWidget" alt="" coords="37,80,136,107"/><area shape="rect" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WObject.html" title="Wt::WObject" alt="" coords="39,5,135,32"/></map>
<center><span class="legend">[<a href="graph_legend.html">legend</a>]</span></center></div>
<p><a href="classFolderView-members.html">List of all members.</a></p>
<table class="memberdecls">
<tr><td colspan="2"><h2><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classFolderView.html#a61d205958444a0a7f23cd9558e697c5c">FolderView</a> (<a class="elRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WContainerWidget.html">Wt::WContainerWidget</a> *<a class="elRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WWidget.html#a3461e31818c4d2f516641bdaf508312a">parent</a>=0)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Constructor. <a href="#a61d205958444a0a7f23cd9558e697c5c"></a><br/></td></tr>
<tr><td colspan="2"><h2><a name="pub-static-attribs"></a>
Static Public Attributes</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">static const char * </td><td class="memItemRight" valign="bottom"><a class="el" href="classFolderView.html#af50f30fffaedf2e6e4b1e0d65acc9df0">FileSelectionMimeType</a> = "application/x-computers-selection"</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Constant that indicates the mime type for a selection of files. <a href="#af50f30fffaedf2e6e4b1e0d65acc9df0"></a><br/></td></tr>
<tr><td colspan="2"><h2><a name="pro-methods"></a>
Protected Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual void </td><td class="memItemRight" valign="bottom"><a class="el" href="classFolderView.html#a7a33bd20f3847bed7fdd1fba82c1496f">dropEvent</a> (const <a class="elRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WDropEvent.html">Wt::WDropEvent</a> &event, const <a class="elRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WModelIndex.html">Wt::WModelIndex</a> &target)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Drop event. <a href="#a7a33bd20f3847bed7fdd1fba82c1496f"></a><br/></td></tr>
</table>
<hr/><a name="details" id="details"></a><h2>Detailed Description</h2>
<div class="textblock"><p>A specialized treeview that supports a custom drop event. </p>
<p>Definition at line <a class="el" href="FolderView_8h_source.html#l00019">19</a> of file <a class="el" href="FolderView_8h_source.html">FolderView.h</a>.</p>
</div><hr/><h2>Constructor & Destructor Documentation</h2>
<a class="anchor" id="a61d205958444a0a7f23cd9558e697c5c"></a><!-- doxytag: member="FolderView::FolderView" ref="a61d205958444a0a7f23cd9558e697c5c" args="(Wt::WContainerWidget *parent=0)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">FolderView::FolderView </td>
<td>(</td>
<td class="paramtype"><a class="elRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WContainerWidget.html">Wt::WContainerWidget</a> * </td>
<td class="paramname"><em>parent</em> = <code>0</code></td><td>)</td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Constructor. </p>
<p>Definition at line <a class="el" href="FolderView_8C_source.html#l00019">19</a> of file <a class="el" href="FolderView_8C_source.html">FolderView.C</a>.</p>
<div class="fragment"><pre class="fragment"> : <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WTreeView.html#aa6555aa2d53557340824faa314b318f2">WTreeView</a>(parent)
{
<span class="comment">/*</span>
<span class="comment"> * Accept drops for the custom mime type.</span>
<span class="comment"> */</span>
<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WWidget.html#aebee4b24e8128c08ae4aa3682adf6d8f">acceptDrops</a>(<a class="code" href="classFolderView.html#af50f30fffaedf2e6e4b1e0d65acc9df0" title="Constant that indicates the mime type for a selection of files.">FileSelectionMimeType</a>);
}
</pre></div>
</div>
</div>
<hr/><h2>Member Function Documentation</h2>
<a class="anchor" id="a7a33bd20f3847bed7fdd1fba82c1496f"></a><!-- doxytag: member="FolderView::dropEvent" ref="a7a33bd20f3847bed7fdd1fba82c1496f" args="(const Wt::WDropEvent &event, const Wt::WModelIndex &target)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void FolderView::dropEvent </td>
<td>(</td>
<td class="paramtype">const <a class="elRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WDropEvent.html">Wt::WDropEvent</a> & </td>
<td class="paramname"><em>event</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const <a class="elRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WModelIndex.html">Wt::WModelIndex</a> & </td>
<td class="paramname"><em>target</em> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td><code> [protected, virtual]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Drop event. </p>
<p>Reimplemented from <a class="elRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WAbstractItemView.html#ae80a4371f19e9c0c14f1cc961da17b87">Wt::WAbstractItemView</a>.</p>
<p>Definition at line <a class="el" href="FolderView_8C_source.html#l00028">28</a> of file <a class="el" href="FolderView_8C_source.html">FolderView.C</a>.</p>
<div class="fragment"><pre class="fragment">{
<span class="comment">/*</span>
<span class="comment"> * We reimplement the drop event to handle the dropping of a</span>
<span class="comment"> * selection of computers.</span>
<span class="comment"> *</span>
<span class="comment"> * The test below would always be true in this case, since we only</span>
<span class="comment"> * indicated support for that particular mime type.</span>
<span class="comment"> */</span>
<span class="keywordflow">if</span> (event.<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WDropEvent.html#a14e3c3a1cb956319cefe63bddc29a0de">mimeType</a>() == <a class="code" href="classFolderView.html#af50f30fffaedf2e6e4b1e0d65acc9df0" title="Constant that indicates the mime type for a selection of files.">FileSelectionMimeType</a>) {
<span class="comment">/*</span>
<span class="comment"> * The source object for a drag of a selection from a WTreeView is</span>
<span class="comment"> * a WItemSelectionModel.</span>
<span class="comment"> */</span>
<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WItemSelectionModel.html">WItemSelectionModel</a> *selection
= <span class="keyword">dynamic_cast<</span><a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WItemSelectionModel.html">WItemSelectionModel</a> *<span class="keyword">></span>(<span class="keyword">event</span>.source());
<span class="preprocessor">#ifdef WT_THREADED</span>
<span class="preprocessor"></span> <span class="keywordtype">int</span> result = <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WWidget.html#a52dcef5a385ddfa0a8c3e6c20000f181">WMessageBox::show</a>
(<span class="stringliteral">"Drop event"</span>,
<span class="stringliteral">"Move "</span>
+ boost::lexical_cast<std::string>(selection-><a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WItemSelectionModel.html#a4c366757fa7e6b5b6519d34e3c2ac084">selectedIndexes</a>().size())
+ <span class="stringliteral">" files to folder '"</span>
+ boost::any_cast<WString>(target.<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WModelIndex.html#a7f05920329ca4b7fdbb10931afdb634e">data</a>(<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/group__modelview.html#gga0ae864e12320f9f89172735e075ed068a5ed17aded8a0e3b712698cf85a218f1f">DisplayRole</a>)).toUTF8()
+ <span class="stringliteral">"' ?"</span>,
<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/namespaceWt.html#a270a5e1af09979a6559f0f39e3d93062a5bf8c24f48fc404ccfea9ae2248a989c">Yes</a> | <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/namespaceWt.html#a270a5e1af09979a6559f0f39e3d93062a4ca128eca84d1965d7ac1bb8a6936e58">No</a>);
<span class="preprocessor">#else</span>
<span class="preprocessor"></span> <span class="keywordtype">int</span> result = <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/namespaceWt.html#a270a5e1af09979a6559f0f39e3d93062a5bf8c24f48fc404ccfea9ae2248a989c">Yes</a>;
<span class="preprocessor">#endif</span>
<span class="preprocessor"></span>
<span class="keywordflow">if</span> (result == Yes) {
<span class="comment">/*</span>
<span class="comment"> * You can access the source model from the selection and</span>
<span class="comment"> * manipulate it.</span>
<span class="comment"> */</span>
<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WAbstractItemModel.html">WAbstractItemModel</a> *sourceModel = selection-><a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WItemSelectionModel.html#a42fb83302389cc2942cc09a198c0ee00">model</a>();
WModelIndexSet toChange = selection-><a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WItemSelectionModel.html#a4c366757fa7e6b5b6519d34e3c2ac084">selectedIndexes</a>();
<span class="keywordflow">for</span> (WModelIndexSet::reverse_iterator i = toChange.rbegin();
i != toChange.rend(); ++i) {
<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WModelIndex.html">WModelIndex</a> index = *i;
<span class="comment">/*</span>
<span class="comment"> * Copy target folder to file. Since we are using a</span>
<span class="comment"> * dynamic WSortFilterProxyModel that filters on folder, this</span>
<span class="comment"> * will also result in the removal of the file from the</span>
<span class="comment"> * current view.</span>
<span class="comment"> */</span>
std::map<int, boost::any> data = <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WAbstractItemView.html#abd583faed8e2fc3936d1b5545c4bbf84">model</a>()-><a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WAbstractItemModel.html#a74055362d502d80375c6599f6f8ea1cf">itemData</a>(target);
data[<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/group__modelview.html#gga0ae864e12320f9f89172735e075ed068aab6678fc176854f7990d6cff4eed779e">DecorationRole</a>] = index.<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WModelIndex.html#a7f05920329ca4b7fdbb10931afdb634e">data</a>(<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/group__modelview.html#gga0ae864e12320f9f89172735e075ed068aab6678fc176854f7990d6cff4eed779e">DecorationRole</a>);
sourceModel-><a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WAbstractItemModel.html#ac60d1042bf1bcea9c262d3de30c520fd">setItemData</a>(index, data);
}
}
}
}
</pre></div>
</div>
</div>
<hr/><h2>Member Data Documentation</h2>
<a class="anchor" id="af50f30fffaedf2e6e4b1e0d65acc9df0"></a><!-- doxytag: member="FolderView::FileSelectionMimeType" ref="af50f30fffaedf2e6e4b1e0d65acc9df0" args="" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">const char * <a class="el" href="classFolderView.html#af50f30fffaedf2e6e4b1e0d65acc9df0">FolderView::FileSelectionMimeType</a> = "application/x-computers-selection"<code> [static]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Constant that indicates the mime type for a selection of files. </p>
<p>Every kind of dragged data should be identified using a unique mime type. </p>
<p>Definition at line <a class="el" href="FolderView_8h_source.html#l00026">26</a> of file <a class="el" href="FolderView_8h_source.html">FolderView.h</a>.</p>
</div>
</div>
<hr/>The documentation for this class was generated from the following files:<ul>
<li>/home/koen/project/wt/public-git/wt/examples/treeview-dragdrop/<a class="el" href="FolderView_8h_source.html">FolderView.h</a></li>
<li>/home/koen/project/wt/public-git/wt/examples/treeview-dragdrop/<a class="el" href="FolderView_8C_source.html">FolderView.C</a></li>
</ul>
</div>
<hr size="1"><address style="text-align: right; margin: 3px"><small>
Generated on Fri Mar 30 2012 for <a href="http://www.webtoolkit.eu/wt">the
C++ Web Toolkit (Wt)</a> by <a
href="http://www.doxygen.org/index.html"><img src="doxygen.png"
alt="doxygen" border="0" style="vertical-align: middle; display:
inline-block; height: 2em"></a> 1.7.5.1</small></address>
</body>
</html>
|