Commit 1c41fce0 authored by Erwan Tulou's avatar Erwan Tulou

skins2: add accessors to VarTree

parent 3b3251c4
This diff is collapsed.
...@@ -68,16 +68,24 @@ public: ...@@ -68,16 +68,24 @@ public:
/// Remove all elements from the children's list /// Remove all elements from the children's list
virtual void clear(); virtual void clear();
/// \todo Use accessors for these fields ? inline int getId() { return m_id; }
int m_id; inline void *getData() { return m_pData; }
UStringPtr m_cString; inline UString* getString() {return (UString*)m_cString.get(); }
bool m_selected; inline void setString( UStringPtr val ) { m_cString = val; }
bool m_playing;
bool m_expanded;
bool m_deleted;
void *m_pData;
inline bool isReadonly() { return m_readonly; }; inline bool isReadonly() { return m_readonly; };
inline bool isSelected() { return m_selected; };
inline bool isPlaying() { return m_playing; };
inline bool isExpanded() { return m_expanded; };
inline bool isDeleted() { return m_deleted; };
inline void setSelected( bool val ) { m_selected = val; }
inline void setPlaying( bool val ) { m_playing = val; }
inline void setExpanded( bool val ) { m_expanded = val; }
inline void setDeleted( bool val ) { m_deleted = val; }
inline void toggleSelected() { m_selected = !m_selected; }
inline void toggleExpanded() { m_expanded = !m_expanded; }
/// Get the number of children /// Get the number of children
int size() const { return m_children.size(); } int size() const { return m_children.size(); }
...@@ -196,7 +204,16 @@ private: ...@@ -196,7 +204,16 @@ private:
/// Pointer to parent node /// Pointer to parent node
VarTree *m_pParent; VarTree *m_pParent;
int m_id;
void *m_pData;
UStringPtr m_cString;
/// indicators
bool m_readonly; bool m_readonly;
bool m_selected;
bool m_playing;
bool m_expanded;
bool m_deleted;
/// Variable type /// Variable type
static const string m_type; static const string m_type;
......
...@@ -53,7 +53,7 @@ void Playtree::delSelected() ...@@ -53,7 +53,7 @@ void Playtree::delSelected()
playlist_Lock( getIntf()->p_sys->p_playlist ); playlist_Lock( getIntf()->p_sys->p_playlist );
for( it = begin(); it != end(); it = getNextItem( it ) ) for( it = begin(); it != end(); it = getNextItem( it ) )
{ {
if( it->m_selected && !it->isReadonly() ) if( it->isSelected() && !it->isReadonly() )
{ {
it->cascadeDelete(); it->cascadeDelete();
} }
...@@ -65,10 +65,10 @@ void Playtree::delSelected() ...@@ -65,10 +65,10 @@ void Playtree::delSelected()
it = begin(); it = begin();
while( it != end() ) while( it != end() )
{ {
if( it->m_deleted ) if( it->isDeleted() )
{ {
VarTree::Iterator it2; VarTree::Iterator it2;
playlist_item_t *p_item = (playlist_item_t *)(it->m_pData); playlist_item_t *p_item = (playlist_item_t *)(it->getData());
if( p_item->i_children == -1 ) if( p_item->i_children == -1 )
{ {
playlist_DeleteFromInput( getIntf()->p_sys->p_playlist, playlist_DeleteFromInput( getIntf()->p_sys->p_playlist,
...@@ -97,7 +97,7 @@ void Playtree::action( VarTree *pItem ) ...@@ -97,7 +97,7 @@ void Playtree::action( VarTree *pItem )
playlist_Lock( m_pPlaylist ); playlist_Lock( m_pPlaylist );
VarTree::Iterator it; VarTree::Iterator it;
playlist_item_t *p_item = (playlist_item_t *)pItem->m_pData; playlist_item_t *p_item = (playlist_item_t *)pItem->getData();
playlist_item_t *p_parent = p_item; playlist_item_t *p_parent = p_item;
while( p_parent ) while( p_parent )
{ {
...@@ -129,9 +129,9 @@ void Playtree::onUpdateItem( int id ) ...@@ -129,9 +129,9 @@ void Playtree::onUpdateItem( int id )
if( it != end() ) if( it != end() )
{ {
// Update the item // Update the item
playlist_item_t* pNode = (playlist_item_t*)(it->m_pData); playlist_item_t* pNode = (playlist_item_t*)(it->getData());
UString *pName = new UString( getIntf(), pNode->p_input->psz_name ); UString *pName = new UString( getIntf(), pNode->p_input->psz_name );
it->m_cString = UStringPtr( pName ); it->setString( UStringPtr( pName ) );
} }
else else
{ {
...@@ -151,7 +151,7 @@ void Playtree::onUpdateCurrent( bool b_active ) ...@@ -151,7 +151,7 @@ void Playtree::onUpdateCurrent( bool b_active )
Iterator it = findById( m_currentItem->i_id ); Iterator it = findById( m_currentItem->i_id );
if( it != end() ) if( it != end() )
it->m_playing = false; it->setPlaying( false );
m_currentItem = NULL; m_currentItem = NULL;
} }
else else
...@@ -167,7 +167,7 @@ void Playtree::onUpdateCurrent( bool b_active ) ...@@ -167,7 +167,7 @@ void Playtree::onUpdateCurrent( bool b_active )
Iterator it = findById( current->i_id ); Iterator it = findById( current->i_id );
if( it != end() ) if( it != end() )
it->m_playing = true; it->setPlaying( true );
m_currentItem = current; m_currentItem = current;
playlist_Unlock( m_pPlaylist ); playlist_Unlock( m_pPlaylist );
...@@ -189,12 +189,12 @@ void Playtree::onDelete( int i_id ) ...@@ -189,12 +189,12 @@ void Playtree::onDelete( int i_id )
{ {
VarTree* parent = item->parent(); VarTree* parent = item->parent();
item->m_deleted = true; item->setDeleted( true );
tree_update descr; tree_update descr;
descr.i_id = i_id; descr.i_id = i_id;
descr.i_type = 3; descr.i_type = 3;
descr.b_visible = parent ? parent->m_expanded : true; descr.b_visible = parent ? parent->isExpanded() : true;
notify( &descr ); notify( &descr );
if( parent ) if( parent )
...@@ -232,7 +232,7 @@ void Playtree::onAppend( playlist_add_t *p_add ) ...@@ -232,7 +232,7 @@ void Playtree::onAppend( playlist_add_t *p_add )
tree_update descr; tree_update descr;
descr.i_id = p_add->i_item; descr.i_id = p_add->i_item;
descr.i_parent = p_add->i_node; descr.i_parent = p_add->i_node;
descr.b_visible = node->m_expanded; descr.b_visible = node->isExpanded();
descr.i_type = 2; descr.i_type = 2;
notify( &descr ); notify( &descr );
} }
...@@ -269,7 +269,7 @@ void Playtree::buildTree() ...@@ -269,7 +269,7 @@ void Playtree::buildTree()
/* Set the root's name */ /* Set the root's name */
UString *pName = new UString( getIntf(), UString *pName = new UString( getIntf(),
m_pPlaylist->p_root_category->p_input->psz_name ); m_pPlaylist->p_root_category->p_input->psz_name );
m_cString = UStringPtr( pName ); setString( UStringPtr( pName ) );
buildNode( m_pPlaylist->p_root_category, *this ); buildNode( m_pPlaylist->p_root_category, *this );
......
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