From af2167011bf0bbd0f0922fd3ece14a2f413803a3 Mon Sep 17 00:00:00 2001 From: nds Date: Fri, 30 Oct 2015 11:44:07 +0300 Subject: [PATCH] Simplification of the code --- src/ModuleBase/ModuleBase_DoubleSpinBox.cpp | 6 ------ src/ModuleBase/ModuleBase_DoubleSpinBox.h | 1 - .../ModuleBase_OperationFeature.cpp | 2 -- .../ModuleBase_WidgetDoubleValue.cpp | 8 -------- .../ModuleBase_WidgetExprEditor.cpp | 3 --- src/ModuleBase/ModuleBase_WidgetExprEditor.h | 1 - src/ModuleBase/ModuleBase_WidgetIntValue.cpp | 9 ++------- src/PartSet/PartSet_WidgetPoint2d.cpp | 13 ------------- src/PartSet/PartSet_WidgetPoint2dDistance.cpp | 19 ------------------- src/PartSet/PartSet_WidgetPoint2dDistance.h | 4 ---- 10 files changed, 2 insertions(+), 64 deletions(-) diff --git a/src/ModuleBase/ModuleBase_DoubleSpinBox.cpp b/src/ModuleBase/ModuleBase_DoubleSpinBox.cpp index 5cd665673..94387b2ec 100644 --- a/src/ModuleBase/ModuleBase_DoubleSpinBox.cpp +++ b/src/ModuleBase/ModuleBase_DoubleSpinBox.cpp @@ -80,7 +80,6 @@ ModuleBase_DoubleSpinBox::ModuleBase_DoubleSpinBox(QWidget* theParent, int thePr SLOT(onTextChanged( const QString& ))); connect(this, SIGNAL(valueChanged(const QString&)), this, SLOT(onValueChanged(const QString&))); - //connect(this, SIGNAL(editingFinished()), this, SLOT(onEditingFinished())); } /*! @@ -345,11 +344,6 @@ void ModuleBase_DoubleSpinBox::onValueChanged(const QString& theValue) myIsModified = true; } -void ModuleBase_DoubleSpinBox::onEditingFinished() -{ - //myIsModified = false; -} - bool ModuleBase_DoubleSpinBox::isModified() const { return myIsModified; diff --git a/src/ModuleBase/ModuleBase_DoubleSpinBox.h b/src/ModuleBase/ModuleBase_DoubleSpinBox.h index d98957b14..51c36cc70 100644 --- a/src/ModuleBase/ModuleBase_DoubleSpinBox.h +++ b/src/ModuleBase/ModuleBase_DoubleSpinBox.h @@ -69,7 +69,6 @@ signals: /// Called on text changed virtual void onTextChanged(const QString&); void onValueChanged(const QString& theValue); - void onEditingFinished(); protected: /// Removes extra trailing zero symbols diff --git a/src/ModuleBase/ModuleBase_OperationFeature.cpp b/src/ModuleBase/ModuleBase_OperationFeature.cpp index 39bdd4e38..8048ff9f5 100755 --- a/src/ModuleBase/ModuleBase_OperationFeature.cpp +++ b/src/ModuleBase/ModuleBase_OperationFeature.cpp @@ -38,8 +38,6 @@ #include #endif -#define APPLY_BY_ENTER_OR_TAB - ModuleBase_OperationFeature::ModuleBase_OperationFeature(const QString& theId, QObject* theParent) : ModuleBase_Operation(theId, theParent), myIsEditing(false) diff --git a/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp b/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp index 9cd6797fc..5f6415893 100644 --- a/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp +++ b/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp @@ -31,8 +31,6 @@ #include #endif -#define APPLY_BY_ENTER_OR_TAB - ModuleBase_WidgetDoubleValue::ModuleBase_WidgetDoubleValue(QWidget* theParent, const Config_WidgetAPI* theData, const std::string& theParentId) @@ -88,16 +86,10 @@ ModuleBase_WidgetDoubleValue::ModuleBase_WidgetDoubleValue(QWidget* theParent, myLabel->setToolTip(aTTip); aControlLay->addRow(myLabel, mySpinBox); -#ifdef APPLY_BY_ENTER_OR_TAB // Apply widget value change by enter/tab event. - //connect(mySpinBox, SIGNAL(editingFinished()), this, SIGNAL(valuesChanged())); connect(mySpinBox, SIGNAL(valueStored()), this, SIGNAL(valuesChanged())); connect(mySpinBox, SIGNAL(valueChanged(const QString&)), this, SIGNAL(valuesModified())); connect(mySpinBox, SIGNAL(focusNextPrev()), this, SIGNAL(focusNextPrev())); - -#else - connect(mySpinBox, SIGNAL(valueChanged(const QString&)), this, SIGNAL(valuesChanged())); -#endif } ModuleBase_WidgetDoubleValue::~ModuleBase_WidgetDoubleValue() diff --git a/src/ModuleBase/ModuleBase_WidgetExprEditor.cpp b/src/ModuleBase/ModuleBase_WidgetExprEditor.cpp index b11bd6714..3e040c4d3 100644 --- a/src/ModuleBase/ModuleBase_WidgetExprEditor.cpp +++ b/src/ModuleBase/ModuleBase_WidgetExprEditor.cpp @@ -214,8 +214,6 @@ void ExpressionEditor::paintEvent( QPaintEvent* theEvent ) bool ExpressionEditor::focusNextPrevChild(bool theIsNext) { - if (myIsModified) - emit editingFinished(); emit valueStored(); emit focusNextPrev(); return QPlainTextEdit::focusNextPrevChild(theIsNext); @@ -250,7 +248,6 @@ ModuleBase_WidgetExprEditor::ModuleBase_WidgetExprEditor( QWidget* theParent, this->setLayout(aMainLay); connect(myEditor, SIGNAL(valueModified()), this, SIGNAL(valuesModified())); - //connect(myEditor, SIGNAL(editingFinished()), this, SLOT(onTextChanged())); connect(myEditor, SIGNAL(valueStored()), this, SLOT(onTextChanged())); connect(myEditor, SIGNAL(focusNextPrev()), this, SIGNAL(focusNextPrev())); diff --git a/src/ModuleBase/ModuleBase_WidgetExprEditor.h b/src/ModuleBase/ModuleBase_WidgetExprEditor.h index 69f36b46c..67d6453d6 100644 --- a/src/ModuleBase/ModuleBase_WidgetExprEditor.h +++ b/src/ModuleBase/ModuleBase_WidgetExprEditor.h @@ -64,7 +64,6 @@ class ExpressionEditor: public QPlainTextEdit void onTextChanged(); signals: - void editingFinished(); void valueModified(); /// A signal that is emitted by the "Tab" key event. It is emitted before the key is processed. void valueStored(); diff --git a/src/ModuleBase/ModuleBase_WidgetIntValue.cpp b/src/ModuleBase/ModuleBase_WidgetIntValue.cpp index cb6986301..d9c2a64b2 100644 --- a/src/ModuleBase/ModuleBase_WidgetIntValue.cpp +++ b/src/ModuleBase/ModuleBase_WidgetIntValue.cpp @@ -34,8 +34,6 @@ #include #endif -#define APPLY_BY_ENTER_OR_TAB - ModuleBase_WidgetIntValue::ModuleBase_WidgetIntValue(QWidget* theParent, const Config_WidgetAPI* theData, const std::string& theParentId) @@ -87,13 +85,10 @@ ModuleBase_WidgetIntValue::ModuleBase_WidgetIntValue(QWidget* theParent, myLabel->setToolTip(aTTip); aControlLay->addRow(myLabel, mySpinBox); -#ifdef APPLY_BY_ENTER_OR_TAB // Apply widget value change by enter/tab event. - connect(mySpinBox, SIGNAL(editingFinished()), this, SIGNAL(valuesChanged())); + connect(mySpinBox, SIGNAL(valueStored()), this, SIGNAL(valuesChanged())); connect(mySpinBox, SIGNAL(valueChanged(int)), this, SIGNAL(valuesModified())); -#else - connect(mySpinBox, SIGNAL(valueChanged(int)), this, SIGNAL(valuesChanged())); -#endif + connect(mySpinBox, SIGNAL(focusNextPrev()), this, SIGNAL(focusNextPrev())); } ModuleBase_WidgetIntValue::~ModuleBase_WidgetIntValue() diff --git a/src/PartSet/PartSet_WidgetPoint2d.cpp b/src/PartSet/PartSet_WidgetPoint2d.cpp index 8f62484fb..6cd4fb22a 100644 --- a/src/PartSet/PartSet_WidgetPoint2d.cpp +++ b/src/PartSet/PartSet_WidgetPoint2d.cpp @@ -51,8 +51,6 @@ const double MaxCoordinate = 1e12; static QStringList MyFeaturesForCoincedence; -#define APPLY_BY_ENTER_OR_TAB - PartSet_WidgetPoint2D::PartSet_WidgetPoint2D(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop, const Config_WidgetAPI* theData, @@ -88,16 +86,10 @@ PartSet_WidgetPoint2D::PartSet_WidgetPoint2D(QWidget* theParent, myXSpin->setToolTip(tr("X")); aGroupLay->addWidget(myXSpin, 0, 1); -#ifdef APPLY_BY_ENTER_OR_TAB // Apply widget value change by enter/tab event. - //connect(myXSpin, SIGNAL(editingFinished()), this, SLOT(onValuesChanged())); - //connect(myXSpin, SIGNAL(focusNextPrev()), this, SLOT(onValuesChanged())); connect(myXSpin, SIGNAL(valueStored()), this, SLOT(onValuesChanged())); connect(myXSpin, SIGNAL(valueChanged(const QString&)), this, SIGNAL(valuesModified())); connect(myXSpin, SIGNAL(focusNextPrev()), this, SIGNAL(focusNextPrev())); -#else - connect(myXSpin, SIGNAL(valueChanged(const QString&)), this, SLOT(onValuesChanged())); -#endif } { QLabel* aLabel = new QLabel(myGroupBox); @@ -110,15 +102,10 @@ PartSet_WidgetPoint2D::PartSet_WidgetPoint2D(QWidget* theParent, myYSpin->setToolTip(tr("Y")); aGroupLay->addWidget(myYSpin, 1, 1); -#ifdef APPLY_BY_ENTER_OR_TAB // Apply widget value change by enter/tab event. - //connect(myYSpin, SIGNAL(editingFinished()), this, SLOT(onValuesChanged())); connect(myYSpin, SIGNAL(valueStored()), this, SLOT(onValuesChanged())); connect(myYSpin, SIGNAL(valueChanged(const QString&)), this, SIGNAL(valuesModified())); connect(myYSpin, SIGNAL(focusNextPrev()), this, SIGNAL(focusNextPrev())); -#else - connect(myYSpin, SIGNAL(valueChanged(const QString&)), this, SLOT(onValuesChanged())); -#endif } QVBoxLayout* aLayout = new QVBoxLayout(this); ModuleBase_Tools::zeroMargins(aLayout); diff --git a/src/PartSet/PartSet_WidgetPoint2dDistance.cpp b/src/PartSet/PartSet_WidgetPoint2dDistance.cpp index d2f1a08aa..ef7bf36c0 100644 --- a/src/PartSet/PartSet_WidgetPoint2dDistance.cpp +++ b/src/PartSet/PartSet_WidgetPoint2dDistance.cpp @@ -22,8 +22,6 @@ #include -#define APPLY_BY_ENTER_OR_TAB - PartSet_WidgetPoint2dDistance::PartSet_WidgetPoint2dDistance(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop, const Config_WidgetAPI* theData, @@ -31,18 +29,6 @@ PartSet_WidgetPoint2dDistance::PartSet_WidgetPoint2dDistance(QWidget* theParent, : ModuleBase_WidgetDoubleValue(theParent, theData, theParentId), myWorkshop(theWorkshop) { myFirstPntName = theData->getProperty("first_point"); - - // Reconnect to local slot -#ifdef APPLY_BY_ENTER_OR_TAB - // Apply widget value change by enter/tab event. - //disconnect(mySpinBox, SIGNAL(editingFinished()), this, SIGNAL(valuesChanged())); - disconnect(mySpinBox, SIGNAL(valueStored()), this, SIGNAL(valuesChanged())); - connect(mySpinBox, SIGNAL(editingFinished()), this, SLOT(onValuesChanged())); - connect(mySpinBox, SIGNAL(valueChanged(double)), this, SIGNAL(valuesModified())); -#else - disconnect(mySpinBox, SIGNAL(valueChanged(double)), this, SIGNAL(valuesChanged())); - connect(mySpinBox, SIGNAL(valueChanged(double)), this, SLOT(onValuesChanged())); -#endif } PartSet_WidgetPoint2dDistance::~PartSet_WidgetPoint2dDistance() @@ -132,11 +118,6 @@ void PartSet_WidgetPoint2dDistance::onMouseMove(ModuleBase_IViewWindow* theWnd, setValueState(ModifiedInViewer); } -void PartSet_WidgetPoint2dDistance::onValuesChanged() -{ - emit valuesChanged(); -} - bool PartSet_WidgetPoint2dDistance::processEnter() { bool isModified = mySpinBox->isModified(); diff --git a/src/PartSet/PartSet_WidgetPoint2dDistance.h b/src/PartSet/PartSet_WidgetPoint2dDistance.h index 472561804..7b350d33e 100644 --- a/src/PartSet/PartSet_WidgetPoint2dDistance.h +++ b/src/PartSet/PartSet_WidgetPoint2dDistance.h @@ -87,10 +87,6 @@ protected: virtual double computeValue(const std::shared_ptr& theFirstPnt, const std::shared_ptr& theCurrentPnt); -private slots: - /// Process values changed event - void onValuesChanged(); - protected: /// A reference to workshop ModuleBase_IWorkshop* myWorkshop; -- 2.39.2