From: nds Date: Fri, 6 Nov 2015 11:49:23 +0000 (+0300) Subject: Enter processing on integer field. X-Git-Tag: V_2.0.0_alfa1~20 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=5ba2ac3f39478507bd781082adb879a43d4afe7e;p=modules%2Fshaper.git Enter processing on integer field. --- diff --git a/src/ModuleBase/CMakeLists.txt b/src/ModuleBase/CMakeLists.txt index 5d6e49ef8..0969deb10 100644 --- a/src/ModuleBase/CMakeLists.txt +++ b/src/ModuleBase/CMakeLists.txt @@ -13,6 +13,7 @@ SET(PROJECT_HEADERS ModuleBase_FilterValidated.h ModuleBase_IErrorMgr.h ModuleBase_IModule.h + ModuleBase_IntSpinBox.h ModuleBase_IPrefMgr.h ModuleBase_IPropertyPanel.h ModuleBase_ISelection.h @@ -64,6 +65,7 @@ SET(PROJECT_SOURCES ModuleBase_FilterValidated.cpp ModuleBase_IErrorMgr.cpp ModuleBase_IModule.cpp + ModuleBase_IntSpinBox.cpp ModuleBase_IPrefMgr.cpp ModuleBase_IPropertyPanel.cpp ModuleBase_ISelection.cpp diff --git a/src/ModuleBase/ModuleBase_IntSpinBox.cpp b/src/ModuleBase/ModuleBase_IntSpinBox.cpp new file mode 100755 index 000000000..933cc8455 --- /dev/null +++ b/src/ModuleBase/ModuleBase_IntSpinBox.cpp @@ -0,0 +1,30 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + +// File: ModuleBase_IntSpinBox.cxx +// Author: Natalia ERMOLAEVA +// +#include "ModuleBase_IntSpinBox.h" + +#include + +ModuleBase_IntSpinBox::ModuleBase_IntSpinBox(QWidget* theParent) +: QSpinBox(theParent), + myIsModified(false) +{ + connect(this, SIGNAL(valueChanged(const QString&)), this, SLOT(onValueChanged(const QString&))); +} + +void ModuleBase_IntSpinBox::onValueChanged(const QString& theValue) +{ + myIsModified = true; +} + +bool ModuleBase_IntSpinBox::isModified() const +{ + return myIsModified; +} + +void ModuleBase_IntSpinBox::clearModified() +{ + myIsModified = false; +} diff --git a/src/ModuleBase/ModuleBase_IntSpinBox.h b/src/ModuleBase/ModuleBase_IntSpinBox.h new file mode 100755 index 000000000..2e6d959a4 --- /dev/null +++ b/src/ModuleBase/ModuleBase_IntSpinBox.h @@ -0,0 +1,44 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + +// File: ModuleBase_IntSpinBox.h +// Author: Natalia ERMOLAEVA +// +#ifndef MODULEBASE_INT_SPINBOX_H_ +#define MODULEBASE_INT_SPINBOX_H_ + +#include "ModuleBase.h" + +#include + +class QWidget; +class QKeyEvent; + +/** + * \ingroup GUI + * Enhanced version of the Qt's int spin box. + * It allows to store modified state +*/ +class MODULEBASE_EXPORT ModuleBase_IntSpinBox : public QSpinBox +{ +Q_OBJECT + +public: + explicit ModuleBase_IntSpinBox(QWidget* theParent = 0); + virtual ~ModuleBase_IntSpinBox() {}; + + /// Returns true if the current value is modified by has not been applyed yet + virtual bool isModified() const; + + /// Clears modified state + void clearModified(); + +protected slots: + /// Called on value changed + void onValueChanged(const QString& theValue); + + private: + /// Boolean value whether the spin box content is modified + bool myIsModified; +}; + +#endif diff --git a/src/ModuleBase/ModuleBase_WidgetIntValue.cpp b/src/ModuleBase/ModuleBase_WidgetIntValue.cpp index 02c1d6613..b92d5863f 100644 --- a/src/ModuleBase/ModuleBase_WidgetIntValue.cpp +++ b/src/ModuleBase/ModuleBase_WidgetIntValue.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -22,7 +23,6 @@ #include #include #include -#include #include @@ -48,7 +48,7 @@ ModuleBase_WidgetIntValue::ModuleBase_WidgetIntValue(QWidget* theParent, if (!aLabelIcon.isEmpty()) myLabel->setPixmap(QPixmap(aLabelIcon)); - mySpinBox = new QSpinBox(this); + mySpinBox = new ModuleBase_IntSpinBox(this); QString anObjName = QString::fromStdString(attributeID()); mySpinBox->setObjectName(anObjName); @@ -139,3 +139,14 @@ QList ModuleBase_WidgetIntValue::getControls() const aList.append(mySpinBox); return aList; } + +bool ModuleBase_WidgetIntValue::processEnter() +{ + bool isModified = mySpinBox->isModified(); + if (isModified) { + emit valuesChanged(); + mySpinBox->clearModified(); + mySpinBox->selectAll(); + } + return isModified; +} diff --git a/src/ModuleBase/ModuleBase_WidgetIntValue.h b/src/ModuleBase/ModuleBase_WidgetIntValue.h index 8fd1ef5d8..ffc52d9f9 100644 --- a/src/ModuleBase/ModuleBase_WidgetIntValue.h +++ b/src/ModuleBase/ModuleBase_WidgetIntValue.h @@ -10,11 +10,11 @@ #include "ModuleBase.h" #include "ModuleBase_ModelWidget.h" +class ModuleBase_IntSpinBox; class Config_WidgetAPI; class QWidget; class QLabel; class QTimer; -class QSpinBox; /** * \ingroup GUI @@ -41,6 +41,9 @@ Q_OBJECT /// \return a control list virtual QList getControls() const; + /// Returns true if the event is processed. + virtual bool processEnter(); + protected: /// Saves the internal parameters to the given feature /// \return True in success @@ -59,7 +62,7 @@ protected: QLabel* myLabel; /// Input value control - QSpinBox* mySpinBox; + ModuleBase_IntSpinBox* mySpinBox; }; #endif