summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opieirc/ircchannellist.cpp1
-rw-r--r--noncore/net/opieirc/ircchanneltab.cpp2
-rw-r--r--noncore/net/opieirc/ircmisc.cpp1
-rw-r--r--noncore/net/opieirc/ircservertab.cpp1
-rw-r--r--noncore/net/opieirc/ircsettings.cpp3
-rw-r--r--noncore/net/opieirc/irctab.cpp1
-rw-r--r--noncore/net/opieirc/main.cpp1
-rw-r--r--noncore/net/opieirc/mainwindow.cpp2
8 files changed, 0 insertions, 12 deletions
diff --git a/noncore/net/opieirc/ircchannellist.cpp b/noncore/net/opieirc/ircchannellist.cpp
index 566b223..4e13dee 100644
--- a/noncore/net/opieirc/ircchannellist.cpp
+++ b/noncore/net/opieirc/ircchannellist.cpp
@@ -1,48 +1,47 @@
1#include <qpe/resource.h> 1#include <qpe/resource.h>
2#include <qpixmap.h>
3#include "ircchannellist.h" 2#include "ircchannellist.h"
4 3
5IRCChannelList::IRCChannelList(IRCChannel *channel, QWidget *parent, const char *name, WFlags f) : QListBox(parent, name, f) { 4IRCChannelList::IRCChannelList(IRCChannel *channel, QWidget *parent, const char *name, WFlags f) : QListBox(parent, name, f) {
6 m_channel = channel; 5 m_channel = channel;
7} 6}
8 7
9void IRCChannelList::update() { 8void IRCChannelList::update() {
10 QPixmap op = Resource::loadPixmap("opieirc/op"); 9 QPixmap op = Resource::loadPixmap("opieirc/op");
11 QPixmap hop = Resource::loadPixmap("opieirc/hop"); 10 QPixmap hop = Resource::loadPixmap("opieirc/hop");
12 QPixmap voice = Resource::loadPixmap("opieirc/voice"); 11 QPixmap voice = Resource::loadPixmap("opieirc/voice");
13 QListIterator<IRCChannelPerson> it = m_channel->people(); 12 QListIterator<IRCChannelPerson> it = m_channel->people();
14 clear(); 13 clear();
15 for (; it.current(); ++it) { 14 for (; it.current(); ++it) {
16 IRCChannelPerson *person = it.current(); 15 IRCChannelPerson *person = it.current();
17 if (person->flags & PERSON_FLAG_OP) { 16 if (person->flags & PERSON_FLAG_OP) {
18 insertItem(op, person->person->nick()); 17 insertItem(op, person->person->nick());
19 } else if (person->flags & PERSON_FLAG_HALFOP) { 18 } else if (person->flags & PERSON_FLAG_HALFOP) {
20 insertItem(op, person->person->nick()); 19 insertItem(op, person->person->nick());
21 } else if (person->flags & PERSON_FLAG_VOICE) { 20 } else if (person->flags & PERSON_FLAG_VOICE) {
22 insertItem(voice, person->person->nick()); 21 insertItem(voice, person->person->nick());
23 } else { 22 } else {
24 insertItem(person->person->nick()); 23 insertItem(person->person->nick());
25 } 24 }
26 } 25 }
27 sort(); 26 sort();
28} 27}
29 28
30 29
31bool IRCChannelList::hasPerson(QString nick) { 30bool IRCChannelList::hasPerson(QString nick) {
32 for (unsigned int i=0; i<count(); i++) { 31 for (unsigned int i=0; i<count(); i++) {
33 if (text(i) == nick) 32 if (text(i) == nick)
34 return TRUE; 33 return TRUE;
35 } 34 }
36 return FALSE; 35 return FALSE;
37} 36}
38 37
39bool IRCChannelList::removePerson(QString nick) { 38bool IRCChannelList::removePerson(QString nick) {
40 for (unsigned int i=0; i<count(); i++) { 39 for (unsigned int i=0; i<count(); i++) {
41 if (text(i) == nick){ 40 if (text(i) == nick){
42 removeItem(i); 41 removeItem(i);
43 return TRUE; 42 return TRUE;
44 } 43 }
45 } 44 }
46 return FALSE; 45 return FALSE;
47} 46}
48 47
diff --git a/noncore/net/opieirc/ircchanneltab.cpp b/noncore/net/opieirc/ircchanneltab.cpp
index 2b8b65e..b0771f6 100644
--- a/noncore/net/opieirc/ircchanneltab.cpp
+++ b/noncore/net/opieirc/ircchanneltab.cpp
@@ -1,167 +1,165 @@
1#include <qpe/qpeapplication.h>
2#include <qpe/resource.h> 1#include <qpe/resource.h>
3#include <qcursor.h>
4#include <qwhatsthis.h> 2#include <qwhatsthis.h>
5#include <qhbox.h> 3#include <qhbox.h>
6#include "ircchanneltab.h" 4#include "ircchanneltab.h"
7#include "ircservertab.h" 5#include "ircservertab.h"
8 6
9IRCChannelTab::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) {
10 m_mainWindow = mainWindow; 8 m_mainWindow = mainWindow;
11 m_parentTab = parentTab; 9 m_parentTab = parentTab;
12 m_channel = channel; 10 m_channel = channel;
13 m_description->setText(tr("Talking on channel") + " <b>" + channel->channelname() + "</b>"); 11 m_description->setText(tr("Talking on channel") + " <b>" + channel->channelname() + "</b>");
14 QHBox *hbox = new QHBox(this); 12 QHBox *hbox = new QHBox(this);
15 m_textview = new QTextView(hbox); 13 m_textview = new QTextView(hbox);
16 m_textview->setHScrollBarMode(QScrollView::AlwaysOff); 14 m_textview->setHScrollBarMode(QScrollView::AlwaysOff);
17 m_textview->setVScrollBarMode(QScrollView::AlwaysOn); 15 m_textview->setVScrollBarMode(QScrollView::AlwaysOn);
18 m_listVisible = TRUE; 16 m_listVisible = TRUE;
19 m_listButton = new QPushButton(">", m_textview); 17 m_listButton = new QPushButton(">", m_textview);
20 m_textview->setCornerWidget(m_listButton); 18 m_textview->setCornerWidget(m_listButton);
21 m_textview->setTextFormat(RichText); 19 m_textview->setTextFormat(RichText);
22 QWhatsThis::add(m_textview, tr("Channel discussion")); 20 QWhatsThis::add(m_textview, tr("Channel discussion"));
23 connect(m_listButton, SIGNAL(clicked()), this, SLOT(toggleList())); 21 connect(m_listButton, SIGNAL(clicked()), this, SLOT(toggleList()));
24 m_list = new IRCChannelList(m_channel, hbox); 22 m_list = new IRCChannelList(m_channel, hbox);
25 m_list->update(); 23 m_list->update();
26 m_list->setMaximumWidth(LISTWIDTH); 24 m_list->setMaximumWidth(LISTWIDTH);
27 m_field = new IRCHistoryLineEdit(this); 25 m_field = new IRCHistoryLineEdit(this);
28 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"));
29 m_popup = new QPopupMenu(m_list); 27 m_popup = new QPopupMenu(m_list);
30 m_lines = 0; 28 m_lines = 0;
31 /* Required so that embedded-style "right" clicks work */ 29 /* Required so that embedded-style "right" clicks work */
32 QPEApplication::setStylusOperation(m_list->viewport(), QPEApplication::RightOnHold); 30 QPEApplication::setStylusOperation(m_list->viewport(), QPEApplication::RightOnHold);
33 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 &)));
34 /* Construct the popup menu */ 32 /* Construct the popup menu */
35 QPopupMenu *ctcpMenu = new QPopupMenu(m_list); 33 QPopupMenu *ctcpMenu = new QPopupMenu(m_list);
36 m_popup->insertItem(Resource::loadPixmap("opieirc/ctcp"), tr("CTCP"), ctcpMenu); 34 m_popup->insertItem(Resource::loadPixmap("opieirc/ctcp"), tr("CTCP"), ctcpMenu);
37 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()));
38 ctcpMenu->insertItem(Resource::loadPixmap("opieirc/ping"), tr("Ping"), this, SLOT(popupPing())); 36 ctcpMenu->insertItem(Resource::loadPixmap("opieirc/ping"), tr("Ping"), this, SLOT(popupPing()));
39 ctcpMenu->insertItem(Resource::loadPixmap("opieirc/version"), tr("Version"), this, SLOT(popupVersion())); 37 ctcpMenu->insertItem(Resource::loadPixmap("opieirc/version"), tr("Version"), this, SLOT(popupVersion()));
40 ctcpMenu->insertItem(Resource::loadPixmap("opieirc/whois"), tr("Whois"), this, SLOT(popupWhois())); 38 ctcpMenu->insertItem(Resource::loadPixmap("opieirc/whois"), tr("Whois"), this, SLOT(popupWhois()));
41 connect(m_mainWindow, SIGNAL(updateScroll()), this, SLOT(scrolling())); 39 connect(m_mainWindow, SIGNAL(updateScroll()), this, SLOT(scrolling()));
42 m_layout->add(hbox); 40 m_layout->add(hbox);
43 hbox->show(); 41 hbox->show();
44 m_layout->add(m_field); 42 m_layout->add(m_field);
45 m_field->setFocus(); 43 m_field->setFocus();
46 connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); 44 connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand()));
47 settingsChanged(); 45 settingsChanged();
48} 46}
49 47
50void IRCChannelTab::scrolling(){ 48void IRCChannelTab::scrolling(){
51 m_textview->ensureVisible(0, m_textview->contentsHeight()); 49 m_textview->ensureVisible(0, m_textview->contentsHeight());
52} 50}
53 51
54void IRCChannelTab::appendText(QString text) { 52void IRCChannelTab::appendText(QString text) {
55 /* not using append because it creates layout problems */ 53 /* not using append because it creates layout problems */
56 QString txt = m_textview->text() + text + "\n"; 54 QString txt = m_textview->text() + text + "\n";
57 if (m_maxLines > 0 && m_lines >= m_maxLines) { 55 if (m_maxLines > 0 && m_lines >= m_maxLines) {
58 int firstBreak = txt.find('\n'); 56 int firstBreak = txt.find('\n');
59 if (firstBreak != -1) { 57 if (firstBreak != -1) {
60 txt = "<qt bgcolor=\"" + m_backgroundColor + "\"/>" + txt.right(txt.length() - (firstBreak + 1)); 58 txt = "<qt bgcolor=\"" + m_backgroundColor + "\"/>" + txt.right(txt.length() - (firstBreak + 1));
61 } 59 }
62 } else { 60 } else {
63 m_lines++; 61 m_lines++;
64 } 62 }
65 m_textview->ensureVisible(0, m_textview->contentsHeight()); 63 m_textview->ensureVisible(0, m_textview->contentsHeight());
66 m_textview->setText(txt); 64 m_textview->setText(txt);
67 m_textview->ensureVisible(0, m_textview->contentsHeight()); 65 m_textview->ensureVisible(0, m_textview->contentsHeight());
68 emit changed(this); 66 emit changed(this);
69} 67}
70 68
71IRCChannelTab::~IRCChannelTab() { 69IRCChannelTab::~IRCChannelTab() {
72 m_parentTab->removeChannelTab(this); 70 m_parentTab->removeChannelTab(this);
73} 71}
74 72
75void IRCChannelTab::processCommand() { 73void IRCChannelTab::processCommand() {
76 QString text = m_field->text(); 74 QString text = m_field->text();
77 if (text.length()>0) { 75 if (text.length()>0) {
78 if (session()->isSessionActive()) { 76 if (session()->isSessionActive()) {
79 if (text.startsWith("/") && !text.startsWith("//")) { 77 if (text.startsWith("/") && !text.startsWith("//")) {
80 /* Command mode */ 78 /* Command mode */
81 m_parentTab->executeCommand(this, text);; 79 m_parentTab->executeCommand(this, text);;
82 } else { 80 } else {
83 if (text.startsWith("//")) 81 if (text.startsWith("//"))
84 text = text.right(text.length()-1); 82 text = text.right(text.length()-1);
85 session()->sendMessage(m_channel, m_field->text()); 83 session()->sendMessage(m_channel, m_field->text());
86 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>");
87 } 85 }
88 } else { 86 } else {
89 appendText("<font color=\"" + m_errorColor + "\">"+tr("Disconnected")+"</font><br>"); 87 appendText("<font color=\"" + m_errorColor + "\">"+tr("Disconnected")+"</font><br>");
90 } 88 }
91 } 89 }
92 m_field->clear(); 90 m_field->clear();
93} 91}
94 92
95void IRCChannelTab::settingsChanged() { 93void IRCChannelTab::settingsChanged() {
96 m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>"); 94 m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>");
97 m_lines = 0; 95 m_lines = 0;
98} 96}
99 97
100void IRCChannelTab::toggleList() { 98void IRCChannelTab::toggleList() {
101 if (m_listVisible) { 99 if (m_listVisible) {
102 m_list->setMaximumWidth(0); 100 m_list->setMaximumWidth(0);
103 m_listButton->setText("<"); 101 m_listButton->setText("<");
104 } else { 102 } else {
105 m_list->setMaximumWidth(LISTWIDTH); 103 m_list->setMaximumWidth(LISTWIDTH);
106 m_listButton->setText(">"); 104 m_listButton->setText(">");
107 } 105 }
108 m_listVisible = !m_listVisible; 106 m_listVisible = !m_listVisible;
109} 107}
110 108
111void IRCChannelTab::mouseButtonPressed(int mouse, QListBoxItem *, const QPoint &point) { 109void IRCChannelTab::mouseButtonPressed(int mouse, QListBoxItem *, const QPoint &point) {
112 switch (mouse) { 110 switch (mouse) {
113 case 1: 111 case 1:
114 break; 112 break;
115 case 2: 113 case 2:
116 m_popup->popup(point); 114 m_popup->popup(point);
117 break; 115 break;
118 }; 116 };
119} 117}
120 118
121void IRCChannelTab::popupQuery() { 119void IRCChannelTab::popupQuery() {
122 if (m_list->currentItem() != -1) { 120 if (m_list->currentItem() != -1) {
123 IRCPerson *person = session()->getPerson(m_list->item(m_list->currentItem())->text()); 121 IRCPerson *person = session()->getPerson(m_list->item(m_list->currentItem())->text());
124 if (person) { 122 if (person) {
125 IRCQueryTab *tab = m_parentTab->getTabForQuery(person); 123 IRCQueryTab *tab = m_parentTab->getTabForQuery(person);
126 if (!tab) { 124 if (!tab) {
127 tab = new IRCQueryTab(person, m_parentTab, m_mainWindow, (QWidget *)parent()); 125 tab = new IRCQueryTab(person, m_parentTab, m_mainWindow, (QWidget *)parent());
128 m_parentTab->addQueryTab(tab); 126 m_parentTab->addQueryTab(tab);
129 m_mainWindow->addTab(tab); 127 m_mainWindow->addTab(tab);
130 } 128 }
131 } 129 }
132 } 130 }
133} 131}
134 132
135void IRCChannelTab::popupPing() { 133void IRCChannelTab::popupPing() {
136 //HAHA, no wonder these don't work 134 //HAHA, no wonder these don't work
137} 135}
138 136
139void IRCChannelTab::popupVersion() { 137void IRCChannelTab::popupVersion() {
140} 138}
141 139
142void IRCChannelTab::popupWhois() { 140void IRCChannelTab::popupWhois() {
143} 141}
144 142
145QString IRCChannelTab::title() { 143QString IRCChannelTab::title() {
146 return m_channel->channelname(); 144 return m_channel->channelname();
147} 145}
148 146
149IRCSession *IRCChannelTab::session() { 147IRCSession *IRCChannelTab::session() {
150 return m_parentTab->session(); 148 return m_parentTab->session();
151} 149}
152 150
153void IRCChannelTab::remove() { 151void IRCChannelTab::remove() {
154 if (session()->isSessionActive()) { 152 if (session()->isSessionActive()) {
155 session()->part(m_channel); 153 session()->part(m_channel);
156 } else { 154 } else {
157 m_mainWindow->killTab(this); 155 m_mainWindow->killTab(this);
158 } 156 }
159} 157}
160 158
161IRCChannel *IRCChannelTab::channel() { 159IRCChannel *IRCChannelTab::channel() {
162 return m_channel; 160 return m_channel;
163} 161}
164 162
165IRCChannelList *IRCChannelTab::list() { 163IRCChannelList *IRCChannelTab::list() {
166 return m_list; 164 return m_list;
167} 165}
diff --git a/noncore/net/opieirc/ircmisc.cpp b/noncore/net/opieirc/ircmisc.cpp
index a15a790..22387b3 100644
--- a/noncore/net/opieirc/ircmisc.cpp
+++ b/noncore/net/opieirc/ircmisc.cpp
@@ -1,84 +1,83 @@
1#include <qlayout.h>
2#include <stdio.h> 1#include <stdio.h>
3#include "ircmisc.h" 2#include "ircmisc.h"
4 3
5IRCTabBar::IRCTabBar(QWidget *parent, const char *name) : QTabBar(parent, name) { 4IRCTabBar::IRCTabBar(QWidget *parent, const char *name) : QTabBar(parent, name) {
6} 5}
7 6
8int IRCTabBar::insertTab(QTab *tab, int index) { 7int IRCTabBar::insertTab(QTab *tab, int index) {
9 /* FIXME: find some nicer way to do this */ 8 /* FIXME: find some nicer way to do this */
10 QExtTab *ext = new QExtTab(); 9 QExtTab *ext = new QExtTab();
11 ext->color = black; 10 ext->color = black;
12 ext->label = tab->text(); 11 ext->label = tab->text();
13 ext->r = tab->rect(); 12 ext->r = tab->rect();
14 ext->enabled = tab->isEnabled(); 13 ext->enabled = tab->isEnabled();
15 ext->iconset = tab->iconSet(); 14 ext->iconset = tab->iconSet();
16 delete tab; 15 delete tab;
17 return QTabBar::insertTab(ext, index); 16 return QTabBar::insertTab(ext, index);
18} 17}
19 18
20void IRCTabBar::setTabColor(int index, QColor color) { 19void IRCTabBar::setTabColor(int index, QColor color) {
21 ((QExtTab *)tab(index))->color = color; 20 ((QExtTab *)tab(index))->color = color;
22 update(); 21 update();
23} 22}
24 23
25void IRCTabBar::paintLabel(QPainter* p, const QRect& br, QTab* t, bool focus) const { 24void IRCTabBar::paintLabel(QPainter* p, const QRect& br, QTab* t, bool focus) const {
26 QRect r = br; 25 QRect r = br;
27 QTabBar::paintLabel(p, br, t, focus); 26 QTabBar::paintLabel(p, br, t, focus);
28 if (t->id == currentTab()) 27 if (t->id == currentTab())
29 r.setBottom(r.bottom() - style().defaultFrameWidth()); 28 r.setBottom(r.bottom() - style().defaultFrameWidth());
30 p->setPen(((QExtTab *)t)->color); 29 p->setPen(((QExtTab *)t)->color);
31 p->drawText(r, AlignCenter | ShowPrefix, t->label); 30 p->drawText(r, AlignCenter | ShowPrefix, t->label);
32} 31}
33 32
34IRCTabWidget::IRCTabWidget(QWidget *parent, const char *name) : QTabWidget(parent, name) { 33IRCTabWidget::IRCTabWidget(QWidget *parent, const char *name) : QTabWidget(parent, name) {
35 setTabBar(new IRCTabBar(this, "tab control")); 34 setTabBar(new IRCTabBar(this, "tab control"));
36} 35}
37 36
38void IRCTabWidget::setTabColor(int index, QColor color) { 37void IRCTabWidget::setTabColor(int index, QColor color) {
39 ((IRCTabBar *)tabBar())->setTabColor(index, color); 38 ((IRCTabBar *)tabBar())->setTabColor(index, color);
40} 39}
41 40
42 41
43IRCHistoryLineEdit::IRCHistoryLineEdit(QWidget *parent, const char *name) : QLineEdit(parent, name) { 42IRCHistoryLineEdit::IRCHistoryLineEdit(QWidget *parent, const char *name) : QLineEdit(parent, name) {
44 m_index = -1; 43 m_index = -1;
45 installEventFilter(this); 44 installEventFilter(this);
46} 45}
47 46
48void IRCHistoryLineEdit::keyPressEvent(QKeyEvent *event) { 47void IRCHistoryLineEdit::keyPressEvent(QKeyEvent *event) {
49 int key = event->key(); 48 int key = event->key();
50 if (key == Key_Up) { 49 if (key == Key_Up) {
51 if (m_history.count() > 0 && m_index < (signed int)m_history.count()-1) { 50 if (m_history.count() > 0 && m_index < (signed int)m_history.count()-1) {
52 m_index++; 51 m_index++;
53 setText(m_history[m_index]); 52 setText(m_history[m_index]);
54 } 53 }
55 } else if (key == Key_Down) { 54 } else if (key == Key_Down) {
56 if (m_history.count() > 0 && m_index > 0) { 55 if (m_history.count() > 0 && m_index > 0) {
57 m_index--; 56 m_index--;
58 setText(m_history[m_index]); 57 setText(m_history[m_index]);
59 } 58 }
60 if (m_index == 0) { 59 if (m_index == 0) {
61 m_index = -1; 60 m_index = -1;
62 setText(""); 61 setText("");
63 } 62 }
64 } else if (key == Key_Return) { 63 } else if (key == Key_Return) {
65 m_history.prepend(text()); 64 m_history.prepend(text());
66 m_index = -1; 65 m_index = -1;
67 } else if (key == Key_Tab) { 66 } else if (key == Key_Tab) {
68 printf("got tab\n"); 67 printf("got tab\n");
69 return; 68 return;
70 } 69 }
71 QLineEdit::keyPressEvent(event); 70 QLineEdit::keyPressEvent(event);
72} 71}
73 72
74bool IRCHistoryLineEdit::eventFilter(QObject *object, QEvent *event) { 73bool IRCHistoryLineEdit::eventFilter(QObject *object, QEvent *event) {
75 if (event->type() == QEvent::KeyPress) { 74 if (event->type() == QEvent::KeyPress) {
76 QKeyEvent *k = (QKeyEvent *) event; 75 QKeyEvent *k = (QKeyEvent *) event;
77 /* Catch tab characters */ 76 /* Catch tab characters */
78 if (k->key() == Key_Tab) { 77 if (k->key() == Key_Tab) {
79 qDebug("tab!"); 78 qDebug("tab!");
80 return TRUE; 79 return TRUE;
81 } 80 }
82 } 81 }
83 return QLineEdit::eventFilter(object, event); 82 return QLineEdit::eventFilter(object, event);
84} 83}
diff --git a/noncore/net/opieirc/ircservertab.cpp b/noncore/net/opieirc/ircservertab.cpp
index 2c28507..d1aab40 100644
--- a/noncore/net/opieirc/ircservertab.cpp
+++ b/noncore/net/opieirc/ircservertab.cpp
@@ -1,374 +1,373 @@
1#include <qpe/config.h>
2#include <qtextstream.h> 1#include <qtextstream.h>
3#include <qwhatsthis.h> 2#include <qwhatsthis.h>
4#include "ircservertab.h" 3#include "ircservertab.h"
5 4
6IRCServerTab::IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) { 5IRCServerTab::IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) {
7 m_server = server; 6 m_server = server;
8 m_session = new IRCSession(&m_server); 7 m_session = new IRCSession(&m_server);
9 m_mainWindow = mainWindow; 8 m_mainWindow = mainWindow;
10 m_close = FALSE; 9 m_close = FALSE;
11 m_lines = 0; 10 m_lines = 0;
12 m_description->setText(tr("Connection to")+" <b>" + server.hostname() + ":" + QString::number(server.port()) + "</b>"); 11 m_description->setText(tr("Connection to")+" <b>" + server.hostname() + ":" + QString::number(server.port()) + "</b>");
13 m_textview = new QTextView(this); 12 m_textview = new QTextView(this);
14 m_textview->setHScrollBarMode(QScrollView::AlwaysOff); 13 m_textview->setHScrollBarMode(QScrollView::AlwaysOff);
15 m_textview->setVScrollBarMode(QScrollView::AlwaysOn); 14 m_textview->setVScrollBarMode(QScrollView::AlwaysOn);
16 m_textview->setTextFormat(RichText); 15 m_textview->setTextFormat(RichText);
17 QWhatsThis::add(m_textview, tr("Server messages")); 16 QWhatsThis::add(m_textview, tr("Server messages"));
18 m_layout->add(m_textview); 17 m_layout->add(m_textview);
19 m_field = new IRCHistoryLineEdit(this); 18 m_field = new IRCHistoryLineEdit(this);
20 QWhatsThis::add(m_field, tr("Type commands here. A list of available commands can be found inside the OpieIRC help")); 19 QWhatsThis::add(m_field, tr("Type commands here. A list of available commands can be found inside the OpieIRC help"));
21 m_layout->add(m_field); 20 m_layout->add(m_field);
22 connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); 21 connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand()));
23 m_field->setFocus(); 22 m_field->setFocus();
24 connect(m_session, SIGNAL(outputReady(IRCOutput)), this, SLOT(display(IRCOutput))); 23 connect(m_session, SIGNAL(outputReady(IRCOutput)), this, SLOT(display(IRCOutput)));
25 connect(m_mainWindow, SIGNAL(updateScroll()), this, SLOT(scrolling())); 24 connect(m_mainWindow, SIGNAL(updateScroll()), this, SLOT(scrolling()));
26 settingsChanged(); 25 settingsChanged();
27} 26}
28 27
29void IRCServerTab::scrolling(){ 28void IRCServerTab::scrolling(){
30 m_textview->ensureVisible(0, m_textview->contentsHeight()); 29 m_textview->ensureVisible(0, m_textview->contentsHeight());
31} 30}
32 31
33 32
34void IRCServerTab::appendText(QString text) { 33void IRCServerTab::appendText(QString text) {
35 /* not using append because it creates layout problems */ 34 /* not using append because it creates layout problems */
36 QString txt = m_textview->text() + text + "\n"; 35 QString txt = m_textview->text() + text + "\n";
37 if (m_maxLines > 0 && m_lines >= m_maxLines) { 36 if (m_maxLines > 0 && m_lines >= m_maxLines) {
38 int firstBreak = txt.find('\n'); 37 int firstBreak = txt.find('\n');
39 if (firstBreak != -1) { 38 if (firstBreak != -1) {
40 txt = "<qt bgcolor=\"" + m_backgroundColor + "\"/>" + txt.right(txt.length() - (firstBreak + 1)); 39 txt = "<qt bgcolor=\"" + m_backgroundColor + "\"/>" + txt.right(txt.length() - (firstBreak + 1));
41 } 40 }
42 } else { 41 } else {
43 m_lines++; 42 m_lines++;
44 } 43 }
45 m_textview->setText(txt); 44 m_textview->setText(txt);
46 m_textview->ensureVisible(0, m_textview->contentsHeight()); 45 m_textview->ensureVisible(0, m_textview->contentsHeight());
47 emit changed(this); 46 emit changed(this);
48} 47}
49 48
50IRCServerTab::~IRCServerTab() { 49IRCServerTab::~IRCServerTab() {
51 delete m_session; 50 delete m_session;
52} 51}
53 52
54void IRCServerTab::removeChannelTab(IRCChannelTab *tab) { 53void IRCServerTab::removeChannelTab(IRCChannelTab *tab) {
55 m_channelTabs.remove(tab); 54 m_channelTabs.remove(tab);
56} 55}
57 56
58void IRCServerTab::removeQueryTab(IRCQueryTab *tab) { 57void IRCServerTab::removeQueryTab(IRCQueryTab *tab) {
59 m_queryTabs.remove(tab); 58 m_queryTabs.remove(tab);
60} 59}
61 60
62void IRCServerTab::addQueryTab(IRCQueryTab *tab) { 61void IRCServerTab::addQueryTab(IRCQueryTab *tab) {
63 m_queryTabs.append(tab); 62 m_queryTabs.append(tab);
64} 63}
65 64
66QString IRCServerTab::title() { 65QString IRCServerTab::title() {
67 return "Server"; 66 return "Server";
68} 67}
69 68
70IRCSession *IRCServerTab::session() { 69IRCSession *IRCServerTab::session() {
71 return m_session; 70 return m_session;
72} 71}
73/* 72/*
74QString *IRCServerTab::mynick() { 73QString *IRCServerTab::mynick() {
75 return (*m_server->nick()); 74 return (*m_server->nick());
76} */ 75} */
77 76
78IRCServer *IRCServerTab::server() { 77IRCServer *IRCServerTab::server() {
79 return &m_server; 78 return &m_server;
80} 79}
81 80
82void IRCServerTab::settingsChanged() { 81void IRCServerTab::settingsChanged() {
83 m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>"); 82 m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>");
84 m_lines = 0; 83 m_lines = 0;
85} 84}
86 85
87void IRCServerTab::executeCommand(IRCTab *tab, QString line) { 86void IRCServerTab::executeCommand(IRCTab *tab, QString line) {
88 QTextIStream stream(&line); 87 QTextIStream stream(&line);
89 QString command; 88 QString command;
90 stream >> command; 89 stream >> command;
91 command = command.upper().right(command.length()-1); 90 command = command.upper().right(command.length()-1);
92 91
93 //JOIN 92 //JOIN
94 if (command == "JOIN" || command == "J") { 93 if (command == "JOIN" || command == "J") {
95 QString channel; 94 QString channel;
96 stream >> channel; 95 stream >> channel;
97 if (channel.length() > 0 && (channel.startsWith("#") || channel.startsWith("+"))) { 96 if (channel.length() > 0 && (channel.startsWith("#") || channel.startsWith("+"))) {
98 m_session->join(channel); 97 m_session->join(channel);
99 } else { 98 } else {
100 tab->appendText("<font color=\"" + m_errorColor + "\">Unknown channel format!</font><br>"); 99 tab->appendText("<font color=\"" + m_errorColor + "\">Unknown channel format!</font><br>");
101 } 100 }
102 } 101 }
103 102
104 //KICK 103 //KICK
105 else if (command == "KICK"){ 104 else if (command == "KICK"){
106 QString nickname; 105 QString nickname;
107 stream >> nickname; 106 stream >> nickname;
108 if (nickname.length() > 0) { 107 if (nickname.length() > 0) {
109 if (line.length() > 7 + nickname.length()) { 108 if (line.length() > 7 + nickname.length()) {
110 QString text = line.right(line.length()-nickname.length()-7); 109 QString text = line.right(line.length()-nickname.length()-7);
111 IRCPerson person; 110 IRCPerson person;
112 person.setNick(nickname); 111 person.setNick(nickname);
113 m_session->kick(((IRCChannelTab *)tab)->channel(), &person, text); 112 m_session->kick(((IRCChannelTab *)tab)->channel(), &person, text);
114 } else { 113 } else {
115 IRCPerson person; 114 IRCPerson person;
116 person.setNick(nickname); 115 person.setNick(nickname);
117 m_session->kick(((IRCChannelTab *)tab)->channel(), &person); 116 m_session->kick(((IRCChannelTab *)tab)->channel(), &person);
118 } 117 }
119 } 118 }
120 } 119 }
121 120
122 else if (command == "OP"){ 121 else if (command == "OP"){
123 QString nickname; 122 QString nickname;
124 stream >> nickname; 123 stream >> nickname;
125 if (nickname.length() > 0) { 124 if (nickname.length() > 0) {
126 QString text = line.right(line.length()-nickname.length()-5); 125 QString text = line.right(line.length()-nickname.length()-5);
127 IRCPerson person; 126 IRCPerson person;
128 person.setNick(nickname); 127 person.setNick(nickname);
129 m_session->op(((IRCChannelTab *)tab)->channel(), &person); 128 m_session->op(((IRCChannelTab *)tab)->channel(), &person);
130 } 129 }
131 } 130 }
132 131
133 //SEND MODES 132 //SEND MODES
134 else if (command == "MODE"){ 133 else if (command == "MODE"){
135 QString text = line.right(line.length()-6); 134 QString text = line.right(line.length()-6);
136 if (text.length() > 0) { 135 if (text.length() > 0) {
137 m_session->mode(text); 136 m_session->mode(text);
138 } else { 137 } else {
139 tab->appendText("<font color=\"" + m_errorColor + "\">/mode channel {[+|-]|o|p|s|i|t|n|b|v} [limit] [user] [ban mask]<br>/mode nickname {[+|-]|i|w|s|o}</font><br>"); 138 tab->appendText("<font color=\"" + m_errorColor + "\">/mode channel {[+|-]|o|p|s|i|t|n|b|v} [limit] [user] [ban mask]<br>/mode nickname {[+|-]|i|w|s|o}</font><br>");
140 } 139 }
141 } 140 }
142 //SEND RAW MESSAGE TO SERVER, COMPLETELY UNCHECKED - anything in the RFC...or really anything you want 141 //SEND RAW MESSAGE TO SERVER, COMPLETELY UNCHECKED - anything in the RFC...or really anything you want
143 else if (command == "RAW"){ 142 else if (command == "RAW"){
144 QString text = line.right(line.length()-5); 143 QString text = line.right(line.length()-5);
145 if (text.length() > 0) { 144 if (text.length() > 0) {
146 m_session->raw(text); 145 m_session->raw(text);
147 } 146 }
148 } 147 }
149 else if (command == "SUSPEND"){ 148 else if (command == "SUSPEND"){
150 QString text = line.right(line.length()-9); 149 QString text = line.right(line.length()-9);
151 if (text.upper() == "ON") { 150 if (text.upper() == "ON") {
152 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; 151 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
153 } 152 }
154 else if (text.upper() == "OFF"){ 153 else if (text.upper() == "OFF"){
155 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Disable; 154 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Disable;
156 } else { 155 } else {
157 tab->appendText("<font color=\"" + m_errorColor + "\">Line: "+ line +"</font><br>Text: "+text); 156 tab->appendText("<font color=\"" + m_errorColor + "\">Line: "+ line +"</font><br>Text: "+text);
158 } 157 }
159 } 158 }
160 159
161 else if (command == "QUIT"){ 160 else if (command == "QUIT"){
162 QString text = line.right(line.length()-6); 161 QString text = line.right(line.length()-6);
163 if (text.length() > 0) { 162 if (text.length() > 0) {
164 m_session->quit(text); 163 m_session->quit(text);
165 } else { 164 } else {
166 m_session->quit(); 165 m_session->quit();
167 } 166 }
168 } 167 }
169 168
170 //SEND ACTION 169 //SEND ACTION
171 else if (command == "ME") { 170 else if (command == "ME") {
172 QString text = line.right(line.length()-4); 171 QString text = line.right(line.length()-4);
173 if (text.length() > 0) { 172 if (text.length() > 0) {
174 if (tab->isA("IRCChannelTab")) { 173 if (tab->isA("IRCChannelTab")) {
175 tab->appendText("<font color=\"" + m_selfColor + "\">*" + IRCOutput::toHTML(m_server.nick()) + " " + IRCOutput::toHTML(text) + "</font><br>"); 174 tab->appendText("<font color=\"" + m_selfColor + "\">*" + IRCOutput::toHTML(m_server.nick()) + " " + IRCOutput::toHTML(text) + "</font><br>");
176 m_session->sendAction(((IRCChannelTab *)tab)->channel(), text); 175 m_session->sendAction(((IRCChannelTab *)tab)->channel(), text);
177 } else if (tab->isA("IRCQueryTab")) { 176 } else if (tab->isA("IRCQueryTab")) {
178 tab->appendText("<font color=\"" + m_selfColor + "\">*" + IRCOutput::toHTML(m_server.nick()) + " " + IRCOutput::toHTML(text) + "</font><br>"); 177 tab->appendText("<font color=\"" + m_selfColor + "\">*" + IRCOutput::toHTML(m_server.nick()) + " " + IRCOutput::toHTML(text) + "</font><br>");
179 m_session->sendAction(((IRCQueryTab *)tab)->person(), text); 178 m_session->sendAction(((IRCQueryTab *)tab)->person(), text);
180 } else { 179 } else {
181 tab->appendText("<font color=\"" + m_errorColor + "\">Invalid tab for this command</font><br>"); 180 tab->appendText("<font color=\"" + m_errorColor + "\">Invalid tab for this command</font><br>");
182 } 181 }
183 } 182 }
184 } 183 }
185 //SEND PRIVMSG 184 //SEND PRIVMSG
186 else if (command == "MSG") { 185 else if (command == "MSG") {
187 QString nickname; 186 QString nickname;
188 stream >> nickname; 187 stream >> nickname;
189 if (nickname.length() > 0) { 188 if (nickname.length() > 0) {
190 if (line.length() > 6 + nickname.length()) { 189 if (line.length() > 6 + nickname.length()) {
191 QString text = line.right(line.length()-nickname.length()-6); 190 QString text = line.right(line.length()-nickname.length()-6);
192 IRCPerson person; 191 IRCPerson person;
193 person.setNick(nickname); 192 person.setNick(nickname);
194 tab->appendText("<font color=\"" + m_textColor + "\">&gt;</font><font color=\"" + m_otherColor + "\">"+IRCOutput::toHTML(nickname)+"</font><font color=\"" + m_textColor + "\">&lt; "+IRCOutput::toHTML(text)+"</font><br>"); 193 tab->appendText("<font color=\"" + m_textColor + "\">&gt;</font><font color=\"" + m_otherColor + "\">"+IRCOutput::toHTML(nickname)+"</font><font color=\"" + m_textColor + "\">&lt; "+IRCOutput::toHTML(text)+"</font><br>");
195 m_session->sendMessage(&person, text); 194 m_session->sendMessage(&person, text);
196 } 195 }
197 } 196 }
198 } 197 }
199 else { 198 else {
200 tab->appendText("<font color=\"" + m_errorColor + "\">Unknown command</font><br>"); 199 tab->appendText("<font color=\"" + m_errorColor + "\">Unknown command</font><br>");
201 } 200 }
202} 201}
203 202
204void IRCServerTab::processCommand() { 203void IRCServerTab::processCommand() {
205 QString text = m_field->text(); 204 QString text = m_field->text();
206 if (text.startsWith("/") && !text.startsWith("//")) { 205 if (text.startsWith("/") && !text.startsWith("//")) {
207 /* Command mode */ 206 /* Command mode */
208 executeCommand(this, text); 207 executeCommand(this, text);
209 } 208 }
210 m_field->clear(); 209 m_field->clear();
211} 210}
212 211
213void IRCServerTab::doConnect() { 212void IRCServerTab::doConnect() {
214 m_session->beginSession(); 213 m_session->beginSession();
215} 214}
216 215
217void IRCServerTab::remove() { 216void IRCServerTab::remove() {
218 /* Close requested */ 217 /* Close requested */
219 if (m_session->isSessionActive()) { 218 if (m_session->isSessionActive()) {
220 /* While there is a running session */ 219 /* While there is a running session */
221 m_close = TRUE; 220 m_close = TRUE;
222 m_session->endSession(); 221 m_session->endSession();
223 } else { 222 } else {
224 /* Session has previously been closed */ 223 /* Session has previously been closed */
225 m_channelTabs.first(); 224 m_channelTabs.first();
226 while (m_channelTabs.current() != 0) { 225 while (m_channelTabs.current() != 0) {
227 m_mainWindow->killTab(m_channelTabs.current()); 226 m_mainWindow->killTab(m_channelTabs.current());
228 } 227 }
229 m_queryTabs.first(); 228 m_queryTabs.first();
230 while (m_queryTabs.current() != 0) { 229 while (m_queryTabs.current() != 0) {
231 m_mainWindow->killTab(m_queryTabs.current()); 230 m_mainWindow->killTab(m_queryTabs.current());
232 } 231 }
233 m_mainWindow->killTab(this); 232 m_mainWindow->killTab(this);
234 } 233 }
235} 234}
236 235
237IRCChannelTab *IRCServerTab::getTabForChannel(IRCChannel *channel) { 236IRCChannelTab *IRCServerTab::getTabForChannel(IRCChannel *channel) {
238 QListIterator<IRCChannelTab> it(m_channelTabs); 237 QListIterator<IRCChannelTab> it(m_channelTabs);
239 238
240 for (; it.current(); ++it) { 239 for (; it.current(); ++it) {
241 if (it.current()->channel() == channel) 240 if (it.current()->channel() == channel)
242 return it.current(); 241 return it.current();
243 } 242 }
244 return 0; 243 return 0;
245} 244}
246 245
247IRCQueryTab *IRCServerTab::getTabForQuery(IRCPerson *person) { 246IRCQueryTab *IRCServerTab::getTabForQuery(IRCPerson *person) {
248 QListIterator<IRCQueryTab> it(m_queryTabs); 247 QListIterator<IRCQueryTab> it(m_queryTabs);
249 248
250 for (; it.current(); ++it) { 249 for (; it.current(); ++it) {
251 if (it.current()->person()->nick() == person->nick()) 250 if (it.current()->person()->nick() == person->nick())
252 return it.current(); 251 return it.current();
253 } 252 }
254 return 0; 253 return 0;
255} 254}
256 255
257void IRCServerTab::display(IRCOutput output) { 256void IRCServerTab::display(IRCOutput output) {
258 257
259 /* All messages to be displayed inside the GUI get here */ 258 /* All messages to be displayed inside the GUI get here */
260 switch (output.type()) { 259 switch (output.type()) {
261 case OUTPUT_CONNCLOSE: 260 case OUTPUT_CONNCLOSE:
262 if (m_close) { 261 if (m_close) {
263 m_channelTabs.first(); 262 m_channelTabs.first();
264 while (m_channelTabs.current() != 0) { 263 while (m_channelTabs.current() != 0) {
265 m_mainWindow->killTab(m_channelTabs.current()); 264 m_mainWindow->killTab(m_channelTabs.current());
266 } 265 }
267 m_queryTabs.first(); 266 m_queryTabs.first();
268 while (m_queryTabs.current() != 0) { 267 while (m_queryTabs.current() != 0) {
269 m_mainWindow->killTab(m_queryTabs.current()); 268 m_mainWindow->killTab(m_queryTabs.current());
270 } 269 }
271 m_mainWindow->killTab(this); 270 m_mainWindow->killTab(this);
272 } else { 271 } else {
273 appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() +"</font><br>"); 272 appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() +"</font><br>");
274 QListIterator<IRCChannelTab> it(m_channelTabs); 273 QListIterator<IRCChannelTab> it(m_channelTabs);
275 for (; it.current(); ++it) { 274 for (; it.current(); ++it) {
276 it.current()->appendText("<font color=\"" + m_serverColor + "\">" + output.htmlMessage() +"</font><br>"); 275 it.current()->appendText("<font color=\"" + m_serverColor + "\">" + output.htmlMessage() +"</font><br>");
277 } 276 }
278 } 277 }
279 break; 278 break;
280 case OUTPUT_SELFJOIN: { 279 case OUTPUT_SELFJOIN: {
281 IRCChannelTab *channeltab = new IRCChannelTab((IRCChannel *)output.getParam(0), this, m_mainWindow, (QWidget *)parent()); 280 IRCChannelTab *channeltab = new IRCChannelTab((IRCChannel *)output.getParam(0), this, m_mainWindow, (QWidget *)parent());
282 m_channelTabs.append(channeltab); 281 m_channelTabs.append(channeltab);
283 m_mainWindow->addTab(channeltab); 282 m_mainWindow->addTab(channeltab);
284 } 283 }
285 break; 284 break;
286 case OUTPUT_CHANPRIVMSG: { 285 case OUTPUT_CHANPRIVMSG: {
287 IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); 286 IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0));
288 channelTab->appendText("<font color=\"" + m_textColor + "\">&lt;</font><font color=\"" + m_otherColor + "\">"+IRCOutput::toHTML(((IRCChannelPerson *)output.getParam(1))->person->nick())+"</font><font color=\"" + m_textColor + "\">&gt; " + output.htmlMessage()+"</font><br>"); 287 channelTab->appendText("<font color=\"" + m_textColor + "\">&lt;</font><font color=\"" + m_otherColor + "\">"+IRCOutput::toHTML(((IRCChannelPerson *)output.getParam(1))->person->nick())+"</font><font color=\"" + m_textColor + "\">&gt; " + output.htmlMessage()+"</font><br>");
289 } 288 }
290 break; 289 break;
291 case OUTPUT_QUERYACTION: 290 case OUTPUT_QUERYACTION:
292 case OUTPUT_QUERYPRIVMSG: { 291 case OUTPUT_QUERYPRIVMSG: {
293 IRCQueryTab *queryTab = getTabForQuery((IRCPerson *)output.getParam(0)); 292 IRCQueryTab *queryTab = getTabForQuery((IRCPerson *)output.getParam(0));
294 if (!queryTab) { 293 if (!queryTab) {
295 queryTab = new IRCQueryTab((IRCPerson *)output.getParam(0), this, m_mainWindow, (QWidget *)parent()); 294 queryTab = new IRCQueryTab((IRCPerson *)output.getParam(0), this, m_mainWindow, (QWidget *)parent());
296 m_queryTabs.append(queryTab); 295 m_queryTabs.append(queryTab);
297 m_mainWindow->addTab(queryTab); 296 m_mainWindow->addTab(queryTab);
298 } 297 }
299 queryTab->display(output); 298 queryTab->display(output);
300 } 299 }
301 break; 300 break;
302 case OUTPUT_SELFPART: { 301 case OUTPUT_SELFPART: {
303 IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); 302 IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0));
304 if (channelTab) 303 if (channelTab)
305 m_mainWindow->killTab(channelTab); 304 m_mainWindow->killTab(channelTab);
306 } 305 }
307 break; 306 break;
308 case OUTPUT_SELFKICK: { 307 case OUTPUT_SELFKICK: {
309 appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() + "</font><br>"); 308 appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() + "</font><br>");
310 IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); 309 IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0));
311 if (channelTab) 310 if (channelTab)
312 m_mainWindow->killTab(channelTab); 311 m_mainWindow->killTab(channelTab);
313 } 312 }
314 break; 313 break;
315 case OUTPUT_CHANACTION: { 314 case OUTPUT_CHANACTION: {
316 IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); 315 IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0));
317 channelTab->appendText("<font color=\"" + m_otherColor + "\">"+output.htmlMessage()+"</font><br>"); 316 channelTab->appendText("<font color=\"" + m_otherColor + "\">"+output.htmlMessage()+"</font><br>");
318 } 317 }
319 break; 318 break;
320 case OUTPUT_TOPIC: { 319 case OUTPUT_TOPIC: {
321 IRCChannel *channel = (IRCChannel *) output.getParam(0); 320 IRCChannel *channel = (IRCChannel *) output.getParam(0);
322 if (channel) { 321 if (channel) {
323 IRCChannelTab *channelTab = getTabForChannel(channel); 322 IRCChannelTab *channelTab = getTabForChannel(channel);
324 if (channelTab) { 323 if (channelTab) {
325 channelTab->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); 324 channelTab->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>");
326 return; 325 return;
327 } 326 }
328 } 327 }
329 appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); 328 appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>");
330 } 329 }
331 break; 330 break;
332 case OUTPUT_QUIT: { 331 case OUTPUT_QUIT: {
333 QString nick = ((IRCPerson *)output.getParam(0))->nick(); 332 QString nick = ((IRCPerson *)output.getParam(0))->nick();
334 QListIterator<IRCChannelTab> it(m_channelTabs); 333 QListIterator<IRCChannelTab> it(m_channelTabs);
335 for (; it.current(); ++it) { 334 for (; it.current(); ++it) {
336 if (it.current()->list()->hasPerson(nick)) { 335 if (it.current()->list()->hasPerson(nick)) {
337 it.current()->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); 336 it.current()->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>");
338 it.current()->list()->update(); 337 it.current()->list()->update();
339 } 338 }
340 } 339 }
341 } 340 }
342 break; 341 break;
343/* case OUTPUT_NICKCHANGE: { 342/* case OUTPUT_NICKCHANGE: {
344 //WAS HERE 343 //WAS HERE
345 QString nick = ((IRCPerson *)output.getParam(0))->nick(); 344 QString nick = ((IRCPerson *)output.getParam(0))->nick();
346 QListIterator<IRCChannelTab> it(m_channelTabs); 345 QListIterator<IRCChannelTab> it(m_channelTabs);
347 for (; it.current(); ++it) { 346 for (; it.current(); ++it) {
348 if (it.current()->list()->hasPerson(nick)) { 347 if (it.current()->list()->hasPerson(nick)) {
349 it.current()->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); 348 it.current()->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>");
350 it.current()->list()->update(); 349 it.current()->list()->update();
351 } 350 }
352 } 351 }
353 } 352 }
354 break; 353 break;
355 */ case OUTPUT_OTHERJOIN: 354 */ case OUTPUT_OTHERJOIN:
356 case OUTPUT_OTHERKICK: 355 case OUTPUT_OTHERKICK:
357 case OUTPUT_CHANPERSONMODE: 356 case OUTPUT_CHANPERSONMODE:
358 case OUTPUT_OTHERPART: { 357 case OUTPUT_OTHERPART: {
359 IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); 358 IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0));
360 channelTab->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); 359 channelTab->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>");
361 channelTab->list()->update(); 360 channelTab->list()->update();
362 } 361 }
363 break; 362 break;
364 case OUTPUT_CTCP: 363 case OUTPUT_CTCP:
365 appendText("<font color=\"" + m_notificationColor + "\">" + output.htmlMessage() + "</font><br>"); 364 appendText("<font color=\"" + m_notificationColor + "\">" + output.htmlMessage() + "</font><br>");
366 break; 365 break;
367 case OUTPUT_ERROR: 366 case OUTPUT_ERROR:
368 appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() + "</font><br>"); 367 appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() + "</font><br>");
369 break; 368 break;
370 default: 369 default:
371 appendText("<font color=\"" + m_serverColor + "\">" + output.htmlMessage() + "</font><br>"); 370 appendText("<font color=\"" + m_serverColor + "\">" + output.htmlMessage() + "</font><br>");
372 break; 371 break;
373 } 372 }
374} 373}
diff --git a/noncore/net/opieirc/ircsettings.cpp b/noncore/net/opieirc/ircsettings.cpp
index 70d5445..2862296 100644
--- a/noncore/net/opieirc/ircsettings.cpp
+++ b/noncore/net/opieirc/ircsettings.cpp
@@ -1,101 +1,98 @@
1#include <opie/ocolorbutton.h> 1#include <opie/ocolorbutton.h>
2#include <opie/otabwidget.h> 2#include <opie/otabwidget.h>
3#include <qlayout.h>
4#include <qvalidator.h> 3#include <qvalidator.h>
5#include <qscrollview.h>
6#include <qwhatsthis.h> 4#include <qwhatsthis.h>
7#include "ircsettings.h" 5#include "ircsettings.h"
8#include "irctab.h" 6#include "irctab.h"
9#include "ircmisc.h"
10 7
11IRCSettings::IRCSettings(QWidget* parent, const char* name, bool modal, WFlags) : QDialog(parent, name, modal, WStyle_ContextHelp) { 8IRCSettings::IRCSettings(QWidget* parent, const char* name, bool modal, WFlags) : QDialog(parent, name, modal, WStyle_ContextHelp) {
12 setCaption(tr("Settings") ); 9 setCaption(tr("Settings") );
13 m_config = new Config("OpieIRC"); 10 m_config = new Config("OpieIRC");
14 m_config->setGroup("OpieIRC"); 11 m_config->setGroup("OpieIRC");
15 QHBoxLayout *l = new QHBoxLayout(this, 2, 2); 12 QHBoxLayout *l = new QHBoxLayout(this, 2, 2);
16 OTabWidget *tw = new OTabWidget(this); 13 OTabWidget *tw = new OTabWidget(this);
17 l->addWidget(tw); 14 l->addWidget(tw);
18 /* General Configuration */ 15 /* General Configuration */
19 QWidget *genwidget = new QWidget(tw); 16 QWidget *genwidget = new QWidget(tw);
20 QGridLayout *layout = new QGridLayout(genwidget, 1, 2, 5, 0); 17 QGridLayout *layout = new QGridLayout(genwidget, 1, 2, 5, 0);
21 QLabel *label = new QLabel(tr("Lines displayed :"), genwidget); 18 QLabel *label = new QLabel(tr("Lines displayed :"), genwidget);
22 layout->addWidget(label, 0, 0); 19 layout->addWidget(label, 0, 0);
23 m_lines = new QLineEdit(m_config->readEntry("Lines", "100"), genwidget); 20 m_lines = new QLineEdit(m_config->readEntry("Lines", "100"), genwidget);
24 QWhatsThis::add(m_lines, tr("Amount of lines to be displayed in chats before old lines get deleted - this is necessary to restrain memory consumption. Set to 0 if you don't need this")); 21 QWhatsThis::add(m_lines, tr("Amount of lines to be displayed in chats before old lines get deleted - this is necessary to restrain memory consumption. Set to 0 if you don't need this"));
25 QIntValidator *validator = new QIntValidator(this); 22 QIntValidator *validator = new QIntValidator(this);
26 validator->setTop(10000); 23 validator->setTop(10000);
27 validator->setBottom(0); 24 validator->setBottom(0);
28 m_lines->setValidator(validator); 25 m_lines->setValidator(validator);
29 layout->addWidget(m_lines, 0, 1); 26 layout->addWidget(m_lines, 0, 1);
30 tw->addTab(genwidget, "opieirc/settings", tr("General")); 27 tw->addTab(genwidget, "opieirc/settings", tr("General"));
31 28
32 /* Color configuration */ 29 /* Color configuration */
33 QScrollView *view = new QScrollView(this); 30 QScrollView *view = new QScrollView(this);
34 view->setResizePolicy(QScrollView::AutoOneFit); 31 view->setResizePolicy(QScrollView::AutoOneFit);
35 view->setFrameStyle( QFrame::NoFrame ); 32 view->setFrameStyle( QFrame::NoFrame );
36 QWidget *widget = new QWidget(view->viewport()); 33 QWidget *widget = new QWidget(view->viewport());
37 view->addChild(widget); 34 view->addChild(widget);
38 layout = new QGridLayout(widget, 7, 2, 5, 0); 35 layout = new QGridLayout(widget, 7, 2, 5, 0);
39 label = new QLabel(tr("Background color :"), widget); 36 label = new QLabel(tr("Background color :"), widget);
40 layout->addWidget(label, 0, 0); 37 layout->addWidget(label, 0, 0);
41 m_background = new OColorButton(widget, m_config->readEntry("BackgroundColor", "#FFFFFF")); 38 m_background = new OColorButton(widget, m_config->readEntry("BackgroundColor", "#FFFFFF"));
42 QWhatsThis::add(m_background, tr("Background color to be used in chats")); 39 QWhatsThis::add(m_background, tr("Background color to be used in chats"));
43 layout->addWidget(m_background, 0, 1); 40 layout->addWidget(m_background, 0, 1);
44 label = new QLabel(tr("Normal text color :"), widget); 41 label = new QLabel(tr("Normal text color :"), widget);
45 layout->addWidget(label, 1, 0); 42 layout->addWidget(label, 1, 0);
46 m_text = new OColorButton(widget, m_config->readEntry("TextColor", "#000000")); 43 m_text = new OColorButton(widget, m_config->readEntry("TextColor", "#000000"));
47 QWhatsThis::add(m_text, tr("Text color to be used in chats")); 44 QWhatsThis::add(m_text, tr("Text color to be used in chats"));
48 layout->addWidget(m_text, 1, 1); 45 layout->addWidget(m_text, 1, 1);
49 label = new QLabel(tr("Error color :"), widget); 46 label = new QLabel(tr("Error color :"), widget);
50 layout->addWidget(label, 2, 0); 47 layout->addWidget(label, 2, 0);
51 m_error = new OColorButton(widget, m_config->readEntry("ErrorColor", "#FF0000")); 48 m_error = new OColorButton(widget, m_config->readEntry("ErrorColor", "#FF0000"));
52 QWhatsThis::add(m_error, tr("Text color to be used to display errors")); 49 QWhatsThis::add(m_error, tr("Text color to be used to display errors"));
53 layout->addWidget(m_error, 2, 1); 50 layout->addWidget(m_error, 2, 1);
54 label = new QLabel(tr("Text written by yourself :"), widget); 51 label = new QLabel(tr("Text written by yourself :"), widget);
55 layout->addWidget(label, 3, 0); 52 layout->addWidget(label, 3, 0);
56 m_self = new OColorButton(widget, m_config->readEntry("SelfColor", "#CC0000")); 53 m_self = new OColorButton(widget, m_config->readEntry("SelfColor", "#CC0000"));
57 QWhatsThis::add(m_self, tr("Text color to be used to identify text written by yourself")); 54 QWhatsThis::add(m_self, tr("Text color to be used to identify text written by yourself"));
58 layout->addWidget(m_self, 3, 1); 55 layout->addWidget(m_self, 3, 1);
59 label = new QLabel(tr("Text written by others :"), widget); 56 label = new QLabel(tr("Text written by others :"), widget);
60 layout->addWidget(label, 4, 0); 57 layout->addWidget(label, 4, 0);
61 m_other = new OColorButton(widget, m_config->readEntry("OtherColor", "#0000BB")); 58 m_other = new OColorButton(widget, m_config->readEntry("OtherColor", "#0000BB"));
62 QWhatsThis::add(m_other, tr("Text color to be used to identify text written by others")); 59 QWhatsThis::add(m_other, tr("Text color to be used to identify text written by others"));
63 layout->addWidget(m_other, 4, 1); 60 layout->addWidget(m_other, 4, 1);
64 label = new QLabel(tr("Text written by the server :"), widget); 61 label = new QLabel(tr("Text written by the server :"), widget);
65 layout->addWidget(label, 5, 0); 62 layout->addWidget(label, 5, 0);
66 m_server = new OColorButton(widget, m_config->readEntry("ServerColor", "#0000FF")); 63 m_server = new OColorButton(widget, m_config->readEntry("ServerColor", "#0000FF"));
67 QWhatsThis::add(m_server, tr("Text color to be used to identify text written by the server")); 64 QWhatsThis::add(m_server, tr("Text color to be used to identify text written by the server"));
68 layout->addWidget(m_server, 5, 1); 65 layout->addWidget(m_server, 5, 1);
69 label = new QLabel(tr("Notifications :"), widget); 66 label = new QLabel(tr("Notifications :"), widget);
70 layout->addWidget(label, 6, 0); 67 layout->addWidget(label, 6, 0);
71 m_notification = new OColorButton(widget, m_config->readEntry("NotificationColor", "#AAE300")); 68 m_notification = new OColorButton(widget, m_config->readEntry("NotificationColor", "#AAE300"));
72 QWhatsThis::add(m_notification, tr("Text color to be used to display notifications")); 69 QWhatsThis::add(m_notification, tr("Text color to be used to display notifications"));
73 layout->addWidget(m_notification, 6, 1); 70 layout->addWidget(m_notification, 6, 1);
74 tw->addTab(view, "opieirc/colors", tr("Colors")); 71 tw->addTab(view, "opieirc/colors", tr("Colors"));
75 tw->setCurrentTab( genwidget ); 72 tw->setCurrentTab( genwidget );
76 showMaximized(); 73 showMaximized();
77} 74}
78 75
79void IRCSettings::accept() { 76void IRCSettings::accept() {
80 IRCTab::m_backgroundColor = m_background->color().name(); 77 IRCTab::m_backgroundColor = m_background->color().name();
81 IRCTab::m_textColor = m_text->color().name(); 78 IRCTab::m_textColor = m_text->color().name();
82 IRCTab::m_errorColor = m_error->color().name(); 79 IRCTab::m_errorColor = m_error->color().name();
83 IRCTab::m_selfColor = m_self->color().name(); 80 IRCTab::m_selfColor = m_self->color().name();
84 IRCTab::m_otherColor = m_other->color().name(); 81 IRCTab::m_otherColor = m_other->color().name();
85 IRCTab::m_serverColor = m_server->color().name(); 82 IRCTab::m_serverColor = m_server->color().name();
86 IRCTab::m_notificationColor = m_notification->color().name(); 83 IRCTab::m_notificationColor = m_notification->color().name();
87 IRCTab::m_maxLines = m_lines->text().toInt(); 84 IRCTab::m_maxLines = m_lines->text().toInt();
88 m_config->writeEntry("BackgroundColor", IRCTab::m_backgroundColor); 85 m_config->writeEntry("BackgroundColor", IRCTab::m_backgroundColor);
89 m_config->writeEntry("TextColor", IRCTab::m_textColor); 86 m_config->writeEntry("TextColor", IRCTab::m_textColor);
90 m_config->writeEntry("ErrorColor", IRCTab::m_errorColor); 87 m_config->writeEntry("ErrorColor", IRCTab::m_errorColor);
91 m_config->writeEntry("SelfColor", IRCTab::m_selfColor); 88 m_config->writeEntry("SelfColor", IRCTab::m_selfColor);
92 m_config->writeEntry("OtherColor", IRCTab::m_otherColor); 89 m_config->writeEntry("OtherColor", IRCTab::m_otherColor);
93 m_config->writeEntry("ServerColor", IRCTab::m_serverColor); 90 m_config->writeEntry("ServerColor", IRCTab::m_serverColor);
94 m_config->writeEntry("NotificationColor", IRCTab::m_notificationColor); 91 m_config->writeEntry("NotificationColor", IRCTab::m_notificationColor);
95 m_config->writeEntry("Lines", m_lines->text()); 92 m_config->writeEntry("Lines", m_lines->text());
96 QDialog::accept(); 93 QDialog::accept();
97} 94}
98 95
99IRCSettings::~IRCSettings() { 96IRCSettings::~IRCSettings() {
100 delete m_config; 97 delete m_config;
101} 98}
diff --git a/noncore/net/opieirc/irctab.cpp b/noncore/net/opieirc/irctab.cpp
index 8a869d6..3351c3b 100644
--- a/noncore/net/opieirc/irctab.cpp
+++ b/noncore/net/opieirc/irctab.cpp
@@ -1,39 +1,38 @@
1#include <qpe/resource.h> 1#include <qpe/resource.h>
2#include <qpixmap.h>
3#include <qpushbutton.h> 2#include <qpushbutton.h>
4#include <qwhatsthis.h> 3#include <qwhatsthis.h>
5#include "irctab.h" 4#include "irctab.h"
6 5
7QString IRCTab::m_errorColor; 6QString IRCTab::m_errorColor;
8QString IRCTab::m_serverColor; 7QString IRCTab::m_serverColor;
9QString IRCTab::m_textColor; 8QString IRCTab::m_textColor;
10QString IRCTab::m_backgroundColor; 9QString IRCTab::m_backgroundColor;
11QString IRCTab::m_selfColor; 10QString IRCTab::m_selfColor;
12QString IRCTab::m_otherColor; 11QString IRCTab::m_otherColor;
13QString IRCTab::m_notificationColor; 12QString IRCTab::m_notificationColor;
14int IRCTab::m_maxLines; 13int IRCTab::m_maxLines;
15 14
16IRCTab::IRCTab(QWidget *parent, const char *name, WFlags f) : QWidget(parent, name, f) { 15IRCTab::IRCTab(QWidget *parent, const char *name, WFlags f) : QWidget(parent, name, f) {
17 m_layout = new QVBoxLayout(this); 16 m_layout = new QVBoxLayout(this);
18 QHBoxLayout *descLayout = new QHBoxLayout(m_layout); 17 QHBoxLayout *descLayout = new QHBoxLayout(m_layout);
19 descLayout->setMargin(5); 18 descLayout->setMargin(5);
20 m_description = new QLabel(tr("Missing description"), this); 19 m_description = new QLabel(tr("Missing description"), this);
21 QWhatsThis::add(m_description, tr("Description of the tab's content")); 20 QWhatsThis::add(m_description, tr("Description of the tab's content"));
22 descLayout->addWidget(m_description); 21 descLayout->addWidget(m_description);
23 descLayout->setStretchFactor(m_description, 5); 22 descLayout->setStretchFactor(m_description, 5);
24 QPushButton *close = new QPushButton(this); 23 QPushButton *close = new QPushButton(this);
25 QWhatsThis::add(close, tr("Close this tab")); 24 QWhatsThis::add(close, tr("Close this tab"));
26 close->setPixmap(Resource::loadPixmap("close")); 25 close->setPixmap(Resource::loadPixmap("close"));
27 connect(close, SIGNAL(clicked()), this, SLOT(remove())); 26 connect(close, SIGNAL(clicked()), this, SLOT(remove()));
28 descLayout->addWidget(close); 27 descLayout->addWidget(close);
29 descLayout->setStretchFactor(m_description, 1); 28 descLayout->setStretchFactor(m_description, 1);
30} 29}
31 30
32 31
33void IRCTab::setID(int id) { 32void IRCTab::setID(int id) {
34 m_id = id; 33 m_id = id;
35} 34}
36 35
37int IRCTab::id() { 36int IRCTab::id() {
38 return m_id; 37 return m_id;
39} 38}
diff --git a/noncore/net/opieirc/main.cpp b/noncore/net/opieirc/main.cpp
index 39acfcc..da38024 100644
--- a/noncore/net/opieirc/main.cpp
+++ b/noncore/net/opieirc/main.cpp
@@ -1,7 +1,6 @@
1#include <qpe/qpeapplication.h>
2#include "mainwindow.h" 1#include "mainwindow.h"
3 2
4#include <opie/oapplicationfactory.h> 3#include <opie/oapplicationfactory.h>
5 4
6 5
7OPIE_EXPORT_APP( OApplicationFactory<MainWindow> ) 6OPIE_EXPORT_APP( OApplicationFactory<MainWindow> )
diff --git a/noncore/net/opieirc/mainwindow.cpp b/noncore/net/opieirc/mainwindow.cpp
index be6f8ed..7414154 100644
--- a/noncore/net/opieirc/mainwindow.cpp
+++ b/noncore/net/opieirc/mainwindow.cpp
@@ -1,93 +1,91 @@
1#include <qmenubar.h> 1#include <qmenubar.h>
2#include <qpe/resource.h> 2#include <qpe/resource.h>
3#include <qpe/config.h>
4#include <qpopupmenu.h>
5#include <qwhatsthis.h> 3#include <qwhatsthis.h>
6 4
7#include "mainwindow.h" 5#include "mainwindow.h"
8#include "ircservertab.h" 6#include "ircservertab.h"
9#include "ircserverlist.h" 7#include "ircserverlist.h"
10#include "ircsettings.h" 8#include "ircsettings.h"
11 9
12MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) { 10MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) {
13 setCaption(tr("IRC Client")); 11 setCaption(tr("IRC Client"));
14 m_tabWidget = new IRCTabWidget(this); 12 m_tabWidget = new IRCTabWidget(this);
15 QWhatsThis::add(m_tabWidget, tr("Server connections, channels, queries and other things will be placed here")); 13 QWhatsThis::add(m_tabWidget, tr("Server connections, channels, queries and other things will be placed here"));
16 connect(m_tabWidget, SIGNAL(currentChanged(QWidget *)), this, SLOT(selected(QWidget *))); 14 connect(m_tabWidget, SIGNAL(currentChanged(QWidget *)), this, SLOT(selected(QWidget *)));
17 setCentralWidget(m_tabWidget); 15 setCentralWidget(m_tabWidget);
18 setToolBarsMovable(FALSE); 16 setToolBarsMovable(FALSE);
19 QMenuBar *menuBar = new QMenuBar(this); 17 QMenuBar *menuBar = new QMenuBar(this);
20 QPopupMenu *irc = new QPopupMenu(this); 18 QPopupMenu *irc = new QPopupMenu(this);
21 menuBar->insertItem(tr("IRC"), irc); 19 menuBar->insertItem(tr("IRC"), irc);
22 QAction *a = new QAction(tr("New connection"), Resource::loadPixmap("pass"), QString::null, 0, this, 0); 20 QAction *a = new QAction(tr("New connection"), Resource::loadPixmap("pass"), QString::null, 0, this, 0);
23 connect(a, SIGNAL(activated()), this, SLOT(newConnection())); 21 connect(a, SIGNAL(activated()), this, SLOT(newConnection()));
24 a->setWhatsThis(tr("Create a new connection to an IRC server")); 22 a->setWhatsThis(tr("Create a new connection to an IRC server"));
25 a->addTo(irc); 23 a->addTo(irc);
26 a = new QAction(tr("Settings"), Resource::loadPixmap("SettingsIcon"), QString::null, 0, this, 0); 24 a = new QAction(tr("Settings"), Resource::loadPixmap("SettingsIcon"), QString::null, 0, this, 0);
27 a->setWhatsThis(tr("Configure OpieIRC's behavior and appearance")); 25 a->setWhatsThis(tr("Configure OpieIRC's behavior and appearance"));
28 connect(a, SIGNAL(activated()), this, SLOT(settings())); 26 connect(a, SIGNAL(activated()), this, SLOT(settings()));
29 a->addTo(irc); 27 a->addTo(irc);
30 loadSettings(); 28 loadSettings();
31} 29}
32 30
33/*IRCTabWidget MainWindow::getTabWidget(){ 31/*IRCTabWidget MainWindow::getTabWidget(){
34 return m_tabWidget; 32 return m_tabWidget;
35} */ 33} */
36 34
37void MainWindow::loadSettings() { 35void MainWindow::loadSettings() {
38 Config config("OpieIRC"); 36 Config config("OpieIRC");
39 config.setGroup("OpieIRC"); 37 config.setGroup("OpieIRC");
40 IRCTab::m_backgroundColor = config.readEntry("BackgroundColor", "#FFFFFF"); 38 IRCTab::m_backgroundColor = config.readEntry("BackgroundColor", "#FFFFFF");
41 IRCTab::m_textColor = config.readEntry("TextColor", "#000000"); 39 IRCTab::m_textColor = config.readEntry("TextColor", "#000000");
42 IRCTab::m_errorColor = config.readEntry("ErrorColor", "#FF0000"); 40 IRCTab::m_errorColor = config.readEntry("ErrorColor", "#FF0000");
43 IRCTab::m_selfColor = config.readEntry("SelfColor", "#CC0000"); 41 IRCTab::m_selfColor = config.readEntry("SelfColor", "#CC0000");
44 IRCTab::m_otherColor = config.readEntry("OtherColor", "#0000BB"); 42 IRCTab::m_otherColor = config.readEntry("OtherColor", "#0000BB");
45 IRCTab::m_serverColor = config.readEntry("ServerColor", "#0000FF"); 43 IRCTab::m_serverColor = config.readEntry("ServerColor", "#0000FF");
46 IRCTab::m_notificationColor = config.readEntry("NotificationColor", "#AA3300"); 44 IRCTab::m_notificationColor = config.readEntry("NotificationColor", "#AA3300");
47 IRCTab::m_maxLines = config.readNumEntry("Lines", 100); 45 IRCTab::m_maxLines = config.readNumEntry("Lines", 100);
48} 46}
49 47
50void MainWindow::selected(QWidget *) { 48void MainWindow::selected(QWidget *) {
51 m_tabWidget->setTabColor(m_tabWidget->currentPageIndex(), black); 49 m_tabWidget->setTabColor(m_tabWidget->currentPageIndex(), black);
52 emit updateScroll(); 50 emit updateScroll();
53} 51}
54 52
55void MainWindow::addTab(IRCTab *tab) { 53void MainWindow::addTab(IRCTab *tab) {
56 connect(tab, SIGNAL(changed(IRCTab *)), this, SLOT(changeEvent(IRCTab *))); 54 connect(tab, SIGNAL(changed(IRCTab *)), this, SLOT(changeEvent(IRCTab *)));
57 m_tabWidget->addTab(tab, tab->title()); 55 m_tabWidget->addTab(tab, tab->title());
58 m_tabWidget->showPage(tab); 56 m_tabWidget->showPage(tab);
59 tab->setID(m_tabWidget->currentPageIndex()); 57 tab->setID(m_tabWidget->currentPageIndex());
60 m_tabs.append(tab); 58 m_tabs.append(tab);
61} 59}
62 60
63void MainWindow::changeEvent(IRCTab *tab) { 61void MainWindow::changeEvent(IRCTab *tab) {
64 if (tab->id() != m_tabWidget->currentPageIndex()) 62 if (tab->id() != m_tabWidget->currentPageIndex())
65 m_tabWidget->setTabColor(tab->id(), blue); 63 m_tabWidget->setTabColor(tab->id(), blue);
66} 64}
67 65
68void MainWindow::killTab(IRCTab *tab) { 66void MainWindow::killTab(IRCTab *tab) {
69 m_tabWidget->removePage(tab); 67 m_tabWidget->removePage(tab);
70 m_tabs.remove(tab); 68 m_tabs.remove(tab);
71 /* there might be nicer ways to do this .. */ 69 /* there might be nicer ways to do this .. */
72 delete tab; 70 delete tab;
73} 71}
74 72
75void MainWindow::newConnection() { 73void MainWindow::newConnection() {
76 IRCServerList list(this, "ServerList", TRUE); 74 IRCServerList list(this, "ServerList", TRUE);
77 if (list.exec() == QDialog::Accepted && list.hasServer()) { 75 if (list.exec() == QDialog::Accepted && list.hasServer()) {
78 IRCServerTab *serverTab = new IRCServerTab(list.server(), this, m_tabWidget); 76 IRCServerTab *serverTab = new IRCServerTab(list.server(), this, m_tabWidget);
79 addTab(serverTab); 77 addTab(serverTab);
80 serverTab->doConnect(); 78 serverTab->doConnect();
81 } 79 }
82} 80}
83 81
84void MainWindow::settings() { 82void MainWindow::settings() {
85 IRCSettings settings(this, "Settings", TRUE); 83 IRCSettings settings(this, "Settings", TRUE);
86 if (settings.exec() == QDialog::Accepted) { 84 if (settings.exec() == QDialog::Accepted) {
87 QListIterator<IRCTab> it(m_tabs); 85 QListIterator<IRCTab> it(m_tabs);
88 for (; it.current(); ++it) { 86 for (; it.current(); ++it) {
89 /* Inform all tabs about the new settings */ 87 /* Inform all tabs about the new settings */
90 it.current()->settingsChanged(); 88 it.current()->settingsChanged();
91 } 89 }
92 } 90 }
93} 91}