summaryrefslogtreecommitdiff
path: root/src/gui/windows
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/windows')
-rw-r--r--src/gui/windows/mailwindow.cpp31
-rw-r--r--src/gui/windows/mailwindow.h2
2 files changed, 33 insertions, 0 deletions
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<int, MailMessage*>::iterator it1 = mMessagesMap.find(id);
+ if (it1 != mMessagesMap.end())
+ mMessagesMap.erase(it1);
+
+ mMailModel->clear();
+
+ FOR_EACH (std::vector<MailMessage*>::iterator, it, mMessages)
+ {
+ MailMessage *message = *it;
+ if (message && message->id == id)
+ {
+ mMessages.erase(it);
+ delete message;
+ break;
+ }
+ }
+
+ FOR_EACH (std::vector<MailMessage*>::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)
diff --git a/src/gui/windows/mailwindow.h b/src/gui/windows/mailwindow.h
index 15964aafe..23f89be0a 100644
--- a/src/gui/windows/mailwindow.h
+++ b/src/gui/windows/mailwindow.h
@@ -56,6 +56,8 @@ class MailWindow final : public Window,
void showMessage(MailMessage *const mail);
+ void removeMail(const int id);
+
private:
std::vector<MailMessage*> mMessages;
std::map<int, MailMessage*> mMessagesMap;