summaryrefslogtreecommitdiff
path: root/noncore/net/opieirc
authorzecke <zecke>2004-09-08 21:51:06 (UTC)
committer zecke <zecke>2004-09-08 21:51:06 (UTC)
commitebb830522c9662bda4c4453e532bcc29631c5d60 (patch) (side-by-side diff)
tree5cf95975e91cb2db78be5cdf47c01a340109c1f4 /noncore/net/opieirc
parentf0fdb800d57e9a1d95ba593185e9462300539eea (diff)
downloadopie-ebb830522c9662bda4c4453e532bcc29631c5d60.zip
opie-ebb830522c9662bda4c4453e532bcc29631c5d60.tar.gz
opie-ebb830522c9662bda4c4453e532bcc29631c5d60.tar.bz2
-Close Tab Keyboard Accelerator with delayed deletion of the tab
-Optionally add a TimeStamp to the Tab -Remove not implemented CTCP actions from the Channel PopupMenu -Give Focus to the Edit Line -Some more ping handling patch inspired and copied from zautrix fork
Diffstat (limited to 'noncore/net/opieirc') (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 @@
Makefile
Makefile.in
moc_*.cpp
-.moc \ No newline at end of file
+.moc
+*.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
@@ -15,6 +15,7 @@ IRCChannelTab::IRCChannelTab(IRCChannel *channel, IRCServerTab *parentTab, MainW
m_textview->setVScrollBarMode(QScrollView::AlwaysOn);
m_listVisible = TRUE;
m_listButton = new QPushButton(">", m_textview);
+ m_listButton->setFlat( true );
m_textview->setCornerWidget(m_listButton);
m_textview->setTextFormat(RichText);
QWhatsThis::add(m_textview, tr("Channel discussion"));
@@ -25,7 +26,7 @@ IRCChannelTab::IRCChannelTab(IRCChannel *channel, IRCServerTab *parentTab, MainW
m_field = new IRCHistoryLineEdit(this);
connect(m_field, SIGNAL(nextTab()), this, SIGNAL(nextTab()));
connect(m_field, SIGNAL(prevTab()), this, SIGNAL(prevTab()));
- connect(m_field, SIGNAL(closeTab()), this, SIGNAL(closeTab()));
+ connect(m_field, SIGNAL(closeTab()), this, SLOT(remove()));
connect(this, SIGNAL(editFocus()), m_field, SLOT(setEditFocus()));
QWhatsThis::add(m_field, tr("Type your message here to participate in the channel discussion"));
@@ -36,7 +37,6 @@ IRCChannelTab::IRCChannelTab(IRCChannel *channel, IRCServerTab *parentTab, MainW
connect(m_list, SIGNAL(mouseButtonPressed(int,QListBoxItem*,const QPoint&)), this, SLOT(mouseButtonPressed(int,QListBoxItem*,const QPoint&)));
/* Construct the popup menu */
QPopupMenu *ctcpMenu = new QPopupMenu(m_list);
- m_popup->insertItem(Resource::loadPixmap("opieirc/ctcp"), tr("CTCP"), ctcpMenu);
m_popup->insertItem(Resource::loadPixmap("opieirc/query"), tr("Query"), this, SLOT(popupQuery()));
ctcpMenu->insertItem(Resource::loadPixmap("opieirc/ping"), tr("Ping"), this, SLOT(popupPing()));
ctcpMenu->insertItem(Resource::loadPixmap("opieirc/version"), tr("Version"), this, SLOT(popupVersion()));
@@ -49,6 +49,7 @@ IRCChannelTab::IRCChannelTab(IRCChannel *channel, IRCServerTab *parentTab, MainW
m_field->setActiveWindow();
connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand()));
+ connect(m_list, SIGNAL(doubleClicked ( QListBoxItem * ) ), this, SLOT(popupQuery( QListBoxItem * ) ));
settingsChanged();
}
@@ -58,7 +59,7 @@ void IRCChannelTab::scrolling(){
void IRCChannelTab::appendText(QString text) {
/* not using append because it creates layout problems */
- QString txt = m_textview->text() + text + "\n";
+ QString txt = m_textview->text() + IRCTab::appendTimestamp( text );
if (m_maxLines > 0 && m_lines >= m_maxLines) {
int firstBreak = txt.find('\n');
if (firstBreak != -1) {
@@ -72,7 +73,9 @@ void IRCChannelTab::appendText(QString text) {
m_textview->ensureVisible(0, m_textview->contentsHeight());
int p1, p2;
- if ( (p1 = text.find("ping", 0, false) )!= -1 && (p2 = text.find( m_parentTab->server()->nick(), 0,false )) != -1 ) {
+ if ( text.contains( IRCMessageParser::tr("Received a CTCP PING from ") ) )
+ emit ping( title() );
+ else if ( (p1 = text.find("ping", 0, false) )!= -1 && (p2 = text.find( m_parentTab->server()->nick(), 0,false )) != -1 ) {
int col = text.findRev("color", -1, false);
if ( col < p2 )
emit ping( title() );
@@ -132,9 +135,9 @@ void IRCChannelTab::mouseButtonPressed(int mouse, QListBoxItem *, const QPoint &
};
}
-void IRCChannelTab::popupQuery() {
- if (m_list->currentItem() != -1) {
- IRCPerson *person = session()->getPerson(m_list->item(m_list->currentItem())->text());
+void IRCChannelTab::popupQuery( QListBoxItem *item) {
+ if (item) {
+ IRCPerson *person = session()->getPerson(item->text());
if (person) {
IRCQueryTab *tab = m_parentTab->getTabForQuery(person);
if (!tab) {
@@ -146,6 +149,11 @@ void IRCChannelTab::popupQuery() {
}
}
+void IRCChannelTab::popupQuery() {
+ if ( m_list->currentItem() != -1 )
+ popupQuery( m_list->item(m_list->currentItem()));
+}
+
void IRCChannelTab::popupPing() {
//HAHA, no wonder these don't work
}
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
@@ -53,7 +53,9 @@ protected slots:
void toggleList();
void mouseButtonPressed(int mouse, QListBoxItem *item, const QPoint &point);
/* Popup slots */
+ void popupQuery(QListBoxItem*);
void popupQuery();
+
void popupPing();
void popupVersion();
void popupWhois();
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
@@ -283,6 +283,40 @@ void IRCMessageParser::parseCTCPPing(IRCMessage *message) {
IRCPerson mask(message->prefix());
m_session->m_connection->sendCTCP(mask.nick(), "PING " + message->allParameters());
emit outputReady(IRCOutput(OUTPUT_CTCP, tr("Received a CTCP PING from ")+mask.nick()));
+
+ //IRCPerson mask(message->prefix());
+ QString dest = message->ctcpDestination();
+ if (dest.startsWith("#")) {
+ IRCChannel *channel = m_session->getChannel(dest.lower());
+ if (channel) {
+ IRCChannelPerson *person = channel->getPerson(mask.nick());
+ if (person) {
+ IRCOutput output(OUTPUT_CHANACTION, tr("Received a CTCP PING from ")+ mask.nick()) ;
+ output.addParam(channel);
+ output.addParam(person);
+ emit outputReady(output);
+ } else {
+ emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP PING with unknown person - Desynchronized?")));
+ }
+ } else {
+ emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP PING with unknown channel - Desynchronized?")));
+ }
+ } else {
+ if (message->ctcpDestination() == m_session->m_server->nick()) {
+ IRCPerson *person = m_session->getPerson(mask.nick());
+ if (!person) {
+ /* Person not yet known, create and add to the current session */
+ person = new IRCPerson(message->prefix());
+ m_session->addPerson(person);
+ }
+ IRCOutput output(OUTPUT_QUERYACTION, tr("Received a CTCP PING from ")+ mask.nick() );
+ output.addParam(person);
+ emit outputReady(output);
+ } else {
+ emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP PING with bad recipient")));
+ }
+ }
+
}
void IRCMessageParser::parseCTCPVersion(IRCMessage *message) {
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
@@ -67,6 +67,9 @@ OKeyConfigManager* IRCHistoryLineEdit::keyConfigInstance() {
KeyNextTab, OKeyPair(Qt::Key_N, Qt::ControlButton) ));
s_manager->addKeyConfig( OKeyConfigItem( tr("Previous Tab"), "prev_tab", QPixmap(),
KeyPrevTab, OKeyPair(Qt::Key_P, Qt::ControlButton) ));
+ s_manager->addKeyConfig( OKeyConfigItem( tr("Close Tab"), "close_tab",
+ QPixmap(), KeyCloseTab,
+ OKeyPair(Qt::Key_C, Qt::ControlButton) ));
s_manager->load();
}
@@ -107,6 +110,8 @@ void IRCHistoryLineEdit::keyPressEvent(QKeyEvent *event) {
case KeyPrevTab:
emit prevTab();
return;
+ case KeyCloseTab:
+ emit closeTab();
default:
break;
}
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
@@ -68,7 +68,8 @@ class IRCHistoryLineEdit : public QLineEdit {
public:
enum KeyMode {
KeyNextTab,
- KeyPrevTab
+ KeyPrevTab,
+ KeyCloseTab
};
static Opie::Core::OKeyConfigManager* keyConfigInstance();
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
@@ -16,19 +16,22 @@ IRCQueryTab::IRCQueryTab(IRCPerson *person, IRCServerTab *parentTab, MainWindow
m_textview->setTextFormat(RichText);
QWhatsThis::add(m_textview, tr("Private discussion"));
m_field = new IRCHistoryLineEdit(this);
+
connect(m_field, SIGNAL(nextTab()), this, SIGNAL(nextTab()));
connect(m_field, SIGNAL(prevTab()), this, SIGNAL(prevTab()));
- connect(m_field, SIGNAL(closeTab()),this, SIGNAL(closeTab()));
-
+ connect(m_field, SIGNAL(closeTab()),this, SLOT(remove()));
+ connect(this, SIGNAL(editFocus()), m_field, SLOT(setEditFocus()));
QWhatsThis::add(m_field, tr("Type your text here in order to send a message to the other person"));
m_layout->add(hbox);
hbox->show();
m_layout->add(m_field);
- m_field->setFocus();
+
connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand()));
connect(m_mainWindow, SIGNAL(updateScroll()), this, SLOT(scrolling()));
settingsChanged();
+ m_field->setFocus();
+ m_field->setActiveWindow();
}
void IRCQueryTab::scrolling(){
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
@@ -82,6 +82,11 @@ IRCServerList::IRCServerList(QWidget* parent, const char *name, bool modal, WFla
}
}
+ connect(m_list, SIGNAL(doubleClicked(QListBoxItem*)),
+ this, SLOT(acceptOnClick(QListBoxItem *)));
+ connect(m_list, SIGNAL(returnPressed(QListBoxItem*)),
+ this, SLOT(acceptOnClick(QListBoxItem*)));
+
QPEApplication::showDialog( this );
}
@@ -122,6 +127,10 @@ void IRCServerList::editServer()
}
}
+void IRCServerList::acceptOnClick( QListBoxItem* ) {
+ accept();
+}
+
int IRCServerList::exec()
{
int returncode = QDialog::exec();
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
@@ -36,12 +36,13 @@ public:
bool hasServer();
/* Return the selected server */
IRCServer server();
-
+
~IRCServerList();
public slots:
void addServer();
void delServer();
void editServer();
+ void acceptOnClick(QListBoxItem*);
protected:
Config *m_config;
QListBox *m_list;
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
@@ -4,7 +4,8 @@
bool IRCServerTab::containsPing( const QString& text, IRCServerTab* tab ) {
- return (text.find("ping") != -1 && text.find( tab->server()->nick() != -1));
+ return (text.contains(IRCMessageParser::tr("Received a CTCP PING from "))) ||
+ (text.find("ping") != -1 && text.find( tab->server()->nick() != -1));
}
@@ -30,10 +31,13 @@ IRCServerTab::IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *pa
QWhatsThis::add(m_field, tr("Type commands here. A list of available commands can be found inside the OpieIRC help"));
m_layout->add(m_field);
connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand()));
- m_field->setFocus();
connect(m_session, SIGNAL(outputReady(IRCOutput)), this, SLOT(display(IRCOutput)));
connect(m_mainWindow, SIGNAL(updateScroll()), this, SLOT(scrolling()));
settingsChanged();
+
+ m_field->setFocus();
+ m_field->setActiveWindow();
+
}
void IRCServerTab::scrolling(){
@@ -43,7 +47,10 @@ void IRCServerTab::scrolling(){
void IRCServerTab::appendText(QString text) {
/* not using append because it creates layout problems */
- QString txt = m_textview->text() + text + "\n";
+ QString txt = m_textview->text() + IRCTab::appendTimestamp( text );
+
+
+
if (m_maxLines > 0 && m_lines >= m_maxLines) {
int firstBreak = txt.find('\n');
if (firstBreak != -1) {
@@ -234,11 +241,11 @@ void IRCServerTab::remove() {
/* Session has previously been closed */
m_channelTabs.first();
while (m_channelTabs.current() != 0) {
- m_mainWindow->killTab(m_channelTabs.current());
+ m_mainWindow->killTab(m_channelTabs.current(), true);
}
m_queryTabs.first();
while (m_queryTabs.current() != 0) {
- m_mainWindow->killTab(m_queryTabs.current());
+ m_mainWindow->killTab(m_queryTabs.current(), true);
}
m_mainWindow->killTab(this);
}
@@ -272,11 +279,11 @@ void IRCServerTab::display(IRCOutput output) {
if (m_close) {
m_channelTabs.first();
while (m_channelTabs.current() != 0) {
- m_mainWindow->killTab(m_channelTabs.current());
+ m_mainWindow->killTab(m_channelTabs.current(), true);
}
m_queryTabs.first();
while (m_queryTabs.current() != 0) {
- m_mainWindow->killTab(m_queryTabs.current());
+ m_mainWindow->killTab(m_queryTabs.current(), true);
}
m_mainWindow->killTab(this);
} else {
@@ -312,14 +319,14 @@ void IRCServerTab::display(IRCOutput output) {
case OUTPUT_SELFPART: {
IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0));
if (channelTab)
- m_mainWindow->killTab(channelTab);
+ m_mainWindow->killTab(channelTab, true);
}
break;
case OUTPUT_SELFKICK: {
appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() + "</font><br>");
IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0));
if (channelTab)
- m_mainWindow->killTab(channelTab);
+ m_mainWindow->killTab(channelTab, true);
}
break;
case OUTPUT_CHANACTION: {
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
@@ -12,6 +12,7 @@
/* QT */
#include <qvalidator.h>
#include <qwhatsthis.h>
+#include <qcheckbox.h>
using namespace Opie;
using namespace Opie::Ui;
@@ -25,7 +26,7 @@ IRCSettings::IRCSettings(QWidget* parent, const char* name, bool modal, WFlags)
l->addWidget(tw);
/* General Configuration */
QWidget *genwidget = new QWidget(tw);
- QGridLayout *layout = new QGridLayout(genwidget, 1, 2, 5, 0);
+ QGridLayout *layout = new QGridLayout(genwidget, 1, 4, 5, 0);
QLabel *label = new QLabel(tr("Lines displayed :"), genwidget);
layout->addWidget(label, 0, 0);
m_lines = new QLineEdit(m_config->readEntry("Lines", "100"), genwidget);
@@ -35,6 +36,19 @@ IRCSettings::IRCSettings(QWidget* parent, const char* name, bool modal, WFlags)
validator->setBottom(0);
m_lines->setValidator(validator);
layout->addWidget(m_lines, 0, 1);
+
+ /*
+ * include timestamp
+ */
+ m_displayTime = new QCheckBox( tr("Display time in chat log"), genwidget );
+ m_displayTime->setChecked( m_config->readBoolEntry("DisplayTime", false) );
+ layout->addMultiCellWidget(m_displayTime, 1, 1, 0, 4 );
+
+ // add a spacer
+ layout->addItem( new QSpacerItem(1,1, QSizePolicy::Minimum,
+ QSizePolicy::MinimumExpanding),
+ 2, 0 );
+
tw->addTab(genwidget, "opieirc/settings", tr("General"));
/* Color configuration */
@@ -117,6 +131,8 @@ void IRCSettings::accept()
m_config->writeEntry("ServerColor", IRCTab::m_serverColor);
m_config->writeEntry("NotificationColor", IRCTab::m_notificationColor);
m_config->writeEntry("Lines", m_lines->text());
+ m_config->writeEntry("DisplayTime", m_displayTime->isChecked() );
+ IRCTab::setUseTimeStamps(m_displayTime->isChecked());
IRCHistoryLineEdit::keyConfigInstance()->save();
QDialog::accept();
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
@@ -32,6 +32,7 @@ class OKeyConfigWidget;
}
}
+class QCheckBox;
class IRCSettings : public QDialog {
Q_OBJECT
public:
@@ -50,6 +51,7 @@ protected:
Opie::OColorButton *m_notification;
Opie::Ui::OKeyConfigWidget *m_keyConf;
QLineEdit *m_lines;
+ QCheckBox *m_displayTime;
};
#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
@@ -18,6 +18,22 @@ QString IRCTab::m_otherColor;
QString IRCTab::m_notificationColor;
int IRCTab::m_maxLines;
+
+static bool g_useTime = false;
+
+void IRCTab::setUseTimeStamps( bool b ) {
+ g_useTime = b;
+}
+
+// ## FIXME use TimeString later for AM/PM Setting
+QString IRCTab::appendTimestamp( const QString& text ) {
+ return g_useTime ?
+ "[" +QTime::currentTime().toString()+"]" + text + "\n" :
+ text + "\n";
+
+}
+
+
IRCTab::IRCTab(QWidget *parent, const char *name, WFlags f) : QWidget(parent, name, f) {
m_layout = new QVBoxLayout(this);
QHBoxLayout *descLayout = new QHBoxLayout(m_layout);
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
@@ -38,6 +38,10 @@ public:
/* The ID is required to store the position of this IRCTab inside the IRCTabWidget */
void setID(int id);
int id();
+
+ static void setUseTimeStamps(bool b);
+ static QString appendTimestamp(const QString& tex);
+
virtual QString title() = 0;
virtual IRCSession *session() = 0;
virtual void appendText(QString text) = 0;
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
@@ -48,6 +48,7 @@ void MainWindow::loadSettings() {
IRCTab::m_serverColor = config.readEntry("ServerColor", "#0000FF");
IRCTab::m_notificationColor = config.readEntry("NotificationColor", "#AA3300");
IRCTab::m_maxLines = config.readNumEntry("Lines", 100);
+ IRCTab::setUseTimeStamps( config.readBoolEntry("DisplayTime", false ) );
}
void MainWindow::selected(QWidget *) {
@@ -60,7 +61,6 @@ void MainWindow::addTab(IRCTab *tab) {
connect(tab, SIGNAL(ping (const QString&)), this, SLOT(slotPing(const QString&)));
connect(tab, SIGNAL(nextTab()), this, SLOT(slotNextTab()));
connect(tab, SIGNAL(prevTab()), this, SLOT(slotPrevTab()));
- connect(tab, SIGNAL(closeTab()), this, SLOT(slotCloseTab()));
m_tabWidget->addTab(tab, tab->title());
m_tabWidget->showPage(tab);
@@ -73,12 +73,24 @@ void MainWindow::changeEvent(IRCTab *tab) {
m_tabWidget->setTabColor(tab->id(), blue);
}
-void MainWindow::killTab(IRCTab *tab) {
- m_tabWidget->removePage(tab);
- m_tabs.remove(tab);
+void MainWindow::killTab(IRCTab *tab, bool imediate) {
+ m_toDelete.append( tab );
- /* there might be nicer ways to do this .. */
- delete tab;
+ if ( imediate )
+ slotKillTabsLater();
+ else
+ QTimer::singleShot(0, this, SLOT(slotKillTabsLater()) );
+}
+
+void MainWindow::slotKillTabsLater() {
+ for ( QListIterator<IRCTab> it(m_toDelete); it.current(); ++it ) {
+ m_tabWidget->removePage( it.current() );
+ m_tabs.remove( it.current() );
+ }
+
+ m_toDelete.setAutoDelete( true );
+ m_toDelete.clear();
+ m_toDelete.setAutoDelete( false );
}
void MainWindow::newConnection() {
@@ -117,13 +129,7 @@ void MainWindow::slotPrevTab() {
m_tabWidget->setCurrentPage ( i-1 );
}
-void MainWindow::slotCloseTab() {
- IRCTab *tab = (IRCTab *) m_tabWidget->currentPage ();
- if ( tab )
- killTab ( tab );
-}
-
-void MainWindow::slotPing( const QString& channel ) {
+void MainWindow::slotPing( const QString& /*channel*/ ) {
raise();
}
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
@@ -34,7 +34,7 @@ public:
MainWindow(QWidget *parent = 0, const char *name = 0, WFlags f = 0);
// IRCTabWidget getTabWidget();
void addTab(IRCTab *tab);
- void killTab(IRCTab *tab);
+ void killTab(IRCTab *tab, bool now = false);
static QString appName() { return QString::fromLatin1("opieirc"); }
static QString appCaption();
signals:
@@ -46,15 +46,16 @@ protected slots:
void changeEvent(IRCTab *);
void slotNextTab();
- void slotPrevTab();
- void slotCloseTab();
+ void slotPrevTab();
void slotPing(const QString&);
+ void slotKillTabsLater();
protected:
void loadSettings();
protected:
IRCTabWidget *m_tabWidget;
QList<IRCTab> m_tabs;
+ QList<IRCTab> m_toDelete;
};
#endif /* __MAINWINDOW_H */