Exemple #1
0
void* Listener(void*)
{
	while(1)
	{
		if(RawMode)
		{
			displayRaw();
		}
		else
		{
			displayRead();
		}
	}
	return NULL;
}
gNodeComponentWidget::gNodeComponentWidget(sJarvisNodeComponent* comp,QWidget *parent) :
    QGroupBox(parent), m_component(comp),
    ui(new Ui::gNodeComponentWidget)
{
    ui->setupUi(this);

    this->setTitle(m_component->getId());

    QList<jarvisActions> actions = m_component->getActions();
    for(int i = 0 ; i < actions.count() ; i++)
    {
        jarvisActions action = actions[i];
        //qDebug() << QString::number(int(action));
        QToolButton* b = new QToolButton(ui->actionsBox);
        QGridLayout* l = (QGridLayout*)ui->actionsBox->layout();

        if      (action == A_DIMM){
            b->deleteLater();
            QSlider* w = new QSlider(this);
            w->setMaximum(100);
            w->setValue(50);
            l->addWidget(w,l->count()/2,l->count()%2);
            connect(w,SIGNAL(valueChanged(int)),m_component,SLOT(dimm(int)));

        }else if(action == A_SET_COLOR){
            connect(b,SIGNAL(clicked()),this,SLOT(selectComponentColor()));
            b->setText(m_component->actionName((m_component->getActions()[i])));
            l->addWidget(b,l->count()/2,l->count()%2);

        }else if(action == A_SET_LEDS){
            connect(b,SIGNAL(clicked()),this,SLOT(sendImage()));
            b->setText(m_component->actionName((m_component->getActions()[i])));
            l->addWidget(b,l->count()/2,l->count()%2);

        }else if(action == A_DISPLAY){
            connect(b,SIGNAL(clicked()),this,SLOT(sendImage()));
            b->setText(m_component->actionName((m_component->getActions()[i])));
            l->addWidget(b,l->count()/2,l->count()%2);
        }else if(action == A_PLAYRTTTL){
            connect(b,SIGNAL(clicked()),this,SLOT(openRtttlPlayer()));
            b->setText(m_component->actionName((m_component->getActions()[i])));
            l->addWidget(b,l->count()/2,l->count()%2);
        }else{
            QString slotName = m_component->slotName(m_component->getActions()[i]);
            b->setText(m_component->actionName((m_component->getActions()[i])));
            l->addWidget(b,l->count()/2,l->count()%2);
            connect(b,SIGNAL(clicked()),m_component,slotName.toStdString().c_str());
        }
    }

    QList<jarvisEvents> events = m_component->getCapableEvents();
    for(int i = 0 ; i < events.count() ; i++)
    {
        gBlinkWidget* w = new gBlinkWidget(ui->eventsBox);
        QLabel* label = new QLabel(ui->eventsBox);
        QGridLayout* l = (QGridLayout*)ui->eventsBox->layout();
        l->addWidget(label,i,0);
        l->addWidget(w,i,1);
        w->setMaximumHeight(50);
        if(events[i] == E_RAW_READ)
        {
            connect(m_component,SIGNAL(rawRead()),w,SLOT(blink()));
            connect(m_component,SIGNAL(rawRead(QStringList)),w,SLOT(displayRead(QStringList)));
            label->setText(m_component->eventName((m_component->getCapableEvents()[i])));

        }else if(events[i] == E_DATA_READ)
        {
            connect(m_component,SIGNAL(dataRead()),w,SLOT(blink()));
            connect(m_component,SIGNAL(dataRead(QStringList)),w,SLOT(displayRead(QStringList)));
            label->setText(m_component->eventName((m_component->getCapableEvents()[i])));

        }else
        {
            QString signalName = m_component->signalName(m_component->getCapableEvents()[i]);
            label->setText(m_component->eventName((m_component->getCapableEvents()[i])));
            connect(m_component,signalName.toStdString().c_str(),w,SLOT(blink()));
        }
        //w->setMinimumSize(32,32);
        //w->setMaximumSize(32,32);
    }
}