[vlc-commits] commit: Qt4: constify currentIndex() and find* helpers, remove CACHE in findInner (Ilkka Ollakka )
git at videolan.org
git at videolan.org
Thu Jun 24 23:18:28 CEST 2010
vlc | branch: master | Ilkka Ollakka <ileoo at videolan.org> | Thu Jun 24 18:13:17 2010 +0300| [568e55553dfb2a2bb01395614d45fcb422b9a302] | committer: Ilkka Ollakka
Qt4: constify currentIndex() and find* helpers, remove CACHE in findInner
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=568e55553dfb2a2bb01395614d45fcb422b9a302
---
.../gui/qt4/components/playlist/playlist_model.cpp | 43 ++++---------------
.../gui/qt4/components/playlist/playlist_model.hpp | 8 ++--
2 files changed, 13 insertions(+), 38 deletions(-)
diff --git a/modules/gui/qt4/components/playlist/playlist_model.cpp b/modules/gui/qt4/components/playlist/playlist_model.cpp
index 3868867..55c308c 100644
--- a/modules/gui/qt4/components/playlist/playlist_model.cpp
+++ b/modules/gui/qt4/components/playlist/playlist_model.cpp
@@ -517,71 +517,46 @@ QStringList PLModel::selectedURIs()
/************************* Lookups *****************************/
-PLItem *PLModel::findById( PLItem *root, int i_id )
+PLItem *PLModel::findById( PLItem *root, int i_id ) const
{
return findInner( root, i_id, false );
}
-PLItem *PLModel::findByInput( PLItem *root, int i_id )
+PLItem *PLModel::findByInput( PLItem *root, int i_id ) const
{
PLItem *result = findInner( root, i_id, true );
return result;
}
-#define CACHE( i, p ) { i_cached_id = i; p_cached_item = p; }
-#define ICACHE( i, p ) { i_cached_input_id = i; p_cached_item_bi = p; }
-
-PLItem * PLModel::findInner( PLItem *root, int i_id, bool b_input )
+PLItem * PLModel::findInner( PLItem *root, int i_id, bool b_input ) const
{
if( !root ) return NULL;
- if( ( !b_input && i_cached_id == i_id) ||
- ( b_input && i_cached_input_id ==i_id ) )
- {
- return b_input ? p_cached_item_bi : p_cached_item;
- }
if( !b_input && root->i_id == i_id )
- {
- CACHE( i_id, root );
return root;
- }
+
else if( b_input && root->p_input->i_id == i_id )
- {
- ICACHE( i_id, root );
return root;
- }
QList<PLItem *>::iterator it = root->children.begin();
while ( it != root->children.end() )
{
if( !b_input && (*it)->i_id == i_id )
- {
- CACHE( i_id, (*it) );
- return p_cached_item;
- }
+ return (*it);
+
else if( b_input && (*it)->p_input->i_id == i_id )
- {
- ICACHE( i_id, (*it) );
- return p_cached_item_bi;
- }
+ return (*it);
+
if( (*it)->children.size() )
{
PLItem *childFound = findInner( (*it), i_id, b_input );
if( childFound )
- {
- if( b_input )
- ICACHE( i_id, childFound )
- else
- CACHE( i_id, childFound )
- return childFound;
- }
+ return childFound;
}
it++;
}
return NULL;
}
-#undef CACHE
-#undef ICACHE
int PLModel::columnToMeta( int _column )
{
diff --git a/modules/gui/qt4/components/playlist/playlist_model.hpp b/modules/gui/qt4/components/playlist/playlist_model.hpp
index f6343df..ca18f0f 100644
--- a/modules/gui/qt4/components/playlist/playlist_model.hpp
+++ b/modules/gui/qt4/components/playlist/playlist_model.hpp
@@ -92,7 +92,7 @@ public:
QStringList selectedURIs();
QModelIndex index( PLItem *, int c ) const;
QModelIndex index( int i_id, int c );
- QModelIndex currentIndex();
+ QModelIndex currentIndex() const;
bool isParent( const QModelIndex &index, const QModelIndex ¤t) const;
bool isCurrent( const QModelIndex &index ) const;
int itemId( const QModelIndex &index ) const;
@@ -154,9 +154,9 @@ private:
QSignalMapper *sortingMapper;
/* Lookups */
- PLItem *findById( PLItem *, int );
- PLItem *findByInput( PLItem *, int );
- PLItem *findInner( PLItem *, int , bool );
+ PLItem *findById( PLItem *, int ) const;
+ PLItem *findByInput( PLItem *, int ) const;
+ PLItem *findInner(PLItem *, int , bool ) const;
bool canEdit() const;
PLItem *p_cached_item;
More information about the vlc-commits
mailing list