Raphaelcoeffic/fix 6765 2.3 (#6795)

* match module as well, not just protocol

* check unique RX# based on protocol (#6781)
This commit is contained in:
Raphael Coeffic
2019-09-16 08:47:11 +02:00
committed by Bertrand Songis
parent e9186e0c54
commit 526d892d6f
2 changed files with 15 additions and 14 deletions
+14 -13
View File
@@ -722,20 +722,22 @@ void TreeModel::refresh()
}
int protocol;
QString rxs;
for (unsigned j=0; j<CPN_MAX_MODULES; j++) {
protocol = model.moduleData[j].protocol;
unsigned moduleIdx = 0;
for (auto const& moduleData: model.moduleData) {
protocol = moduleData.protocol;
// These are the only RXs that allow nominating RX # but changing RX or copying models can leave residual configuration which can cause issues
// if (protocol == PULSES_PXX_XJT_X16 || protocol == PULSES_PXX_XJT_LR12 || protocol == PULSES_PXX_R9M || protocol == PULSES_DSMX || protocol == PULSES_MULTIMODULE) {
if (protocol != PULSES_OFF && model.moduleData[j].modelId > 0) {
if (protocol != PULSES_OFF && moduleData.modelId > 0) {
if (!rxs.isEmpty()) {
rxs.append(", ");
}
unsigned mdlidx = model.moduleData[j].modelId;
unsigned mdlidx = moduleData.modelId;
rxs.append(QString("%1").arg(uint(mdlidx), 2, 10, QChar('0')));
if (!isModelIdUnique(mdlidx)) {
if (!isModelIdUnique(mdlidx, moduleIdx, protocol)) {
current->setHighlightRX(true);
}
}
moduleIdx++;
}
current->setData(currentColumn++, rxs);
}
@@ -746,17 +748,16 @@ void TreeModel::refresh()
}
}
bool TreeModel::isModelIdUnique(unsigned modelIdx)
bool TreeModel::isModelIdUnique(unsigned modelIdx, unsigned module, unsigned protocol)
{
int cnt = 0;
for (unsigned i=0; i<radioData->models.size(); i++) {
ModelData & model = radioData->models[i];
for (auto const& model: radioData->models) {
if (!model.isEmpty()) {
for (unsigned j=0; j<CPN_MAX_MODULES; j++) {
if (model.moduleData[j].protocol != PULSES_OFF && model.moduleData[j].modelId == modelIdx) {
if (++cnt > 1) {
return false;
}
unsigned moduleIdx = 0;
const ModuleData& moduleData = model.moduleData[module];
if (moduleData.protocol == protocol && moduleData.modelId == modelIdx) {
if (++cnt > 1) {
return false;
}
}
}
+1 -1
View File
@@ -149,7 +149,7 @@ class TreeModel : public QAbstractItemModel
private:
TreeItem * getItem(const QModelIndex & index) const;
bool isModelIdUnique(unsigned modelId);
bool isModelIdUnique(unsigned modelId, unsigned module, unsigned protocol);
TreeItem * rootItem;
RadioData * radioData;