summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-04-30 02:19:10 +0300
committerAndrei Karas <akaras@inbox.ru>2015-04-30 02:19:10 +0300
commit7b8493a8a977032b502e6df00b89f6b1a813b78b (patch)
tree6bd3a37411707724960ead54ccb7a7ea36586249 /src/gui
parent780731dbb1d104f3f91eede326fa7dce75b0d6f3 (diff)
downloadManaVerse-7b8493a8a977032b502e6df00b89f6b1a813b78b.tar.gz
ManaVerse-7b8493a8a977032b502e6df00b89f6b1a813b78b.tar.bz2
ManaVerse-7b8493a8a977032b502e6df00b89f6b1a813b78b.tar.xz
ManaVerse-7b8493a8a977032b502e6df00b89f6b1a813b78b.zip
In mail view window add buttons for open previous and next message.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/windows/mailviewwindow.cpp23
-rw-r--r--src/gui/windows/mailviewwindow.h2
-rw-r--r--src/gui/windows/mailwindow.cpp48
-rw-r--r--src/gui/windows/mailwindow.h4
4 files changed, 74 insertions, 3 deletions
diff --git a/src/gui/windows/mailviewwindow.cpp b/src/gui/windows/mailviewwindow.cpp
index 3caf7dc53..8dce1228b 100644
--- a/src/gui/windows/mailviewwindow.cpp
+++ b/src/gui/windows/mailviewwindow.cpp
@@ -26,7 +26,7 @@
#include "gui/mailmessage.h"
-#include "gui/windows/setupwindow.h"
+#include "gui/windows/mailwindow.h"
#include "gui/widgets/button.h"
#include "gui/widgets/containerplacer.h"
@@ -59,6 +59,8 @@ MailViewWindow::MailViewWindow(const MailMessage *const message) :
mGetAttachButton(nullptr),
// TRANSLATORS: mail view window button
mCloseButton(new Button(this, _("Close"), "close", this)),
+ mPrevButton(new Button(this, "<", "prev", this)),
+ mNextButton(new Button(this, ">", "next", this)),
// TRANSLATORS: mail view window label
mTimeLabel(new Label(this, strprintf("%s %s", _("Time:"),
message->strTime.c_str()))),
@@ -119,9 +121,14 @@ MailViewWindow::MailViewWindow(const MailMessage *const message) :
if (message->money || message->itemId)
{
mGetAttachButton = new Button(this, _("Get attach"), "attach", this);
- placer(0, n, mGetAttachButton);
+ placer(0, n++, mGetAttachButton);
}
- placer(2, n, mCloseButton);
+ ContainerPlacer placer2;
+ placer2 = getPlacer(0, n);
+
+ placer2(0, 0, mPrevButton);
+ placer2(1, 0, mNextButton);
+ placer2(2, 0, mCloseButton);
loadWindowState();
enableVisibleSound(true);
@@ -151,4 +158,14 @@ void MailViewWindow::action(const ActionEvent &event)
if (mGetAttachButton)
mailHandler->getAttach(mMessage->id);
}
+ else if (eventId == "next")
+ {
+ if (mMessage)
+ mailWindow->viewNext(mMessage->id);
+ }
+ else if (eventId == "prev")
+ {
+ if (mMessage)
+ mailWindow->viewPrev(mMessage->id);
+ }
}
diff --git a/src/gui/windows/mailviewwindow.h b/src/gui/windows/mailviewwindow.h
index 155449bcf..77e1fb2cb 100644
--- a/src/gui/windows/mailviewwindow.h
+++ b/src/gui/windows/mailviewwindow.h
@@ -50,6 +50,8 @@ class MailViewWindow final : public Window,
const MailMessage *mMessage;
Button *mGetAttachButton;
Button *mCloseButton;
+ Button *mPrevButton;
+ Button *mNextButton;
Label *mTimeLabel;
Label *mMoneyLabel;
Label *mFromLabel;
diff --git a/src/gui/windows/mailwindow.cpp b/src/gui/windows/mailwindow.cpp
index ecef7b54e..aec30ce89 100644
--- a/src/gui/windows/mailwindow.cpp
+++ b/src/gui/windows/mailwindow.cpp
@@ -210,3 +210,51 @@ void MailWindow::showMessage(MailMessage *const mail)
delete mailViewWindow;
mailViewWindow = new MailViewWindow(mail);
}
+
+void MailWindow::viewNext(const int id)
+{
+ FOR_EACH (std::vector<MailMessage*>::iterator, it, mMessages)
+ {
+ MailMessage *message = *it;
+ if (message && message->id == id)
+ {
+ ++ it;
+ if (it == mMessages.end())
+ {
+ it = mMessages.begin();
+ mListBox->setSelected(0);
+ }
+ else
+ {
+ mListBox->setSelected(mListBox->getSelected() + 1);
+ }
+ message = *it;
+ mailHandler->readMessage(message->id);
+ return;
+ }
+ }
+}
+
+void MailWindow::viewPrev(const int id)
+{
+ FOR_EACH (std::vector<MailMessage*>::iterator, it, mMessages)
+ {
+ MailMessage *message = *it;
+ if (message && message->id == id)
+ {
+ if (it == mMessages.begin())
+ {
+ it = mMessages.end();
+ mListBox->setSelected(mMessages.size() - 1);
+ }
+ else
+ {
+ mListBox->setSelected(mListBox->getSelected() - 1);
+ }
+ -- it;
+ message = *it;
+ mailHandler->readMessage(message->id);
+ return;
+ }
+ }
+}
diff --git a/src/gui/windows/mailwindow.h b/src/gui/windows/mailwindow.h
index 23f89be0a..fc5fab397 100644
--- a/src/gui/windows/mailwindow.h
+++ b/src/gui/windows/mailwindow.h
@@ -58,6 +58,10 @@ class MailWindow final : public Window,
void removeMail(const int id);
+ void viewNext(const int id);
+
+ void viewPrev(const int id);
+
private:
std::vector<MailMessage*> mMessages;
std::map<int, MailMessage*> mMessagesMap;