From 87d7ff7e518c103f4319f7395e6491cd2e9406a5 Mon Sep 17 00:00:00 2001 From: nds Date: Fri, 30 Oct 2015 19:02:37 +0300 Subject: [PATCH] Simplification of the code: it removes focusNextPrevChild processing. It is not enough to emit signal about focus change here because it can be changed by mouse click in another control. It is not processed in this method. The same functionality(to store modified value on focus lost) is realized in ::deactivate() of the model widget and processEnter method of the widge. --- src/ModuleBase/ModuleBase_DoubleSpinBox.cpp | 9 --------- src/ModuleBase/ModuleBase_DoubleSpinBox.h | 10 ---------- src/ModuleBase/ModuleBase_ModelWidget.h | 3 --- src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp | 3 --- src/ModuleBase/ModuleBase_WidgetExprEditor.cpp | 12 ------------ src/ModuleBase/ModuleBase_WidgetExprEditor.h | 11 ++--------- src/ModuleBase/ModuleBase_WidgetIntValue.cpp | 3 --- src/PartSet/PartSet_WidgetPoint2d.cpp | 13 ++++--------- src/PartSet/PartSet_WidgetPoint2d.h | 4 ++-- src/XGUI/XGUI_PropertyPanel.cpp | 9 +-------- src/XGUI/XGUI_PropertyPanel.h | 2 -- 11 files changed, 9 insertions(+), 70 deletions(-) diff --git a/src/ModuleBase/ModuleBase_DoubleSpinBox.cpp b/src/ModuleBase/ModuleBase_DoubleSpinBox.cpp index 114a27d6c..081ca65b3 100644 --- a/src/ModuleBase/ModuleBase_DoubleSpinBox.cpp +++ b/src/ModuleBase/ModuleBase_DoubleSpinBox.cpp @@ -217,15 +217,6 @@ void ModuleBase_DoubleSpinBox::keyPressEvent(QKeyEvent *theEvent) QDoubleSpinBox::keyPressEvent(theEvent); } -bool ModuleBase_DoubleSpinBox::focusNextPrevChild(bool theIsNext) -{ - //myIsModified = false; - - //emit valueStored(); - emit focusNextPrev(); - return QDoubleSpinBox::focusNextPrevChild(theIsNext); -} - /*! \brief Perform \a steps increment/decrement steps. diff --git a/src/ModuleBase/ModuleBase_DoubleSpinBox.h b/src/ModuleBase/ModuleBase_DoubleSpinBox.h index 51c36cc70..e1fd8bd61 100644 --- a/src/ModuleBase/ModuleBase_DoubleSpinBox.h +++ b/src/ModuleBase/ModuleBase_DoubleSpinBox.h @@ -60,11 +60,6 @@ Q_OBJECT /// \return the previous value bool enableKeyPressEvent(const bool& theEnable); -signals: - /// A signal that is emitted by the "Tab" key event. It is emitted before the key is processed. - void focusNextPrev(); - void valueStored(); - protected slots: /// Called on text changed virtual void onTextChanged(const QString&); @@ -75,11 +70,6 @@ signals: QString removeTrailingZeroes(const QString&) const; virtual void keyPressEvent(QKeyEvent* theEvent); - /// The parent method that processes the "Tab"/"SHIF + Tab" keyboard events - /// Emits a signal about focus change - /// If theIsNext is true, this function searches forward, if next is false, it searches backward. - virtual bool focusNextPrevChild(bool theIsNext); - private: // boolen flag whether the key event is emitted. The default value is false bool myIsEmitKeyPressEvent; diff --git a/src/ModuleBase/ModuleBase_ModelWidget.h b/src/ModuleBase/ModuleBase_ModelWidget.h index 0942fcce7..dd2c9edd3 100644 --- a/src/ModuleBase/ModuleBase_ModelWidget.h +++ b/src/ModuleBase/ModuleBase_ModelWidget.h @@ -204,9 +204,6 @@ signals: /// The signal about value state modification void valueStateChanged(int theState); - void focusNextPrev(); - void valueStored(); - protected: /// Sets default value of widget. Normally, widget should fetch this value /// from the xml. However, some widgets derived widgets could define it diff --git a/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp b/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp index 5f6415893..4e6ce242c 100644 --- a/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp +++ b/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp @@ -86,10 +86,7 @@ ModuleBase_WidgetDoubleValue::ModuleBase_WidgetDoubleValue(QWidget* theParent, myLabel->setToolTip(aTTip); aControlLay->addRow(myLabel, mySpinBox); - // Apply widget value change by enter/tab event. - connect(mySpinBox, SIGNAL(valueStored()), this, SIGNAL(valuesChanged())); connect(mySpinBox, SIGNAL(valueChanged(const QString&)), this, SIGNAL(valuesModified())); - connect(mySpinBox, SIGNAL(focusNextPrev()), this, SIGNAL(focusNextPrev())); } ModuleBase_WidgetDoubleValue::~ModuleBase_WidgetDoubleValue() diff --git a/src/ModuleBase/ModuleBase_WidgetExprEditor.cpp b/src/ModuleBase/ModuleBase_WidgetExprEditor.cpp index 624e04744..4c37116b2 100644 --- a/src/ModuleBase/ModuleBase_WidgetExprEditor.cpp +++ b/src/ModuleBase/ModuleBase_WidgetExprEditor.cpp @@ -212,13 +212,6 @@ void ExpressionEditor::paintEvent( QPaintEvent* theEvent ) } } -bool ExpressionEditor::focusNextPrevChild(bool theIsNext) -{ - //emit valueStored(); - //emit focusNextPrev(); - return QPlainTextEdit::focusNextPrevChild(theIsNext); -} - void ExpressionEditor::onTextChanged() { myIsModified = true; @@ -248,12 +241,7 @@ ModuleBase_WidgetExprEditor::ModuleBase_WidgetExprEditor( QWidget* theParent, this->setLayout(aMainLay); connect(myEditor, SIGNAL(valueModified()), this, SIGNAL(valuesModified())); - //connect(myEditor, SIGNAL(valueStored()), this, SLOT(onTextChanged())); - //connect(myEditor, SIGNAL(focusNextPrev()), this, SIGNAL(focusNextPrev())); - connect(myEditor, SIGNAL(keyReleased(QKeyEvent*)), this, SIGNAL(keyReleased(QKeyEvent*))); - /// The signal about key release on the control, that corresponds to the attribute - /// \param theEvent key release event } ModuleBase_WidgetExprEditor::~ModuleBase_WidgetExprEditor() diff --git a/src/ModuleBase/ModuleBase_WidgetExprEditor.h b/src/ModuleBase/ModuleBase_WidgetExprEditor.h index 0e81242bb..d51f45805 100644 --- a/src/ModuleBase/ModuleBase_WidgetExprEditor.h +++ b/src/ModuleBase/ModuleBase_WidgetExprEditor.h @@ -64,10 +64,8 @@ class ExpressionEditor: public QPlainTextEdit void onTextChanged(); signals: + /// The signal about text change in the text editor void valueModified(); - /// A signal that is emitted by the "Tab" key event. It is emitted before the key is processed. - //void valueStored(); - //void focusNextPrev(); /// The signal about key release on the control, that corresponds to the attribute /// \param theEvent key release event @@ -89,12 +87,7 @@ signals: /// Redefinition of virtual method virtual void paintEvent( QPaintEvent* ); - /// The parent method that processes the "Tab"/"SHIF + Tab" keyboard events - /// Emits a signal about focus change - /// If theIsNext is true, this function searches forward, if next is false, it searches backward. - virtual bool focusNextPrevChild(bool theIsNext); - - private: +private: QStringListModel* myCompleterModel; QCompleter* myCompleter; bool myCompletedAndSelected; diff --git a/src/ModuleBase/ModuleBase_WidgetIntValue.cpp b/src/ModuleBase/ModuleBase_WidgetIntValue.cpp index d9c2a64b2..02c1d6613 100644 --- a/src/ModuleBase/ModuleBase_WidgetIntValue.cpp +++ b/src/ModuleBase/ModuleBase_WidgetIntValue.cpp @@ -85,10 +85,7 @@ ModuleBase_WidgetIntValue::ModuleBase_WidgetIntValue(QWidget* theParent, myLabel->setToolTip(aTTip); aControlLay->addRow(myLabel, mySpinBox); - // Apply widget value change by enter/tab event. - connect(mySpinBox, SIGNAL(valueStored()), this, SIGNAL(valuesChanged())); connect(mySpinBox, SIGNAL(valueChanged(int)), this, SIGNAL(valuesModified())); - 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 6cd4fb22a..66a67efc4 100644 --- a/src/PartSet/PartSet_WidgetPoint2d.cpp +++ b/src/PartSet/PartSet_WidgetPoint2d.cpp @@ -86,10 +86,7 @@ PartSet_WidgetPoint2D::PartSet_WidgetPoint2D(QWidget* theParent, myXSpin->setToolTip(tr("X")); aGroupLay->addWidget(myXSpin, 0, 1); - // Apply widget value change by enter/tab event. - connect(myXSpin, SIGNAL(valueStored()), this, SLOT(onValuesChanged())); connect(myXSpin, SIGNAL(valueChanged(const QString&)), this, SIGNAL(valuesModified())); - connect(myXSpin, SIGNAL(focusNextPrev()), this, SIGNAL(focusNextPrev())); } { QLabel* aLabel = new QLabel(myGroupBox); @@ -102,10 +99,7 @@ PartSet_WidgetPoint2D::PartSet_WidgetPoint2D(QWidget* theParent, myYSpin->setToolTip(tr("Y")); aGroupLay->addWidget(myYSpin, 1, 1); - // Apply widget value change by enter/tab event. - connect(myYSpin, SIGNAL(valueStored()), this, SLOT(onValuesChanged())); connect(myYSpin, SIGNAL(valueChanged(const QString&)), this, SIGNAL(valuesModified())); - connect(myYSpin, SIGNAL(focusNextPrev()), this, SIGNAL(focusNextPrev())); } QVBoxLayout* aLayout = new QVBoxLayout(this); ModuleBase_Tools::zeroMargins(aLayout); @@ -461,17 +455,18 @@ bool PartSet_WidgetPoint2D::isFeatureContainsPoint(const FeaturePtr& theFeature, return aPointIsFound; } -void PartSet_WidgetPoint2D::onValuesChanged() +/*void PartSet_WidgetPoint2D::onValuesChanged() { emit valuesChanged(); -} +}*/ bool PartSet_WidgetPoint2D::processEnter() { bool isModified = myXSpin->isModified() || myYSpin->isModified(); if (isModified) { bool isXModified = myXSpin->isModified(); - onValuesChanged(); + emit valuesChanged(); + //onValuesChanged(); myXSpin->clearModified(); myYSpin->clearModified(); if (isXModified) diff --git a/src/PartSet/PartSet_WidgetPoint2d.h b/src/PartSet/PartSet_WidgetPoint2d.h index b4e45af67..d5f87eca0 100755 --- a/src/PartSet/PartSet_WidgetPoint2d.h +++ b/src/PartSet/PartSet_WidgetPoint2d.h @@ -124,9 +124,9 @@ protected: /// \return boolean result bool isFeatureContainsPoint(const FeaturePtr& theFeature, double theX, double theY); -private slots: +//private slots: /// Process value changed event - void onValuesChanged(); + //void onValuesChanged(); private: /// Returns point 2d from selected vertex diff --git a/src/XGUI/XGUI_PropertyPanel.cpp b/src/XGUI/XGUI_PropertyPanel.cpp index 097d9145d..f447f24a2 100755 --- a/src/XGUI/XGUI_PropertyPanel.cpp +++ b/src/XGUI/XGUI_PropertyPanel.cpp @@ -118,8 +118,6 @@ void XGUI_PropertyPanel::setModelWidgets(const QList& t this, SLOT(activateNextWidget(ModuleBase_ModelWidget*))); connect(aWidget, SIGNAL(keyReleased(QKeyEvent*)), this, SIGNAL(keyReleased(QKeyEvent*))); - //connect(aWidget, SIGNAL(focusNextPrev()), - // this, SLOT(onFocusNextPrev())); } } @@ -170,11 +168,6 @@ void XGUI_PropertyPanel::activateNextWidget(ModuleBase_ModelWidget* theWidget) activateWidget(NULL); } -void XGUI_PropertyPanel::onFocusNextPrev() -{ - setActiveWidget(NULL); -} - bool XGUI_PropertyPanel::focusNextPrevChild(bool theIsNext) { // it wraps the Tabs clicking to follow in the chain: @@ -246,7 +239,7 @@ void XGUI_PropertyPanel::activateWidget(ModuleBase_ModelWidget* theWidget) emit widgetActivated(myActiveWidget); } else if (!isEditingMode()) { emit noMoreWidgets(); - setFocusOnOkButton(); + //setFocusOnOkButton(); } } } diff --git a/src/XGUI/XGUI_PropertyPanel.h b/src/XGUI/XGUI_PropertyPanel.h index 9e6c38592..374ea5efc 100644 --- a/src/XGUI/XGUI_PropertyPanel.h +++ b/src/XGUI/XGUI_PropertyPanel.h @@ -118,8 +118,6 @@ public slots: */ virtual void activateWidget(ModuleBase_ModelWidget* theWidget); - void onFocusNextPrev(); - protected: /// Makes the widget active, deactivate the previous, activate and hightlight the given one /// \param theWidget a widget -- 2.39.2