Index: sources/view/VBluetoothDeviceInfo.cpp =================================================================== diff -u -r0470ff6f209ff0c5089f8f0849b6da04f60f8f41 -rfdb48ba3fba8e95027ebf573325c8f25db74c070 --- sources/view/VBluetoothDeviceInfo.cpp (.../VBluetoothDeviceInfo.cpp) (revision 0470ff6f209ff0c5089f8f0849b6da04f60f8f41) +++ sources/view/VBluetoothDeviceInfo.cpp (.../VBluetoothDeviceInfo.cpp) (revision fdb48ba3fba8e95027ebf573325c8f25db74c070) @@ -5,28 +5,27 @@ #include // Project - +// coco begin validated: Cannot be tested on server, but has been validated manually using namespace View; /*! * \brief VBluetoothDeviceInfo::VBluetoothDeviceInfo * Constructor for the VBluetoothDeviceInfo class * \param info - the device information */ -VBluetoothDeviceInfo::VBluetoothDeviceInfo(const QBluetoothDeviceInfo &info) +VBluetoothDeviceInfo::VBluetoothDeviceInfo(const QBluetoothDeviceInfo &info) : _connected(false) { - device = info; + _address = info.address().toString(); + _name = info.name(); } /*! - * \brief VBluetoothDeviceInfo::getDevice - * Gets the QBluetoothDeviceInfo this class describes - * \return The QBluetoothDeviceInfo object + * \brief VBluetoothDeviceInfo::VBluetoothDeviceInfo + * Constructor for the VBluetoothDeviceInfo class + * \param address - (QString) bluetooth address of the device + * \param name - (QString) name of the bluetooth device */ -QBluetoothDeviceInfo VBluetoothDeviceInfo::getDevice() const -{ - return device; -} +VBluetoothDeviceInfo::VBluetoothDeviceInfo(const QString &address, const QString &name) : _address(address), _name(name), _connected(false) {} /*! * \brief VBluetoothDeviceInfo::getName @@ -35,7 +34,7 @@ */ QString VBluetoothDeviceInfo::getName() const { - return device.name(); + return _name; } /*! @@ -45,16 +44,46 @@ */ QString VBluetoothDeviceInfo::getAddress() const { - return device.address().toString(); + return _address; } /*! - * \brief VBluetoothDeviceInfo::setDevice - * Sets the QBluetoothDeviceInfo object to a new object - * \param device - the new QbluetoothDeviceInfo device + * \brief VBluetoothDeviceInfo::setConnected + * Sets the bluetooth connection state */ -void VBluetoothDeviceInfo::setDevice(const QBluetoothDeviceInfo &device) +void VBluetoothDeviceInfo::setConnected(const bool &conn) { - this->device = device; - emit deviceChanged(); + if (conn != _connected) + { + _connected = conn; + emit deviceChanged(); + } } + +/*! + * \brief VBluetoothDeviceInfo::isConnected + * Gets the bluetooth connection state + * \return bool - true if connected, false otherwise + */ +bool VBluetoothDeviceInfo::isConnected() const +{ + return _connected; +} + +/*! + * \brief VBluetoothDeviceInfo::isValid + * Checks whether the VBluetoothDeviceInfo object is valid or not. + * \return true if valid, false otherwise + */ +bool VBluetoothDeviceInfo::isValid() const +{ + if (_address.length() != 17) + return false; + + if (_name.length() == 0) + return false; + + return true; +} + +// coco end