QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
qserialportinfo.cpp
Go to the documentation of this file.
1// Copyright (C) 2011-2012 Denis Shienkov <denis.shienkov@gmail.com>
2// Copyright (C) 2011 Sergey Belyashov <Sergey.Belyashov@gmail.com>
3// Copyright (C) 2012 Laszlo Papp <lpapp@kde.org>
4// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
5
6#include "qserialportinfo.h"
7#include "qserialportinfo_p.h"
8#include "qserialport.h"
9#include "qserialport_p.h"
10
12
13// We changed from QScopedPointer to std::unique_ptr, make sure it's
14// binary compatible. The QScopedPointer had a non-default deleter, but
15// the deleter just provides a static function to use for deletion so we don't
16// include it in this template definition (the deleter-class was deleted).
17static_assert(sizeof(std::unique_ptr<QSerialPortInfoPrivate>)
18 == sizeof(QScopedPointer<QSerialPortInfoPrivate>));
19
55
60 : d_ptr(other.d_ptr ? new QSerialPortInfoPrivate(*other.d_ptr) : nullptr)
61{
62}
63
68 : QSerialPortInfo(port.portName())
69{
70}
71
80{
81 const auto infos = QSerialPortInfo::availablePorts();
82 for (const QSerialPortInfo &info : infos) {
83 if (name == info.portName()) {
84 *this = info;
85 break;
86 }
87 }
88}
89
94
102
108{
109 d_ptr.swap(other.d_ptr);
110}
111
116{
117 QSerialPortInfo(other).swap(*this);
118 return *this;
119}
120
127{
128 Q_D(const QSerialPortInfo);
129 return !d ? QString() : d->portName;
130}
131
138{
139 Q_D(const QSerialPortInfo);
140 return !d ? QString() : d->device;
141}
142
150{
151 Q_D(const QSerialPortInfo);
152 return !d ? QString() : d->description;
153}
154
162{
163 Q_D(const QSerialPortInfo);
164 return !d ? QString() : d->manufacturer;
165}
166
178{
179 Q_D(const QSerialPortInfo);
180 return !d ? QString() : d->serialNumber;
181}
182
190{
191 Q_D(const QSerialPortInfo);
192 return !d ? 0 : d->vendorIdentifier;
193}
194
202{
203 Q_D(const QSerialPortInfo);
204 return !d ? 0 : d->productIdentifier;
205}
206
214{
215 Q_D(const QSerialPortInfo);
216 return !d ? false : d->hasVendorIdentifier;
217}
218
226{
227 Q_D(const QSerialPortInfo);
228 return !d ? false : d->hasProductIdentifier;
229}
230
248
255QT_END_NAMESPACE
Provides information about existing serial ports.
quint16 productIdentifier() const
QString manufacturer() const
void swap(QSerialPortInfo &other)
QString portName() const
bool hasVendorIdentifier() const
QString serialNumber() const
static QList< QSerialPortInfo > availablePorts()
QString systemLocation() const
QString description() const
quint16 vendorIdentifier() const
bool hasProductIdentifier() const
QSerialPortInfo & operator=(const QSerialPortInfo &other)
static QList< qint32 > standardBaudRates()
static QList< qint32 > standardBaudRates()
Provides functions to access serial ports.
Definition qserialport.h:17
QT_BEGIN_NAMESPACE