1
//---------------------------------------------------------------------------
3
// Project: OpenWalnut ( http://www.openwalnut.org )
5
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6
// For more information see http://www.openwalnut.org/copying
8
// This file is part of OpenWalnut.
10
// OpenWalnut is free software: you can redistribute it and/or modify
11
// it under the terms of the GNU Lesser General Public License as published by
12
// the Free Software Foundation, either version 3 of the License, or
13
// (at your option) any later version.
15
// OpenWalnut is distributed in the hope that it will be useful,
16
// but WITHOUT ANY WARRANTY; without even the implied warranty of
17
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
// GNU Lesser General Public License for more details.
20
// You should have received a copy of the GNU Lesser General Public License
21
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
23
//---------------------------------------------------------------------------
27
#include "WQtModuleOneToOneCombinerAction.h"
28
#include "WQtModuleOneToOneCombinerAction.moc"
30
WQtModuleOneToOneCombinerAction::WQtModuleOneToOneCombinerAction( QWidget* parent, WIconManager* iconManager,
31
boost::shared_ptr< WModuleOneToOneCombiner > combiner,
34
m_combiner( combiner )
37
std::string from = "";
39
// NOTE: all the tooltips and so on for this action are used from the first combiner in the group
41
// use the name property of the modules
42
std::string srcName = "";
43
std::string targetName = m_combiner->getTargetModule()->getProperties()->getProperty( "Name" )->toPropString()->get();
45
// might be null ( for example if a module should be added that does not require an input)
46
if( m_combiner->getSrcModule() )
48
srcName = m_combiner->getSrcModule()->getProperties()->getProperty( "Name" )->toPropString()->get();
50
// append real module name if it is different from user specified name
51
if( srcName != m_combiner->getSrcModule()->getName() )
53
srcName += " (" + m_combiner->getSrcModule()->getName() + ")";
57
// append real module name if it is different from user specified name
58
if( targetName != m_combiner->getTargetModule()->getName() )
60
targetName += " (" + m_combiner->getTargetModule()->getName() + ")";
63
from = srcName + ": <i>" + m_combiner->getSrcConnector() + "</i> ➜ ";
64
std::string tooltip = "<b>" + targetName + "</b><br><nobr>" + from + targetName + ": <i>" + m_combiner->getTargetConnector() + "</i></nobr>";
66
// We need this because menu items seem not to support HTNL
67
std::string advancedTextString = srcName + ":" + m_combiner->getSrcConnector() + " -> " + targetName + ":" + m_combiner->getTargetConnector();
69
setToolTip( tooltip.c_str() );
70
setText( advancedText ? advancedTextString.c_str() : targetName.c_str() );
71
setIconText( advancedText ? tooltip.c_str() : targetName.c_str() );
73
// get an icon for this module
74
setIcon( iconManager->getIcon( m_combiner->getTargetModule()->getName().c_str(), iconManager->getIcon( "DefaultModuleIcon" ) ) );
76
// we need to use released signal here, as the pushed signal also gets emitted on newly created buttons which are under the mouse pointer with
77
// pressed left button.
78
connect( this, SIGNAL( triggered() ), this, SLOT( applyCombiner() ) );
81
WQtModuleOneToOneCombinerAction::~WQtModuleOneToOneCombinerAction()
85
void WQtModuleOneToOneCombinerAction::applyCombiner()