diff --git a/.hgsubstate b/.hgsubstate --- a/.hgsubstate +++ b/.hgsubstate @@ -1,1 +1,1 @@ -b05d3dada0406dd7c1700d5d53719a901d214281 src/SocExplorerEngine/PeripheralWidget +e3a98a04d9ec8685bf222f8d687a614a71927549 src/SocExplorerEngine/PeripheralWidget diff --git a/src/SocExplorerEngine/engine/socexplorerengine.cpp b/src/SocExplorerEngine/engine/socexplorerengine.cpp --- a/src/SocExplorerEngine/engine/socexplorerengine.cpp +++ b/src/SocExplorerEngine/engine/socexplorerengine.cpp @@ -217,7 +217,7 @@ void SocExplorerEngine::message(socexplo if(!_self) init(); if(loglvl>=debugLevel) - qDebug()<< QTime::currentTime().toString()+" " + sender->instanceName+":"+message; + qDebug()<< QTime::currentTime().toString()+" " + sender->instanceName()+":"+message; } diff --git a/src/SocExplorerEngine/pluginManagerWdgt/pluginmanagerWDGT.cpp b/src/SocExplorerEngine/pluginManagerWdgt/pluginmanagerWDGT.cpp --- a/src/SocExplorerEngine/pluginManagerWdgt/pluginmanagerWDGT.cpp +++ b/src/SocExplorerEngine/pluginManagerWdgt/pluginmanagerWDGT.cpp @@ -75,6 +75,7 @@ pluginmanagerWDGT::pluginmanagerWDGT(QWi connect(this->treeview,SIGNAL(loadSysDriverToParent(QString,QString)),this,SIGNAL(loadSysDriverToParent(QString,QString))); connect(this->treeview,SIGNAL(changeSysDriverInstName(QString,QString)),this,SIGNAL(changeSysDriverInstName(QString,QString))); connect(this->treeview,SIGNAL(closeSysDriver(QString)),this,SIGNAL(closeSysDriver(QString))); + connect(this->treeview,SIGNAL(pluginselected(QString)),this,SIGNAL(pluginselected(QString))); this->rootLoadable = false; this->childLoadable = false; this->pluginTable->refreshPluginList(); diff --git a/src/SocExplorerEngine/pluginManagerWdgt/pluginmanagerWDGT.h b/src/SocExplorerEngine/pluginManagerWdgt/pluginmanagerWDGT.h --- a/src/SocExplorerEngine/pluginManagerWdgt/pluginmanagerWDGT.h +++ b/src/SocExplorerEngine/pluginManagerWdgt/pluginmanagerWDGT.h @@ -63,6 +63,8 @@ signals: void treeChanged(const QList& drivers); void changeSysDriverInstName(const QString newinstanceName,const QString previnstanceName); void closeSysDriver(const QString instanceName); + void pluginselected(const QString& instanceName); + public slots: //void libselected(int row); void addPlugin(); diff --git a/src/SocExplorerEngine/pluginManagerWdgt/plugintree.cpp b/src/SocExplorerEngine/pluginManagerWdgt/plugintree.cpp --- a/src/SocExplorerEngine/pluginManagerWdgt/plugintree.cpp +++ b/src/SocExplorerEngine/pluginManagerWdgt/plugintree.cpp @@ -13,6 +13,7 @@ plugintree::plugintree(QWidget *parent) this->setAcceptDrops(true); this->setDragDropMode(QAbstractItemView::DropOnly); connect(this,SIGNAL(itemChanged(QTreeWidgetItem*,int)),this,SLOT(pluginselectedslt(QTreeWidgetItem*,int))); + connect(this,SIGNAL(itemSelectionChanged()),this,SLOT(itemSelectionChangedslt())); this->setHeaderLabels(QStringList()<<"Loaded plugins"); emit this->geteplugintree(); } @@ -24,6 +25,14 @@ void plugintree::pluginselectedslt(QTree emit this->pluginselected(item->text(0)); } +void plugintree::itemSelectionChangedslt() +{ + if(this->selectedItems().count()==1) + { + emit this->pluginselected(this->selectedItems().first()->text(0)); + } +} + void plugintree::treeChanged(const QList& drivers) { this->clear(); @@ -31,7 +40,7 @@ void plugintree::treeChanged(const QList { QTreeWidgetItem* currentItem=new QTreeWidgetItem; currentItem->setIcon(0,QSvgIcon(":/images/server.svg")); - currentItem->setText(0,drivers.at(i)->instanceName); + currentItem->setText(0,drivers.at(i)->instanceName()); this->addTopLevelItem(currentItem); if(drivers.at(i)->childs.count()!=0) { @@ -48,7 +57,7 @@ void plugintree::addplugin(socexplorerpl { QTreeWidgetItem* currentItem=new QTreeWidgetItem; currentItem->setIcon(0,QSvgIcon(":/images/server.svg")); - currentItem->setText(0,driver->childs.at(i)->instanceName); + currentItem->setText(0,driver->childs.at(i)->instanceName()); item->addChild(currentItem); if(driver->childs.at(i)->childs.count()!=0) { diff --git a/src/SocExplorerEngine/pluginManagerWdgt/plugintree.h b/src/SocExplorerEngine/pluginManagerWdgt/plugintree.h --- a/src/SocExplorerEngine/pluginManagerWdgt/plugintree.h +++ b/src/SocExplorerEngine/pluginManagerWdgt/plugintree.h @@ -61,7 +61,7 @@ signals: public slots: void treeChanged(const QList& drivers); void pluginselectedslt( QTreeWidgetItem * item, int column); - + void itemSelectionChangedslt(); private: void addplugin(socexplorerplugin* driver,QTreeWidgetItem* item); diff --git a/src/SocExplorerEngine/plugins/genericPySysdriver.cpp b/src/SocExplorerEngine/plugins/genericPySysdriver.cpp --- a/src/SocExplorerEngine/plugins/genericPySysdriver.cpp +++ b/src/SocExplorerEngine/plugins/genericPySysdriver.cpp @@ -98,6 +98,6 @@ bool genericPySysdriver::loadbin(unsigne QString genericPySysdriver::instance() { - return plugin->instanceName; + return plugin->instanceName(); } diff --git a/src/SocExplorerEngine/plugins/socexplorerplugin.cpp b/src/SocExplorerEngine/plugins/socexplorerplugin.cpp --- a/src/SocExplorerEngine/plugins/socexplorerplugin.cpp +++ b/src/SocExplorerEngine/plugins/socexplorerplugin.cpp @@ -31,9 +31,14 @@ int socexplorerplugin::baseAddress(){ret void socexplorerplugin::setBaseAddress(unsigned int baseAddress){this->BaseAddress = baseAddress;} +QString socexplorerplugin::instanceName() +{ + return this->_instanceName; +} + int socexplorerplugin::registermenu(QMenu *menu) { - this->menu = menu->addMenu(this->instanceName); + this->menu = menu->addMenu(this->_instanceName); this->closeAction = this->menu->addAction(tr("Close plugin")); QObject::connect(this->closeAction,SIGNAL(triggered()),this,SLOT(closeMe())); this->ChildsMenu = this->menu->addMenu(QString("Childs")); @@ -41,7 +46,7 @@ int socexplorerplugin::registermenu(QMen { this->childs.at(i)->registermenu(this->ChildsMenu); } - if(this->pyObject!=NULL)emit this->registerObject((QObject*)this->pyObject,this->instanceName); + if(this->pyObject!=NULL)emit this->registerObject((QObject*)this->pyObject,this->instanceName()); return 0; } @@ -74,8 +79,10 @@ void socexplorerplugin::activate(bool fl void socexplorerplugin::setInstanceName(const QString &newName) { - this->instanceName = newName; - this->menu->setTitle(this->instanceName); + this->_instanceName = newName; + if(this->menu) + this->menu->setTitle(this->_instanceName); + this->setWindowTitle(newName); } void socexplorerplugin::makeGenericPyWrapper() diff --git a/src/SocExplorerEngine/plugins/socexplorerplugin.h b/src/SocExplorerEngine/plugins/socexplorerplugin.h --- a/src/SocExplorerEngine/plugins/socexplorerplugin.h +++ b/src/SocExplorerEngine/plugins/socexplorerplugin.h @@ -86,8 +86,11 @@ public: //! Default plugin constructor, any plugin should call this constructor. This constructor creates a //! default python wrapper instance. If you want to connect your own python wrapper, you have to clear //! createPyObject option and instanciate your own genericPySysdriver derivated object. - socexplorerplugin(QWidget *parent = 0,bool createPyObject=true) + socexplorerplugin(QWidget *parent = 0,bool createPyObject=true):QDockWidget(parent) { + closeAction=NULL; + menu=NULL; + ChildsMenu=NULL; this->Connected = false; this->setFeatures(QDockWidget::DockWidgetMovable|QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetVerticalTitleBar); _Name = new QString(driver_Name); @@ -126,7 +129,7 @@ public: QList childs; socexplorerplugin* parent; QAction* closeAction; - QString instanceName; + QString instanceName(); QMenu* menu; QMenu* ChildsMenu; @@ -167,6 +170,7 @@ protected: QString* _Author; QString* _Version; QString* _Description; + QString _instanceName; int _canBeChild; int _canBeRoot; int _VID; diff --git a/src/SocExplorerEngine/proxy/socexplorerproxy.cpp b/src/SocExplorerEngine/proxy/socexplorerproxy.cpp --- a/src/SocExplorerEngine/proxy/socexplorerproxy.cpp +++ b/src/SocExplorerEngine/proxy/socexplorerproxy.cpp @@ -95,7 +95,7 @@ void socexplorerproxy::loadSysDriver(con void socexplorerproxy::loadSysDriver(socexplorerplugin *driver, const QString instanceName) { if(!_self)init(); - driver->instanceName.append(instanceName); + driver->setInstanceName(instanceName); driver->parent = NULL; drivers->append(driver); linearDriverList->append(driver); @@ -158,7 +158,7 @@ void socexplorerproxy::loadSysDriverToPa if(!_self)init(); linearDriverList->append(driver); driver->parent = parent; - driver->instanceName.append(instanceName); + driver->setInstanceName(instanceName); parent->childs.append(driver); connectChildToProxy(driver); connectChildToParent(parent,driver); @@ -204,18 +204,14 @@ void socexplorerproxy::loadChild(socexpl void socexplorerproxy::connectChildToParent(socexplorerplugin *parent, socexplorerplugin *child) { if(!_self)init(); - //connect(child,SIGNAL(WriteSig(uint*,uint,uint)),parent,SLOT(Write(uint*,uint,uint))); - //connect(child,SIGNAL(ReadSig(uint*,uint,uint)),parent,SLOT(Read(uint*,uint,uint))); - connect(parent,SIGNAL(activateSig(bool)),child,SLOT(activate(bool)));//,Qt::DirectConnection); + connect(parent,SIGNAL(activateSig(bool)),child,SLOT(activate(bool))); child->activate(parent->isConnected()); } void socexplorerproxy::disconnectChildToParent(socexplorerplugin *child) { if(!_self)init(); - //disconnect(child,SIGNAL(WriteSig(uint*,uint,uint)),child->parent,SLOT(Write(uint*,uint,uint))); - // disconnect(child,SIGNAL(ReadSig(uint*,uint,uint)),child->parent,SLOT(Read(uint*,uint,uint))); - disconnect(child->parent,SIGNAL(activateSig(bool)),child,SLOT(activate(bool)));//,Qt::DirectConnection); + disconnect(child->parent,SIGNAL(activateSig(bool)),child,SLOT(activate(bool))); } @@ -252,7 +248,7 @@ QString socexplorerproxy::getinstanceNam void socexplorerproxy::changeSysDriverInstName(socexplorerplugin* driver) { if(!_self)init(); - QString prevName(driver->instanceName); + QString prevName(driver->instanceName()); } bool socexplorerproxy::instanceNameIsValid(const QString& instanceName) @@ -260,7 +256,7 @@ bool socexplorerproxy::instanceNameIsVal if(!_self)init(); for(int k=0;kcount();k++) { - if(!linearDriverList->at(k)->instanceName.compare(instanceName)) + if(!linearDriverList->at(k)->instanceName().compare(instanceName)) return false; } return true; @@ -271,7 +267,7 @@ socexplorerplugin *socexplorerproxy::fin if(!_self)init(); for(int k=0;kcount();k++) { - if(linearDriverList->at(k)->instanceName.compare(instanceName)) + if(linearDriverList->at(k)->instanceName().compare(instanceName)) return linearDriverList->at(k); } return NULL; @@ -304,7 +300,7 @@ socexplorerplugin* socexplorerproxy::get if(!_self)init(); for(int i=0;icount();i++) { - if(!linearDriverList->at(i)->instanceName.compare(instanceName)) + if(!linearDriverList->at(i)->instanceName().compare(instanceName)) return linearDriverList->at(i); } return NULL; diff --git a/src/dockablepluginmanager.cpp b/src/dockablepluginmanager.cpp --- a/src/dockablepluginmanager.cpp +++ b/src/dockablepluginmanager.cpp @@ -10,6 +10,7 @@ dockablePluginManager::dockablePluginMan connect(this,SIGNAL(treeChanged(QList)),this->managerGui,SIGNAL(treeChanged(QList))); connect(this->managerGui,SIGNAL(changeSysDriverInstName(QString,QString)),this,SIGNAL(changeSysDriverInstName(QString,QString))); connect(this->managerGui,SIGNAL(closeSysDriver(QString)),this,SIGNAL(closeSysDriver(QString))); + connect(this->managerGui,SIGNAL(pluginselected(QString)),this,SIGNAL(pluginselected(QString))); this->setWidget(this->managerGui); this->setWindowTitle(this->managerGui->windowTitle()); } diff --git a/src/dockablepluginmanager.h b/src/dockablepluginmanager.h --- a/src/dockablepluginmanager.h +++ b/src/dockablepluginmanager.h @@ -39,6 +39,7 @@ signals: void treeChanged(const QList& drivers); void changeSysDriverInstName(const QString newinstanceName,const QString previnstanceName); void closeSysDriver(const QString instanceName); + void pluginselected(const QString& instanceName); public slots: private: diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -36,9 +36,9 @@ LPMONMainWindow::LPMONMainWindow(QString this->setAcceptDrops(true); this->pluginManager->setRootLoadable(true); this->PythonConsoleInst->pyConsoleRunFile(ScriptToEval); - QProgressBar* test = SocExplorerEngine::getProgressBar("test",10); - statusBar()->setFixedHeight(statusBar()->height()); - SocExplorerEngine::deleteProgressBar(test); +// QProgressBar* test = SocExplorerEngine::getProgressBar("test",10); +// statusBar()->setFixedHeight(statusBar()->height()); +// SocExplorerEngine::deleteProgressBar(test); } @@ -64,7 +64,8 @@ void LPMONMainWindow::makeObjects(QStrin SocExplorerEngine::xmlModel()->scanXmlFiles(); this->regExplorer = new regsExplorer(); this->regExplorer->setAllowedAreas(Qt::AllDockWidgetAreas); - this->pluginsDockContainer->addDockWidget(Qt::TopDockWidgetArea,this->regExplorer); +// this->pluginsDockContainer->addDockWidget(Qt::TopDockWidgetArea,this->regExplorer); + this->addPluginInterface(this->regExplorer); this->PythonConsoleInst = new PythonConsole(socexplorerproxy::self()); this->PythonConsoleInst->addObject("SocExplorerEngine",SocExplorerEngine::self()); this->pluginManager = new dockablePluginManager(); @@ -98,8 +99,10 @@ void LPMONMainWindow::makeConnections() connect(this->pluginManager,SIGNAL(changeSysDriverInstName(QString,QString)),this->PythonConsoleInst,SLOT(changeSysDriverInstName(QString,QString))); connect(this->pluginManager,SIGNAL(closeSysDriver(QString)),socexplorerproxy::self(),SLOT(closeSysDriver(QString))); connect(this->pluginManager,SIGNAL(closeSysDriver(QString)),this->PythonConsoleInst,SLOT(removeDriver(QString))); + connect(this->pluginManager,SIGNAL(pluginselected(QString)),this,SLOT(pluginselected(QString))); connect(this->about,SIGNAL(triggered()),this,SLOT(showAboutBox())); connect(this->exploreRegs,SIGNAL(triggered()),this->regExplorer,SLOT(show())); + this->pluginManager->connect(this->pluginManager,SIGNAL(loadSysDrviver(QString)),socexplorerproxy::self(),SLOT(loadSysDriver(QString))); this->pluginManager->connect(this->pluginManager,SIGNAL(loadSysDriverToParent(QString,QString)),socexplorerproxy::self(),SLOT(loadSysDriverToParent(QString,QString))); @@ -207,6 +210,14 @@ void LPMONMainWindow::showAboutBox() p_about->show(); } +void LPMONMainWindow::pluginselected(const QString &instanceName) +{ + socexplorerplugin* drv=socexplorerproxy::self()->getSysDriver(instanceName); +// if(drv) +// drv->activate(true); +// TODO add plugin widget auto focus +} + void LPMONMainWindow::closeEvent(QCloseEvent *event) diff --git a/src/mainwindow.h b/src/mainwindow.h --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -62,7 +62,7 @@ public slots: void updateText(); void setLangage(QAction* action); void showAboutBox(); - + void pluginselected(const QString& instanceName); signals: void translateSig();