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
//---------------------------------------------------------------------------
25
#include "WQtCombinerActionList.h"
27
WQtCombinerActionList::WQtCombinerActionList( QWidget* parent, WIconManager* icons, WCombinerTypes::WCompatiblesList compatibles,
28
const WQtModuleConfig* exclusionPredicate, bool advancedText ):
31
// create an action for each group:
32
for( WCombinerTypes::WCompatiblesList::iterator groups = compatibles.begin(); groups != compatibles.end(); ++groups )
34
// check current prototype against whitelist and blacklist
35
if( exclusionPredicate && exclusionPredicate->operator()( groups->first ) )
39
// create a new action for this group
40
WQtModuleOneToOneCombinerAction* group = new WQtModuleOneToOneCombinerAction( parent, icons, *groups->second.begin(), advancedText );
42
group->setIconVisibleInMenu( true );
45
// only add a sub menu if there are more than 1 items in the group
46
if( ( *groups ).second.size() > 1 )
48
QMenu* groupMenu = new QMenu( parent );
49
// iterate all the children
50
for( WCombinerTypes::WOneToOneCombiners::iterator combiner = ( *groups ).second.begin();
51
combiner != ( *groups ).second.end(); ++combiner )
53
WQtModuleOneToOneCombinerAction* a = new WQtModuleOneToOneCombinerAction( parent, icons, *combiner, true );
55
a->setIconVisibleInMenu( true );
56
groupMenu->addAction( a );
58
group->setMenu( groupMenu );
63
WQtCombinerActionList::WQtCombinerActionList( QWidget* parent, WIconManager* icons, WCombinerTypes::WDisconnectList disconnects ):
66
// create an action for each group:
67
for( WCombinerTypes::WDisconnectList::iterator groups = disconnects.begin(); groups != disconnects.end(); ++groups )
69
// create a new action for this group
70
WQtModuleOneToOneCombinerAction* group = new WQtModuleOneToOneCombinerAction( parent, icons, *groups->second.begin(), true );
72
group->setIconVisibleInMenu( true );
75
// only add a sub menu if there are more than 1 items in the group
76
if( ( *groups ).second.size() > 1 )
78
QMenu* groupMenu = new QMenu( parent );
79
// iterate all the children
80
for( WCombinerTypes::WOneToOneCombiners::iterator combiner = ( *groups ).second.begin();
81
combiner != ( *groups ).second.end(); ++combiner )
83
WQtModuleOneToOneCombinerAction* a = new WQtModuleOneToOneCombinerAction( parent, icons, *combiner, true );
85
a->setIconVisibleInMenu( true );
86
groupMenu->addAction( a );
88
group->setMenu( groupMenu );
93
WQtCombinerActionList::WQtCombinerActionList():
99
WQtCombinerActionList::~WQtCombinerActionList()