]> SALOME platform Git repositories - modules/shaper.git/blob - src/PartSet/PartSet_WidgetMultiSelectorComposite.cpp
Salome HOME
#1371 Using auxilliary Sketch elements in any Feature: code improvement to separate...
[modules/shaper.git] / src / PartSet / PartSet_WidgetMultiSelectorComposite.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        PartSet_WidgetMultiSelectorComposite.cpp
4 // Created:     17 Mar 2016
5 // Author:      Natalia Ermolaeva
6
7 #include "PartSet_WidgetMultiSelectorComposite.h"
8
9 PartSet_WidgetMultiSelectorComposite::PartSet_WidgetMultiSelectorComposite(QWidget* theParent,
10                                                          ModuleBase_IWorkshop* theWorkshop,
11                                                          const Config_WidgetAPI* theData)
12 : ModuleBase_WidgetMultiSelector(theParent, theWorkshop, theData)
13 {
14 }
15
16 PartSet_WidgetMultiSelectorComposite::~PartSet_WidgetMultiSelectorComposite()
17 {
18 }
19
20 bool PartSet_WidgetMultiSelectorComposite::focusTo()
21 {
22   bool aCanHaveFocus = true;
23
24   if (hasSubObjects()) {
25   // disable widget controls
26     disableControls();
27     aCanHaveFocus = false;
28   }
29   else
30     aCanHaveFocus = ModuleBase_WidgetMultiSelector::focusTo();
31   return aCanHaveFocus;
32 }
33
34 void PartSet_WidgetMultiSelectorComposite::setEditingMode(bool isEditing)
35 {
36   ModuleBase_ModelWidget::setEditingMode(isEditing);
37   bool aHasSubObjects = hasSubObjects();
38   if (aHasSubObjects)
39     disableControls();
40 }
41
42 bool PartSet_WidgetMultiSelectorComposite::hasSubObjects() const
43 {
44   bool aHasSubObjects = false;
45
46   bool aCanSetFocus = true;
47   CompositeFeaturePtr aComposite = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(myFeature);
48   if (aComposite.get())
49     aHasSubObjects = aComposite->numberOfSubs() > 0;
50   return aHasSubObjects;
51 }
52
53 void PartSet_WidgetMultiSelectorComposite::disableControls()
54 {
55   QList<QWidget*> aMyControls = getControls();
56   foreach(QWidget*  eachControl, aMyControls) {
57     eachControl->setFocusPolicy(Qt::NoFocus);
58     eachControl->setEnabled(false);
59   }
60 }