update// addec chatmodel.h chatmodel.cpp to realize the whole chat history

This commit is contained in:
Strider
2020-04-26 21:50:49 +02:00
parent 8793d96e39
commit 22cc122120
3 changed files with 147 additions and 2 deletions

49
src/chatmodel.cpp Normal file
View File

@@ -0,0 +1,49 @@
#include "chatmodel.h"
ChatModel::ChatModel(std::map<long, ChatItem> chatItems)
{
this->chatItems = chatItems;
}
ChatModel::ChatModel(std::vector<ChatItem> chatItems)
{
this->setItems(chatItems);
}
std::map<long, ChatItem> ChatModel::getItems()
{
return this->chatItems;
}
void ChatModel::setItems(std::map<long, ChatItem> items)
{
this->chatItems = chatItems;
}
void ChatModel::setItems(std::vector<ChatItem> items)
{
for(ChatItem c : items)
{
this->chatItems[c.getTimestamp()] = c;
}
}
void ChatModel::renderChatBox(QListView &view)
{
for(ChatItem c : items)
{
view.getItems().add(QString("[Timestamp] <Contactname|Me>: lorem ipsum ...."));
}
//todo render items to view
}
void ChatModel::renderChatBox(QListView *view)
{
for(ChatItem c : items)
{
view->getItems().add(QString("[Timestamp] <Contactname|Me>: lorem ipsum ...."));
}
//todo render items to view
}