ManaPlus
mailwindow.h
Go to the documentation of this file.
1 /*
2  * The ManaPlus Client
3  * Copyright (C) 2011-2019 The ManaPlus Developers
4  * Copyright (C) 2019-2021 Andrei Karas
5  *
6  * This file is part of The ManaPlus Client.
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  */
21 
22 #ifndef GUI_WINDOWS_MAILWINDOW_H
23 #define GUI_WINDOWS_MAILWINDOW_H
24 
25 #include "gui/widgets/window.h"
26 
27 #include "enums/net/mailopentype.h"
28 
30 
31 class Button;
32 class ExtendedListBox;
33 class ExtendedNamesModel;
34 class ScrollArea;
35 
36 struct MailMessage;
37 
43 class MailWindow final : public Window,
44  public ActionListener
45 {
46  public:
47  MailWindow();
48 
50 
51  ~MailWindow() override final;
52 
53  void action(const ActionEvent &event) override final;
54 
55  void addMail(MailMessage *const message);
56 
57  void clear() override final;
58 
59  void showMessage(MailMessage *const mail,
60  const int itemsCount);
61 
62  void removeMail(const int64_t id);
63 
64  void viewNext(const int64_t id);
65 
66  void viewPrev(const int64_t id);
67 
68  void mouseClicked(MouseEvent &event) override final;
69 
70  void postConnection();
71 
72  static void createMail(const std::string &to);
73 
74  MailMessage *findMail(const int64_t id) A_WARN_UNUSED;
75 
76  void setOpenType(const MailOpenTypeT &type)
77  { mOpenType = type; }
78 
80  { return mOpenType; }
81 
82  void setLastPage();
83 
84  void refreshMailNames();
85 
86  private:
87  void refreshMails();
88 
89  std::string getMailHeader(const MailMessage *const message) const
91 
92  STD_VECTOR<MailMessage*> mMessages;
93  std::map<int64_t, MailMessage*> mMessagesMap;
103  bool mUseMail2;
104  bool mLastPage;
105 };
106 
107 extern MailWindow *mailWindow;
108 
109 #endif // GUI_WINDOWS_MAILWINDOW_H
Definition: button.h:102
Button * mRefreshButton
Definition: mailwindow.h:97
void refreshMailNames()
Definition: mailwindow.cpp:390
std::vector< MailMessage * > mMessages
Definition: mailwindow.h:92
bool mLastPage
Definition: mailwindow.h:104
std::map< int64_t, MailMessage * > mMessagesMap
Definition: mailwindow.h:93
Button * mReturnButton
Definition: mailwindow.h:100
ExtendedNamesModel * mMailModel
Definition: mailwindow.h:94
void refreshMails()
Definition: mailwindow.cpp:352
void mouseClicked(MouseEvent &event)
Definition: mailwindow.cpp:334
void clear()
Definition: mailwindow.cpp:184
void postConnection()
Definition: mailwindow.cpp:347
void setOpenType(const MailOpenTypeT &type)
Definition: mailwindow.h:76
bool mUseMail2
Definition: mailwindow.h:103
void removeMail(const int64_t id)
Definition: mailwindow.cpp:233
ScrollArea * mListScrollArea
Definition: mailwindow.h:96
void addMail(MailMessage *const message)
Definition: mailwindow.cpp:224
ExtendedListBox * mListBox
Definition: mailwindow.h:95
void viewPrev(const int64_t id)
Definition: mailwindow.cpp:306
std::string getMailHeader(const MailMessage *const message) const
Definition: mailwindow.cpp:193
void action(const ActionEvent &event)
Definition: mailwindow.cpp:127
Button * mOpenButton
Definition: mailwindow.h:101
MailMessage * findMail(const int64_t id)
Definition: mailwindow.cpp:376
void showMessage(MailMessage *const mail, const int itemsCount)
Definition: mailwindow.cpp:260
MailOpenTypeT mOpenType
Definition: mailwindow.h:102
Button * mNewButton
Definition: mailwindow.h:98
Button * mDeleteButton
Definition: mailwindow.h:99
void viewNext(const int64_t id)
Definition: mailwindow.cpp:278
static void createMail(const std::string &to)
Definition: mailwindow.cpp:367
MailOpenTypeT getOpenType() const
Definition: mailwindow.h:79
void setLastPage()
Definition: mailwindow.cpp:384
Definition: window.h:102
#define A_WARN_UNUSED
Definition: localconsts.h:161
#define A_NONNULL(...)
Definition: localconsts.h:168
#define final
Definition: localconsts.h:46
#define A_DELETE_COPY(func)
Definition: localconsts.h:53
MailOpenType ::T MailOpenTypeT
Definition: mailopentype.h:33
MailWindow * mailWindow
Definition: mailwindow.cpp:54