Index: sources/gui/guiview.cpp =================================================================== diff -u -r9a3ee027dbc33f39ee7df2a9dc5a7897c6b1854d -rb9c5b0b3afc3b34d4980ecc4f023f498f80dafbc --- sources/gui/guiview.cpp (.../guiview.cpp) (revision 9a3ee027dbc33f39ee7df2a9dc5a7897c6b1854d) +++ sources/gui/guiview.cpp (.../guiview.cpp) (revision b9c5b0b3afc3b34d4980ecc4f023f498f80dafbc) @@ -1,6 +1,6 @@ /*! * - * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. + * Copyright (c) 2019-2019 Diality Inc. - All Rights Reserved. * \copyright \n * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, \n * IN PART OR IN WHOLE, \n @@ -15,6 +15,7 @@ // Project #include "guicontroller.h" +#include "guiglobals.h" // namespace using namespace Gui; @@ -26,48 +27,166 @@ GuiView::GuiView(QQuickItem *parent) { Q_UNUSED(parent) - connection(); + initConnections(); } -void GuiView::connection() +/*! + * \brief GuiView::initConnections + * \details Initializes the required signal/slot connection between this class and other objects + * to be able to communicate. + */ +void GuiView::initConnections() { - connect(_GuiController, SIGNAL(didActionConfirm(GuiActionType, GuiActionInfo)), - this , SLOT( onActionConfirm(GuiActionType, GuiActionInfo))); + connect(&_GuiController, SIGNAL(didActionReceive (GuiActionType, const QVariantList &)), + this , SLOT( onActionReceive (GuiActionType, const QVariantList &))); - connect(_GuiController, SIGNAL(didActionCommand(GuiActionType )), - this , SLOT( onActionCommand(GuiActionType ))); - // since we don't have access to GuiView object because it is created in Qml. // Connection to the GuiController made here // It should be defined in the class which wants to connect to signal. - connect(this , SIGNAL(didActionRequest(GuiActionType)), - _GuiController, SLOT( doActionRequest(GuiActionType))); + connect(this , SIGNAL(didActionTransmit(GuiActionType,const QVariantList &)), + &_GuiController, SLOT( doActionTransmit(GuiActionType,const QVariantList &))); - connect(this , SIGNAL(didActionPerform(GuiActionType,GuiActionInfo)), - _GuiController, SLOT( doActionPerform(GuiActionType,GuiActionInfo))); + // From UI : USB drive umount + connect(this , SIGNAL(didUSBDriveUmount()), + &_GuiController, SLOT( doUSBDriveUmount())); + // From OS : USB drive removed + connect(&_GuiController, SIGNAL(didUSBDriveMount ()), + this , SLOT( doUSBDriveMount ())); + connect(&_GuiController, SIGNAL(didUSBDriveRemove()), + this , SLOT( doUSBDriveRemove())); + + connect(&_GuiController, SIGNAL(didExport()), + this , SLOT( doExport())); + + // From UI : Export Log + connect(this , SIGNAL(didExportLog()), + &_GuiController, SLOT( doExportLog())); } -void GuiView::onActionConfirm(GuiActionType vAction, GuiActionInfo vInfo) +/*! + * \brief GuiView::onActionReceive + * \details emits didActionReceive signal to notify other classes (Gui) + * , an action has been received. + * \param vAction - the action + * \param vData - the action data + */ +void GuiView::onActionReceive (GuiActionType vAction, const QVariantList &vData) { // process the evaluation and notify GUI // process ... - emit didActionConfirm(vAction, vInfo); + emit didActionReceive (vAction, vData); } -void GuiView::onActionCommand(GuiActionType vAction) +/*! + * \brief GuiView::doActionTransmit + * \details emits didActionTransmit signal to notify other classes (GuiController) + * , an action has been required to be transmitted. + * \param vAction - the action + * \param vData - the action data + */ +void GuiView::doActionTransmit(GuiActionType vAction, const QVariantList &vData) { - // process the commanded action and notify GUI - // process ... - emit didActionCommand(vAction); + emit didActionTransmit(vAction, vData); +} +/*! + * \brief GuiView::doActionTransmit + * \details emits didActionTransmit signal to notify other classes (GuiController) + * , an action has been required to be transmitted. + * \note The overloaded method with only one data parameter, for easier use in qml. + * \param vAction - the action + * \param vData - the action data + */ + +void GuiView::doActionTransmit(GuiActionType vAction, const QVariant &vData) +{ + QVariantList mData; + mData += vData; + emit didActionTransmit(vAction, mData); } -void GuiView::doActionRequest(GuiActionType vAction) +/*! + * \brief GuiView::doUSBDriveMount + * \details emits didUSBDriveMount signal to notify other classes (GuiController) + * , the USB drive has been mounted. + */ +void GuiView::doUSBDriveMount () { - emit didActionRequest(vAction); + emit didUSBDriveMount (); } -void GuiView::doActionPerform(GuiActionType vAction, GuiActionInfo vInfo) +/*! + * \brief GuiView::doUSBDriveUmount + * \details emits didUSBDriveRemove signal to notify other classes (GuiController) + * , the USB drive has been removed. + */ +void GuiView::doUSBDriveUmount() { - emit didActionPerform(vAction, vInfo); + emit didUSBDriveUmount(); } + +/*! + * \brief GuiView::doUSBDriveRemove + * \details emits didUSBDriveRemove signal to notify other classes (GuiController) + * , the USB drive has been removed. + */ +void GuiView::doUSBDriveRemove() +{ + emit didUSBDriveRemove(); +} + +/*! + * \brief GuiView::onExport + * \details The slot which will be called to notify the export is done + * by emitting the didExport signal. + */ +void GuiView::doExport() +{ + emit didExport(); +} + +/*! + * \brief GuiView::doExportLog + * \details emits didExportLog signal to notify other classes (GuiController) + * , the User requested to export the log. + */ +void GuiView::doExportLog() +{ + emit didExportLog(); +} + +/*! + * \brief GuiView::alarmPriorityName + * \details this code is the place holder for the alarms description mapping + * since it is another feature + * it returns the enum name for now + * \param vEnum - The Alarm priority + * \return String representation of the Alarm priority Enum name + */ +QString GuiView::alarmPriorityName(GuiAlarmPriority vEnum) +{ + // this code is the place holder for the alarms description mapping + // since it is another feature + // it returns the enum name for now + const QMetaObject *mo = qt_getEnumMetaObject(vEnum); + int enumIdx = mo->indexOfEnumerator(qt_getEnumName(vEnum)); + return mo->enumerator(enumIdx).valueToKey(vEnum); +} + +/*! + * \brief GuiView::alarmIDName + * \details this code is the place holder for the alarms description mapping + * since it is another feature + * it returns the enum name for now + * \param vEnum - The Alarm ID + * \return String representation of the Alarm Id Enum name + */ +QString GuiView::alarmIDName(GuiAlarmID vEnum) +{ + // this code is the place holder for the alarms description mapping + // since it is another feature + // it returns the enum name for now + const QMetaObject *mo = qt_getEnumMetaObject(vEnum); + int enumIdx = mo->indexOfEnumerator(qt_getEnumName(vEnum)); + return mo->enumerator(enumIdx).valueToKey(vEnum); +}