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:
parent
c6ae44f523
commit
83294613f6
63 changed files with 4166 additions and 2295 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue