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 <tobias.doerffel@gmail.com>
This commit is contained in:
Tobias Doerffel
2009-06-23 01:00:33 +02:00
parent 75a45cca5f
commit 30543d708c
2 changed files with 14 additions and 0 deletions

View File

@@ -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 );

View File

@@ -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() )