1 #ifndef NEARBYDEVICESMODEL_H
2 #define NEARBYDEVICESMODEL_H
5 #include <QAbstractListModel>
6 #include <QDBusObjectPath>
8 #include "bluemanager.h"
9 #include "blueadapter.h"
10 #include "asyncagent.h"
11 #include "bluetoothdevice.h"
13 namespace NearbyDevicesModelRoles
17 name = Qt::UserRole + 1,
23 class NearbyItem: public QObject
26 Q_PROPERTY(QString name READ name)
27 Q_PROPERTY(QString address READ address)
28 Q_PROPERTY(QString icon READ icon)
29 Q_PROPERTY(bool legacyPairing READ legacyPairing)
31 NearbyItem(QString name="", QString address="", QString icon="", bool legacy=false, QObject* parent = 0)
40 QString name() { return m_name; }
41 QString address() { return m_addy; }
42 QString icon() { return m_icon; }
43 bool legacyPairing() { return m_legacy; }
51 class NearbyDevicesModel : public QAbstractListModel
54 Q_PROPERTY(BluetoothDevice* pairingDevice READ pairingDevice)
57 NearbyDevicesModel(QObject *parent = 0);
59 BluetoothDevice* pairingDevice() { if(agent) return agent->device(); else return NULL; }
63 int columnCount(const QModelIndex &) const { return 1;}
64 int rowCount(const QModelIndex &parent = QModelIndex()) const;
65 QVariant data(const QModelIndex &index, int role) const;
67 QString hwAddress(int index) { return devices[index]->address(); }
68 QString alias(int index){ return devices[index]->name(); }
69 void pair(QString hwaddy);
70 void discover(bool start);
73 void replyRequestConfirmation(bool confirmed);
74 void replyPasskey(uint passkey);
75 void replyRequestPidCode(QString pidCode);
77 void setAdapterProperty(QString name, QVariant value);
80 void adapterAdded(QDBusObjectPath);
81 void adapterRemoved(QDBusObjectPath);
82 void deviceCreated(QString hwaddy, QVariantMap properties);
83 void deviceRemoved(QString hwaddy);
85 void adapterPropertiesChangedSlot(QString n,QDBusVariant v);
88 void requestConfirmation(QString device, uint code);
89 void requestPasskey(QString device);
90 void requestPidCode(QString device);
93 void nearbyDeviceFound(int index);
94 void nearbyDeviceRemoved(int index);
96 void adapterPropertiesChanged(QString name, QVariant value);
99 QList<NearbyItem*> devices;
100 OrgBluezManagerInterface *manager;
101 OrgBluezAdapterInterface *adapter;
105 #endif // NEARBYDEVICESMODEL_H