added release signal and fixed bug in ayncagent that was causing crashes
[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 BluetoothDevicesModel : public QAbstractListModel
10 {
11     Q_OBJECT
12 public:
13         explicit BluetoothDevicesModel(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         QString devicePath(QString name);
29
30         QList<BluetoothDevice*> devices(){ return m_devices; }
31
32         BluetoothDevice* device(QString path);
33
34 private slots:
35         void adapterAdded(QDBusObjectPath);
36         void adapterRemoved(QDBusObjectPath);
37         void deviceCreated(QDBusObjectPath);
38         void deviceRemoved(QDBusObjectPath);
39
40         void devicePropertyChanged(QString name, QVariant value);
41
42 signals:
43         void devicePaired(BluetoothDevice*);
44
45 private:
46         OrgBluezManagerInterface *manager;
47         OrgBluezAdapterInterface *adapter;
48         QList<BluetoothDevice*> m_devices;
49 };
50
51 #endif // BLUETOOTHDEVICEMODEL_H