Questions about models in NotificationDelegate.qml

Marco Martin notmart at gmail.com
Tue Sep 3 22:17:37 UTC 2013


On Tuesday 27 August 2013, Christoph Feck wrote:
> Hi,
> 
> Looking at the NotificationDelegate.qml file, I see several lines that
> say "notificationsModel.remove(index)", fired from timers, running
> animations etc.
> 
> Do QML models automatically make sure the index is still valid, in
> other words, when e.g. the timer fires delayed, and another item has
> been added or removed in the meantime, is the index updated
> accordingly? Or worse, if the item has been removed for other reasons,
> is the timer/animation automatically cancelled so that remove() is not
> called again?

in that case the timer is inside the dellegate itself.

in the context of the delegate, index will always be the index associated to 
that delegate itself, and yes, it's always valid.

if there is a timer in the delegate that right now has index 3, but the index 
2 gets removed from the index before the timer expires, the inex variable will 
automatically be changed to 2, continuing to point to the proper item.

on the other hand, if the index variable had been saved to another variable, 
that would have caused problems because that cpy wouldn't get updated, so 
could get incorrect, but doesn't seem to be the case.

Cheers,
Marco Martin


More information about the Plasma-devel mailing list