#include "viewmodel/tree/util/Log2TreeItemConverter.h" /*************************************************************************************************/ std::unique_ptr SimpleLog2TreeItemConverter::convert(const Log_ptr log, const TMap& translatorMap) const { auto root = std::make_unique(QVariantList{QString("Field"), QString("Value")}); if(log) { addIdItem(log, translatorMap, root.get()); addLevelItem(log, translatorMap, root.get()); addSrcItem(log, translatorMap, root.get()); addMsgItem(log, translatorMap, root.get()); addScopeItem(log, translatorMap, root.get()); addThreadId(log, translatorMap, root.get()); addTimestamp(log, translatorMap, root.get()); } return root; } /*************************************************************************************************/ void SimpleLog2TreeItemConverter::addIdItem(const Log_ptr log, const ILog2TreeItemConvertor::TMap& translatorMap, TreeItem* parent) const { if(log->id.has_value()) { parent->appendChild(std::make_unique( QVariantList{"Logger Id", translatorMap[id]->provideString(log)})); } } /*************************************************************************************************/ void SimpleLog2TreeItemConverter::addLevelItem(const Log_ptr log, const ILog2TreeItemConvertor::TMap& translatorMap, TreeItem* parent) const { if(log->level.has_value()) { parent->appendChild(std::make_unique( QVariantList{"Level", translatorMap[level]->provideString(log)})); } } /*************************************************************************************************/ void SimpleLog2TreeItemConverter::addSrcItem(const Log_ptr log, const ILog2TreeItemConvertor::TMap& translatorMap, TreeItem* parent) const { if(log->src.has_value()) { auto srcRoot = std::make_unique(QVariantList{"Location", ""}); srcRoot->appendChild(std::make_unique(QVariantList{ "Filename", translatorMap[file]->provideString(log)})); srcRoot->appendChild(std::make_unique(QVariantList{ "Line Number", translatorMap[lineno]->provideString(log)})); srcRoot->appendChild(std::make_unique(QVariantList{ "Function Name", translatorMap[func]->provideString(log)})); parent->appendChild(std::move(srcRoot)); } } /*************************************************************************************************/ void SimpleLog2TreeItemConverter::addMsgItem(const Log_ptr log, const ILog2TreeItemConvertor::TMap& translatorMap, TreeItem* parent) const { if(log->msg.has_value()) { } } /*************************************************************************************************/ void SimpleLog2TreeItemConverter::addScopeItem(const Log_ptr log, const ILog2TreeItemConvertor::TMap& translatorMap, TreeItem* parent) const { if(log->scope.has_value()) { parent->appendChild(std::make_unique( QVariantList{"Scope", translatorMap[scope]->provideString(log)})); } } /*************************************************************************************************/ void SimpleLog2TreeItemConverter::addThreadId(const Log_ptr log, const ILog2TreeItemConvertor::TMap& translatorMap, TreeItem* parent) const { if(log->threadId.has_value()) { parent->appendChild(std::make_unique( QVariantList{"ThreadId", translatorMap[threadId]->provideString(log)})); } } /*************************************************************************************************/ void SimpleLog2TreeItemConverter::addTimestamp(const Log_ptr log, const ILog2TreeItemConvertor::TMap& translatorMap, TreeItem* parent) const { if(log->timestamp.has_value()) { parent->appendChild(std::make_unique( QVariantList{"Time", translatorMap[timestamp]->provideString(log)})); } }