forked from CPP-Final-Project/Chat_Client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MessageWModel.h
62 lines (44 loc) · 1.63 KB
/
MessageWModel.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
#pragma once
#include <QAbstractListModel>
#include <bitset>
#include "messageitem.h"
class MessageWModel final : public QAbstractListModel
{
Q_OBJECT
friend class MessageWView;
public:
enum Role
{
MessageRole = Qt::UserRole,
};
explicit MessageWModel(QObject* parent = Q_NULLPTR);
~MessageWModel() override;
MessageWModel(const MessageWModel&) = delete;
MessageWModel(MessageWModel&&) = delete;
const MessageWModel& operator =(const MessageWModel&) = delete;
MessageWModel& operator = (MessageWModel&&) = delete;
[[nodiscard]] bool hashMessage(const std::bitset<128>& hash) const;
[[nodiscard]] messageItemPtr getMessageFromId(const int id) const;
[[nodiscard]] int rowCount(QModelIndex const& parent = QModelIndex()) const override final;
[[nodiscard]] QVariant data(QModelIndex const& index, int role = Qt::DisplayRole) const override final;
[[nodiscard]] Qt::ItemFlags flags(const QModelIndex& index) const override final;
//void update_raw( const int i_row);
//void update_all();
using QAbstractListModel::beginInsertRows;
using QAbstractListModel::endInsertRows;
using QAbstractListModel::beginRemoveRows;
using QAbstractListModel::endRemoveRows;
using QAbstractListModel::beginResetModel;
using QAbstractListModel::endResetModel;
using QAbstractListModel::dataChanged;
void onAnotheLikeChanged(const QVariant& like_);
public Q_SLOT:
void addMessage(const QVariant& new_msg_var_);
private Q_SLOTS:
void clear();
void addMessages(const QVariantList& new_msg_list_);
private:
messagesList model_messages;
QMap<uint64_t, messageItemPtr> model_id_to_msg;
QHash<std::bitset<128>, messageItemPtr> model_hash_to_msg;
};