Refactor parts of SignalVectorModel (#3342)

This commit is contained in:
pajlada
2021-11-12 17:26:38 +01:00
committed by GitHub
parent bc0b7e4d99
commit 85f6795f70
+15 -8
View File
@@ -430,6 +430,11 @@ protected:
} }
}; };
const std::vector<Row> &rows() const
{
return this->rows_;
}
private: private:
std::vector<QMap<int, QVariant>> headerData_; std::vector<QMap<int, QVariant>> headerData_;
SignalVector<TVectorItem> *vector_; SignalVector<TVectorItem> *vector_;
@@ -460,26 +465,28 @@ private:
return i; return i;
} }
public:
// returns the related index of the model // 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) if (row.isCustomRow)
{ {
index++; vectorIndex++;
} }
if (i == index) if (modelIndex == vectorIndex)
{ {
return i; return modelIndex;
} }
i++;
modelIndex++;
} }
return i; return modelIndex;
} }
}; };