forked from lucretius/SilentDragonLite
Strider
4 years ago
3 changed files with 147 additions and 2 deletions
@ -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
|
|||
} |
@ -0,0 +1,94 @@ |
|||
#include <string> |
|||
#include <map> |
|||
#include <vector> |
|||
#include <QListView> |
|||
|
|||
class ChatItem |
|||
{ |
|||
private: |
|||
long timestamp; |
|||
std::string address; |
|||
std::string contact; |
|||
std::string memo; |
|||
bool outgoing = false; |
|||
|
|||
public: |
|||
ChatItem() {} |
|||
ChatItem(long timestamp, std::string address, std::string contact, std::string memo); |
|||
ChatItem(long timestamp, std::string address, std::string contact, std::string memo, bool outgoing = false); |
|||
|
|||
long getTimestamp() |
|||
{ |
|||
return this->timestamp; |
|||
} |
|||
|
|||
std::string getAddress() |
|||
{ |
|||
return this->address; |
|||
} |
|||
|
|||
std::string getContact() |
|||
{ |
|||
return this->contact; |
|||
} |
|||
|
|||
std::string getMemo() |
|||
{ |
|||
return this->memo; |
|||
} |
|||
|
|||
bool isOutgoing() |
|||
{ |
|||
return this->outgoing; |
|||
} |
|||
|
|||
void setTimestamp(long timestamp) |
|||
{ |
|||
this->timestamp = timestamp; |
|||
} |
|||
|
|||
void setAddress(std::string address) |
|||
{ |
|||
this->address = address; |
|||
} |
|||
|
|||
void setContact(std::string contact) |
|||
{ |
|||
this->contact = contact; |
|||
} |
|||
|
|||
void setMemo(std::string memo) |
|||
{ |
|||
this->memo = memo; |
|||
} |
|||
|
|||
void toggleOutgo() |
|||
{ |
|||
this->outgoing = true; |
|||
} |
|||
|
|||
~ChatItem() |
|||
{ |
|||
delete timestamp; |
|||
delete address; |
|||
delete contact; |
|||
delete memo; |
|||
delete outgoing; |
|||
} |
|||
}; |
|||
|
|||
class ChatModel |
|||
{ |
|||
private: |
|||
std::map<long, ChatItem> chatItems; |
|||
|
|||
public: |
|||
ChatModel() {}; |
|||
ChatModel(std::map<long, ChatItem> chatItems); |
|||
ChatModel(std::vector<ChatItem> chatItems); |
|||
std::map<long, ChatItem> getItems(); |
|||
void setItems(std::map<long, ChatItem> items); |
|||
void setItems(std::vector<ChatItem> items); |
|||
void renderChatBox(QListView &view); |
|||
void renderChatBox(QListView *view); |
|||
}; |
Loading…
Reference in new issue