From 5afe15be83fb907637cb78aa213b984fb5f74666 Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Mon, 16 Sep 2019 08:46:22 +0200 Subject: [PATCH] match module as well, not just protocol (#6794) --- companion/src/modelslist.cpp | 16 +++++++++------- companion/src/modelslist.h | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/companion/src/modelslist.cpp b/companion/src/modelslist.cpp index 0bd2efac7..d606e7e74 100644 --- a/companion/src/modelslist.cpp +++ b/companion/src/modelslist.cpp @@ -722,6 +722,7 @@ void TreeModel::refresh() } int protocol; QString rxs; + 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 @@ -732,10 +733,11 @@ void TreeModel::refresh() } unsigned mdlidx = moduleData.modelId; rxs.append(QString("%1").arg(uint(mdlidx), 2, 10, QChar('0'))); - if (!isModelIdUnique(mdlidx, protocol)) { + if (!isModelIdUnique(mdlidx, moduleIdx, protocol)) { current->setHighlightRX(true); } } + moduleIdx++; } current->setData(currentColumn++, rxs); } @@ -746,16 +748,16 @@ void TreeModel::refresh() } } -bool TreeModel::isModelIdUnique(unsigned modelIdx, unsigned protocol) +bool TreeModel::isModelIdUnique(unsigned modelIdx, unsigned module, unsigned protocol) { int cnt = 0; for (auto const& model: radioData->models) { if (!model.isEmpty()) { - for (auto const& moduleData: model.moduleData) { - if (moduleData.protocol == protocol && moduleData.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; } } } diff --git a/companion/src/modelslist.h b/companion/src/modelslist.h index 3a5b2b714..135e8b28d 100644 --- a/companion/src/modelslist.h +++ b/companion/src/modelslist.h @@ -149,7 +149,7 @@ class TreeModel : public QAbstractItemModel private: TreeItem * getItem(const QModelIndex & index) const; - bool isModelIdUnique(unsigned modelId, unsigned protocol); + bool isModelIdUnique(unsigned modelId, unsigned module, unsigned protocol); TreeItem * rootItem; RadioData * radioData;