Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qquick3drenderstatstexturesmodel.cpp
Go to the documentation of this file.
1
// Copyright (C) 2022 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
// Qt-Security score:significant reason:default
4
5
6
#
include
"qquick3drenderstatstexturesmodel_p.h"
7
8
#
include
<
QtCore
/
QRegularExpression
>
9
10
QT_BEGIN_NAMESPACE
11
12
QHash<
int
, QByteArray> QQuick3DRenderStatsTexturesModel::roleNames()
const
13
{
14
return
{ {Qt::DisplayRole,
"display"
} };
15
}
16
17
int
QQuick3DRenderStatsTexturesModel::rowCount(
const
QModelIndex &parent)
const
18
{
19
Q_UNUSED(parent);
20
return
m_data.count();
21
}
22
23
int
QQuick3DRenderStatsTexturesModel::columnCount(
const
QModelIndex &parent)
const
24
{
25
Q_UNUSED(parent);
26
return
5;
27
}
28
29
QVariant QQuick3DRenderStatsTexturesModel::data(
const
QModelIndex &index,
int
role)
const
30
{
31
if
(!index.isValid())
32
return
QVariant();
33
34
const
uint row = index.row();
35
const
uint column = index.column();
36
37
if
(role == Qt::DisplayRole) {
38
// Name 0
39
if
(column == 0)
40
return
m_data[row].name;
41
// Size 1
42
if
(column == 1)
43
return
m_data[row].size;
44
// Format 2
45
if
(column == 2)
46
return
m_data[row].format;
47
// Mip Levels 3
48
if
(column == 3)
49
return
m_data[row].mipLevels;
50
// Flags 4
51
if
(column == 4)
52
return
m_data[row].flags;
53
}
54
55
return
QVariant();
56
}
57
58
QVariant QQuick3DRenderStatsTexturesModel::headerData(
int
section, Qt::Orientation orientation,
int
role)
const
59
{
60
if
(role != Qt::DisplayRole || orientation != Qt::Horizontal || section > 5)
61
return
QVariant();
62
63
switch
(section) {
64
case
0:
65
return
QStringLiteral(
"Name"
);
66
case
1:
67
return
QStringLiteral(
"Size"
);
68
case
2:
69
return
QStringLiteral(
"Format"
);
70
case
3:
71
return
QStringLiteral(
"Mip Levels"
);
72
case
4:
73
return
QStringLiteral(
"Flags"
);
74
default
:
75
Q_UNREACHABLE();
76
return
QVariant();
77
}
78
}
79
80
const
QString &QQuick3DRenderStatsTexturesModel::textureData()
const
81
{
82
return
m_textureData;
83
}
84
85
void
QQuick3DRenderStatsTexturesModel::setTextureData(
const
QString &newTextureData)
86
{
87
if
(m_textureData == newTextureData)
88
return
;
89
90
m_textureData = newTextureData;
91
emit textureDataChanged();
92
93
// newTextureData is just a markdown table...
94
QVector<Data> newData;
95
if
(!m_textureData.isEmpty()) {
96
auto
lines = m_textureData.split(QRegularExpression(QStringLiteral(
"[\r\n]"
)), Qt::SkipEmptyParts);
97
if
(lines.size() > 2) {
98
for
(qsizetype i = 2; i < lines.size(); ++i) {
99
const
auto
&line = lines.at(i);
100
auto
fields = line.split(QLatin1Char(
'|'
), Qt::SkipEmptyParts);
101
if
(fields.size() < 4)
// flags field can be empty
102
continue
;
103
Data data;
104
bool
isUInt32 =
false
;
105
data.name = fields[0];
106
data.size = fields[1];
107
data.format = fields[2];
108
data.mipLevels = fields[3].toULong(&isUInt32);
109
if
(!isUInt32)
110
continue
;
111
if
(fields.size() == 5)
112
data.flags = fields[4];
113
newData.append(data);
114
}
115
}
116
}
117
118
// update the model
119
beginResetModel();
120
m_data = newData;
121
endResetModel();
122
}
123
124
QT_END_NAMESPACE
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
qtquick3d
src
helpers
impl
qquick3drenderstatstexturesmodel.cpp
Generated on
for Qt by
1.18.0