-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmessagemodel.h
87 lines (63 loc) · 1.98 KB
/
messagemodel.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#ifndef MESSAGEMODEL_H
#define MESSAGEMODEL_H
#include <QObject>
#include <QAbstractListModel>
#include "gamedata.h"
struct Message
{
Message(){ }
Message(uint _ID, QString _Emitter, QString _Recipient , uint _Type, QString _MessageContent, QString _Emitted){
ID = _ID;
Emitter = _Emitter;
Recipient = _Recipient;
MessageContent = _MessageContent;
Type = _Type;
Emitted = _Emitted;
}
uint ID = 0;
QString Emitter = "Invalid";
QString Recipient = "Invalid";
uint Type = 0;
QString MessageContent = "Invalid";
QString Emitted = "Invalid";
QVariant getRole(int role) const;
enum Roles {
RoleId = Qt::UserRole + 1,
RoleEmitter,
RoleRecipient,
RoleType,
RoleMessage,
RoleEmitted
};
};
class MessageModel : public QAbstractListModel
{
Q_OBJECT
public:
MessageModel(GameData& gameData);
MessageModel& operator=( const MessageModel& mm){
Q_UNUSED(mm);
//FIXME
return *this;
}
~MessageModel();
int rowCount(const QModelIndex & parent = QModelIndex()) const;
QVariant data( const QModelIndex & index, int role = Qt::DisplayRole ) const;
Q_INVOKABLE Qt::ItemFlags flags(const QModelIndex &index) const Q_DECL_OVERRIDE;
//bool setData(const QModelIndex & index, const QVariant & value, int role = Qt::EditRole);
//bool insertRows(int row, int count, const QModelIndex & parent = QModelIndex());
//bool removeRows(int row, int count, const QModelIndex & parent = QModelIndex());
void resetModel();
void updateModel();
public slots:
bool sendSystemMessage(QString message);
bool sendMessage(QString message, QString recipient);
signals:
protected:
QHash<int, QByteArray> roleNames() const;
private:
QVector< Message> m_lstValues ;
GameData& m_gameData;
bool addMessage( QString emitter, QString recip, uint type, QString mesg, uint CampaignId);
};
#endif // MESSAGEMODEL_H