forked from panigrahip/3GPPDecoder
-
Notifications
You must be signed in to change notification settings - Fork 3
/
dissectormodel.cpp
40 lines (32 loc) · 969 Bytes
/
dissectormodel.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
#include "dissectormodel.h"
DissectorModel::DissectorModel(QObject *parent) :
QAbstractListModel(parent)
{
}
int DissectorModel::rowCount(const QModelIndex &) const {
return dissector.count();
}
QVariant DissectorModel::headerData(int section, Qt::Orientation, int role) const {
if (role != Qt::DisplayRole) {
return QVariant();
}
return QString("%1").arg(section);
}
QVariant DissectorModel::data(const QModelIndex &index, int role) const {
if (!index.isValid()) {
return QVariant();
}
if (index.row() >= dissector.count()) {
return QVariant();
}
if (role == Qt::DisplayRole) {
return dissector.at(index.row()).first;
} else if (role == Qt::UserRole) {
return dissector.at(index.row()).second;
} else {
return QVariant();
}
}
void DissectorModel::addData(QString name, QString dissector_t) {
dissector.append(QPair<QString, QString>(name, dissector_t));
}