+
+void XGUI_PropertyPanel::activateNextWidget(ModuleBase_ModelWidget* theWidget)
+{
+ // TO CHECK: Editing operation does not have automatical activation of widgets
+ if (isEditingMode()) {
+ activateWidget(NULL);
+ return;
+ }
+ ModuleBase_ModelWidget* aNextWidget = 0;
+ QList<ModuleBase_ModelWidget*>::const_iterator anIt = myWidgets.begin(), aLast = myWidgets.end();
+ bool isFoundWidget = false;
+ for (; anIt != aLast && !aNextWidget; anIt++) {
+ if (isFoundWidget || !theWidget) {
+ if ((*anIt)->focusTo()) {
+ aNextWidget = *anIt;
+ }
+ }
+ isFoundWidget = (*anIt) == theWidget;
+ }
+ // Normaly focusTo is enough to activate widget
+ // here is a special case on mouse click in the viewer
+ //if(aNextWidget == NULL) {
+ activateWidget(aNextWidget);
+ //}
+}
+
+void XGUI_PropertyPanel::setStretchEnabled(bool isEnabled)
+{
+ if (myMainLayout->count() == 0)
+ return;
+ int aStretchIdx = myMainLayout->count() - 1;
+ bool hasStretch = myMainLayout->itemAt(aStretchIdx)->spacerItem() != NULL;
+ QLayoutItem* aChild;
+ if (isEnabled) {
+ if (!hasStretch) myMainLayout->addStretch(1);
+ } else if (hasStretch) {
+ aChild = myMainLayout->takeAt(aStretchIdx);
+ delete aChild;
+ }
+}
+
+void XGUI_PropertyPanel::activateNextWidget()
+{
+ activateNextWidget(myActiveWidget);
+}
+
+void XGUI_PropertyPanel::setAcceptEnabled(bool isEnabled)
+{
+ QPushButton* anOkBtn = findChild<QPushButton*>(PROP_PANEL_OK);
+ anOkBtn->setEnabled(isEnabled);
+}
+
+void XGUI_PropertyPanel::activateWidget(ModuleBase_ModelWidget* theWidget)
+{
+ // Avoid activation of already actve widget. It could happen on focusIn event many times
+ if (theWidget == myActiveWidget)
+ return;
+ if(myActiveWidget) {
+ myActiveWidget->deactivate();
+ myActiveWidget->setHighlighted(false);
+ }
+ if(theWidget) {
+ theWidget->activate();
+ theWidget->setHighlighted(true);
+ }
+ myActiveWidget = theWidget;
+ if (myActiveWidget)
+ emit widgetActivated(theWidget);
+ else if (!isEditingMode())
+ emit noMoreWidgets();
+}
+
+void XGUI_PropertyPanel::setOkEnabled(bool theEnabled)
+{
+ QPushButton* anOkBtn = findChild<QPushButton*>(PROP_PANEL_OK);
+ anOkBtn->setEnabled(theEnabled);
+}
+
+bool XGUI_PropertyPanel::isOkEnabled() const
+{
+ QPushButton* anOkBtn = findChild<QPushButton*>(PROP_PANEL_OK);
+ return anOkBtn->isEnabled();
+}
+
+void XGUI_PropertyPanel::setCancelEnabled(bool theEnabled)
+{
+ QPushButton* anCancelBtn = findChild<QPushButton*>(PROP_PANEL_CANCEL);
+ anCancelBtn->setEnabled(theEnabled);
+}
+
+bool XGUI_PropertyPanel::isCancelEnabled() const
+{
+ QPushButton* anCancelBtn = findChild<QPushButton*>(PROP_PANEL_CANCEL);
+ return anCancelBtn->isEnabled();
+}
+
+