diff --git a/companion/src/modelslist.cpp b/companion/src/modelslist.cpp index 337553e5a..0bd2efac7 100644 --- a/companion/src/modelslist.cpp +++ b/companion/src/modelslist.cpp @@ -722,17 +722,17 @@ void TreeModel::refresh() } int protocol; QString rxs; - for (unsigned j=0; j 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, j)) { + if (!isModelIdUnique(mdlidx, protocol)) { current->setHighlightRX(true); } } @@ -746,15 +746,16 @@ void TreeModel::refresh() } } -bool TreeModel::isModelIdUnique(unsigned modelIdx, unsigned module) +bool TreeModel::isModelIdUnique(unsigned modelIdx, unsigned protocol) { int cnt = 0; - for (unsigned i=0; imodels.size(); i++) { - ModelData & model = radioData->models[i]; + for (auto const& model: radioData->models) { if (!model.isEmpty()) { - if (model.moduleData[module].protocol != PULSES_OFF && model.moduleData[module].modelId == modelIdx) { - if (++cnt > 1) { - return false; + for (auto const& moduleData: model.moduleData) { + 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 6aaebae92..3a5b2b714 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 module); + bool isModelIdUnique(unsigned modelId, unsigned protocol); TreeItem * rootItem; RadioData * radioData;