KVIrc 5.2.0
Developer APIs
KviConsoleWindow.h
Go to the documentation of this file.
1#ifndef _KVI_CONSOLE_H_
2#define _KVI_CONSOLE_H_
3//=============================================================================
4//
5// File : KviConsoleWindow.h
6// Creation date : Sun Jun 25 2000 15:00:20 by Szymon Stefanek
7//
8// This file is part of the KVIrc IRC client distribution
9// Copyright (C) 2000-2010 Szymon Stefanek (pragma at kvirc dot net)
10//
11// This program is FREE software. You can redistribute it and/or
12// modify it under the terms of the GNU General Public License
13// as published by the Free Software Foundation; either version 2
14// of the License, or (at your option) any later version.
15//
16// This program is distributed in the HOPE that it will be USEFUL,
17// but WITHOUT ANY WARRANTY; without even the implied warranty of
18// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19// See the GNU General Public License for more details.
20//
21// You should have received a copy of the GNU General Public License
22// along with this program. If not, write to the Free Software Foundation,
23// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24//
25//=============================================================================
26
27#include "kvi_settings.h"
28#include "KviIrcConnection.h"
30#include "KviWindow.h"
31#include "KviIrcSocket.h"
32#include "KviIrcServer.h"
33#include "KviCString.h"
34#include "KviIrcContext.h"
35#include "KviUserListView.h"
36#include "KviThemedComboBox.h"
37
38#include <time.h>
39#include <vector>
40
41#include <QToolButton>
42
43class QToolBar;
44
45class KviAvatar;
46class KviDnsResolver;
48class KviIrcUserEntry;
49class KviIrcServer;
50class KviIrcNetwork;
51class KviProxy;
52class KviUserListView;
56
57#ifdef COMPILE_ON_WINDOWS
58// windoze wants it to compile QList<KviChannelWindow> and QList<KviQueryWindow>
59#include "KviChannelWindow.h"
60#include "KviQueryWindow.h"
61#else
63class KviQueryWindow;
64#endif
65
66//
67// The console window
68//
69
70#define KVI_CONSOLE_FLAG_FIRSTINAPP 1
71#define KVI_CONSOLE_FLAG_FIRSTINFRAME 2
72
74{
75 friend class KviMainWindow;
76 friend class KviIrcSocket;
77 friend class KviChannelWindow;
78 friend class KviQueryWindow;
79 friend class KviIrcContext;
80 Q_OBJECT
81protected:
82 KviConsoleWindow(int iFlags);
83
84public:
86
87protected:
88 int m_iFlags; // FIXME: make this a KviWindow property ?
89 // UI
93 QString m_szStatusString; // nick (flags) on server | not connected
98
99protected:
100 // UI
101 QPixmap * myIconPtr() override;
102 void fillCaptionBuffers() override;
103 void resizeEvent(QResizeEvent * e) override;
104 void closeEvent(QCloseEvent * e) override;
105 void getBaseLogFileName(QString & buffer) override;
106 void getWindowListTipText(QString & buffer) override;
107 QSize sizeHint() const override;
108 void applyOptions() override;
109 void triggerCreationEvents() override;
110 void fillStatusString();
111 //void socketError(int iError);
112 //void socketStateChange();
113 //void registerLinkMonitor(KviIrcSocketMonitor * m);
114 //void unregisterLinkMonitor(KviIrcSocketMonitor * m);
115 void loadProperties(KviConfigurationFile * cfg) override;
116 void saveProperties(KviConfigurationFile * cfg) override;
117
119 // internal helper for applyHighlighting
120 int triggerOnHighlight(KviWindow * wnd, int type, const QString & nick, const QString & user, const QString & host, const QString & szMsg, const QString & trigger);
121
122 void showNotifyList(bool bShow, bool bIgnoreSizeChange = false);
123 static int getSmartColorHashForNick(QString * szNick);
124
125public:
126 KviIrcContext * context() { return m_pContext; };
127
128 // UI
129 KviUserListView * notifyListView() const { return m_pNotifyListView; }
130 int selectedCount();
131
132 //
133 // State
134 //
136
137 // these should disappear!
138 bool isConnected() { return context()->isConnected(); }
139 bool isIPv6Connection();
140 bool isNotConnected();
141 bool connectionInProgress();
142 //
143 // This connection info
144 //
145 QString currentNetworkName();
146 KviAvatar * currentAvatar();
147 //
148 // IRC Context wide helpers (connection related)
149 //
150 void getUserTipText(const QString & nick, KviIrcUserEntry * e, QString & buffer);
152 {
153 NoWindowFlashing = 1, // has meaning only if NoHighlighting is NOT given, otherwise it is implied
154 NoNotifier = 2, // has meaning only if NoHighlighitng is NOT given, otherwise it is implied
155 NoHighlighting = 4,
156 NoNotifications = 7 // this is 1|2|4 implies NoWindowFlashing and NoNotifier
157 };
158 void outputPrivmsg(KviWindow * wnd, int type, const QString & nick,
159 const QString & user, const QString & host, const QString & msg, int iFlags = 0, const QString & prefix = QString(), const QString & suffix = QString(), const QDateTime & datetime = QDateTime());
160 // this applies highlighting to the specified message
161 // and triggers the OnHighlight event.
162 // it returns KVI_OUT_HIGHLIGHT if highlighting was applied
163 // and -1 if OnHighlight called halt
164 // otherwise it returns <type>
165 int applyHighlighting(KviWindow * wnd, int type, const QString & nick, const QString & user, const QString & host, const QString & szMsg);
166 // Avatar helpers (connection related)
167 void resetAvatarForMatchingUsers(KviRegisteredUser * u);
168 // this should be protected at least
169 void avatarChangedUpdateWindows(const QString & nick, const QString & textLine);
170 void avatarChanged(KviAvatar * avatar, const QString & nick, const QString & user, const QString & host, const QString & textLine);
171 KviAvatar * setAvatar(const QString & nick, const QString & user, const QString & host, const QString & szLocalPath, const QString & szName);
172 void checkDefaultAvatar(KviIrcUserEntry * e, const QString & nick, const QString & user, const QString & host);
173 void setAvatarFromOptions();
174
175 // This returns the default avatar for the current KVIrc user
176 // if he has chosen a valid avatar in the options dialog
177 // otherwise returns 0.
178 // The avatar is allocated with new and must be deleted
179 // when no longer needed.
180 KviAvatar * defaultAvatarFromOptions();
181
182 void terminateConnectionRequest(bool bForce = false, const char * quitMsg = nullptr);
183
184 // Status string (usermode + nick) (connection related too)
185 const QString & statusString() const { return m_szStatusString; }
186
187 KviWindow * activeWindow();
188 // User db, connection related
189 void completeChannel(const QString & word, std::vector<QString> & matches);
190 void completeServer(const QString & word, std::vector<QString> & matches);
191 void connectionAttached();
192 void connectionDetached();
193
199 void addHighlightedChannel(const QString & szChan);
200
206 void removeHighlightedChannel(const QString & szChan);
207
213 bool isHighlightedChannel(const QString & szChan) { return m_pTmpHighLightedChannels->contains(szChan, Qt::CaseInsensitive); };
214
215public slots:
216 void updateUri();
217 void executeInternalCommand(int index);
218 void recentUrlsChanged();
219protected slots:
220 void ircUriChanged(const QString &);
221 void toggleNotifyView();
222 void textViewRightClicked();
223};
224
229
231{
233 return connection()->target()->server()->isIPv6();
234}
235
237{
238 return (context()->state() == KviIrcContext::Idle);
239}
240
242{
243 return (connection() ? connection()->currentNetworkName() : QString());
244}
245
246#endif //_KVI_CONSOLE_H_
Channel widget: abstraction of an IRC channel.
An abstraction of a connection to an IRC server.
Irc server handling.
Lower stack protocol for IRC connection.
Query widget: abstraction of an IRC query.
User list view management.
Contains the KviWindow class.
Avatar class.
Definition KviAvatar.h:54
The class which manages a channel.
Definition KviChannelWindow.h:114
Definition KviConfigurationFile.h:50
Definition KviConsoleWindow.h:74
QString currentNetworkName()
Definition KviConsoleWindow.h:241
KviIrcContext::State state()
Definition KviConsoleWindow.h:135
const QString & statusString() const
Definition KviConsoleWindow.h:185
KviWindowToolPageButton * m_pNotifyViewButton
Definition KviConsoleWindow.h:91
static int getSmartColorHashForNick(QString *szNick)
QString m_szOwnSmartColor
Definition KviConsoleWindow.h:94
bool isConnected()
Definition KviConsoleWindow.h:138
bool isNotConnected()
Definition KviConsoleWindow.h:236
KviUserListView * notifyListView() const
Definition KviConsoleWindow.h:129
KviUserListView * m_pNotifyListView
Definition KviConsoleWindow.h:90
QStringList * m_pTmpHighLightedChannels
Definition KviConsoleWindow.h:95
KviIrcContext * context()
Definition KviConsoleWindow.h:126
int selectedCount()
Definition KviConsoleWindow.h:225
bool isHighlightedChannel(const QString &szChan)
Returns true if the channel is highlighted.
Definition KviConsoleWindow.h:213
void destroyConnection()
bool isIPv6Connection()
Definition KviConsoleWindow.h:230
KviIrcContext * m_pContext
Definition KviConsoleWindow.h:96
QList< int > m_SplitterSizesList
Definition KviConsoleWindow.h:97
void terminateConnectionRequest(bool bForce=false, const char *quitMsg=nullptr)
KviThemedComboBox * m_pAddressEdit
Definition KviConsoleWindow.h:92
OutputPrivmsgFlags
Definition KviConsoleWindow.h:152
QString m_szStatusString
Definition KviConsoleWindow.h:93
int m_iFlags
Definition KviConsoleWindow.h:88
The KviDnsResolver class.
Definition KviDnsResolver.h:90
KviIrcServer * server() const
Definition KviIrcConnectionTarget.h:56
KviIrcConnectionTarget * target() const
Returns the target of this connection.
Definition KviIrcConnection.h:210
Definition KviIrcContext.h:60
State
Definition KviIrcContext.h:76
@ Idle
Definition KviIrcContext.h:77
bool isConnected() const
Definition KviIrcContext.h:120
State state() const
Definition KviIrcContext.h:119
Network handling class.
Definition KviIrcNetwork.h:48
The class which manages the irc servers.
Definition KviIrcServer.h:52
bool isIPv6() const
Returns true if the server uses IPv6.
Definition KviIrcServer.h:284
This class is the lowest level of the KVIrc networking stack.
Definition KviIrcSocket.h:75
The class which manages the user database.
Definition KviIrcUserDataBase.h:47
A class to handle the entries of the user database.
Definition KviIrcUserEntry.h:45
Definition KviMainWindow.h:58
Definition KviNotifyList.h:43
Definition KviProxy.h:37
The class which manages a query.
Definition KviQueryWindow.h:50
Definition KviRegisteredUser.h:40
Definition KviThemedComboBox.h:34
User list view management class.
Definition KviUserListView.h:226
int selectedCount()
Returns the number of selected entries in the userlist.
Definition KviUserListView.h:348
Definition KviWindowToolWidget.h:47
Base class for all windows in KVIrc.
Definition KviWindow.h:75
virtual void loadProperties(KviConfigurationFile *pCfg)
Definition KviWindow.cpp:596
virtual void applyOptions()
Definition KviWindow.cpp:1137
virtual QPixmap * myIconPtr()
Definition KviWindow.cpp:627
virtual void triggerCreationEvents()
Definition KviWindow.h:468
virtual void getWindowListTipText(QString &szBuffer)
Definition KviWindow.h:357
virtual void fillCaptionBuffers()
Definition KviWindow.cpp:632
virtual void saveProperties(KviConfigurationFile *pCfg)
Definition KviWindow.cpp:570
KviIrcContext * context()
Definition KviWindow.cpp:1380
virtual void getBaseLogFileName(QString &szBuffer)
Definition KviWindow.cpp:565
void closeEvent(QCloseEvent *pEvent) override
Definition KviWindow.cpp:866
KviIrcConnection * connection()
Returns the current IRC connection (if any)
Definition KviWindow.cpp:1373
#define u
Definition detector.cpp:86
#define e
Definition detector.cpp:70
#define KVI_ASSERT(condition)
GNUC
Definition kvi_debug.h:137
This file contains compile time settings.
#define KVIRC_API
Definition kvi_settings.h:127