<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">I am wondering on how I could display a single ListModel in multiple (filtered) SilicaGridViews?<div>Simply making an item invisible does not work , because it still consumes (<span style="color: rgb(128, 0, 0);">cellWidth </span>x <span style="color: rgb(128, 0, 0);"> </span><span style="color: rgb(128, 0, 0);">cellHeight</span>) the space.</div><div><br><div>Or would you know a project which did something similar? <br><div><pre style="margin-top: 0px; margin-bottom: 0px;"><br></pre><div><div>I know I could also implement my own model in c++. Probably something like this was done my someone already? </div><div><br></div><div><br></div><div>I am experementing with this QML file (far from ready ;)).</div><div>[FilteredListModel.qml]</div><div>
<pre style="margin-top: 0px; margin-bottom: 0px;"><!--StartFragment--><span style=" color:#808000;">import</span><span style=" color:#c0c0c0;"> </span>QtQuick<span style=" color:#c0c0c0;"> </span>2.0</pre><pre style="margin-top: 0px; margin-bottom: 0px;"><pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#808000;">import</span><span style=" color:#c0c0c0;"> </span>Sailfish.Silica<span style=" color:#c0c0c0;"> </span>1.0<!--EndFragment--></pre><div><br></div></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><br></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#800080;">Item</span><span style=" color:#c0c0c0;"> </span>{</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;"> </span><span style=" color:#808000;">property</span><span style=" color:#c0c0c0;"> </span><span style=" color:#800080;">ListModel</span><span style=" color:#c0c0c0;"> </span><span style=" color:#800000;">filteredModel</span>:<span style=" color:#c0c0c0;"> </span><span style="font-style: italic;">_filteredModel</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;"> </span><span style=" color:#808000;">property</span><span style=" color:#c0c0c0;"> </span><span style=" color:#800080;">ListModel</span><span style=" color:#c0c0c0;"> </span><span style=" color:#800000;">model</span>:<span style=" color:#c0c0c0;"> </span><span style="font-style: italic;">_model</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;"> </span><span style=" color:#808000;">property</span><span style=" color:#c0c0c0;"> </span><span style=" color:#808000;">string</span><span style=" color:#c0c0c0;"> </span><span style=" color:#800000;">filterRoleName</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;"> </span><span style=" color:#808000;">property</span><span style=" color:#c0c0c0;"> </span><span style=" color:#808000;">var</span><span style=" color:#c0c0c0;"> </span><span style=" color:#800000;">filterValue</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><br></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;"> </span><span style=" color:#800080;">ListModel</span><span style=" color:#c0c0c0;"> </span>{</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;"> </span><span style=" color:#800000;">id</span>:<span style=" color:#c0c0c0;"> </span><span style="font-style: italic;">_filteredModel</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;"> </span>}</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><br></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;"> </span><span style=" color:#800080;">ListModel</span><span style=" color:#c0c0c0;"> </span>{</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;"> </span><span style=" color:#800000;">id</span>:<span style=" color:#c0c0c0;"> </span><span style="font-style: italic;">_model</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><br></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;"> </span><span style=" color:#800000;">onRowsInserted</span>:<span style=" color:#c0c0c0;"> </span>{</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;"> </span><span style=" color:#808000;">for</span><span style=" color:#c0c0c0;"> </span>(<span style=" color:#808000;">var</span><span style=" color:#c0c0c0;"> </span><span style=" font-style:italic; color:#2985c7;">i</span><span style=" color:#c0c0c0;"> </span>=<span style=" color:#c0c0c0;"> </span><span style=" font-style:italic; color:#2985c7;">first</span>;<span style=" color:#c0c0c0;"> </span><span style=" font-style:italic; color:#2985c7;">i</span><span style=" color:#c0c0c0;"> </span><=<span style=" color:#c0c0c0;"> </span><span style=" font-style:italic; color:#2985c7;">last</span>;<span style=" color:#c0c0c0;"> </span><span style=" font-style:italic; color:#2985c7;">i</span>++)<span style=" color:#c0c0c0;"> </span>{</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><br></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;"> </span><span style=" color:#808000;">var</span><span style=" color:#c0c0c0;"> </span><span style=" font-style:italic; color:#2985c7;">entry</span><span style=" color:#c0c0c0;"> </span>=<span style=" color:#c0c0c0;"> </span><span style="font-style: italic;">model</span>.get(<span style=" font-style:italic; color:#2985c7;">i</span>);</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;"> </span><span style=" color:#808000;">if</span><span style=" color:#c0c0c0;"> </span>(<span style=" font-style:italic; color:#2985c7;">entry</span>[<span style="font-style: italic;">filterRoleName</span>]<span style=" color:#c0c0c0;"> </span>===<span style=" color:#c0c0c0;"> </span><span style="font-style: italic;">filterValue</span>)</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;"> </span>{</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;"> </span><span style="font-style: italic;">_filteredModel</span>.append(<span style=" font-style:italic; color:#2985c7;">entry</span>);</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;"> </span>}</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;"> </span>}</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;"> </span>}</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><br></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;"> </span><span style=" color:#800000;">onRowsRemoved</span>:<span style=" color:#c0c0c0;"> </span>{</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;"> </span><span style=" color:#808000;">for</span><span style=" color:#c0c0c0;"> </span>(<span style=" color:#808000;">var</span><span style=" color:#c0c0c0;"> </span><span style=" font-style:italic; color:#2985c7;">i</span><span style=" color:#c0c0c0;"> </span>=<span style=" color:#c0c0c0;"> </span><span style=" font-style:italic; color:#2985c7;">first</span>;<span style=" color:#c0c0c0;"> </span><span style=" font-style:italic; color:#2985c7;">i</span><span style=" color:#c0c0c0;"> </span><=<span style=" color:#c0c0c0;"> </span><span style=" font-style:italic; color:#2985c7;">last</span>;<span style=" color:#c0c0c0;"> </span><span style=" font-style:italic; color:#2985c7;">i</span>++)<span style=" color:#c0c0c0;"> </span>{</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;"> </span><span style="font-style: italic;">_filteredModel</span>.remove(<span style=" font-style:italic; color:#2985c7;">i</span>);</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;"> </span>}</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;"> </span>}</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;"> </span>}</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><br></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;"> </span><span style=" color:#808000;">function</span><span style=" color:#c0c0c0;"> </span><span style="font-style: italic;">append</span>(sobject)</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;"> </span>{</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;"> </span><span style="font-style: italic;">model</span>.append(<span style=" font-style:italic; color:#2985c7;">sobject</span>);</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;"> </span>}</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><br></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;"> </span><span style=" color:#808000;">function</span><span style=" color:#c0c0c0;"> </span><span style="font-style: italic;">setProperty</span>(index,<span style=" color:#c0c0c0;"> </span>key,<span style=" color:#c0c0c0;"> </span>value<span style=" color:#c0c0c0;"> </span>)</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;"> </span>{</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;"> </span><span style="font-style: italic;">model</span>.setProperty(<span style=" font-style:italic; color:#2985c7;">index</span>,<span style=" color:#c0c0c0;"> </span><span style=" font-style:italic; color:#2985c7;">key</span>,<span style=" color:#c0c0c0;"> </span><span style=" font-style:italic; color:#2985c7;">value</span>);</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;"> </span><span style=" color:#808000;">var</span><span style=" color:#c0c0c0;"> </span><span style=" font-style:italic; color:#2985c7;">entry</span><span style=" color:#c0c0c0;"> </span>=<span style=" color:#c0c0c0;"> </span><span style="font-style: italic;">model</span>.get(<span style=" font-style:italic; color:#2985c7;">index</span>);</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><br></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;"> </span><span style=" color:#808000;">if</span><span style=" color:#c0c0c0;"> </span>(<span style=" font-style:italic; color:#2985c7;">entry</span>[<span style="font-style: italic;">filterRoleName</span>]<span style=" color:#c0c0c0;"> </span>===<span style=" color:#c0c0c0;"> </span><span style="font-style: italic;">filterValue</span>)</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;"> </span>{</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;"> </span><span style="font-style: italic;">_filteredModel</span>.set(<span style=" font-style:italic; color:#2985c7;">index</span>,<span style=" color:#c0c0c0;"> </span><span style="font-style: italic;">model</span>.get(<span style=" font-style:italic; color:#2985c7;">index</span>))</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;"> </span>}</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;"> </span><span style=" color:#808000;">else</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;"> </span>{</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;"> </span><span style="font-style: italic;">_filteredModel</span>.remove(<span style=" font-style:italic; color:#2985c7;">index</span>);</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;"> </span>}</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;"> </span>}</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><br></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;"> </span><span style=" color:#808000;">function</span><span style=" color:#c0c0c0;"> </span><span style="font-style: italic;">remove</span>(index)</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;"> </span>{</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;"> </span><span style="font-style: italic;">model</span>.remove(<span style=" font-style:italic; color:#2985c7;">index</span>);</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;"> </span>}</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><br></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;"> </span><span style=" color:#800000;">Component.onCompleted</span>:<span style=" color:#c0c0c0;"> </span>{</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;"> </span><span style="font-style: italic;">model</span>.append({<span style=" color:#008000;">"name"</span>:<span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">"Apple"</span>,<span style=" color:#008000;">"cost"</span>:<span style=" color:#c0c0c0;"> </span>0.25,active:<span style=" color:#c0c0c0;"> </span>false});</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;"> </span><span style="font-style: italic;">model</span>.append({<span style=" color:#008000;">"name"</span>:<span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">"Orange"</span>,<span style=" color:#008000;">"cost"</span>:<span style=" color:#c0c0c0;"> </span>0.90,active:<span style=" color:#c0c0c0;"> </span>true});</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;"> </span><span style="font-style: italic;">model</span>.append({<span style=" color:#008000;">"name"</span>:<span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">"Bannana"</span>,<span style=" color:#008000;">"cost"</span>:<span style=" color:#c0c0c0;"> </span>0.30,active:<span style=" color:#c0c0c0;"> </span>true});</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;"> </span><span style="font-style: italic;">model</span>.append({<span style=" color:#008000;">"name"</span>:<span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">"Ananas"</span>,<span style=" color:#008000;">"cost"</span>:<span style=" color:#c0c0c0;"> </span>3.10,active:<span style=" color:#c0c0c0;"> </span>true});</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;"> </span>}</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;">}<!--EndFragment--></pre><div><br></div><div apple-content-edited="true">
<div style="color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><font color="#929292"><br class="Apple-interchange-newline"><br></font></div><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br></div></div></div></div></div></div></div></div></body></html>