X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModuleBase%2FModuleBase_WidgetExprEditor.cpp;h=1fb6bf1aa8e735af11c357b3f5df4ff3abe6bac1;hb=423f6b0a08a86d5e47115b87603cddeae4468b49;hp=4c37116b2a9fb15487402461c43ca7bdb0d283cf;hpb=f34fba2433c87ccdf824df0dc8c34099054b1715;p=modules%2Fshaper.git diff --git a/src/ModuleBase/ModuleBase_WidgetExprEditor.cpp b/src/ModuleBase/ModuleBase_WidgetExprEditor.cpp index 4c37116b2..1fb6bf1aa 100644 --- a/src/ModuleBase/ModuleBase_WidgetExprEditor.cpp +++ b/src/ModuleBase/ModuleBase_WidgetExprEditor.cpp @@ -36,7 +36,7 @@ #include ExpressionEditor::ExpressionEditor(QWidget* theParent) -: QPlainTextEdit(theParent), myCompletedAndSelected(false), myIsModified(false) +: QPlainTextEdit(theParent), myCompletedAndSelected(false) { myCompleter = new QCompleter(this); myCompleter->setWidget(this); @@ -114,8 +114,6 @@ void ExpressionEditor::performCompletion(const QString& theCompletionPrefix) void ExpressionEditor::keyPressEvent(QKeyEvent* theEvent) { - bool anIsModified = myIsModified; - if (myCompletedAndSelected && handledCompletedAndSelected(theEvent)) return; myCompletedAndSelected = false; @@ -137,7 +135,7 @@ void ExpressionEditor::keyPressEvent(QKeyEvent* theEvent) switch (theEvent->key()) { case Qt::Key_Enter: case Qt::Key_Return: - emit keyReleased(theEvent); + emit keyReleased(this, theEvent); // do not react to the Enter key, the property panel processes it return; break; @@ -173,16 +171,6 @@ QString ExpressionEditor::placeHolderText() const return myPlaceHolderText; } -bool ExpressionEditor::isModified() const -{ - return myIsModified; -} - -void ExpressionEditor::clearModified() -{ - myIsModified = false; -} - void ExpressionEditor::paintEvent( QPaintEvent* theEvent ) { QPlainTextEdit::paintEvent( theEvent ); @@ -206,7 +194,8 @@ void ExpressionEditor::paintEvent( QPaintEvent* theEvent ) QPen anOldpen = aPainter.pen(); aPainter.setPen( aColor ); lineRect.adjust(minLB, 0, 0, 0); - QString elidedText = aFontMetrics.elidedText( myPlaceHolderText, Qt::ElideRight, lineRect.width() ); + QString elidedText = + aFontMetrics.elidedText( myPlaceHolderText, Qt::ElideRight, lineRect.width() ); aPainter.drawText( lineRect, va, elidedText ); aPainter.setPen( anOldpen ); } @@ -214,16 +203,14 @@ void ExpressionEditor::paintEvent( QPaintEvent* theEvent ) void ExpressionEditor::onTextChanged() { - myIsModified = true; emit valueModified(); } ModuleBase_WidgetExprEditor::ModuleBase_WidgetExprEditor( QWidget* theParent, const Config_WidgetAPI* theData, - const std::string& theParentId, const std::string& thePlaceHolder ) - : ModuleBase_ModelWidget(theParent, theData, theParentId) +: ModuleBase_ModelWidget(theParent, theData) { QVBoxLayout* aMainLay = new QVBoxLayout(this); ModuleBase_Tools::adjustMargins(aMainLay); @@ -241,20 +228,30 @@ ModuleBase_WidgetExprEditor::ModuleBase_WidgetExprEditor( QWidget* theParent, this->setLayout(aMainLay); connect(myEditor, SIGNAL(valueModified()), this, SIGNAL(valuesModified())); - connect(myEditor, SIGNAL(keyReleased(QKeyEvent*)), this, SIGNAL(keyReleased(QKeyEvent*))); + connect(myEditor, SIGNAL(keyReleased(QObject*, QKeyEvent*)), + this, SIGNAL(keyReleased(QObject*, QKeyEvent*))); } ModuleBase_WidgetExprEditor::~ModuleBase_WidgetExprEditor() { } +void ModuleBase_WidgetExprEditor::activateCustom() +{ + ModuleBase_ModelWidget::activateCustom(); + + QStringList aParameters; + ModuleBase_Tools::getParameters(aParameters); + myEditor->setCompletionList(aParameters); +} + void ModuleBase_WidgetExprEditor::initializeValueByActivate() { } -bool ModuleBase_WidgetExprEditor::storeValueCustom() const +bool ModuleBase_WidgetExprEditor::storeValueCustom() { - // A rare case when plugin was not loaded. + // A rare case when plugin was not loaded. if(!myFeature) return false; DataPtr aData = myFeature->data(); @@ -287,7 +284,7 @@ bool ModuleBase_WidgetExprEditor::storeValueCustom() const bool ModuleBase_WidgetExprEditor::restoreValueCustom() { - // A rare case when plugin was not loaded. + // A rare case when plugin was not loaded. if(!myFeature) return false; DataPtr aData = myFeature->data(); @@ -314,10 +311,9 @@ QList ModuleBase_WidgetExprEditor::getControls() const bool ModuleBase_WidgetExprEditor::processEnter() { - bool isModified = myEditor->isModified(); + bool isModified = getValueState() == ModifiedInPP; if (isModified) { emit valuesChanged(); - myEditor->clearModified(); myEditor->selectAll(); } return isModified;