1 #ifndef TAB_ROOM_H
2 #define TAB_ROOM_H
3 
4 #include "lineeditcompleter.h"
5 #include "tab.h"
6 
7 #include <QFocusEvent>
8 #include <QGroupBox>
9 #include <QKeyEvent>
10 #include <QMap>
11 
12 namespace google
13 {
14 namespace protobuf
15 {
16 class Message;
17 }
18 } // namespace google
19 class AbstractClient;
20 class UserList;
21 class QLabel;
22 class ChatView;
23 class QPushButton;
24 class QTextTable;
25 class QCompleter;
26 class RoomEvent;
27 class ServerInfo_Room;
28 class ServerInfo_Game;
29 class Event_ListGames;
30 class Event_JoinRoom;
31 class Event_LeaveRoom;
32 class Event_RoomSay;
33 class GameSelector;
34 class Response;
35 class PendingCommand;
36 class ServerInfo_User;
37 class LineEditCompleter;
38 
39 class TabRoom : public Tab
40 {
41     Q_OBJECT
42 private:
43     AbstractClient *client;
44     int roomId;
45     QString roomName;
46     ServerInfo_User *ownUser;
47     QMap<int, QString> gameTypes;
48 
49     GameSelector *gameSelector;
50     UserList *userList;
51     ChatView *chatView;
52     QLabel *sayLabel;
53     LineEditCompleter *sayEdit;
54     QGroupBox *chatGroupBox;
55 
56     QMenu *roomMenu;
57     QAction *aLeaveRoom;
58     QAction *aOpenChatSettings;
59     QAction *aClearChat;
60     QString sanitizeHtml(QString dirty) const;
61 
62     QStringList autocompleteUserList;
63     QCompleter *completer;
64 signals:
65     void roomClosing(TabRoom *tab);
66     void openMessageDialog(const QString &userName, bool focus);
67     void maximizeClient();
68     void notIdle();
69 private slots:
70     void sendMessage();
71     void sayFinished(const Response &response);
72     void actLeaveRoom();
73     void actClearChat();
74     void actOpenChatSettings();
75     void addMentionTag(QString mentionTag);
76     void focusTab();
77     void actShowMentionPopup(QString &sender);
78     void actShowPopup(const QString &message);
79     void actCompleterChanged();
80 
81     void processListGamesEvent(const Event_ListGames &event);
82     void processJoinRoomEvent(const Event_JoinRoom &event);
83     void processLeaveRoomEvent(const Event_LeaveRoom &event);
84     void processRoomSayEvent(const Event_RoomSay &event);
85     void refreshShortcuts();
86 
87 public:
88     TabRoom(TabSupervisor *_tabSupervisor,
89             AbstractClient *_client,
90             ServerInfo_User *_ownUser,
91             const ServerInfo_Room &info);
92     ~TabRoom();
93     void retranslateUi();
94     void closeRequest();
95     void tabActivated();
96     void processRoomEvent(const RoomEvent &event);
getRoomId()97     int getRoomId() const
98     {
99         return roomId;
100     }
getGameTypes()101     const QMap<int, QString> &getGameTypes() const
102     {
103         return gameTypes;
104     }
getChannelName()105     QString getChannelName() const
106     {
107         return roomName;
108     }
getTabText()109     QString getTabText() const
110     {
111         return roomName;
112     }
getUserInfo()113     const ServerInfo_User *getUserInfo() const
114     {
115         return ownUser;
116     }
117 
118     PendingCommand *prepareRoomCommand(const ::google::protobuf::Message &cmd);
119     void sendRoomCommand(PendingCommand *pend);
120 };
121 
122 #endif
123