void WHtreeProcesser::collapseNode( const size_t thisNodeID, const dist_t coefficient, HTPROC_COLLAPSE collapseMode ) { if( thisNodeID > m_tree.getRoot().getID() ) { throw std::runtime_error( "ERROR @ collapseNode::flattenBranch(): nodeID is out of boundaries" ); } const WHnode& thisNode( m_tree.getNode( thisNodeID ) ); dist_t upperLevel( thisNode.getDistLevel() ); std::list< nodeID_t > worklist; worklist.push_back( thisNode.getFullID() ); while( !worklist.empty() ) { WHnode* currentNode( m_tree.fetchNode( worklist.front() ) ); worklist.pop_front(); std::vector< nodeID_t > currentKids( currentNode->getChildren() ); dist_t parentLevel( currentNode->getDistLevel() ); for( std::vector< nodeID_t >::iterator kidIter( currentKids.begin() ); kidIter != currentKids.end(); ++kidIter ) { if( m_tree.getNode( *kidIter ).isNode() ) { dist_t kidLevel( m_tree.getNode( *kidIter ).getDistLevel() ); bool doCollapse( false ); switch( collapseMode ) { case HTPR_C_CONSTANT: doCollapse = ( ( parentLevel - kidLevel ) < coefficient ); break; case HTPR_C_LINEAR: doCollapse = ( ( parentLevel - kidLevel ) < ( kidLevel * coefficient ) ); break; case HTPR_C_SQ: doCollapse = ( ( parentLevel - kidLevel ) < ( kidLevel * kidLevel * coefficient ) ); break; default: break; } if( doCollapse ) { worklist.push_back( *kidIter ); } } } currentNode->setDistLevel( upperLevel ); } return; } // end collapseNodeLinear() -------------------------------------------------------------------------------------
void CFileBrowserEngine::GetCurrentItemsL(CDesCArray* aItems) { __LOGSTR_TOFILE("CFileBrowserEngine::GetCurrentItemsL() begins"); aItems->Reset(); // If the current directory is not the first one, // add '...' entry as the first element of the listbox if (iCurrentDirectory.Length() > 0) { TFileName upperLevel(KNullDesC); upperLevel.Format(KStringUp, 2); aItems->AppendL(upperLevel); } // Retrieve folders names TFileName folderName(KNullDesC); if (iCurrentDirectory.Length() == 0) { // Get CCoeEnv instance CEikonEnv* eikonEnv = CEikonEnv::Static(); HBufC* stringHolder1 = StringLoader::LoadL(R_FILEBROWSER_PHONEMEMORY, eikonEnv ); HBufC* stringHolder2 = StringLoader::LoadL(R_FILEBROWSER_CARDMEMORY, eikonEnv ); for (TInt i = 0; i < iCurrentFolders.Count(); i++) { // As icon we use folder icon (index 0) if ( i == 0) { TFileName fileName = iCurrentFolders[i].iName; fileName.Append(*stringHolder1); folderName.Format(KStringIcon, 3, &fileName); } else { TFileName fileName = iCurrentFolders[i].iName; fileName.Append(*stringHolder2); folderName.Format(KStringIcon, 4, &fileName); } aItems->AppendL(folderName); } delete stringHolder2; stringHolder2 = NULL; delete stringHolder1; stringHolder1 = NULL; } else { for (TInt i = 0; i < iCurrentFolders.Count(); i++) { // As icon we use folder icon (index 0) folderName.Format(KStringIcon, 0, &iCurrentFolders[i].iName); aItems->AppendL(folderName); } } // Retrieve files names TFileName fileName(KNullDesC); for (TInt i = 0; i < iCurrentFiles.Count(); i++) { // As folder we use file icon (index 1) fileName.Format(KStringIcon, 1, &iCurrentFiles[i].iName); aItems->AppendL(fileName); } __LOGSTR_TOFILE("CFileBrowserEngine::GetCurrentItemsL() ends"); }