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:
dlktdr
2022-09-06 21:04:10 +10:00
committed by Peter Feerick
parent c103abb58b
commit 32a6f792b9
3 changed files with 20 additions and 16 deletions
+1 -1
View File
@@ -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);
-1
View File
@@ -11,7 +11,6 @@ class RadioData;
typedef struct { typedef struct {
QString label; QString label;
QModelIndex index;
int radioLabelIndex; int radioLabelIndex;
} LabelItem; } LabelItem;
+6 -1
View File
@@ -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,6 +226,7 @@ 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;
@@ -239,7 +245,6 @@ bool LabelsStorageFormat::loadYaml(RadioData & radioData)
} }
} }
} }
}
int modelIdx = 0; int modelIdx = 0;
bool hasLabels = getCurrentFirmware()->getCapability(HasModelLabels); bool hasLabels = getCurrentFirmware()->getCapability(HasModelLabels);