Commit d9cdd294 authored by Erwan Tulou's avatar Erwan Tulou

skins2: use enum type for better clarity

parent fd930cde
......@@ -140,21 +140,24 @@ int CtrlTree::maxItems()
void CtrlTree::onUpdate( Subject<VarTree, tree_update> &rTree,
tree_update *arg )
{
if( arg->i_type == 0 ) // Item update
if( arg->type == arg->UpdateItem ) // Item update
{
if( arg->b_active_item )
autoScroll();
if( isItemVisible( arg->i_id ) )
{
makeImage();
notifyLayout();
}
else if ( arg->i_type == 1 ) // Global change or deletion
}
else if ( arg->type == arg->ResetAll ) // Global change or deletion
{
m_firstPos = m_flat ? m_rTree.firstLeaf() : m_rTree.begin();
makeImage();
notifyLayout();
}
else if ( arg->i_type == 2 ) // Item-append
else if ( arg->type == arg->AppendItem ) // Item-append
{
if( m_flat && m_firstPos->size() )
{
......@@ -169,7 +172,7 @@ void CtrlTree::onUpdate( Subject<VarTree, tree_update> &rTree,
notifyLayout();
}
}
else if( arg->i_type == 3 ) // item-del
else if( arg->type == arg->DeleteItem ) // item-del
{
/* Make sure firstPos is valid */
VarTree::Iterator it_old = m_firstPos;
......
......@@ -35,9 +35,18 @@
/// Description of an update to the tree
typedef struct tree_update
{
int i_type;
enum type_t
{
UpdateItem,
AppendItem,
DeleteItem,
ResetAll,
};
enum type_t type;
int i_id;
bool b_active_item;
} tree_update;
/// Tree variable
......
......@@ -57,7 +57,7 @@ void Playtree::delSelected()
}
/// \todo Do this better (handle item-deleted)
tree_update descr;
descr.i_type = 3;
descr.type = tree_update::DeleteItem;
notify( &descr );
it = begin();
while( it != end() )
......@@ -114,7 +114,7 @@ void Playtree::onChange()
{
buildTree();
tree_update descr;
descr.i_type = 1;
descr.type = tree_update::ResetAll;
notify( &descr );
}
......@@ -129,7 +129,7 @@ void Playtree::onUpdateItem( int id )
it->setString( UStringPtr( pName ) );
tree_update descr;
descr.i_type = 0;
descr.type = tree_update::UpdateItem;
descr.i_id = id;
descr.b_active_item = false;
notify( &descr );
......@@ -149,7 +149,7 @@ void Playtree::onUpdateCurrent( bool b_active )
it->setPlaying( false );
tree_update descr;
descr.i_type = 0;
descr.type = tree_update::UpdateItem;
descr.i_id = it->getId();
descr.b_active_item = false;
notify( &descr );
......@@ -175,7 +175,7 @@ void Playtree::onUpdateCurrent( bool b_active )
playlist_Unlock( m_pPlaylist );
tree_update descr;
descr.i_type = 0;
descr.type = tree_update::UpdateItem;
descr.i_id = current->i_id;
descr.b_active_item = true;
notify( &descr );
......@@ -192,7 +192,7 @@ void Playtree::onDelete( int i_id )
item->setDeleted( true );
tree_update descr;
descr.i_type = 3;
descr.type = tree_update::DeleteItem;
descr.i_id = i_id;
notify( &descr );
......@@ -223,7 +223,7 @@ void Playtree::onAppend( playlist_add_t *p_add )
playlist_Unlock( m_pPlaylist );
tree_update descr;
descr.i_type = 2;
descr.type = tree_update::AppendItem;
descr.i_id = p_add->i_item;
notify( &descr );
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment