/*! * * Copyright (c) 2023-2024 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 VHDUsageInfo.cpp * \author (last) Dara Navaei * \date (last) 23-Sep-2024 * \author (original) Vy * \date (original) 08-Sep-2023 * */ #include "VHDUsageInfo.h" // Project #include "GuiController.h" #include "format.h" VIEW_DEF_CLASS_ADJUSTMENT(VHDUsageInfo) void View::VHDUsageInfo::initConnections() { ADJUST_VIEW_CONNECTION( HDUsageInfoRequestData) ACTION_VIEW_CONNECTION(HDUsageInfoResponseData) ACTION_VIEW_CONNECTION(SettingsData) } /*! * \brief VHDUsageInfo::onActionReceive * \details received response model data handler * \param vData - model data */ void View::VHDUsageInfo::onActionReceive(const HDUsageInfoResponseData &vData) { // Format the time in hours to be only one decimal point. // In .arg(), the second field is the field width // The third field is the number notation so 'f' in this case means no scientific notation // The fourth field is the number of decimal places which 1 decimal is needed here. QString timeFormatted = QString("%1").arg(vData.mTotalTxHours, 0, 'f', 0); totalTxHours(timeFormatted); timeFormatted = QString("%1").arg(vData.mTotalTxHoursSinceLastService, 0, 'f', 0); totalTxHoursSinceLastService(timeFormatted); epochOfStartOfLastTx (Format::fromEpoch(vData.mEpochOfStartOfLastTx, _dateFormat)); // *** has to be the last to let the information to be set and then emit the signal *** // *** otherwise will use the Previous values before being set. *** adjustment ( true ); } void View::VHDUsageInfo::onActionReceive(const SettingsData &) { _dateFormat = _Settings.dateFormat(); }