fix(cpn) Delete Label, Import models, Add fav
CMPN: Correct not reading models if no labels.yml CMPN: Fix crash if no delete with no label selected
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -11,7 +11,6 @@ class RadioData;
|
||||
|
||||
typedef struct {
|
||||
QString label;
|
||||
QModelIndex index;
|
||||
int radioLabelIndex;
|
||||
} LabelItem;
|
||||
|
||||
|
||||
@@ -137,6 +137,11 @@ bool LabelsStorageFormat::loadBin(RadioData & radioData)
|
||||
qDebug() << "Invalid line" <<line;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Add a Favorites label
|
||||
if(getCurrentFirmware()->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<std::string> filelist;
|
||||
if (!getFileList(filelist)) {
|
||||
return false;
|
||||
}
|
||||
// Scan for all models
|
||||
std::list<std::string> 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()) });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user