Index: sources/applicationcontroller.cpp =================================================================== diff -u -r5194f3afffb28dac90a7ca4153b6a0ca2f239387 -r9a3ee027dbc33f39ee7df2a9dc5a7897c6b1854d --- sources/applicationcontroller.cpp (.../applicationcontroller.cpp) (revision 5194f3afffb28dac90a7ca4153b6a0ca2f239387) +++ sources/applicationcontroller.cpp (.../applicationcontroller.cpp) (revision 9a3ee027dbc33f39ee7df2a9dc5a7897c6b1854d) @@ -14,48 +14,111 @@ #include "applicationcontroller.h" // Qt -#include // Project +#include "guiglobals.h" +#include "guicontroller.h" +#include "messagehandler.h" -ApplicationController *ApplicationController::_instance = nullptr; +// Singleton +SINGLETON_INIT(ApplicationController) + +/*! + * \brief ApplicationController::ApplicationController + * \param parent + */ ApplicationController::ApplicationController(QObject *parent) : QObject(parent) { - _guiController = Gui::GuiController::I(); _fileHandler = new Storage::FileHandler (this); _applicationPost = new ApplicationPost(this); - connect(_guiController,&GuiController::initialized,this, &ApplicationController::UiInitialized); + } -bool ApplicationController::event(QEvent *event) +/*! + * \brief ApplicationController initializer + */ +bool ApplicationController::init() { - return QObject::event(event); + if (!_fileHandler ->init()) return false; + if (!_applicationPost->init()) return false; + connection(); + return true; } -ApplicationController *ApplicationController::I() +/*! + * \brief GUI Controller connections definition + */ +void ApplicationController::connection() { - if (!_instance) { - _instance = new ApplicationController(); - } - return _instance; + // From GUI + connect(_GuiController , SIGNAL(didActionRequest(GuiActionType)), + this , SLOT( onActionRequest(GuiActionType))); + // From GUI + connect(_GuiController , SIGNAL(didActionPerform(GuiActionType,GuiActionInfo)), + this , SLOT( onActionPerform(GuiActionType, GuiActionInfo))); + + // From HD/DG + connect(_MessageHandler, SIGNAL(didActionCommand(GuiActionType)), + this , SLOT( onActionCommand(GuiActionType))); + // From HD/DG + connect(_MessageHandler, SIGNAL(didActionConfirm(GuiActionType,GuiActionInfo)), + this , SLOT( onActionConfirm(GuiActionType, GuiActionInfo))); } -bool ApplicationController::init() + +/*! + * \brief Process the requested action + * \details Processes the requested action + * \param vAction - User requested Action + */ +void ApplicationController::onActionRequest(GuiActionType vAction) { - if (!_fileHandler ->init()) return false; - if (!_applicationPost->init()) return false; - _guiController->init(); - return true; + qDebug() << "ApplicationController.actionRequested : " << vAction; + // Process the requested action by GUI + // Process ... + emit didActionRequest(vAction); } -void ApplicationController::UiInitialized(bool ok) +/*! + * \brief Process the performed action + * \details An action which has been commanded by HD has been performed by GUI.\n + * GUI notifies that the action has been performed + * \param vAction + * \param vInfo + */ +void ApplicationController::onActionPerform(GuiActionType vAction, GuiActionInfo vInfo) { - if(ok) { - if(_applicationPost->init()) { - _applicationPost->start(); - } - } - else { - quit(-1); - } + qDebug() << "ApplicationController.actionPerformed : " << vAction << vInfo; + // Process the performed action by GUI + // Process ... + emit didActionPerform(vAction, vInfo); } + +/*! + * \brief Action commanded by HD + * \details An action has been commanded by HD, + * GUI requires to be notified to perform the action. + * \param vAction + */ +void ApplicationController::onActionCommand(GuiActionType vAction) +{ + qDebug() << "ApplicationController.actionCommanded : " << vAction; + // Process the command and notify GUI Controller + // Process ... + emit didActionCommand(vAction); +} + +/*! + * \brief An action has been confirmed + * \details GUI requested an action. + * In response HD confirmed the action. + * \param vAction + * \param vInfo + */ +void ApplicationController::onActionConfirm(GuiActionType vAction, GuiActionInfo vInfo) +{ + qDebug() << "ApplicationController.actionConfirmed : " << vAction; + // Process the command and notify GUI Controller + // Process ... + emit didActionConfirm(vAction, vInfo); +}