Events_Message.h
Events_Listener.h
Events_Loop.h
+ Events_Error.h
)
SET(PROJECT_SOURCES
Events_Message.cpp
Events_Listener.cpp
Events_Loop.cpp
+ Events_Error.cpp
)
ADD_DEFINITIONS(-DEVENTS_EXPORTS)
--- /dev/null
+/*
+ * Events_Error.cpp
+ *
+ * Created on: Apr 28, 2014
+ * Author: sbh
+ */
+
+#include <Events_Error.h>
+#include <Events_Loop.h>
+
+Events_Error::Events_Error(char* theDescription, const void* theSender)
+ : Events_Message(Events_Error::errorID(), theSender)
+{
+ myDescription = theDescription;
+}
+
+Events_Error::~Events_Error()
+{
+}
+
+Events_ID Events_Error::errorID()
+{
+ Events_Loop* aLoop = Events_Loop::loop();
+ return aLoop->eventByName("ApplicationError");
+}
+
+char* Events_Error::description() const
+{
+ return myDescription;
+}
+
+void Events_Error::send(char* theDescription, const void* theSender)
+{
+ Events_Error anError(theDescription, theSender);
+ Events_Loop::loop()->send(anError);
+}
+
+static void send(std::string theDescription, const void* theSender = 0)
+{
+ Events_Error::send(theDescription.c_str(), theSender);
+}
--- /dev/null
+/*
+ * Events_Error.h
+ *
+ * Created on: Apr 28, 2014
+ * Author: sbh
+ */
+
+#ifndef EVENTS_ERROR_H_
+#define EVENTS_ERROR_H_
+
+#include <Events.h>
+#include <Events_Message.h>
+
+#include <string>
+
+class EVENTS_EXPORT Events_Error: public Events_Message
+{
+ char* myDescription; ///< pointer to the description of the error
+
+public:
+ virtual ~Events_Error();
+
+ static Events_ID errorID();
+ char* description() const;
+ static void send(char* theDescription, const void* theSender = 0);
+ static void send(std::string theDescription, const void* theSender = 0);
+
+protected:
+ Events_Error(char* theDescription, const void* theSender = 0);
+};
+
+#endif /* EVENTS_ERROR_H_ */
#include <Config_WidgetReader.h>
#include <Events_Loop.h>
#include <Events_Message.h>
+#include <Events_Error.h>
#include <GeomAPI_Shape.h>
XGUI_SelectionMgr.h
XGUI_SalomeConnector.h
XGUI_ActionsMgr.h
+ XGUI_ErrorDialog.h
)
SET(PROJECT_AUTOMOC
XGUI_OperationMgr.cpp
XGUI_SelectionMgr.cpp
XGUI_ActionsMgr.cpp
+ XGUI_ErrorDialog.cpp
)
SET(PROJECT_RESOURCES
--- /dev/null
+/*
+ * XGUI_ErrorDialog.cpp
+ *
+ * Created on: Apr 28, 2014
+ * Author: sbh
+ */
+#include <XGUI_ErrorDialog.h>
+
+#include <QDialogButtonBox>
+#include <QHBoxLayout>
+#include <QLabel>
+#include <QVBoxLayout>
+#include <QTextEdit>
+
+XGUI_ErrorDialog::XGUI_ErrorDialog(QWidget* parent)
+ : QDialog(parent)
+{
+ QVBoxLayout* aDlgLay = new QVBoxLayout(this);
+ setWindowTitle(tr("Application errors"));
+ myErrorLog = new QTextEdit(this);
+ myErrorLog->setReadOnly(true);
+ aDlgLay->addWidget(myErrorLog);
+ QDialogButtonBox* aButtonBox =
+ new QDialogButtonBox(QDialogButtonBox::Close, Qt::Horizontal, this);
+ aDlgLay->addWidget(aButtonBox);
+ aDlgLay->setContentsMargins(2,2,2,2);
+ aDlgLay->setSpacing(2);
+ setLayout(aDlgLay);
+ resize(420, 240);
+
+ connect(aButtonBox, SIGNAL(accepted()), this, SLOT(clear()));
+ connect(aButtonBox, SIGNAL(rejected()), this, SLOT(clear()));
+}
+
+XGUI_ErrorDialog::~XGUI_ErrorDialog()
+{
+}
+
+void XGUI_ErrorDialog::refresh()
+{
+ myErrorLog->clear();
+ foreach(QString eachError, myErrors)
+ {
+ myErrorLog->append(eachError);
+ }
+}
+
+void XGUI_ErrorDialog::clear()
+{
+ myErrorLog->clear();
+ myErrors.clear();
+ QDialog::reject();
+}
+
+void XGUI_ErrorDialog::addError(const QString& theError)
+{
+ myErrors.append(theError);
+ refresh();
+}
+
+void XGUI_ErrorDialog::removeError(const QString& theError)
+{
+ myErrors.removeAll(theError);
+ refresh();
+}
+
--- /dev/null
+/*
+ * XGUI_ErrorDialog.h
+ *
+ * Created on: Apr 28, 2014
+ * Author: sbh
+ */
+
+#ifndef XGUI_ERRORDIALOG_H_
+#define XGUI_ERRORDIALOG_H_
+
+#include <XGUI.h>
+#include <QDialog>
+
+class QTextEdit;
+
+class XGUI_ErrorDialog: public QDialog
+{
+ Q_OBJECT
+public:
+ XGUI_EXPORT XGUI_ErrorDialog(QWidget* parent);
+ XGUI_EXPORT virtual ~XGUI_ErrorDialog();
+
+public slots:
+ XGUI_EXPORT void refresh();
+ XGUI_EXPORT void clear();
+ XGUI_EXPORT void addError(const QString&);
+ XGUI_EXPORT void removeError(const QString&);
+
+private:
+ QTextEdit* myErrorLog;
+ QStringList myErrors;
+};
+
+#endif /* XGUI_ERRORDIALOG_H_ */
#include "XGUI_OperationMgr.h"
#include "XGUI_SalomeConnector.h"
#include "XGUI_ActionsMgr.h"
+#include "XGUI_ErrorDialog.h"
#include <ModelAPI_PluginManager.h>
#include <ModelAPI_Feature.h>
#include <ModelAPI_AttributeDocRef.h>
#include <Events_Loop.h>
+#include <Events_Error.h>
#include <ModuleBase_PropPanelOperation.h>
#include <ModuleBase_Operation.h>
#include <Config_FeatureMessage.h>
mySelector = new XGUI_SelectionMgr(this);
myOperationMgr = new XGUI_OperationMgr(this);
myActionsMgr = new XGUI_ActionsMgr(this);
+ myErrorDlg = new XGUI_ErrorDialog(myMainWindow);
+
connect(myOperationMgr, SIGNAL(operationStarted()), this, SLOT(onOperationStarted()));
connect(myOperationMgr, SIGNAL(operationStopped(ModuleBase_Operation*)),
this, SLOT(onOperationStopped(ModuleBase_Operation*)));
+ connect(this, SIGNAL(errorOccurred(const QString&)), myErrorDlg, SLOT(addError(const QString&)));
}
//******************************************************
initMenu();
//Initialize event listening
Events_Loop* aLoop = Events_Loop::loop();
+ aLoop->registerListener(this, Events_Error::errorID()); //!< Listening application errors.
//TODO(sbh): Implement static method to extract event id [SEID]
Events_ID aFeatureId = aLoop->eventByName("FeatureEvent");
aLoop->registerListener(this, aFeatureId);
{
static Events_ID aFeatureId = Events_Loop::loop()->eventByName("FeatureEvent");
if (theMessage->eventID() == aFeatureId) {
- const Config_FeatureMessage* aFeatureMsg =
- dynamic_cast<const Config_FeatureMessage*>(theMessage);
+ const Config_FeatureMessage* aFeatureMsg = dynamic_cast<const Config_FeatureMessage*>(theMessage);
addFeature(aFeatureMsg);
return;
}
- const Config_PointerMessage* aPartSetMsg =
- dynamic_cast<const Config_PointerMessage*>(theMessage);
+ const Config_PointerMessage* aPartSetMsg = dynamic_cast<const Config_PointerMessage*>(theMessage);
if (aPartSetMsg) {
ModuleBase_PropPanelOperation* anOperation =
(ModuleBase_PropPanelOperation*)(aPartSetMsg->pointer());
}
return;
}
+ const Events_Error* anAppError = dynamic_cast<const Events_Error*>(theMessage);
+ if (anAppError) {
+ emit errorOccurred(QString::fromLatin1(anAppError->description()));
+ myErrorDlg->show();
+ myErrorDlg->raise();
+ myErrorDlg->activateWindow();
+ }
#ifdef _DEBUG
qDebug() << "XGUI_Workshop::ProcessEvent: "
class XGUI_SalomeConnector;
class XGUI_ObjectsBrowser;
class XGUI_ActionsMgr;
+class XGUI_ErrorDialog;
class ModuleBase_Operation;
class ModuleBase_PropPanelOperation;
void onFeatureTriggered();
+signals:
+ void errorOccurred(const QString&);
+
protected:
//Event-loop processing methods:
void addFeature(const Config_FeatureMessage*);
XGUI_OperationMgr* myOperationMgr; ///< manager to manipulate through the operations
XGUI_ActionsMgr* myActionsMgr;
XGUI_SalomeConnector* mySalomeConnector;
+ XGUI_ErrorDialog* myErrorDlg;
};
#endif