-_LoadPluginsFromPath( const std::string& path )
-{
- QDir dir( path.c_str( ) );
- std::stringstream filters_str;
- filters_str << "*." << cpPlugins_PLUGIN_EXT;
- QStringList filters;
- filters << filters_str.str( ).c_str( );
- auto files = dir.entryList( filters );
- for( auto fIt = files.begin( ); fIt != files.end( ); ++fIt )
- {
- try
- {
- this->m_Interface.LoadPluginFile(
- ( dir.absolutePath( ) + QDir::separator( ) + *fIt ).toStdString( )
- );
- }
- catch( std::exception& err )
- {
- // Just ignore un-loadable libraries
- } // yrt
-
- } // rof
- this->_UpdateLoadedPlugins( );
-}
-
-// -------------------------------------------------------------------------
-void PipelineEditor::
-_UpdateLoadedPlugins( )
-{
- this->_Block( );
- auto filters = this->m_Interface.GetFilters( );
- if( filters.size( ) == 0 )
- {
- QMessageBox::critical(
- this,
- "Error loading default plugins",
- "No plugins loaded: remember to load some!!!"
- );
- this->_UnBlock( );
- return;
-
- } // fi
-
- for( auto cIt = filters.begin( ); cIt != filters.end( ); ++cIt )
- {
- // Create or get category
- QList< QTreeWidgetItem* > cat_items =
- this->m_UI->LoadedPlugins->findItems(
- cIt->first.c_str( ), Qt::MatchExactly | Qt::MatchRecursive
- );
- QTreeWidgetItem* cat = NULL;
- if( cat_items.size( ) == 0 )
- {
- cat = new QTreeWidgetItem(
- ( QTreeWidgetItem* )( NULL ), QStringList( cIt->first.c_str( ) )
- );
- this->m_UI->LoadedPlugins->addTopLevelItem( cat );
- }
- else
- cat = cat_items[ 0 ];
-
- // Create filters
- auto fIt = cIt->second.begin( );
- for( ; fIt != cIt->second.end( ); ++fIt )
- {
- QList< QTreeWidgetItem* > filter_items =
- this->m_UI->LoadedPlugins->findItems(
- fIt->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->c_str( ) )
- );
-
- } // rof
-
- } // rof
- this->_UnBlock( );
- this->m_Interface.SaveConfiguration( cpPlugins_CONFIG_FILE );
-}
-
-// -------------------------------------------------------------------------
-void PipelineEditor::
-_Block( )
-{
- this->m_Application->setOverrideCursor( Qt::WaitCursor );
- this->m_Application->installEventFilter( &( this->m_Blocker ) );
-}
-
-// -------------------------------------------------------------------------
-void PipelineEditor::
-_UnBlock( )
-{
- while( this->m_Application->overrideCursor( ) )
- this->m_Application->restoreOverrideCursor( );
- this->m_Application->removeEventFilter( &( this->m_Blocker ) );
-}
-
-// -------------------------------------------------------------------------
-void PipelineEditor::
-_ButtonLoadPluginsFile( )
-{
- QFileDialog dlg( this );
- dlg.setFileMode( QFileDialog::ExistingFiles );
- dlg.setDirectory( "." );
-
- std::stringstream name_filter;
- std::string suffix = std::string( cpPlugins_PLUGIN_EXT );
- name_filter
- << "Plugins file (*." << cpPlugins_PLUGIN_EXT << ");;All files (*)";
- dlg.setNameFilter( name_filter.str( ).c_str( ) );
- dlg.setDefaultSuffix( suffix.c_str( ) );
-
- if( !( dlg.exec( ) ) )
- return;
-
- // Read
- QStringList names = dlg.selectedFiles( );
- std::stringstream err_str;
- for( auto qIt = names.begin( ); qIt != names.end( ); ++qIt )
- {
- try
- {
- this->m_Interface.LoadPluginFile( qIt->toStdString( ) );
- }
- catch( std::exception& err )
- {
- err_str << err.what( ) << std::endl;
-
- } // yrt
-
- } // rof
-
- // 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
- // TODO: this->m_Interface.SaveDefaultConfiguration( this->m_PluginsPath );
- this->_UpdateLoadedPlugins( );
-}
-
-// -------------------------------------------------------------------------
-void PipelineEditor::
-_ButtonLoadPluginsPath( )