+ else { // backward by SHIFT + Tab
+ QToolButton* anOkBtn = findChild<QToolButton*>(PROP_PANEL_OK);
+ if (anOkBtn->hasFocus()) {
+ // after Apply, the last control should be focused
+ QWidget* aLastControl = 0;
+ for (int i = myWidgets.size()-1; i >= 0 && !aLastControl; i--)
+ aLastControl = myWidgets[i]->getControlAcceptingFocus(false);
+ if (aLastControl)
+ aLastControl->setFocus();
+ isChangedFocus = true;
+ }
+ else {
+ // after the first control, the Cancel button should be focused
+ QWidget* aFirstControl = 0;
+ for (int i = 0, aSize = myWidgets.size(); i < aSize && !aFirstControl; i++)
+ aFirstControl = myWidgets[i]->getControlAcceptingFocus(true);
+ if (aFirstControl && aFirstControl->hasFocus()) {
+ QToolButton* aCancelBtn = findChild<QToolButton*>(PROP_PANEL_CANCEL);
+ aCancelBtn->setFocus();
+ isChangedFocus = true;
+ }
+ }
+ }
+
+ if (!isChangedFocus)
+ isChangedFocus = ModuleBase_IPropertyPanel::focusNextPrevChild(theIsNext);
+
+ return isChangedFocus;
+}
+
+void XGUI_PropertyPanel::activateNextWidget()
+{
+ activateNextWidget(myActiveWidget);
+}
+
+void XGUI_PropertyPanel::activateWidget(ModuleBase_ModelWidget* theWidget)
+{
+ std::string aPreviosAttributeID;
+ if(myActiveWidget)
+ aPreviosAttributeID = myActiveWidget->attributeID();
+
+ // Avoid activation of already actve widget. It could happen on focusIn event many times
+ if (setActiveWidget(theWidget)) {
+ emit widgetActivated(myActiveWidget);
+ if (!myActiveWidget && !isEditingMode()) {
+ emit noMoreWidgets(aPreviosAttributeID);
+ }
+ }
+}
+
+bool XGUI_PropertyPanel::setActiveWidget(ModuleBase_ModelWidget* theWidget)
+{
+ // Avoid activation of already actve widget. It could happen on focusIn event many times
+ if (theWidget == myActiveWidget) {
+ return false;
+ }
+ std::string aPreviosAttributeID;
+ if(myActiveWidget) {
+ aPreviosAttributeID = myActiveWidget->attributeID();
+ myActiveWidget->deactivate();
+ myActiveWidget->setHighlighted(false);
+ }
+ if(theWidget) {
+ emit beforeWidgetActivated(theWidget);
+ theWidget->setHighlighted(true);
+ theWidget->activate();
+ }
+ myActiveWidget = theWidget;
+ return true;
+}
+
+void XGUI_PropertyPanel::setFocusOnOkButton()
+{
+ QToolButton* anOkBtn = findChild<QToolButton*>(PROP_PANEL_OK);
+ anOkBtn->setFocus();
+}
+
+void XGUI_PropertyPanel::setCancelEnabled(bool theEnabled)
+{
+ QToolButton* anCancelBtn = findChild<QToolButton*>(PROP_PANEL_CANCEL);
+ anCancelBtn->setEnabled(theEnabled);
+}
+
+bool XGUI_PropertyPanel::isCancelEnabled() const
+{
+ QToolButton* anCancelBtn = findChild<QToolButton*>(PROP_PANEL_CANCEL);
+ return anCancelBtn->isEnabled();
+}
+
+void XGUI_PropertyPanel::setEditingMode(bool isEditing)
+{
+ ModuleBase_IPropertyPanel::setEditingMode(isEditing);
+ foreach(ModuleBase_ModelWidget* aWgt, myWidgets) {
+ aWgt->setEditingMode(isEditing);
+ }
+}
+
+void XGUI_PropertyPanel::setupActions(XGUI_ActionsMgr* theMgr)
+{
+ QStringList aButtonNames;
+ aButtonNames << PROP_PANEL_OK << PROP_PANEL_CANCEL << PROP_PANEL_HELP;
+ QList<XGUI_ActionsMgr::OperationStateActionId> aActionIds;
+ aActionIds << XGUI_ActionsMgr::Accept << XGUI_ActionsMgr::Abort << XGUI_ActionsMgr::Help;
+ for (int i = 0; i < aButtonNames.size(); ++i) {
+ QToolButton* aBtn = findChild<QToolButton*>(aButtonNames.at(i));
+ QAction* anAct = theMgr->operationStateAction(aActionIds.at(i));
+ aBtn->setDefaultAction(anAct);
+ }
+}
+
+ModuleBase_ModelWidget* XGUI_PropertyPanel::preselectionWidget() const
+{
+ return myPreselectionWidget;