#include "loqheaderviewcheckbox.h"

LoQHeaderViewCheckBox::LoQHeaderViewCheckBox(Qt::Orientation orientation, QWidget *parent, const QString &id) : QHeaderView(orientation, parent)
{
    qDebug() <<"LoQHeaderViewCheckBox -s";
    m_checkBox = new QCheckBox(this);
    m_checkBox->setProperty("ssType", "header");
    m_checkBox->setProperty("ssName", "selectAll");
    m_checkBox->setProperty("ssId"  , id);
    m_checkBox->setChecked(false);
    connect(m_checkBox, SIGNAL(toggled(bool)), this, SIGNAL(sigCheckAll(bool)));
    qDebug() <<"LoQHeaderViewCheckBox -o";
}
void LoQHeaderViewCheckBox::HideHeaderCheckBox(bool b)
{
    qDebug() <<"HideHeaderCheckBox -s";
    if(b)
        m_checkBox->hide();
    else {
        m_checkBox->show();
    }
    qDebug() <<"HideHeaderCheckBox -o";
}
void LoQHeaderViewCheckBox::paintSection(QPainter *painter, const QRect &rect, int logicalIndex) const
{
    QHeaderView::paintSection(painter, rect, logicalIndex);
    if (logicalIndex == 0) {
        m_checkBox->setGeometry(rect);
    }
}

void LoQHeaderViewCheckBox::onAllChecked(bool f)
{
    m_checkBox->blockSignals(true);
    m_checkBox->setChecked(f);
    m_checkBox->blockSignals(false);
}
