author | wazlaf <wazlaf> | 2002-09-21 23:59:08 (UTC) |
---|---|---|
committer | wazlaf <wazlaf> | 2002-09-21 23:59:08 (UTC) |
commit | d60625b5551f26cdc35f7b2497ab538de859537d (patch) (side-by-side diff) | |
tree | 998c8d2e1f12a9c7ab9b55fa578f93d1a178ade6 /noncore/net/opieirc/ircservertab.cpp | |
parent | 54238c669808ceccaa6fb0ab0dcbf4565b370196 (diff) | |
download | opie-d60625b5551f26cdc35f7b2497ab538de859537d.zip opie-d60625b5551f26cdc35f7b2497ab538de859537d.tar.gz opie-d60625b5551f26cdc35f7b2497ab538de859537d.tar.bz2 |
query windows and basic commands such as /me, /msg
Diffstat (limited to 'noncore/net/opieirc/ircservertab.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/opieirc/ircservertab.cpp | 54 |
1 files changed, 51 insertions, 3 deletions
diff --git a/noncore/net/opieirc/ircservertab.cpp b/noncore/net/opieirc/ircservertab.cpp index 503a758..8b8771f 100644 --- a/noncore/net/opieirc/ircservertab.cpp +++ b/noncore/net/opieirc/ircservertab.cpp @@ -8,12 +8,13 @@ IRCServerTab::IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *pa m_mainWindow = mainWindow; m_close = FALSE; m_description->setText(tr("Connection to")+" <b>" + server.hostname() + ":" + QString::number(server.port()) + "</b>"); m_textview = new QTextView(this); m_textview->setHScrollBarMode(QScrollView::AlwaysOff); m_textview->setVScrollBarMode(QScrollView::AlwaysOn); + m_textview->setTextFormat(RichText); m_layout->add(m_textview); m_field = new QLineEdit(this); m_layout->add(m_field); connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); m_field->setFocus(); connect(m_session, SIGNAL(outputReady(IRCOutput)), this, SLOT(display(IRCOutput))); @@ -30,12 +31,16 @@ IRCServerTab::~IRCServerTab() { } void IRCServerTab::removeChannelTab(IRCChannelTab *tab) { m_channelTabs.remove(tab); } +void IRCServerTab::removeQueryTab(IRCQueryTab *tab) { + m_queryTabs.remove(tab); +} + QString IRCServerTab::title() { return "Server"; } IRCSession *IRCServerTab::session() { return m_session; @@ -57,22 +62,36 @@ void IRCServerTab::executeCommand(IRCTab *tab, QString line) { if (channel.length() > 0 && channel.startsWith("#")) { m_session->join(channel); } else { tab->appendText("<font color=\"#ff0000\">Unknown channel format!</font><br>"); } } else if (command == "ME") { - QString text = IRCOutput::toHTML(line.right(line.length()-4)); + QString text = line.right(line.length()-4); if (text.length() > 0) { if (tab->isA("IRCChannelTab")) { - tab->appendText("<font color=\"#cc0000\">*" + m_server.nick() + " " + text + "</font><br>"); + tab->appendText("<font color=\"#cc0000\">*" + IRCOutput::toHTML(m_server.nick()) + " " + IRCOutput::toHTML(text) + "</font><br>"); m_session->sendAction(((IRCChannelTab *)tab)->channel(), text); } else if (tab->isA("IRCQueryTab")) { + tab->appendText("<font color=\"#cc0000\">*" + IRCOutput::toHTML(m_server.nick()) + " " + IRCOutput::toHTML(text) + "</font><br>"); + m_session->sendAction(((IRCQueryTab *)tab)->person(), text); } else { tab->appendText("<font color=\"#ff0000\">Invalid tab for this command</font><br>"); } } + } else if (command == "MSG") { + QString nickname; + stream >> nickname; + if (nickname.length() > 0) { + if (line.length() > 6 + nickname.length()) { + QString text = line.right(line.length()-nickname.length()-6); + IRCPerson person; + person.setNick(nickname); + tab->appendText("><font color=\"#0000dd\">"+IRCOutput::toHTML(nickname)+"</font>< "+IRCOutput::toHTML(text)+"<br>"); + m_session->sendMessage(&person, text); + } + } } else { tab->appendText("<font color=\"#ff0000\">Unknown command</font><br>"); } } void IRCServerTab::processCommand() { @@ -97,12 +116,16 @@ void IRCServerTab::remove() { } else { /* Session has previously been closed */ m_channelTabs.first(); while (m_channelTabs.current() != 0) { m_mainWindow->killTab(m_channelTabs.current()); } + m_queryTabs.first(); + while (m_queryTabs.current() != 0) { + m_mainWindow->killTab(m_queryTabs.current()); + } m_mainWindow->killTab(this); } } IRCChannelTab *IRCServerTab::getTabForChannel(IRCChannel *channel) { QListIterator<IRCChannelTab> it(m_channelTabs); @@ -111,22 +134,36 @@ IRCChannelTab *IRCServerTab::getTabForChannel(IRCChannel *channel) { if (it.current()->channel() == channel) return it.current(); } return 0; } +IRCQueryTab *IRCServerTab::getTabForQuery(IRCPerson *person) { + QListIterator<IRCQueryTab> it(m_queryTabs); + + for (; it.current(); ++it) { + if (it.current()->person()->nick() == person->nick()) + return it.current(); + } + return 0; +} + void IRCServerTab::display(IRCOutput output) { /* All messages to be displayed inside the GUI get here */ switch (output.type()) { case OUTPUT_CONNCLOSE: if (m_close) { m_channelTabs.first(); while (m_channelTabs.current() != 0) { m_mainWindow->killTab(m_channelTabs.current()); } + m_queryTabs.first(); + while (m_queryTabs.current() != 0) { + m_mainWindow->killTab(m_queryTabs.current()); + } m_mainWindow->killTab(this); } else { appendText("<font color=\"#0000dd\">" + output.htmlMessage() +"</font><br>"); QListIterator<IRCChannelTab> it(m_channelTabs); for (; it.current(); ++it) { it.current()->appendText("<font color=\"#0000dd\">" + output.htmlMessage() +"</font><br>"); @@ -138,13 +175,24 @@ void IRCServerTab::display(IRCOutput output) { m_channelTabs.append(channeltab); m_mainWindow->addTab(channeltab); } break; case OUTPUT_CHANPRIVMSG: { IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); - channelTab->appendText("<<font color=\"#0000dd\">"+((IRCChannelPerson *)output.getParam(1))->person->nick()+"</font>> "+output.htmlMessage()+"<br>"); + channelTab->appendText("<<font color=\"#0000dd\">"+IRCOutput::toHTML(((IRCChannelPerson *)output.getParam(1))->person->nick())+"</font>> "+output.htmlMessage()+"<br>"); + } + break; + case OUTPUT_QUERYACTION: + case OUTPUT_QUERYPRIVMSG: { + IRCQueryTab *queryTab = getTabForQuery((IRCPerson *)output.getParam(0)); + if (!queryTab) { + queryTab = new IRCQueryTab((IRCPerson *)output.getParam(0), this, m_mainWindow, (QWidget *)parent()); + m_queryTabs.append(queryTab); + m_mainWindow->addTab(queryTab); + } + queryTab->display(output); } break; case OUTPUT_SELFPART: { IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); if (channelTab) m_mainWindow->killTab(channelTab); |