X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=appli%2FPipelineEditor%2FPluginsNavigator.cxx;fp=appli%2FPipelineEditor%2FPluginsNavigator.cxx;h=305d74674cfd5b08dc713a742235c34c106e1887;hb=2e142df11d6f312a2a2b5097b8da73571ed523e8;hp=0000000000000000000000000000000000000000;hpb=61b3659afe961ed248f30e26f9ca8f28fcfafddc;p=cpPlugins.git diff --git a/appli/PipelineEditor/PluginsNavigator.cxx b/appli/PipelineEditor/PluginsNavigator.cxx new file mode 100644 index 0000000..305d746 --- /dev/null +++ b/appli/PipelineEditor/PluginsNavigator.cxx @@ -0,0 +1,88 @@ +// ========================================================================= +// @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$