Sophie

Sophie

distrib > Mageia > 4 > i586 > by-pkgid > 41640b7d04ef5b5040e7668305a5ba3d > files > 490

python-kde4-doc-4.11.4-1.mga4.noarch.rpm

<?xml version="1.0" encoding="UTF-8"?>
<!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" lang="en" xml:lang="en">

<head>
  <title>KLinkItemSelectionModel</title>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta http-equiv="Content-Style-Type" content="text/css" />
  <link rel="stylesheet" type="text/css" href="../common/doxygen.css" />
  <link rel="stylesheet" media="screen" type="text/css" title="KDE Colors" href="../common/kde.css" />
</head>
<body>
<div id="container">
<div id="header">
  <div id="header_top">
    <div>
      <div>
        <img alt ="" src="../common/top-kde.jpg"/>
        KDE 4.9 PyKDE API Reference
      </div>
    </div>
  </div>
  <div id="header_bottom">
    <div id="location">
      <ul>
        <li>KDE's Python API</li>
      </ul>
    </div>

    <div id="menu">
      <ul>
        <li><a href="../modules.html">Overview</a></li>
<li><a href="http://techbase.kde.org/Development/Languages/Python">PyKDE Home</a></li>
<li><a href="http://kde.org/family/">Sitemap</a></li>
<li><a href="http://kde.org/contact/">Contact Us</a></li>
</ul>
    </div>
  </div>
</div>

<div id="body_wrapper">
<div id="body">
<div id="right">
<div class="content">
<div id="main">
<div class="clearer">&nbsp;</div>

<h1>KLinkItemSelectionModel Class Reference</h1>
<code>from PyKDE4.kdeui import *</code>
<p>
Inherits: QItemSelectionModel &#x2192; QObject<br />


<h2>Detailed Description</h2>

<p>Makes it possible to share a selection in multiple views which do not have the same source model
</p>
<p>
Although <a href="http://doc.trolltech.com/4.6/model-view-view.html#sharing-selections-between-views">multiple views can share the same QItemSelectionModel</a>, the views then need to have the same source model.
</p>
<p>
If there is a proxy model between the model and one of the views, or different proxy models in each, this class makes
it possible to share the selection between the views.
</p>
<p>
<div align="center"><img src="../images/kproxyitemselectionmodel-simple.png" /><p><strong> "Sharing a QItemSelectionModel between views on the same model is trivial" </strong></p></div>
<div align="center"><img src="../images/kproxyitemselectionmodel-error.png" /><p><strong> "If a proxy model is used, it is no longer possible to share the QItemSelectionModel directly" </strong></p></div>
<div align="center"><img src="../images/kproxyitemselectionmodel-solution.png" /><p><strong> "A KProxyItemSelectionModel can be used to map the selection through the proxy model" </strong></p></div>
</p>
<p>
<pre class="fragment">
QAbstractItemModel *model = getModel();

QSortFilterProxyModel *proxy = new QSortFilterProxyModel();
proxy-&gt;setSourceModel(model);

QTreeView *view1 = new QTreeView(splitter);
view1-&gt;setModel(model);

KProxyItemSelectionModel *view2SelectionModel = new KProxyItemSelectionModel( proxy, view1-&gt;selectionModel());

QTreeView *view2 = new QTreeView(splitter);
// Note that the QAbstractItemModel passed to KProxyItemSelectionModel must be the same as what is used in the view
view2-&gt;setModel(proxy);
view2-&gt;setSelectionModel( view2SelectionModel );
</pre>
</p>
<p>
<div align="center"><img src="../images/kproxyitemselectionmodel-complex.png" /><p><strong> "Arbitrarily complex proxy configurations on the same root model can be used" </strong></p></div>
</p>
<p>
<pre class="fragment">
QAbstractItemModel *model = getModel();

QSortFilterProxyModel *proxy1 = new QSortFilterProxyModel();
proxy1-&gt;setSourceModel(model);
QSortFilterProxyModel *proxy2 = new QSortFilterProxyModel();
proxy2-&gt;setSourceModel(proxy1);
QSortFilterProxyModel *proxy3 = new QSortFilterProxyModel();
proxy3-&gt;setSourceModel(proxy2);

QTreeView *view1 = new QTreeView(splitter);
view1-&gt;setModel(proxy3);

QSortFilterProxyModel *proxy4 = new QSortFilterProxyModel();
proxy4-&gt;setSourceModel(model);
QSortFilterProxyModel *proxy5 = new QSortFilterProxyModel();
proxy5-&gt;setSourceModel(proxy4);

KProxyItemSelectionModel *view2SelectionModel = new KProxyItemSelectionModel( proxy5, view1-&gt;selectionModel());

