UASQuickViewItemSelect.cc 996 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
#include "UASQuickViewItemSelect.h"
#include <QLabel>
#include <QCheckBox>
UASQuickViewItemSelect::UASQuickViewItemSelect(QWidget *parent) : QWidget(parent)
{
    ui.setupUi(this);
    currcol = 0;
    currrow = 0;
}
void UASQuickViewItemSelect::addItem(QString item,bool enabled)
{
    QCheckBox *label = new QCheckBox(this);
    if (enabled)
    {
        label->setChecked(true);
    }
    connect(label,SIGNAL(clicked(bool)),this,SLOT(checkBoxClicked(bool)));
    label->setText(item);
    label->show();
    ui.gridLayout->addWidget(label,currrow,currcol++);
    if (currcol > 10)
    {
        currcol = 0;
        currrow++;
    }
}
void UASQuickViewItemSelect::checkBoxClicked(bool checked)
{
    QCheckBox *check = qobject_cast<QCheckBox*>(sender());
    if (!check)
    {
        return;
    }
    if (checked)
    {
        emit valueEnabled(check->text());
    }
    else
    {
        emit valueDisabled(check->text());
    }
}

UASQuickViewItemSelect::~UASQuickViewItemSelect()
{
}