author | wazlaf <wazlaf> | 2002-09-21 23:59:08 (UTC) |
---|---|---|
committer | wazlaf <wazlaf> | 2002-09-21 23:59:08 (UTC) |
commit | d60625b5551f26cdc35f7b2497ab538de859537d (patch) (unidiff) | |
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 | |||
@@ -11,6 +11,7 @@ IRCServerTab::IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *pa | |||
11 | m_textview = new QTextView(this); | 11 | m_textview = new QTextView(this); |
12 | m_textview->setHScrollBarMode(QScrollView::AlwaysOff); | 12 | m_textview->setHScrollBarMode(QScrollView::AlwaysOff); |
13 | m_textview->setVScrollBarMode(QScrollView::AlwaysOn); | 13 | m_textview->setVScrollBarMode(QScrollView::AlwaysOn); |
14 | m_textview->setTextFormat(RichText); | ||
14 | m_layout->add(m_textview); | 15 | m_layout->add(m_textview); |
15 | m_field = new QLineEdit(this); | 16 | m_field = new QLineEdit(this); |
16 | m_layout->add(m_field); | 17 | m_layout->add(m_field); |
@@ -33,6 +34,10 @@ void IRCServerTab::removeChannelTab(IRCChannelTab *tab) { | |||
33 | m_channelTabs.remove(tab); | 34 | m_channelTabs.remove(tab); |
34 | } | 35 | } |
35 | 36 | ||
37 | void IRCServerTab::removeQueryTab(IRCQueryTab *tab) { | ||
38 | m_queryTabs.remove(tab); | ||
39 | } | ||
40 | |||
36 | QString IRCServerTab::title() { | 41 | QString IRCServerTab::title() { |
37 | return "Server"; | 42 | return "Server"; |
38 | } | 43 | } |
@@ -60,16 +65,30 @@ void IRCServerTab::executeCommand(IRCTab *tab, QString line) { | |||
60 | tab->appendText("<font color=\"#ff0000\">Unknown channel format!</font><br>"); | 65 | tab->appendText("<font color=\"#ff0000\">Unknown channel format!</font><br>"); |
61 | } | 66 | } |
62 | } else if (command == "ME") { | 67 | } else if (command == "ME") { |
63 | QString text = IRCOutput::toHTML(line.right(line.length()-4)); | 68 | QString text = line.right(line.length()-4); |
64 | if (text.length() > 0) { | 69 | if (text.length() > 0) { |
65 | if (tab->isA("IRCChannelTab")) { | 70 | if (tab->isA("IRCChannelTab")) { |
66 | tab->appendText("<font color=\"#cc0000\">*" + m_server.nick() + " " + text + "</font><br>"); | 71 | tab->appendText("<font color=\"#cc0000\">*" + IRCOutput::toHTML(m_server.nick()) + " " + IRCOutput::toHTML(text) + "</font><br>"); |
67 | m_session->sendAction(((IRCChannelTab *)tab)->channel(), text); | 72 | m_session->sendAction(((IRCChannelTab *)tab)->channel(), text); |
68 | } else if (tab->isA("IRCQueryTab")) { | 73 | } else if (tab->isA("IRCQueryTab")) { |
74 | tab->appendText("<font color=\"#cc0000\">*" + IRCOutput::toHTML(m_server.nick()) + " " + IRCOutput::toHTML(text) + "</font><br>"); | ||
75 | m_session->sendAction(((IRCQueryTab *)tab)->person(), text); | ||
69 | } else { | 76 | } else { |
70 | tab->appendText("<font color=\"#ff0000\">Invalid tab for this command</font><br>"); | 77 | tab->appendText("<font color=\"#ff0000\">Invalid tab for this command</font><br>"); |
71 | } | 78 | } |
72 | } | 79 | } |
80 | } else if (command == "MSG") { | ||
81 | QString nickname; | ||
82 | stream >> nickname; | ||
83 | if (nickname.length() > 0) { | ||
84 | if (line.length() > 6 + nickname.length()) { | ||
85 | QString text = line.right(line.length()-nickname.length()-6); | ||
86 | IRCPerson person; | ||
87 | person.setNick(nickname); | ||
88 | tab->appendText("><font color=\"#0000dd\">"+IRCOutput::toHTML(nickname)+"</font>< "+IRCOutput::toHTML(text)+"<br>"); | ||
89 | m_session->sendMessage(&person, text); | ||
90 | } | ||
91 | } | ||
73 | } else { | 92 | } else { |
74 | tab->appendText("<font color=\"#ff0000\">Unknown command</font><br>"); | 93 | tab->appendText("<font color=\"#ff0000\">Unknown command</font><br>"); |
75 | } | 94 | } |
@@ -100,6 +119,10 @@ void IRCServerTab::remove() { | |||
100 | while (m_channelTabs.current() != 0) { | 119 | while (m_channelTabs.current() != 0) { |
101 | m_mainWindow->killTab(m_channelTabs.current()); | 120 | m_mainWindow->killTab(m_channelTabs.current()); |
102 | } | 121 | } |
122 | m_queryTabs.first(); | ||
123 | while (m_queryTabs.current() != 0) { | ||
124 | m_mainWindow->killTab(m_queryTabs.current()); | ||
125 | } | ||
103 | m_mainWindow->killTab(this); | 126 | m_mainWindow->killTab(this); |
104 | } | 127 | } |
105 | } | 128 | } |
@@ -114,6 +137,16 @@ IRCChannelTab *IRCServerTab::getTabForChannel(IRCChannel *channel) { | |||
114 | return 0; | 137 | return 0; |
115 | } | 138 | } |
116 | 139 | ||
140 | IRCQueryTab *IRCServerTab::getTabForQuery(IRCPerson *person) { | ||
141 | QListIterator<IRCQueryTab> it(m_queryTabs); | ||
142 | |||
143 | for (; it.current(); ++it) { | ||
144 | if (it.current()->person()->nick() == person->nick()) | ||
145 | return it.current(); | ||
146 | } | ||
147 | return 0; | ||
148 | } | ||
149 | |||
117 | void IRCServerTab::display(IRCOutput output) { | 150 | void IRCServerTab::display(IRCOutput output) { |
118 | 151 | ||
119 | /* All messages to be displayed inside the GUI get here */ | 152 | /* All messages to be displayed inside the GUI get here */ |
@@ -124,6 +157,10 @@ void IRCServerTab::display(IRCOutput output) { | |||
124 | while (m_channelTabs.current() != 0) { | 157 | while (m_channelTabs.current() != 0) { |
125 | m_mainWindow->killTab(m_channelTabs.current()); | 158 | m_mainWindow->killTab(m_channelTabs.current()); |
126 | } | 159 | } |
160 | m_queryTabs.first(); | ||
161 | while (m_queryTabs.current() != 0) { | ||
162 | m_mainWindow->killTab(m_queryTabs.current()); | ||
163 | } | ||
127 | m_mainWindow->killTab(this); | 164 | m_mainWindow->killTab(this); |
128 | } else { | 165 | } else { |
129 | appendText("<font color=\"#0000dd\">" + output.htmlMessage() +"</font><br>"); | 166 | appendText("<font color=\"#0000dd\">" + output.htmlMessage() +"</font><br>"); |
@@ -141,7 +178,18 @@ void IRCServerTab::display(IRCOutput output) { | |||
141 | break; | 178 | break; |
142 | case OUTPUT_CHANPRIVMSG: { | 179 | case OUTPUT_CHANPRIVMSG: { |
143 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); | 180 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); |
144 | channelTab->appendText("<<font color=\"#0000dd\">"+((IRCChannelPerson *)output.getParam(1))->person->nick()+"</font>> "+output.htmlMessage()+"<br>"); | 181 | channelTab->appendText("<<font color=\"#0000dd\">"+IRCOutput::toHTML(((IRCChannelPerson *)output.getParam(1))->person->nick())+"</font>> "+output.htmlMessage()+"<br>"); |
182 | } | ||
183 | break; | ||
184 | case OUTPUT_QUERYACTION: | ||
185 | case OUTPUT_QUERYPRIVMSG: { | ||
186 | IRCQueryTab *queryTab = getTabForQuery((IRCPerson *)output.getParam(0)); | ||
187 | if (!queryTab) { | ||
188 | queryTab = new IRCQueryTab((IRCPerson *)output.getParam(0), this, m_mainWindow, (QWidget *)parent()); | ||
189 | m_queryTabs.append(queryTab); | ||
190 | m_mainWindow->addTab(queryTab); | ||
191 | } | ||
192 | queryTab->display(output); | ||
145 | } | 193 | } |
146 | break; | 194 | break; |
147 | case OUTPUT_SELFPART: { | 195 | case OUTPUT_SELFPART: { |