/*! * * 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 MAbstract.cpp * \date 7/2/2020 * \author Behrouz NematiPour * */ #include "MAbstract.h" #include using namespace Model; // #define ROUND_FLOATS /*! * \brief MAbstract::toVariantList * \details Currnet values of the model data will be listed in a QVariantList vData. * It has been mostly been used for debugging with the Generic onAcitonRecived 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 (parameter.type() == uint(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 { return _typeText[typeText()] + _delimiter + _unitText[unitText()] + _delimiter + infoText(); }