Salome HOME
Issues #2173, #2169: processing focus in widget by SHAPER loop (instead of Qt loop...
[modules/shaper.git] / src / ModuleBase / ModuleBase_WidgetEditor.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        ModuleBase_WidgetEditor.h
4 // Created:     25 Apr 2014
5 // Author:      Natalia ERMOLAEVA
6
7 #ifndef ModuleBase_WidgetEditor_H
8 #define ModuleBase_WidgetEditor_H
9
10 #include <ModuleBase.h>
11 #include "ModuleBase_WidgetDoubleValue.h"
12
13 #include <QObject>
14 #include <QStringList>
15
16 class ModelAPI_Feature;
17 class QDialog;
18 class QLineEdit;
19
20 /**\class ModuleBase_WidgetEditor
21  * \ingroup GUI
22  * \brief Custom widget. An abstract class to be redefined to fill with some GUI controls
23  */
24 class MODULEBASE_EXPORT ModuleBase_WidgetEditor : public ModuleBase_WidgetDoubleValue
25 {
26 Q_OBJECT
27  public:
28   /// Constructor
29   /// \param theParent the parent object
30   /// \param theData the widget configuation. The attribute of the model widget is obtained from
31   ModuleBase_WidgetEditor(QWidget* theParent, const Config_WidgetAPI* theData);
32   /// Constructor
33   /// \param theParent the parent object
34   /// \param theAttribute The attribute of the model widget
35   ModuleBase_WidgetEditor(QWidget* theParent, const std::string& theAttribute);
36
37   /// Destructor
38   virtual ~ModuleBase_WidgetEditor();
39
40   /// Set focus to the first control of the current widget.
41   /// The focus policy of the control is checked.
42   /// If the widget has the NonFocus focus policy, it is skipped.
43   /// \return the state whether the widget can accept the focus
44   virtual bool focusTo();
45
46   /// Shous popup window under cursor for data editing
47   /// \param theSendSignals a flag whether the signals should be sent or the value
48   /// is to be applyed directly
49   /// \return true if the editor value is accepted
50   bool showPopupEditor(const bool theSendSignals = true);
51
52   /// Set current cursor position
53   /// \param theX the X coordinate
54   /// \param theY the Y coordinate
55   void setCursorPosition(const int theX, const int theY);
56
57   /// Returns true if the event is processed.
58   virtual bool processEnter();
59
60 private:
61   /// Show editor
62   /// \param theOutValue a result value
63   /// \param theOutText a result text
64   /// \return true if the editor value is accepted
65   bool editedValue(double& theOutValue, QString& theOutText);
66
67  private:
68    ///< the current widget feature
69    FeaturePtr myFeature;
70
71    ///< the kinds of possible features
72    QStringList myFeatureKinds;
73
74    int myXPosition, myYPosition;
75
76    QDialog* myEditorDialog;
77 };
78
79 #endif