summaryrefslogtreecommitdiff
path: root/noncore/net/opieirc/ircserverlist.cpp
authorwazlaf <wazlaf>2002-09-11 22:22:04 (UTC)
committer wazlaf <wazlaf>2002-09-11 22:22:04 (UTC)
commit4864665ad76095620fdf5aa19d24f05967f32b40 (patch) (unidiff)
tree4b3e371b5da03292ce09f7e388885dd3ec049ff8 /noncore/net/opieirc/ircserverlist.cpp
parent7ab82ad13aaf708ffba4bf4294d29b789007ddde (diff)
downloadopie-4864665ad76095620fdf5aa19d24f05967f32b40.zip
opie-4864665ad76095620fdf5aa19d24f05967f32b40.tar.gz
opie-4864665ad76095620fdf5aa19d24f05967f32b40.tar.bz2
serverlist browser
Diffstat (limited to 'noncore/net/opieirc/ircserverlist.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opieirc/ircserverlist.cpp90
1 files changed, 83 insertions, 7 deletions
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 +1,2 @@
1#include <stdio.h>
1#include <qlayout.h> 2#include <qlayout.h>
@@ -6,2 +7,3 @@
6#include "ircservereditor.h" 7#include "ircservereditor.h"
8#include <stdio.h>
7 9
@@ -9,4 +11,16 @@ class IRCListBoxServer : public QListBoxText {
9public: 11public:
10 IRCListBoxServer(IRCServer server); 12 IRCListBoxServer(IRCServer server) : QListBoxText(server.name()) {
11 QString text(); 13 m_server = server;
14 }
15
16 IRCServer server() {
17 return m_server;
18 }
19
20 void setServer(IRCServer server) {
21 m_server = server;
22 setText(m_server.name());
23 }
24protected:
25 IRCServer m_server;
12}; 26};
@@ -16,5 +30,4 @@ IRCServerList::IRCServerList(QWidget* parent, const char *name, bool modal, WFla
16 setCaption(tr("Serverlist Browser")); 30 setCaption(tr("Serverlist Browser"));
17 m_config = new Config("OpieIRC");
18 m_config->setGroup("OpieIRC");
19 QLabel *label = new QLabel(tr("Please choose a server profile"), this); 31 QLabel *label = new QLabel(tr("Please choose a server profile"), this);
32 label->setAlignment(AlignHCenter);
20 layout->addWidget(label); 33 layout->addWidget(label);
@@ -30,2 +43,25 @@ IRCServerList::IRCServerList(QWidget* parent, const char *name, bool modal, WFla
30 layout->addWidget(buttons); 43 layout->addWidget(buttons);
44 /* Load the configuration file */
45 m_config = new Config("OpieIRC");
46 m_config->setGroup("OpieIRC");
47 int count = m_config->readNumEntry("ServerCount", 0);
48 if (count) {
49 for (int i=0; i<count; i++) {
50 m_config->setGroup("OpieIRC");
51 QString name = m_config->readEntry("Server"+QString::number(i));
52 if (name.length() > 0) {
53 IRCServer server;
54 m_config->setGroup(name);
55 server.setName(name);
56 server.setHostname(m_config->readEntry("Hostname"));
57 server.setPort(m_config->readNumEntry("Port"));
58 server.setUsername(m_config->readEntry("Username"));
59 server.setPassword(m_config->readEntry("Password"));
60 server.setNick(m_config->readEntry("Nick"));
61 server.setRealname(m_config->readEntry("Realname"));
62 m_list->insertItem(new IRCListBoxServer(server));
63 }
64 }
65 }
66
31 showMaximized(); 67 showMaximized();
@@ -38,4 +74,4 @@ void IRCServerList::addServer() {
38 server = editor.getServer(); 74 server = editor.getServer();
39 //m_servers->append(server); 75 /* Gets deleted by QListBox, so this is ok */
40 update(); 76 m_list->insertItem(new IRCListBoxServer(server));
41 } 77 }
@@ -44,2 +80,6 @@ void IRCServerList::addServer() {
44void IRCServerList::delServer() { 80void IRCServerList::delServer() {
81 int index = m_list->currentItem();
82 if (index != -1) {
83 m_list->removeItem(index);
84 }
45} 85}
@@ -47,5 +87,41 @@ void IRCServerList::delServer() {
47void IRCServerList::editServer() { 87void IRCServerList::editServer() {
88 int index = m_list->currentItem();
89 if (index != -1) {
90 IRCListBoxServer *item = (IRCListBoxServer *)m_list->item(index);
91 IRCServer server = item->server();
92 IRCServerEditor editor(server, this, "ServerEditor", TRUE);
93 if (editor.exec() == QDialog::Accepted) {
94 server = editor.getServer();
95 item->setServer(server);
96 }
97 }
98}
99
100int IRCServerList::exec() {
101 int returncode = QDialog::exec();
102 /* Now save the changes */
103 m_config->setGroup("OpieIRC");
104 m_config->clearGroup();
105 m_config->writeEntry("ServerCount", QString::number(m_list->count()));
106 for (unsigned int i=0; i<m_list->count(); i++) {
107 IRCServer server = ((IRCListBoxServer *)m_list->item(i))->server();
108 m_config->setGroup("OpieIRC");
109 m_config->writeEntry("Server"+QString::number(i), server.name());
110 m_config->setGroup(server.name());
111 m_config->writeEntry("Hostname", server.hostname());
112 m_config->writeEntry("Port", QString::number(server.port()));
113 m_config->writeEntry("Username", server.username());
114 m_config->writeEntry("Password", server.password());
115 m_config->writeEntry("Nick", server.nick());
116 m_config->writeEntry("Realname", server.realname());
117 }
118 return returncode;
119}
120
121bool IRCServerList::hasServer() {
122 return (m_list->currentItem() != -1);
48} 123}
49 124
50void IRCServerList::update() { 125IRCServer IRCServerList::server() {
126 return ((IRCListBoxServer *)m_list->item(m_list->currentItem()))->server();
51} 127}