diff --git a/companion/src/labels.cpp b/companion/src/labels.cpp index 4c9bd6427..20423fcc8 100644 --- a/companion/src/labels.cpp +++ b/companion/src/labels.cpp @@ -228,7 +228,7 @@ bool LabelsModel::insertRows(int row, int count, const QModelIndex &parent) bool LabelsModel::removeRows(int row, int count, const QModelIndex &parent) { - if (parent.isValid()) + if (parent.isValid() || row < 0) return false; bool deleted=false; beginRemoveRows(parent, row, row + count - 1); diff --git a/companion/src/labels.h b/companion/src/labels.h index 811a6bc5a..6361f4cab 100644 --- a/companion/src/labels.h +++ b/companion/src/labels.h @@ -11,7 +11,6 @@ class RadioData; typedef struct { QString label; - QModelIndex index; int radioLabelIndex; } LabelItem; diff --git a/companion/src/storage/labeled.cpp b/companion/src/storage/labeled.cpp index 0289582d7..8cb2ed177 100644 --- a/companion/src/storage/labeled.cpp +++ b/companion/src/storage/labeled.cpp @@ -137,6 +137,11 @@ bool LabelsStorageFormat::loadBin(RadioData & radioData) qDebug() << "Invalid line" <getCapability(HasModelLabels)) { + radioData.labels.append(tr("Favorites")); + } return true; } @@ -221,22 +226,22 @@ bool LabelsStorageFormat::loadYaml(RadioData & radioData) } catch(const std::runtime_error& e) { setError(tr("Can't load MODELS/labels.yml") + ":\n" + QString(e.what())); } + } - // Scan for all models - std::list filelist; - if (!getFileList(filelist)) { - return false; - } + // Scan for all models + std::list filelist; + if (!getFileList(filelist)) { + return false; + } - const std::regex yml_regex("MODELS/(model([0-9]+)\\.yml)"); - for(const auto& f : filelist) { - std::smatch match; - if (std::regex_match(f, match, yml_regex)) { - if (match.size() == 3) { - std::ssub_match modelFile = match[1]; - std::ssub_match modelIdx = match[2]; - modelFiles.push_back({ modelFile.str(), "", std::stoi(modelIdx.str()) }); - } + const std::regex yml_regex("MODELS/(model([0-9]+)\\.yml)"); + for(const auto& f : filelist) { + std::smatch match; + if (std::regex_match(f, match, yml_regex)) { + if (match.size() == 3) { + std::ssub_match modelFile = match[1]; + std::ssub_match modelIdx = match[2]; + modelFiles.push_back({ modelFile.str(), "", std::stoi(modelIdx.str()) }); } } }