Salome HOME
Issue #1834: Fix length of lines
[modules/shaper.git] / src / ModuleBase / ModuleBase_IPropertyPanel.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 /*
4  * ModuleBase_IPropertyPanel.cpp
5  *
6  *  Created on: Oct 01, 2014
7  *      Author: vsv
8  */
9
10 #include "ModuleBase_IPropertyPanel.h"
11 #include "ModuleBase_ModelWidget.h"
12 #include "ModuleBase_ToolBox.h"
13
14 #include <ModelAPI_Validator.h>
15 #include <ModelAPI_Session.h>
16
17 ModuleBase_IPropertyPanel::ModuleBase_IPropertyPanel(QWidget* theParent)
18  : QDockWidget(theParent), myIsEditing(false)
19 {
20
21 }
22
23 ModuleBase_ModelWidget* ModuleBase_IPropertyPanel::findFirstAcceptingValueWidget()
24 {
25   return ModuleBase_IPropertyPanel::findFirstAcceptingValueWidget(modelWidgets());
26 }
27
28 ModuleBase_ModelWidget* ModuleBase_IPropertyPanel::findFirstAcceptingValueWidget(
29                                         const QList<ModuleBase_ModelWidget*>& theWidgets)
30 {
31   ModuleBase_ModelWidget* aFirstWidget = 0;
32
33   ModelAPI_ValidatorsFactory* aValidators = ModelAPI_Session::get()->validators();
34
35   ModuleBase_ModelWidget* aWgt;
36   QList<ModuleBase_ModelWidget*>::const_iterator aWIt;
37   bool isOffToolBox = false;
38   for (aWIt = theWidgets.begin(); aWIt != theWidgets.end() && !aFirstWidget; ++aWIt) {
39     aWgt = (*aWIt);
40     if (!aValidators->isCase(aWgt->feature(), aWgt->attributeID()))
41       continue; // this attribute is not participated in the current case
42
43     if (!aWgt->canAcceptFocus())
44       continue;
45
46     /// workaround for the same attributes used in different stacked widgets(attribute types)
47     if (ModuleBase_ToolBox::isOffToolBoxParent(aWgt))
48       continue;
49
50     aFirstWidget = aWgt;
51   }
52   return aFirstWidget;
53 }