- fixed base agent ignoring pass in object path
[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         Q_PROPERTY(bool discoverable READ discoverable WRITE makeDiscoverable NOTIFY discoverableChanged);
13         Q_PROPERTY(bool adapterPresent READ adapterPresent NOTIFY adapterChanged)
14 public:
15         explicit BluetoothDevicesModel(QObject *parent = 0);
16
17         enum Role
18         {
19                 name = Qt::UserRole + 1,
20                 address,
21                 path
22         };
23
24         bool adapterPresent() { return adapter != NULL; }
25
26 public slots:
27
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;
31
32         QString devicePath(QString name);
33
34         QList<BluetoothDevice*> devices(){ return m_devices; }
35
36         BluetoothDevice* device(QString path);
37         void makeDiscoverable(bool isDiscoverable);
38         bool discoverable();
39
40 private slots:
41         void adapterAdded(QDBusObjectPath);
42         void adapterRemoved(QDBusObjectPath);
43         void deviceCreated(QDBusObjectPath);
44         void deviceRemoved(QDBusObjectPath);
45
46         void devicePropertyChanged(QString name, QVariant value);
47         void adapterPropertyChanged(QString name, QDBusVariant value);
48
49 signals:
50         void devicePaired(BluetoothDevice* device);
51         void discoverableChanged(bool discoverable);
52         void adapterChanged(bool adapterPresent);
53
54 private:
55         OrgBluezManagerInterface *manager;
56         OrgBluezAdapterInterface *adapter;
57         QList<BluetoothDevice*> m_devices;
58 };
59
60 #endif // BLUETOOTHDEVICEMODEL_H