<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Nov 3, 2014 at 10:21 PM, Dirk Hohndel <span dir="ltr"><<a href="mailto:dirk@hohndel.org" target="_blank">dirk@hohndel.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">So I'm trying to understand how this all hooks together and it's clear<br>
that there's some Qt magic in the background that I'm missing...<br></blockquote><div><br></div><div>There is a bit of black magic, yes.<br><br></div><div>So, everytime a filter is changed, *every* row on the dive list is send to a specific function,<br></div><div>trips and dives, doesn't matter:<br><br></div><div>this one:<br>bool MultiFilterSortModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const<br> <br></div><div>but if you wanna check if something happened just *after* the filter was due,<br></div><div>you need to implement something inside of the<br><br>void MultiFilterSortModel::myInvalidate()<br>{<br>    invalidate();<br></div><div> // HERE.<br></div><div>}<br><br></div><div>The 'invalidate()' method is internal to Qt and all it does is mark the model as dirty and filter everything again based on the filterAcceptsRow.<br><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Let's assume I want to have a function called every time the filters<br>
change. How would I go about this?<br></blockquote><div><br></div><div>Add it after the invalidate() call.<br></div><div>or create a new signal inside of MultiFilterSortModel called 'filterFinished()', call it after the invalidate() call, and connect it to your own slot.<br> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Another question. In the regular model code for the dive list - we have<br>
lots of selection modification code there. That needs to become aware of<br>
filter data so that selecting a trip in the filtered view only selects the<br>
dives inside this trip that are visible under the filter - and similarly,<br>
the trip row in the view needs to show the number of visible dives in that<br>
trip, not the number of total dives in that trip.<br></blockquote><div><br></div><div>Very hard to do with our current setup:<br> The state of the DiveModel is unchanged, we are applying a filter on top of it.<br></div><div> so it doesn't know about the filter at all.<br><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
To illustrate:<br>
<br>
I have a trip with 12 dives<br>
<br>
I filter for dives with Buddy Tomaz<br>
<br>
Then only the 6 dives with Tomaz are shown, but similarly the trip summary<br>
row should read<br>
<br>
Dive trip (6 dives)<br>
<br>
instead of "(12 dives)"<br>
<br>
So when I'm in TripItem::data() member, how can I figure out how many of<br>
the dives in that trip are visible with the current filter?<br></blockquote><div><br></div><div>*right now* we cant. simple as that ( unless we do something really ugly to the code. )<br></div><div>so, Options:<br><br></div><div>1 - We hack around that, but the code will be easy to break and hard to maintain, for now.<br></div><div>2 - We hm....<br></div><div>okay, some light came, maybe we can.<br><br></div><div>the MultiFilterProxyModel acts as 'proxy' so we can use it's own data() method to retrieve information about<br>the filtered trip - but I'm not really sure it works, I need to test and see, the setup should be as this:<br><br></div><div>1 - Implement the data() method for MultiFilterProxyModel,<br></div><div>if the current index is a dive, call the default implementation<br>if the current index is a trip, verify the number of children it has in the proxy model, not in the real model.<br></div><div>return the correct string.<br><br></div><div><br></div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
I'm not asking you to implement any or all of this - I'm hoping that<br>
you'll be able to teach me enough to understand how all this works so I<br>
can implement it myself.<br>
<span class=""><font color="#888888"><br>
/D<br>
</font></span></blockquote></div><br></div></div>