-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgroupmessagemanager.h
51 lines (43 loc) · 1.84 KB
/
groupmessagemanager.h
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
48
49
50
51
// GroupMessageManager.h
#ifndef GROUPMESSAGEMANAGER_H
#define GROUPMESSAGEMANAGER_H
#include <QHash>
#include <QObject>
#include "GroupData.h"
#include "Message.h"
class GroupMessageManager : public QObject
{
Q_OBJECT
Q_PROPERTY(QHash<int, GroupData *> groupMessages READ groupMessages NOTIFY groupMessagesChanged)
public:
explicit GroupMessageManager(QObject *parent = nullptr);
Q_INVOKABLE void addMessage(int groupId,
int ms_id,
const QString &sender,
const QString &message,
const QString &time,
const QString &messageType,
int userId,
const QString &createdAt);
Q_INVOKABLE void pushFrontMessage(int groupId,
int ms_id,
const QString &sender,
const QString &message,
const QString &time,
const QString &messageType,
int userId,
const QString &createdAt);
Q_INVOKABLE QList<Message *> getMessages(int groupId) const;
Q_INVOKABLE void removeMessage(int groupId, int ms_id);
Q_INVOKABLE void setCurrentPage(int groupId, int page);
Q_INVOKABLE int getCurrentPage(int groupId) const;
Q_INVOKABLE int getSize(int groupId) const;
Q_INVOKABLE void setCurrentScrollIndex(int groupId, int currentIndex);
Q_INVOKABLE int getCurrentScrollIndex(int groupId) const;
QHash<int, GroupData *> groupMessages() const;
signals:
void groupMessagesChanged();
private:
QHash<int, GroupData *> m_groupMessages;
};
#endif // GROUPMESSAGEMANAGER_H