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&);
36 void setPlaceHolderText( const QString& );
37 QString placeHolderText() const;
40 void insertCompletion(const QString&, bool isSingleWord = false);
41 void performCompletion();
44 void performCompletion(const QString& theCompletionPrefix);
45 virtual void keyPressEvent(QKeyEvent* theEvent);
46 bool handledCompletedAndSelected(QKeyEvent* theEvent);
47 virtual void paintEvent( QPaintEvent* );
50 QStringListModel* myCompleterModel;
51 QCompleter* myCompleter;
52 bool myCompletedAndSelected;
53 QString myPlaceHolderText;
60 class MODULEBASE_EXPORT ModuleBase_WidgetExprEditor : public ModuleBase_ModelWidget
65 /// \param theParent the parent object
66 /// \param theData the widget configuration.
67 /// \param theParentId is Id of a parent of the current attribute
68 ModuleBase_WidgetExprEditor( QWidget* theParent,
69 const Config_WidgetAPI* theData,
70 const std::string& theParentId,
71 const std::string& thePlaceHolder );
72 virtual ~ModuleBase_WidgetExprEditor();
74 virtual QList<QWidget*> getControls() const;
77 /// A slot for processing text changed event
81 /// Saves the internal parameters to the given feature
82 /// \return True in success
83 virtual bool storeValueCustom() const;
85 virtual bool restoreValueCustom();
88 /// A line edit control
89 QLabel* myResultLabel;
90 ExpressionEditor* myEditor;
93 #endif /* MODULEBASE_WIDGETEXPREDITOR_H_ */