-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathintipedit.cpp
More file actions
42 lines (35 loc) · 887 Bytes
/
intipedit.cpp
File metadata and controls
42 lines (35 loc) · 887 Bytes
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
#include "intipedit.h"
#include "intipvalidator.h"
#include "intipv4calculator.h"
#include "ipv4.h"
#include <QVBoxLayout>
IntIpEdit::IntIpEdit(QWidget *parent)
: IntIpEdit(default_value, parent)
{}
IntIpEdit::IntIpEdit(const QString& text, QWidget *parent)
: QWidget(parent)
{
IntIpValidator::set_to(&m_edit);
m_edit.setText(text);
connect(&m_edit, &QLineEdit::textChanged, this, &IntIpEdit::ipChanged);
setup_ui();
}
QString IntIpEdit::getIp() const
{
return IpV4::fix(m_edit.text());
}
void IntIpEdit::setIp(const QString &text)
{
m_edit.setText(text);
}
void IntIpEdit::ipChanged(const QString &text)
{
m_edit.setToolTip(IntIpV4Calculator::convert(text));
emit onIpChanged(getIp());
}
void IntIpEdit::setup_ui()
{
auto main_lay = new QVBoxLayout(this);
main_lay->addWidget(&m_edit);
main_lay->setContentsMargins(0,0,0,0);
}