From 600c370ed33ec9828ef609d68a8e46d564f0f1af Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 29 Apr 2015 21:36:44 +0300 Subject: eathena: impliment packet SMSG_MAIL_RETURN. --- src/gui/windows/mailwindow.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'src/gui/windows/mailwindow.cpp') diff --git a/src/gui/windows/mailwindow.cpp b/src/gui/windows/mailwindow.cpp index 15faf779a..ecef7b54e 100644 --- a/src/gui/windows/mailwindow.cpp +++ b/src/gui/windows/mailwindow.cpp @@ -164,6 +164,37 @@ void MailWindow::addMail(MailMessage *const message) mMessagesMap[message->id] = message; } +void MailWindow::removeMail(const int id) +{ + std::map::iterator it1 = mMessagesMap.find(id); + if (it1 != mMessagesMap.end()) + mMessagesMap.erase(it1); + + mMailModel->clear(); + + FOR_EACH (std::vector::iterator, it, mMessages) + { + MailMessage *message = *it; + if (message && message->id == id) + { + mMessages.erase(it); + delete message; + break; + } + } + + FOR_EACH (std::vector::iterator, it, mMessages) + { + MailMessage *message = *it; + if (message) + { + mMailModel->add(strprintf("%s %s", + message->unread ? " " : "U", + message->title.c_str())); + } + } +} + void MailWindow::showMessage(MailMessage *const mail) { if (!mail) -- cgit v1.2.3-70-g09d2