@@ -0,0 +1,119 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the SocExplorer Software | |
|
3 | -- Copyright (C) 2014, Laboratory of Plasmas Physic - CNRS | |
|
4 | -- | |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
|
6 | -- it under the terms of the GNU General Public License as published by | |
|
7 | -- the Free Software Foundation; either version 2 of the License, or | |
|
8 | -- (at your option) any later version. | |
|
9 | -- | |
|
10 | -- This program is distributed in the hope that it will be useful, | |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|
13 | -- GNU General Public License for more details. | |
|
14 | -- | |
|
15 | -- You should have received a copy of the GNU General Public License | |
|
16 | -- along with this program; if not, write to the Free Software | |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
|
18 | -------------------------------------------------------------------------------*/ | |
|
19 | /*-- Author : Paul Leroy | |
|
20 | -- Mail : paul.leroy@lpp.polytechnique.fr | |
|
21 | ----------------------------------------------------------------------------*/ | |
|
22 | #include "qipdialogbox.h" | |
|
23 | #include <QSpinBox> | |
|
24 | #include <QHBoxLayout> | |
|
25 | #include <QVBoxLayout> | |
|
26 | #include <QLabel> | |
|
27 | #include <QString> | |
|
28 | #include <QLocale> | |
|
29 | ||
|
30 | QIPDialogBox::QIPDialogBox(QWidget *parent) : | |
|
31 | QWidget(parent) | |
|
32 | { | |
|
33 | QHBoxLayout *addressLayout = new QHBoxLayout; | |
|
34 | QVBoxLayout *mainLayout = new QVBoxLayout; | |
|
35 | addressPart1 = new QSpinBox; | |
|
36 | addressPart2 = new QSpinBox; | |
|
37 | addressPart3 = new QSpinBox; | |
|
38 | addressPart4 = new QSpinBox; | |
|
39 | ||
|
40 | addressPart1->setRange(0, 255); | |
|
41 | addressPart1->setValue(129); | |
|
42 | addressPart1->setButtonSymbols(QAbstractSpinBox::NoButtons); | |
|
43 | ||
|
44 | addressPart2->setRange(0, 255); | |
|
45 | addressPart2->setValue(104); | |
|
46 | addressPart2->setButtonSymbols(QAbstractSpinBox::NoButtons); | |
|
47 | ||
|
48 | addressPart3->setRange(0, 255); | |
|
49 | addressPart3->setValue(27); | |
|
50 | addressPart3->setButtonSymbols(QAbstractSpinBox::NoButtons); | |
|
51 | ||
|
52 | addressPart4->setRange(0, 255); | |
|
53 | addressPart4->setValue(113); | |
|
54 | addressPart4->setButtonSymbols(QAbstractSpinBox::NoButtons); | |
|
55 | ||
|
56 | valueChanged(); | |
|
57 | ||
|
58 | connect(addressPart1, SIGNAL(valueChanged(int)), this, SLOT(valueChanged())); | |
|
59 | connect(addressPart2, SIGNAL(valueChanged(int)), this, SLOT(valueChanged())); | |
|
60 | connect(addressPart3, SIGNAL(valueChanged(int)), this, SLOT(valueChanged())); | |
|
61 | connect(addressPart4, SIGNAL(valueChanged(int)), this, SLOT(valueChanged())); | |
|
62 | ||
|
63 | addressLayout->addWidget(addressPart1); | |
|
64 | addressLayout->addWidget(addressPart2); | |
|
65 | addressLayout->addWidget(addressPart3); | |
|
66 | addressLayout->addWidget(addressPart4); | |
|
67 | mainLayout->addLayout(addressLayout); | |
|
68 | //mainLayout->addWidget(labelGRESBIP); | |
|
69 | ||
|
70 | setLayout(mainLayout); | |
|
71 | } | |
|
72 | ||
|
73 | void QIPDialogBox::valueChanged() // SLOT | |
|
74 | { | |
|
75 | gresbIP = addressPart1->cleanText(); | |
|
76 | gresbIP.append("."); | |
|
77 | gresbIP.append(addressPart2->cleanText()); | |
|
78 | gresbIP.append("."); | |
|
79 | gresbIP.append(addressPart3->cleanText()); | |
|
80 | gresbIP.append("."); | |
|
81 | gresbIP.append(addressPart4->cleanText()); | |
|
82 | } | |
|
83 | ||
|
84 | QString QIPDialogBox::getIP() | |
|
85 | { | |
|
86 | return(gresbIP); | |
|
87 | } | |
|
88 | ||
|
89 | void QIPDialogBox::setIP(unsigned char address1, unsigned char address2, unsigned char address3, unsigned char address4) | |
|
90 | { | |
|
91 | addressPart1->setValue(address1); | |
|
92 | addressPart2->setValue(address2); | |
|
93 | addressPart3->setValue(address3); | |
|
94 | addressPart4->setValue(address4); | |
|
95 | addressPart1->repaint(); | |
|
96 | addressPart2->repaint(); | |
|
97 | addressPart3->repaint(); | |
|
98 | addressPart4->repaint(); | |
|
99 | } | |
|
100 | ||
|
101 | unsigned char QIPDialogBox::get_addressPart1() | |
|
102 | { | |
|
103 | return (unsigned char) addressPart1->value(); | |
|
104 | } | |
|
105 | ||
|
106 | unsigned char QIPDialogBox::get_addressPart2() | |
|
107 | { | |
|
108 | return (unsigned char) addressPart2->value(); | |
|
109 | } | |
|
110 | ||
|
111 | unsigned char QIPDialogBox::get_addressPart3() | |
|
112 | { | |
|
113 | return (unsigned char) addressPart3->value(); | |
|
114 | } | |
|
115 | ||
|
116 | unsigned char QIPDialogBox::get_addressPart4() | |
|
117 | { | |
|
118 | return (unsigned char) addressPart4->value(); | |
|
119 | } |
@@ -0,0 +1,55 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the SocExplorer Software | |
|
3 | -- Copyright (C) 2014, Laboratory of Plasmas Physic - CNRS | |
|
4 | -- | |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
|
6 | -- it under the terms of the GNU General Public License as published by | |
|
7 | -- the Free Software Foundation; either version 2 of the License, or | |
|
8 | -- (at your option) any later version. | |
|
9 | -- | |
|
10 | -- This program is distributed in the hope that it will be useful, | |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|
13 | -- GNU General Public License for more details. | |
|
14 | -- | |
|
15 | -- You should have received a copy of the GNU General Public License | |
|
16 | -- along with this program; if not, write to the Free Software | |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
|
18 | -------------------------------------------------------------------------------*/ | |
|
19 | /*-- Author : Paul Leroy | |
|
20 | -- Mail : paul.leroy@lpp.polytechnique.fr | |
|
21 | ----------------------------------------------------------------------------*/ | |
|
22 | #ifndef WIDGETADDRESS_H | |
|
23 | #define WIDGETADDRESS_H | |
|
24 | ||
|
25 | #include <QWidget> | |
|
26 | #include <QSpinBox> | |
|
27 | #include <QString> | |
|
28 | #include <QLabel> | |
|
29 | ||
|
30 | class QIPDialogBox : public QWidget | |
|
31 | { | |
|
32 | Q_OBJECT | |
|
33 | public: | |
|
34 | explicit QIPDialogBox(QWidget *parent = 0); | |
|
35 | void setIP(unsigned char address1, unsigned char address2, unsigned char address3, unsigned char address4); | |
|
36 | ||
|
37 | signals: | |
|
38 | ||
|
39 | public slots: | |
|
40 | void valueChanged(); | |
|
41 | QString getIP(); | |
|
42 | unsigned char get_addressPart1(); | |
|
43 | unsigned char get_addressPart2(); | |
|
44 | unsigned char get_addressPart3(); | |
|
45 | unsigned char get_addressPart4(); | |
|
46 | ||
|
47 | private: | |
|
48 | QSpinBox *addressPart1; | |
|
49 | QSpinBox *addressPart2; | |
|
50 | QSpinBox *addressPart3; | |
|
51 | QSpinBox *addressPart4; | |
|
52 | QString gresbIP; | |
|
53 | }; | |
|
54 | ||
|
55 | #endif // WIDGETADDRESS_H |
General Comments 0
You need to be logged in to leave comments.
Login now