0031939: Coding - correction of spelling errors in comments [part 2]
[occt.git] / tools / VInspector / VInspector_ToolBar.cxx
CommitLineData
14bbbdcb 1// Created on: 2017-06-16
2// Created by: Natalia ERMOLAEVA
3// Copyright (c) 2017 OPEN CASCADE SAS
4//
5// This file is part of Open CASCADE Technology software library.
6//
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.
12//
13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
15
0cb512c0 16#include <inspector/VInspector_ToolBar.hxx>
14bbbdcb 17
130eb114 18#include <Standard_WarningsDisable.hxx>
14bbbdcb 19#include <QHBoxLayout>
0cb512c0 20#include <QPushButton>
14bbbdcb 21#include <QWidget>
130eb114 22#include <Standard_WarningsRestore.hxx>
0cb512c0 23
14bbbdcb 24// =======================================================================
25// function : Constructor
26// purpose :
27// =======================================================================
28VInspector_ToolBar::VInspector_ToolBar (QWidget* theParent)
29: QObject (theParent)
30{
0cb512c0 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"));
35
14bbbdcb 36 myActionsMap[VInspector_ToolActionType_UpdateId]->setText ("Update");
37
14bbbdcb 38 myMainWindow = new QWidget (theParent);
39
40 QHBoxLayout* aLay = new QHBoxLayout (myMainWindow);
0cb512c0 41 aLay->setMargin(0);
42 for (QMap<VInspector_ToolActionType, QPushButton*>::ConstIterator anActionsIt = myActionsMap.begin();
14bbbdcb 43 anActionsIt != myActionsMap.end(); anActionsIt++)
44 {
0cb512c0 45 QPushButton* aBtn = anActionsIt.value();
14bbbdcb 46 connect (aBtn, SIGNAL (clicked()), this, SLOT (onActionClicked()));
47 aLay->addWidget (aBtn);
48 }
0cb512c0 49 aLay->addStretch(1);
14bbbdcb 50}
51
52// =======================================================================
53// function : GetToolButton
54// purpose :
55// =======================================================================
0cb512c0 56QPushButton* VInspector_ToolBar::GetToolButton (const VInspector_ToolActionType& theActionId ) const
14bbbdcb 57{
58 return myActionsMap.contains (theActionId) ? myActionsMap[theActionId] : 0;
59}
60
61// =======================================================================
62// function : onActionClicked
63// purpose :
64// =======================================================================
65void VInspector_ToolBar::onActionClicked()
66{
67 int anId = -1;
0cb512c0 68 QPushButton* aSenderBtn = (QPushButton*)sender();
14bbbdcb 69
0cb512c0 70 for (QMap<VInspector_ToolActionType, QPushButton*>::ConstIterator anActionsIt = myActionsMap.begin();
14bbbdcb 71 anActionsIt != myActionsMap.end(); anActionsIt++)
72 {
73 if (anActionsIt.value() != aSenderBtn)
74 continue;
75 anId = anActionsIt.key();
76 break;
77 }
78
14bbbdcb 79 if (anId != -1)
80 emit actionClicked (anId);
81}