~ubuntu-branches/ubuntu/raring/openwalnut/raring

« back to all changes in this revision

Viewing changes to src/qt4gui/guiElements/WQtModuleOneToOneCombinerAction.cpp

  • Committer: Package Import Robot
  • Author(s): Sebastian Eichelbaum
  • Date: 2012-12-12 11:26:32 UTC
  • mfrom: (3.1.1 sid)
  • Revision ID: package-import@ubuntu.com-20121212112632-xhiuwkxuz5h0idkh
Tags: 1.3.1+hg5849-1
* Minor changes compared to 1.3.0 but included several bug fixes.
* See http://www.openwalnut.org/versions/4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//---------------------------------------------------------------------------
 
2
//
 
3
// Project: OpenWalnut ( http://www.openwalnut.org )
 
4
//
 
5
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
 
6
// For more information see http://www.openwalnut.org/copying
 
7
//
 
8
// This file is part of OpenWalnut.
 
9
//
 
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.
 
14
//
 
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.
 
19
//
 
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/>.
 
22
//
 
23
//---------------------------------------------------------------------------
 
24
 
 
25
#include <string>
 
26
 
 
27
#include "WQtModuleOneToOneCombinerAction.h"
 
28
#include "WQtModuleOneToOneCombinerAction.moc"
 
29
 
 
30
WQtModuleOneToOneCombinerAction::WQtModuleOneToOneCombinerAction( QWidget* parent, WIconManager* iconManager,
 
31
                                                                  boost::shared_ptr< WModuleOneToOneCombiner > combiner,
 
32
                                                                  bool advancedText ):
 
33
    QAction( parent ),
 
34
    m_combiner( combiner )
 
35
{
 
36
    // nice tooltip
 
37
    std::string from = "";
 
38
 
 
39
    // NOTE: all the tooltips and so on for this action are used from the first combiner in the group
 
40
 
 
41
    // use the name property of the modules
 
42
    std::string srcName = "";
 
43
    std::string targetName = m_combiner->getTargetModule()->getProperties()->getProperty( "Name" )->toPropString()->get();
 
44
 
 
45
    // might be null ( for example if a module should be added that does not require an input)
 
46
    if( m_combiner->getSrcModule() )
 
47
    {
 
48
        srcName = m_combiner->getSrcModule()->getProperties()->getProperty( "Name" )->toPropString()->get();
 
49
 
 
50
        // append real module name if it is different from user specified name
 
51
        if( srcName != m_combiner->getSrcModule()->getName() )
 
52
        {
 
53
            srcName += " (" + m_combiner->getSrcModule()->getName() + ")";
 
54
        }
 
55
    }
 
56
 
 
57
    // append real module name if it is different from user specified name
 
58
    if( targetName != m_combiner->getTargetModule()->getName() )
 
59
    {
 
60
        targetName += " (" + m_combiner->getTargetModule()->getName() + ")";
 
61
    }
 
62
 
 
63
    from = srcName + ": <i>" + m_combiner->getSrcConnector() + "</i> &nbsp;&nbsp;&#10140;&nbsp;&nbsp; ";
 
64
    std::string tooltip = "<b>" + targetName + "</b><br><nobr>" + from + targetName + ": <i>" + m_combiner->getTargetConnector() + "</i></nobr>";
 
65
 
 
66
    // We need this because menu items seem not to support HTNL
 
67
    std::string advancedTextString = srcName + ":" + m_combiner->getSrcConnector() + " -> " + targetName + ":" + m_combiner->getTargetConnector();
 
68
 
 
69
    setToolTip( tooltip.c_str() );
 
70
    setText( advancedText ? advancedTextString.c_str() : targetName.c_str() );
 
71
    setIconText( advancedText ? tooltip.c_str() : targetName.c_str() );
 
72
 
 
73
    // get an icon for this module
 
74
    setIcon( iconManager->getIcon( m_combiner->getTargetModule()->getName().c_str(), iconManager->getIcon( "DefaultModuleIcon" ) ) );
 
75
 
 
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() ) );
 
79
}
 
80
 
 
81
WQtModuleOneToOneCombinerAction::~WQtModuleOneToOneCombinerAction()
 
82
{
 
83
}
 
84
 
 
85
void WQtModuleOneToOneCombinerAction::applyCombiner()
 
86
{
 
87
    m_combiner->run();
 
88
}
 
89