1 // Created on: 2017-06-16
2 // Created by: Natalia ERMOLAEVA
3 // Copyright (c) 2017 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #include <inspector/VInspector_ToolBar.hxx>
18 #include <Standard_WarningsDisable.hxx>
19 #include <QHBoxLayout>
20 #include <QPushButton>
22 #include <Standard_WarningsRestore.hxx>
24 // =======================================================================
25 // function : Constructor
27 // =======================================================================
28 VInspector_ToolBar::VInspector_ToolBar (QWidget* theParent)
31 myActionsMap[VInspector_ToolActionType_UpdateId] = new QPushButton (theParent);
32 myActionsMap[VInspector_ToolActionType_UpdateId]->setIcon (QIcon (":/icons/treeview_update.png"));
33 myActionsMap[VInspector_ToolActionType_UpdateId]->setText (tr ("Update Tree Model"));
34 myActionsMap[VInspector_ToolActionType_UpdateId]->setToolTip (tr ("Update Tree Model"));
36 myActionsMap[VInspector_ToolActionType_UpdateId]->setText ("Update");
38 myMainWindow = new QWidget (theParent);
40 QHBoxLayout* aLay = new QHBoxLayout (myMainWindow);
42 for (QMap<VInspector_ToolActionType, QPushButton*>::ConstIterator anActionsIt = myActionsMap.begin();
43 anActionsIt != myActionsMap.end(); anActionsIt++)
45 QPushButton* aBtn = anActionsIt.value();
46 connect (aBtn, SIGNAL (clicked()), this, SLOT (onActionClicked()));
47 aLay->addWidget (aBtn);
52 // =======================================================================
53 // function : GetToolButton
55 // =======================================================================
56 QPushButton* VInspector_ToolBar::GetToolButton (const VInspector_ToolActionType& theActionId ) const
58 return myActionsMap.contains (theActionId) ? myActionsMap[theActionId] : 0;
61 // =======================================================================
62 // function : onActionClicked
64 // =======================================================================
65 void VInspector_ToolBar::onActionClicked()
68 QPushButton* aSenderBtn = (QPushButton*)sender();
70 for (QMap<VInspector_ToolActionType, QPushButton*>::ConstIterator anActionsIt = myActionsMap.begin();
71 anActionsIt != myActionsMap.end(); anActionsIt++)
73 if (anActionsIt.value() != aSenderBtn)
75 anId = anActionsIt.key();
80 emit actionClicked (anId);