From 85f6795f7015bcb19ffad5f349e535e11530f038 Mon Sep 17 00:00:00 2001 From: pajlada Date: Fri, 12 Nov 2021 17:26:38 +0100 Subject: [PATCH] Refactor parts of SignalVectorModel (#3342) --- src/common/SignalVectorModel.hpp | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/common/SignalVectorModel.hpp b/src/common/SignalVectorModel.hpp index e2b0a71b7..5054eaffc 100644 --- a/src/common/SignalVectorModel.hpp +++ b/src/common/SignalVectorModel.hpp @@ -430,6 +430,11 @@ protected: } }; + const std::vector &rows() const + { + return this->rows_; + } + private: std::vector> headerData_; SignalVector *vector_; @@ -460,26 +465,28 @@ private: return i; } +public: // returns the related index of the model - int getModelIndexFromVectorIndex(int index) + int getModelIndexFromVectorIndex(int vectorIndex) const { - int i = 0; + int modelIndex = 0; - for (auto &row : this->rows_) + for (auto &row : this->rows()) { if (row.isCustomRow) { - index++; + vectorIndex++; } - if (i == index) + if (modelIndex == vectorIndex) { - return i; + return modelIndex; } - i++; + + modelIndex++; } - return i; + return modelIndex; } };