diff options
author | Andrei Karas <akaras@inbox.ru> | 2017-08-25 03:10:19 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2017-08-25 03:10:19 +0300 |
commit | b68c40d34eecf9da09a00101286b046d93927161 (patch) | |
tree | 3a72009efde8295d85309b77abe1df9b5e9d5ec7 /src/gui | |
parent | 82e3927dd6a1e7c035cda8c88a1287834367b95f (diff) | |
download | manaplus-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')
-rw-r--r-- | src/gui/mailmessage.h | 8 | ||||
-rw-r--r-- | src/gui/windows/mailwindow.cpp | 38 | ||||
-rw-r--r-- | src/gui/windows/mailwindow.h | 8 |
3 files changed, 43 insertions, 11 deletions
diff --git a/src/gui/mailmessage.h b/src/gui/mailmessage.h index c7aaf1cc7..b5ce75612 100644 --- a/src/gui/mailmessage.h +++ b/src/gui/mailmessage.h @@ -36,13 +36,15 @@ struct MailMessage final text(), id(0), time(0), + expireTime(0), money(0), itemAmount(0), itemId(0), itemType(0), itemAttribute(0U), itemRefine(0U), - unread(false), + type(0U), + read(false), itemIdentify(false) { for (int f = 0; f < 4; f ++) @@ -58,13 +60,15 @@ struct MailMessage final uint16_t card[maxMailCards]; int id; int time; + int expireTime; int money; int itemAmount; int itemId; int itemType; uint8_t itemAttribute; uint8_t itemRefine; - bool unread; + uint8_t type; + bool read; bool itemIdentify; }; #endif // GUI_MAILMESSAGE_H 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) diff --git a/src/gui/windows/mailwindow.h b/src/gui/windows/mailwindow.h index 9ac4a5069..b356b0666 100644 --- a/src/gui/windows/mailwindow.h +++ b/src/gui/windows/mailwindow.h @@ -23,6 +23,8 @@ #include "gui/widgets/window.h" +#include "enums/net/mailopentype.h" + #include "listeners/actionlistener.h" class Button; @@ -67,9 +69,14 @@ class MailWindow final : public Window, void createMail(const std::string &to); + void setOpenType(const MailOpenTypeT &type) + { mOpenType = type; } + private: void refreshMails(); + std::string getMailHeader(MailMessage *const message) A_NONNULL(2); + STD_VECTOR<MailMessage*> mMessages; std::map<int, MailMessage*> mMessagesMap; ExtendedNamesModel *mMailModel; @@ -80,6 +87,7 @@ class MailWindow final : public Window, Button *mDeleteButton; Button *mReturnButton; Button *mOpenButton; + MailOpenTypeT mOpenType; bool mUseMail2; }; |