ModuleBase_FilterValidated.h
ModuleBase_IErrorMgr.h
ModuleBase_IModule.h
+ ModuleBase_IntSpinBox.h
ModuleBase_IPrefMgr.h
ModuleBase_IPropertyPanel.h
ModuleBase_ISelection.h
ModuleBase_FilterValidated.cpp
ModuleBase_IErrorMgr.cpp
ModuleBase_IModule.cpp
+ ModuleBase_IntSpinBox.cpp
ModuleBase_IPrefMgr.cpp
ModuleBase_IPropertyPanel.cpp
ModuleBase_ISelection.cpp
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: ModuleBase_IntSpinBox.cxx
+// Author: Natalia ERMOLAEVA
+//
+#include "ModuleBase_IntSpinBox.h"
+
+#include <QKeyEvent>
+
+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;
+}
--- /dev/null
+// 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 <QSpinBox>
+
+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
#include <ModuleBase_WidgetIntValue.h>
#include <ModuleBase_ParamSpinBox.h>
#include <ModuleBase_Tools.h>
+#include <ModuleBase_IntSpinBox.h>
#include <ModelAPI_AttributeInteger.h>
#include <ModelAPI_Data.h>
#include <QLabel>
#include <QEvent>
#include <QTimer>
-#include <QSpinBox>
#include <math.h>
if (!aLabelIcon.isEmpty())
myLabel->setPixmap(QPixmap(aLabelIcon));
- mySpinBox = new QSpinBox(this);
+ mySpinBox = new ModuleBase_IntSpinBox(this);
QString anObjName = QString::fromStdString(attributeID());
mySpinBox->setObjectName(anObjName);
aList.append(mySpinBox);
return aList;
}
+
+bool ModuleBase_WidgetIntValue::processEnter()
+{
+ bool isModified = mySpinBox->isModified();
+ if (isModified) {
+ emit valuesChanged();
+ mySpinBox->clearModified();
+ mySpinBox->selectAll();
+ }
+ return isModified;
+}
#include "ModuleBase.h"
#include "ModuleBase_ModelWidget.h"
+class ModuleBase_IntSpinBox;
class Config_WidgetAPI;
class QWidget;
class QLabel;
class QTimer;
-class QSpinBox;
/**
* \ingroup GUI
/// \return a control list
virtual QList<QWidget*> 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
QLabel* myLabel;
/// Input value control
- QSpinBox* mySpinBox;
+ ModuleBase_IntSpinBox* mySpinBox;
};
#endif