summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opieirc/.cvsignore3
-rw-r--r--noncore/net/opieirc/ircchanneltab.cpp22
-rw-r--r--noncore/net/opieirc/ircchanneltab.h2
-rw-r--r--noncore/net/opieirc/ircmessageparser.cpp34
-rw-r--r--noncore/net/opieirc/ircmisc.cpp5
-rw-r--r--noncore/net/opieirc/ircmisc.h3
-rw-r--r--noncore/net/opieirc/ircquerytab.cpp9
-rw-r--r--noncore/net/opieirc/ircserverlist.cpp9
-rw-r--r--noncore/net/opieirc/ircserverlist.h3
-rw-r--r--noncore/net/opieirc/ircservertab.cpp25
-rw-r--r--noncore/net/opieirc/ircsettings.cpp18
-rw-r--r--noncore/net/opieirc/ircsettings.h2
-rw-r--r--noncore/net/opieirc/irctab.cpp16
-rw-r--r--noncore/net/opieirc/irctab.h4
-rw-r--r--noncore/net/opieirc/mainwindow.cpp32
-rw-r--r--noncore/net/opieirc/mainwindow.h7
16 files changed, 155 insertions, 39 deletions
diff --git a/noncore/net/opieirc/.cvsignore b/noncore/net/opieirc/.cvsignore
index d5423d6..0ccbade 100644
--- a/noncore/net/opieirc/.cvsignore
+++ b/noncore/net/opieirc/.cvsignore
@@ -1,4 +1,5 @@
1Makefile 1Makefile
2Makefile.in 2Makefile.in
3moc_*.cpp 3moc_*.cpp
4.moc \ No newline at end of file 4.moc
5*.gch \ No newline at end of file
diff --git a/noncore/net/opieirc/ircchanneltab.cpp b/noncore/net/opieirc/ircchanneltab.cpp
index b6e3954..7610058 100644
--- a/noncore/net/opieirc/ircchanneltab.cpp
+++ b/noncore/net/opieirc/ircchanneltab.cpp
@@ -14,8 +14,9 @@ IRCChannelTab::IRCChannelTab(IRCChannel *channel, IRCServerTab *parentTab, MainW
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_listButton->setFlat( true );
18 m_textview->setCornerWidget(m_listButton); 19 m_textview->setCornerWidget(m_listButton);
19 m_textview->setTextFormat(RichText); 20 m_textview->setTextFormat(RichText);
20 QWhatsThis::add(m_textview, tr("Channel discussion")); 21 QWhatsThis::add(m_textview, tr("Channel discussion"));
21 connect(m_listButton, SIGNAL(clicked()), this, SLOT(toggleList())); 22 connect(m_listButton, SIGNAL(clicked()), this, SLOT(toggleList()));
@@ -24,9 +25,9 @@ IRCChannelTab::IRCChannelTab(IRCChannel *channel, IRCServerTab *parentTab, MainW
24 m_list->setMaximumWidth(LISTWIDTH); 25 m_list->setMaximumWidth(LISTWIDTH);
25 m_field = new IRCHistoryLineEdit(this); 26 m_field = new IRCHistoryLineEdit(this);
26 connect(m_field, SIGNAL(nextTab()), this, SIGNAL(nextTab())); 27 connect(m_field, SIGNAL(nextTab()), this, SIGNAL(nextTab()));
27 connect(m_field, SIGNAL(prevTab()), this, SIGNAL(prevTab())); 28 connect(m_field, SIGNAL(prevTab()), this, SIGNAL(prevTab()));
28 connect(m_field, SIGNAL(closeTab()), this, SIGNAL(closeTab())); 29 connect(m_field, SIGNAL(closeTab()), this, SLOT(remove()));
29 connect(this, SIGNAL(editFocus()), m_field, SLOT(setEditFocus())); 30 connect(this, SIGNAL(editFocus()), m_field, SLOT(setEditFocus()));
30 31
31 QWhatsThis::add(m_field, tr("Type your message here to participate in the channel discussion")); 32 QWhatsThis::add(m_field, tr("Type your message here to participate in the channel discussion"));
32 m_popup = new QPopupMenu(m_list); 33 m_popup = new QPopupMenu(m_list);
@@ -35,9 +36,8 @@ IRCChannelTab::IRCChannelTab(IRCChannel *channel, IRCServerTab *parentTab, MainW
35 QPEApplication::setStylusOperation(m_list->viewport(), QPEApplication::RightOnHold); 36 QPEApplication::setStylusOperation(m_list->viewport(), QPEApplication::RightOnHold);
36 connect(m_list, SIGNAL(mouseButtonPressed(int,QListBoxItem*,const QPoint&)), this, SLOT(mouseButtonPressed(int,QListBoxItem*,const QPoint&))); 37 connect(m_list, SIGNAL(mouseButtonPressed(int,QListBoxItem*,const QPoint&)), this, SLOT(mouseButtonPressed(int,QListBoxItem*,const QPoint&)));
37 /* Construct the popup menu */ 38 /* Construct the popup menu */
38 QPopupMenu *ctcpMenu = new QPopupMenu(m_list); 39 QPopupMenu *ctcpMenu = new QPopupMenu(m_list);
39 m_popup->insertItem(Resource::loadPixmap("opieirc/ctcp"), tr("CTCP"), ctcpMenu);
40 m_popup->insertItem(Resource::loadPixmap("opieirc/query"), tr("Query"), this, SLOT(popupQuery())); 40 m_popup->insertItem(Resource::loadPixmap("opieirc/query"), tr("Query"), this, SLOT(popupQuery()));
41 ctcpMenu->insertItem(Resource::loadPixmap("opieirc/ping"), tr("Ping"), this, SLOT(popupPing())); 41 ctcpMenu->insertItem(Resource::loadPixmap("opieirc/ping"), tr("Ping"), this, SLOT(popupPing()));
42 ctcpMenu->insertItem(Resource::loadPixmap("opieirc/version"), tr("Version"), this, SLOT(popupVersion())); 42 ctcpMenu->insertItem(Resource::loadPixmap("opieirc/version"), tr("Version"), this, SLOT(popupVersion()));
43 ctcpMenu->insertItem(Resource::loadPixmap("opieirc/whois"), tr("Whois"), this, SLOT(popupWhois())); 43 ctcpMenu->insertItem(Resource::loadPixmap("opieirc/whois"), tr("Whois"), this, SLOT(popupWhois()));
@@ -48,8 +48,9 @@ IRCChannelTab::IRCChannelTab(IRCChannel *channel, IRCServerTab *parentTab, MainW
48 m_field->setFocus(); 48 m_field->setFocus();
49 m_field->setActiveWindow(); 49 m_field->setActiveWindow();
50 50
51 connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); 51 connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand()));
52 connect(m_list, SIGNAL(doubleClicked ( QListBoxItem * ) ), this, SLOT(popupQuery( QListBoxItem * ) ));
52 settingsChanged(); 53 settingsChanged();
53} 54}
54 55
55void IRCChannelTab::scrolling(){ 56void IRCChannelTab::scrolling(){
@@ -57,9 +58,9 @@ void IRCChannelTab::scrolling(){
57} 58}
58 59
59void IRCChannelTab::appendText(QString text) { 60void IRCChannelTab::appendText(QString text) {
60 /* not using append because it creates layout problems */ 61 /* not using append because it creates layout problems */
61 QString txt = m_textview->text() + text + "\n"; 62 QString txt = m_textview->text() + IRCTab::appendTimestamp( text );
62 if (m_maxLines > 0 && m_lines >= m_maxLines) { 63 if (m_maxLines > 0 && m_lines >= m_maxLines) {
63 int firstBreak = txt.find('\n'); 64 int firstBreak = txt.find('\n');
64 if (firstBreak != -1) { 65 if (firstBreak != -1) {
65 txt = "<qt bgcolor=\"" + m_backgroundColor + "\"/>" + txt.right(txt.length() - (firstBreak + 1)); 66 txt = "<qt bgcolor=\"" + m_backgroundColor + "\"/>" + txt.right(txt.length() - (firstBreak + 1));
@@ -71,9 +72,11 @@ void IRCChannelTab::appendText(QString text) {
71 m_textview->setText(txt); 72 m_textview->setText(txt);
72 m_textview->ensureVisible(0, m_textview->contentsHeight()); 73 m_textview->ensureVisible(0, m_textview->contentsHeight());
73 74
74 int p1, p2; 75 int p1, p2;
75 if ( (p1 = text.find("ping", 0, false) )!= -1 && (p2 = text.find( m_parentTab->server()->nick(), 0,false )) != -1 ) { 76 if ( text.contains( IRCMessageParser::tr("Received a CTCP PING from ") ) )
77 emit ping( title() );
78 else if ( (p1 = text.find("ping", 0, false) )!= -1 && (p2 = text.find( m_parentTab->server()->nick(), 0,false )) != -1 ) {
76 int col = text.findRev("color", -1, false); 79 int col = text.findRev("color", -1, false);
77 if ( col < p2 ) 80 if ( col < p2 )
78 emit ping( title() ); 81 emit ping( title() );
79 82
@@ -131,11 +134,11 @@ void IRCChannelTab::mouseButtonPressed(int mouse, QListBoxItem *, const QPoint &
131 break; 134 break;
132 }; 135 };
133} 136}
134 137
135void IRCChannelTab::popupQuery() { 138void IRCChannelTab::popupQuery( QListBoxItem *item) {
136 if (m_list->currentItem() != -1) { 139 if (item) {
137 IRCPerson *person = session()->getPerson(m_list->item(m_list->currentItem())->text()); 140 IRCPerson *person = session()->getPerson(item->text());
138 if (person) { 141 if (person) {
139 IRCQueryTab *tab = m_parentTab->getTabForQuery(person); 142 IRCQueryTab *tab = m_parentTab->getTabForQuery(person);
140 if (!tab) { 143 if (!tab) {
141 tab = new IRCQueryTab(person, m_parentTab, m_mainWindow, (QWidget *)parent()); 144 tab = new IRCQueryTab(person, m_parentTab, m_mainWindow, (QWidget *)parent());
@@ -145,8 +148,13 @@ void IRCChannelTab::popupQuery() {
145 } 148 }
146 } 149 }
147} 150}
148 151
152void IRCChannelTab::popupQuery() {
153 if ( m_list->currentItem() != -1 )
154 popupQuery( m_list->item(m_list->currentItem()));
155}
156
149void IRCChannelTab::popupPing() { 157void IRCChannelTab::popupPing() {
150 //HAHA, no wonder these don't work 158 //HAHA, no wonder these don't work
151} 159}
152 160
diff --git a/noncore/net/opieirc/ircchanneltab.h b/noncore/net/opieirc/ircchanneltab.h
index 001c96d..70b212c 100644
--- a/noncore/net/opieirc/ircchanneltab.h
+++ b/noncore/net/opieirc/ircchanneltab.h
@@ -52,9 +52,11 @@ protected slots:
52 void processCommand(); 52 void processCommand();
53 void toggleList(); 53 void toggleList();
54 void mouseButtonPressed(int mouse, QListBoxItem *item, const QPoint &point); 54 void mouseButtonPressed(int mouse, QListBoxItem *item, const QPoint &point);
55 /* Popup slots */ 55 /* Popup slots */
56 void popupQuery(QListBoxItem*);
56 void popupQuery(); 57 void popupQuery();
58
57 void popupPing(); 59 void popupPing();
58 void popupVersion(); 60 void popupVersion();
59 void popupWhois(); 61 void popupWhois();
60protected: 62protected:
diff --git a/noncore/net/opieirc/ircmessageparser.cpp b/noncore/net/opieirc/ircmessageparser.cpp
index 90280d7..ecc7e9a 100644
--- a/noncore/net/opieirc/ircmessageparser.cpp
+++ b/noncore/net/opieirc/ircmessageparser.cpp
@@ -282,8 +282,42 @@ void IRCMessageParser::parseLiteralError(IRCMessage *message) {
282void IRCMessageParser::parseCTCPPing(IRCMessage *message) { 282void IRCMessageParser::parseCTCPPing(IRCMessage *message) {
283 IRCPerson mask(message->prefix()); 283 IRCPerson mask(message->prefix());
284 m_session->m_connection->sendCTCP(mask.nick(), "PING " + message->allParameters()); 284 m_session->m_connection->sendCTCP(mask.nick(), "PING " + message->allParameters());
285 emit outputReady(IRCOutput(OUTPUT_CTCP, tr("Received a CTCP PING from ")+mask.nick())); 285 emit outputReady(IRCOutput(OUTPUT_CTCP, tr("Received a CTCP PING from ")+mask.nick()));
286
287 //IRCPerson mask(message->prefix());
288 QString dest = message->ctcpDestination();
289 if (dest.startsWith("#")) {
290 IRCChannel *channel = m_session->getChannel(dest.lower());
291 if (channel) {
292 IRCChannelPerson *person = channel->getPerson(mask.nick());
293 if (person) {
294 IRCOutput output(OUTPUT_CHANACTION, tr("Received a CTCP PING from ")+ mask.nick()) ;
295 output.addParam(channel);
296 output.addParam(person);
297 emit outputReady(output);
298 } else {
299 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP PING with unknown person - Desynchronized?")));
300 }
301 } else {
302 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP PING with unknown channel - Desynchronized?")));
303 }
304 } else {
305 if (message->ctcpDestination() == m_session->m_server->nick()) {
306 IRCPerson *person = m_session->getPerson(mask.nick());
307 if (!person) {
308 /* Person not yet known, create and add to the current session */
309 person = new IRCPerson(message->prefix());
310 m_session->addPerson(person);
311 }
312 IRCOutput output(OUTPUT_QUERYACTION, tr("Received a CTCP PING from ")+ mask.nick() );
313 output.addParam(person);
314 emit outputReady(output);
315 } else {
316 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP PING with bad recipient")));
317 }
318 }
319
286} 320}
287 321
288void IRCMessageParser::parseCTCPVersion(IRCMessage *message) { 322void IRCMessageParser::parseCTCPVersion(IRCMessage *message) {
289 IRCPerson mask(message->prefix()); 323 IRCPerson mask(message->prefix());
diff --git a/noncore/net/opieirc/ircmisc.cpp b/noncore/net/opieirc/ircmisc.cpp
index 9b9bff8..6fc5ba0 100644
--- a/noncore/net/opieirc/ircmisc.cpp
+++ b/noncore/net/opieirc/ircmisc.cpp
@@ -66,8 +66,11 @@ OKeyConfigManager* IRCHistoryLineEdit::keyConfigInstance() {
66 s_manager->addKeyConfig( OKeyConfigItem( tr("Next Tab"), "next_tab", QPixmap(), 66 s_manager->addKeyConfig( OKeyConfigItem( tr("Next Tab"), "next_tab", QPixmap(),
67 KeyNextTab, OKeyPair(Qt::Key_N, Qt::ControlButton) )); 67 KeyNextTab, OKeyPair(Qt::Key_N, Qt::ControlButton) ));
68 s_manager->addKeyConfig( OKeyConfigItem( tr("Previous Tab"), "prev_tab", QPixmap(), 68 s_manager->addKeyConfig( OKeyConfigItem( tr("Previous Tab"), "prev_tab", QPixmap(),
69 KeyPrevTab, OKeyPair(Qt::Key_P, Qt::ControlButton) )); 69 KeyPrevTab, OKeyPair(Qt::Key_P, Qt::ControlButton) ));
70 s_manager->addKeyConfig( OKeyConfigItem( tr("Close Tab"), "close_tab",
71 QPixmap(), KeyCloseTab,
72 OKeyPair(Qt::Key_C, Qt::ControlButton) ));
70 s_manager->load(); 73 s_manager->load();
71 } 74 }
72 75
73 return s_manager; 76 return s_manager;
@@ -106,8 +109,10 @@ void IRCHistoryLineEdit::keyPressEvent(QKeyEvent *event) {
106 return; 109 return;
107 case KeyPrevTab: 110 case KeyPrevTab:
108 emit prevTab(); 111 emit prevTab();
109 return; 112 return;
113 case KeyCloseTab:
114 emit closeTab();
110 default: 115 default:
111 break; 116 break;
112 } 117 }
113 118
diff --git a/noncore/net/opieirc/ircmisc.h b/noncore/net/opieirc/ircmisc.h
index 37eed28..3cf64df 100644
--- a/noncore/net/opieirc/ircmisc.h
+++ b/noncore/net/opieirc/ircmisc.h
@@ -67,9 +67,10 @@ class IRCHistoryLineEdit : public QLineEdit {
67 Q_OBJECT 67 Q_OBJECT
68public: 68public:
69 enum KeyMode { 69 enum KeyMode {
70 KeyNextTab, 70 KeyNextTab,
71 KeyPrevTab 71 KeyPrevTab,
72 KeyCloseTab
72 }; 73 };
73 74
74 static Opie::Core::OKeyConfigManager* keyConfigInstance(); 75 static Opie::Core::OKeyConfigManager* keyConfigInstance();
75 76
diff --git a/noncore/net/opieirc/ircquerytab.cpp b/noncore/net/opieirc/ircquerytab.cpp
index 1fddc6d..53474b9 100644
--- a/noncore/net/opieirc/ircquerytab.cpp
+++ b/noncore/net/opieirc/ircquerytab.cpp
@@ -15,21 +15,24 @@ IRCQueryTab::IRCQueryTab(IRCPerson *person, IRCServerTab *parentTab, MainWindow
15 m_textview->setVScrollBarMode(QScrollView::AlwaysOn); 15 m_textview->setVScrollBarMode(QScrollView::AlwaysOn);
16 m_textview->setTextFormat(RichText); 16 m_textview->setTextFormat(RichText);
17 QWhatsThis::add(m_textview, tr("Private discussion")); 17 QWhatsThis::add(m_textview, tr("Private discussion"));
18 m_field = new IRCHistoryLineEdit(this); 18 m_field = new IRCHistoryLineEdit(this);
19
19 connect(m_field, SIGNAL(nextTab()), this, SIGNAL(nextTab())); 20 connect(m_field, SIGNAL(nextTab()), this, SIGNAL(nextTab()));
20 connect(m_field, SIGNAL(prevTab()), this, SIGNAL(prevTab())); 21 connect(m_field, SIGNAL(prevTab()), this, SIGNAL(prevTab()));
21 connect(m_field, SIGNAL(closeTab()),this, SIGNAL(closeTab())); 22 connect(m_field, SIGNAL(closeTab()),this, SLOT(remove()));
22 23 connect(this, SIGNAL(editFocus()), m_field, SLOT(setEditFocus()));
23 24
24 QWhatsThis::add(m_field, tr("Type your text here in order to send a message to the other person")); 25 QWhatsThis::add(m_field, tr("Type your text here in order to send a message to the other person"));
25 m_layout->add(hbox); 26 m_layout->add(hbox);
26 hbox->show(); 27 hbox->show();
27 m_layout->add(m_field); 28 m_layout->add(m_field);
28 m_field->setFocus(); 29
29 connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); 30 connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand()));
30 connect(m_mainWindow, SIGNAL(updateScroll()), this, SLOT(scrolling())); 31 connect(m_mainWindow, SIGNAL(updateScroll()), this, SLOT(scrolling()));
31 settingsChanged(); 32 settingsChanged();
33 m_field->setFocus();
34 m_field->setActiveWindow();
32} 35}
33 36
34void IRCQueryTab::scrolling(){ 37void IRCQueryTab::scrolling(){
35 m_textview->ensureVisible(0, m_textview->contentsHeight()); 38 m_textview->ensureVisible(0, m_textview->contentsHeight());
diff --git a/noncore/net/opieirc/ircserverlist.cpp b/noncore/net/opieirc/ircserverlist.cpp
index 62bfc17..3e78469 100644
--- a/noncore/net/opieirc/ircserverlist.cpp
+++ b/noncore/net/opieirc/ircserverlist.cpp
@@ -81,8 +81,13 @@ IRCServerList::IRCServerList(QWidget* parent, const char *name, bool modal, WFla
81 } 81 }
82 } 82 }
83 } 83 }
84 84
85 connect(m_list, SIGNAL(doubleClicked(QListBoxItem*)),
86 this, SLOT(acceptOnClick(QListBoxItem *)));
87 connect(m_list, SIGNAL(returnPressed(QListBoxItem*)),
88 this, SLOT(acceptOnClick(QListBoxItem*)));
89
85 QPEApplication::showDialog( this ); 90 QPEApplication::showDialog( this );
86} 91}
87 92
88void IRCServerList::addServer() 93void IRCServerList::addServer()
@@ -121,8 +126,12 @@ void IRCServerList::editServer()
121 } 126 }
122 } 127 }
123} 128}
124 129
130void IRCServerList::acceptOnClick( QListBoxItem* ) {
131 accept();
132}
133
125int IRCServerList::exec() 134int IRCServerList::exec()
126{ 135{
127 int returncode = QDialog::exec(); 136 int returncode = QDialog::exec();
128 /* Now save the changes */ 137 /* Now save the changes */
diff --git a/noncore/net/opieirc/ircserverlist.h b/noncore/net/opieirc/ircserverlist.h
index d61210e..869b26f 100644
--- a/noncore/net/opieirc/ircserverlist.h
+++ b/noncore/net/opieirc/ircserverlist.h
@@ -35,14 +35,15 @@ public:
35 /* Check whether a server was selected */ 35 /* Check whether a server was selected */
36 bool hasServer(); 36 bool hasServer();
37 /* Return the selected server */ 37 /* Return the selected server */
38 IRCServer server(); 38 IRCServer server();
39 39
40 ~IRCServerList(); 40 ~IRCServerList();
41public slots: 41public slots:
42 void addServer(); 42 void addServer();
43 void delServer(); 43 void delServer();
44 void editServer(); 44 void editServer();
45 void acceptOnClick(QListBoxItem*);
45protected: 46protected:
46 Config *m_config; 47 Config *m_config;
47 QListBox *m_list; 48 QListBox *m_list;
48}; 49};
diff --git a/noncore/net/opieirc/ircservertab.cpp b/noncore/net/opieirc/ircservertab.cpp
index 2a34c0b..5ca7a29 100644
--- a/noncore/net/opieirc/ircservertab.cpp
+++ b/noncore/net/opieirc/ircservertab.cpp
@@ -3,9 +3,10 @@
3#include "ircservertab.h" 3#include "ircservertab.h"
4 4
5 5
6bool IRCServerTab::containsPing( const QString& text, IRCServerTab* tab ) { 6bool IRCServerTab::containsPing( const QString& text, IRCServerTab* tab ) {
7 return (text.find("ping") != -1 && text.find( tab->server()->nick() != -1)); 7 return (text.contains(IRCMessageParser::tr("Received a CTCP PING from "))) ||
8 (text.find("ping") != -1 && text.find( tab->server()->nick() != -1));
8} 9}
9 10
10 11
11IRCServerTab::IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) { 12IRCServerTab::IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) {
@@ -29,12 +30,15 @@ IRCServerTab::IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *pa
29 30
30 QWhatsThis::add(m_field, tr("Type commands here. A list of available commands can be found inside the OpieIRC help")); 31 QWhatsThis::add(m_field, tr("Type commands here. A list of available commands can be found inside the OpieIRC help"));
31 m_layout->add(m_field); 32 m_layout->add(m_field);
32 connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); 33 connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand()));
33 m_field->setFocus();
34 connect(m_session, SIGNAL(outputReady(IRCOutput)), this, SLOT(display(IRCOutput))); 34 connect(m_session, SIGNAL(outputReady(IRCOutput)), this, SLOT(display(IRCOutput)));
35 connect(m_mainWindow, SIGNAL(updateScroll()), this, SLOT(scrolling())); 35 connect(m_mainWindow, SIGNAL(updateScroll()), this, SLOT(scrolling()));
36 settingsChanged(); 36 settingsChanged();
37
38 m_field->setFocus();
39 m_field->setActiveWindow();
40
37} 41}
38 42
39void IRCServerTab::scrolling(){ 43void IRCServerTab::scrolling(){
40 m_textview->ensureVisible(0, m_textview->contentsHeight()); 44 m_textview->ensureVisible(0, m_textview->contentsHeight());
@@ -42,9 +46,12 @@ void IRCServerTab::scrolling(){
42 46
43 47
44void IRCServerTab::appendText(QString text) { 48void IRCServerTab::appendText(QString text) {
45 /* not using append because it creates layout problems */ 49 /* not using append because it creates layout problems */
46 QString txt = m_textview->text() + text + "\n"; 50 QString txt = m_textview->text() + IRCTab::appendTimestamp( text );
51
52
53
47 if (m_maxLines > 0 && m_lines >= m_maxLines) { 54 if (m_maxLines > 0 && m_lines >= m_maxLines) {
48 int firstBreak = txt.find('\n'); 55 int firstBreak = txt.find('\n');
49 if (firstBreak != -1) { 56 if (firstBreak != -1) {
50 txt = "<qt bgcolor=\"" + m_backgroundColor + "\"/>" + txt.right(txt.length() - (firstBreak + 1)); 57 txt = "<qt bgcolor=\"" + m_backgroundColor + "\"/>" + txt.right(txt.length() - (firstBreak + 1));
@@ -233,13 +240,13 @@ void IRCServerTab::remove() {
233 } else { 240 } else {
234 /* Session has previously been closed */ 241 /* Session has previously been closed */
235 m_channelTabs.first(); 242 m_channelTabs.first();
236 while (m_channelTabs.current() != 0) { 243 while (m_channelTabs.current() != 0) {
237 m_mainWindow->killTab(m_channelTabs.current()); 244 m_mainWindow->killTab(m_channelTabs.current(), true);
238 } 245 }
239 m_queryTabs.first(); 246 m_queryTabs.first();
240 while (m_queryTabs.current() != 0) { 247 while (m_queryTabs.current() != 0) {
241 m_mainWindow->killTab(m_queryTabs.current()); 248 m_mainWindow->killTab(m_queryTabs.current(), true);
242 } 249 }
243 m_mainWindow->killTab(this); 250 m_mainWindow->killTab(this);
244 } 251 }
245} 252}
@@ -271,13 +278,13 @@ void IRCServerTab::display(IRCOutput output) {
271 case OUTPUT_CONNCLOSE: 278 case OUTPUT_CONNCLOSE:
272 if (m_close) { 279 if (m_close) {
273 m_channelTabs.first(); 280 m_channelTabs.first();
274 while (m_channelTabs.current() != 0) { 281 while (m_channelTabs.current() != 0) {
275 m_mainWindow->killTab(m_channelTabs.current()); 282 m_mainWindow->killTab(m_channelTabs.current(), true);
276 } 283 }
277 m_queryTabs.first(); 284 m_queryTabs.first();
278 while (m_queryTabs.current() != 0) { 285 while (m_queryTabs.current() != 0) {
279 m_mainWindow->killTab(m_queryTabs.current()); 286 m_mainWindow->killTab(m_queryTabs.current(), true);
280 } 287 }
281 m_mainWindow->killTab(this); 288 m_mainWindow->killTab(this);
282 } else { 289 } else {
283 appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() +"</font><br>"); 290 appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() +"</font><br>");
@@ -311,16 +318,16 @@ void IRCServerTab::display(IRCOutput output) {
311 break; 318 break;
312 case OUTPUT_SELFPART: { 319 case OUTPUT_SELFPART: {
313 IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); 320 IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0));
314 if (channelTab) 321 if (channelTab)
315 m_mainWindow->killTab(channelTab); 322 m_mainWindow->killTab(channelTab, true);
316 } 323 }
317 break; 324 break;
318 case OUTPUT_SELFKICK: { 325 case OUTPUT_SELFKICK: {
319 appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() + "</font><br>"); 326 appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() + "</font><br>");
320 IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); 327 IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0));
321 if (channelTab) 328 if (channelTab)
322 m_mainWindow->killTab(channelTab); 329 m_mainWindow->killTab(channelTab, true);
323 } 330 }
324 break; 331 break;
325 case OUTPUT_CHANACTION: { 332 case OUTPUT_CHANACTION: {
326 IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); 333 IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0));
diff --git a/noncore/net/opieirc/ircsettings.cpp b/noncore/net/opieirc/ircsettings.cpp
index 1fba030..7a1dd6c 100644
--- a/noncore/net/opieirc/ircsettings.cpp
+++ b/noncore/net/opieirc/ircsettings.cpp
@@ -11,8 +11,9 @@
11 11
12/* QT */ 12/* QT */
13#include <qvalidator.h> 13#include <qvalidator.h>
14#include <qwhatsthis.h> 14#include <qwhatsthis.h>
15#include <qcheckbox.h>
15 16
16using namespace Opie; 17using namespace Opie;
17using namespace Opie::Ui; 18using namespace Opie::Ui;
18IRCSettings::IRCSettings(QWidget* parent, const char* name, bool modal, WFlags) : QDialog(parent, name, modal, WStyle_ContextHelp) 19IRCSettings::IRCSettings(QWidget* parent, const char* name, bool modal, WFlags) : QDialog(parent, name, modal, WStyle_ContextHelp)
@@ -24,9 +25,9 @@ IRCSettings::IRCSettings(QWidget* parent, const char* name, bool modal, WFlags)
24 OTabWidget *tw = new OTabWidget(this); 25 OTabWidget *tw = new OTabWidget(this);
25 l->addWidget(tw); 26 l->addWidget(tw);
26 /* General Configuration */ 27 /* General Configuration */
27 QWidget *genwidget = new QWidget(tw); 28 QWidget *genwidget = new QWidget(tw);
28 QGridLayout *layout = new QGridLayout(genwidget, 1, 2, 5, 0); 29 QGridLayout *layout = new QGridLayout(genwidget, 1, 4, 5, 0);
29 QLabel *label = new QLabel(tr("Lines displayed :"), genwidget); 30 QLabel *label = new QLabel(tr("Lines displayed :"), genwidget);
30 layout->addWidget(label, 0, 0); 31 layout->addWidget(label, 0, 0);
31 m_lines = new QLineEdit(m_config->readEntry("Lines", "100"), genwidget); 32 m_lines = new QLineEdit(m_config->readEntry("Lines", "100"), genwidget);
32 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")); 33 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"));
@@ -34,8 +35,21 @@ IRCSettings::IRCSettings(QWidget* parent, const char* name, bool modal, WFlags)
34 validator->setTop(10000); 35 validator->setTop(10000);
35 validator->setBottom(0); 36 validator->setBottom(0);
36 m_lines->setValidator(validator); 37 m_lines->setValidator(validator);
37 layout->addWidget(m_lines, 0, 1); 38 layout->addWidget(m_lines, 0, 1);
39
40 /*
41 * include timestamp
42 */
43 m_displayTime = new QCheckBox( tr("Display time in chat log"), genwidget );
44 m_displayTime->setChecked( m_config->readBoolEntry("DisplayTime", false) );
45 layout->addMultiCellWidget(m_displayTime, 1, 1, 0, 4 );
46
47 // add a spacer
48 layout->addItem( new QSpacerItem(1,1, QSizePolicy::Minimum,
49 QSizePolicy::MinimumExpanding),
50 2, 0 );
51
38 tw->addTab(genwidget, "opieirc/settings", tr("General")); 52 tw->addTab(genwidget, "opieirc/settings", tr("General"));
39 53
40 /* Color configuration */ 54 /* Color configuration */
41 QScrollView *view = new QScrollView(this); 55 QScrollView *view = new QScrollView(this);
@@ -116,8 +130,10 @@ void IRCSettings::accept()
116 m_config->writeEntry("OtherColor", IRCTab::m_otherColor); 130 m_config->writeEntry("OtherColor", IRCTab::m_otherColor);
117 m_config->writeEntry("ServerColor", IRCTab::m_serverColor); 131 m_config->writeEntry("ServerColor", IRCTab::m_serverColor);
118 m_config->writeEntry("NotificationColor", IRCTab::m_notificationColor); 132 m_config->writeEntry("NotificationColor", IRCTab::m_notificationColor);
119 m_config->writeEntry("Lines", m_lines->text()); 133 m_config->writeEntry("Lines", m_lines->text());
134 m_config->writeEntry("DisplayTime", m_displayTime->isChecked() );
135 IRCTab::setUseTimeStamps(m_displayTime->isChecked());
120 IRCHistoryLineEdit::keyConfigInstance()->save(); 136 IRCHistoryLineEdit::keyConfigInstance()->save();
121 137
122 QDialog::accept(); 138 QDialog::accept();
123} 139}
diff --git a/noncore/net/opieirc/ircsettings.h b/noncore/net/opieirc/ircsettings.h
index a032aff..b51d535 100644
--- a/noncore/net/opieirc/ircsettings.h
+++ b/noncore/net/opieirc/ircsettings.h
@@ -31,8 +31,9 @@ namespace Ui {
31class OKeyConfigWidget; 31class OKeyConfigWidget;
32} 32}
33} 33}
34 34
35class QCheckBox;
35class IRCSettings : public QDialog { 36class IRCSettings : public QDialog {
36 Q_OBJECT 37 Q_OBJECT
37public: 38public:
38 IRCSettings(QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags f = 0); 39 IRCSettings(QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags f = 0);
@@ -49,7 +50,8 @@ protected:
49 Opie::OColorButton *m_other; 50 Opie::OColorButton *m_other;
50 Opie::OColorButton *m_notification; 51 Opie::OColorButton *m_notification;
51 Opie::Ui::OKeyConfigWidget *m_keyConf; 52 Opie::Ui::OKeyConfigWidget *m_keyConf;
52 QLineEdit *m_lines; 53 QLineEdit *m_lines;
54 QCheckBox *m_displayTime;
53}; 55};
54 56
55#endif /* __IRCSETTINGS_H */ 57#endif /* __IRCSETTINGS_H */
diff --git a/noncore/net/opieirc/irctab.cpp b/noncore/net/opieirc/irctab.cpp
index 2b3ecd4..fbbf303 100644
--- a/noncore/net/opieirc/irctab.cpp
+++ b/noncore/net/opieirc/irctab.cpp
@@ -17,8 +17,24 @@ QString IRCTab::m_selfColor;
17QString IRCTab::m_otherColor; 17QString IRCTab::m_otherColor;
18QString IRCTab::m_notificationColor; 18QString IRCTab::m_notificationColor;
19int IRCTab::m_maxLines; 19int IRCTab::m_maxLines;
20 20
21
22static bool g_useTime = false;
23
24void IRCTab::setUseTimeStamps( bool b ) {
25 g_useTime = b;
26}
27
28// ## FIXME use TimeString later for AM/PM Setting
29QString IRCTab::appendTimestamp( const QString& text ) {
30 return g_useTime ?
31 "[" +QTime::currentTime().toString()+"]" + text + "\n" :
32 text + "\n";
33
34}
35
36
21IRCTab::IRCTab(QWidget *parent, const char *name, WFlags f) : QWidget(parent, name, f) { 37IRCTab::IRCTab(QWidget *parent, const char *name, WFlags f) : QWidget(parent, name, f) {
22 m_layout = new QVBoxLayout(this); 38 m_layout = new QVBoxLayout(this);
23 QHBoxLayout *descLayout = new QHBoxLayout(m_layout); 39 QHBoxLayout *descLayout = new QHBoxLayout(m_layout);
24 descLayout->setMargin(5); 40 descLayout->setMargin(5);
diff --git a/noncore/net/opieirc/irctab.h b/noncore/net/opieirc/irctab.h
index 6c29ea5..d17c530 100644
--- a/noncore/net/opieirc/irctab.h
+++ b/noncore/net/opieirc/irctab.h
@@ -37,8 +37,12 @@ public:
37 IRCTab(QWidget *parent = 0, const char *name = 0, WFlags f = 0); 37 IRCTab(QWidget *parent = 0, const char *name = 0, WFlags f = 0);
38 /* The ID is required to store the position of this IRCTab inside the IRCTabWidget */ 38 /* The ID is required to store the position of this IRCTab inside the IRCTabWidget */
39 void setID(int id); 39 void setID(int id);
40 int id(); 40 int id();
41
42 static void setUseTimeStamps(bool b);
43 static QString appendTimestamp(const QString& tex);
44
41 virtual QString title() = 0; 45 virtual QString title() = 0;
42 virtual IRCSession *session() = 0; 46 virtual IRCSession *session() = 0;
43 virtual void appendText(QString text) = 0; 47 virtual void appendText(QString text) = 0;
44signals: 48signals:
diff --git a/noncore/net/opieirc/mainwindow.cpp b/noncore/net/opieirc/mainwindow.cpp
index 2e674c5..2562f33 100644
--- a/noncore/net/opieirc/mainwindow.cpp
+++ b/noncore/net/opieirc/mainwindow.cpp
@@ -47,8 +47,9 @@ void MainWindow::loadSettings() {
47 IRCTab::m_otherColor = config.readEntry("OtherColor", "#0000BB"); 47 IRCTab::m_otherColor = config.readEntry("OtherColor", "#0000BB");
48 IRCTab::m_serverColor = config.readEntry("ServerColor", "#0000FF"); 48 IRCTab::m_serverColor = config.readEntry("ServerColor", "#0000FF");
49 IRCTab::m_notificationColor = config.readEntry("NotificationColor", "#AA3300"); 49 IRCTab::m_notificationColor = config.readEntry("NotificationColor", "#AA3300");
50 IRCTab::m_maxLines = config.readNumEntry("Lines", 100); 50 IRCTab::m_maxLines = config.readNumEntry("Lines", 100);
51 IRCTab::setUseTimeStamps( config.readBoolEntry("DisplayTime", false ) );
51} 52}
52 53
53void MainWindow::selected(QWidget *) { 54void MainWindow::selected(QWidget *) {
54 m_tabWidget->setTabColor(m_tabWidget->currentPageIndex(), black); 55 m_tabWidget->setTabColor(m_tabWidget->currentPageIndex(), black);
@@ -59,9 +60,8 @@ void MainWindow::addTab(IRCTab *tab) {
59 connect(tab, SIGNAL(changed(IRCTab*)), this, SLOT(changeEvent(IRCTab*))); 60 connect(tab, SIGNAL(changed(IRCTab*)), this, SLOT(changeEvent(IRCTab*)));
60 connect(tab, SIGNAL(ping (const QString&)), this, SLOT(slotPing(const QString&))); 61 connect(tab, SIGNAL(ping (const QString&)), this, SLOT(slotPing(const QString&)));
61 connect(tab, SIGNAL(nextTab()), this, SLOT(slotNextTab())); 62 connect(tab, SIGNAL(nextTab()), this, SLOT(slotNextTab()));
62 connect(tab, SIGNAL(prevTab()), this, SLOT(slotPrevTab())); 63 connect(tab, SIGNAL(prevTab()), this, SLOT(slotPrevTab()));
63 connect(tab, SIGNAL(closeTab()), this, SLOT(slotCloseTab()));
64 64
65 m_tabWidget->addTab(tab, tab->title()); 65 m_tabWidget->addTab(tab, tab->title());
66 m_tabWidget->showPage(tab); 66 m_tabWidget->showPage(tab);
67 tab->setID(m_tabWidget->currentPageIndex()); 67 tab->setID(m_tabWidget->currentPageIndex());
@@ -72,14 +72,26 @@ void MainWindow::changeEvent(IRCTab *tab) {
72 if (tab->id() != m_tabWidget->currentPageIndex()) 72 if (tab->id() != m_tabWidget->currentPageIndex())
73 m_tabWidget->setTabColor(tab->id(), blue); 73 m_tabWidget->setTabColor(tab->id(), blue);
74} 74}
75 75
76void MainWindow::killTab(IRCTab *tab) { 76void MainWindow::killTab(IRCTab *tab, bool imediate) {
77 m_tabWidget->removePage(tab); 77 m_toDelete.append( tab );
78 m_tabs.remove(tab);
79 78
80 /* there might be nicer ways to do this .. */ 79 if ( imediate )
81 delete tab; 80 slotKillTabsLater();
81 else
82 QTimer::singleShot(0, this, SLOT(slotKillTabsLater()) );
83}
84
85void MainWindow::slotKillTabsLater() {
86 for ( QListIterator<IRCTab> it(m_toDelete); it.current(); ++it ) {
87 m_tabWidget->removePage( it.current() );
88 m_tabs.remove( it.current() );
89 }
90
91 m_toDelete.setAutoDelete( true );
92 m_toDelete.clear();
93 m_toDelete.setAutoDelete( false );
82} 94}
83 95
84void MainWindow::newConnection() { 96void MainWindow::newConnection() {
85 IRCServerList list(this, "ServerList", TRUE); 97 IRCServerList list(this, "ServerList", TRUE);
@@ -116,14 +128,8 @@ void MainWindow::slotPrevTab() {
116 if ( i > 1 ) 128 if ( i > 1 )
117 m_tabWidget->setCurrentPage ( i-1 ); 129 m_tabWidget->setCurrentPage ( i-1 );
118} 130}
119 131
120void MainWindow::slotCloseTab() { 132void MainWindow::slotPing( const QString& /*channel*/ ) {
121 IRCTab *tab = (IRCTab *) m_tabWidget->currentPage ();
122 if ( tab )
123 killTab ( tab );
124}
125
126void MainWindow::slotPing( const QString& channel ) {
127 raise(); 133 raise();
128} 134}
129 135
diff --git a/noncore/net/opieirc/mainwindow.h b/noncore/net/opieirc/mainwindow.h
index 945fc71..abf205d 100644
--- a/noncore/net/opieirc/mainwindow.h
+++ b/noncore/net/opieirc/mainwindow.h
@@ -33,9 +33,9 @@ class MainWindow : public QMainWindow {
33public: 33public:
34 MainWindow(QWidget *parent = 0, const char *name = 0, WFlags f = 0); 34 MainWindow(QWidget *parent = 0, const char *name = 0, WFlags f = 0);
35// IRCTabWidget getTabWidget(); 35// IRCTabWidget getTabWidget();
36 void addTab(IRCTab *tab); 36 void addTab(IRCTab *tab);
37 void killTab(IRCTab *tab); 37 void killTab(IRCTab *tab, bool now = false);
38 static QString appName() { return QString::fromLatin1("opieirc"); } 38 static QString appName() { return QString::fromLatin1("opieirc"); }
39 static QString appCaption(); 39 static QString appCaption();
40signals: 40signals:
41 void updateScroll(); 41 void updateScroll();
@@ -45,16 +45,17 @@ protected slots:
45 void selected(QWidget *); 45 void selected(QWidget *);
46 void changeEvent(IRCTab *); 46 void changeEvent(IRCTab *);
47 47
48 void slotNextTab(); 48 void slotNextTab();
49 void slotPrevTab(); 49 void slotPrevTab();
50 void slotCloseTab();
51 void slotPing(const QString&); 50 void slotPing(const QString&);
51 void slotKillTabsLater();
52 52
53protected: 53protected:
54 void loadSettings(); 54 void loadSettings();
55protected: 55protected:
56 IRCTabWidget *m_tabWidget; 56 IRCTabWidget *m_tabWidget;
57 QList<IRCTab> m_tabs; 57 QList<IRCTab> m_tabs;
58 QList<IRCTab> m_toDelete;
58}; 59};
59 60
60#endif /* __MAINWINDOW_H */ 61#endif /* __MAINWINDOW_H */