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);
19 name = Qt::UserRole + 1,
24 bool adapterPresent() { return adapter != NULL; }
28 int columnCount(const QModelIndex &) const { return 1; }
29 int rowCount(const QModelIndex &parent = QModelIndex()) const;
30 QVariant data(const QModelIndex &index, int role) const;
32 QString devicePath(QString name);
34 QList<BluetoothDevice*> devices(){ return m_devices; }
36 BluetoothDevice* device(QString path);
37 void makeDiscoverable(bool isDiscoverable);
41 void adapterAdded(QDBusObjectPath);
42 void adapterRemoved(QDBusObjectPath);
43 void deviceCreated(QDBusObjectPath);
44 void deviceRemoved(QDBusObjectPath);
46 void devicePropertyChanged(QString name, QVariant value);
47 void adapterPropertyChanged(QString name, QDBusVariant value);
50 void devicePaired(BluetoothDevice* device);
51 void discoverableChanged(bool discoverable);
52 void adapterChanged(bool adapterPresent);
55 OrgBluezManagerInterface *manager;
56 OrgBluezAdapterInterface *adapter;
57 QList<BluetoothDevice*> m_devices;
60 #endif // BLUETOOTHDEVICEMODEL_H