ModuleBase_FilterFactory.h
ModuleBase_FilterValidated.h
ModuleBase_IDocumentDataModel.h
+ ModuleBase_IErrorMgr.h
ModuleBase_IModule.h
ModuleBase_IPrefMgr.h
ModuleBase_IPropertyPanel.h
ModuleBase_FilterFactory.cpp
ModuleBase_FilterValidated.cpp
ModuleBase_IDocumentDataModel.cpp
+ ModuleBase_IErrorMgr.cpp
ModuleBase_IModule.cpp
ModuleBase_IPrefMgr.cpp
ModuleBase_IPropertyPanel.cpp
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: ModuleBase_ErrorMgr.cpp
+// Created: 22 July 2015
+// Author: Sergey POKHODENKO
+
+#include "ModuleBase_IErrorMgr.h"
+
+#include "ModuleBase_IPropertyPanel.h"
+#include "ModuleBase_ModelWidget.h"
+
+ModuleBase_IErrorMgr::ModuleBase_IErrorMgr(QObject* theParent /*= 0*/)
+ : QObject(theParent)
+ , myPropertyPanel(NULL)
+{
+
+}
+
+ModuleBase_IErrorMgr::~ModuleBase_IErrorMgr()
+{
+
+}
+
+void ModuleBase_IErrorMgr::setPropertyPanel(ModuleBase_IPropertyPanel* theProp)
+{
+ myPropertyPanel = theProp;
+
+ if (myPropertyPanel) {
+ foreach(const ModuleBase_ModelWidget* aWgt, myPropertyPanel->modelWidgets()) {
+ connect(aWgt, SIGNAL(afterValuesChanged()), this, SLOT(onWidgetChanged()));
+ connect(aWgt, SIGNAL(afterValuesRestored()), this, SLOT(onWidgetChanged()));
+ }
+ }
+}
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: ModuleBase_IErrorMgr.h
+// Created: 22 July 2015
+// Author: Sergey POKHODENKO
+
+#ifndef ModuleBase_IErrorMgr_H
+#define ModuleBase_IErrorMgr_H
+
+#include "ModuleBase.h"
+#include <QObject>
+
+class ModuleBase_IPropertyPanel;
+
+class MODULEBASE_EXPORT ModuleBase_IErrorMgr : public QObject
+{
+ Q_OBJECT
+public:
+ /// Default constructor
+ ModuleBase_IErrorMgr(QObject* theParent = 0);
+ /// Virtual destructor
+ virtual ~ModuleBase_IErrorMgr();
+
+ /// \brief Set property pane to the operation
+ /// \param theProp a property panel instance
+ virtual void setPropertyPanel(ModuleBase_IPropertyPanel* theProp);
+
+ /// \return Currently installed property panel
+ ModuleBase_IPropertyPanel* propertyPanel() const { return myPropertyPanel; }
+
+public slots:
+ /// SLOT, that is called after the operation is validated and feature validation errors have changed.
+ virtual void onValidationStateChanged() = 0;
+
+protected slots:
+ /// Process values changed event for processing feature attribute validation errors.
+ virtual void onWidgetChanged() = 0;
+
+protected:
+ /// Access to property panel
+ ModuleBase_IPropertyPanel* myPropertyPanel;
+};
+
+#endif // ModuleBase_IErrorMgr_H
\ No newline at end of file
/// \param theParent is a parent of the property panel
ModuleBase_IPropertyPanel(QWidget* theParent);
+ /// Returns header widget
+ virtual QWidget* headerWidget() const = 0;
+
/// Returns currently active widget
virtual ModuleBase_ModelWidget* activeWidget() const = 0;
XGUI_DataModel.h
XGUI_Displayer.h
XGUI_ErrorDialog.h
+ XGUI_ErrorMgr.h
XGUI_HistoryMenu.h
XGUI_ModuleConnector.h
XGUI_ObjectsBrowser.h
XGUI_DataModel.cpp
XGUI_Displayer.cpp
XGUI_ErrorDialog.cpp
+ XGUI_ErrorMgr.cpp
XGUI_HistoryMenu.cpp
XGUI_ModuleConnector.cpp
XGUI_ObjectsBrowser.cpp
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: XGUI_ErrorMgr.cpp
+// Created: 22 July 2015
+// Author: Sergey POKHODENKO
+
+#include "XGUI_ErrorMgr.h"
+
+#include "XGUI_OperationMgr.h"
+
+#include <ModuleBase_IPropertyPanel.h>
+#include <ModuleBase_ModelWidget.h>
+
+#include <ModelAPI_Attribute.h>
+#include <ModelAPI_Session.h>
+#include <ModelAPI_Validator.h>
+
+#include <QLabel>
+
+XGUI_ErrorMgr::XGUI_ErrorMgr(QObject* theParent /*= 0*/)
+ : ModuleBase_IErrorMgr(theParent)
+{
+
+}
+
+XGUI_ErrorMgr::~XGUI_ErrorMgr()
+{
+
+}
+
+const char* toString(ModelAPI_ExecState theExecState)
+{
+#define TO_STRING(__NAME__) case __NAME__: return #__NAME__;
+ switch (theExecState) {
+ TO_STRING(ModelAPI_StateDone)
+ TO_STRING(ModelAPI_StateMustBeUpdated)
+ TO_STRING(ModelAPI_StateExecFailed)
+ TO_STRING(ModelAPI_StateInvalidArgument)
+ TO_STRING(ModelAPI_StateNothing)
+ default: "Unknown ExecState.";
+ }
+#undef TO_STRING
+}
+
+void XGUI_ErrorMgr::onValidationStateChanged()
+{
+ XGUI_OperationMgr* anOperationMgr = dynamic_cast<XGUI_OperationMgr*>(sender());
+ if (!anOperationMgr || !anOperationMgr->currentOperation())
+ return;
+
+ if (!myPropertyPanel)
+ return;
+
+ // get feature
+ FeaturePtr aFeature = anOperationMgr->currentOperation()->feature();
+ if (!aFeature.get())
+ return;
+
+ // set error indication
+ QString anError = QString::fromStdString(aFeature->error());
+ if (anError.isEmpty()) {
+ bool isDone = ( aFeature->data()->execState() == ModelAPI_StateDone
+ || aFeature->data()->execState() == ModelAPI_StateMustBeUpdated );
+ if (!isDone)
+ anError = toString(aFeature->data()->execState());
+ }
+
+ QWidget* aWidget = myPropertyPanel->headerWidget();
+ if (aWidget) {
+ aWidget->setToolTip(anError);
+ aWidget->setStyleSheet(anError.isEmpty() ? "" : "background-color:pink;");
+ }
+}
+
+void XGUI_ErrorMgr::onWidgetChanged()
+{
+ static ModelAPI_ValidatorsFactory* aValidators = ModelAPI_Session::get()->validators();
+
+ ModuleBase_ModelWidget* aModelWidget = dynamic_cast<ModuleBase_ModelWidget*>(sender());
+ if (!aModelWidget || !aModelWidget->feature().get())
+ return;
+
+ std::string anAttributeID = aModelWidget->attributeID();
+ AttributePtr anAttribute = aModelWidget->feature()->attribute(anAttributeID);
+ if (!anAttribute.get())
+ return;
+
+ std::string aValidatorID;
+ std::string anErrorMsg;
+ if (!aValidators->validate(anAttribute, aValidatorID, anErrorMsg)) {
+ if (anErrorMsg.empty())
+ anErrorMsg = "unknown error.";
+ anErrorMsg = "Attribute \"" + anAttributeID + "\" invalidated by \"" + aValidatorID + "\" with error: " + anErrorMsg;
+ }
+
+ QString anError = QString::fromStdString(anErrorMsg);
+ QList<QWidget*> aWidgetList = aModelWidget->getControls();
+ foreach(QWidget* aWidget, aWidgetList) {
+ QLabel* aLabel = qobject_cast<QLabel*>(aWidget);
+ // We won't set the effect to QLabels - it looks ugly
+ if (aLabel) continue;
+
+ // Get the original tool tip of the widget
+ QString aTTip = aWidget->toolTip().section("Errors:\n", 0, 0).trimmed();
+ // Add the error message into the tool tip
+ if (!anError.isEmpty()) {
+ if (!aTTip.isEmpty())
+ aTTip.append('\n');
+ aTTip += "Errors:\n" + anError;
+ }
+ aWidget->setToolTip(aTTip);
+ aWidget->setStyleSheet(anError.isEmpty() ? "" : "background-color:pink;");
+ }
+}
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: XGUI_ErrorMgr.h
+// Created: 22 July 2015
+// Author: Sergey POKHODENKO
+
+#ifndef XGUI_ErrorMgr_H
+#define XGUI_ErrorMgr_H
+
+#include "XGUI.h"
+
+#include <ModuleBase_IErrorMgr.h>
+
+class XGUI_EXPORT XGUI_ErrorMgr : public ModuleBase_IErrorMgr
+{
+ Q_OBJECT
+public:
+ XGUI_ErrorMgr(QObject* theParent = 0);
+ /// Virtual destructor
+ virtual ~XGUI_ErrorMgr();
+
+public slots:
+ /// Reimplemented from ModuleBase_ErrorMgr::onValidationStateChanged().
+ virtual void onValidationStateChanged();
+
+protected slots:
+ /// Reimplemented from ModuleBase_ErrorMgr::onWidgetChanged().
+ virtual void onWidgetChanged();
+};
+
+#endif // XGUI_ErrorMgr_H
\ No newline at end of file
ModuleBase_Tools::zeroMargins(aBtnLay);
aMainLayout->addWidget(aFrm, aPanelRow++, kPanelColumn);
+ myHeaderWidget = aFrm;
+
QStringList aBtnNames;
aBtnNames << QString(PROP_PANEL_HELP)
<< QString(PROP_PANEL_OK)
virtual ~XGUI_PropertyPanel();
+ /// Returns header widget
+ virtual QWidget* headerWidget() const { return myHeaderWidget; }
+
/// Returns main widget of the property panel, which children will be created
/// by WidgetFactory using the XML definition
ModuleBase_PageBase* contentWidget();
*/
virtual void activateWidget(ModuleBase_ModelWidget* theWidget);
+ protected:
+ QWidget* myHeaderWidget;
+
private:
ModuleBase_PageWidget* myPanelPage;
QList<ModuleBase_ModelWidget*> myWidgets;
#include "XGUI_ContextMenuMgr.h"
#include "XGUI_Displayer.h"
#include "XGUI_ErrorDialog.h"
+#include "XGUI_ErrorMgr.h"
#include "XGUI_ModuleConnector.h"
#include "XGUI_ObjectsBrowser.h"
#include "XGUI_OperationMgr.h"
myOperationMgr = new XGUI_OperationMgr(this, 0);
myActionsMgr = new XGUI_ActionsMgr(this);
myErrorDlg = new XGUI_ErrorDialog(QApplication::desktop());
+ myErrorMgr = new XGUI_ErrorMgr(this);
myContextMenuMgr = new XGUI_ContextMenuMgr(this);
connect(myContextMenuMgr, SIGNAL(actionTriggered(const QString&, bool)), this,
SLOT(onContextMenuCommand(const QString&, bool)));
SLOT(onOperationCommitted(ModuleBase_Operation*)));
connect(myOperationMgr, SIGNAL(operationAborted(ModuleBase_Operation*)),
SLOT(onOperationAborted(ModuleBase_Operation*)));
+ connect(myOperationMgr, SIGNAL(validationStateChanged(bool)),
+ myErrorMgr, SLOT(onValidationStateChanged()));
+
if (myMainWindow)
connect(myMainWindow, SIGNAL(exitKeySequence()), SLOT(onExit()));
connect(this, SIGNAL(errorOccurred(const QString&)), myErrorDlg, SLOT(addError(const QString&)));
myModule->propertyPanelDefined(theOperation);
myPropertyPanel->setWindowTitle(theOperation->getDescription()->description());
+
+ myErrorMgr->setPropertyPanel(myPropertyPanel);
}
/*
class XGUI_ContextMenuMgr;
class XGUI_Displayer;
class XGUI_ErrorDialog;
+class XGUI_ErrorMgr;
class XGUI_ModuleConnector;
class XGUI_ObjectsBrowser;
class XGUI_OperationMgr;
private:
AppElements_MainWindow* myMainWindow;
ModuleBase_IModule* myModule;
+ XGUI_ErrorMgr* myErrorMgr;
XGUI_ObjectsBrowser* myObjectBrowser;
XGUI_PropertyPanel* myPropertyPanel;
XGUI_SelectionMgr* mySelector;