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