1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the QtNfc module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or (at your option) the GNU General
28** Public license version 3 or any later version approved by the KDE Free
29** Qt Foundation. The licenses are as published by the Free Software
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31** included in the packaging of this file. Please review the following
32** information to ensure the GNU General Public License requirements will
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34** https://www.gnu.org/licenses/gpl-3.0.html.
35**
36** $QT_END_LICENSE$
37**
38****************************************************************************/
39
40#include "qdeclarativendeffilter_p.h"
41
42/*!
43 \qmltype NdefFilter
44 \instantiates QDeclarativeNdefFilter
45 \since 5.2
46 \brief Represents a filtering constraint for NDEF message records.
47
48 \ingroup nfc-qml
49 \inqmlmodule QtNfc
50
51 \sa NearField
52 \sa QNdefFilter
53
54 The NdefFilter type is used with the NearField type to read NDEF messages from NFC Forum
55 tags that match a given structure.
56
57 \code
58 NearField {
59 filter: [
60 NdefFilter {
61 type: "urn:nfc:wkt:U"
62 minimum: 1
63 maximum: 1
64 }
65 ]
66 }
67 \endcode
68*/
69
70/*!
71 \qmlproperty string NdefFilter::type
72
73 This property holds the NDEF record type that the filter matches. This property must be set to
74 the fully qualified record type, i.e. including the NIS and NSS prefixes. For example set to
75 \c {urn:nfc:wkt:U} to match NFC RTD-URI records.
76*/
77
78/*!
79 \qmlproperty QQmlNdefRecord::TypeNameFormat NdefFilter::typeNameFormat
80
81 This property holds the NDEF record name format type \l QQmlNdefRecord::TypeNameFormat.
82*/
83
84/*!
85 \qmlproperty int NdefFilter::minimum
86
87 This property holds the minimum number of records of the given type that must be in the NDEF
88 message for it match.
89
90 The default minimum is 1.
91
92 \sa maximum
93*/
94
95/*!
96 \qmlproperty int NdefFilter::maximum
97
98 This property holds the maximum number of records of the given type that must be in the NDEF
99 message for it match.
100
101 The default maximum is UINT_MAX.
102
103 \sa minimum
104*/
105
106QDeclarativeNdefFilter::QDeclarativeNdefFilter(QObject *parent)
107: QObject(parent), m_minimum(1), m_maximum(INT_MAX)
108{
109}
110
111QString QDeclarativeNdefFilter::type() const
112{
113 return m_type;
114}
115
116void QDeclarativeNdefFilter::setType(const QString &t)
117{
118 if (m_type == t)
119 return;
120
121 m_type = t;
122 emit typeChanged();
123}
124
125QQmlNdefRecord::TypeNameFormat QDeclarativeNdefFilter::typeNameFormat() const
126{
127 return m_typeNameFormat;
128}
129
130void QDeclarativeNdefFilter::setTypeNameFormat(QQmlNdefRecord::TypeNameFormat format)
131{
132 if (m_typeNameFormat == format)
133 return;
134
135 m_typeNameFormat = format;
136 emit typeNameFormatChanged();
137}
138
139int QDeclarativeNdefFilter::minimum() const
140{
141 return m_minimum;
142}
143
144void QDeclarativeNdefFilter::setMinimum(int value)
145{
146 if (m_minimum == value)
147 return;
148
149 m_minimum = value;
150 emit minimumChanged();
151}
152
153int QDeclarativeNdefFilter::maximum() const
154{
155 return m_maximum;
156}
157
158void QDeclarativeNdefFilter::setMaximum(int value)
159{
160 if (m_maximum == value)
161 return;
162
163 m_maximum = value;
164 emit maximumChanged();
165}
166

source code of qtconnectivity/src/imports/nfc/qdeclarativendeffilter.cpp