1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
4 * ModuleBase_WidgetExprEditor.h
6 * Created on: Oct 8, 2014
10 #ifndef MODULEBASE_WIDGETEXPREDITOR_H_
11 #define MODULEBASE_WIDGETEXPREDITOR_H_
13 #include <ModuleBase.h>
14 #include <ModuleBase_ModelWidget.h>
19 #include <QStringList>
20 #include <QPlainTextEdit>
23 class QStringListModel;
26 class ExpressionEditor: public QPlainTextEdit
31 explicit ExpressionEditor(QWidget* theParent = 0);
32 virtual ~ExpressionEditor();
34 void setCompletionList(QStringList&);
37 void insertCompletion(const QString&, bool isSingleWord = false);
38 void performCompletion();
41 void performCompletion(const QString& theCompletionPrefix);
42 virtual void keyPressEvent(QKeyEvent* theEvent);
43 bool handledCompletedAndSelected(QKeyEvent* theEvent);
46 QStringListModel* myCompleterModel;
47 QCompleter* myCompleter;
48 bool myCompletedAndSelected;
55 class MODULEBASE_EXPORT ModuleBase_WidgetExprEditor : public ModuleBase_ModelWidget
60 /// \param theParent the parent object
61 /// \param theData the widget configuration.
62 /// \param theParentId is Id of a parent of the current attribute
63 ModuleBase_WidgetExprEditor(QWidget* theParent,
64 const Config_WidgetAPI* theData,
65 const std::string& theParentId);
66 virtual ~ModuleBase_WidgetExprEditor();
68 virtual bool restoreValue();
70 virtual QList<QWidget*> getControls() const;
73 /// A slot for processing text changed event
77 /// Saves the internal parameters to the given feature
78 /// \return True in success
79 virtual bool storeValueCustom() const;
82 /// A line edit control
83 QLabel* myResultLabel;
84 ExpressionEditor* myEditor;
87 #endif /* MODULEBASE_WIDGETEXPREDITOR_H_ */