-
Notifications
You must be signed in to change notification settings - Fork 88
/
mainwindow.h
122 lines (103 loc) · 3.18 KB
/
mainwindow.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include "fellowlistwidget.h"
#include "searchfellowdlg.h"
#include "recvtextedit.h"
#include "feiqlib/feiqengine.h"
#include "filemanagerdlg.h"
#include "settings.h"
#include <unordered_map>
#include "chooseemojidlg.h"
#include <QFileInfo>
#include "sendtextedit.h"
using namespace std;
namespace Ui {
class MainWindow;
}
class FeiqWin;
struct UnshownMessage
{
shared_ptr<ViewEvent> event;
bool replied = false;
bool read = false;
long notifyId = 0;
bool isUnread()
{
return !replied && !read;
}
};
Q_DECLARE_METATYPE(shared_ptr<ViewEvent>)
class MainWindow : public QMainWindow, IFeiqView
{
Q_OBJECT
friend class FeiqWin;
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
void setFeiqWin(FeiqWin* feiqWin);
public slots:
void onNotifyClicked(const QString& fellowIp);
void onNotifyReplied(long notifyId, const QString& fellowIp, const QString& reply);
protected:
void enterEvent(QEvent *event);
signals:
void showErrorAndQuit(const QString& text);
void statChanged(FileTask* fileTask);
void progressChanged(FileTask* fileTask);
void feiqViewEvent(shared_ptr<ViewEvent> event);
private slots:
void finishSearch(const Fellow* fellow);
void openSettings();
void openSearchDlg();
void openDownloadDlg();
void onShowErrorAndQuit(const QString& text);
void navigateToFileTask(IdType packetNo, IdType fileId, bool upload);
void sendKnock();
void sendText();
void openChartTo(const Fellow* fellow);
void handleFeiqViewEvent(shared_ptr<ViewEvent> event);
void refreshFellowList();
void addFellow();
void openChooseEmojiDlg();
void sendFile();
void sendFile(string filepath);
void sendFiles(QList<QFileInfo> files);
private:
void userAddFellow(QString ip);
long showNotification(const Fellow* fellow, const QString& text);
shared_ptr<Fellow> checkCurFellow();
void showResult(pair<bool, string> ret, const Content *content);
vector<const Fellow*> fellowSearchDriver(const QString& text);
void initFeiq();
void readEvent(const ViewEvent* event);
void setBadgeNumber(int number);
QString simpleTextOf(const Content* content);
UnshownMessage& addUnshownMessage(const Fellow *fellow, shared_ptr<ViewEvent> event);
UnshownMessage *findUnshownMessage(int id);
void notifyUnshown(UnshownMessage &umsg);
void updateUnshownHint(const Fellow* fellow);
int getUnreadCount();
void flushUnshown(const Fellow* fellow);
// IFileTaskObserver interface
public:
void onStateChanged(FileTask *fileTask);
void onProgress(FileTask *fileTask);
// IFeiqView interface
public:
void onEvent(shared_ptr<ViewEvent> event);
private:
Ui::MainWindow *ui;
FellowListWidget mFellowList;
SearchFellowDlg* mSearchFellowDlg;
FileManagerDlg* mDownloadFileDlg;
ChooseEmojiDlg* mChooseEmojiDlg;
Settings* mSettings;
FeiqEngine mFeiq;
RecvTextEdit* mRecvTextEdit;
SendTextEdit* mSendTextEdit;
QString mTitle;
unordered_map<const Fellow*, list<UnshownMessage>> mUnshownEvents;
FeiqWin* mFeiqWin = nullptr;
};
#endif // MAINWINDOW_H