+ delete this->m_Plugins;
+}
+
+// -------------------------------------------------------------------------
+void cpPipelineEditor::
+_UpdateLoadedPlugins( )
+{
+ auto& classes = this->m_Plugins->GetClasses( );
+
+ if( classes.size( ) == 0 )
+ {
+ QMessageBox::critical(
+ this,
+ "Error loading default plugins",
+ "No plugins loaded: remember to load some!!!"
+ );
+ return;
+
+ } // fi
+
+ auto catIt = classes.begin( );
+ for( ; catIt != classes.end( ); ++catIt )
+ {
+ // Create or get category
+ QList< QTreeWidgetItem* > cat_items =
+ this->m_UI->LoadedPlugins->findItems(
+ catIt->first.c_str( ), Qt::MatchExactly | Qt::MatchRecursive
+ );
+ QTreeWidgetItem* cat = NULL;
+ if( cat_items.size( ) == 0 )
+ {
+ cat = new QTreeWidgetItem(
+ ( QTreeWidgetItem* )( NULL ), QStringList( catIt->first.c_str( ) )
+ );
+ this->m_UI->LoadedPlugins->addTopLevelItem( cat );
+ }
+ else
+ cat = cat_items[ 0 ];
+
+ // Create filters
+ auto fIt = catIt->second.begin( );
+ for( ; fIt != catIt->second.end( ); ++fIt )
+ {
+ QList< QTreeWidgetItem* > filter_items =
+ this->m_UI->LoadedPlugins->findItems(
+ fIt->first.c_str( ), Qt::MatchExactly | Qt::MatchRecursive
+ );
+ auto fiIt = filter_items.begin( );
+ auto found_fiIt = filter_items.end( );
+ for( ; fiIt != filter_items.end( ); ++fiIt )
+ if( ( *fiIt )->parent( ) == cat )
+ found_fiIt = fiIt;
+
+ // Add filter
+ if( found_fiIt == filter_items.end( ) )
+ QTreeWidgetItem* filter = new QTreeWidgetItem(
+ cat, QStringList( fIt->first.c_str( ) )
+ );
+ } // rof
+
+ } // rof
+}
+
+// -------------------------------------------------------------------------
+void cpPipelineEditor::
+_ButtonLoadPluginsFile( )
+{
+ QFileDialog dlg( this );
+ dlg.setFileMode( QFileDialog::ExistingFiles );
+ dlg.setDirectory( "." );
+#ifdef _WIN32
+ dlg.setNameFilter( "Plugins file (*.dll);;All files (*)" );
+ dlg.setDefaultSuffix( "dll" );
+#else // _WIN32
+ dlg.setNameFilter( "Plugins file (*.so);;All files (*)" );
+ dlg.setDefaultSuffix( "so" );
+#endif // _WIN32
+ if( !( dlg.exec( ) ) )
+ return;
+
+ // Read
+ QStringList names = dlg.selectedFiles( );
+ std::stringstream err_str;
+ for( auto qIt = names.begin( ); qIt != names.end( ); ++qIt )
+ if( !( this->m_Plugins->Load( qIt->toStdString( ) ) ) )
+ err_str << qIt->toStdString( ) << std::endl;
+
+ // Show an error message
+ std::string err = err_str.str( );
+ if( err.size( ) > 0 )
+ QMessageBox::critical(
+ this,
+ "Error loading plugins",
+ err.c_str( )
+ );
+
+ // Update view
+ this->_UpdateLoadedPlugins( );
+}
+
+// -------------------------------------------------------------------------
+void cpPipelineEditor::
+_ButtonLoadPluginsPath( )
+{
+ QFileDialog dlg( this );
+ dlg.setFileMode( QFileDialog::DirectoryOnly );
+ dlg.setDirectory( "." );
+ if( !( dlg.exec( ) ) )
+ return;
+
+ // Read
+ std::string dir = dlg.selectedFiles( ).begin( )->toStdString( );
+ if( !( this->m_Plugins->LoadFromFolder( dir, false ) ) )
+ QMessageBox::critical(
+ this,
+ "Error loading plugins directory",
+ dir.c_str( )
+ );
+
+ // Update view
+ this->_UpdateLoadedPlugins( );