File: hamlibnetworkconfigwidget.cpp

package info (click to toggle)
klog 2.4.2-3
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 12,228 kB
  • sloc: cpp: 51,678; makefile: 15
file content (66 lines) | stat: -rw-r--r-- 2,106 bytes parent folder | download | duplicates (2)
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include "hamlibnetworkconfigwidget.h"

HamLibNetworkConfigWidget::HamLibNetworkConfigWidget(QWidget *parent) : QWidget(parent)
{
    //qDebug() << Q_FUNC_INFO;
    hostAddressLineEdit = new QLineEdit();
    portQSpinBox = new QSpinBox;
    //qDebug() << Q_FUNC_INFO << " - END";
}

void HamLibNetworkConfigWidget::createUI()
{
    portQSpinBox->setMaximum (65535);
    portQSpinBox->setMinimum (0);
    hostAddressLineEdit->setToolTip (tr("Enter the hostname or address of the radio."));
    portQSpinBox->setToolTip (tr("Set de network port of the radio."));

    //portQSpinBox->setValue (rigctlport);
    QLabel *hostAddLabel = new QLabel(tr("Host/Address"));
    hostAddLabel->setBuddy(hostAddressLineEdit);
    hostAddLabel->setToolTip(tr("Enter the hostname or address of the radio."));
    hostAddLabel->setAlignment(Qt::AlignVCenter| Qt::AlignCenter);
    hostAddLabel->setEnabled(true);

    QLabel *portNetLabel = new QLabel(tr("Port"));
    portNetLabel->setBuddy(portQSpinBox);
    portNetLabel->setToolTip(tr("Enter the port of the radio."));
    portNetLabel->setAlignment(Qt::AlignVCenter| Qt::AlignCenter);
    portNetLabel->setEnabled(true);

    QGridLayout *networkLayout = new QGridLayout;
    //qDebug() << Q_FUNC_INFO << " - 120";
    networkLayout->addWidget (hostAddLabel, 0, 0);
    networkLayout->addWidget (hostAddressLineEdit, 0, 1);
    networkLayout->addWidget (portNetLabel, 1, 0);
    networkLayout->addWidget (portQSpinBox, 1, 1);

    //networkGroup->setLayout (networkLayout);
    setLayout (networkLayout);
    //qDebug() << Q_FUNC_INFO << " - END";
}

int HamLibNetworkConfigWidget::getPort()
{
    return portQSpinBox->value ();
}

void HamLibNetworkConfigWidget::setPort (const int _b)
{//TODO: Check that
    if ((_b<0) || (_b>65535))
    {
        return;
    }
    portQSpinBox->setValue (_b);
}

QString HamLibNetworkConfigWidget::getAddress()
{
    return hostAddressLineEdit->text ();
}

void HamLibNetworkConfigWidget::setAddress(const QString &_st)
{ //TODO: Check that what is arriving is a hostname or IP address
    hostAddressLineEdit->setText (_st);
}