Salome HOME
Remove extra files
[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 ModuleBase_ModelWidget;
18
19 class QAction;
20 class QDialog;
21 class QLabel;
22
23 /**
24  * \class XGUI_ErrorMgr
25  * \ingroup GUI
26  * \brief Class of Errors manager object
27  */
28 class XGUI_EXPORT XGUI_ErrorMgr : public ModuleBase_IErrorMgr
29 {
30   Q_OBJECT
31 public:
32   /// Constructor
33   /// \param theParent a parent object
34   /// \param theWorkshop a workshop object
35   XGUI_ErrorMgr(QObject* theParent, ModuleBase_IWorkshop* theWorkshop);
36   /// Virtual destructor
37   virtual ~XGUI_ErrorMgr();
38
39   /// Update actions for the given feature
40   /// \param theFeature a feature
41   void updateActions(const FeaturePtr& theFeature);
42
43   /// Update enable state of AcceptAll action if the feature uses it
44   /// \param theFeature a feature
45   void updateAcceptAllAction(const FeaturePtr& theFeature);
46
47   /// Returns true if the apply is enabled for the current feature
48   bool isApplyEnabled() const;
49
50 protected slots:
51   /// Reimplemented from ModuleBase_ErrorMgr::onWidgetChanged().
52   virtual void onWidgetChanged();
53
54 private:
55   /// Stores initial values of accept/accept all tool/status tip to internal containers
56   void storeInitialActionValues();
57
58   /// It disables the propety panel Accept action if the error message is not empty
59   /// The message is set to the header tool tip.
60   /// \param theAction an action to be changed
61   /// \param theError an error state
62   void updateAcceptActionState(const QString& theError);
63
64   /// It updates the tool tip of the widget controls according to the widget error
65   /// \param theWidget a widget
66   /// \param theError an error state
67   void updateToolTip(ModuleBase_ModelWidget* theWidget, const QString& theError);
68
69   /// Returns casted workshop
70   XGUI_Workshop* workshop() const;
71
72   /// Returns an active widget of the current operation
73   /// \return the widget or zero
74   ModuleBase_ModelWidget* activeWidget() const;
75
76 private:
77   ModuleBase_IWorkshop* myWorkshop; /// workshop
78   QDialog* myErrorDialog; /// contains the error message
79   QLabel* myErrorLabel; /// contains an error information
80   QString myAcceptToolTip; /// cached tool tip value for enabled Accept action
81   QString myAcceptAllToolTip; /// cached tool tip value for enabled AcceptAll action
82   QString myAcceptStatusTip; /// cached status tip value for enabled Accept action
83   QString myAcceptAllStatusTip; /// cached status tip value for enabled AcceptAll action
84 };
85
86 #endif // XGUI_ErrorMgr_H