/**
********************************************************************************
\brief  constructor

Constructs a NodeState widget. The NodeState widget is used to show the
POWERLINK state of a node.
*******************************************************************************/
NodeState::NodeState(const QString &label_p, QWidget *parent)
    : QWidget(parent)
{
    m_pRedLed  = new QPixmap(":/img/ledred.png");
    m_pYellowLed = new QPixmap(":/img/ledyellow.png");
    m_pGreenLed = new QPixmap(":/img/ledgreen.png");

    // ---------------------------------------------------------------------
    // Layout
    // ---------------------------------------------------------------------
    QHBoxLayout *pStateLayout = new QHBoxLayout;
    setLayout(pStateLayout);

    setContentsMargins(0, 0, 0, 0);

    QLabel *pStateLabel = new QLabel(label_p);
    QFont tmpFont1("Arial", 18, QFont::Bold);
    pStateLabel->setFont(tmpFont1);
    pStateLayout->addWidget(pStateLabel);

    pStateLayout->addStretch();

    // create array for pointers to LedButtons
    m_pLedLabel = new QLabel();
    m_pLedLabel->setPixmap(*m_pRedLed);
    pStateLayout->addWidget(m_pLedLabel);

    pStateLayout->update();
}
//------------------------------------------------------------------------------
Leds::Leds(int count_p, QWidget* parent_p)
    : QWidget(parent_p)
{
    int nIdx;

    count = count_p;

    QHBoxLayout* pLedsLayout = new QHBoxLayout;
    setLayout(pLedsLayout);

    setContentsMargins(0, 0, 0, 0);

    // create array for pointers to LedButtons
    ppLedLabels = new QLabel*[count_p];

    pActiveLed  = new QPixmap(":/img/ledred.png");
    pInactiveLed = new QPixmap(":/img/ledgreen.png");

    for (nIdx = 0; nIdx < count_p; nIdx++)
    {
        ppLedLabels[nIdx] = new QLabel(parent_p);
        ppLedLabels[nIdx]->setPixmap(*pInactiveLed);
        pLedsLayout->addWidget(ppLedLabels[nIdx]);
    }
    pLedsLayout->update();
}