-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathtracemodel.cpp
63 lines (58 loc) · 1.55 KB
/
tracemodel.cpp
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
// SPDX-License-Identifier: GPL-3.0
#include "tracemodel.h"
#include "traceview.h"
TraceModel::TraceModel(QObject *parent, TraceView *tv) : QAbstractTableModel(parent), tv_(tv)
{
}
int TraceModel::rowCount(const QModelIndex &parent) const
{
Q_UNUSED(parent);
return tv_->getTrace()->getPacketCount();
}
int TraceModel::columnCount(const QModelIndex &parent) const
{
Q_UNUSED(parent);
return 6;
}
QVariant TraceModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid() || role != Qt::DisplayRole) {
return QVariant();
}
int i = index.row();
switch (index.column()) {
case 0:
return tv_->getTrace()->getSummary(i).no;
case 1:
return tv_->getTrace()->getSummary(i).time;
case 2:
return tv_->getTrace()->getSummary(i).src;
case 3:
return tv_->getTrace()->getSummary(i).dst;
case 4:
return tv_->getTrace()->getSummary(i).proto;
case 5:
return tv_->getTrace()->getSummary(i).info;;
}
return QVariant();
}
QVariant TraceModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if (role == Qt::DisplayRole && orientation == Qt::Horizontal) {
switch (section) {
case 0:
return QString("No.");
case 1:
return QString("Time");
case 2:
return QString("Source");
case 3:
return QString("Dest.");
case 4:
return QString("Proto");
case 5:
return QString("Info");
}
}
return QVariant();
}