Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qopenxrspatialanchormodel.cpp
Go to the documentation of this file.
1// Copyright (C) 2023 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
7
9
11 : QAbstractListModel{parent}
12{
13 m_spaceExtension = QOpenXRSpaceExtension::instance();
15 connect(m_spaceExtension, &QOpenXRSpaceExtension::anchorAdded, this, &QOpenXRSpatialAnchorModel::handleAnchorAdded);
16}
17
19{
20 if (parent.isValid() || m_spaceExtension == nullptr)
21 return 0;
22
23 return m_spaceExtension->anchors().count();
24}
25
27{
28 if (!index.isValid() || m_spaceExtension == nullptr)
29 return QVariant();
30
31 const auto &anchors = m_spaceExtension->anchors();
32
33 // check bounds
34 if (index.row() < 0 || index.row() >= anchors.count())
35 return QVariant();
36
37 const auto &anchor = anchors.at(index.row());
38
39 if (role == Anchor)
40 return QVariant::fromValue(anchor);
41
42 // shouldn't be reachable under normal circumstances.
43 return QVariant();
44}
45
46QHash<int, QByteArray> QOpenXRSpatialAnchorModel::roleNames() const
47{
48 QHash<int, QByteArray> roles;
49 roles[Anchor] = "anchor";
50 return roles;
51}
52
54{
55 if (m_spaceExtension == nullptr)
56 return;
57
58 // not supported on the Simulator, this will be a no-op there
59 m_spaceExtension->requestSceneCapture();
60}
61
63{
64 if (m_spaceExtension == nullptr)
65 return;
66
67 m_spaceExtension->queryAllAnchors();
68}
69
70void QOpenXRSpatialAnchorModel::handleAnchorAdded(QOpenXRSpatialAnchor *anchor)
71{
72 Q_UNUSED(anchor)
73 // Brute Force :-p
76}
77
82
84{
85 if (m_filterMode == newFilterMode)
86 return;
87 m_filterMode = newFilterMode;
89}
90
92{
93 return m_uuids;
94}
95
96void QOpenXRSpatialAnchorModel::setUuids(const QList<QUuid> &newUuids)
97{
98 if (m_uuids == newUuids)
99 return;
100 m_uuids = newUuids;
102}
103
104QOpenXRSpatialAnchorModel::SemanticLabels QOpenXRSpatialAnchorModel::labels() const
105{
106 return m_labels;
107}
108
109void QOpenXRSpatialAnchorModel::setLabels(const SemanticLabels &newLabels)
110{
111 if (m_labels == newLabels)
112 return;
113 m_labels = newLabels;
115}
116
void endResetModel()
Completes a model reset operation.
void beginResetModel()
Begins a model reset operation.
QObject * parent() const
Returns a pointer to the parent object.
Definition qobject.h:346
qsizetype count() const noexcept
Definition qlist.h:398
\inmodule QtCore
\inmodule QtCore
Definition qobject.h:103
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
Definition qobject.cpp:2960
const QList< QOpenXRSpatialAnchor * > & anchors() const
static QOpenXRSpaceExtension * instance()
void anchorAdded(QOpenXRSpatialAnchor *anchor)
void setUuids(const QList< QUuid > &newUuids)
int rowCount(const QModelIndex &parent) const override
Returns the number of rows under the given parent.
QHash< int, QByteArray > roleNames() const override
void setFilterMode(FilterMode newFilterMode)
QVariant data(const QModelIndex &index, int role) const override
Returns the data stored under the given role for the item referred to by the index.
QOpenXRSpatialAnchorModel(QObject *parent=nullptr)
void setLabels(const SemanticLabels &newLabels)
\inmodule QtCore
Definition qvariant.h:65
static auto fromValue(T &&value) noexcept(std::is_nothrow_copy_constructible_v< T > &&Private::CanUseInternalSpace< T >) -> std::enable_if_t< std::conjunction_v< std::is_copy_constructible< T >, std::is_destructible< T > >, QVariant >
Definition qvariant.h:536
Combined button and popup list for selecting options.
GLuint index
[2]
QQuickAnchors * anchors(QQuickItem *item)
#define emit
#define Q_UNUSED(x)