<div class="gmail_quote">On Thu, Aug 13, 2009 at 5:44 PM, Ilkka Ollakka <span dir="ltr"><<a href="mailto:ilkka.ollakka%2Bvlc@oamk.fi">ilkka.ollakka+vlc@oamk.fi</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div id=":1az" class="ii gt">I'm not sure if we need to store playlist_item_t* in playlist_model, as<br>
we can get it from playlist in playlist_ItemGetByInput( playlist,<br>
input_item_t ). But yes, it could be easier if we could do littlebit<br>
finer locking on playlist items also.<br>
<br>
Ofcourse it would help to retain node-order if we could store<br>
playlist_item_t* in model, and I tried it myself (not with great success<br>
;)<br>
<br>
But maybe it could be done just storing input_item_t* pointers in<br>
hierarchy inside model, as currently PLitem basicly holds info if it's<br>
current item, showflags (which are same on every-item usually), and what<br>
item is it's parent.</div></blockquote></div><br>My idea was to not have another hierarchy for the Qt4 model at all, to really just use p_playlist_t and p_playlist_item_t.<br>We would use<br><br><blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;" class="gmail_quote">
QModelIndex index = createIndex (row, 0, <i>(playlist_item_t *)</i> item);<br></blockquote><br>Then for example:<br><br><blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;" class="gmail_quote">
int rowCount( QModelIndex index)<br>{<br>    return static_cast<playlist_item_t*>( index.internalPointer() )->i_children;<br>}<br></blockquote><br>In this case we couldn't just use input_item_t* instead of playlist_item_t* because the former doesn't hold information about children and parent. And if using playlist_ItemGetByInput() we can never know if we are in the category or onelevel storage space, because it will return always one of them and you can't choose. I must comment that this category/onelevel thing complicates stuff quite a lot, probably everybody that dealt with playlist code realized that.<br>
<br>On Thu, Aug 13, 2009 at 5:44 PM, Ilkka Ollakka <span dir="ltr"><<a href="mailto:ilkka.ollakka%2Bvlc@oamk.fi">ilkka.ollakka+vlc@oamk.fi</a>></span> wrote:<br><blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;" class="gmail_quote">
Actually not sure if this helps that much, but we can notify views<br>
 inside qt4 gui, as most of the deletions are triggered from gui and<br>
 user-actions (exluding playlist-demuxers). If I don't remember that all<br>
 wrong.</blockquote><div><br>Hmm, demuxer callbacks could be a problem, but since the callback is for "input item got subitem" it actually doesn't mess with playlist items, so there we could notify views in advance.<br>
But i'm guessing: there was this recent furious debate about multiple interfaces at the same time, and imagine that another interface could remove playlist items and only then notify the system... mess. I think inside the core playlist code it should be like that:<br>
<blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;" class="gmail_quote"><div style="text-align: left;">void example_core_remove_item(playlist_item_t* item)<br>{<br>
   example_send_callback_item_will_be_removed (item);<br>   example_do_the_removing(item);<br>   example_send_callback_item_removed(item);<br>}</div></blockquote><div>And then :<br><blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;" class="gmail_quote">
void PLModel::example_on_item_will_be_removed(item) { emit beginRemoveRows(...); }<br>void PLModel::example_on_item_removed(item) { emit endRemoveRows(...); }</blockquote><div>Of course then:<br><blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;" class="gmail_quote">
void PLModel::example_remove_item ( QModelIndex qmIndex )<br>{<br>    example_core_remove_item ( static_cast<playlist_item_t*>( index.internalPointer() ) )<br>}</blockquote><div> </div></div></div>And that's all the model should do upon removing. The nice way of not having another hierarchy for the qt4 model is that you don't need to have double tree management code, the core will do it all, the qt model only passes info to the qt view.<br>
<br>Hmm, I only guess what happens if beginRemoveRows is called more than once before endRemoveRows... and similar...<br> </div>