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/windows | |
parent | 82e3927dd6a1e7c035cda8c88a1287834367b95f (diff) | |
download | plus-b68c40d34eecf9da09a00101286b046d93927161.tar.gz plus-b68c40d34eecf9da09a00101286b046d93927161.tar.bz2 plus-b68c40d34eecf9da09a00101286b046d93927161.tar.xz plus-b68c40d34eecf9da09a00101286b046d93927161.zip |
Add support for show mail list for new mail system.
Diffstat (limited to 'src/gui/windows')
-rw-r--r-- | src/gui/windows/mailwindow.cpp | 38 | ||||
-rw-r--r-- | src/gui/windows/mailwindow.h | 8 |
2 files changed, 37 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) 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; }; |