#include <string>
ExpressionEditor::ExpressionEditor(QWidget* theParent)
-: QPlainTextEdit(theParent), myCompletedAndSelected(false), myIsModified(false)
+: QPlainTextEdit(theParent), myCompletedAndSelected(false)
{
myCompleter = new QCompleter(this);
myCompleter->setWidget(this);
void ExpressionEditor::keyPressEvent(QKeyEvent* theEvent)
{
- bool anIsModified = myIsModified;
-
if (myCompletedAndSelected && handledCompletedAndSelected(theEvent))
return;
myCompletedAndSelected = false;
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;
return myPlaceHolderText;
}
-bool ExpressionEditor::isModified() const
-{
- return myIsModified;
-}
-
-void ExpressionEditor::clearModified()
-{
- myIsModified = false;
-}
-
void ExpressionEditor::paintEvent( QPaintEvent* theEvent )
{
QPlainTextEdit::paintEvent( 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);
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.
if(!myFeature)
bool ModuleBase_WidgetExprEditor::processEnter()
{
- bool isModified = myEditor->isModified();
+ bool isModified = getValueState() == ModifiedInPP;
if (isModified) {
emit valuesChanged();
- myEditor->clearModified();
myEditor->selectAll();
}
return isModified;