Sophie

Sophie

distrib > Fedora > 18 > x86_64 > by-pkgid > b3a1f4d91c26f535919e39e25606614a > files > 332

wt-doc-3.2.3-1.fc18.noarch.rpm

<!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
   &#160;<span id="projectnumber">3.2.3</span>
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;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&#160;List</span></a></li>
      <li><a href="inherits.html"><span>Class&#160;Hierarchy</span></a></li>
      <li><a href="functions.html"><span>Class&#160;Members</span></a></li>
    </ul>
  </div>
</div>
<div class="header">
  <div class="summary">
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="#pub-static-attribs">Static Public Attributes</a> &#124;
<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 &lt;<a class="el" href="FolderView_8h_source.html">FolderView.h</a>&gt;</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">&#160;</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">&#160;</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 *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classFolderView.html#af50f30fffaedf2e6e4b1e0d65acc9df0">FileSelectionMimeType</a> = &quot;application/x-computers-selection&quot;</td></tr>
<tr><td class="mdescLeft">&#160;</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&#160;</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> &amp;event, const <a class="elRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WModelIndex.html">Wt::WModelIndex</a> &amp;target)</td></tr>
<tr><td class="mdescLeft">&#160;</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 &amp; 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> *&#160;</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 &amp;event, const Wt::WModelIndex &amp;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> &amp;&#160;</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> &amp;&#160;</td>
          <td class="paramname"><em>target</em>&#160;</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&lt;</span><a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WItemSelectionModel.html">WItemSelectionModel</a> *<span class="keyword">&gt;</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">&quot;Drop event&quot;</span>,
       <span class="stringliteral">&quot;Move &quot;</span>
       + boost::lexical_cast&lt;std::string&gt;(selection-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WItemSelectionModel.html#a4c366757fa7e6b5b6519d34e3c2ac084">selectedIndexes</a>().size())
       + <span class="stringliteral">&quot; files to folder &#39;&quot;</span>
       + boost::any_cast&lt;WString&gt;(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">&quot;&#39; ?&quot;</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-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WItemSelectionModel.html#a42fb83302389cc2942cc09a198c0ee00">model</a>();

      WModelIndexSet toChange = selection-&gt;<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&lt;int, boost::any&gt; data = <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WAbstractItemView.html#abd583faed8e2fc3936d1b5545c4bbf84">model</a>()-&gt;<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-&gt;<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> = &quot;application/x-computers-selection&quot;<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 Thu Nov 1 2012 for <a href="http://www.webtoolkit.eu/wt">the
C++ Web Toolkit (Wt)</a> by&nbsp;<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>