void ColorSchemeGraphicsItem::updateRects()
{
    qDeleteAll(m_rects);
    m_rects.clear();

    const auto parent = dynamic_cast<QWidget*>(parentWidget());
    const auto dpiScale = DpiAware::dpiBasedScale(parent);
    const auto invRatio = 1.0 / DpiAware::devicePixelRatio(parent);

    const QSize rectSize = m_rectSize.toSize() * dpiScale;
    const int margin  = m_margin * dpiScale; // this is required to be an int

    auto pen = QPen(QPalette().dark().color());
    pen.setWidthF(invRatio);

    for (uint i = 0; i < m_classes; ++i)
    {
        auto rect = new QGraphicsRectItem(this);

        rect->setPen(pen);

        rect->setRect(margin, margin + i * (rectSize.height() + m_padding), rectSize.width(), rectSize.height());
        m_rects << rect;
    }

    updateBrushes();
    updateTooltips();

    m_frame->setRect(0, 0, rectSize.width() + 2.0 * margin + invRatio,
        rectSize.height() * m_classes + m_padding * (m_classes - 1) + 2.0 * margin + invRatio);  
    
    update();
}
void DataSourceControlWidget::treatLineWidthChanging()
{
    if (mDataSource) {
        auto graphStyle = mDataSource->graphStyle();
        auto pen = graphStyle->pen();
        pen.setWidthF(ui->lineWidthDoubleSpinBox->value());
        graphStyle->setPen(pen);
    }
}