Diffstat (limited to 'noncore/net/opieirc/ircservertab.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/opieirc/ircservertab.cpp | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/noncore/net/opieirc/ircservertab.cpp b/noncore/net/opieirc/ircservertab.cpp index 2a34c0b..5ca7a29 100644 --- a/noncore/net/opieirc/ircservertab.cpp +++ b/noncore/net/opieirc/ircservertab.cpp | |||
@@ -1,15 +1,16 @@ | |||
1 | #include <qtextstream.h> | 1 | #include <qtextstream.h> |
2 | #include <qwhatsthis.h> | 2 | #include <qwhatsthis.h> |
3 | #include "ircservertab.h" | 3 | #include "ircservertab.h" |
4 | 4 | ||
5 | 5 | ||
6 | bool IRCServerTab::containsPing( const QString& text, IRCServerTab* tab ) { | 6 | bool IRCServerTab::containsPing( const QString& text, IRCServerTab* tab ) { |
7 | return (text.find("ping") != -1 && text.find( tab->server()->nick() != -1)); | 7 | return (text.contains(IRCMessageParser::tr("Received a CTCP PING from "))) || |
8 | (text.find("ping") != -1 && text.find( tab->server()->nick() != -1)); | ||
8 | } | 9 | } |
9 | 10 | ||
10 | 11 | ||
11 | IRCServerTab::IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) { | 12 | IRCServerTab::IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) { |
12 | m_server = server; | 13 | m_server = server; |
13 | m_session = new IRCSession(&m_server); | 14 | m_session = new IRCSession(&m_server); |
14 | m_mainWindow = mainWindow; | 15 | m_mainWindow = mainWindow; |
15 | m_close = FALSE; | 16 | m_close = FALSE; |
@@ -25,30 +26,36 @@ IRCServerTab::IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *pa | |||
25 | connect(m_field, SIGNAL(nextTab()), this, SIGNAL(nextTab())); | 26 | connect(m_field, SIGNAL(nextTab()), this, SIGNAL(nextTab())); |
26 | connect(m_field, SIGNAL(prevTab()), this, SIGNAL(prevTab())); | 27 | connect(m_field, SIGNAL(prevTab()), this, SIGNAL(prevTab())); |
27 | connect(m_field, SIGNAL(closeTab()), this, SIGNAL(closeTab())); | 28 | connect(m_field, SIGNAL(closeTab()), this, SIGNAL(closeTab())); |
28 | connect(this, SIGNAL(editFocus()), m_field, SLOT(setEditFocus())); | 29 | connect(this, SIGNAL(editFocus()), m_field, SLOT(setEditFocus())); |
29 | 30 | ||
30 | QWhatsThis::add(m_field, tr("Type commands here. A list of available commands can be found inside the OpieIRC help")); | 31 | QWhatsThis::add(m_field, tr("Type commands here. A list of available commands can be found inside the OpieIRC help")); |
31 | m_layout->add(m_field); | 32 | m_layout->add(m_field); |
32 | connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); | 33 | connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); |
33 | m_field->setFocus(); | ||
34 | connect(m_session, SIGNAL(outputReady(IRCOutput)), this, SLOT(display(IRCOutput))); | 34 | connect(m_session, SIGNAL(outputReady(IRCOutput)), this, SLOT(display(IRCOutput))); |
35 | connect(m_mainWindow, SIGNAL(updateScroll()), this, SLOT(scrolling())); | 35 | connect(m_mainWindow, SIGNAL(updateScroll()), this, SLOT(scrolling())); |
36 | settingsChanged(); | 36 | settingsChanged(); |
37 | |||
38 | m_field->setFocus(); | ||
39 | m_field->setActiveWindow(); | ||
40 | |||
37 | } | 41 | } |
38 | 42 | ||
39 | void IRCServerTab::scrolling(){ | 43 | void IRCServerTab::scrolling(){ |
40 | m_textview->ensureVisible(0, m_textview->contentsHeight()); | 44 | m_textview->ensureVisible(0, m_textview->contentsHeight()); |
41 | } | 45 | } |
42 | 46 | ||
43 | 47 | ||
44 | void IRCServerTab::appendText(QString text) { | 48 | void IRCServerTab::appendText(QString text) { |
45 | /* not using append because it creates layout problems */ | 49 | /* not using append because it creates layout problems */ |
46 | QString txt = m_textview->text() + text + "\n"; | 50 | QString txt = m_textview->text() + IRCTab::appendTimestamp( text ); |
51 | |||
52 | |||
53 | |||
47 | if (m_maxLines > 0 && m_lines >= m_maxLines) { | 54 | if (m_maxLines > 0 && m_lines >= m_maxLines) { |
48 | int firstBreak = txt.find('\n'); | 55 | int firstBreak = txt.find('\n'); |
49 | if (firstBreak != -1) { | 56 | if (firstBreak != -1) { |
50 | txt = "<qt bgcolor=\"" + m_backgroundColor + "\"/>" + txt.right(txt.length() - (firstBreak + 1)); | 57 | txt = "<qt bgcolor=\"" + m_backgroundColor + "\"/>" + txt.right(txt.length() - (firstBreak + 1)); |
51 | } | 58 | } |
52 | } else { | 59 | } else { |
53 | m_lines++; | 60 | m_lines++; |
54 | } | 61 | } |
@@ -229,21 +236,21 @@ void IRCServerTab::remove() { | |||
229 | if (m_session->isSessionActive()) { | 236 | if (m_session->isSessionActive()) { |
230 | /* While there is a running session */ | 237 | /* While there is a running session */ |
231 | m_close = TRUE; | 238 | m_close = TRUE; |
232 | m_session->endSession(); | 239 | m_session->endSession(); |
233 | } else { | 240 | } else { |
234 | /* Session has previously been closed */ | 241 | /* Session has previously been closed */ |
235 | m_channelTabs.first(); | 242 | m_channelTabs.first(); |
236 | while (m_channelTabs.current() != 0) { | 243 | while (m_channelTabs.current() != 0) { |
237 | m_mainWindow->killTab(m_channelTabs.current()); | 244 | m_mainWindow->killTab(m_channelTabs.current(), true); |
238 | } | 245 | } |
239 | m_queryTabs.first(); | 246 | m_queryTabs.first(); |
240 | while (m_queryTabs.current() != 0) { | 247 | while (m_queryTabs.current() != 0) { |
241 | m_mainWindow->killTab(m_queryTabs.current()); | 248 | m_mainWindow->killTab(m_queryTabs.current(), true); |
242 | } | 249 | } |
243 | m_mainWindow->killTab(this); | 250 | m_mainWindow->killTab(this); |
244 | } | 251 | } |
245 | } | 252 | } |
246 | 253 | ||
247 | IRCChannelTab *IRCServerTab::getTabForChannel(IRCChannel *channel) { | 254 | IRCChannelTab *IRCServerTab::getTabForChannel(IRCChannel *channel) { |
248 | QListIterator<IRCChannelTab> it(m_channelTabs); | 255 | QListIterator<IRCChannelTab> it(m_channelTabs); |
249 | 256 | ||
@@ -267,21 +274,21 @@ IRCQueryTab *IRCServerTab::getTabForQuery(IRCPerson *person) { | |||
267 | void IRCServerTab::display(IRCOutput output) { | 274 | void IRCServerTab::display(IRCOutput output) { |
268 | 275 | ||
269 | /* All messages to be displayed inside the GUI get here */ | 276 | /* All messages to be displayed inside the GUI get here */ |
270 | switch (output.type()) { | 277 | switch (output.type()) { |
271 | case OUTPUT_CONNCLOSE: | 278 | case OUTPUT_CONNCLOSE: |
272 | if (m_close) { | 279 | if (m_close) { |
273 | m_channelTabs.first(); | 280 | m_channelTabs.first(); |
274 | while (m_channelTabs.current() != 0) { | 281 | while (m_channelTabs.current() != 0) { |
275 | m_mainWindow->killTab(m_channelTabs.current()); | 282 | m_mainWindow->killTab(m_channelTabs.current(), true); |
276 | } | 283 | } |
277 | m_queryTabs.first(); | 284 | m_queryTabs.first(); |
278 | while (m_queryTabs.current() != 0) { | 285 | while (m_queryTabs.current() != 0) { |
279 | m_mainWindow->killTab(m_queryTabs.current()); | 286 | m_mainWindow->killTab(m_queryTabs.current(), true); |
280 | } | 287 | } |
281 | m_mainWindow->killTab(this); | 288 | m_mainWindow->killTab(this); |
282 | } else { | 289 | } else { |
283 | appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() +"</font><br>"); | 290 | appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() +"</font><br>"); |
284 | QListIterator<IRCChannelTab> it(m_channelTabs); | 291 | QListIterator<IRCChannelTab> it(m_channelTabs); |
285 | for (; it.current(); ++it) { | 292 | for (; it.current(); ++it) { |
286 | it.current()->appendText("<font color=\"" + m_serverColor + "\">" + output.htmlMessage() +"</font><br>"); | 293 | it.current()->appendText("<font color=\"" + m_serverColor + "\">" + output.htmlMessage() +"</font><br>"); |
287 | } | 294 | } |
@@ -307,24 +314,24 @@ void IRCServerTab::display(IRCOutput output) { | |||
307 | m_mainWindow->addTab(queryTab); | 314 | m_mainWindow->addTab(queryTab); |
308 | } | 315 | } |
309 | queryTab->display(output); | 316 | queryTab->display(output); |
310 | } | 317 | } |
311 | break; | 318 | break; |
312 | case OUTPUT_SELFPART: { | 319 | case OUTPUT_SELFPART: { |
313 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); | 320 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); |
314 | if (channelTab) | 321 | if (channelTab) |
315 | m_mainWindow->killTab(channelTab); | 322 | m_mainWindow->killTab(channelTab, true); |
316 | } | 323 | } |
317 | break; | 324 | break; |
318 | case OUTPUT_SELFKICK: { | 325 | case OUTPUT_SELFKICK: { |
319 | appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() + "</font><br>"); | 326 | appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() + "</font><br>"); |
320 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); | 327 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); |
321 | if (channelTab) | 328 | if (channelTab) |
322 | m_mainWindow->killTab(channelTab); | 329 | m_mainWindow->killTab(channelTab, true); |
323 | } | 330 | } |
324 | break; | 331 | break; |
325 | case OUTPUT_CHANACTION: { | 332 | case OUTPUT_CHANACTION: { |
326 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); | 333 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); |
327 | channelTab->appendText("<font color=\"" + m_otherColor + "\">"+output.htmlMessage()+"</font><br>"); | 334 | channelTab->appendText("<font color=\"" + m_otherColor + "\">"+output.htmlMessage()+"</font><br>"); |
328 | } | 335 | } |
329 | break; | 336 | break; |
330 | case OUTPUT_TOPIC: { | 337 | case OUTPUT_TOPIC: { |