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>
18 #include <QStringList>
19 #include <QPlainTextEdit>
22 class QStringListModel;
25 class ExpressionEditor: public QPlainTextEdit
30 explicit ExpressionEditor(QWidget* theParent = 0);
31 virtual ~ExpressionEditor();
33 void setCompletionList(QStringList&);
36 void insertCompletion(const QString&, bool isSingleWord = false);
37 void performCompletion();
40 void performCompletion(const QString& theCompletionPrefix);
41 virtual void keyPressEvent(QKeyEvent* theEvent);
42 bool handledCompletedAndSelected(QKeyEvent* theEvent);
45 QStringListModel* myCompleterModel;
46 QCompleter* myCompleter;
47 bool myCompletedAndSelected;
54 class MODULEBASE_EXPORT ModuleBase_WidgetExprEditor : public ModuleBase_ModelWidget
59 /// \param theParent the parent object
60 /// \param theData the widget configuration.
61 /// \param theParentId is Id of a parent of the current attribute
62 ModuleBase_WidgetExprEditor(QWidget* theParent,
63 const Config_WidgetAPI* theData,
64 const std::string& theParentId);
65 virtual ~ModuleBase_WidgetExprEditor();
67 virtual bool restoreValue();
69 virtual QList<QWidget*> getControls() const;
72 /// A slot for processing text changed event
76 /// Saves the internal parameters to the given feature
77 /// \return True in success
78 virtual bool storeValueCustom() const;
81 /// A line edit control
82 ExpressionEditor* myEditor;
85 #endif /* MODULEBASE_WIDGETEXPREDITOR_H_ */