1 #ifndef BLUETOOTHDEVICEMODEL_H
2 #define BLUETOOTHDEVICEMODEL_H
4 #include <QAbstractListModel>
5 #include "bluemanager.h"
6 #include "blueadapter.h"
7 #include "bluetoothdevice.h"
9 class BluetoothDevicesModel : public QAbstractListModel
12 Q_PROPERTY(bool discoverable READ discoverable WRITE makeDiscoverable NOTIFY discoverableChanged);
13 Q_PROPERTY(bool adapterPresent READ adapterPresent NOTIFY adapterChanged)
15 explicit BluetoothDevicesModel(QObject *parent = 0);
17 bool adapterPresent() { return adapter != NULL; }
21 int columnCount(const QModelIndex &) const { return 1; }
22 int rowCount(const QModelIndex &parent = QModelIndex()) const;
23 QVariant data(const QModelIndex &index, int role) const;
25 QString devicePath(QString name);
27 QList<BluetoothDevice*> devices(){ return m_devices; }
29 BluetoothDevice* device(QString path);
30 void makeDiscoverable(bool isDiscoverable);
34 void adapterAdded(QDBusObjectPath);
35 void adapterRemoved(QDBusObjectPath);
36 void deviceCreated(QDBusObjectPath);
37 void deviceRemoved(QDBusObjectPath);
39 void devicePropertyChanged(QString name, QVariant value);
40 void adapterPropertyChanged(QString name, QDBusVariant value);
43 void devicePaired(BluetoothDevice* device);
44 void discoverableChanged(bool discoverable);
45 void adapterChanged(bool adapterPresent);
48 OrgBluezManagerInterface *manager;
49 OrgBluezAdapterInterface *adapter;
50 QList<BluetoothDevice*> m_devices;
53 #endif // BLUETOOTHDEVICEMODEL_H