/*************************************************************************** * * * begin : 15 Jan 2004 * * copyright : (C) 2003 by Samokhvalov Anton :) * * * ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include #include #include #include #include "TopicLeaf.h" #include "TopicTree.h" #include "Index.h" TopicLeaf::TopicLeaf( TopicLeaf* parent, const chm::chm_topics_tree* tree, Index* index ): KListViewItem( parent ), path( tree->path ), title( tree->title ) { index->add( tree->path, this ); for ( std::list< chm::chm_topics_tree* >::const_reverse_iterator i = tree->children.rbegin(); i != tree->children.rend(); ++i ) { if ( *i ) { new TopicLeaf( this, *i, index ); } } if ( tree->children.empty() ) { setPixmap( 0, SmallIcon( "doc", 22) ); } else { setPixmap( 0, SmallIcon( "folder", 22) ); } } TopicLeaf::TopicLeaf( TopicTree* parent, const chm::chm_topics_tree* tree, Index* index ): KListViewItem( parent ), path( tree->path ), title( tree->title ) { // setText( 0, getCodec()->toUnicode( tree->title.c_str() ) ); index->add( tree->path, this ); for ( std::list< chm::chm_topics_tree* >::const_reverse_iterator i = tree->children.rbegin(); i != tree->children.rend(); ++i ) { if ( *i ) { new TopicLeaf( this, *i, index ); } } if ( tree->children.empty() ) { setPixmap( 0, SmallIcon( "doc", 22) ); } else { setPixmap( 0, SmallIcon( "folder", 22) ); } } QTextCodec* TopicLeaf::getCodec() { return ((TopicTree*)listView())->getCodec(); } void TopicLeaf::updateCodec() { setText( 0, getCodec()->toUnicode( title.c_str() ) ); }