Commit b1f1c802 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[CHANGE] - preparations for including dynamic module connection to gui

parent ea44f149
......@@ -64,13 +64,13 @@ private:
template < typename T >
WTypeComparable< T >::WTypeComparable()
{
// init
}
template < typename T >
WTypeComparable< T >::~WTypeComparable()
{
// clean up
}
#endif // WTYPECOMPARABLE_H
......
......@@ -126,6 +126,19 @@ WQtModuleTreeItem* WQtDatasetBrowser::addModule( boost::shared_ptr< WModule > mo
return tiModules->addModuleItem( module );
}
boost::shared_ptr< WModule > WQtDatasetBrowser::getSelectedModule()
{
if ( m_treeWidget->selectedItems().at( 0 )->type() == 1 )
{
return ( ( WQtDatasetTreeItem* ) m_treeWidget->selectedItems().at( 0 ) )->getModule();
}
else if ( m_treeWidget->selectedItems().at( 0 )->type() == 3 )
{
return ( ( WQtModuleTreeItem* ) m_treeWidget->selectedItems().at( 0 ) )->getModule();
}
return boost::shared_ptr< WModule >();
}
void WQtDatasetBrowser::selectTreeItem()
{
......@@ -139,22 +152,25 @@ void WQtDatasetBrowser::selectTreeItem()
}
boost::shared_ptr< WModule >module;
m_mainWindow->getToolBar()->clearNonPersistentTabs();
if ( m_treeWidget->selectedItems().at( 0 )->type() == 1 )
{
module = ( ( WQtDatasetTreeItem* ) m_treeWidget->selectedItems().at( 0 ) )->getModule();
// create ribbon menu entry
m_mainWindow->getToolBar()->addTab( QString( "Compatibles" ), false );
std::set< boost::shared_ptr< WModule > > comps = WModuleFactory::getModuleFactory()->getCompatiblePrototypes( module );
for ( std::set< boost::shared_ptr< WModule > >::iterator iter = comps.begin(); iter != comps.end(); ++iter )
{
m_mainWindow->getToolBar()->addPushButton( QString( ( *iter )->getName().c_str() ), QString( "Compatibles" ),
m_mainWindow->getIconManager()->getIcon( "load" ), QString( ( *iter )->getName().c_str() ) );
}
}
else
{
module = ( ( WQtModuleTreeItem* ) m_treeWidget->selectedItems().at( 0 ) )->getModule();
}
// create ribbon menu entry
std::set< boost::shared_ptr< WModule > > comps = WModuleFactory::getModuleFactory()->getCompatiblePrototypes( module );
for ( std::set< boost::shared_ptr< WModule > >::iterator iter = comps.begin(); iter != comps.end(); ++iter )
{
std::cout << "Name:" << ( *iter )->getName() << std::endl;
}
// create properties
std::vector < WProperty* >props = module->getProperties()->getPropertyVector();
......
......@@ -103,6 +103,13 @@ public:
*/
void connectSlots();
/**
* Returns the module currently selected in dataset browser.
*
* \return the module.
*/
boost::shared_ptr< WModule > getSelectedModule();
public slots:
void slotSetIntProperty( QString name, int value );
void slotSetBoolProperty( QString name, bool value );
......
......@@ -42,6 +42,11 @@ void WQtPushButton::setName( QString name )
m_name = name;
}
QString WQtPushButton::getName()
{
return m_name;
}
void WQtPushButton::emitPressed()
{
emit pushButtonPressed( m_name, true );
......
......@@ -52,6 +52,13 @@ public:
*/
void setName( QString name );
/**
* Getter for this button's name.
*
* \return the name
*/
QString getName();
private:
QString m_name;
......
......@@ -22,6 +22,8 @@
//
//---------------------------------------------------------------------------
#include <vector>
#include "WQtMenuPage.h"
WQtMenuPage::WQtMenuPage( QString name, bool persistent )
......@@ -47,11 +49,18 @@ QString WQtMenuPage::getName()
return m_name;
}
std::vector< QString > WQtMenuPage::getButtons()
{
return m_ownButtons;
}
void WQtMenuPage::addButton( WQtPushButton* button )
{
int count = m_pageLayout->count();
m_pageLayout->insertWidget( count -1, button );
this->setLayout( m_pageLayout );
m_ownButtons.push_back( button->getName() );
}
bool WQtMenuPage::isPersistent() const
......
......@@ -25,6 +25,7 @@
#ifndef WQTMENUPAGE_H
#define WQTMENUPAGE_H
#include <vector>
#include <QtGui/QHBoxLayout>
#include <QtGui/QWidget>
......@@ -55,6 +56,13 @@ public:
*/
void addButton( WQtPushButton* button );
/**
* Gives back the list of buttons associated with this tab.
*
* \return the list of buttons
*/
std::vector< QString > getButtons();
QString getName();
/**
......@@ -75,6 +83,11 @@ private:
QHBoxLayout* m_pageLayout;
QString m_name;
/**
* List of buttons belonging to this tab.
*/
std::vector< QString > m_ownButtons;
};
#endif // WQTMENUPAGE_H
......@@ -24,6 +24,8 @@
#include <cassert>
#include <iostream>
#include <vector>
#include <map>
#include "WQtRibbonMenu.h"
......@@ -42,12 +44,12 @@ WQtRibbonMenu::~WQtRibbonMenu()
}
WQtMenuPage* WQtRibbonMenu::addTab( QString name )
WQtMenuPage* WQtRibbonMenu::addTab( QString name, bool persistent )
{
// don't add a tab with the same name twice
assert( m_tabList.count( name ) == 0 );
WQtMenuPage* tab = new WQtMenuPage( name );
WQtMenuPage* tab = new WQtMenuPage( name, persistent );
m_tabWidget->addTab( tab, name );
......@@ -84,6 +86,12 @@ void WQtRibbonMenu::clearNonPersistentTabs()
int idx = m_tabWidget->indexOf( ( *iter ).second );
if ( !( *iter ).second->isPersistent() )
{
std::vector< QString > buttons = ( *iter ).second->getButtons();
for ( std::vector< QString >::iterator bIter = buttons.begin(); bIter != buttons.end(); ++bIter )
{
m_buttonList.erase( *bIter );
}
m_tabWidget->removeTab( idx );
m_tabList.erase( iter );
}
......
......@@ -51,7 +51,7 @@ public:
/**
*
*/
WQtMenuPage* addTab( QString name );
WQtMenuPage* addTab( QString name, bool persistent = true );
/**
*
......
......@@ -230,14 +230,6 @@ void WKernel::doLoadDataSets( std::vector< std::string > fileNames )
shared_ptr< WModule > mod = m_moduleFactory->create( m_moduleFactory->getPrototypeByName( "Data Module" ) );
mod->getProperties()->setValue( "filename" , ( *iter ) );
m_moduleContainer->add( mod );
/*std::set< boost::shared_ptr< WModule > > comps = m_moduleFactory->getCompatiblePrototypes( mod );
WLogger::getLogger()->addLogMessage( "Compatible Modules? -> ", "Kernel", LL_ERROR );
for ( std::set< boost::shared_ptr< WModule > >::iterator iter=comps.begin(); iter != comps.end(); ++iter )
{
WLogger::getLogger()->addLogMessage( "Compatible Modules: " + ( *iter )->getName() , "Kernel", LL_ERROR );
}*/
}
}
......
......@@ -108,14 +108,10 @@ public:
*/
virtual bool connectable( boost::shared_ptr<WModuleConnector> con )
{
//if ( dynamic_cast<WModuleOutputData<T>* >( con.get() ) ) // NOLINT - since we really need them here
{
// NOTE: the upper cast already checked the compatibility completely. WModuleInputConnector::connectable does the
// same check again. But since we do not know what checks will be added to WModuleInputConnector::connectable in the
// future we forward the call.
return WModuleInputConnector::connectable( con );
}
return false;
// NOTE: the upper cast already checked the compatibility completely. WModuleInputConnector::connectable does the
// same check again. But since we do not know what checks will be added to WModuleInputConnector::connectable in the
// future we forward the call.
return WModuleInputConnector::connectable( con );
};
protected:
......
......@@ -98,17 +98,10 @@ public:
*/
virtual bool connectable( boost::shared_ptr<WModuleConnector> con )
{
//WLogger::getLogger()->addLogMessage( "MAGUCKN", getCanonicalName(), LL_ERROR );
//WLogger::getLogger()->addLogMessage( "Mit: " + con->getCanonicalName(), getCanonicalName(), LL_ERROR );
//if ( dynamic_cast< WModuleInputData< T >* >( con.get() ) ) // NOLINT - since we really need the dynamic cast here
{
//WLogger::getLogger()->addLogMessage( "GEIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIL" + con->getCanonicalName(), getCanonicalName(), LL_ERROR );
// NOTE: the upper cast already checked the compatibility completely. WModuleOutputConnector::connectable does the
// same check again. But since we do not know what checks will be added to WModuleOutputConnector::connectable in the
// future we forward the call.
return WModuleOutputConnector::connectable( con );
}
// NOTE: the upper cast already checked the compatibility completely. WModuleOutputConnector::connectable does the
// same check again. But since we do not know what checks will be added to WModuleOutputConnector::connectable in the
// future we forward the call.
return WModuleOutputConnector::connectable( con );
};
protected:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment