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)
|
bool LabelsModel::removeRows(int row, int count, const QModelIndex &parent)
|
||||||
{
|
{
|
||||||
if (parent.isValid())
|
if (parent.isValid() || row < 0)
|
||||||
return false;
|
return false;
|
||||||
bool deleted=false;
|
bool deleted=false;
|
||||||
beginRemoveRows(parent, row, row + count - 1);
|
beginRemoveRows(parent, row, row + count - 1);
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ class RadioData;
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
QString label;
|
QString label;
|
||||||
QModelIndex index;
|
|
||||||
int radioLabelIndex;
|
int radioLabelIndex;
|
||||||
} LabelItem;
|
} LabelItem;
|
||||||
|
|
||||||
|
|||||||
@@ -137,6 +137,11 @@ bool LabelsStorageFormat::loadBin(RadioData & radioData)
|
|||||||
qDebug() << "Invalid line" <<line;
|
qDebug() << "Invalid line" <<line;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add a Favorites label
|
||||||
|
if(getCurrentFirmware()->getCapability(HasModelLabels)) {
|
||||||
|
radioData.labels.append(tr("Favorites"));
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -221,22 +226,22 @@ bool LabelsStorageFormat::loadYaml(RadioData & radioData)
|
|||||||
} catch(const std::runtime_error& e) {
|
} catch(const std::runtime_error& e) {
|
||||||
setError(tr("Can't load MODELS/labels.yml") + ":\n" + QString(e.what()));
|
setError(tr("Can't load MODELS/labels.yml") + ":\n" + QString(e.what()));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Scan for all models
|
// Scan for all models
|
||||||
std::list<std::string> filelist;
|
std::list<std::string> filelist;
|
||||||
if (!getFileList(filelist)) {
|
if (!getFileList(filelist)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
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() == 3) {
|
if (match.size() == 3) {
|
||||||
std::ssub_match modelFile = match[1];
|
std::ssub_match modelFile = match[1];
|
||||||
std::ssub_match modelIdx = match[2];
|
std::ssub_match modelIdx = match[2];
|
||||||
modelFiles.push_back({ modelFile.str(), "", std::stoi(modelIdx.str()) });
|
modelFiles.push_back({ modelFile.str(), "", std::stoi(modelIdx.str()) });
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user