X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModuleBase%2FModuleBase_WidgetEditor.cpp;h=07c59651de695bdd6de1d735644fe43719c550b2;hb=676e0178fdedf35ba607ef9d4f02d871dd06fa28;hp=694e5a809deb39a7074c0f82b885a31578af6297;hpb=e6aea428c7da7751e753eac36b99e16b7e3166e4;p=modules%2Fshaper.git diff --git a/src/ModuleBase/ModuleBase_WidgetEditor.cpp b/src/ModuleBase/ModuleBase_WidgetEditor.cpp index 694e5a809..07c59651d 100644 --- a/src/ModuleBase/ModuleBase_WidgetEditor.cpp +++ b/src/ModuleBase/ModuleBase_WidgetEditor.cpp @@ -1,14 +1,18 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + // File: ModuleBase_WidgetEditor.cpp // Created: 25 Apr 2014 // Author: Natalia ERMOLAEVA #include +#include +#include #include #include #include -#include +#include #include #include @@ -22,18 +26,13 @@ #include #include #include -#include +#include ModuleBase_WidgetEditor::ModuleBase_WidgetEditor(QWidget* theParent, - const Config_WidgetAPI* theData) -: ModuleBase_WidgetDoubleValue(theParent, theData) -{ -} - -ModuleBase_WidgetEditor::ModuleBase_WidgetEditor(QWidget* theParent, const std::string& theAttribute) -: ModuleBase_WidgetDoubleValue(theParent, 0) + const Config_WidgetAPI* theData, + const std::string& theParentId) + : ModuleBase_WidgetDoubleValue(theParent, theData, theParentId) { - setAttributeID(theAttribute); } ModuleBase_WidgetEditor::~ModuleBase_WidgetEditor() @@ -45,9 +44,10 @@ double editedValue(double theValue, bool& isDone) QDialog aDlg; aDlg.setWindowFlags(Qt::FramelessWindowHint); QHBoxLayout* aLay = new QHBoxLayout(&aDlg); - aLay->setContentsMargins(0,0,0,0); + ModuleBase_Tools::zeroMargins(aLay); QLineEdit* aEditor = new QLineEdit(QString::number(theValue), &aDlg); + aEditor->setValidator(new QDoubleValidator(aEditor)); QObject::connect(aEditor, SIGNAL(returnPressed()), &aDlg, SLOT(accept())); aLay->addWidget(aEditor); @@ -61,22 +61,31 @@ double editedValue(double theValue, bool& isDone) return aValue; } -void ModuleBase_WidgetEditor::focusTo() +bool ModuleBase_WidgetEditor::focusTo() +{ + // We can not launch here modal process for value editing because + // it can be called on other focusOutWidget event and will block it + QTimer::singleShot(1, this, SLOT(showPopupEditor())); + return true; +} + +void ModuleBase_WidgetEditor::showPopupEditor() { + // White while all events will be processed + QApplication::processEvents(); double aValue = mySpinBox->value(); bool isDone; aValue = editedValue(aValue, isDone); if (isDone) { - bool isBlocked = mySpinBox->blockSignals(true); - mySpinBox->setValue(aValue); - mySpinBox->blockSignals(isBlocked); + ModuleBase_Tools::setSpinValue(mySpinBox, aValue); } emit valuesChanged(); emit focusOutWidget(this); } -void ModuleBase_WidgetEditor::editFeatureValue(FeaturePtr theFeature, const std::string theAttribute) +void ModuleBase_WidgetEditor::editFeatureValue(FeaturePtr theFeature, + const std::string theAttribute) { DataPtr aData = theFeature->data(); AttributeDoublePtr aRef = aData->real(theAttribute);