summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/windows/mailviewwindow.cpp36
-rw-r--r--src/gui/windows/mailviewwindow.h6
-rw-r--r--src/gui/windows/mailwindow.cpp11
-rw-r--r--src/gui/windows/mailwindow.h2
4 files changed, 50 insertions, 5 deletions
diff --git a/src/gui/windows/mailviewwindow.cpp b/src/gui/windows/mailviewwindow.cpp
index 56367ef78..b250fad43 100644
--- a/src/gui/windows/mailviewwindow.cpp
+++ b/src/gui/windows/mailviewwindow.cpp
@@ -23,6 +23,7 @@
#include "configuration.h"
#include "settings.h"
+#include "net/mail2handler.h"
#include "net/mailhandler.h"
#include "gui/mailmessage.h"
@@ -54,7 +55,7 @@
MailViewWindow *mailViewWindow = nullptr;
-MailViewWindow::MailViewWindow(const MailMessage *const message,
+MailViewWindow::MailViewWindow(MailMessage *const message,
const int itemsCount) :
// TRANSLATORS: mail view window name
Window(_("View mail"), Modal_false, nullptr, "mailview.xml"),
@@ -128,7 +129,7 @@ MailViewWindow::MailViewWindow(const MailMessage *const message,
mGetMoneyButton = new Button(this,
// TRANSLATORS: mail view attached money button
_("Get money"),
- "attach", this);
+ "money", this);
placer(0, n++, mGetMoneyButton);
}
placer(0, n++, mGetAttachButton);
@@ -170,8 +171,23 @@ void MailViewWindow::action(const ActionEvent &event)
}
else if (eventId == "attach")
{
- if (mGetAttachButton != nullptr)
+ if (mUseMail2)
+ {
+ mail2Handler->requestItems(mailWindow->getOpenType(),
+ mMessage->id);
+ }
+ else
+ {
mailHandler->getAttach(mMessage->id);
+ }
+ }
+ else if (eventId == "money")
+ {
+ if (mUseMail2)
+ {
+ mail2Handler->requestMoney(mailWindow->getOpenType(),
+ mMessage->id);
+ }
}
else if (eventId == "next")
{
@@ -221,3 +237,17 @@ void MailViewWindow::updateItems()
mItemContainer->updateMatrix();
updateAttachButton();
}
+
+void MailViewWindow::removeItems(const int64_t mailId)
+{
+ if (mailId != mMessage->id)
+ return;
+ mInventory->clear();
+ mMessage->type = static_cast<MailMessageType::Type>(
+ CAST_S32(mMessage->type) | CAST_S32(MailMessageType::Item));
+ mMessage->type = static_cast<MailMessageType::Type>(
+ CAST_S32(mMessage->type) ^ CAST_S32(MailMessageType::Item));
+ updateAttachButton();
+ if (mailWindow)
+ mailWindow->refreshMailNames();
+}
diff --git a/src/gui/windows/mailviewwindow.h b/src/gui/windows/mailviewwindow.h
index 524c029d4..13ad25676 100644
--- a/src/gui/windows/mailviewwindow.h
+++ b/src/gui/windows/mailviewwindow.h
@@ -38,7 +38,7 @@ class MailViewWindow final : public Window,
public ActionListener
{
public:
- MailViewWindow(const MailMessage *const message,
+ MailViewWindow(MailMessage *const message,
const int itemsCount) A_NONNULL(2);
A_DELETE_COPY(MailViewWindow)
@@ -51,10 +51,12 @@ class MailViewWindow final : public Window,
void updateItems();
+ void removeItems(const int64_t mailId);
+
private:
void updateAttachButton();
- const MailMessage *mMessage;
+ MailMessage *mMessage;
Button *mGetAttachButton;
Button *mGetMoneyButton;
Button *mCloseButton;
diff --git a/src/gui/windows/mailwindow.cpp b/src/gui/windows/mailwindow.cpp
index 18371b7ad..5536aecbc 100644
--- a/src/gui/windows/mailwindow.cpp
+++ b/src/gui/windows/mailwindow.cpp
@@ -375,3 +375,14 @@ void MailWindow::setLastPage()
mLastPage = true;
mReturnButton->setEnabled(false);
}
+
+void MailWindow::refreshMailNames()
+{
+ mMailModel->clear();
+ FOR_EACH (STD_VECTOR<MailMessage*>::iterator, it, mMessages)
+ {
+ MailMessage *message = *it;
+ if (message != nullptr)
+ mMailModel->add(getMailHeader(message));
+ }
+}
diff --git a/src/gui/windows/mailwindow.h b/src/gui/windows/mailwindow.h
index 1639dfed0..6a310fb37 100644
--- a/src/gui/windows/mailwindow.h
+++ b/src/gui/windows/mailwindow.h
@@ -80,6 +80,8 @@ class MailWindow final : public Window,
void setLastPage();
+ void refreshMailNames();
+
private:
void refreshMails();