Index: sources/gui/GuiView.cpp =================================================================== diff -u -r61f16c988a159401c92730b4cbfca5085c77222f -r9ef6badf8e172436bba2bfad1642ae7e469e0361 --- sources/gui/GuiView.cpp (.../GuiView.cpp) (revision 61f16c988a159401c92730b4cbfca5085c77222f) +++ sources/gui/GuiView.cpp (.../GuiView.cpp) (revision 9ef6badf8e172436bba2bfad1642ae7e469e0361) @@ -1,15 +1,15 @@ /*! * - * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. + * Copyright (c) 2020-2023 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 + * \file GuiView.cpp + * \author (last) Behrouz NematiPour + * \date (last) 16-Oct-2022 + * \author (original) Behrouz NematiPour + * \date (original) 26-Aug-2020 * */ @@ -43,11 +43,13 @@ 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. + // since we do not 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 &))); + connect(this , SIGNAL(didQuitApplication()), + &_GuiController, SLOT( doQuitApplication())); // From UI : USB drive umount connect(this , SIGNAL(didUSBDriveUmount()), @@ -57,21 +59,29 @@ this , SLOT( onUSBDriveMount ())); connect(&_GuiController, SIGNAL(didUSBDriveRemove()), this , SLOT( onUSBDriveRemove())); + connect(&_GuiController, SIGNAL(didUSBSpaceChange(bool, qint64, qint64, quint8)), + this , SLOT( onUSBSpaceChange(bool, qint64, qint64, quint8))); // SD Card - connect(&_GuiController, SIGNAL(didSDCardStateChange(bool,bool)), - this , SLOT( onSDCardStateChange(bool,bool))); + connect(&_GuiController , SIGNAL(didSDCardStateChange(bool,bool)), + this , SLOT( onSDCardStateChange(bool,bool))); + connect(&_GuiController , SIGNAL(didSDCardSpaceChange(bool, qint64, qint64, quint8)), + this , SLOT( onSDCardSpaceChange(bool, qint64, qint64, quint8))); + connect(&_GuiController , SIGNAL(didExport()), + this , SLOT( onExport())); + connect(&_GuiController , SIGNAL(didExportStat (quint32, const QString &, quint8)), + this , SLOT( onExportStat (quint32, const QString &, quint8))); - /// TEST: Test the space on GUI, not sure if we keep it. - connect(&_DeviceController, SIGNAL( didSDCardSpaceChange(bool, qint64, qint64, quint8)), - this , SLOT( onSDCardSpaceChange(bool, qint64, qint64, quint8))); - - connect(&_GuiController, SIGNAL(didExport()), - this , SLOT( onExport())); - // From UI : Export Log - connect(this , SIGNAL(didExportLog()), - &_GuiController, SLOT( doExportLog())); + connect(this , SIGNAL(didExportLog (const GuiStringIndexMap &)), + &_GuiController, SLOT( doExportLog (const GuiStringIndexMap &))); + connect(this , SIGNAL(didExportService (const GuiStringIndexMap &)), + &_GuiController, SLOT( doExportService (const GuiStringIndexMap &))); + connect(this , SIGNAL(didExportTreatment (const GuiStringIndexMap &)), + &_GuiController, SLOT( doExportTreatment (const GuiStringIndexMap &))); + + connect(&_GuiController, SIGNAL(didPOSTPass (bool)), + this , SLOT( onPOSTPass (bool))); } /*! @@ -97,11 +107,11 @@ 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. + // disabled coco begin validated: This code later needs to be removed when Investigated thoroughly. // has been tested manually emit didActionTransmit(vAction, vData); } -// coco end +// disabled coco end /*! * \brief GuiView::doActionTransmit @@ -115,13 +125,13 @@ 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. + // disabled 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 +// disabled coco end /*! * \brief GuiView::doUSBDriveMount @@ -130,13 +140,13 @@ */ void GuiView::onUSBDriveMount () { - // coco begin validated: This needs user interaction to plug-in USB device + // disabled coco begin validated: This needs user interaction to plug-in USB device // has been tested manually - usbReady (true ); - usbRemoved (false); + usbIsReady (true ); + usbIsRemoved(false); emit didUSBDriveMount (); } -// coco end +// disabled coco end /*! * \brief GuiView::doUSBDriveUmount @@ -145,13 +155,14 @@ */ void GuiView::doUSBDriveUmount() { - // coco begin validated: This needs user interaction to plug-in USB device + // disabled coco begin validated: This needs user interaction to plug-in USB device // has been tested manually - usbReady (false); - usbRemoved (false); + usbIsReady (false); + usbIsRemoved(false); + exportRunning(false); emit didUSBDriveUmount(); } -// coco end +// disabled coco end /*! * \brief GuiView::doUSBDriveRemove @@ -160,13 +171,14 @@ */ void GuiView::onUSBDriveRemove() { - // coco begin validated: This needs user interaction to plug-in USB device + // disabled coco begin validated: This needs user interaction to plug-in USB device // has been tested manually - usbReady (false); - usbRemoved (true ); + usbIsReady (false); + usbIsRemoved(true ); + exportRunning(false); emit didUSBDriveRemove(); } -// coco end +// disabled coco end /*! * \brief GuiView::onSDCardStateChange @@ -177,13 +189,16 @@ */ void GuiView::onSDCardStateChange(bool vIsReady, bool vIsReadOnly) { - // coco begin validated: This needs user interaction to plug-in USB device + // disabled coco begin validated: This needs user interaction to plug-in USB device // has been tested manually - /// DEBUG: qDebug() << " ***** GuiView " << Storage::SDCard_Base_Path_Name << vIsReady; + //DEBUG:0: qDebug() << " ***** GuiView " << Storage::SDCard_Base_Path_Name << vIsReady; sdIsReady (vIsReady ); sdIsReadOnly(vIsReadOnly); + if (! vIsReady || vIsReadOnly) exportRunning(false); + + //DEBUG:0: qDebug() << __FUNCTION__ << _sdIsReady << _sdIsReadOnly; } -// coco end +// disabled coco end /*! * \brief GuiController::doSDCardSpaceTooLow @@ -192,11 +207,11 @@ */ void GuiView::onSDCardSpaceTooLow(quint8 vAvailablePercent) { - // coco begin validated: This needs to fill up the SD-Card and test with human interactions. + // disabled coco begin validated: This needs to fill up the SD-Card and test with human interactions. // has been tested manually sdTooLowPecent(vAvailablePercent); } -// coco end +// disabled coco end /*! * \brief GuiView::onExport @@ -205,26 +220,135 @@ */ void GuiView::onExport() { - // coco begin validated: This needs user interaction to plug-in USB device - // has been tested manually + doExportListRemove(); + exportRunning(false); emit didExport(); + //DEBUG:0: qDebug() << " ~~~~~ " << "GuiView::onExport" << _exportRunning; } -// coco end /*! + * \brief GuiView::onExportStat + * \details handler slot of the signal didExportStat, which is emitted when a state of the selected item is changed. + * \param vIndex - selected item index + * \param vFileName - selected item file name + * \param vPercent - selected item export percentage. + */ +void GuiView::onExportStat(quint32 vIndex, const QString &vFileName, quint8 vPercent) +{ + //DEBUG: qDebug() << "3" << vIndex << vFileName << vPercent; + + _exportListPercent [vIndex] = vPercent; + exportIndex (vIndex ); + exportFile (vFileName ); + exportPercent (vPercent ); + if ( vPercent == 100 ) + doExportListDelete(vIndex); + emit didExportStat (vIndex, vFileName, vPercent); +} + +/*! + * \brief GuiView::doExportListInsert + * \details invocable slot from UI to insert an item in the selection list. + * \param vIndex - selected item index + * \param vFileName - selected item file name + */ +void GuiView::doExportListInsert(quint32 vIndex, const QString &vFilename) +{ + _exportList [vIndex] = vFilename ; + _exportListPercent [vIndex] = 100 ; + exportIndex ( vIndex ); + exportFile ( vFilename ); + exportCount ( _exportList.count() ); + emit exportListChanged (_exportList ); +} + +/*! + * \brief GuiView::doExportListDelete + * \details invocable slot from UI to delete a selected item from the list. + * \param vIndex - deselected item index + */ +void GuiView::doExportListDelete(quint32 vIndex) +{ + _exportList.remove (vIndex); + _exportListPercent [vIndex] = 0 ; + exportIndex ( vIndex ); + exportFile ( "" ); + exportCount ( _exportList.count() ); + emit exportListChanged (_exportList ); +} + +/*! + * \brief GuiView::doExportListSelect + * \details invocable slot from UI to identify if the item with the index vIndex is selected. + * \param vIndex - item index + * \return true if the item with index vIndex is selected. + */ +bool GuiView::doExportListSelect(quint32 vIndex) +{ + bool contains = _exportList.contains(vIndex); + return contains; +} + +/*! + * \brief GuiView::doExportListPercent + * \details invocable slot from UI to get the exported/copied percent of the item with the index vIndex. + * \param vIndex - item index + * \return the exported/copied percent + */ +quint8 GuiView::doExportListPercent(quint32 vIndex) +{ + exportIndex ( vIndex ); + return _exportListPercent[vIndex]; +} + +/*! + * \brief GuiView::doExportListRemove + * \details invocable slot from UI to clear the selection list, and reset related values/properties.. + */ +void GuiView::doExportListRemove() +{ + exportIndex ( 0 ); + exportFile ( "" ); + exportPercent ( 0 ); + exportCount ( 0 ); + _exportList.clear ( ); + emit exportListChanged (_exportList); +} + +/*! * \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(); + exportRunning(true); + emit didExportLog(_exportList); } -// coco end /*! + * \brief GuiView::doExportService + * \details emits didExportService signal to notify other classes (GuiController) + * , the User requested to export the log. + */ +void GuiView::doExportService() +{ + exportRunning(true); + emit didExportService(_exportList); +} + +/*! + * \brief GuiView::doExportTreatment + * \details emits didExportTreatment signal to notify other classes (GuiController) + * , the User requested to export the log. + */ +void GuiView::doExportTreatment() +{ + exportRunning(true); + emit didExportTreatment(_exportList); +} + +/*! * \brief GuiView::onSDCardSpaceChange * \details SD Card storage space parameter change slot. * This slot when called is calling the function concurrentRemoveLogs, @@ -237,13 +361,35 @@ */ void GuiView::onSDCardSpaceChange(bool vReady, qint64 vTotal, qint64 vAvailable, quint8 vPercent) { - // coco begin validated: This needs user interaction to change the SD card files system. - // has been tested manually /// DEBUG: qDebug() << vReady << vTotal << vAvailable << vPercent << Storage::Available_Space_Percent; Q_UNUSED(vReady) - sdTotal ( vTotal ); - sdAvail ( vAvailable ); - sdPercent ( vPercent ); - sdIsLow ( vPercent <= Storage::Available_Space_Percent ); + sdTotal ( vTotal ); + sdAvail ( vAvailable ); + sdPercent ( vPercent ); + sdIsLow ( Storage::Log_Min_Available_Total_Space_IsLow(vPercent) ); } -// coco end + +void GuiView::onUSBSpaceChange(bool vReady, qint64 vTotal, qint64 vAvailable, quint8 vPercent) +{ + // DEBUG: qDebug() << "GuiView::onUSBSpaceChange" << vReady << vTotal << vAvailable << vPercent; + usbTotal ( vTotal ); + usbAvail ( vAvailable ); + usbPercent ( vPercent ); + usbIsReady ( vReady ); + // TODO : the space check should also be done for the USB as destination but needs calculation and will be done later. + // usbIsLow ( vPercent <= Storage::Available_Space_Percent ); +} + +void GuiView::onPOSTPass(bool vPass) +{ + manufactMode( gEnableManufacturing && vPass ); + postPass(vPass); +} + +/*! + * \brief GuiView::doQuitApplication + * \details emit the didQuitApplication signal to ask ApplicationController to Quit the application gracefully. + */ +void GuiView::doQuitApplication() { + emit didQuitApplication(); +}