summaryrefslogtreecommitdiff
path: root/noncore/net/opieirc/ircchanneltab.cpp
authoralwin <alwin>2004-03-02 12:21:11 (UTC)
committer alwin <alwin>2004-03-02 12:21:11 (UTC)
commitb6b1c97559c0ed9f2e33632272426bf98f289232 (patch) (unidiff)
treed3a9987704770cdf5eb14e1136f6e3ecb2f36a04 /noncore/net/opieirc/ircchanneltab.cpp
parent0d59c780513da78033f4d9040475dee9db0256d4 (diff)
downloadopie-b6b1c97559c0ed9f2e33632272426bf98f289232.zip
opie-b6b1c97559c0ed9f2e33632272426bf98f289232.tar.gz
opie-b6b1c97559c0ed9f2e33632272426bf98f289232.tar.bz2
applied the patch generated by the optimize_connect script from
TT.
Diffstat (limited to 'noncore/net/opieirc/ircchanneltab.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opieirc/ircchanneltab.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/net/opieirc/ircchanneltab.cpp b/noncore/net/opieirc/ircchanneltab.cpp
index b0771f6..667e977 100644
--- a/noncore/net/opieirc/ircchanneltab.cpp
+++ b/noncore/net/opieirc/ircchanneltab.cpp
@@ -1,127 +1,127 @@
1#include <qpe/resource.h> 1#include <qpe/resource.h>
2#include <qwhatsthis.h> 2#include <qwhatsthis.h>
3#include <qhbox.h> 3#include <qhbox.h>
4#include "ircchanneltab.h" 4#include "ircchanneltab.h"
5#include "ircservertab.h" 5#include "ircservertab.h"
6 6
7IRCChannelTab::IRCChannelTab(IRCChannel *channel, IRCServerTab *parentTab, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) { 7IRCChannelTab::IRCChannelTab(IRCChannel *channel, IRCServerTab *parentTab, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) {
8 m_mainWindow = mainWindow; 8 m_mainWindow = mainWindow;
9 m_parentTab = parentTab; 9 m_parentTab = parentTab;
10 m_channel = channel; 10 m_channel = channel;
11 m_description->setText(tr("Talking on channel") + " <b>" + channel->channelname() + "</b>"); 11 m_description->setText(tr("Talking on channel") + " <b>" + channel->channelname() + "</b>");
12 QHBox *hbox = new QHBox(this); 12 QHBox *hbox = new QHBox(this);
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_listVisible = TRUE; 16 m_listVisible = TRUE;
17 m_listButton = new QPushButton(">", m_textview); 17 m_listButton = new QPushButton(">", m_textview);
18 m_textview->setCornerWidget(m_listButton); 18 m_textview->setCornerWidget(m_listButton);
19 m_textview->setTextFormat(RichText); 19 m_textview->setTextFormat(RichText);
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 QWhatsThis::add(m_field, tr("Type your message here to participate in the channel discussion")); 26 QWhatsThis::add(m_field, tr("Type your message here to participate in the channel discussion"));
27 m_popup = new QPopupMenu(m_list); 27 m_popup = new QPopupMenu(m_list);
28 m_lines = 0; 28 m_lines = 0;
29 /* Required so that embedded-style "right" clicks work */ 29 /* Required so that embedded-style "right" clicks work */
30 QPEApplication::setStylusOperation(m_list->viewport(), QPEApplication::RightOnHold); 30 QPEApplication::setStylusOperation(m_list->viewport(), QPEApplication::RightOnHold);
31 connect(m_list, SIGNAL(mouseButtonPressed(int, QListBoxItem *, const QPoint&)), this, SLOT(mouseButtonPressed(int, QListBoxItem *, const QPoint &))); 31 connect(m_list, SIGNAL(mouseButtonPressed(int,QListBoxItem*,const QPoint&)), this, SLOT(mouseButtonPressed(int,QListBoxItem*,const QPoint&)));
32 /* Construct the popup menu */ 32 /* Construct the popup menu */
33 QPopupMenu *ctcpMenu = new QPopupMenu(m_list); 33 QPopupMenu *ctcpMenu = new QPopupMenu(m_list);
34 m_popup->insertItem(Resource::loadPixmap("opieirc/ctcp"), tr("CTCP"), ctcpMenu); 34 m_popup->insertItem(Resource::loadPixmap("opieirc/ctcp"), tr("CTCP"), ctcpMenu);
35 m_popup->insertItem(Resource::loadPixmap("opieirc/query"), tr("Query"), this, SLOT(popupQuery())); 35 m_popup->insertItem(Resource::loadPixmap("opieirc/query"), tr("Query"), this, SLOT(popupQuery()));
36 ctcpMenu->insertItem(Resource::loadPixmap("opieirc/ping"), tr("Ping"), this, SLOT(popupPing())); 36 ctcpMenu->insertItem(Resource::loadPixmap("opieirc/ping"), tr("Ping"), this, SLOT(popupPing()));
37 ctcpMenu->insertItem(Resource::loadPixmap("opieirc/version"), tr("Version"), this, SLOT(popupVersion())); 37 ctcpMenu->insertItem(Resource::loadPixmap("opieirc/version"), tr("Version"), this, SLOT(popupVersion()));
38 ctcpMenu->insertItem(Resource::loadPixmap("opieirc/whois"), tr("Whois"), this, SLOT(popupWhois())); 38 ctcpMenu->insertItem(Resource::loadPixmap("opieirc/whois"), tr("Whois"), this, SLOT(popupWhois()));
39 connect(m_mainWindow, SIGNAL(updateScroll()), this, SLOT(scrolling())); 39 connect(m_mainWindow, SIGNAL(updateScroll()), this, SLOT(scrolling()));
40 m_layout->add(hbox); 40 m_layout->add(hbox);
41 hbox->show(); 41 hbox->show();
42 m_layout->add(m_field); 42 m_layout->add(m_field);
43 m_field->setFocus(); 43 m_field->setFocus();
44 connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); 44 connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand()));
45 settingsChanged(); 45 settingsChanged();
46} 46}
47 47
48void IRCChannelTab::scrolling(){ 48void IRCChannelTab::scrolling(){
49 m_textview->ensureVisible(0, m_textview->contentsHeight()); 49 m_textview->ensureVisible(0, m_textview->contentsHeight());
50} 50}
51 51
52void IRCChannelTab::appendText(QString text) { 52void IRCChannelTab::appendText(QString text) {
53 /* not using append because it creates layout problems */ 53 /* not using append because it creates layout problems */
54 QString txt = m_textview->text() + text + "\n"; 54 QString txt = m_textview->text() + text + "\n";
55 if (m_maxLines > 0 && m_lines >= m_maxLines) { 55 if (m_maxLines > 0 && m_lines >= m_maxLines) {
56 int firstBreak = txt.find('\n'); 56 int firstBreak = txt.find('\n');
57 if (firstBreak != -1) { 57 if (firstBreak != -1) {
58 txt = "<qt bgcolor=\"" + m_backgroundColor + "\"/>" + txt.right(txt.length() - (firstBreak + 1)); 58 txt = "<qt bgcolor=\"" + m_backgroundColor + "\"/>" + txt.right(txt.length() - (firstBreak + 1));
59 } 59 }
60 } else { 60 } else {
61 m_lines++; 61 m_lines++;
62 } 62 }
63 m_textview->ensureVisible(0, m_textview->contentsHeight()); 63 m_textview->ensureVisible(0, m_textview->contentsHeight());
64 m_textview->setText(txt); 64 m_textview->setText(txt);
65 m_textview->ensureVisible(0, m_textview->contentsHeight()); 65 m_textview->ensureVisible(0, m_textview->contentsHeight());
66 emit changed(this); 66 emit changed(this);
67} 67}
68 68
69IRCChannelTab::~IRCChannelTab() { 69IRCChannelTab::~IRCChannelTab() {
70 m_parentTab->removeChannelTab(this); 70 m_parentTab->removeChannelTab(this);
71} 71}
72 72
73void IRCChannelTab::processCommand() { 73void IRCChannelTab::processCommand() {
74 QString text = m_field->text(); 74 QString text = m_field->text();
75 if (text.length()>0) { 75 if (text.length()>0) {
76 if (session()->isSessionActive()) { 76 if (session()->isSessionActive()) {
77 if (text.startsWith("/") && !text.startsWith("//")) { 77 if (text.startsWith("/") && !text.startsWith("//")) {
78 /* Command mode */ 78 /* Command mode */
79 m_parentTab->executeCommand(this, text);; 79 m_parentTab->executeCommand(this, text);;
80 } else { 80 } else {
81 if (text.startsWith("//")) 81 if (text.startsWith("//"))
82 text = text.right(text.length()-1); 82 text = text.right(text.length()-1);
83 session()->sendMessage(m_channel, m_field->text()); 83 session()->sendMessage(m_channel, m_field->text());
84 appendText("<font color=\"" + m_textColor + "\">&lt;</font><font color=\"" + m_selfColor + "\">"+m_parentTab->server()->nick()+"</font><font color=\"" + m_textColor + "\">&gt; "+IRCOutput::toHTML(m_field->text())+"</font><br>"); 84 appendText("<font color=\"" + m_textColor + "\">&lt;</font><font color=\"" + m_selfColor + "\">"+m_parentTab->server()->nick()+"</font><font color=\"" + m_textColor + "\">&gt; "+IRCOutput::toHTML(m_field->text())+"</font><br>");
85 } 85 }
86 } else { 86 } else {
87 appendText("<font color=\"" + m_errorColor + "\">"+tr("Disconnected")+"</font><br>"); 87 appendText("<font color=\"" + m_errorColor + "\">"+tr("Disconnected")+"</font><br>");
88 } 88 }
89 } 89 }
90 m_field->clear(); 90 m_field->clear();
91} 91}
92 92
93void IRCChannelTab::settingsChanged() { 93void IRCChannelTab::settingsChanged() {
94 m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>"); 94 m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>");
95 m_lines = 0; 95 m_lines = 0;
96} 96}
97 97
98void IRCChannelTab::toggleList() { 98void IRCChannelTab::toggleList() {
99 if (m_listVisible) { 99 if (m_listVisible) {
100 m_list->setMaximumWidth(0); 100 m_list->setMaximumWidth(0);
101 m_listButton->setText("<"); 101 m_listButton->setText("<");
102 } else { 102 } else {
103 m_list->setMaximumWidth(LISTWIDTH); 103 m_list->setMaximumWidth(LISTWIDTH);
104 m_listButton->setText(">"); 104 m_listButton->setText(">");
105 } 105 }
106 m_listVisible = !m_listVisible; 106 m_listVisible = !m_listVisible;
107} 107}
108 108
109void IRCChannelTab::mouseButtonPressed(int mouse, QListBoxItem *, const QPoint &point) { 109void IRCChannelTab::mouseButtonPressed(int mouse, QListBoxItem *, const QPoint &point) {
110 switch (mouse) { 110 switch (mouse) {
111 case 1: 111 case 1:
112 break; 112 break;
113 case 2: 113 case 2:
114 m_popup->popup(point); 114 m_popup->popup(point);
115 break; 115 break;
116 }; 116 };
117} 117}
118 118
119void IRCChannelTab::popupQuery() { 119void IRCChannelTab::popupQuery() {
120 if (m_list->currentItem() != -1) { 120 if (m_list->currentItem() != -1) {
121 IRCPerson *person = session()->getPerson(m_list->item(m_list->currentItem())->text()); 121 IRCPerson *person = session()->getPerson(m_list->item(m_list->currentItem())->text());
122 if (person) { 122 if (person) {
123 IRCQueryTab *tab = m_parentTab->getTabForQuery(person); 123 IRCQueryTab *tab = m_parentTab->getTabForQuery(person);
124 if (!tab) { 124 if (!tab) {
125 tab = new IRCQueryTab(person, m_parentTab, m_mainWindow, (QWidget *)parent()); 125 tab = new IRCQueryTab(person, m_parentTab, m_mainWindow, (QWidget *)parent());
126 m_parentTab->addQueryTab(tab); 126 m_parentTab->addQueryTab(tab);
127 m_mainWindow->addTab(tab); 127 m_mainWindow->addTab(tab);