Salome HOME
projects
/
modules
/
shaper.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
WidgetMultiSelector preparation to use ModelAPI_AttributeRefAttrList.
[modules/shaper.git]
/
src
/
ModuleBase
/
ModuleBase_WidgetExprEditor.cpp
diff --git
a/src/ModuleBase/ModuleBase_WidgetExprEditor.cpp
b/src/ModuleBase/ModuleBase_WidgetExprEditor.cpp
index b8e8ca60e4872d29582e0b222d4bb4d61bbb5c51..c0e683f89751ae8fd1da7e52c00b5059919ba923 100644
(file)
--- a/
src/ModuleBase/ModuleBase_WidgetExprEditor.cpp
+++ b/
src/ModuleBase/ModuleBase_WidgetExprEditor.cpp
@@
-52,6
+52,10
@@
ExpressionEditor::ExpressionEditor(QWidget* theParent)
this, SLOT(insertCompletion(const QString&)));
(void) new QShortcut(QKeySequence(tr("Ctrl+Space", "Complete")),
this, SLOT(performCompletion()));
this, SLOT(insertCompletion(const QString&)));
(void) new QShortcut(QKeySequence(tr("Ctrl+Space", "Complete")),
this, SLOT(performCompletion()));
+
+ connect(this, SIGNAL(textChanged()), this, SLOT(onTextChanged()));
+
+ setTabChangesFocus(true);
}
ExpressionEditor::~ExpressionEditor()
}
ExpressionEditor::~ExpressionEditor()
@@
-117,16
+121,28
@@
void ExpressionEditor::keyPressEvent(QKeyEvent* theEvent)
switch (theEvent->key()) {
case Qt::Key_Up:
case Qt::Key_Down:
switch (theEvent->key()) {
case Qt::Key_Up:
case Qt::Key_Down:
+ case Qt::Key_Escape:
case Qt::Key_Enter:
case Qt::Key_Return:
case Qt::Key_Enter:
case Qt::Key_Return:
- case Qt::Key_Escape:
theEvent->ignore();
theEvent->ignore();
-
return;
+ return;
default:
myCompleter->popup()->hide();
break;
}
}
default:
myCompleter->popup()->hide();
break;
}
}
+ else {
+ switch (theEvent->key()) {
+ case Qt::Key_Enter:
+ case Qt::Key_Return:
+ emit keyReleased(theEvent);
+ // do not react to the Enter key, the property panel processes it
+ return;
+ break;
+ default:
+ break;
+ }
+ }
QPlainTextEdit::keyPressEvent(theEvent);
}
QPlainTextEdit::keyPressEvent(theEvent);
}
@@
-184,6
+200,10
@@
void ExpressionEditor::paintEvent( QPaintEvent* theEvent )
}
}
}
}
+void ExpressionEditor::onTextChanged()
+{
+ emit valueModified();
+}
ModuleBase_WidgetExprEditor::ModuleBase_WidgetExprEditor( QWidget* theParent,
ModuleBase_WidgetExprEditor::ModuleBase_WidgetExprEditor( QWidget* theParent,
@@
-207,13
+227,18
@@
ModuleBase_WidgetExprEditor::ModuleBase_WidgetExprEditor( QWidget* theParent,
aMainLay->addWidget(myEditor);
this->setLayout(aMainLay);
aMainLay->addWidget(myEditor);
this->setLayout(aMainLay);
- connect(myEditor, SIGNAL(textChanged()), this, SLOT(onTextChanged()));
+ connect(myEditor, SIGNAL(valueModified()), this, SIGNAL(valuesModified()));
+ connect(myEditor, SIGNAL(keyReleased(QKeyEvent*)), this, SIGNAL(keyReleased(QKeyEvent*)));
}
ModuleBase_WidgetExprEditor::~ModuleBase_WidgetExprEditor()
{
}
}
ModuleBase_WidgetExprEditor::~ModuleBase_WidgetExprEditor()
{
}
+void ModuleBase_WidgetExprEditor::initializeValueByActivate()
+{
+}
+
bool ModuleBase_WidgetExprEditor::storeValueCustom() const
{
// A rare case when plugin was not loaded.
bool ModuleBase_WidgetExprEditor::storeValueCustom() const
{
// A rare case when plugin was not loaded.
@@
-221,13
+246,14
@@
bool ModuleBase_WidgetExprEditor::storeValueCustom() const
return false;
DataPtr aData = myFeature->data();
AttributeStringPtr aStringAttr = aData->string(attributeID());
return false;
DataPtr aData = myFeature->data();
AttributeStringPtr aStringAttr = aData->string(attributeID());
+
QString aWidgetValue = myEditor->toPlainText();
aStringAttr->setValue(aWidgetValue.toStdString());
updateObject(myFeature);
// Try to get the value
QString aStateMsg;
QString aWidgetValue = myEditor->toPlainText();
aStringAttr->setValue(aWidgetValue.toStdString());
updateObject(myFeature);
// Try to get the value
QString aStateMsg;
- std::string anErrorMessage = myFeature->
error
();
+ std::string anErrorMessage = myFeature->
string("ExpressionError")->value
();
if (anErrorMessage.empty()) {
ResultParameterPtr aParam =
std::dynamic_pointer_cast<ModelAPI_ResultParameter>(myFeature->firstResult());
if (anErrorMessage.empty()) {
ResultParameterPtr aParam =
std::dynamic_pointer_cast<ModelAPI_ResultParameter>(myFeature->firstResult());
@@
-240,7
+266,7
@@
bool ModuleBase_WidgetExprEditor::storeValueCustom() const
}
}
} else {
}
}
} else {
- aStateMsg = QString::fromStdString(anErrorMessage);
+ aStateMsg =
"Error: " +
QString::fromStdString(anErrorMessage);
}
myResultLabel->setText(aStateMsg);
return true;
}
myResultLabel->setText(aStateMsg);
return true;
@@
-273,7
+299,17
@@
QList<QWidget*> ModuleBase_WidgetExprEditor::getControls() const
return result;
}
return result;
}
+bool ModuleBase_WidgetExprEditor::processEnter()
+{
+ bool isModified = getValueState() == ModifiedInPP;
+ if (isModified) {
+ emit valuesChanged();
+ myEditor->selectAll();
+ }
+ return isModified;
+}
+
void ModuleBase_WidgetExprEditor::onTextChanged()
{
void ModuleBase_WidgetExprEditor::onTextChanged()
{
-
storeValue
();
+
emit valuesChanged
();
}
}