summaryrefslogtreecommitdiff
path: root/noncore/net/opieirc/ircchanneltab.cpp
Unidiff
Diffstat (limited to 'noncore/net/opieirc/ircchanneltab.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/opieirc/ircchanneltab.cpp58
1 files changed, 55 insertions, 3 deletions
diff --git a/noncore/net/opieirc/ircchanneltab.cpp b/noncore/net/opieirc/ircchanneltab.cpp
index 4675265..c1695db 100644
--- a/noncore/net/opieirc/ircchanneltab.cpp
+++ b/noncore/net/opieirc/ircchanneltab.cpp
@@ -1,83 +1,135 @@
1#include <qpe/qpeapplication.h>
2#include <qpe/resource.h>
3#include <qcursor.h>
1#include <qhbox.h> 4#include <qhbox.h>
2#include "ircchanneltab.h" 5#include "ircchanneltab.h"
3#include "ircservertab.h" 6#include "ircservertab.h"
4 7
5IRCChannelTab::IRCChannelTab(IRCChannel *channel, IRCServerTab *parentTab, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) { 8IRCChannelTab::IRCChannelTab(IRCChannel *channel, IRCServerTab *parentTab, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) {
6 m_mainWindow = mainWindow; 9 m_mainWindow = mainWindow;
7 m_parentTab = parentTab; 10 m_parentTab = parentTab;
8 m_channel = channel; 11 m_channel = channel;
9 m_description->setText(tr("Talking on channel") + " <b>" + channel->channelname() + "</b>"); 12 m_description->setText(tr("Talking on channel") + " <b>" + channel->channelname() + "</b>");
10 QHBox *hbox = new QHBox(this); 13 QHBox *hbox = new QHBox(this);
11 m_textview = new QTextView(hbox); 14 m_textview = new QTextView(hbox);
12 m_textview->setHScrollBarMode(QScrollView::AlwaysOff); 15 m_textview->setHScrollBarMode(QScrollView::AlwaysOff);
13 m_textview->setVScrollBarMode(QScrollView::AlwaysOn); 16 m_textview->setVScrollBarMode(QScrollView::AlwaysOn);
14 m_listVisible = TRUE; 17 m_listVisible = TRUE;
15 m_listButton = new QPushButton(">", m_textview); 18 m_listButton = new QPushButton(">", m_textview);
16 m_textview->setCornerWidget(m_listButton); 19 m_textview->setCornerWidget(m_listButton);
17 m_textview->setTextFormat(RichText); 20 m_textview->setTextFormat(RichText);
18 connect(m_listButton, SIGNAL(clicked()), this, SLOT(toggleList())); 21 connect(m_listButton, SIGNAL(clicked()), this, SLOT(toggleList()));
19 m_list = new IRCChannelList(m_channel, hbox); 22 m_list = new IRCChannelList(m_channel, hbox);
20 m_list->update(); 23 m_list->update();
21 m_list->setMaximumWidth(LISTWIDTH); 24 m_list->setMaximumWidth(LISTWIDTH);
22 m_field = new QLineEdit(this); 25 m_field = new QLineEdit(this);
26 m_popup = new QPopupMenu(m_list);
27 /* Required so that embedded-style "right" clicks work */
28 QPEApplication::setStylusOperation(m_list->viewport(), QPEApplication::RightOnHold);
29 connect(m_list, SIGNAL(mouseButtonPressed(int, QListBoxItem *, const QPoint&)), this, SLOT(mouseButtonPressed(int, QListBoxItem *, const QPoint &)));
30 /* Construct the popup menu */
31 QPopupMenu *ctcpMenu = new QPopupMenu(m_list);
32 m_popup->insertItem(Resource::loadPixmap("opieirc/ctcp"), tr("CTCP"), ctcpMenu);
33 m_popup->insertItem(Resource::loadPixmap("opieirc/query"), tr("Query"), this, SLOT(popupQuery()));
34 ctcpMenu->insertItem(Resource::loadPixmap("opieirc/ping"), tr("Ping"), this, SLOT(popupPing()));
35 ctcpMenu->insertItem(Resource::loadPixmap("opieirc/version"), tr("Version"), this, SLOT(popupVersion()));
36 ctcpMenu->insertItem(Resource::loadPixmap("opieirc/whois"), tr("Whois"), this, SLOT(popupWhois()));
37
23 m_layout->add(hbox); 38 m_layout->add(hbox);
24 hbox->show(); 39 hbox->show();
25 m_layout->add(m_field); 40 m_layout->add(m_field);
26 m_field->setFocus(); 41 m_field->setFocus();
27 connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); 42 connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand()));
28 43 settingsChanged();
29} 44}
30 45
31void IRCChannelTab::appendText(QString text) { 46void IRCChannelTab::appendText(QString text) {
32 /* not using append because it creates layout problems */ 47 /* not using append because it creates layout problems */
33 m_textview->setText(m_textview->text() + text); 48 m_textview->setText(m_textview->text() + text);
34 m_textview->ensureVisible(0, m_textview->contentsHeight()); 49 m_textview->ensureVisible(0, m_textview->contentsHeight());
35} 50}
36 51
37IRCChannelTab::~IRCChannelTab() { 52IRCChannelTab::~IRCChannelTab() {
38 m_parentTab->removeChannelTab(this); 53 m_parentTab->removeChannelTab(this);
39} 54}
40 55
41void IRCChannelTab::processCommand() { 56void IRCChannelTab::processCommand() {
42 QString text = m_field->text(); 57 QString text = m_field->text();
43 if (text.length()>0) { 58 if (text.length()>0) {
44 if (session()->isSessionActive()) { 59 if (session()->isSessionActive()) {
45 if (text.startsWith("/") && !text.startsWith("//")) { 60 if (text.startsWith("/") && !text.startsWith("//")) {
46 /* Command mode */ 61 /* Command mode */
47 m_parentTab->executeCommand(this, text);; 62 m_parentTab->executeCommand(this, text);;
48 } else { 63 } else {
49 if (text.startsWith("//")) 64 if (text.startsWith("//"))
50 text = text.right(text.length()-1); 65 text = text.right(text.length()-1);
51 session()->sendMessage(m_channel, m_field->text()); 66 session()->sendMessage(m_channel, m_field->text());
52 appendText("&lt;<font color=\"#dd0000\">"+m_parentTab->server()->nick()+"</font>&gt; "+IRCOutput::toHTML(m_field->text())+"<br>"); 67 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>");
53 } 68 }
54 } else { 69 } else {
55 appendText("<font color=\"#ff0000\">"+tr("Disconnected")+"</font><br>"); 70 appendText("<font color=\"" + m_errorColor + "\">"+tr("Disconnected")+"</font><br>");
56 } 71 }
57 } 72 }
58 m_field->clear(); 73 m_field->clear();
59} 74}
60 75
76void IRCChannelTab::settingsChanged() {
77 m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>");
78}
79
61void IRCChannelTab::toggleList() { 80void IRCChannelTab::toggleList() {
62 if (m_listVisible) { 81 if (m_listVisible) {
63 m_list->setMaximumWidth(0); 82 m_list->setMaximumWidth(0);
64 m_listButton->setText("<"); 83 m_listButton->setText("<");
65 } else { 84 } else {
66 m_list->setMaximumWidth(LISTWIDTH); 85 m_list->setMaximumWidth(LISTWIDTH);
67 m_listButton->setText(">"); 86 m_listButton->setText(">");
68 } 87 }
69 m_listVisible = !m_listVisible; 88 m_listVisible = !m_listVisible;
70} 89}
71 90
91void IRCChannelTab::mouseButtonPressed(int mouse, QListBoxItem *, const QPoint &point) {
92 switch (mouse) {
93 case 1:
94 break;
95 case 2:
96 m_popup->popup(point);
97 break;
98 };
99}
100
101void IRCChannelTab::popupQuery() {
102 if (m_list->currentItem() != -1) {
103 IRCPerson *person = session()->getPerson(m_list->item(m_list->currentItem())->text());
104 if (person) {
105 IRCQueryTab *tab = m_parentTab->getTabForQuery(person);
106 if (!tab) {
107 tab = new IRCQueryTab(person, m_parentTab, m_mainWindow, (QWidget *)parent());
108 m_parentTab->addQueryTab(tab);
109 m_mainWindow->addTab(tab);
110 }
111 }
112 }
113}
114
115void IRCChannelTab::popupPing() {
116}
117
118void IRCChannelTab::popupVersion() {
119}
120
121void IRCChannelTab::popupWhois() {
122}
123
72QString IRCChannelTab::title() { 124QString IRCChannelTab::title() {
73 return m_channel->channelname(); 125 return m_channel->channelname();
74} 126}
75 127
76IRCSession *IRCChannelTab::session() { 128IRCSession *IRCChannelTab::session() {
77 return m_parentTab->session(); 129 return m_parentTab->session();
78} 130}
79 131
80void IRCChannelTab::remove() { 132void IRCChannelTab::remove() {
81 if (session()->isSessionActive()) { 133 if (session()->isSessionActive()) {
82 session()->part(m_channel); 134 session()->part(m_channel);
83 } else { 135 } else {