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:
@@ -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 );
|
||||
|
||||
@@ -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() )
|
||||
|
||||
Reference in New Issue
Block a user