forked from CPP-Final-Project/Chat_Client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChatWModel.h
More file actions
59 lines (43 loc) · 1.5 KB
/
ChatWModel.h
File metadata and controls
59 lines (43 loc) · 1.5 KB
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
#pragma once
#include <QAbstractListModel>
#include <bitset>
#include <QSize>
//#include "ChatWView.h"
#include "ChatItem.h"
class ChatWModel : public QAbstractListModel
{
Q_OBJECT;
friend class ChatWView;
public:
enum Role
{
ChatRole = Qt::UserRole,
};
explicit ChatWModel(QObject* parent = Q_NULLPTR);
~ChatWModel() override;
ChatWModel(const ChatWModel&) = delete;
ChatWModel(ChatWModel&&) = delete;
const ChatWModel& operator =(const ChatWModel&) = delete;
ChatWModel& operator = (ChatWModel&&) = delete;
[[nodiscard]] bool hashChat(const std::bitset<128>& hash) const; //ma ze??
[[nodiscard]] chatItemPtr getChatFromId(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;
using QAbstractListModel::beginInsertRows;
using QAbstractListModel::endInsertRows;
using QAbstractListModel::beginRemoveRows;
using QAbstractListModel::endRemoveRows;
using QAbstractListModel::beginResetModel;
using QAbstractListModel::endResetModel;
using QAbstractListModel::dataChanged;
public Q_SLOT:
void addChat(const QVariant& new_chat_var_);
void addChats(const QVariantList& new_chat_list_);
private Q_SLOTS:
void clear();
private:
chatList model_chats;
QMap<uint64_t, chatItemPtr> model_id_to_chat;
QHash<std::bitset<128>, chatItemPtr> model_hash_to_chat;
};