Commit 36f82683 authored by Erwan Tulou's avatar Erwan Tulou

skins2(playlist): cosmetics + avoid objects passed as value if not needed

parent 7647873a
...@@ -39,8 +39,7 @@ VarTree::VarTree( intf_thread_t *pIntf ) ...@@ -39,8 +39,7 @@ VarTree::VarTree( intf_thread_t *pIntf )
VarTree::VarTree( intf_thread_t *pIntf, VarTree *pParent, int id, VarTree::VarTree( intf_thread_t *pIntf, VarTree *pParent, int id,
const UStringPtr &rcString, bool selected, bool playing, const UStringPtr &rcString, bool selected, bool playing,
bool expanded, bool readonly, bool expanded, bool readonly, void *pData )
void *pData )
: Variable( pIntf ), m_id( id ), m_cString( rcString ), : Variable( pIntf ), m_id( id ), m_cString( rcString ),
m_selected( selected ), m_playing( playing ), m_expanded( expanded ), m_selected( selected ), m_playing( playing ), m_expanded( expanded ),
m_deleted( false ), m_pData( pData ), m_pParent( pParent ), m_deleted( false ), m_pData( pData ), m_pParent( pParent ),
...@@ -57,8 +56,7 @@ VarTree::~VarTree() ...@@ -57,8 +56,7 @@ VarTree::~VarTree()
} }
void VarTree::add( int id, const UStringPtr &rcString, bool selected, void VarTree::add( int id, const UStringPtr &rcString, bool selected,
bool playing, bool expanded, bool readonly, bool playing, bool expanded, bool readonly, void *pData )
void *pData )
{ {
m_children.push_back( VarTree( getIntf(), this, id, rcString, selected, m_children.push_back( VarTree( getIntf(), this, id, rcString, selected,
playing, expanded, readonly, playing, expanded, readonly,
...@@ -268,7 +266,7 @@ VarTree::Iterator VarTree::getNextVisibleItem( Iterator it ) ...@@ -268,7 +266,7 @@ VarTree::Iterator VarTree::getNextVisibleItem( Iterator it )
} }
else else
{ {
VarTree::Iterator it_old = it; Iterator it_old = it;
++it; ++it;
// Was 'it' the last brother? If so, look for uncles // Was 'it' the last brother? If so, look for uncles
if( it_old->parent() && it_old->parent()->end() == it ) if( it_old->parent() && it_old->parent()->end() == it )
...@@ -281,7 +279,7 @@ VarTree::Iterator VarTree::getNextVisibleItem( Iterator it ) ...@@ -281,7 +279,7 @@ VarTree::Iterator VarTree::getNextVisibleItem( Iterator it )
VarTree::Iterator VarTree::getPrevVisibleItem( Iterator it ) VarTree::Iterator VarTree::getPrevVisibleItem( Iterator it )
{ {
VarTree::Iterator it_old = it; Iterator it_old = it;
if( it == root()->begin() || it == ++(root()->begin()) ) return it; if( it == root()->begin() || it == ++(root()->begin()) ) return it;
/* Was it the first child of its parent ? */ /* Was it the first child of its parent ? */
...@@ -310,7 +308,7 @@ VarTree::Iterator VarTree::getNextItem( Iterator it ) ...@@ -310,7 +308,7 @@ VarTree::Iterator VarTree::getNextItem( Iterator it )
} }
else else
{ {
VarTree::Iterator it_old = it; Iterator it_old = it;
++it; ++it;
// Was 'it' the last brother? If so, look for uncles // Was 'it' the last brother? If so, look for uncles
if( it_old->parent() && it_old->parent()->end() == it ) if( it_old->parent() && it_old->parent()->end() == it )
...@@ -323,7 +321,7 @@ VarTree::Iterator VarTree::getNextItem( Iterator it ) ...@@ -323,7 +321,7 @@ VarTree::Iterator VarTree::getNextItem( Iterator it )
VarTree::Iterator VarTree::getPrevItem( Iterator it ) VarTree::Iterator VarTree::getPrevItem( Iterator it )
{ {
VarTree::Iterator it_old = it; Iterator it_old = it;
if( it == root()->begin() || it == ++(root()->begin()) ) return it; if( it == root()->begin() || it == ++(root()->begin()) ) return it;
/* Was it the first child of its parent ? */ /* Was it the first child of its parent ? */
...@@ -380,7 +378,7 @@ VarTree::Iterator VarTree::findById( int id ) ...@@ -380,7 +378,7 @@ VarTree::Iterator VarTree::findById( int id )
} }
void VarTree::ensureExpanded( VarTree::Iterator it ) void VarTree::ensureExpanded( const Iterator& it )
{ {
/// Don't expand ourselves, only our parents /// Don't expand ourselves, only our parents
VarTree *current = &(*it); VarTree *current = &(*it);
...@@ -422,7 +420,7 @@ void VarTree::cascadeDelete() ...@@ -422,7 +420,7 @@ void VarTree::cascadeDelete()
} }
} }
int VarTree::getRank( Iterator item, bool flat ) int VarTree::getRank( const Iterator& item, bool flat )
{ {
int index = 1; int index = 1;
Iterator it; Iterator it;
......
...@@ -57,7 +57,7 @@ public: ...@@ -57,7 +57,7 @@ public:
VarTree( intf_thread_t *pIntf, VarTree *pParent, int id, VarTree( intf_thread_t *pIntf, VarTree *pParent, int id,
const UStringPtr &rcString, bool selected, bool playing, const UStringPtr &rcString, bool selected, bool playing,
bool expanded,bool readonly, void *pData ); bool expanded, bool readonly, void *pData );
virtual ~VarTree(); virtual ~VarTree();
...@@ -66,8 +66,7 @@ public: ...@@ -66,8 +66,7 @@ public:
/// Add a pointer on string in the children's list /// Add a pointer on string in the children's list
virtual void add( int id, const UStringPtr &rcString, bool selected, virtual void add( int id, const UStringPtr &rcString, bool selected,
bool playing, bool expanded, bool readonly, bool playing, bool expanded, bool readonly, void *pData );
void *pData );
/// Remove the selected item from the children's list /// Remove the selected item from the children's list
virtual void delSelected(); virtual void delSelected();
...@@ -128,10 +127,8 @@ public: ...@@ -128,10 +127,8 @@ public:
/// Get first leaf /// Get first leaf
Iterator firstLeaf(); Iterator firstLeaf();
void removeChild( VarTree::Iterator item ) /// Remove a child
{ void removeChild( Iterator it ) { m_children.erase( it ); }
m_children.erase( item );
}
/// Execute the action associated to this item /// Execute the action associated to this item
virtual void action( VarTree *pItem ) { } virtual void action( VarTree *pItem ) { }
...@@ -175,13 +172,13 @@ public: ...@@ -175,13 +172,13 @@ public:
Iterator getPrevLeaf( Iterator it ); Iterator getPrevLeaf( Iterator it );
/// return rank of visible item starting from 1 /// return rank of visible item starting from 1
int getRank( Iterator it, bool flat ); int getRank( const Iterator& it, bool flat );
/// Find a children node with the given id /// Find a children node with the given id
Iterator findById( int id ); Iterator findById( int id );
/// Ensure an item is expanded /// Ensure an item is expanded
void ensureExpanded( VarTree::Iterator ); void ensureExpanded( const Iterator& it );
/// flag a whole subtree for deletion /// flag a whole subtree for deletion
void cascadeDelete(); void cascadeDelete();
......
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