<div dir="ltr">              Hi Oleksii,<div style>  After writing the code I realized that RemorseItem by default excecutes its executable onDestruction() when its timer is on. I am not quite sure why it didn't work the same way before or why I precieved it differently.</div><div style><br></div><div style>Thanks again Kris</div></div><div class="gmail_extra"><br><div class="gmail_quote">On 14 October 2014 08:46, Oleksii Serdiuk <span dir="ltr"><<a href="mailto:contacts@oleksii.name" target="_blank">contacts@oleksii.name</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Kris,<br>
<br>
Aha! So what you want is:<br>
<br>
1. User selects to remove an item in the ListView.<br>
2. RemorseItem activates so user can cancel the deletion.<br>
3. When timer times out, the item is actually deleted from the model.<br>
<br>
And, in this case, 3. breaks when user scrolls the item away before<br>
timeout: delegate is deleted -> RemorseItem never times out -> item not<br>
deleted from the model.<br>
<br>
Then yes, performing deletion in Component.onDestruction() is the way<br>
Jolla's standard apps do (at least I've seen it in one of their apps).<br>
So you're on the right track :-)<br>
<span class=""><br>
On 13/10/14 23:54, Krisztian Olah wrote:<br>
>        Hi Oleksii,<br>
>   It is the model that handles the actual removal, but I want a<br>
> RemorseItem to call it, which is in return requested by the delegate. I<br>
> want all list items to have their own remorse timer in case user wants<br>
> to cancel one but not the other.<br>
>   In my current version it works fine, except when the user scrolls away<br>
> too far the RemorseItem is destroyed and the file is left on the disk,<br>
> but come to think of it; perhaps I could just call the model.remove()<br>
> function when onDestruction() signal is emitted. Thanks, if I didn't<br>
> write this letter I might not think of it. :)<br>
><br>
> Anyway if you want to see the latest version you can have a look here:<br>
> <a href="https://github.com/KrisztianOlah/london-sail/blob/devel/qml/pages/MyMapsPage.qml" target="_blank">https://github.com/KrisztianOlah/london-sail/blob/devel/qml/pages/MyMapsPage.qml</a><br>
><br>
> I'd be happy for any feedback. :)<br>
><br>
> Thanks Kris<br>
><br>
> On 13 October 2014 20:10, Oleksii Serdiuk <<a href="mailto:contacts@oleksii.name">contacts@oleksii.name</a><br>
</span><span class="">> <mailto:<a href="mailto:contacts@oleksii.name">contacts@oleksii.name</a>>> wrote:<br>
><br>
>     Hi Kris,<br>
><br>
>     If I understood you right, why do you try to remove list elements<br>
>     directly from the ListVie. You should be removing them from the<br>
>     model and it will also remove components from the list.<br>
><br>
>     See<br>
</span>>     <a href="http://qt-project.org/doc/qt-__5/qml-qtqml-models-listmodel.__html" target="_blank">http://qt-project.org/doc/qt-__5/qml-qtqml-models-listmodel.__html</a><br>
<span class="">>     <<a href="http://qt-project.org/doc/qt-5/qml-qtqml-models-listmodel.html" target="_blank">http://qt-project.org/doc/qt-5/qml-qtqml-models-listmodel.html</a>><br>
><br>
>     You can access ListView's model through its 'model' property:<br>
><br>
>     > listView.model.remove(index);<br>
><br>
><br>
>     If you'd like to animate the removal, set 'remove' property of<br>
>     ListView (SilicaListView is based on ListView) to some transition<br>
>     animation.<br>
><br>
</span>>     <a href="http://qt-project.org/doc/qt-__5/qml-qtquick-listview.html#__remove-prop" target="_blank">http://qt-project.org/doc/qt-__5/qml-qtquick-listview.html#__remove-prop</a><br>
<span class="">>     <<a href="http://qt-project.org/doc/qt-5/qml-qtquick-listview.html#remove-prop" target="_blank">http://qt-project.org/doc/qt-5/qml-qtquick-listview.html#remove-prop</a>><br>
><br>
><br>
>     That would be a "proper" way to do it :-)<br>
><br>
><br>
><br>
>     On 10.10.2014 17:00, Krisztian Olah wrote:<br>
><br>
>                        Hi everyone,<br>
><br>
>            I need some help between choosing ListView or Repeater.<br>
>         I've got a SilicaListView whose elements I want to remove(only<br>
>         remove,<br>
>         never add) dynamically from GUI. When I have fairly a long list<br>
>         count(~25), reaching the element with<br>
</span>>         ListView.contentItem.children[__index] is not possible for the<br>
<div class="HOEnZb"><div class="h5">>         mid to end<br>
>         of the list, probably because ListView destroys items that are not<br>
>         visible. When that happens children[index] will not refer to the<br>
>         same<br>
>         element as model.index and therefore I cannot call remove() on<br>
>         the item.<br>
>         Using a Repeater would of course prevent this, but I don't think<br>
>         I can<br>
>         have a RemoveAnimation and I think I would have to reset the model.<br>
><br>
>            Is there another way that I didn't think of that would allow<br>
>         me to<br>
>         remove items from my model with animation and would allow me to<br>
>         have a<br>
>         list up to 1000 members(in real use it will probably be under<br>
>         100) long?<br>
><br>
>                Thanks in advance<br>
>                         Kris<br>
<br>
--<br>
With best regards,<br>
Oleksii Serdiuk<br>
<br>
</div></div><br>_______________________________________________<br>
SailfishOS.org Devel mailing list<br>
To unsubscribe, please send a mail to <a href="mailto:devel-unsubscribe@lists.sailfishos.org">devel-unsubscribe@lists.sailfishos.org</a><br></blockquote></div><br></div>