update// addec chatmodel.h chatmodel.cpp to realize the whole chat history
This commit is contained in:
49
src/chatmodel.cpp
Normal file
49
src/chatmodel.cpp
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user