author | skyhusker <skyhusker> | 2005-06-09 17:37:13 (UTC) |
---|---|---|
committer | skyhusker <skyhusker> | 2005-06-09 17:37:13 (UTC) |
commit | 5173a392a1422add3e3ae2a38d6bd4eb5df3cf87 (patch) (unidiff) | |
tree | ce9d8b66e60e6028b7524b8e3ac8f45d6afa2332 | |
parent | 2ed64fcf5a3c93ce613e63461cb925568c7df887 (diff) | |
download | opie-5173a392a1422add3e3ae2a38d6bd4eb5df3cf87.zip opie-5173a392a1422add3e3ae2a38d6bd4eb5df3cf87.tar.gz opie-5173a392a1422add3e3ae2a38d6bd4eb5df3cf87.tar.bz2 |
Fix cosmetic error displaying channels starting with '&'
-rw-r--r-- | noncore/net/opieirc/ircchanneltab.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/noncore/net/opieirc/ircchanneltab.cpp b/noncore/net/opieirc/ircchanneltab.cpp index 707e17f..881ded7 100644 --- a/noncore/net/opieirc/ircchanneltab.cpp +++ b/noncore/net/opieirc/ircchanneltab.cpp | |||
@@ -1,220 +1,223 @@ | |||
1 | #include <opie2/oresource.h> | 1 | #include <opie2/oresource.h> |
2 | #include <qwhatsthis.h> | 2 | #include <qwhatsthis.h> |
3 | #include <qhbox.h> | 3 | #include <qhbox.h> |
4 | #include <qdict.h> | 4 | #include <qdict.h> |
5 | 5 | ||
6 | #include "ircchanneltab.h" | 6 | #include "ircchanneltab.h" |
7 | #include "ircservertab.h" | 7 | #include "ircservertab.h" |
8 | #include "ircmessageparser.h" | 8 | #include "ircmessageparser.h" |
9 | 9 | ||
10 | #include <opie2/odebug.h> | 10 | #include <opie2/odebug.h> |
11 | QDict<QString> IRCChannelTab::m_queuedMessages (17); | 11 | QDict<QString> IRCChannelTab::m_queuedMessages (17); |
12 | 12 | ||
13 | IRCChannelTab::IRCChannelTab(IRCChannel *channel, IRCServerTab *parentTab, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) { | 13 | IRCChannelTab::IRCChannelTab(IRCChannel *channel, IRCServerTab *parentTab, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) { |
14 | m_mainWindow = mainWindow; | 14 | m_mainWindow = mainWindow; |
15 | m_parentTab = parentTab; | 15 | m_parentTab = parentTab; |
16 | m_channel = channel; | 16 | m_channel = channel; |
17 | m_description->setText(tr("Talking on channel") + " <b>" + channel->channelname() + "</b>"); | 17 | m_description->setText(tr("Talking on channel") + " <b>" + channel->channelname() + "</b>"); |
18 | QHBox *hbox = new QHBox(this); | 18 | QHBox *hbox = new QHBox(this); |
19 | m_textview = new QTextView(hbox); | 19 | m_textview = new QTextView(hbox); |
20 | m_textview->setHScrollBarMode(QScrollView::AlwaysOff); | 20 | m_textview->setHScrollBarMode(QScrollView::AlwaysOff); |
21 | m_textview->setVScrollBarMode(QScrollView::AlwaysOn); | 21 | m_textview->setVScrollBarMode(QScrollView::AlwaysOn); |
22 | m_listVisible = TRUE; | 22 | m_listVisible = TRUE; |
23 | m_listButton = new QPushButton(">", m_textview); | 23 | m_listButton = new QPushButton(">", m_textview); |
24 | m_listButton->setFlat( true ); | 24 | m_listButton->setFlat( true ); |
25 | m_textview->setCornerWidget(m_listButton); | 25 | m_textview->setCornerWidget(m_listButton); |
26 | m_textview->setTextFormat(RichText); | 26 | m_textview->setTextFormat(RichText); |
27 | QWhatsThis::add(m_textview, tr("Channel discussion")); | 27 | QWhatsThis::add(m_textview, tr("Channel discussion")); |
28 | connect(m_listButton, SIGNAL(clicked()), this, SLOT(toggleList())); | 28 | connect(m_listButton, SIGNAL(clicked()), this, SLOT(toggleList())); |
29 | m_list = new IRCChannelList(m_channel, hbox); | 29 | m_list = new IRCChannelList(m_channel, hbox); |
30 | m_list->update(); | 30 | m_list->update(); |
31 | m_list->setMaximumWidth(LISTWIDTH); | 31 | m_list->setMaximumWidth(LISTWIDTH); |
32 | m_field = new IRCHistoryLineEdit(this); | 32 | m_field = new IRCHistoryLineEdit(this); |
33 | connect(m_field, SIGNAL(nextTab()), this, SIGNAL(nextTab())); | 33 | connect(m_field, SIGNAL(nextTab()), this, SIGNAL(nextTab())); |
34 | connect(m_field, SIGNAL(prevTab()), this, SIGNAL(prevTab())); | 34 | connect(m_field, SIGNAL(prevTab()), this, SIGNAL(prevTab())); |
35 | connect(m_field, SIGNAL(closeTab()), this, SLOT(remove())); | 35 | connect(m_field, SIGNAL(closeTab()), this, SLOT(remove())); |
36 | connect(this, SIGNAL(editFocus()), m_field, SLOT(setEditFocus())); | 36 | connect(this, SIGNAL(editFocus()), m_field, SLOT(setEditFocus())); |
37 | 37 | ||
38 | QWhatsThis::add(m_field, tr("Type your message here to participate in the channel discussion")); | 38 | QWhatsThis::add(m_field, tr("Type your message here to participate in the channel discussion")); |
39 | m_popup = new QPopupMenu(m_list); | 39 | m_popup = new QPopupMenu(m_list); |
40 | m_lines = 0; | 40 | m_lines = 0; |
41 | /* Required so that embedded-style "right" clicks work */ | 41 | /* Required so that embedded-style "right" clicks work */ |
42 | QPEApplication::setStylusOperation(m_list->viewport(), QPEApplication::RightOnHold); | 42 | QPEApplication::setStylusOperation(m_list->viewport(), QPEApplication::RightOnHold); |
43 | connect(m_list, SIGNAL(mouseButtonPressed(int,QListBoxItem*,const QPoint&)), this, SLOT(mouseButtonPressed(int,QListBoxItem*,const QPoint&))); | 43 | connect(m_list, SIGNAL(mouseButtonPressed(int,QListBoxItem*,const QPoint&)), this, SLOT(mouseButtonPressed(int,QListBoxItem*,const QPoint&))); |
44 | /* Construct the popup menu */ | 44 | /* Construct the popup menu */ |
45 | //QPopupMenu *ctcpMenu = new QPopupMenu(m_list); | 45 | //QPopupMenu *ctcpMenu = new QPopupMenu(m_list); |
46 | m_popup->insertItem(Opie::Core::OResource::loadPixmap("opieirc/query",Opie::Core::OResource::SmallIcon), | 46 | m_popup->insertItem(Opie::Core::OResource::loadPixmap("opieirc/query",Opie::Core::OResource::SmallIcon), |
47 | tr("Query"), this, SLOT(popupQuery())); | 47 | tr("Query"), this, SLOT(popupQuery())); |
48 | m_popup->insertSeparator(); | 48 | m_popup->insertSeparator(); |
49 | m_popup->insertItem(Opie::Core::OResource::loadPixmap("opieirc/ping",Opie::Core::OResource::SmallIcon), | 49 | m_popup->insertItem(Opie::Core::OResource::loadPixmap("opieirc/ping",Opie::Core::OResource::SmallIcon), |
50 | tr("Ping"), this, SLOT(popupPing())); | 50 | tr("Ping"), this, SLOT(popupPing())); |
51 | m_popup->insertItem(Opie::Core::OResource::loadPixmap("opieirc/version",Opie::Core::OResource::SmallIcon), | 51 | m_popup->insertItem(Opie::Core::OResource::loadPixmap("opieirc/version",Opie::Core::OResource::SmallIcon), |
52 | tr("Version"), this, SLOT(popupVersion())); | 52 | tr("Version"), this, SLOT(popupVersion())); |
53 | m_popup->insertItem(Opie::Core::OResource::loadPixmap("opieirc/whois",Opie::Core::OResource::SmallIcon), | 53 | m_popup->insertItem(Opie::Core::OResource::loadPixmap("opieirc/whois",Opie::Core::OResource::SmallIcon), |
54 | tr("Whois"), this, SLOT(popupWhois())); | 54 | tr("Whois"), this, SLOT(popupWhois())); |
55 | //m_popup->insertItem(ctcpMenu, "CTCP"); | 55 | //m_popup->insertItem(ctcpMenu, "CTCP"); |
56 | connect(m_mainWindow, SIGNAL(updateScroll()), this, SLOT(scrolling())); | 56 | connect(m_mainWindow, SIGNAL(updateScroll()), this, SLOT(scrolling())); |
57 | m_layout->add(hbox); | 57 | m_layout->add(hbox); |
58 | hbox->show(); | 58 | hbox->show(); |
59 | m_layout->add(m_field); | 59 | m_layout->add(m_field); |
60 | m_field->setFocus(); | 60 | m_field->setFocus(); |
61 | m_field->setActiveWindow(); | 61 | m_field->setActiveWindow(); |
62 | 62 | ||
63 | connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); | 63 | connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); |
64 | connect(m_list, SIGNAL(doubleClicked ( QListBoxItem * ) ), this, SLOT(popupQuery( QListBoxItem * ) )); | 64 | connect(m_list, SIGNAL(doubleClicked ( QListBoxItem * ) ), this, SLOT(popupQuery( QListBoxItem * ) )); |
65 | settingsChanged(); | 65 | settingsChanged(); |
66 | 66 | ||
67 | if(m_queuedMessages[m_channel->channelname()]) { | 67 | if(m_queuedMessages[m_channel->channelname()]) { |
68 | appendText(*m_queuedMessages[m_channel->channelname()]); | 68 | appendText(*m_queuedMessages[m_channel->channelname()]); |
69 | delete m_queuedMessages[m_channel->channelname()]; | 69 | delete m_queuedMessages[m_channel->channelname()]; |
70 | m_queuedMessages.remove(m_channel->channelname()); | 70 | m_queuedMessages.remove(m_channel->channelname()); |
71 | } | 71 | } |
72 | } | 72 | } |
73 | 73 | ||
74 | void IRCChannelTab::scrolling(){ | 74 | void IRCChannelTab::scrolling(){ |
75 | m_textview->ensureVisible(0, m_textview->contentsHeight()); | 75 | m_textview->ensureVisible(0, m_textview->contentsHeight()); |
76 | } | 76 | } |
77 | 77 | ||
78 | void IRCChannelTab::appendText(QString text) { | 78 | void IRCChannelTab::appendText(QString text) { |
79 | /* not using append because it creates layout problems */ | 79 | /* not using append because it creates layout problems */ |
80 | QString txt = m_textview->text() + IRCTab::appendTimestamp( text ); | 80 | QString txt = m_textview->text() + IRCTab::appendTimestamp( text ); |
81 | if (m_maxLines > 0 && m_lines >= m_maxLines) { | 81 | if (m_maxLines > 0 && m_lines >= m_maxLines) { |
82 | int firstBreak = txt.find('\n'); | 82 | int firstBreak = txt.find('\n'); |
83 | if (firstBreak != -1) { | 83 | if (firstBreak != -1) { |
84 | txt = "<qt bgcolor=\"" + m_backgroundColor + "\"/>" + txt.right(txt.length() - (firstBreak + 1)); | 84 | txt = "<qt bgcolor=\"" + m_backgroundColor + "\"/>" + txt.right(txt.length() - (firstBreak + 1)); |
85 | } | 85 | } |
86 | } else { | 86 | } else { |
87 | m_lines++; | 87 | m_lines++; |
88 | } | 88 | } |
89 | m_textview->ensureVisible(0, m_textview->contentsHeight()); | 89 | m_textview->ensureVisible(0, m_textview->contentsHeight()); |
90 | m_textview->setText(txt); | 90 | m_textview->setText(txt); |
91 | m_textview->ensureVisible(0, m_textview->contentsHeight()); | 91 | m_textview->ensureVisible(0, m_textview->contentsHeight()); |
92 | 92 | ||
93 | int p1, p2; | 93 | int p1, p2; |
94 | if ( text.contains( IRCMessageParser::tr("Received a CTCP PING from ") ) ) | 94 | if ( text.contains( IRCMessageParser::tr("Received a CTCP PING from ") ) ) |
95 | emit ping( title() ); | 95 | emit ping( title() ); |
96 | else if ( (p1 = text.find("ping", 0, false) )!= -1 && (p2 = text.find( m_parentTab->server()->nick(), 0,false )) != -1 ) { | 96 | else if ( (p1 = text.find("ping", 0, false) )!= -1 && (p2 = text.find( m_parentTab->server()->nick(), 0,false )) != -1 ) { |
97 | int col = text.findRev("color", -1, false); | 97 | int col = text.findRev("color", -1, false); |
98 | if ( col < p2 ) | 98 | if ( col < p2 ) |
99 | emit ping( title() ); | 99 | emit ping( title() ); |
100 | 100 | ||
101 | } | 101 | } |
102 | 102 | ||
103 | emit changed(this); | 103 | emit changed(this); |
104 | } | 104 | } |
105 | 105 | ||
106 | IRCChannelTab::~IRCChannelTab() { | 106 | IRCChannelTab::~IRCChannelTab() { |
107 | m_parentTab->removeChannelTab(this); | 107 | m_parentTab->removeChannelTab(this); |
108 | } | 108 | } |
109 | 109 | ||
110 | void IRCChannelTab::processCommand() { | 110 | void IRCChannelTab::processCommand() { |
111 | QString text = m_field->text(); | 111 | QString text = m_field->text(); |
112 | if (text.length()>0) { | 112 | if (text.length()>0) { |
113 | if (session()->isSessionActive()) { | 113 | if (session()->isSessionActive()) { |
114 | if (text.startsWith("/") && !text.startsWith("//")) { | 114 | if (text.startsWith("/") && !text.startsWith("//")) { |
115 | /* Command mode */ | 115 | /* Command mode */ |
116 | m_parentTab->executeCommand(this, text);; | 116 | m_parentTab->executeCommand(this, text);; |
117 | } else { | 117 | } else { |
118 | if (text.startsWith("//")) | 118 | if (text.startsWith("//")) |
119 | text = text.right(text.length()-1); | 119 | text = text.right(text.length()-1); |
120 | session()->sendMessage(m_channel, m_field->text()); | 120 | session()->sendMessage(m_channel, m_field->text()); |
121 | appendText("<font color=\"" + m_textColor + "\"><</font><font color=\"" + m_selfColor + "\">"+m_parentTab->server()->nick()+"</font><font color=\"" + m_textColor + "\">> "+IRCOutput::toHTML(m_field->text())+"</font><br>"); | 121 | appendText("<font color=\"" + m_textColor + "\"><</font><font color=\"" + m_selfColor + "\">"+m_parentTab->server()->nick()+"</font><font color=\"" + m_textColor + "\">> "+IRCOutput::toHTML(m_field->text())+"</font><br>"); |
122 | } | 122 | } |
123 | } else { | 123 | } else { |
124 | appendText("<font color=\"" + m_errorColor + "\">"+tr("Disconnected")+"</font><br>"); | 124 | appendText("<font color=\"" + m_errorColor + "\">"+tr("Disconnected")+"</font><br>"); |
125 | } | 125 | } |
126 | } | 126 | } |
127 | m_field->clear(); | 127 | m_field->clear(); |
128 | } | 128 | } |
129 | 129 | ||
130 | void IRCChannelTab::settingsChanged() { | 130 | void IRCChannelTab::settingsChanged() { |
131 | m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>"); | 131 | m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>"); |
132 | m_lines = 0; | 132 | m_lines = 0; |
133 | } | 133 | } |
134 | 134 | ||
135 | void IRCChannelTab::toggleList() { | 135 | void IRCChannelTab::toggleList() { |
136 | if (m_listVisible) { | 136 | if (m_listVisible) { |
137 | m_list->setMaximumWidth(0); | 137 | m_list->setMaximumWidth(0); |
138 | m_listButton->setText("<"); | 138 | m_listButton->setText("<"); |
139 | } else { | 139 | } else { |
140 | m_list->setMaximumWidth(LISTWIDTH); | 140 | m_list->setMaximumWidth(LISTWIDTH); |
141 | m_listButton->setText(">"); | 141 | m_listButton->setText(">"); |
142 | } | 142 | } |
143 | m_listVisible = !m_listVisible; | 143 | m_listVisible = !m_listVisible; |
144 | } | 144 | } |
145 | 145 | ||
146 | void IRCChannelTab::mouseButtonPressed(int mouse, QListBoxItem *, const QPoint &point) { | 146 | void IRCChannelTab::mouseButtonPressed(int mouse, QListBoxItem *, const QPoint &point) { |
147 | switch (mouse) { | 147 | switch (mouse) { |
148 | case 1: | 148 | case 1: |
149 | break; | 149 | break; |
150 | case 2: | 150 | case 2: |
151 | m_popup->popup(point); | 151 | m_popup->popup(point); |
152 | break; | 152 | break; |
153 | }; | 153 | }; |
154 | } | 154 | } |
155 | 155 | ||
156 | void IRCChannelTab::popupQuery( QListBoxItem *item) { | 156 | void IRCChannelTab::popupQuery( QListBoxItem *item) { |
157 | if (item) { | 157 | if (item) { |
158 | IRCPerson *person = session()->getPerson(item->text()); | 158 | IRCPerson *person = session()->getPerson(item->text()); |
159 | if (person) { | 159 | if (person) { |
160 | IRCQueryTab *tab = m_parentTab->getTabForQuery(person); | 160 | IRCQueryTab *tab = m_parentTab->getTabForQuery(person); |
161 | if (!tab) { | 161 | if (!tab) { |
162 | tab = new IRCQueryTab(person, m_parentTab, m_mainWindow, (QWidget *)parent()); | 162 | tab = new IRCQueryTab(person, m_parentTab, m_mainWindow, (QWidget *)parent()); |
163 | m_parentTab->addQueryTab(tab); | 163 | m_parentTab->addQueryTab(tab); |
164 | m_mainWindow->addTab(tab); | 164 | m_mainWindow->addTab(tab); |
165 | } | 165 | } |
166 | } | 166 | } |
167 | } | 167 | } |
168 | } | 168 | } |
169 | 169 | ||
170 | void IRCChannelTab::popupQuery() { | 170 | void IRCChannelTab::popupQuery() { |
171 | if ( m_list->currentItem() != -1 ) | 171 | if ( m_list->currentItem() != -1 ) |
172 | popupQuery( m_list->item(m_list->currentItem())); | 172 | popupQuery( m_list->item(m_list->currentItem())); |
173 | } | 173 | } |
174 | 174 | ||
175 | void IRCChannelTab::popupPing() { | 175 | void IRCChannelTab::popupPing() { |
176 | if(m_list->currentItem() != -1) | 176 | if(m_list->currentItem() != -1) |
177 | m_parentTab->session()->sendCTCPPing(m_list->text(m_list->currentItem())); | 177 | m_parentTab->session()->sendCTCPPing(m_list->text(m_list->currentItem())); |
178 | } | 178 | } |
179 | 179 | ||
180 | void IRCChannelTab::popupVersion() { | 180 | void IRCChannelTab::popupVersion() { |
181 | if(m_list->currentItem() != -1) | 181 | if(m_list->currentItem() != -1) |
182 | m_parentTab->session()->sendCTCPRequest(m_list->text(m_list->currentItem()), "VERSION", ""); | 182 | m_parentTab->session()->sendCTCPRequest(m_list->text(m_list->currentItem()), "VERSION", ""); |
183 | } | 183 | } |
184 | 184 | ||
185 | void IRCChannelTab::popupWhois() { | 185 | void IRCChannelTab::popupWhois() { |
186 | if(m_list->currentItem() != -1) | 186 | if(m_list->currentItem() != -1) |
187 | m_parentTab->session()->whois(m_list->text(m_list->currentItem())); | 187 | m_parentTab->session()->whois(m_list->text(m_list->currentItem())); |
188 | } | 188 | } |
189 | 189 | ||
190 | QString IRCChannelTab::title() { | 190 | QString IRCChannelTab::title() { |
191 | return m_channel->channelname(); | 191 | if(!m_channel->channelname().startsWith("&")) |
192 | return m_channel->channelname(); | ||
193 | |||
194 | return "&" + m_channel->channelname(); | ||
192 | } | 195 | } |
193 | 196 | ||
194 | IRCSession *IRCChannelTab::session() { | 197 | IRCSession *IRCChannelTab::session() { |
195 | return m_parentTab->session(); | 198 | return m_parentTab->session(); |
196 | } | 199 | } |
197 | 200 | ||
198 | void IRCChannelTab::remove() { | 201 | void IRCChannelTab::remove() { |
199 | if (session()->isSessionActive()) { | 202 | if (session()->isSessionActive()) { |
200 | session()->part(m_channel); | 203 | session()->part(m_channel); |
201 | } else { | 204 | } else { |
202 | m_mainWindow->killTab(this); | 205 | m_mainWindow->killTab(this); |
203 | } | 206 | } |
204 | } | 207 | } |
205 | 208 | ||
206 | void IRCChannelTab::enqueue(const QString &channel, const QString &message) { | 209 | void IRCChannelTab::enqueue(const QString &channel, const QString &message) { |
207 | if (m_queuedMessages.count() == (m_queuedMessages.size() - 1) ) | 210 | if (m_queuedMessages.count() == (m_queuedMessages.size() - 1) ) |
208 | /* 17 messages max */ | 211 | /* 17 messages max */ |
209 | return; | 212 | return; |
210 | m_queuedMessages.insert(channel, new QString(message)); | 213 | m_queuedMessages.insert(channel, new QString(message)); |
211 | } | 214 | } |
212 | 215 | ||
213 | IRCChannel *IRCChannelTab::channel() { | 216 | IRCChannel *IRCChannelTab::channel() { |
214 | return m_channel; | 217 | return m_channel; |
215 | } | 218 | } |
216 | 219 | ||
217 | IRCChannelList *IRCChannelTab::list() { | 220 | IRCChannelList *IRCChannelTab::list() { |
218 | return m_list; | 221 | return m_list; |
219 | } | 222 | } |
220 | 223 | ||