summaryrefslogtreecommitdiff
path: root/noncore
Unidiff
Diffstat (limited to 'noncore') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opieirc/ircchanneltab.cpp18
-rw-r--r--noncore/net/opieirc/ircmessageparser.cpp24
-rw-r--r--noncore/net/opieirc/ircmisc.cpp19
-rw-r--r--noncore/net/opieirc/ircmisc.h8
-rw-r--r--noncore/net/opieirc/ircquerytab.cpp9
-rw-r--r--noncore/net/opieirc/ircservertab.cpp15
-rw-r--r--noncore/net/opieirc/ircservertab.h2
-rw-r--r--noncore/net/opieirc/irctab.cpp7
-rw-r--r--noncore/net/opieirc/irctab.h10
-rw-r--r--noncore/net/opieirc/mainwindow.cpp37
-rw-r--r--noncore/net/opieirc/mainwindow.h7
11 files changed, 138 insertions, 18 deletions
diff --git a/noncore/net/opieirc/ircchanneltab.cpp b/noncore/net/opieirc/ircchanneltab.cpp
index 667e977..b6e3954 100644
--- a/noncore/net/opieirc/ircchanneltab.cpp
+++ b/noncore/net/opieirc/ircchanneltab.cpp
@@ -20,12 +20,17 @@ IRCChannelTab::IRCChannelTab(IRCChannel *channel, IRCServerTab *parentTab, MainW
20 QWhatsThis::add(m_textview, tr("Channel discussion")); 20 QWhatsThis::add(m_textview, tr("Channel discussion"));
21 connect(m_listButton, SIGNAL(clicked()), this, SLOT(toggleList())); 21 connect(m_listButton, SIGNAL(clicked()), this, SLOT(toggleList()));
22 m_list = new IRCChannelList(m_channel, hbox); 22 m_list = new IRCChannelList(m_channel, hbox);
23 m_list->update(); 23 m_list->update();
24 m_list->setMaximumWidth(LISTWIDTH); 24 m_list->setMaximumWidth(LISTWIDTH);
25 m_field = new IRCHistoryLineEdit(this); 25 m_field = new IRCHistoryLineEdit(this);
26 connect(m_field, SIGNAL(nextTab()), this, SIGNAL(nextTab()));
27 connect(m_field, SIGNAL(prevTab()), this, SIGNAL(prevTab()));
28 connect(m_field, SIGNAL(closeTab()), this, SIGNAL(closeTab()));
29 connect(this, SIGNAL(editFocus()), m_field, SLOT(setEditFocus()));
30
26 QWhatsThis::add(m_field, tr("Type your message here to participate in the channel discussion")); 31 QWhatsThis::add(m_field, tr("Type your message here to participate in the channel discussion"));
27 m_popup = new QPopupMenu(m_list); 32 m_popup = new QPopupMenu(m_list);
28 m_lines = 0; 33 m_lines = 0;
29 /* Required so that embedded-style "right" clicks work */ 34 /* Required so that embedded-style "right" clicks work */
30 QPEApplication::setStylusOperation(m_list->viewport(), QPEApplication::RightOnHold); 35 QPEApplication::setStylusOperation(m_list->viewport(), QPEApplication::RightOnHold);
31 connect(m_list, SIGNAL(mouseButtonPressed(int,QListBoxItem*,const QPoint&)), this, SLOT(mouseButtonPressed(int,QListBoxItem*,const QPoint&))); 36 connect(m_list, SIGNAL(mouseButtonPressed(int,QListBoxItem*,const QPoint&)), this, SLOT(mouseButtonPressed(int,QListBoxItem*,const QPoint&)));
@@ -38,12 +43,14 @@ IRCChannelTab::IRCChannelTab(IRCChannel *channel, IRCServerTab *parentTab, MainW
38 ctcpMenu->insertItem(Resource::loadPixmap("opieirc/whois"), tr("Whois"), this, SLOT(popupWhois())); 43 ctcpMenu->insertItem(Resource::loadPixmap("opieirc/whois"), tr("Whois"), this, SLOT(popupWhois()));
39 connect(m_mainWindow, SIGNAL(updateScroll()), this, SLOT(scrolling())); 44 connect(m_mainWindow, SIGNAL(updateScroll()), this, SLOT(scrolling()));
40 m_layout->add(hbox); 45 m_layout->add(hbox);
41 hbox->show(); 46 hbox->show();
42 m_layout->add(m_field); 47 m_layout->add(m_field);
43 m_field->setFocus(); 48 m_field->setFocus();
49 m_field->setActiveWindow();
50
44 connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); 51 connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand()));
45 settingsChanged(); 52 settingsChanged();
46} 53}
47 54
48void IRCChannelTab::scrolling(){ 55void IRCChannelTab::scrolling(){
49 m_textview->ensureVisible(0, m_textview->contentsHeight()); 56 m_textview->ensureVisible(0, m_textview->contentsHeight());
@@ -60,12 +67,21 @@ void IRCChannelTab::appendText(QString text) {
60 } else { 67 } else {
61 m_lines++; 68 m_lines++;
62 } 69 }
63 m_textview->ensureVisible(0, m_textview->contentsHeight()); 70 m_textview->ensureVisible(0, m_textview->contentsHeight());
64 m_textview->setText(txt); 71 m_textview->setText(txt);
65 m_textview->ensureVisible(0, m_textview->contentsHeight()); 72 m_textview->ensureVisible(0, m_textview->contentsHeight());
73
74 int p1, p2;
75 if ( (p1 = text.find("ping", 0, false) )!= -1 && (p2 = text.find( m_parentTab->server()->nick(), 0,false )) != -1 ) {
76 int col = text.findRev("color", -1, false);
77 if ( col < p2 )
78 emit ping( title() );
79
80 }
81
66 emit changed(this); 82 emit changed(this);
67} 83}
68 84
69IRCChannelTab::~IRCChannelTab() { 85IRCChannelTab::~IRCChannelTab() {
70 m_parentTab->removeChannelTab(this); 86 m_parentTab->removeChannelTab(this);
71} 87}
@@ -119,13 +135,13 @@ void IRCChannelTab::mouseButtonPressed(int mouse, QListBoxItem *, const QPoint &
119void IRCChannelTab::popupQuery() { 135void IRCChannelTab::popupQuery() {
120 if (m_list->currentItem() != -1) { 136 if (m_list->currentItem() != -1) {
121 IRCPerson *person = session()->getPerson(m_list->item(m_list->currentItem())->text()); 137 IRCPerson *person = session()->getPerson(m_list->item(m_list->currentItem())->text());
122 if (person) { 138 if (person) {
123 IRCQueryTab *tab = m_parentTab->getTabForQuery(person); 139 IRCQueryTab *tab = m_parentTab->getTabForQuery(person);
124 if (!tab) { 140 if (!tab) {
125 tab = new IRCQueryTab(person, m_parentTab, m_mainWindow, (QWidget *)parent()); 141 tab = new IRCQueryTab(person, m_parentTab, m_mainWindow, (QWidget *)parent());
126 m_parentTab->addQueryTab(tab); 142 m_parentTab->addQueryTab(tab);
127 m_mainWindow->addTab(tab); 143 m_mainWindow->addTab(tab);
128 } 144 }
129 } 145 }
130 } 146 }
131} 147}
diff --git a/noncore/net/opieirc/ircmessageparser.cpp b/noncore/net/opieirc/ircmessageparser.cpp
index 400ff41..90280d7 100644
--- a/noncore/net/opieirc/ircmessageparser.cpp
+++ b/noncore/net/opieirc/ircmessageparser.cpp
@@ -1,12 +1,12 @@
1#include <qtextstream.h> 1#include <qtextstream.h>
2#include "ircmessageparser.h" 2#include "ircmessageparser.h"
3#include "ircversion.h" 3#include "ircversion.h"
4 4
5/* Lookup table for literal commands */ 5/* Lookup table for literal commands */
6IRCLiteralMessageParserStruct IRCMessageParser::literalParserProcTable[] = { 6IRCLiteralMessageParserStruct IRCMessageParser::literalParserProcTable[] = {
7 { "PING", FUNC(parseLiteralPing) }, 7 { "PING", FUNC(parseLiteralPing) },
8 { "NOTICE", FUNC(parseLiteralNotice) }, 8 { "NOTICE", FUNC(parseLiteralNotice) },
9 { "JOIN", FUNC(parseLiteralJoin) }, 9 { "JOIN", FUNC(parseLiteralJoin) },
10 { "PRIVMSG", FUNC(parseLiteralPrivMsg) }, 10 { "PRIVMSG", FUNC(parseLiteralPrivMsg) },
11 { "NICK", FUNC(parseLiteralNick) }, 11 { "NICK", FUNC(parseLiteralNick) },
12 { "PART", FUNC(parseLiteralPart) }, 12 { "PART", FUNC(parseLiteralPart) },
@@ -17,21 +17,21 @@ IRCLiteralMessageParserStruct IRCMessageParser::literalParserProcTable[] = {
17 { "KICK", FUNC(parseLiteralKick) }, 17 { "KICK", FUNC(parseLiteralKick) },
18 { "TOPIC", FUNC(parseLiteralTopic) }, 18 { "TOPIC", FUNC(parseLiteralTopic) },
19 { 0 , 0 } 19 { 0 , 0 }
20}; 20};
21 21
22/* Lookup table for literal commands */ 22/* Lookup table for literal commands */
23IRCCTCPMessageParserStruct IRCMessageParser::ctcpParserProcTable[] = { 23IRCCTCPMessageParserStruct IRCMessageParser::ctcpParserProcTable[] = {
24 { "PING", FUNC(parseCTCPPing) }, 24 { "PING", FUNC(parseCTCPPing) },
25 { "VERSION", FUNC(parseCTCPVersion) }, 25 { "VERSION", FUNC(parseCTCPVersion) },
26 { "ACTION", FUNC(parseCTCPAction) }, 26 { "ACTION", FUNC(parseCTCPAction) },
27 { 0 , 0 } 27 { 0 , 0 }
28}; 28};
29 29
30/* Lookup table for numerical commands */ 30/* Lookup table for numerical commands */
31IRCNumericalMessageParserStruct IRCMessageParser::numericalParserProcTable[] = { 31IRCNumericalMessageParserStruct IRCMessageParser::numericalParserProcTable[] = {
32 { 1, FUNC(parseNumerical001) }, // RPL_WELCOME 32 { 1, FUNC(parseNumerical001) }, // RPL_WELCOME
33 { 2, FUNC(parseNumerical002) }, // RPL_YOURHOST 33 { 2, FUNC(parseNumerical002) }, // RPL_YOURHOST
34 { 3, FUNC(parseNumerical003) }, // RPL_CREATED 34 { 3, FUNC(parseNumerical003) }, // RPL_CREATED
35 { 4, FUNC(parseNumerical004) }, // RPL_MYINFO 35 { 4, FUNC(parseNumerical004) }, // RPL_MYINFO
36 { 5, FUNC(parseNumerical005) }, // RPL_BOUNCE, RPL_PROTOCTL 36 { 5, FUNC(parseNumerical005) }, // RPL_BOUNCE, RPL_PROTOCTL
37 { 251, FUNC(parseNumericalStats) }, // RPL_LUSERCLIENT 37 { 251, FUNC(parseNumericalStats) }, // RPL_LUSERCLIENT
@@ -168,13 +168,13 @@ void IRCMessageParser::parseLiteralPart(IRCMessage *message) {
168 } else { 168 } else {
169 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel for part not found - desynchronized?"))); 169 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel for part not found - desynchronized?")));
170 } 170 }
171} 171}
172 172
173void IRCMessageParser::parseLiteralPrivMsg(IRCMessage *message) { 173void IRCMessageParser::parseLiteralPrivMsg(IRCMessage *message) {
174 if (m_session->m_server->nick() == message->param(0)) { 174 if (m_session->m_server->nick().lower() == message->param(0).lower() ) {
175 /* IRC Query message detected, verify sender and display it */ 175 /* IRC Query message detected, verify sender and display it */
176 IRCPerson mask(message->prefix()); 176 IRCPerson mask(message->prefix());
177 IRCPerson *person = m_session->getPerson(mask.nick()); 177 IRCPerson *person = m_session->getPerson(mask.nick());
178 if (!person) { 178 if (!person) {
179 /* Person not yet known, create and add to the current session */ 179 /* Person not yet known, create and add to the current session */
180 person = new IRCPerson(message->prefix()); 180 person = new IRCPerson(message->prefix());
@@ -203,13 +203,13 @@ void IRCMessageParser::parseLiteralPrivMsg(IRCMessage *message) {
203 } else { 203 } else {
204 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received PRIVMSG of unknown type"))); 204 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received PRIVMSG of unknown type")));
205 } 205 }
206} 206}
207 207
208void IRCMessageParser::parseLiteralNick(IRCMessage *message) { 208void IRCMessageParser::parseLiteralNick(IRCMessage *message) {
209 209
210 IRCPerson mask(message->prefix()); 210 IRCPerson mask(message->prefix());
211 /* this way of handling nick changes really sucks */ 211 /* this way of handling nick changes really sucks */
212 if (mask.nick() == m_session->m_server->nick()) { 212 if (mask.nick() == m_session->m_server->nick()) {
213 /* We are changing our nickname */ 213 /* We are changing our nickname */
214 m_session->m_server->setNick(message->param(0)); 214 m_session->m_server->setNick(message->param(0));
215 IRCOutput output(OUTPUT_NICKCHANGE, tr("You are now known as %1").arg( message->param(0))); 215 IRCOutput output(OUTPUT_NICKCHANGE, tr("You are now known as %1").arg( message->param(0)));
@@ -217,13 +217,13 @@ void IRCMessageParser::parseLiteralNick(IRCMessage *message) {
217 emit outputReady(output); 217 emit outputReady(output);
218 } else { 218 } else {
219 /* Someone else is */ 219 /* Someone else is */
220 IRCPerson *person = m_session->getPerson(mask.nick()); 220 IRCPerson *person = m_session->getPerson(mask.nick());
221 if (person) { 221 if (person) {
222 //IRCOutput output(OUTPUT_NICKCHANGE, tr("%1 is now known as %2").arg( mask.nick() ).arg( message->param(0))); 222 //IRCOutput output(OUTPUT_NICKCHANGE, tr("%1 is now known as %2").arg( mask.nick() ).arg( message->param(0)));
223 223
224 /* new code starts here -- this removes the person from all channels */ 224 /* new code starts here -- this removes the person from all channels */
225 QList<IRCChannel> channels; 225 QList<IRCChannel> channels;
226 m_session->getChannelsByPerson(person, channels); 226 m_session->getChannelsByPerson(person, channels);
227 QListIterator<IRCChannel> it(channels); 227 QListIterator<IRCChannel> it(channels);
228 for (;it.current(); ++it) { 228 for (;it.current(); ++it) {
229 IRCChannelPerson *chanperson = it.current()->getPerson(mask.nick()); 229 IRCChannelPerson *chanperson = it.current()->getPerson(mask.nick());
@@ -231,13 +231,13 @@ void IRCMessageParser::parseLiteralNick(IRCMessage *message) {
231 chanperson->person->setNick(message->param(0)); 231 chanperson->person->setNick(message->param(0));
232 it.current()->addPerson(chanperson); 232 it.current()->addPerson(chanperson);
233 IRCOutput output(OUTPUT_NICKCHANGE, tr("%1 is now known as %2").arg( mask.nick() ).arg( message->param(0))); 233 IRCOutput output(OUTPUT_NICKCHANGE, tr("%1 is now known as %2").arg( mask.nick() ).arg( message->param(0)));
234 output.addParam(person); 234 output.addParam(person);
235 emit outputReady(output); 235 emit outputReady(output);
236 } 236 }
237 /* new code ends here */ 237 /* new code ends here */
238 } else { 238 } else {
239 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nickname change of an unknown person"))); 239 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nickname change of an unknown person")));
240 } 240 }
241 } 241 }
242} 242}
243 243
@@ -245,13 +245,13 @@ void IRCMessageParser::parseLiteralQuit(IRCMessage *message) {
245 IRCPerson mask(message->prefix()); 245 IRCPerson mask(message->prefix());
246 IRCPerson *person = m_session->getPerson(mask.nick()); 246 IRCPerson *person = m_session->getPerson(mask.nick());
247 if (person) { 247 if (person) {
248 QList<IRCChannel> channels; 248 QList<IRCChannel> channels;
249 m_session->getChannelsByPerson(person, channels); 249 m_session->getChannelsByPerson(person, channels);
250 QListIterator<IRCChannel> it(channels); 250 QListIterator<IRCChannel> it(channels);
251 for (;it.current(); ++it) { 251 for (;it.current(); ++it) {
252 IRCChannelPerson *chanperson = it.current()->getPerson(mask.nick()); 252 IRCChannelPerson *chanperson = it.current()->getPerson(mask.nick());
253 it.current()->removePerson(chanperson); 253 it.current()->removePerson(chanperson);
254 delete chanperson; 254 delete chanperson;
255 } 255 }
256 m_session->removePerson(person); 256 m_session->removePerson(person);
257 IRCOutput output(OUTPUT_QUIT, tr("%1 has quit (%2)" ).arg( mask.nick() ).arg( message->param(0) )); 257 IRCOutput output(OUTPUT_QUIT, tr("%1 has quit (%2)" ).arg( mask.nick() ).arg( message->param(0) ));
@@ -322,13 +322,13 @@ void IRCMessageParser::parseCTCPAction(IRCMessage *message) {
322 emit outputReady(output); 322 emit outputReady(output);
323 } else { 323 } else {
324 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with bad recipient"))); 324 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with bad recipient")));
325 } 325 }
326 } 326 }
327} 327}
328 328
329void IRCMessageParser::parseLiteralMode(IRCMessage *message) { 329void IRCMessageParser::parseLiteralMode(IRCMessage *message) {
330 IRCPerson mask(message->prefix()); 330 IRCPerson mask(message->prefix());
331 331
332 if (message->param(0).startsWith("#")) { 332 if (message->param(0).startsWith("#")) {
333 IRCChannel *channel = m_session->getChannel(message->param(0).lower()); 333 IRCChannel *channel = m_session->getChannel(message->param(0).lower());
334 if (channel) { 334 if (channel) {
@@ -458,30 +458,30 @@ void IRCMessageParser::parseNumericalNames(IRCMessage *message) {
458 QString people = message->param(3); 458 QString people = message->param(3);
459 QTextIStream stream(&people); 459 QTextIStream stream(&people);
460 QString temp; 460 QString temp;
461 461
462 while (!stream.atEnd()) { 462 while (!stream.atEnd()) {
463 stream >> temp; 463 stream >> temp;
464 464
465 char flagch = temp.at(0).latin1(); 465 char flagch = temp.at(0).latin1();
466 int flag = 0; 466 int flag = 0;
467 QString nick; 467 QString nick;
468 /* Parse person flags */ 468 /* Parse person flags */
469 if (flagch == '@' || flagch == '+' || flagch=='%' || flagch == '*') { 469 if (flagch == '@' || flagch == '+' || flagch=='%' || flagch == '*') {
470 470
471 nick = temp.right(temp.length()-1); 471 nick = temp.right(temp.length()-1);
472 switch (flagch) { 472 switch (flagch) {
473 case '@': flag = PERSON_FLAG_OP; break; 473 case '@': flag = PERSON_FLAG_OP; break;
474 case '+': flag = PERSON_FLAG_VOICE; break; 474 case '+': flag = PERSON_FLAG_VOICE; break;
475 case '%': flag = PERSON_FLAG_HALFOP; break; 475 case '%': flag = PERSON_FLAG_HALFOP; break;
476 default : flag = 0; break; 476 default : flag = 0; break;
477 } 477 }
478 } else { 478 } else {
479 nick = temp; 479 nick = temp;
480 } 480 }
481 481
482 IRCChannelPerson *chan_person = new IRCChannelPerson(); 482 IRCChannelPerson *chan_person = new IRCChannelPerson();
483 IRCPerson *person = m_session->getPerson(nick); 483 IRCPerson *person = m_session->getPerson(nick);
484 if (person == 0) { 484 if (person == 0) {
485 person = new IRCPerson(); 485 person = new IRCPerson();
486 person->setNick(nick); 486 person->setNick(nick);
487 m_session->addPerson(person); 487 m_session->addPerson(person);
diff --git a/noncore/net/opieirc/ircmisc.cpp b/noncore/net/opieirc/ircmisc.cpp
index 6d93a34..df6f874 100644
--- a/noncore/net/opieirc/ircmisc.cpp
+++ b/noncore/net/opieirc/ircmisc.cpp
@@ -63,24 +63,37 @@ void IRCHistoryLineEdit::keyPressEvent(QKeyEvent *event) {
63 m_index = -1; 63 m_index = -1;
64 setText(""); 64 setText("");
65 } 65 }
66 } else if (key == Key_Return) { 66 } else if (key == Key_Return) {
67 m_history.prepend(text()); 67 m_history.prepend(text());
68 m_index = -1; 68 m_index = -1;
69 } else if (key == Key_Tab) { 69 } else if (key == Key_N && event->state() == Qt::ControlButton) {
70 odebug << "got tab" << oendl; 70 emit nextTab();
71 return;
72 } else if ( ( key == Key_Y || key == Key_Z ) && event->state() == Qt::ControlButton) {
73 emit closeTab();
74 return;
75 } else if (key == Key_P && event->state() == Qt::ControlButton) {
76 emit prevTab();
71 return; 77 return;
72 } 78 }
79
73 QLineEdit::keyPressEvent(event); 80 QLineEdit::keyPressEvent(event);
74} 81}
75 82
76bool IRCHistoryLineEdit::eventFilter(QObject *object, QEvent *event) { 83bool IRCHistoryLineEdit::eventFilter(QObject *object, QEvent *event) {
77 if (event->type() == QEvent::KeyPress) { 84 if (event->type() == QEvent::KeyPress) {
78 QKeyEvent *k = (QKeyEvent *) event; 85 QKeyEvent *k = (QKeyEvent *) event;
79 /* Catch tab characters */ 86 /* Catch tab characters */
80 if (k->key() == Key_Tab) { 87 if (k->key() == Key_Tab) {
81 odebug << "tab!" << oendl; 88 emit nextTab();
82 return TRUE; 89 return TRUE;
83 } 90 }
84 } 91 }
85 return QLineEdit::eventFilter(object, event); 92 return QLineEdit::eventFilter(object, event);
86} 93}
94
95
96void IRCHistoryLineEdit::setEditFocus() {
97 setActiveWindow();
98 setFocus();
99}
diff --git a/noncore/net/opieirc/ircmisc.h b/noncore/net/opieirc/ircmisc.h
index b4a5b06..c42dcbd 100644
--- a/noncore/net/opieirc/ircmisc.h
+++ b/noncore/net/opieirc/ircmisc.h
@@ -58,12 +58,20 @@ protected:
58 58
59class IRCHistoryLineEdit : public QLineEdit { 59class IRCHistoryLineEdit : public QLineEdit {
60 Q_OBJECT 60 Q_OBJECT
61public: 61public:
62 IRCHistoryLineEdit(QWidget *parent = 0, const char *name = 0); 62 IRCHistoryLineEdit(QWidget *parent = 0, const char *name = 0);
63 virtual bool eventFilter(QObject *object, QEvent *event); 63 virtual bool eventFilter(QObject *object, QEvent *event);
64public slots:
65 void setEditFocus();
66signals:
67 void nextTab();
68 void prevTab();
69 void closeTab();
70
71
64protected: 72protected:
65 void keyPressEvent(QKeyEvent *); 73 void keyPressEvent(QKeyEvent *);
66protected: 74protected:
67 QStringList m_history; 75 QStringList m_history;
68 int m_index; 76 int m_index;
69}; 77};
diff --git a/noncore/net/opieirc/ircquerytab.cpp b/noncore/net/opieirc/ircquerytab.cpp
index a113b04..1fddc6d 100644
--- a/noncore/net/opieirc/ircquerytab.cpp
+++ b/noncore/net/opieirc/ircquerytab.cpp
@@ -13,12 +13,17 @@ IRCQueryTab::IRCQueryTab(IRCPerson *person, IRCServerTab *parentTab, MainWindow
13 m_textview = new QTextView(hbox); 13 m_textview = new QTextView(hbox);
14 m_textview->setHScrollBarMode(QScrollView::AlwaysOff); 14 m_textview->setHScrollBarMode(QScrollView::AlwaysOff);
15 m_textview->setVScrollBarMode(QScrollView::AlwaysOn); 15 m_textview->setVScrollBarMode(QScrollView::AlwaysOn);
16 m_textview->setTextFormat(RichText); 16 m_textview->setTextFormat(RichText);
17 QWhatsThis::add(m_textview, tr("Private discussion")); 17 QWhatsThis::add(m_textview, tr("Private discussion"));
18 m_field = new IRCHistoryLineEdit(this); 18 m_field = new IRCHistoryLineEdit(this);
19 connect(m_field, SIGNAL(nextTab()), this, SIGNAL(nextTab()));
20 connect(m_field, SIGNAL(prevTab()), this, SIGNAL(prevTab()));
21 connect(m_field, SIGNAL(closeTab()),this, SIGNAL(closeTab()));
22
23
19 QWhatsThis::add(m_field, tr("Type your text here in order to send a message to the other person")); 24 QWhatsThis::add(m_field, tr("Type your text here in order to send a message to the other person"));
20 m_layout->add(hbox); 25 m_layout->add(hbox);
21 hbox->show(); 26 hbox->show();
22 m_layout->add(m_field); 27 m_layout->add(m_field);
23 m_field->setFocus(); 28 m_field->setFocus();
24 connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); 29 connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand()));
@@ -41,12 +46,16 @@ void IRCQueryTab::appendText(QString text) {
41 } 46 }
42 } else { 47 } else {
43 m_lines++; 48 m_lines++;
44 } 49 }
45 m_textview->setText(txt); 50 m_textview->setText(txt);
46 m_textview->ensureVisible(0, m_textview->contentsHeight()); 51 m_textview->ensureVisible(0, m_textview->contentsHeight());
52
53 if ( IRCServerTab::containsPing( text, m_parentTab ) )
54 emit ping( title() );
55
47 emit changed(this); 56 emit changed(this);
48} 57}
49 58
50IRCQueryTab::~IRCQueryTab() { 59IRCQueryTab::~IRCQueryTab() {
51 m_parentTab->removeQueryTab(this); 60 m_parentTab->removeQueryTab(this);
52 delete m_person; 61 delete m_person;
diff --git a/noncore/net/opieirc/ircservertab.cpp b/noncore/net/opieirc/ircservertab.cpp
index d1aab40..2a34c0b 100644
--- a/noncore/net/opieirc/ircservertab.cpp
+++ b/noncore/net/opieirc/ircservertab.cpp
@@ -1,10 +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
6bool IRCServerTab::containsPing( const QString& text, IRCServerTab* tab ) {
7 return (text.find("ping") != -1 && text.find( tab->server()->nick() != -1));
8}
9
10
5IRCServerTab::IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) { 11IRCServerTab::IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) {
6 m_server = server; 12 m_server = server;
7 m_session = new IRCSession(&m_server); 13 m_session = new IRCSession(&m_server);
8 m_mainWindow = mainWindow; 14 m_mainWindow = mainWindow;
9 m_close = FALSE; 15 m_close = FALSE;
10 m_lines = 0; 16 m_lines = 0;
@@ -13,12 +19,17 @@ IRCServerTab::IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *pa
13 m_textview->setHScrollBarMode(QScrollView::AlwaysOff); 19 m_textview->setHScrollBarMode(QScrollView::AlwaysOff);
14 m_textview->setVScrollBarMode(QScrollView::AlwaysOn); 20 m_textview->setVScrollBarMode(QScrollView::AlwaysOn);
15 m_textview->setTextFormat(RichText); 21 m_textview->setTextFormat(RichText);
16 QWhatsThis::add(m_textview, tr("Server messages")); 22 QWhatsThis::add(m_textview, tr("Server messages"));
17 m_layout->add(m_textview); 23 m_layout->add(m_textview);
18 m_field = new IRCHistoryLineEdit(this); 24 m_field = new IRCHistoryLineEdit(this);
25 connect(m_field, SIGNAL(nextTab()), this, SIGNAL(nextTab()));
26 connect(m_field, SIGNAL(prevTab()), this, SIGNAL(prevTab()));
27 connect(m_field, SIGNAL(closeTab()), this, SIGNAL(closeTab()));
28 connect(this, SIGNAL(editFocus()), m_field, SLOT(setEditFocus()));
29
19 QWhatsThis::add(m_field, tr("Type commands here. A list of available commands can be found inside the OpieIRC help")); 30 QWhatsThis::add(m_field, tr("Type commands here. A list of available commands can be found inside the OpieIRC help"));
20 m_layout->add(m_field); 31 m_layout->add(m_field);
21 connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); 32 connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand()));
22 m_field->setFocus(); 33 m_field->setFocus();
23 connect(m_session, SIGNAL(outputReady(IRCOutput)), this, SLOT(display(IRCOutput))); 34 connect(m_session, SIGNAL(outputReady(IRCOutput)), this, SLOT(display(IRCOutput)));
24 connect(m_mainWindow, SIGNAL(updateScroll()), this, SLOT(scrolling())); 35 connect(m_mainWindow, SIGNAL(updateScroll()), this, SLOT(scrolling()));
@@ -118,20 +129,20 @@ void IRCServerTab::executeCommand(IRCTab *tab, QString line) {
118 } 129 }
119 } 130 }
120 131
121 else if (command == "OP"){ 132 else if (command == "OP"){
122 QString nickname; 133 QString nickname;
123 stream >> nickname; 134 stream >> nickname;
124 if (nickname.length() > 0) { 135 if (nickname.length() > 0) {
125 QString text = line.right(line.length()-nickname.length()-5); 136 QString text = line.right(line.length()-nickname.length()-5);
126 IRCPerson person; 137 IRCPerson person;
127 person.setNick(nickname); 138 person.setNick(nickname);
128 m_session->op(((IRCChannelTab *)tab)->channel(), &person); 139 m_session->op(((IRCChannelTab *)tab)->channel(), &person);
129 } 140 }
130 } 141 }
131 142
132 //SEND MODES 143 //SEND MODES
133 else if (command == "MODE"){ 144 else if (command == "MODE"){
134 QString text = line.right(line.length()-6); 145 QString text = line.right(line.length()-6);
135 if (text.length() > 0) { 146 if (text.length() > 0) {
136 m_session->mode(text); 147 m_session->mode(text);
137 } else { 148 } else {
diff --git a/noncore/net/opieirc/ircservertab.h b/noncore/net/opieirc/ircservertab.h
index 48200d7..69543fc 100644
--- a/noncore/net/opieirc/ircservertab.h
+++ b/noncore/net/opieirc/ircservertab.h
@@ -30,12 +30,14 @@
30#include "ircmisc.h" 30#include "ircmisc.h"
31 31
32 32
33class IRCServerTab : public IRCTab { 33class IRCServerTab : public IRCTab {
34 Q_OBJECT 34 Q_OBJECT
35public: 35public:
36 static bool containsPing(const QString& text, IRCServerTab *tab);
37
36 /* IRCTab implementation */ 38 /* IRCTab implementation */
37 IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *parent = 0, const char *name = 0, WFlags f = 0); 39 IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *parent = 0, const char *name = 0, WFlags f = 0);
38 ~IRCServerTab(); 40 ~IRCServerTab();
39 QString title(); 41 QString title();
40 IRCSession *session(); 42 IRCSession *session();
41 IRCServer *server(); 43 IRCServer *server();
diff --git a/noncore/net/opieirc/irctab.cpp b/noncore/net/opieirc/irctab.cpp
index 3351c3b..8e1dc16 100644
--- a/noncore/net/opieirc/irctab.cpp
+++ b/noncore/net/opieirc/irctab.cpp
@@ -1,10 +1,11 @@
1#include <qpe/resource.h> 1#include <qpe/resource.h>
2#include <qpushbutton.h> 2#include <qpushbutton.h>
3#include <qwhatsthis.h> 3#include <qwhatsthis.h>
4#include "irctab.h" 4#include "irctab.h"
5#include "mainwindow.h"
5 6
6QString IRCTab::m_errorColor; 7QString IRCTab::m_errorColor;
7QString IRCTab::m_serverColor; 8QString IRCTab::m_serverColor;
8QString IRCTab::m_textColor; 9QString IRCTab::m_textColor;
9QString IRCTab::m_backgroundColor; 10QString IRCTab::m_backgroundColor;
10QString IRCTab::m_selfColor; 11QString IRCTab::m_selfColor;
@@ -33,6 +34,12 @@ void IRCTab::setID(int id) {
33 m_id = id; 34 m_id = id;
34} 35}
35 36
36int IRCTab::id() { 37int IRCTab::id() {
37 return m_id; 38 return m_id;
38} 39}
40
41void IRCTab::showEvent( QShowEvent *ev ) {
42 topLevelWidget()->setCaption( MainWindow::appCaption() + " " + title() );
43 QWidget::showEvent( ev );
44 emit editFocus();
45}
diff --git a/noncore/net/opieirc/irctab.h b/noncore/net/opieirc/irctab.h
index 7a2d0a2..6c29ea5 100644
--- a/noncore/net/opieirc/irctab.h
+++ b/noncore/net/opieirc/irctab.h
@@ -40,15 +40,25 @@ public:
40 int id(); 40 int id();
41 virtual QString title() = 0; 41 virtual QString title() = 0;
42 virtual IRCSession *session() = 0; 42 virtual IRCSession *session() = 0;
43 virtual void appendText(QString text) = 0; 43 virtual void appendText(QString text) = 0;
44signals: 44signals:
45 void changed(IRCTab *); 45 void changed(IRCTab *);
46 void ping(const QString& );
47 void nextTab();
48 void prevTab();
49 void closeTab();
50 void editFocus();
51
46public slots: 52public slots:
47 virtual void remove() = 0; 53 virtual void remove() = 0;
48 virtual void settingsChanged() = 0; 54 virtual void settingsChanged() = 0;
55
56protected:
57 void showEvent( QShowEvent* );
58
49protected: 59protected:
50 QLabel *m_description; 60 QLabel *m_description;
51 QVBoxLayout *m_layout; 61 QVBoxLayout *m_layout;
52 int m_id; 62 int m_id;
53public: 63public:
54 /* Configuration shared accross all instances - contains HTML style colors (#rrggbb) */ 64 /* Configuration shared accross all instances - contains HTML style colors (#rrggbb) */
diff --git a/noncore/net/opieirc/mainwindow.cpp b/noncore/net/opieirc/mainwindow.cpp
index 0923a11..1143213 100644
--- a/noncore/net/opieirc/mainwindow.cpp
+++ b/noncore/net/opieirc/mainwindow.cpp
@@ -4,12 +4,17 @@
4 4
5#include "mainwindow.h" 5#include "mainwindow.h"
6#include "ircservertab.h" 6#include "ircservertab.h"
7#include "ircserverlist.h" 7#include "ircserverlist.h"
8#include "ircsettings.h" 8#include "ircsettings.h"
9 9
10QString MainWindow::appCaption() {
11 return QObject::tr("Opie IRC");
12}
13
14
10MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) { 15MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) {
11 setCaption(tr("IRC Client")); 16 setCaption(tr("IRC Client"));
12 m_tabWidget = new IRCTabWidget(this); 17 m_tabWidget = new IRCTabWidget(this);
13 QWhatsThis::add(m_tabWidget, tr("Server connections, channels, queries and other things will be placed here")); 18 QWhatsThis::add(m_tabWidget, tr("Server connections, channels, queries and other things will be placed here"));
14 connect(m_tabWidget, SIGNAL(currentChanged(QWidget*)), this, SLOT(selected(QWidget*))); 19 connect(m_tabWidget, SIGNAL(currentChanged(QWidget*)), this, SLOT(selected(QWidget*)));
15 setCentralWidget(m_tabWidget); 20 setCentralWidget(m_tabWidget);
@@ -49,12 +54,17 @@ void MainWindow::selected(QWidget *) {
49 m_tabWidget->setTabColor(m_tabWidget->currentPageIndex(), black); 54 m_tabWidget->setTabColor(m_tabWidget->currentPageIndex(), black);
50 emit updateScroll(); 55 emit updateScroll();
51} 56}
52 57
53void MainWindow::addTab(IRCTab *tab) { 58void MainWindow::addTab(IRCTab *tab) {
54 connect(tab, SIGNAL(changed(IRCTab*)), this, SLOT(changeEvent(IRCTab*))); 59 connect(tab, SIGNAL(changed(IRCTab*)), this, SLOT(changeEvent(IRCTab*)));
60 connect(tab, SIGNAL(ping (const QString&)), this, SLOT(slotPing(const QString&)));
61 connect(tab, SIGNAL(nextTab()), this, SLOT(slotNextTab()));
62 connect(tab, SIGNAL(prevTab()), this, SLOT(slotPrevTab()));
63 connect(tab, SIGNAL(closeTab()), this, SLOT(slotCloseTab()));
64
55 m_tabWidget->addTab(tab, tab->title()); 65 m_tabWidget->addTab(tab, tab->title());
56 m_tabWidget->showPage(tab); 66 m_tabWidget->showPage(tab);
57 tab->setID(m_tabWidget->currentPageIndex()); 67 tab->setID(m_tabWidget->currentPageIndex());
58 m_tabs.append(tab); 68 m_tabs.append(tab);
59} 69}
60 70
@@ -86,6 +96,33 @@ void MainWindow::settings() {
86 for (; it.current(); ++it) { 96 for (; it.current(); ++it) {
87 /* Inform all tabs about the new settings */ 97 /* Inform all tabs about the new settings */
88 it.current()->settingsChanged(); 98 it.current()->settingsChanged();
89 } 99 }
90 } 100 }
91} 101}
102
103
104void MainWindow::slotNextTab() {
105 int i = m_tabWidget->currentPageIndex ();
106 m_tabWidget->setCurrentPage ( i+1 );
107
108 int j = m_tabWidget->currentPageIndex ();
109 if ( i == j )
110 m_tabWidget->setCurrentPage ( 1 );
111}
112
113void MainWindow::slotPrevTab() {
114 int i = m_tabWidget->currentPageIndex ();
115 if ( i > 1 )
116 m_tabWidget->setCurrentPage ( i-1 );
117}
118
119void MainWindow::slotCloseTab() {
120 IRCTab *tab = (IRCTab *) m_tabWidget->currentPage ();
121 if ( tab )
122 killTab ( tab );
123}
124
125void MainWindow::slotPing( const QString& channel ) {
126 raise();
127}
128
diff --git a/noncore/net/opieirc/mainwindow.h b/noncore/net/opieirc/mainwindow.h
index 0f60855..945fc71 100644
--- a/noncore/net/opieirc/mainwindow.h
+++ b/noncore/net/opieirc/mainwindow.h
@@ -33,19 +33,26 @@ class MainWindow : public QMainWindow {
33public: 33public:
34 MainWindow(QWidget *parent = 0, const char *name = 0, WFlags f = 0); 34 MainWindow(QWidget *parent = 0, const char *name = 0, WFlags f = 0);
35// IRCTabWidget getTabWidget(); 35// IRCTabWidget getTabWidget();
36 void addTab(IRCTab *tab); 36 void addTab(IRCTab *tab);
37 void killTab(IRCTab *tab); 37 void killTab(IRCTab *tab);
38 static QString appName() { return QString::fromLatin1("opieirc"); } 38 static QString appName() { return QString::fromLatin1("opieirc"); }
39 static QString appCaption();
39signals: 40signals:
40 void updateScroll(); 41 void updateScroll();
41protected slots: 42protected slots:
42 void newConnection(); 43 void newConnection();
43 void settings(); 44 void settings();
44 void selected(QWidget *); 45 void selected(QWidget *);
45 void changeEvent(IRCTab *); 46 void changeEvent(IRCTab *);
47
48 void slotNextTab();
49 void slotPrevTab();
50 void slotCloseTab();
51 void slotPing(const QString&);
52
46protected: 53protected:
47 void loadSettings(); 54 void loadSettings();
48protected: 55protected:
49 IRCTabWidget *m_tabWidget; 56 IRCTabWidget *m_tabWidget;
50 QList<IRCTab> m_tabs; 57 QList<IRCTab> m_tabs;
51}; 58};