summary refs log tree commit diff
path: root/src/ui/UserProfile.h
blob: c37e23aed3f0327cf5a5cb4333c757b673d4fe34 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#pragma once

#include <QObject>
#include <QString>
#include <QVector>

#include "MatrixClient.h"

class DeviceInfo
{
public:
        DeviceInfo(const QString deviceID, const QString displayName)
          : device_id(deviceID)
          , display_name(displayName)
        {}

        DeviceInfo() {}

        QString device_id;
        QString display_name;
};

class UserProfile : public QObject
{
        Q_OBJECT
        Q_PROPERTY(QString userId READ getUserId WRITE setUserId NOTIFY userIdChanged)
        Q_PROPERTY(QVector<DeviceInfo> deviceList READ getDeviceList NOTIFY deviceListUpdated)
public:
        // constructor
        explicit UserProfile(QObject *parent = 0);
        // getters
        QVector<DeviceInfo> getDeviceList();
        QString getUserId();
        // setters
        void setUserId(const QString &userId);

        Q_INVOKABLE void fetchDeviceList(const QString &userID);
        Q_INVOKABLE void updateDeviceList();

signals:
        void userIdChanged();
        void deviceListUpdated();

private:
        QVector<DeviceInfo> deviceList;
        QString userId;
};