/*! * * Copyright (c) 2020-2025 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 MAbstract.cpp * \author (last) Behrouz NematiPour * \date (last) 04-Aug-2021 * \author (original) Behrouz NemaiPour * \date (original) 04-Jul-2020 * */ #include "MAbstract.h" #include using namespace Model; #define ROUND_FLOATS const QMap MAbstract::_typeText = MAbstract::_typeText_make(); const QMap MAbstract::_unitText = MAbstract::_unitText_make(); /*! * \brief MAbstract::toVariantList * \details Current values of the model data will be listed in a QVariantList vData. * It has been mostly been used for debugging with the Generic onActionReceived which has the QVariantList as the signal parameter. * \param vData - The output data of the QVariantList */ void MAbstract::toVariantList(QVariantList &vData) const { vData = parameters(); } /*! * \brief MAbstract::toString * \details String Representation of the model data. * \return String */ QString MAbstract::toString() const { QVariantList mParameters = parameters(); QString mString = description(); for( const auto ¶meter : mParameters ) { if (static_cast(parameter.type()) == QMetaType::Float) // Qt has a mixed definition of QVariant::Type and QMetaType seems like a not fixed issue. #ifdef ROUND_FLOATS mString += _delimiter + QString("%1").arg(parameter.toFloat(),0,'f',_precision); #else mString += _delimiter + parameter.toString(); #endif else mString += _delimiter + parameter.toString(); } return mString; } /*! * \brief MAbstract::description * \details The description of the model. mostly used in logging. * \return String */ QString MAbstract::description() const { // TODO : not all the received messages are inherited form MAbstract // also LOG_EVENT is adding E // so for now let LOG_EVENT add E until all the received messages inherit from MAbstract return /*_typeText[typeText()] + _delimiter +*/ _unitText[unitText()] + _delimiter + infoText(); }