-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMainWindow.cpp
More file actions
43 lines (36 loc) · 1.2 KB
/
MainWindow.cpp
File metadata and controls
43 lines (36 loc) · 1.2 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
#include "MainWindow.h"
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
setupUi(this);
packetsView->setModel(&DataManager::get().packets);
packetsView->setColumnHidden(1, true);
packetsView->setColumnHidden(6, true);
statusLabel = new QLabel();
statusLabel->setToolTip("Q: Queued D: Dropped");
this->statusBar()->addWidget(statusLabel);
QObject::connect(actionExit, SIGNAL(triggered()), qApp, SLOT(quit()));
QObject::connect(actionStartStop, SIGNAL(toggled(bool)), this, SIGNAL(toggleCapture(bool)));
QObject::connect(actionStartStop, SIGNAL(toggled(bool)), this, SLOT(setCapturing(bool)));
QObject::connect(packetsView->model(), SIGNAL(rowsInserted(const QModelIndex&, int, int)),
this, SLOT(onRowsInserted(const QModelIndex&, int, int)));
}
MainWindow::~MainWindow()
{}
void MainWindow::setStatus(const QString& status)
{
statusLabel->setText(status);
}
void MainWindow::setCapturing(bool toggle)
{
actionStartStop->setChecked(toggle);
if(toggle == false)
{
for(int i=0; i<packetsView->model()->columnCount(); ++i)
packetsView->resizeColumnToContents(i);
}
}
void MainWindow::onRowsInserted(const QModelIndex& parent, int from, int to)
{
packetsView->scrollToBottom();
}