ircdocktabcontents.h
1 //------------------------------------------------------------------------------
2 // ircdocktabcontents.h
3 //------------------------------------------------------------------------------
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 // 02110-1301 USA
19 //
20 //------------------------------------------------------------------------------
21 // Copyright (C) 2010 "Zalewa" <zalewapl@gmail.com>
22 //------------------------------------------------------------------------------
23 #ifndef __IRCDOCK_TAB_CONTENTS_H_
24 #define __IRCDOCK_TAB_CONTENTS_H_
25 
26 #include "dptr.h"
27 
28 #include <QWidget>
29 
30 class IRCAdapterBase;
31 class IRCChatAdapter;
32 class IRCDock;
33 class IRCMessageClass;
34 class IRCNetworkAdapter;
35 class IRCNetworkEntity;
37 class IRCUserInfo;
38 class IRCUserList;
39 class QMenu;
40 class QModelIndex;
41 class QStandardItem;
42 
46 class IRCDockTabContents : public QWidget
47 {
48  Q_OBJECT
49 
50 public:
51  IRCDockTabContents(IRCDock *pParentIRCDock);
52  ~IRCDockTabContents() override;
53 
58 
65  void grabFocus();
66  bool hasTabFocus() const;
67 
68  QIcon icon() const;
69 
70  IRCAdapterBase *ircAdapter() const
71  {
72  return pIrcAdapter;
73  }
74 
79  void setIRCAdapter(IRCAdapterBase *pAdapter);
80 
81  QString title() const;
82  QString titleColor() const;
83 
84 public slots:
85  void receiveMessage(const QString &message);
86  void receiveMessageWithClass(const QString &message, const IRCMessageClass &messageClass);
87 
88 signals:
96 
97  void titleBlinkRequested();
103  void titleChange(IRCDockTabContents *pCaller);
104 
109  void focusRequest(IRCDockTabContents *pCaller);
110 
111  void newMessagePrinted();
112 
113 protected slots:
114  void adapterFocusRequest();
115  void adapterTerminating();
116 
117  void adapterTitleChange()
118  {
119  emit titleChange(this);
120  }
121 
122  void nameAdded(const IRCUserInfo &userInfo);
123  void nameListUpdated(const IRCUserList &userList);
124  void nameRemoved(const IRCUserInfo &userInfo);
125  void nameUpdated(const IRCUserInfo &userInfo);
126 
131  void newChatWindowIsOpened(IRCChatAdapter *pAdapter);
132 
133  void myNicknameUsedSlot();
134 
135  void receiveError(const QString &error);
136  void sendMessage();
137  void userListCustomContextMenuRequested(const QPoint &pos);
138  void userListDoubleClicked();
139 
140 protected:
141  IRCAdapterBase *pIrcAdapter;
142  IRCDock *pParentIRCDock;
143 
144  bool eventFilter(QObject *watched, QEvent *event) override;
145 
146 private:
147  class UserListMenu;
148 
149  enum PrivChatMenu
150  {
151  PrivWhois,
152  PrivCtcpPing,
153  PrivCtcpTime,
154  PrivCtcpVersion,
155  PrivIgnore
156  };
157 
159  friend class PrivData<IRCDockTabContents>;
160 
161  static const int BLINK_TIMER_DELAY_MS;
162 
163  void alertIfConfigured();
164  void appendGeneralChatContextMenuOptions(QMenu *menu);
165  void appendPrivChatContextMenuOptions(QMenu *menu);
166  void appendPrivChatContextMenuAction(QMenu *menu, const QString &text, PrivChatMenu type);
167 
168  void completeNickname();
169  QStandardItem *findUserListItem(const QString &nickname);
170  UserListMenu &getUserListContextMenu();
171  void insertMessage(const IRCMessageClass &messageClass, const QString &htmlString);
172  void markDate();
173  IRCNetworkAdapter *network();
174  const IRCNetworkEntity &networkEntity() const;
175  bool openLog();
176  QString recipient() const;
177  bool restoreLog();
178  void rotateOldLog();
179  QString selectedNickname();
180 
181  void sendCtcpPing(const QString &nickname);
182  void sendCtcpTime(const QString &nickname);
183  void sendCtcpVersion(const QString &nickname);
184  void sendWhois(const QString &nickname);
185 
191  void setBlinkTitle(bool b);
195  void setupNewUserListModel();
196  void startIgnoreOperation(const QString &nickname);
197 
198  QString wrapTextWithMetaTags(const QString &text,
199  const IRCMessageClass &messageClass) const;
200 
201  bool writeLog(const QString &text);
202 
203 private slots:
204  void blinkTimerSlot();
205  void onFocusChanged(QWidget *old, QWidget *now);
206  void onPrivChatActionTriggered();
207  void printToSendersNetworksCurrentChatBox(const QString &text, const IRCMessageClass &msgClass);
208  void resetNicknameCompletion();
209  void showChatContextMenu(const QPoint &pos);
210  void showIgnoresManager();
211 };
212 
213 #endif