SpikeStream Application Library
0.2
|
00001 //SpikeStream includes 00002 #include "Globals.h" 00003 #include "PluginManager.h" 00004 #include "PluginsDialog.h" 00005 using namespace spikestream; 00006 00007 //Qt includes 00008 #include <QComboBox> 00009 #include <QLayout> 00010 #include <QStackedWidget> 00011 00012 00014 PluginsDialog::PluginsDialog(QWidget* parent, const QString pluginFolder, const QString title) : QDialog(parent){ 00015 //Set caption 00016 this->setWindowTitle(title); 00017 00018 //Create vertical box to organize layout 00019 QVBoxLayout* mainVerticalBox = new QVBoxLayout(this); 00020 00021 //Get list of available plugins - some plugins may fail to load and throw an exception 00022 QString pluginPath = Globals::getSpikeStreamRoot() + pluginFolder; 00023 PluginManager* pluginManager = new PluginManager(pluginPath); 00024 try{ 00025 pluginManager->loadPlugins(); 00026 } 00027 catch(SpikeStreamException& ex){ 00028 qCritical()<<ex.getMessage(); 00029 } 00030 00031 //Load up plugins that worked. 00032 try{ 00033 QStringList pluginList = pluginManager->getPluginNames(); 00034 00035 //Add list to combo box 00036 QComboBox* pluginsCombo = new QComboBox(this); 00037 pluginsCombo->addItems(pluginList); 00038 00039 //Add combo to layout 00040 QHBoxLayout *comboBox = new QHBoxLayout(); 00041 comboBox->addWidget(new QLabel("Available plugins: ")); 00042 comboBox->addWidget(pluginsCombo); 00043 comboBox->addStretch(5); 00044 mainVerticalBox->addLayout(comboBox); 00045 00046 //Add the widgets to a stacked widget 00047 QStackedWidget* stackedWidget = new QStackedWidget(); 00048 for(QList<QString>::iterator iter = pluginList.begin(); iter != pluginList.end(); ++iter){ 00049 stackedWidget->addWidget(pluginManager->getPlugin(*iter)); 00050 } 00051 00052 //Add stacked widget to layout 00053 mainVerticalBox->addWidget(stackedWidget); 00054 00055 //Connect combo changed signal to slot loading appropriate analysis widget 00056 connect(pluginsCombo, SIGNAL(currentIndexChanged(int)), stackedWidget, SLOT(setCurrentIndex(int)) ); 00057 } 00058 catch(SpikeStreamException& ex){ 00059 qCritical()<<ex.getMessage(); 00060 } 00061 } 00062 00063 00065 PluginsDialog::~PluginsDialog(){ 00066 } 00067 00068 00069 00070