#include "cctrlparamslider.h"

#include <QStringList>
CCtrlParamSlider::CCtrlParamSlider(QWidget *parent) : CCtrlParamBase(parent)
{

    sliderparam=new QSlider(Qt::Horizontal,this);
    sliderparam->setSizePolicy(m_hor,m_ver);
    labelparam=new QLabel(this);
    labelparam->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
    layout->addWidget(sliderparam);
    layout->addWidget(labelparam);
    layout->addWidget(staticuint);
    staticname->setMinimumWidth(60);
    labelparam->setMinimumWidth(50);
    sliderparam->setValue(0);
    labelparam->setNum(0);
    setLayout(layout);
 //   labelparam->setBuddy(sliderparam);
    connect(sliderparam,SIGNAL(valueChanged(int)),labelparam,SLOT(setNum(int)));
}

void CCtrlParamSlider::MParamInit(Variant *pParam)
{
    CCtrlParamBase::MParamInit(pParam);

    QStringList list=pParam->m_slRange;
    Q_ASSERT(list.size()>=2);
    sliderparam->setRange(list.at(0).toInt(),list.at(1).toInt());
}

void CCtrlParamSlider::MTimeFresh()
{

}

void CCtrlParamSlider::MFresh()
{
     if(!m_pParam||m_pParam->m_vVar.type()!=QVariant::Int) return;
        sliderparam->setValue(m_pParam->m_vVar.toInt());
}

void CCtrlParamSlider::MApply()
{
    m_pParam->m_vVar.setValue(sliderparam->value());
}

