Diffstat (limited to 'noncore/net/opieirc/ircservertab.cpp') (more/less context) (ignore 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 @@ -12,4 +12,5 @@ IRCServerTab::IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *pa m_textview->setHScrollBarMode(QScrollView::AlwaysOff); m_textview->setVScrollBarMode(QScrollView::AlwaysOn); + m_textview->setTextFormat(RichText); m_layout->add(m_textview); m_field = new QLineEdit(this); @@ -34,4 +35,8 @@ void IRCServerTab::removeChannelTab(IRCChannelTab *tab) { } +void IRCServerTab::removeQueryTab(IRCQueryTab *tab) { + m_queryTabs.remove(tab); +} + QString IRCServerTab::title() { return "Server"; @@ -61,14 +66,28 @@ void IRCServerTab::executeCommand(IRCTab *tab, QString line) { } } 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>"); @@ -101,4 +120,8 @@ void IRCServerTab::remove() { m_mainWindow->killTab(m_channelTabs.current()); } + m_queryTabs.first(); + while (m_queryTabs.current() != 0) { + m_mainWindow->killTab(m_queryTabs.current()); + } m_mainWindow->killTab(this); } @@ -115,4 +138,14 @@ IRCChannelTab *IRCServerTab::getTabForChannel(IRCChannel *channel) { } +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) { @@ -125,4 +158,8 @@ void IRCServerTab::display(IRCOutput output) { 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 { @@ -142,5 +179,16 @@ void IRCServerTab::display(IRCOutput output) { 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; |