//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see .
//
//---------------------------------------------------------------------------
#include
#include
#include
#include "../../../kernel/WKernel.h"
#include "../../../common/WProgressCombiner.h"
#include "../../../common/WProgress.h"
#include "../../../kernel/WModuleInputConnector.h"
#include "../../../kernel/WModuleOutputConnector.h"
#include "../events/WModuleDeleteEvent.h"
#include "../events/WEventTypes.h"
#include "../events/WPropertyChangedEvent.h"
#include "../WQt4Gui.h"
#include "../WMainWindow.h"
#include "WTreeItemTypes.h"
#include "WQtTreeItem.h"
WQtTreeItem::WQtTreeItem( QTreeWidgetItem * parent, WTreeItemType type, boost::shared_ptr< WModule > module ) :
QTreeWidgetItem( parent, type ),
m_deleteInProgress( false ),
m_needPostDeleteEvent( true ),
m_handledInput( "" )
{
m_module = module;
m_name = module->getName();
if ( module->getProperties()->getProperty( "active" )->toPropBool()->get() )
{
this->setCheckState( 0, Qt::Checked );
}
else
{
this->setCheckState( 0, Qt::Unchecked );
}
this->setFlags( Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled );
// grab the runtime name property
// replace the name by the filename
boost::shared_ptr< WPropertyBase > p = module->getProperties()->findProperty( "Name" );
// always ensure that findProperty really found something
if ( p )
{
m_nameProp = p->toPropString();
}
// was it a string prop?
if ( m_nameProp )
{
m_name = m_nameProp->get( true );
m_nameProp->getUpdateCondition()->subscribeSignal( boost::bind( &WQtTreeItem::nameChanged, this ) );
}
m_updateTimer = boost::shared_ptr< QTimer >( new QTimer() );
connect( m_updateTimer.get(), SIGNAL( timeout() ), this, SLOT( update() ) );
m_updateTimer->start( 50 );
}
WQtTreeItem::~WQtTreeItem()
{
}
boost::shared_ptr< WModule > WQtTreeItem::getModule()
{
return m_module;
}
std::string WQtTreeItem::getName()
{
return m_name;
}
void WQtTreeItem::updateTooltip( std::string progress )
{
std::string tooltip = "";
if ( m_module->isCrashed()() )
{
tooltip += "A problem occured. The module has been stopped.