+//**************************************************************
+QWidget* ModuleBase_ModelWidget::getControlAcceptingFocus(const bool isFirst)
+{
+ QWidget* aControl = 0;
+
+ QList<QWidget*> aControls = getControls();
+ int aSize = aControls.size();
+
+ if (isFirst) {
+ for (int i = 0; i < aSize && !aControl; i++) {
+ if (aControls[i]->focusPolicy() != Qt::NoFocus)
+ aControl = aControls[i];
+ }
+ }
+ else {
+ for (int i = aSize - 1; i >= 0 && !aControl; i--) {
+ if (aControls[i]->focusPolicy() != Qt::NoFocus)
+ aControl = aControls[i];
+ }
+ }
+ return aControl;
+}
+
+//**************************************************************
+void ModuleBase_ModelWidget::setDefaultValue(const std::string& theValue)
+{
+ myDefaultValue = theValue;
+}
+
+//**************************************************************
+bool ModuleBase_ModelWidget::storeValue()
+{
+ setValueState(Stored);
+
+ emit beforeValuesChanged();
+ bool isDone = false;
+ // value is stored only in creation mode and in edition if there is not
+ // XML flag prohibited modification in edit mode(macro feature circle/arc)
+ if (!isEditingMode() || isModifiedInEdit().empty())
+ isDone = storeValueCustom();
+ else {
+ /// store value in an alternative attribute if possible(attribute has the same type)
+ std::string aWidgetAttribute = attributeID();
+ myAttributeID = isModifiedInEdit();
+ storeValueCustom();
+ myAttributeID = aWidgetAttribute;
+ // operation will be restarted but if isDone == true, PagedContainer will try to set focus
+ // to the current widget, but will be already deleted
+ isDone = false;
+ }
+
+ emit afterValuesChanged();
+
+ return isDone;
+}
+#ifdef DEBUG_VALUE_STATE
+
+//**************************************************************
+std::string getDebugInfo(const ModuleBase_ModelWidget::ValueState& theState)
+{
+ std::string anInfo;
+ switch (theState) {
+ case ModuleBase_ModelWidget::Stored: anInfo = "Stored "; break;
+ case ModuleBase_ModelWidget::ModifiedInPP: anInfo = "ModifiedInPP "; break;
+ case ModuleBase_ModelWidget::ModifiedInViewer: anInfo = "ModifiedInViewer"; break;
+ case ModuleBase_ModelWidget::Reset: anInfo = "Reset "; break;
+ default: break;
+ }
+ return anInfo;
+}
+#endif
+
+//**************************************************************
+ModuleBase_ModelWidget::ValueState ModuleBase_ModelWidget::setValueState
+ (const ModuleBase_ModelWidget::ValueState& theState)
+{
+ ValueState aState = myState;
+
+ if (myState != theState && !myIsValueStateBlocked) {
+#ifdef DEBUG_VALUE_STATE
+ qDebug(QString("setValueState: previous state = %1,\t new state = %2")
+ .arg(getDebugInfo(myState).c_str())
+ .arg(getDebugInfo(theState).c_str()).toStdString().c_str());
+#endif
+ myState = theState;
+ emit valueStateChanged(aState);
+ }
+ return aState;
+}
+
+//**************************************************************
+bool ModuleBase_ModelWidget::blockValueState(const bool theBlocked)
+{
+ bool isBlocked = myIsValueStateBlocked;
+ myIsValueStateBlocked = theBlocked;
+ return isBlocked;
+}
+
+//**************************************************************
+bool ModuleBase_ModelWidget::restoreValue()
+{
+ emit beforeValuesRestored();
+ bool isDone = restoreValueCustom();
+ emit afterValuesRestored();
+
+ return isDone;
+}
+
+//**************************************************************
+void ModuleBase_ModelWidget::updateObject(ObjectPtr theObject)
+{
+ if (!myFlushUpdateBlocked) {
+#ifdef DEBUG_WIDGET_INSTANCE
+ qDebug("ModuleBase_ModelWidget::updateObject");
+#endif
+ ModuleBase_Tools::flushUpdated(theObject);
+ emit objectUpdated();
+ }
+}
+
+//**************************************************************
+bool ModuleBase_ModelWidget::canProcessAction(ModuleBase_ActionType theActionType,
+ bool& isActionEnabled)
+{
+ isActionEnabled = false;
+ switch (theActionType) {
+ case ActionEnter: return false;
+ case ActionEscape: return false;
+ case ActionDelete: return true;
+ case ActionSelection: return true;
+ case ActionUndo:
+ case ActionRedo:
+ default:
+ return false;
+ }
+}
+
+//**************************************************************
+bool ModuleBase_ModelWidget::processAction(ModuleBase_ActionType theActionType,
+ const ActionParamPtr& theParam)
+{
+ switch (theActionType) {
+ case ActionEnter:
+ return processEnter();
+ case ActionEscape:
+ return processEscape();
+ case ActionDelete:
+ return processDelete();
+ case ActionSelection:
+ processSelection();
+ case ActionUndo:
+ case ActionRedo:
+ default:
+ return false;
+ }
+}
+
+//**************************************************************
+bool ModuleBase_ModelWidget::processEnter()
+{
+ return false;
+}
+
+//**************************************************************
+bool ModuleBase_ModelWidget::processEscape()
+{
+ return false;
+}
+
+//**************************************************************
+bool ModuleBase_ModelWidget::processDelete()
+{
+ // we consider that model objects eats delete key in order to
+ // do nothing by for example symbol delete in line edit or spin box
+ return true;
+}
+
+//**************************************************************
+bool ModuleBase_ModelWidget::processSelection()
+{
+ return false;
+}
+
+//**************************************************************