Salome HOME
Copyright update 2022
[modules/shaper.git] / src / XGUI / XGUI_ErrorMgr.h
1 // Copyright (C) 2014-2022  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #ifndef XGUI_ErrorMgr_H
21 #define XGUI_ErrorMgr_H
22
23 #include "XGUI.h"
24
25 #include <ModuleBase_IErrorMgr.h>
26 #include <ModelAPI_Feature.h>
27
28 class XGUI_Workshop;
29 class ModuleBase_IWorkshop;
30 class ModuleBase_ModelWidget;
31
32 class QAction;
33 class QDialog;
34 class QLabel;
35
36 /**
37  * \class XGUI_ErrorMgr
38  * \ingroup GUI
39  * \brief Class of Errors manager object
40  */
41 class XGUI_EXPORT XGUI_ErrorMgr : public ModuleBase_IErrorMgr
42 {
43   Q_OBJECT
44 public:
45   /// Constructor
46   /// \param theParent a parent object
47   /// \param theWorkshop a workshop object
48   XGUI_ErrorMgr(QObject* theParent, ModuleBase_IWorkshop* theWorkshop);
49   /// Virtual destructor
50   virtual ~XGUI_ErrorMgr();
51
52   /// Update actions for the given feature
53   /// \param theFeature a feature
54   virtual void updateActions(const FeaturePtr& theFeature);
55
56   /// Update enable state of AcceptAll action if the feature uses it
57   /// \param theFeature a feature
58   void updateAcceptAllAction(const FeaturePtr& theFeature);
59
60   /// Returns true if the apply is enabled for the current feature
61   bool isApplyEnabled() const;
62
63 protected slots:
64   /// Reimplemented from ModuleBase_ErrorMgr::onWidgetChanged().
65   virtual void onWidgetChanged();
66
67 private:
68   /// Stores initial values of accept/accept all tool/status tip to internal containers
69   void storeInitialActionValues();
70
71   /// It disables the propety panel Accept action if the error message is not empty
72   /// The message is set to the header tool tip.
73   /// \param theAction an action to be changed
74   /// \param theError an error state
75   void updateAcceptActionState(const QString& theError);
76
77   /// It updates the tool tip of the widget controls according to the widget error
78   /// \param theWidget a widget
79   /// \param theError an error state
80   void updateToolTip(ModuleBase_ModelWidget* theWidget, const QString& theError);
81
82   /// Returns casted workshop
83   XGUI_Workshop* workshop() const;
84
85   /// Returns an active widget of the current operation
86   /// \return the widget or zero
87   ModuleBase_ModelWidget* activeWidget() const;
88
89 private:
90   ModuleBase_IWorkshop* myWorkshop; /// workshop
91   QDialog* myErrorDialog; /// contains the error message
92   QLabel* myErrorLabel; /// contains an error information
93   QString myAcceptToolTip; /// cached tool tip value for enabled Accept action
94   QString myAcceptAllToolTip; /// cached tool tip value for enabled AcceptAll action
95   QString myAcceptStatusTip; /// cached status tip value for enabled Accept action
96   QString myAcceptAllStatusTip; /// cached status tip value for enabled AcceptAll action
97 };
98
99 #endif // XGUI_ErrorMgr_H