author | wazlaf <wazlaf> | 2002-09-11 22:22:04 (UTC) |
---|---|---|
committer | wazlaf <wazlaf> | 2002-09-11 22:22:04 (UTC) |
commit | 4864665ad76095620fdf5aa19d24f05967f32b40 (patch) (side-by-side diff) | |
tree | 4b3e371b5da03292ce09f7e388885dd3ec049ff8 | |
parent | 7ab82ad13aaf708ffba4bf4294d29b789007ddde (diff) | |
download | opie-4864665ad76095620fdf5aa19d24f05967f32b40.zip opie-4864665ad76095620fdf5aa19d24f05967f32b40.tar.gz opie-4864665ad76095620fdf5aa19d24f05967f32b40.tar.bz2 |
serverlist browser
-rw-r--r-- | noncore/net/opieirc/.cvsignore | 3 | ||||
-rw-r--r-- | noncore/net/opieirc/ircquerytab.cpp | 2 | ||||
-rw-r--r-- | noncore/net/opieirc/ircquerytab.h | 24 | ||||
-rw-r--r-- | noncore/net/opieirc/ircserver.cpp | 10 | ||||
-rw-r--r-- | noncore/net/opieirc/ircserver.h | 6 | ||||
-rw-r--r-- | noncore/net/opieirc/ircservereditor.cpp | 44 | ||||
-rw-r--r-- | noncore/net/opieirc/ircservereditor.h | 5 | ||||
-rw-r--r-- | noncore/net/opieirc/ircserverlist.cpp | 90 | ||||
-rw-r--r-- | noncore/net/opieirc/ircserverlist.h | 8 | ||||
-rw-r--r-- | noncore/net/opieirc/ircservertab.cpp | 9 | ||||
-rw-r--r-- | noncore/net/opieirc/ircservertab.h | 4 | ||||
-rw-r--r-- | noncore/net/opieirc/mainwindow.cpp | 19 | ||||
-rw-r--r-- | noncore/net/opieirc/opieirc.pro | 6 |
13 files changed, 171 insertions, 59 deletions
diff --git a/noncore/net/opieirc/.cvsignore b/noncore/net/opieirc/.cvsignore new file mode 100644 index 0000000..39391f4 --- a/dev/null +++ b/noncore/net/opieirc/.cvsignore @@ -0,0 +1,3 @@ +Makefile +Makefile.in +moc_*.cpp diff --git a/noncore/net/opieirc/ircquerytab.cpp b/noncore/net/opieirc/ircquerytab.cpp new file mode 100644 index 0000000..6d24845 --- a/dev/null +++ b/noncore/net/opieirc/ircquerytab.cpp @@ -0,0 +1,2 @@ +#include "ircquerytab.h" + diff --git a/noncore/net/opieirc/ircquerytab.h b/noncore/net/opieirc/ircquerytab.h new file mode 100644 index 0000000..fac976d --- a/dev/null +++ b/noncore/net/opieirc/ircquerytab.h @@ -0,0 +1,24 @@ +/* + OpieIRC - An embedded IRC client + Copyright (C) 2002 Wenzel Jakob + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*/ + +#ifndef __IRCQUERYTAB_H +#define __IRCQUERYTAB_H + +#endif /* __IRCQUERYTAB_H */ diff --git a/noncore/net/opieirc/ircserver.cpp b/noncore/net/opieirc/ircserver.cpp index 33a788b..e16e2b2 100644 --- a/noncore/net/opieirc/ircserver.cpp +++ b/noncore/net/opieirc/ircserver.cpp @@ -1,62 +1,62 @@ #include "ircserver.h" IRCServer::IRCServer() { - m_port = 0; + m_port = 6667; } void IRCServer::setHostname(QString hostname) { m_hostname = hostname; } -void IRCServer::setDescription(QString description) { - m_description = description; +void IRCServer::setName(QString name) { + m_name = name; } void IRCServer::setPort(int port) { m_port = port; } void IRCServer::setUsername(QString username) { m_username = username; } void IRCServer::setPassword(QString password) { m_password = password; } void IRCServer::setNick(QString nick) { m_nick = nick; } void IRCServer::setRealname(QString realname) { m_realname = realname; } QString IRCServer::hostname() { return m_hostname; } -QString IRCServer::description() { - return m_description; +QString IRCServer::name() { + return m_name; } unsigned short int IRCServer::port() { return m_port; } QString IRCServer::username() { return m_username; } QString IRCServer::password() { return m_password; } QString IRCServer::nick() { return m_nick; } QString IRCServer::realname() { return m_realname; } diff --git a/noncore/net/opieirc/ircserver.h b/noncore/net/opieirc/ircserver.h index 5f06c73..f56f231 100644 --- a/noncore/net/opieirc/ircserver.h +++ b/noncore/net/opieirc/ircserver.h @@ -1,58 +1,58 @@ /* OpieIRC - An embedded IRC client Copyright (C) 2002 Wenzel Jakob This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef __IRCSERVER_H #define __IRCSERVER_H #include <qstring.h> /* IRCServer stores all information required to establish a connection to a server. */ class IRCServer { public: IRCServer(); + void setName(QString name); void setHostname(QString hostname); - void setDescription(QString description); void setPort(int port); void setUsername(QString username); void setPassword(QString password); void setNick(QString nick); void setRealname(QString realname); QString hostname(); - QString description(); + QString name(); unsigned short int port(); QString username(); QString password(); QString nick(); QString realname(); protected: QString m_hostname; - QString m_description; + QString m_name; unsigned short int m_port; QString m_username; QString m_password; QString m_nick; QString m_realname; }; #endif /* __IRCSERVER_H */ diff --git a/noncore/net/opieirc/ircservereditor.cpp b/noncore/net/opieirc/ircservereditor.cpp index 1b157d6..798081f 100644 --- a/noncore/net/opieirc/ircservereditor.cpp +++ b/noncore/net/opieirc/ircservereditor.cpp @@ -1,49 +1,61 @@ +#include <qmessagebox.h> #include <qlayout.h> #include <qlabel.h> #include "ircservereditor.h" IRCServerEditor::IRCServerEditor(IRCServer server, QWidget* parent, const char* name, bool modal = FALSE, WFlags f) : QDialog(parent, name, modal, f) { QGridLayout *layout = new QGridLayout(this, 6, 2, 5, 5); - QLabel *label = new QLabel(tr("Hostname :"), this); - m_hostname = new QLineEdit(server.hostname(), this); + QLabel *label = new QLabel(tr("Profile name :"), this); + m_name = new QLineEdit(server.name(), this); layout->addWidget(label, 0, 0); - layout->addWidget(m_hostname, 0, 1); + layout->addWidget(m_name, 0, 1); + label = new QLabel(tr("Hostname :"), this); + m_hostname = new QLineEdit(server.hostname(), this); + layout->addWidget(label, 1, 0); + layout->addWidget(m_hostname, 1, 1); label = new QLabel(tr("Port :"), this); m_port = new QLineEdit(QString::number(server.port()), this); - layout->addWidget(label, 1, 0); - layout->addWidget(m_port, 1, 1); + layout->addWidget(label, 2, 0); + layout->addWidget(m_port, 2, 1); label = new QLabel(tr("Nickname :"), this); m_nickname = new QLineEdit(server.nick(), this); - layout->addWidget(label, 2, 0); - layout->addWidget(m_nickname, 2, 1); - label = new QLabel(tr("Description :"), this); - m_description = new QLineEdit(server.description(), this); layout->addWidget(label, 3, 0); - layout->addWidget(m_description, 3, 1); + layout->addWidget(m_nickname, 3, 1); label = new QLabel(tr("Realname :"), this); m_realname = new QLineEdit(server.realname(), this); layout->addWidget(label, 4, 0); layout->addWidget(m_realname, 4, 1); - label = new QLabel(tr("Username :"), this); - m_username = new QLineEdit(server.username(), this); - layout->addWidget(label, 3, 0); - layout->addWidget(m_username, 3, 1); label = new QLabel(tr("Password :"), this); m_password = new QLineEdit(server.password(), this); layout->addWidget(label, 5, 0); layout->addWidget(m_password, 5, 1); showMaximized(); } +void IRCServerEditor::accept() { + if (m_name->text().length()==0) + QMessageBox::critical(this, tr("Error"), tr("Profile name required")); + else if (m_hostname->text().length()==0) + QMessageBox::critical(this, tr("Error"), tr("Host name required")); + else if (m_port->text().toInt()<=0) + QMessageBox::critical(this, tr("Error"), tr("Port required")); + else if (m_nickname->text().length()==0) + QMessageBox::critical(this, tr("Error"), tr("Nickname required")); + else if (m_realname->text().length()==0) + QMessageBox::critical(this, tr("Error"), tr("Realname required")); + else + QDialog::accept(); +} + IRCServer IRCServerEditor::getServer() { IRCServer server; + server.setName(m_name->text()); server.setHostname(m_hostname->text()); server.setPort(m_port->text().toInt()); server.setNick(m_nickname->text()); - server.setDescription(m_description->text()); server.setRealname(m_realname->text()); - server.setUsername(m_username->text()); + server.setUsername(m_nickname->text()); server.setPassword(m_password->text()); return server; } diff --git a/noncore/net/opieirc/ircservereditor.h b/noncore/net/opieirc/ircservereditor.h index 86cdf32..20c94f7 100644 --- a/noncore/net/opieirc/ircservereditor.h +++ b/noncore/net/opieirc/ircservereditor.h @@ -1,43 +1,44 @@ /* OpieIRC - An embedded IRC client Copyright (C) 2002 Wenzel Jakob This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef __IRCSERVEREDITOR #define __IRCSERVEREDITOR #include <qdialog.h> #include <qlineedit.h> #include "ircserver.h" class IRCServerEditor : public QDialog { Q_OBJECT public: IRCServerEditor(IRCServer server, QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags f = 0); IRCServer getServer(); +protected slots: + void accept(); protected: + QLineEdit *m_name; QLineEdit *m_hostname; QLineEdit *m_port; - QLineEdit *m_description; QLineEdit *m_nickname; - QLineEdit *m_username; QLineEdit *m_password; QLineEdit *m_realname; }; #endif /* __IRCSERVEREDITOR_H */ diff --git a/noncore/net/opieirc/ircserverlist.cpp b/noncore/net/opieirc/ircserverlist.cpp index 964fa13..b2d746a 100644 --- a/noncore/net/opieirc/ircserverlist.cpp +++ b/noncore/net/opieirc/ircserverlist.cpp @@ -1,55 +1,131 @@ +#include <stdio.h> #include <qlayout.h> #include <qlabel.h> #include <qhbox.h> #include <qpushbutton.h> #include "ircserverlist.h" #include "ircservereditor.h" +#include <stdio.h> class IRCListBoxServer : public QListBoxText { public: - IRCListBoxServer(IRCServer server); - QString text(); + IRCListBoxServer(IRCServer server) : QListBoxText(server.name()) { + m_server = server; + } + + IRCServer server() { + return m_server; + } + + void setServer(IRCServer server) { + m_server = server; + setText(m_server.name()); + } +protected: + IRCServer m_server; }; IRCServerList::IRCServerList(QWidget* parent, const char *name, bool modal, WFlags f) : QDialog(parent, name, modal, f) { QVBoxLayout *layout = new QVBoxLayout(this, 5, 5); setCaption(tr("Serverlist Browser")); - m_config = new Config("OpieIRC"); - m_config->setGroup("OpieIRC"); QLabel *label = new QLabel(tr("Please choose a server profile"), this); + label->setAlignment(AlignHCenter); layout->addWidget(label); m_list = new QListBox(this); layout->addWidget(m_list); QHBox *buttons = new QHBox(this); QPushButton *del = new QPushButton(tr("Delete"), buttons); QPushButton *edit = new QPushButton(tr("Edit"), buttons); QPushButton *add = new QPushButton(tr("Add"), buttons); connect(del, SIGNAL(clicked()), this, SLOT(delServer())); connect(edit, SIGNAL(clicked()), this, SLOT(editServer())); connect(add, SIGNAL(clicked()), this, SLOT(addServer())); layout->addWidget(buttons); + /* Load the configuration file */ + m_config = new Config("OpieIRC"); + m_config->setGroup("OpieIRC"); + int count = m_config->readNumEntry("ServerCount", 0); + if (count) { + for (int i=0; i<count; i++) { + m_config->setGroup("OpieIRC"); + QString name = m_config->readEntry("Server"+QString::number(i)); + if (name.length() > 0) { + IRCServer server; + m_config->setGroup(name); + server.setName(name); + server.setHostname(m_config->readEntry("Hostname")); + server.setPort(m_config->readNumEntry("Port")); + server.setUsername(m_config->readEntry("Username")); + server.setPassword(m_config->readEntry("Password")); + server.setNick(m_config->readEntry("Nick")); + server.setRealname(m_config->readEntry("Realname")); + m_list->insertItem(new IRCListBoxServer(server)); + } + } + } + showMaximized(); } void IRCServerList::addServer() { IRCServer server; IRCServerEditor editor(server, this, "ServerEditor", TRUE); if (editor.exec() == QDialog::Accepted) { server = editor.getServer(); - //m_servers->append(server); - update(); + /* Gets deleted by QListBox, so this is ok */ + m_list->insertItem(new IRCListBoxServer(server)); } } void IRCServerList::delServer() { + int index = m_list->currentItem(); + if (index != -1) { + m_list->removeItem(index); + } } void IRCServerList::editServer() { + int index = m_list->currentItem(); + if (index != -1) { + IRCListBoxServer *item = (IRCListBoxServer *)m_list->item(index); + IRCServer server = item->server(); + IRCServerEditor editor(server, this, "ServerEditor", TRUE); + if (editor.exec() == QDialog::Accepted) { + server = editor.getServer(); + item->setServer(server); + } + } +} + +int IRCServerList::exec() { + int returncode = QDialog::exec(); + /* Now save the changes */ + m_config->setGroup("OpieIRC"); + m_config->clearGroup(); + m_config->writeEntry("ServerCount", QString::number(m_list->count())); + for (unsigned int i=0; i<m_list->count(); i++) { + IRCServer server = ((IRCListBoxServer *)m_list->item(i))->server(); + m_config->setGroup("OpieIRC"); + m_config->writeEntry("Server"+QString::number(i), server.name()); + m_config->setGroup(server.name()); + m_config->writeEntry("Hostname", server.hostname()); + m_config->writeEntry("Port", QString::number(server.port())); + m_config->writeEntry("Username", server.username()); + m_config->writeEntry("Password", server.password()); + m_config->writeEntry("Nick", server.nick()); + m_config->writeEntry("Realname", server.realname()); + } + return returncode; +} + +bool IRCServerList::hasServer() { + return (m_list->currentItem() != -1); } -void IRCServerList::update() { +IRCServer IRCServerList::server() { + return ((IRCListBoxServer *)m_list->item(m_list->currentItem()))->server(); } IRCServerList::~IRCServerList() { delete m_config; } diff --git a/noncore/net/opieirc/ircserverlist.h b/noncore/net/opieirc/ircserverlist.h index ad9231d..d61210e 100644 --- a/noncore/net/opieirc/ircserverlist.h +++ b/noncore/net/opieirc/ircserverlist.h @@ -1,46 +1,50 @@ /* OpieIRC - An embedded IRC client Copyright (C) 2002 Wenzel Jakob This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef __IRCSERVERLIST_H #define __IRCSERVERLIST_H #include <qdialog.h> #include <qpe/config.h> #include <qlistbox.h> #include <qlist.h> #include "ircserver.h" class IRCServerList : public QDialog { Q_OBJECT public: IRCServerList(QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags f = 0); + int exec(); + /* Check whether a server was selected */ + bool hasServer(); + /* Return the selected server */ + IRCServer server(); + ~IRCServerList(); public slots: void addServer(); void delServer(); void editServer(); protected: - void update(); -protected: Config *m_config; QListBox *m_list; }; #endif /* __IRCSERVERLIST_H */ diff --git a/noncore/net/opieirc/ircservertab.cpp b/noncore/net/opieirc/ircservertab.cpp index 1f377aa..724f4bd 100644 --- a/noncore/net/opieirc/ircservertab.cpp +++ b/noncore/net/opieirc/ircservertab.cpp @@ -1,97 +1,96 @@ #include <stdio.h> #include "ircservertab.h" -IRCServerTab::IRCServerTab(IRCServer *server, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) { +IRCServerTab::IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) { m_server = server; - m_session = new IRCSession(m_server); + m_session = new IRCSession(&m_server); m_mainWindow = mainWindow; m_close = FALSE; - m_description->setText(tr("Connection to")+" <b>" + server->hostname() + ":" + QString::number(server->port()) + "</b>"); + m_description->setText(tr("Connection to")+" <b>" + server.hostname() + ":" + QString::number(server.port()) + "</b>"); m_textview = new QTextView(this); m_textview->setHScrollBarMode(QScrollView::AlwaysOff); m_textview->setVScrollBarMode(QScrollView::AlwaysOn); m_layout->add(m_textview); m_field = new QLineEdit(this); 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))); } void IRCServerTab::appendText(QString text) { /* not using append because it creates layout problems */ m_textview->setText(m_textview->text() + text); m_textview->ensureVisible(0, m_textview->contentsHeight()); } IRCServerTab::~IRCServerTab() { QListIterator<IRCChannelTab> it(m_channelTabs); for (; it.current(); ++it) { m_mainWindow->killTab(it.current()); } delete m_session; - delete m_server; } void IRCServerTab::removeChannelTab(IRCChannelTab *tab) { m_channelTabs.remove(tab); } QString IRCServerTab::title() { return "Server"; } IRCSession *IRCServerTab::session() { return m_session; } IRCServer *IRCServerTab::server() { - return m_server; + return &m_server; } void IRCServerTab::processCommand() { m_field->clear(); appendText("<font color=\"#ff0000\">Not supported yet</font><br>"); } void IRCServerTab::doConnect() { m_session->beginSession(); } void IRCServerTab::remove() { if (m_session->isSessionActive()) { m_close = TRUE; m_session->endSession(); } else { m_mainWindow->killTab(this); } } IRCChannelTab *IRCServerTab::getTabForChannel(IRCChannel *channel) { QListIterator<IRCChannelTab> it(m_channelTabs); for (; it.current(); ++it) { if (it.current()->channel() == channel) return it.current(); } return 0; } void IRCServerTab::display(IRCOutput output) { switch (output.type()) { case OUTPUT_CONNCLOSE: if (m_close) m_mainWindow->killTab(this); else appendText("<font color=\"#0000dd\">" + output.message() +"</font><br>"); break; case OUTPUT_SELFJOIN: { IRCChannelTab *channeltab = new IRCChannelTab((IRCChannel *)output.getParam(0), this, m_mainWindow, (QWidget *)parent()); m_channelTabs.append(channeltab); m_mainWindow->addTab(channeltab); } break; case OUTPUT_CHANPRIVMSG: { IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); channelTab->appendText("<<font color=\"#0000dd\">"+((IRCChannelPerson *)output.getParam(1))->person->nick()+"</font>> "+output.message()+"<br>"); } diff --git a/noncore/net/opieirc/ircservertab.h b/noncore/net/opieirc/ircservertab.h index 79b5876..fa9a0a3 100644 --- a/noncore/net/opieirc/ircservertab.h +++ b/noncore/net/opieirc/ircservertab.h @@ -1,60 +1,60 @@ /* OpieIRC - An embedded IRC client Copyright (C) 2002 Wenzel Jakob This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef __IRCSERVERTAB_H #define __IRCSERVERTAB_H #include "irctab.h" #include "ircsession.h" #include "mainwindow.h" #include "ircchanneltab.h" class IRCServerTab : public IRCTab { Q_OBJECT public: /* IRCTab implementation */ - IRCServerTab(IRCServer *server, MainWindow *mainWindow, QWidget *parent = 0, const char *name = 0, WFlags f = 0); + IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *parent = 0, const char *name = 0, WFlags f = 0); ~IRCServerTab(); QString title(); IRCSession *session(); IRCServer *server(); /* Start the server session */ void doConnect(); void removeChannelTab(IRCChannelTab *tab); protected: void appendText(QString text); IRCChannelTab *getTabForChannel(IRCChannel *channel); public slots: void remove(); void processCommand(); protected slots: void display(IRCOutput output); protected: bool m_close; - IRCServer *m_server; + IRCServer m_server; IRCSession *m_session; MainWindow *m_mainWindow; QTextView *m_textview; QLineEdit *m_field; QList<IRCChannelTab> m_channelTabs; }; #endif /* __IRCSERVERTAB_H */ diff --git a/noncore/net/opieirc/mainwindow.cpp b/noncore/net/opieirc/mainwindow.cpp index bc0b0d1..3d13ee9 100644 --- a/noncore/net/opieirc/mainwindow.cpp +++ b/noncore/net/opieirc/mainwindow.cpp @@ -14,66 +14,55 @@ MainWindow::MainWindow(QWidget *parent, const char *name, WFlags f) : QMainWindo setCentralWidget(m_tabWidget); setToolBarsMovable(FALSE); QPEMenuBar *menuBar = new QPEMenuBar(this); QPopupMenu *irc = new QPopupMenu(this); menuBar->insertItem(tr("IRC"), irc); QAction *a = new QAction(tr("New connection"), Resource::loadPixmap("pass"), QString::null, 0, this, 0); connect(a, SIGNAL(activated()), this, SLOT(newConnection())); a->addTo(irc); m_joinAction = new QAction(tr("Join channel"), Resource::loadPixmap("forward"), QString::null, 0, this, 0); m_joinAction->setEnabled(FALSE); connect(m_joinAction, SIGNAL(activated()), this, SLOT(join())); m_joinAction->addTo(irc); } void MainWindow::tabSelected(QWidget *) { m_joinAction->setEnabled(TRUE); } void MainWindow::closeTab() { /* Does not directly close the tab but triggers an action which at some point will close the tab using a callback */ IRCTab *tab = (IRCTab *)m_tabWidget->currentPage(); if (tab) { tab->remove(); } } void MainWindow::join() { IRCTab *tab = (IRCTab *)m_tabWidget->currentPage(); if (tab) { tab->session()->join("#opie.de"); } } void MainWindow::addTab(IRCTab *tab) { m_tabWidget->addTab(tab, tab->title()); m_tabWidget->showPage(tab); tabSelected(tab); } void MainWindow::killTab(IRCTab *tab) { m_tabWidget->removePage(tab); /* there might be nicer ways to do this .. */ delete tab; } void MainWindow::newConnection() { - IRCServer *server = new IRCServer(); - server->setHostname("irc.openprojects.net"); - server->setPort(6667); - server->setDescription("OpenProjects"); - server->setNick("opie-irc"); - server->setUsername("opie-irc"); - server->setRealname("opie-irc"); - IRCServerTab *serverTab = new IRCServerTab(server, this, m_tabWidget); + IRCServerList list(this, "ServerList", TRUE); + if (list.exec() == QDialog::Accepted && list.hasServer()) { + IRCServerTab *serverTab = new IRCServerTab(list.server(), this, m_tabWidget); addTab(serverTab); serverTab->doConnect(); - - /* - * Serverlist : not functional yet - IRCServerList *list = new IRCServerList(this, "ServerList", TRUE); - list->exec(); - delete list; - */ + } } diff --git a/noncore/net/opieirc/opieirc.pro b/noncore/net/opieirc/opieirc.pro index d24535b..0e188e4 100644 --- a/noncore/net/opieirc/opieirc.pro +++ b/noncore/net/opieirc/opieirc.pro @@ -1,22 +1,24 @@ TEMPLATE = app CONFIG = qt warn_on release DESTDIR = $(OPIEDIR)/bin HEADERS = ircchannel.h ircconnection.h \ ircmessage.h \ ircmessageparser.h ircoutput.h \ ircperson.h ircserver.h ircsession.h \ mainwindow.h irctab.h ircservertab.h \ ircchanneltab.h ircchannellist.h \ - ircserverlist.h ircservereditor.h + ircserverlist.h ircservereditor.h \ + ircquerytab.h SOURCES = ircchannel.cpp ircconnection.cpp \ ircmessage.cpp \ ircmessageparser.cpp ircoutput.cpp \ ircperson.cpp ircserver.cpp \ ircsession.cpp main.cpp mainwindow.cpp \ irctab.cpp ircservertab.cpp \ ircchanneltab.cpp ircchannellist.cpp \ - ircserverlist.cpp ircservereditor.cpp + ircserverlist.cpp ircservereditor.cpp \ + ircquerytab.cpp INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe |