-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharpdatabase.cpp
More file actions
53 lines (47 loc) · 1.34 KB
/
arpdatabase.cpp
File metadata and controls
53 lines (47 loc) · 1.34 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
#include "arpdatabase.h"
ArpDatabase::ArpDatabase(QObject *parent)
: QAbstractTableModel(parent)
{
for(int i=0; i<10; i++){
arp_data.append({"10.0.0.0-10.255.255.255", "Label", "Label"});
}
}
QVariant ArpDatabase::headerData(int section, Qt::Orientation orientation, int role) const
{
if (role != Qt::DisplayRole)
return QVariant();
if (orientation == Qt::Horizontal) {
// Return the name of the column
switch (section) {
case 0:
return QStringLiteral("Column 1");
case 1:
return QStringLiteral("Column 2");
case 2:
return QStringLiteral("Column 3");
// Add more columns as needed
default:
return QString("Column %1").arg(section + 1);
}
}
return QVariant();
}
int ArpDatabase::rowCount(const QModelIndex &) const
{
return arp_data.count();
}
int ArpDatabase::columnCount(const QModelIndex &) const
{
return arp_data.at(0).count();
}
QVariant ArpDatabase::data(const QModelIndex &index, int role) const
{
if (!index.isValid())
return QVariant();
if (index.row() >= arp_data.size() || index.row() < 0)
return QVariant();
if (role == Qt::DisplayRole) {
return arp_data.at(index.row()).at(index.column());
}
return QVariant();
}