Salome HOME
Merge branch 'python_parametric_api' of https://git.salome-platform.org/git/modules...
[modules/shaper.git] / src / XGUI / XGUI_ErrorMgr.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        XGUI_ErrorMgr.h
4 // Created:     22 July 2015
5 // Author:      Sergey POKHODENKO
6
7 #ifndef XGUI_ErrorMgr_H
8 #define XGUI_ErrorMgr_H
9
10 #include "XGUI.h"
11
12 #include <ModuleBase_IErrorMgr.h>
13 #include <ModelAPI_Feature.h>
14
15 class XGUI_Workshop;
16 class ModuleBase_IWorkshop;
17 class QAction;
18 class QDialog;
19 class QLabel;
20
21 /**
22  * \class XGUI_ErrorMgr
23  * \ingroup GUI
24  * \brief Class of Errors manager object
25  */
26 class XGUI_EXPORT XGUI_ErrorMgr : public ModuleBase_IErrorMgr
27 {
28   Q_OBJECT
29 public:
30   /// Constructor
31   /// \param theParent a parent object
32   /// \param theWorkshop a workshop object
33   XGUI_ErrorMgr(QObject* theParent, ModuleBase_IWorkshop* theWorkshop);
34   /// Virtual destructor
35   virtual ~XGUI_ErrorMgr();
36
37   /// Update actions for the given feature
38   /// \param theFeature a feature
39   void updateActions(const FeaturePtr& theFeature);
40
41   /// Update enable state of AcceptAll action if the feature uses it
42   /// \param theFeature a feature
43   void updateAcceptAllAction(const FeaturePtr& theFeature);
44
45   /// Return true if the feature has no error. If there is an error and the action
46   /// is not valid, the dialog with the error information is shown.
47   /// \param theAction an action, which is checked on validity
48   /// \param theFeature a feature that provides error information
49   bool canProcessClick(QAction* theAction, const FeaturePtr& theFeature);
50
51 public slots:
52   /// Reimplemented from ModuleBase_ErrorMgr::onValidationStateChanged().
53   //virtual void onValidationStateChanged();
54
55 protected slots:
56   /// Reimplemented from ModuleBase_ErrorMgr::onWidgetChanged().
57   virtual void onWidgetChanged();
58
59 private:
60   /// It updates the action state according to the given parameter
61   /// \param theAction an action to be changed
62   /// \param theFeature an feature that corresponds to the action
63   void updateActionState(QAction* theAction, const FeaturePtr& theFeature);
64
65   /// Returns the feature error message
66   /// \param theFeature a feature
67   /// \return the error message
68   //QString getFeatureError(const FeaturePtr& theFeature) const;
69
70   /// Returns casted workshop
71   XGUI_Workshop* workshop() const;
72
73 private:
74   ModuleBase_IWorkshop* myWorkshop;
75   QDialog* myErrorDialog; /// contains the error message
76   QLabel* myErrorLabel; /// contains an error information
77 };
78
79 #endif // XGUI_ErrorMgr_H