-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtoolsmodel.cpp
More file actions
54 lines (48 loc) · 1.5 KB
/
toolsmodel.cpp
File metadata and controls
54 lines (48 loc) · 1.5 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
#include "toolsmodel.h"
ToolsModel::ToolsModel(QObject *parent)
: QAbstractTableModel(parent)
{
tools_data.append({"IP Address","1.1.1.1"});
tools_data.append({"Internet Server Provider","Cloudfare, Inc"});
tools_data.append({"Internet Organisation",""});
tools_data.append({"Hostname","one.one.one.one"});
tools_data.append({"Latitude","-33.8688"});
tools_data.append({"Longitude","151.209"});
tools_data.append({"Postal/ZIP Code","1001"});
}
QVariant ToolsModel::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");
default:
return QString("Column %1").arg(section + 1);
}
}
return QVariant();
}
int ToolsModel::rowCount(const QModelIndex &) const
{
return tools_data.count();
}
int ToolsModel::columnCount(const QModelIndex &) const
{
return tools_data.at(0).count();
}
QVariant ToolsModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid())
return QVariant();
if (index.row() >= tools_data.size() || index.row() < 0)
return QVariant();
if (role == Qt::DisplayRole) {
return tools_data.at(index.row()).at(index.column());
}
return QVariant();
}