// ========================================================================= // @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co) // ========================================================================= #include "PluginsNavigator.h" #include // ------------------------------------------------------------------------- PluginsNavigator:: PluginsNavigator( QWidget* parent ) : Superclass( parent ) { this->m_PlgMgr.Configure( ); this->setDragEnabled( true ); this->setDragDropMode( QAbstractItemView::DragOnly ); this->setAlternatingRowColors( true ); this->Update( ); } // ------------------------------------------------------------------------- PluginsNavigator:: ~PluginsNavigator( ) { } // ------------------------------------------------------------------------- void PluginsNavigator:: Update( ) { this->_Clear( ); this->_Update( ); } // ------------------------------------------------------------------------- void PluginsNavigator:: _Clear( ) { this->clear( ); this->setColumnCount( 1 ); QString header_txt = "Plugins"; if( QTreeWidgetItem* header = this->headerItem( ) ) header->setText( 0, header_txt ); else this->setHeaderLabel( header_txt ); } // ------------------------------------------------------------------------- void PluginsNavigator:: _Update( ) { typedef boost::char_separator< char > _TSep; typedef boost::tokenizer< _TSep > _TTok; typedef cpPlugins::Interface::Manager::TPlugins _TPlugins; typedef _TPlugins::value_type _TPlg; for( const _TPlg& plg: this->m_PlgMgr.GetPlugins( ) ) { _TSep sep{ ":" }; _TTok tokens{ plg.first, sep }; QTreeWidgetItem* cat = NULL; for( const std::string& t: tokens ) { QList< QTreeWidgetItem* > cat_items; /* TODO if( cat != NULL ) cat_items = cat->findItems( t.c_str( ), Qt::MatchExactly | Qt::MatchRecursive ); else */ cat_items = this->findItems( t.c_str( ), Qt::MatchExactly | Qt::MatchRecursive ); if( cat_items.size( ) == 0 ) { bool prev = ( cat == NULL ); cat = new QTreeWidgetItem( cat, QStringList( t.c_str( ) ) ); if( prev ) this->addTopLevelItem( cat ); } else cat = cat_items[ 0 ]; } // rof } // rof this->expandAll( ); } // eof - $RCSfile$