Newer
Older
#include "SubConfig.hpp"
SubConfig::SubConfig(BaseConfig & model) : model(model)
{
update();
}
{
unsigned int currentLastLineIndex = firstLineIndex + getNbLines();
if (currentLastLineIndex >= model.getNbLines()-1)
unsigned int newFirstLineIndex = firstLineIndex + 0.8*(currentLastLineIndex-firstLineIndex);
unsigned int newLastLineIndex = std::min(newFirstLineIndex + spanSize, model.getNbLines());
unsigned int newLineNumber = newLastLineIndex - newFirstLineIndex;
if (getNbLines() < newLineNumber)
resizeLines(newLineNumber);
{
auto linesBegin = getIterator(0, firstLineIndex, 0);
auto firstToSave = getConstIterator(0, newFirstLineIndex, 0);
auto lastToSave = getConstIterator(0, currentLastLineIndex, 0);
while (firstToSave != lastToSave)
(*linesBegin++) = (*firstToSave++);
}
if (getNbLines() > newLineNumber)
resizeLines(newLineNumber);
{
unsigned int nbLinesCopied = currentLastLineIndex - newFirstLineIndex;
auto newlinesBegin = getIterator(0, firstLineIndex+nbLinesCopied, 0);
auto firstToSave = model.getConstIterator(0, currentLastLineIndex, 0);
auto lastToSave = model.getConstIterator(0, newLastLineIndex, 0);
while (firstToSave != lastToSave)
(*newlinesBegin++) = (*firstToSave++);
firstLineIndex = newFirstLineIndex;
}
}
std::size_t SubConfig::getNbColumns() const
{
return model.getNbColumns();
}
std::size_t SubConfig::getColIndex(const std::string & colName) const
{
return model.getColIndex(colName);
}
const std::string & SubConfig::getColName(int colIndex) const
{
return model.getColName(colIndex);
}
std::size_t SubConfig::getFirstLineIndex() const
{
return firstLineIndex;
}