QTreeView *view2 = new QTreeView(splitter);
// Note that the QAbstractItemModel passed to KProxyItemSelectionModel must be the same as what is used in the view
view2-&gt;setModel(proxy5);
view2-&gt;setSelectionModel( view2SelectionModel );
</pre>
</p>
<p>
See also <a href="http://websvn.kde.org/trunk/KDE/kdelibs/kdeui/tests/proxymodeltestapp/proxyitemselectionwidget.cpp?view=markup">kdelibs/kdeui/tests/proxymodeltestapp/proxyitemselectionwidget.cpp</a>.
</p>
<p>
<dl class="since" compact><dt><b>Since:</b></dt><dd> 4.5
</dd></dl> 
<dl class="author" compact><dt><b>Author:</b></dt><dd> Stephen Kelly &lt;steveire@gmail.com&gt; </dd></dl>
</p>
<table border="0" cellpadding="0" cellspacing="0"><tr><td colspan="2"><br><h2>Methods</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="#KLinkItemSelectionModel">__init__</a> (self, QAbstractItemModel targetModel, QItemSelectionModel linkedItemSelectionModel, QObject parent=0)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="#select">select</a> (self, QModelIndex index, QItemSelectionModel::SelectionFlags command)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="#select">select</a> (self, QItemSelection selection, QItemSelectionModel::SelectionFlags command)</td></tr>
</table>
<hr><h2>Method Documentation</h2><a class="anchor" name="KLinkItemSelectionModel"></a>
<div class="memitem">
<div class="memproto">
<table class="memname"><tr>
<td class="memname">__init__</td>
<td>(</td>
<td class="paramtype">&nbsp;<em>self</em>, </td>
<td class="paramname"></td>
</tr><tr>
<td class="memname"></td>
<td></td>
<td class="paramtype">QAbstractItemModel&nbsp;</td>
<td class="paramname"><em>targetModel</em>, </td>
</tr>
<tr>
<td class="memname"></td>
<td></td>
<td class="paramtype">QItemSelectionModel&nbsp;</td>
<td class="paramname"><em>linkedItemSelectionModel</em>, </td>
</tr>
<tr>
<td class="memname"></td>
<td></td>
<td class="paramtype">QObject&nbsp;</td>
<td class="paramname"><em>parent=0</em></td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td>
<td></td>
<td width="100%"> </td>
</tr></table>
</div>
<div class="memdoc"><p>Constructor.
</p></div></div><a class="anchor" name="select"></a>
<div class="memitem">
<div class="memproto">
<table class="memname"><tr>
<td class="memname"> select</td>
<td>(</td>
<td class="paramtype">&nbsp;<em>self</em>, </td>
<td class="paramname"></td>
</tr><tr>
<td class="memname"></td>
<td></td>
<td class="paramtype">QModelIndex&nbsp;</td>
<td class="paramname"><em>index</em>, </td>
</tr>
<tr>
<td class="memname"></td>
<td></td>
<td class="paramtype">QItemSelectionModel::SelectionFlags&nbsp;</td>
<td class="paramname"><em>command</em></td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td>
<td></td>
<td width="100%"> </td>
</tr></table>
</div>
<div class="memdoc"></div></div><a class="anchor" name="select"></a>
<div class="memitem">
<div class="memproto">
<table class="memname"><tr>
<td class="memname"> select</td>
<td>(</td>
<td class="paramtype">&nbsp;<em>self</em>, </td>
<td class="paramname"></td>
</tr><tr>
<td class="memname"></td>
<td></td>
<td class="paramtype">QItemSelection&nbsp;</td>
<td class="paramname"><em>selection</em>, </td>
</tr>
<tr>
<td class="memname"></td>
<td></td>
<td class="paramtype">QItemSelectionModel::SelectionFlags&nbsp;</td>
<td class="paramname"><em>command</em></td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td>
<td></td>
<td width="100%"> </td>
</tr></table>
</div>
<div class="memdoc"></div></div>
</div>
</div>
</div>

<div id="left">

<div class="menu_box">
<div class="nav_list">
<ul>
<li><a href="../allclasses.html">Full Index</a></li>
</ul>
</div>

<a name="cp-menu" /><div class="menutitle"><div>
  <h2 id="cp-menu-project">Modules</h2>
</div></div>
<div class="nav_list">
<ul><li><a href="../akonadi/index.html">akonadi</a></li>
<li><a href="../dnssd/index.html">dnssd</a></li>
<li><a href="../kdecore/index.html">kdecore</a></li>
<li><a href="../kdeui/index.html">kdeui</a></li>
<li><a href="../khtml/index.html">khtml</a></li>
<li><a href="../kio/index.html">kio</a></li>
<li><a href="../knewstuff/index.html">knewstuff</a></li>
<li><a href="../kparts/index.html">kparts</a></li>
<li><a href="../kutils/index.html">kutils</a></li>
<li><a href="../nepomuk/index.html">nepomuk</a></li>
<li><a href="../phonon/index.html">phonon</a></li>
<li><a href="../plasma/index.html">plasma</a></li>
<li><a href="../polkitqt/index.html">polkitqt</a></li>
<li><a href="../solid/index.html">solid</a></li>
<li><a href="../soprano/index.html">soprano</a></li>
</ul></div></div>

</div>

</div>
  <div class="clearer"/>
</div>

<div id="end_body"></div>
</div>
<div id="footer"><div id="footer_text">
This documentation is maintained by <a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;simon&#64;simonzone&#46;com">Simon Edwards</a>.<br />
        KDE<sup>&#174;</sup> and <a href="../images/kde_gear_black.png">the K Desktop Environment<sup>&#174;</sup> logo</a> are registered trademarks of <a href="http://ev.kde.org/" title="Homepage of the KDE non-profit Organization">KDE e.V.</a> |
        <a href="http://www.kde.org/contact/impressum.php">Legal</a>
    </div></div>
</body>
</html>