1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
4 * ModuleBase_IPropertyPanel.cpp
6 * Created on: Oct 01, 2014
10 #include "ModuleBase_IPropertyPanel.h"
11 #include "ModuleBase_ModelWidget.h"
12 #include "ModuleBase_ToolBox.h"
14 #include <ModelAPI_Validator.h>
15 #include <ModelAPI_Session.h>
17 ModuleBase_IPropertyPanel::ModuleBase_IPropertyPanel(QWidget* theParent)
18 : QDockWidget(theParent), myIsEditing(false)
22 ModuleBase_ModelWidget* ModuleBase_IPropertyPanel::modelWidget(
23 const std::string& theAttributeId) const
25 ModuleBase_ModelWidget* aWidget = 0;
26 QList<ModuleBase_ModelWidget*> aWidgets = modelWidgets();
27 ModelAPI_ValidatorsFactory* aValidators = ModelAPI_Session::get()->validators();
28 for (QList<ModuleBase_ModelWidget*>::const_iterator anIt = aWidgets.begin();
29 anIt != aWidgets.end() && !aWidget; anIt++) {
30 ModuleBase_ModelWidget* aCurrentWidget = *anIt;
31 if (aCurrentWidget->attributeID() == theAttributeId &&
32 aCurrentWidget->canAcceptFocus() &&
33 aValidators->isCase(aCurrentWidget->feature(), aCurrentWidget->attributeID()))
34 aWidget = aCurrentWidget;
40 ModuleBase_ModelWidget* ModuleBase_IPropertyPanel::findFirstAcceptingValueWidget()
42 return ModuleBase_IPropertyPanel::findFirstAcceptingValueWidget(modelWidgets());
45 ModuleBase_ModelWidget* ModuleBase_IPropertyPanel::findFirstAcceptingValueWidget(
46 const QList<ModuleBase_ModelWidget*>& theWidgets)
48 ModuleBase_ModelWidget* aFirstWidget = 0;
50 ModelAPI_ValidatorsFactory* aValidators = ModelAPI_Session::get()->validators();
52 ModuleBase_ModelWidget* aWgt;
53 QList<ModuleBase_ModelWidget*>::const_iterator aWIt;
54 bool isOffToolBox = false;
55 for (aWIt = theWidgets.begin(); aWIt != theWidgets.end() && !aFirstWidget; ++aWIt) {
57 if (!aValidators->isCase(aWgt->feature(), aWgt->attributeID()))
58 continue; // this attribute is not participated in the current case
60 if (!aWgt->canAcceptFocus())
63 /// workaround for the same attributes used in different stacked widgets(attribute types)
64 if (ModuleBase_ToolBox::isOffToolBoxParent(aWgt))