/*! * * Copyright (c) 2021-2024 Diality Inc. - All Rights Reserved. * \copyright * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. * * \file VBluetooth.h * \author (last) Behrouz NematiPour * \date (last) 16-Sep-2021 * \author (original) Behrouz NematiPour * \date (original) 24-Aug-2021 * */ #pragma once // Qt #include // Project #include "main.h" // Doxygen : do not remove #include "VView.h" #include "MBluetooth.h" #include "MUIBloodPressureData.h" // forward declarations class tst_views; namespace View { /*! * \brief The VBluetooth class * \details View for BluetoothInterface. */ class VBluetooth : public QAbstractListModel { Q_OBJECT // friends friend class ::tst_views; PROPERTY(bool , isInvalid , true ) // chose isInvalid instead of isValid for performance reasons to avoid multi call when it is valid. PROPERTY(QString , notification , "" ) PROPERTY(QString , localName , "" ) PROPERTY(QString , localAddr , "" ) PROPERTY(bool , scanEnabled , true ) PROPERTY(qint16 , error , 0 ) PROPERTY(QString , pairedAddr , "" ) PROPERTY(quint8 , pairedBatt , 0 ) // List Model public: enum DataRole { ToStringRole = Qt::DisplayRole , AddrRole = Qt::UserRole , NameRole , PairRole , }; Q_ENUM(DataRole) private: BluetoothDeviceListData _devices {}; void reset(); int rowCount (const QModelIndex & = QModelIndex()) const override; QVariant data (const QModelIndex &index, int role ) const override; QHash roleNames ( ) const override; VIEW_DEC_CLASS(VBluetooth) signals: void didDeviceSelect(const QString &vAddr, const QString &vName); private slots: void onStateChange (const BluetoothData &vData ); void onDeviceChange (const BluetoothDeviceData &vDevice); void onDeviceSelect(const QString &vAddr, const QString &vName); QString toText (Model::MBluetooth::InterfaceStates vState) const; void notify (Model::MBluetooth::InterfaceStates vState); public slots: void doScan (); }; }