summaryrefslogtreecommitdiff
path: root/src/gui/windows/mailwindow.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-08-25 03:10:19 +0300
committerAndrei Karas <akaras@inbox.ru>2017-08-25 03:10:19 +0300
commitb68c40d34eecf9da09a00101286b046d93927161 (patch)
tree3a72009efde8295d85309b77abe1df9b5e9d5ec7 /src/gui/windows/mailwindow.cpp
parent82e3927dd6a1e7c035cda8c88a1287834367b95f (diff)
downloadmanaplus-b68c40d34eecf9da09a00101286b046d93927161.tar.gz
manaplus-b68c40d34eecf9da09a00101286b046d93927161.tar.bz2
manaplus-b68c40d34eecf9da09a00101286b046d93927161.tar.xz
manaplus-b68c40d34eecf9da09a00101286b046d93927161.zip
Add support for show mail list for new mail system.
Diffstat (limited to 'src/gui/windows/mailwindow.cpp')
-rw-r--r--src/gui/windows/mailwindow.cpp38
1 files changed, 29 insertions, 9 deletions
diff --git a/src/gui/windows/mailwindow.cpp b/src/gui/windows/mailwindow.cpp
index 3d157ad3b..ec107f3a6 100644
--- a/src/gui/windows/mailwindow.cpp
+++ b/src/gui/windows/mailwindow.cpp
@@ -46,6 +46,7 @@
#include "utils/dtor.h"
#include "utils/foreach.h"
#include "utils/gettext.h"
+#include "utils/stdmove.h"
#include "utils/stringutils.h"
#include "debug.h"
@@ -60,7 +61,7 @@ MailWindow::MailWindow() :
mMessagesMap(),
mMailModel(new ExtendedNamesModel),
mListBox(CREATEWIDGETR(ExtendedListBox,
- this, mMailModel, "extendedlistbox.xml")),
+ this, mMailModel, "extendedlistbox.xml", 0)),
mListScrollArea(new ScrollArea(this, mListBox,
fromBool(getOptionBool("showlistbackground"), Opaque),
"mail_listbackground.xml")),
@@ -74,6 +75,7 @@ MailWindow::MailWindow() :
mReturnButton(new Button(this, _("Return"), "return", this)),
// TRANSLATORS: mail window button
mOpenButton(new Button(this, _("Open"), "open", this)),
+ mOpenType(MailOpenType::Mail),
mUseMail2(settings.enableNewMailSystem)
{
setWindowName("Mail");
@@ -167,14 +169,31 @@ void MailWindow::clear()
mListBox->setSelected(-1);
}
+std::string MailWindow::getMailHeader(MailMessage *const message)
+{
+ if (mUseMail2)
+ {
+ std::string header;
+ if (message->read)
+ header.append(" ");
+ else
+ header.append("U");
+ return STD_MOVE(header);
+ }
+ else
+ {
+ return strprintf("%s %s",
+ message->read ? " " : "U",
+ message->title.c_str());
+ }
+}
+
void MailWindow::addMail(MailMessage *const message)
{
if (message == nullptr)
return;
mMessages.push_back(message);
- mMailModel->add(strprintf("%s %s",
- message->unread ? " " : "U",
- message->title.c_str()));
+ mMailModel->add(getMailHeader(message));
mMessagesMap[message->id] = message;
}
@@ -201,11 +220,7 @@ void MailWindow::removeMail(const int id)
{
MailMessage *message = *it;
if (message != nullptr)
- {
- mMailModel->add(strprintf("%s %s",
- message->unread ? " " : "U",
- message->title.c_str()));
- }
+ mMailModel->add(getMailHeader(message));
}
}
@@ -294,9 +309,14 @@ void MailWindow::postConnection()
void MailWindow::refreshMails()
{
if (mUseMail2)
+ {
+ clear();
mail2Handler->refreshMailList(MailOpenType::Mail, 0);
+ }
else
+ {
mailHandler->refresh();
+ }
}
void MailWindow::createMail(const std::string &to)