initial Bluetooth Device Model addition
[profile/ivi/bluetooth-qt.git] / bluetoothdevicemodel.h
1 #ifndef BLUETOOTHDEVICEMODEL_H
2 #define BLUETOOTHDEVICEMODEL_H
3
4 #include <QAbstractListModel>
5 #include "bluemanager.h"
6 #include "blueadapter.h"
7 #include "bluetoothdevice.h"
8
9 class BluetoothDeviceModel : public QAbstractListModel
10 {
11     Q_OBJECT
12 public:
13     explicit BluetoothDeviceModel(QObject *parent = 0);
14
15         enum Role
16         {
17                 name = Qt::UserRole + 1,
18                 address,
19                 path
20         };
21
22 public slots:
23
24         int columnCount(const QModelIndex &) const { return 1; }
25         int rowCount(const QModelIndex &parent = QModelIndex()) const;
26         QVariant data(const QModelIndex &index, int role) const;
27
28         void adapterAdded(QDBusObjectPath);
29         void adapterRemoved(QDBusObjectPath);
30         void deviceCreated(QDBusObjectPath);
31         void deviceRemoved(QDBusObjectPath);
32
33         QList<BluetoothDevice*> devices(){ return m_devices; }
34
35 private:
36         OrgBluezManagerInterface *manager;
37         OrgBluezAdapterInterface *adapter;
38         QList<BluetoothDevice*> m_devices;
39 };
40
41 #endif // BLUETOOTHDEVICEMODEL_H