From 30543d708c946320dd6a583c464217681929fe28 Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Tue, 23 Jun 2009 01:00:33 +0200 Subject: [PATCH] ResourceDB: added itemByHash() method Added itemByHash() method to ResourceDB class allowing safe access to an item identified with an according hash. If there's no item associated with the hash, NULL is being returned. Signed-off-by: Tobias Doerffel --- include/ResourceDB.h | 1 + src/core/ResourceDB.cpp | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/include/ResourceDB.h b/include/ResourceDB.h index 402b02835..09ede443f 100644 --- a/include/ResourceDB.h +++ b/include/ResourceDB.h @@ -69,6 +69,7 @@ public: return &m_topLevelNode; } + const ResourceItem * itemByHash( const QString & _hash ) const; const ResourceItem * nearestMatch( const ResourceItem & _item ); void addItem( ResourceItem * newItem ); diff --git a/src/core/ResourceDB.cpp b/src/core/ResourceDB.cpp index 0495d1197..7fb14f960 100644 --- a/src/core/ResourceDB.cpp +++ b/src/core/ResourceDB.cpp @@ -188,6 +188,19 @@ loadTreeItem( treeItem, e ); +const ResourceItem * ResourceDB::itemByHash( const QString & _hash ) const +{ + ItemList::ConstIterator it = m_items.find( _hash ); + if( it != m_items.end() ) + { + return it.value(); + } + return NULL; +} + + + + const ResourceItem * ResourceDB::nearestMatch( const ResourceItem & _item ) { if( !_item.hash().isEmpty() )