1
0
Fork 0
mirror of https://github.com/EdgeTX/edgetx.git synced 2025-07-24 00:35:14 +03:00

refactor(cpn): Support JSON radio hardware definitions (#4406)

This commit is contained in:
Neil Horne 2024-02-04 16:59:04 +11:00 committed by GitHub
parent c6ae44f523
commit 83294613f6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
63 changed files with 4166 additions and 2295 deletions

View file

@ -92,19 +92,11 @@ std::string DataHelpers::getStringTagMappingTag(const StringTagMappingTable& lut
return std::string();
}
int DataHelpers::getStringTagMappingSeq(const StringTagMappingTable& lut, unsigned int index)
std::string DataHelpers::getStringNameMappingTag(const StringTagMappingTable& lut, const char * name)
{
if (index < lut.size())
return lut[index].seq;
return -1;
}
std::string DataHelpers::getStringSeqMappingTag(const StringTagMappingTable& lut, unsigned int seq)
{
const auto it =
auto it =
find_if(lut.begin(), lut.end(), [=](const StringTagMapping& elmt) {
if (elmt.seq == seq) return true;
if (elmt.name == name) return true;
return false;
});
@ -114,3 +106,34 @@ std::string DataHelpers::getStringSeqMappingTag(const StringTagMappingTable& lut
return std::string();
}
std::string DataHelpers::getStringTagMappingName(const StringTagMappingTable& lut, const char * tag)
{
auto it =
find_if(lut.begin(), lut.end(), [=](const StringTagMapping& elmt) {
if (elmt.tag == tag) return true;
return false;
});
if (it != lut.end()) {
return it->name;
}
return std::string();
}
QString DataHelpers::getCompositeName(const QString defaultName, const QString customName, const bool prefixCustom)
{
QString result;
if (customName.trimmed().isEmpty() || prefixCustom)
result = defaultName;
if (!customName.trimmed().isEmpty()) {
if (prefixCustom)
result.append(":");
result.append(customName.trimmed());
}
return result;
}