1 // =========================================================================
2 // @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co)
3 // =========================================================================
5 #include "PluginsNavigator.h"
6 #include <boost/tokenizer.hpp>
8 // -------------------------------------------------------------------------
10 PluginsNavigator( QWidget* parent )
11 : Superclass( parent )
13 this->m_PlgMgr.Configure( );
15 this->setDragEnabled( true );
16 this->setDragDropMode( QAbstractItemView::DragOnly );
17 this->setAlternatingRowColors( true );
21 // -------------------------------------------------------------------------
27 // -------------------------------------------------------------------------
28 void PluginsNavigator::
35 // -------------------------------------------------------------------------
36 void PluginsNavigator::
40 this->setColumnCount( 1 );
41 QString header_txt = "Plugins";
42 if( QTreeWidgetItem* header = this->headerItem( ) )
43 header->setText( 0, header_txt );
45 this->setHeaderLabel( header_txt );
48 // -------------------------------------------------------------------------
49 void PluginsNavigator::
52 typedef boost::char_separator< char > _TSep;
53 typedef boost::tokenizer< _TSep > _TTok;
54 typedef cpPlugins::Interface::Manager::TPlugins _TPlugins;
55 typedef _TPlugins::value_type _TPlg;
57 for( const _TPlg& plg: this->m_PlgMgr.GetPlugins( ) )
60 _TTok tokens{ plg.first, sep };
61 QTreeWidgetItem* cat = NULL;
62 for( const std::string& t: tokens )
64 QList< QTreeWidgetItem* > cat_items;
69 cat->findItems( t.c_str( ), Qt::MatchExactly | Qt::MatchRecursive );
73 this->findItems( t.c_str( ), Qt::MatchExactly | Qt::MatchRecursive );
74 if( cat_items.size( ) == 0 )
76 bool prev = ( cat == NULL );
77 cat = new QTreeWidgetItem( cat, QStringList( t.c_str( ) ) );
79 this->addTopLevelItem( cat );