<commit_before><commit_msg>Create griddefinition.cpp<commit_after>#include "griddefinition.h"

GridDefinition::GridDefinition() :
    _rowSize(0.0f),
    _columnSize(0.0f),
    _invRowSize(0.0f),
    _invColumnSize(0.0f)
{
}

void GridDefinition::addRowDefinition(float size)
{
    _rows << GridCell(size, _rowSize);

    _rowSize += size;
    _invRowSize = 1.0f / _rowSize;
}

void GridDefinition::addColumnDefinition(float size)
{
    _columns << GridCell(size, _columnSize);

    _columnSize += size;
    _invColumnSize = 1.0f / _columnSize;
}

int GridDefinition::rowCount() const
{
    return _rows.size();
}

int GridDefinition::columnCount() const
{
    return _columns.size();
}

float GridDefinition::rowOffset(int index)
{
    return _rows[index]._offset * _invRowSize;
}

float GridDefinition::columnOffset(int index)
{
    return _columns[index]._offset * _invColumnSize;
}

float GridDefinition::rowWeight(int index)
{
    return _rows[index]._weight * _invRowSize;
}

float GridDefinition::columnWeight(int index)
{
    return _columns[index]._weight * _invColumnSize;
}

QPoint GridDefinition::cellPoint(QRect rect, int row, int column)
{
    return QPoint(columnOffset(column) * rect.width() + rect.x(), rowOffset(row) * rect.height() + rect.y());
}

QSize GridDefinition::cellSize(QRect rect, int row, int column, int rowSpan, int columnSpan)
{
    QSize
        size;

    for(int end = qMin(row + rowSpan, rowCount()); row < end; row++)
    {
        size.rheight() += rowWeight(row) * rect.height();
    }

    for(int end = qMin(column + columnSpan, columnCount()); column < end; column++)
    {
        size.rwidth() += columnWeight(column) * rect.width();
    }

    return size;
}

QRect GridDefinition::cellRect(QRect rect, int row, int column, int rowSpan, int columnSpan)
{
    return QRect(cellPoint(rect, row, column), cellSize(rect, row, column, rowSpan, columnSpan));
}
{'fraction_non_alphanumeric': 0.13631578947368422, 'fraction_numerical': 0.00631578947368421, 'mean_word_length': 4.295264623955432, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2712208', 'n_tokens_mistral': 639, 'n_tokens_neox': 631, 'n_words': 135}