/*! * * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. * \copyright * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. * * \file GuiView.cpp * \author (last) Behrouz NematiPour * \date (last) 08-Sep-2020 * \author (original) Behrouz NematiPour * \date (original) 26-Aug-2020 * */ // Project #include "GuiView.h" #include "GuiController.h" // namespace using namespace Gui; /*! * \brief GuiView::GuiView * \details Constructor * \param parent - QObject parent owner object. * Qt handles the children destruction by their parent objects life-cycle. */ GuiView::GuiView(QObject *parent) { Q_UNUSED(parent) initConnections(); } /*! * \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(didActionReceive (GuiActionType, const QVariantList &)), this , SLOT( onActionReceive (GuiActionType, const QVariantList &))); // since we don't have access to this 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(didActionTransmit(GuiActionType,const QVariantList &)), &_GuiController, SLOT( doActionTransmit(GuiActionType,const QVariantList &))); // 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())); // SD Card connect(&_GuiController, SIGNAL(didSDCardStateChange(bool,bool)), this , SLOT( doSDCardStateChange(bool,bool))); connect(&_GuiController, SIGNAL(didExport()), this , SLOT( doExport())); // From UI : Export Log connect(this , SIGNAL(didExportLog()), &_GuiController, SLOT( doExportLog())); } /*! * \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 emit didActionReceive (vAction, vData); } /*! * \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) { // TODO : Remove this code later when Investigated thoroughly. // coco begin validated: This code later needs to be removed when Investigated thoroughly. // has been tested manually emit didActionTransmit(vAction, vData); } // coco end /*! * \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) { // TODO : Remove this code later when Investigated thoroughly. // coco begin validated: This code later needs to be removed when Investigated thoroughly. // has been tested manually QVariantList mData; mData += vData; emit didActionTransmit(vAction, mData); } // coco end /*! * \brief GuiView::doUSBDriveMount * \details emits didUSBDriveMount signal to notify other classes (UI) * , the USB drive has been mounted. */ void GuiView::doUSBDriveMount () { // coco begin validated: This needs user interaction to plug-in USB device // has been tested manually emit didUSBDriveMount (); } // coco end /*! * \brief GuiView::doUSBDriveUmount * \details emits didUSBDriveRemove signal to notify other classes (GuiController) * , the USB drive has been removed. */ void GuiView::doUSBDriveUmount() { // coco begin validated: This needs user interaction to plug-in USB device // has been tested manually emit didUSBDriveUmount(); } // coco end /*! * \brief GuiView::doUSBDriveRemove * \details emits didUSBDriveRemove signal to notify other classes (UI) * , the USB drive has been removed. */ void GuiView::doUSBDriveRemove() { // coco begin validated: This needs user interaction to plug-in USB device // has been tested manually emit didUSBDriveRemove(); } // coco end /*! * \brief GuiView::doSDCardStateChange * \details emits didSDCardStateChange signal to notify other classes (UI) * , the SD Card Stte has been changed. * \param vIsReady - SdCard is Ready * \param vIsReadOnly - SdCard is ReadOnly */ void GuiView::doSDCardStateChange(bool vIsReady, bool vIsReadOnly) { // coco begin validated: This needs user interaction to plug-in USB device // has been tested manually sdIsReady (vIsReady ); sdIsReadOnly(vIsReadOnly); } // coco end /*! * \brief GuiView::onExport * \details The slot which will be called to notify the export is done * by emitting the didExport signal. */ void GuiView::doExport() { // coco begin validated: This needs user interaction to plug-in USB device // has been tested manually emit didExport(); } // coco end /*! * \brief GuiView::doExportLog * \details emits didExportLog signal to notify other classes (GuiController) * , the User requested to export the log. */ void GuiView::doExportLog() { // coco begin validated: This needs user interaction to plug-in USB device // has been tested manually emit didExportLog(); } // coco end