-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinfotable.cpp
More file actions
63 lines (55 loc) · 1.73 KB
/
infotable.cpp
File metadata and controls
63 lines (55 loc) · 1.73 KB
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
#include "infotable.h"
#include "mainwindow.h"
#include "ui_infotable.h"
#include <chrono>
using std::chrono::duration_cast, std::chrono::seconds;
InfoTable::InfoTable(MainWindow & parent)
: QMainWindow(&parent),
ui_m(new Ui::InfoTable),
networkSwitch_m(parent.networkSwitch_m),
macModel_m{nullptr},
sessionsModel_m{nullptr}
{
ui_m->setupUi(this);
connect(ui_m->acceptTimeout, &QAbstractButton::released, this, &InfoTable::onApplyTimeout);
connect(ui_m->clearMac, &QAbstractButton::released, this, &InfoTable::onMacsClear);
connect(ui_m->clearSessions, &QAbstractButton::released, this, &InfoTable::onSessionsClear);
macModel_m.reset(new MacModel(parent.networkSwitch_m.getStorage(), this));
sessionsModel_m.reset(new SessionsModel(parent.networkSwitch_m.getStorage(), this));
ui_m->macTable->setModel(macModel_m.get());
ui_m->sessionsTable->setModel(sessionsModel_m.get());
}
void InfoTable::refreshUi()
{
if (networkSwitch_m.state() == NetworkSwitch::SwitchState::Idle)
{
ui_m->timeoutValue->setEnabled(false);
ui_m->acceptTimeout->setEnabled(false);
}
else
{
ui_m->timeoutValue->setEnabled(true);
ui_m->acceptTimeout->setEnabled(true);
auto guard = networkSwitch_m.getStorage().guard();
ui_m->currentTimeout->setText(
QString("%1")
.arg(duration_cast<seconds>(guard->deviceInfo.defaultMacTimeout).count())
);
}
}
void InfoTable::onApplyTimeout()
{
networkSwitch_m.setMacTimeout(ui_m->timeoutValue->value());
}
void InfoTable::onMacsClear()
{
networkSwitch_m.clearMac();
}
void InfoTable::onSessionsClear()
{
networkSwitch_m.clearSessions();
}
InfoTable::~InfoTable()
{
delete ui_m;
}