void CollectionsPanel::ConnectCollectionListeners() { for ( M_AssetCollections::const_iterator itr = m_CollectionManager->GetCollections().begin(), end = m_CollectionManager->GetCollections().end(); itr != end; ++itr ) { AssetCollection* collection = itr->second; collection->AddChangedListener( Reflect::ElementChangeSignature::Delegate( this, &CollectionsPanel::OnCollectionModified ) ); } }
void CollectionsPanel::OnAssetCollectionsChanged( const Reflect::ElementChangeArgs& args ) { HELIUM_ASSERT( m_CollectionManager == args.m_Element ); for ( M_AssetCollections::const_iterator collectionItr = m_CollectionManager->GetCollections().begin(), collectionEnd = m_CollectionManager->GetCollections().end(); collectionItr != collectionEnd; ++collectionItr ) { AssetCollection* collection = collectionItr->second; collection->AddChangedListener( Reflect::ElementChangeSignature::Delegate( this, &CollectionsPanel::OnCollectionModified ) ); } UpdateCollections(); }
void SearchHistory::PushHistory( const SearchQuery* query ) { // we should always have a query here HELIUM_ASSERT( query ); if ( m_Active || !query ) { return; } if ( m_Current && (*m_Current) == (*query) ) { return; } //if ( m_BatchState > 0 ) //{ // m_Batch->Push( query ); // return; //} // we have a new query, so delete all subsequent queries from our current position m_Forward.clear(); // if we have a finite length and we are full, remove the oldest query while ( m_MaxHistory > 0 && GetLength() >= m_MaxHistory ) { m_Back.erase( m_Back.begin() ); } // if we have a current, move that to the Back list if ( m_Current ) { // append our query to the queue m_Back.push_back( m_Current ); AssetCollection* oldCollection = m_Current->GetCollection(); if ( oldCollection ) { oldCollection->RemoveChangedListener( Reflect::ElementChangeSignature::Delegate( this, &SearchHistory::OnCollectionChanged ) ); } } m_Current = query; AssetCollection* collection = m_Current->GetCollection(); if ( collection ) { collection->AddChangedListener( Reflect::ElementChangeSignature::Delegate( this, &SearchHistory::OnCollectionChanged ) ); } // fire an event to interested listeners m_Changed.Raise( SearchHistoryChangeArgs( this, query ) ); }
void SearchHistory::Forward( int historyIndex ) { m_Active = true; int index = historyIndex < 0 ? (int)m_Forward.size() - 1 : historyIndex; // if the forward stack is not empty if ( (int)m_Forward.size() > index ) { // get the query at the next position SearchQueryPtr query = NULL; while ( m_Forward.size() && (int)m_Forward.size() > index ) { query = m_Forward.back(); m_Forward.pop_back(); //if there's something in Current, move it to the back list if ( m_Current ) { m_Back.push_back( m_Current ); AssetCollection* oldCollection = m_Current->GetCollection(); if ( oldCollection ) { oldCollection->RemoveChangedListener( Reflect::ElementChangeSignature::Delegate( this, &SearchHistory::OnCollectionChanged ) ); } } m_Current = query; AssetCollection* collection = m_Current->GetCollection(); if ( collection ) { collection->AddChangedListener( Reflect::ElementChangeSignature::Delegate( this, &SearchHistory::OnCollectionChanged ) ); } } if ( query ) { PushMRU( query ); if ( m_VaultSearch ) { m_VaultSearch->RequestSearch( query ); } m_GoForward.Raise( SearchHistoryChangeArgs( this, query.Ptr() ) ); } } m_Active = false; }