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
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -430,6 +430,11 @@ protected:
}
};
const std::vector<Row> &rows() const
{
return this->rows_;
}
private:
std::vector<QMap<int, QVariant>> headerData_;
SignalVector<TVectorItem> *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;
}
i++;
return modelIndex;
}
return i;
modelIndex++;
}
return modelIndex;
}
};