Various small fixes
This commit is contained in:
@@ -689,6 +689,7 @@ void TreeModel::refresh()
|
|||||||
defaultCategoryItem = rootItem->appendChild(0, -1);
|
defaultCategoryItem = rootItem->appendChild(0, -1);
|
||||||
/*: Translators do NOT use accent for this, this is the default category name on Horus. */
|
/*: Translators do NOT use accent for this, this is the default category name on Horus. */
|
||||||
defaultCategoryItem->setData(0, tr("Models"));
|
defaultCategoryItem->setData(0, tr("Models"));
|
||||||
|
radioData->categories.push_back(qPrintable(tr("Models")));
|
||||||
}
|
}
|
||||||
categoryItem = defaultCategoryItem;
|
categoryItem = defaultCategoryItem;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,8 @@ bool CategorizedStorageFormat::load(RadioData & radioData)
|
|||||||
if (st == STORAGE_TYPE_UNKNOWN) {
|
if (st == STORAGE_TYPE_UNKNOWN) {
|
||||||
st = probeFormat();
|
st = probeFormat();
|
||||||
}
|
}
|
||||||
if (st == STORAGE_TYPE_ETX || st == STORAGE_TYPE_YML) {
|
if (st == STORAGE_TYPE_ETX || st == STORAGE_TYPE_YML
|
||||||
|
|| st == STORAGE_TYPE_UNKNOWN) {
|
||||||
return loadYaml(radioData);
|
return loadYaml(radioData);
|
||||||
} else {
|
} else {
|
||||||
return loadBin(radioData);
|
return loadBin(radioData);
|
||||||
@@ -272,13 +273,14 @@ bool CategorizedStorageFormat::loadYaml(RadioData & radioData)
|
|||||||
// push default category
|
// push default category
|
||||||
radioData.categories.push_back("Models");
|
radioData.categories.push_back("Models");
|
||||||
|
|
||||||
const std::regex yml_regex("MODELS/(model[0-9]+\\.yml)");
|
const std::regex yml_regex("MODELS/(model([0-9]+)\\.yml)");
|
||||||
for(const auto& f : filelist) {
|
for(const auto& f : filelist) {
|
||||||
std::smatch match;
|
std::smatch match;
|
||||||
if (std::regex_match(f, match, yml_regex)) {
|
if (std::regex_match(f, match, yml_regex)) {
|
||||||
if (match.size() == 2) {
|
if (match.size() == 3) {
|
||||||
std::ssub_match modelFile = match[1];
|
std::ssub_match modelFile = match[1];
|
||||||
modelFiles.push_back({ modelFile.str(), "", 0, 0 });
|
std::ssub_match modelIdx = match[2];
|
||||||
|
modelFiles.push_back({ modelFile.str(), "", 0, std::stoi(modelIdx.str()) });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -304,6 +306,7 @@ bool CategorizedStorageFormat::loadYaml(RadioData & radioData)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int modelIdx = 0;
|
||||||
radioData.models.resize(modelFiles.size());
|
radioData.models.resize(modelFiles.size());
|
||||||
for (const auto& mc : modelFiles) {
|
for (const auto& mc : modelFiles) {
|
||||||
qDebug() << "Filename: " << mc.filename.c_str() << " / Category: " << mc.category;
|
qDebug() << "Filename: " << mc.filename.c_str() << " / Category: " << mc.category;
|
||||||
@@ -318,7 +321,7 @@ bool CategorizedStorageFormat::loadYaml(RadioData & radioData)
|
|||||||
// Please note:
|
// Please note:
|
||||||
// ModelData() use memset to clear everything to 0
|
// ModelData() use memset to clear everything to 0
|
||||||
//
|
//
|
||||||
auto& model = radioData.models[mc.modelIdx];
|
auto& model = radioData.models[modelIdx++];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!loadModelFromYaml(model,modelBuffer)) {
|
if (!loadModelFromYaml(model,modelBuffer)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user