1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qbluetoothhostinfo.h"
5#include "qbluetoothhostinfo_p.h"
6
7QT_BEGIN_NAMESPACE
8
9QT_IMPL_METATYPE_EXTERN(QBluetoothHostInfo)
10
11/*!
12 \class QBluetoothHostInfo
13 \inmodule QtBluetooth
14 \brief The QBluetoothHostInfo class encapsulates the details of a local
15 QBluetooth device.
16
17 \since 5.2
18
19 This class holds the name and address of a local Bluetooth device.
20*/
21
22/*!
23 Constructs a null QBluetoothHostInfo object.
24*/
25QBluetoothHostInfo::QBluetoothHostInfo() :
26 d_ptr(new QBluetoothHostInfoPrivate)
27{
28}
29
30/*!
31 Constructs a new QBluetoothHostInfo which is a copy of \a other.
32*/
33QBluetoothHostInfo::QBluetoothHostInfo(const QBluetoothHostInfo &other) :
34 d_ptr(new QBluetoothHostInfoPrivate)
35{
36 Q_D(QBluetoothHostInfo);
37
38 d->m_address = other.d_func()->m_address;
39 d->m_name = other.d_func()->m_name;
40}
41
42/*!
43 Destroys the QBluetoothHostInfo.
44*/
45QBluetoothHostInfo::~QBluetoothHostInfo()
46{
47 delete d_ptr;
48}
49
50/*!
51 Assigns \a other to this QBluetoothHostInfo instance.
52*/
53QBluetoothHostInfo &QBluetoothHostInfo::operator=(const QBluetoothHostInfo &other)
54{
55 Q_D(QBluetoothHostInfo);
56
57 d->m_address = other.d_func()->m_address;
58 d->m_name = other.d_func()->m_name;
59
60 return *this;
61}
62
63/*!
64 \fn bool QBluetoothHostInfo::operator==(const QBluetoothHostInfo &a,
65 const QBluetoothHostInfo &b)
66 \brief Returns \c true if \a a and \a b are equal, otherwise \c false.
67*/
68
69/*!
70 \fn bool QBluetoothHostInfo::operator!=(const QBluetoothHostInfo &a,
71 const QBluetoothHostInfo &b)
72 \brief Returns \c true if \a a and \a b are not equal, otherwise \c false.
73*/
74
75/*!
76 \brief Returns \c true if \a a and \a b are equal, otherwise \c false.
77 \internal
78*/
79bool QBluetoothHostInfo::equals(const QBluetoothHostInfo &a, const QBluetoothHostInfo &b)
80{
81 if (a.d_ptr == b.d_ptr)
82 return true;
83
84 return a.d_ptr->m_address == b.d_ptr->m_address && a.d_ptr->m_name == b.d_ptr->m_name;
85}
86
87/*!
88 Returns the Bluetooth address as a QBluetoothAddress.
89*/
90QBluetoothAddress QBluetoothHostInfo::address() const
91{
92 Q_D(const QBluetoothHostInfo);
93 return d->m_address;
94}
95
96/*!
97 Sets the Bluetooth \a address for this Bluetooth host info object.
98*/
99void QBluetoothHostInfo::setAddress(const QBluetoothAddress &address)
100{
101 Q_D(QBluetoothHostInfo);
102 d->m_address = address;
103}
104
105/*!
106 Returns the user visible name of the host info object.
107*/
108QString QBluetoothHostInfo::name() const
109{
110 Q_D(const QBluetoothHostInfo);
111 return d->m_name;
112}
113
114/*!
115 Sets the \a name of the host info object.
116*/
117void QBluetoothHostInfo::setName(const QString &name)
118{
119 Q_D(QBluetoothHostInfo);
120 d->m_name = name;
121}
122
123QT_END_NAMESPACE
124

source code of qtconnectivity/src/bluetooth/qbluetoothhostinfo.cpp