1 // Copyright (C) 2014-2017 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 * ModuleBase_IPropertyPanel.cpp
23 * Created on: Oct 01, 2014
27 #include "ModuleBase_IPropertyPanel.h"
28 #include "ModuleBase_ModelWidget.h"
29 #include "ModuleBase_ToolBox.h"
31 #include <ModelAPI_Validator.h>
32 #include <ModelAPI_Session.h>
34 ModuleBase_IPropertyPanel::ModuleBase_IPropertyPanel(QWidget* theParent)
35 : QDockWidget(theParent), myIsEditing(false)
39 ModuleBase_ModelWidget* ModuleBase_IPropertyPanel::modelWidget(
40 const std::string& theAttributeId) const
42 ModuleBase_ModelWidget* aWidget = 0;
43 QList<ModuleBase_ModelWidget*> aWidgets = modelWidgets();
44 ModelAPI_ValidatorsFactory* aValidators = ModelAPI_Session::get()->validators();
45 for (QList<ModuleBase_ModelWidget*>::const_iterator anIt = aWidgets.begin();
46 anIt != aWidgets.end() && !aWidget; anIt++) {
47 ModuleBase_ModelWidget* aCurrentWidget = *anIt;
48 if (aCurrentWidget->attributeID() == theAttributeId &&
49 aCurrentWidget->canAcceptFocus() &&
50 aValidators->isCase(aCurrentWidget->feature(), aCurrentWidget->attributeID()))
51 aWidget = aCurrentWidget;
57 ModuleBase_ModelWidget* ModuleBase_IPropertyPanel::findFirstAcceptingValueWidget()
59 return ModuleBase_IPropertyPanel::findFirstAcceptingValueWidget(modelWidgets());
62 ModuleBase_ModelWidget* ModuleBase_IPropertyPanel::findFirstAcceptingValueWidget(
63 const QList<ModuleBase_ModelWidget*>& theWidgets)
65 ModuleBase_ModelWidget* aFirstWidget = 0;
67 ModelAPI_ValidatorsFactory* aValidators = ModelAPI_Session::get()->validators();
69 ModuleBase_ModelWidget* aWgt;
70 QList<ModuleBase_ModelWidget*>::const_iterator aWIt;
71 bool isOffToolBox = false;
72 for (aWIt = theWidgets.begin(); aWIt != theWidgets.end() && !aFirstWidget; ++aWIt) {
74 if (!aValidators->isCase(aWgt->feature(), aWgt->attributeID()))
75 continue; // this attribute is not participated in the current case
77 if (!aWgt->canAcceptFocus())
80 /// workaround for the same attributes used in different stacked widgets(attribute types)
81 if (ModuleBase_ToolBox::isOffToolBoxParent(aWgt))