ircdocktabcontents.h
1 //------------------------------------------------------------------------------
2 // ircdocktabcontents.h
3 //------------------------------------------------------------------------------
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
9 //
10 // This program 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
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; 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);
53 
58 
65  void grabFocus();
66  bool hasTabFocus() const;
67 
68  QIcon icon() const;
69 
70  IRCAdapterBase* ircAdapter() const { return pIrcAdapter; }
71 
76  void setIRCAdapter(IRCAdapterBase* pAdapter);
77 
78  QString title() const;
79  QString titleColor() const;
80 
81  public slots:
82  void receiveMessage(const QString& message);
83  void receiveMessageWithClass(const QString& message, const IRCMessageClass& messageClass);
84 
85  signals:
93 
94  void titleBlinkRequested();
100  void titleChange(IRCDockTabContents* pCaller);
101 
106  void focusRequest(IRCDockTabContents* pCaller);
107 
108  void newMessagePrinted();
109 
110  protected slots:
111  void adapterFocusRequest();
112  void adapterTerminating();
113 
114  void adapterTitleChange()
115  {
116  emit titleChange(this);
117  }
118 
119  void nameAdded(const IRCUserInfo& userInfo);
120  void nameListUpdated(const IRCUserList& userList);
121  void nameRemoved(const IRCUserInfo& userInfo);
122  void nameUpdated(const IRCUserInfo& userInfo);
123 
128  void newChatWindowIsOpened(IRCChatAdapter* pAdapter);
129 
130  void myNicknameUsedSlot();
131 
132  void receiveError(const QString& error);
133  void sendMessage();
134  void userListCustomContextMenuRequested(const QPoint& pos);
135  void userListDoubleClicked(const QModelIndex& index);
136 
137  protected:
138  IRCAdapterBase* pIrcAdapter;
139  IRCDock* pParentIRCDock;
140 
141  bool eventFilter(QObject *watched, QEvent *event);
142 
143  private:
144  class UserListMenu;
145 
146  enum PrivChatMenu
147  {
148  PrivWhois,
149  PrivCtcpPing,
150  PrivCtcpTime,
151  PrivCtcpVersion,
152  PrivIgnore
153  };
154 
156  friend class PrivData<IRCDockTabContents>;
157 
158  static const int BLINK_TIMER_DELAY_MS;
159 
160  void alertIfConfigured();
161  void appendGeneralChatContextMenuOptions(QMenu *menu);
162  void appendPrivChatContextMenuOptions(QMenu *menu);
163  void appendPrivChatContextMenuAction(QMenu *menu, const QString &text, PrivChatMenu type);
164 
165  void completeNickname();
166  QStandardItem* findUserListItem(const QString& nickname);
167  UserListMenu& getUserListContextMenu();
168  void insertMessage(const IRCMessageClass& messageClass, const QString& htmlString);
169  void markDate();
170  IRCNetworkAdapter* network();
171  const IRCNetworkEntity &networkEntity() const;
172  bool openLog();
173  QString recipient() const;
174  bool restoreLog();
175  void rotateOldLog();
176  QString selectedNickname();
177 
178  void sendCtcpPing(const QString &nickname);
179  void sendCtcpTime(const QString &nickname);
180  void sendCtcpVersion(const QString &nickname);
181  void sendWhois(const QString &nickname);
182 
188  void setBlinkTitle(bool b);
192  void setupNewUserListModel();
193  void startIgnoreOperation(const QString &nickname);
194 
195  QString wrapTextWithMetaTags(const QString &text,
196  const IRCMessageClass &messageClass) const;
197 
198  bool writeLog(const QString &text);
199 
200  private slots:
201  void blinkTimerSlot();
202  void onFocusChanged(QWidget *old, QWidget *now);
203  void onPrivChatActionTriggered();
204  void printToSendersNetworksCurrentChatBox(const QString &text, const IRCMessageClass &msgClass);
205  void resetNicknameCompletion();
206  void showChatContextMenu(const QPoint &pos);
207  void showIgnoresManager();
208 };
209 
210 #endif
Interprets communication between the client and the IRC server.
Allows to perform operation on a list of users.
Definition: ircuserlist.h:42
void setIRCAdapter(IRCAdapterBase *pAdapter)
Calling this multiple times on the same object will cause memory leaks.
Dockable widget designed for IRC communication.
Definition: ircdock.h:39
void grabFocus()
Called when tab becomes active.
Provides an unified communication interface between a client and IRC network entities.
void chatWindowCloseRequest(IRCDockTabContents *)
Emitted when the IRCAdapterBase that is associated with this widget is no longer valid - possibly eve...
Dockable widget designed for IRC communication.
Handles chatting through IRC.
void newChatWindowIsOpened(IRCChatAdapter *pAdapter)
Captures signals from IRC Networks which indicate that a new chat window is being opened...
void titleChange(IRCDockTabContents *pCaller)
Emitted when the variable returned by IRCAdapterBase::title() might have changed and the application ...
void focusRequest(IRCDockTabContents *pCaller)
Emitted when network adapter for this dock emits its focusRequest() signal.
Holds information flags about given nickname.
Definition: ircuserinfo.h:35
Definition: dptr.h:31
Data structure that describes and defines a connection to an IRC network or server.
void applyAppearanceSettings()
Applies current appearance settings from the IRC config.