summaryrefslogtreecommitdiff
path: root/noncore/net/opieirc/ircserverlist.cpp
Unidiff
Diffstat (limited to 'noncore/net/opieirc/ircserverlist.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opieirc/ircserverlist.cpp76
1 files changed, 51 insertions, 25 deletions
diff --git a/noncore/net/opieirc/ircserverlist.cpp b/noncore/net/opieirc/ircserverlist.cpp
index 595ae3e..62bfc17 100644
--- a/noncore/net/opieirc/ircserverlist.cpp
+++ b/noncore/net/opieirc/ircserverlist.cpp
@@ -1,22 +1,32 @@
1
2#include "ircserverlist.h"
3#include "ircservereditor.h"
4
5/* OPIE */
6#include <qpe/qpeapplication.h>
7
8/* QT */
1#include <qlayout.h> 9#include <qlayout.h>
2#include <qlabel.h> 10#include <qlabel.h>
3#include <qhbox.h> 11#include <qhbox.h>
4#include <qpushbutton.h> 12#include <qpushbutton.h>
5#include <qwhatsthis.h> 13#include <qwhatsthis.h>
6#include "ircserverlist.h"
7#include "ircservereditor.h"
8 14
9class IRCListBoxServer : public QListBoxText { 15class IRCListBoxServer : public QListBoxText
16{
10public: 17public:
11 IRCListBoxServer(IRCServer server) : QListBoxText(server.name()) { 18 IRCListBoxServer(IRCServer server) : QListBoxText(server.name())
19 {
12 m_server = server; 20 m_server = server;
13 } 21 }
14 22
15 IRCServer server() { 23 IRCServer server()
24 {
16 return m_server; 25 return m_server;
17 } 26 }
18 27
19 void setServer(IRCServer server) { 28 void setServer(IRCServer server)
29 {
20 m_server = server; 30 m_server = server;
21 setText(m_server.name()); 31 setText(m_server.name());
22 } 32 }
@@ -24,7 +34,8 @@ protected:
24 IRCServer m_server; 34 IRCServer m_server;
25}; 35};
26 36
27IRCServerList::IRCServerList(QWidget* parent, const char *name, bool modal, WFlags) : QDialog(parent, name, modal, WStyle_ContextHelp) { 37IRCServerList::IRCServerList(QWidget* parent, const char *name, bool modal, WFlags) : QDialog(parent, name, modal, WStyle_ContextHelp)
38{
28 QVBoxLayout *layout = new QVBoxLayout(this, 5, 5); 39 QVBoxLayout *layout = new QVBoxLayout(this, 5, 5);
29 setCaption(tr("Serverlist Browser")); 40 setCaption(tr("Serverlist Browser"));
30 QLabel *label = new QLabel(tr("Please choose a server profile"), this); 41 QLabel *label = new QLabel(tr("Please choose a server profile"), this);
@@ -48,11 +59,14 @@ IRCServerList::IRCServerList(QWidget* parent, const char *name, bool modal, WFla
48 m_config = new Config("OpieIRC"); 59 m_config = new Config("OpieIRC");
49 m_config->setGroup("OpieIRC"); 60 m_config->setGroup("OpieIRC");
50 int count = m_config->readNumEntry("ServerCount", 0); 61 int count = m_config->readNumEntry("ServerCount", 0);
51 if (count) { 62 if (count)
52 for (int i=0; i<count; i++) { 63 {
64 for (int i=0; i<count; i++)
65 {
53 m_config->setGroup("OpieIRC"); 66 m_config->setGroup("OpieIRC");
54 QString name = m_config->readEntry("Server"+QString::number(i)); 67 QString name = m_config->readEntry("Server"+QString::number(i));
55 if (name.length() > 0) { 68 if (name.length() > 0)
69 {
56 IRCServer server; 70 IRCServer server;
57 m_config->setGroup(name); 71 m_config->setGroup(name);
58 server.setName(name); 72 server.setName(name);
@@ -67,46 +81,55 @@ IRCServerList::IRCServerList(QWidget* parent, const char *name, bool modal, WFla
67 } 81 }
68 } 82 }
69 } 83 }
70 84
71 showMaximized(); 85 QPEApplication::showDialog( this );
72} 86}
73 87
74void IRCServerList::addServer() { 88void IRCServerList::addServer()
89{
75 IRCServer server; 90 IRCServer server;
76 IRCServerEditor editor(server, this, "ServerEditor", TRUE); 91 IRCServerEditor editor(server, this, "ServerEditor", TRUE);
77 if (editor.exec() == QDialog::Accepted) { 92 if (editor.exec() == QDialog::Accepted)
93 {
78 server = editor.getServer(); 94 server = editor.getServer();
79 /* Gets deleted by QListBox, so this is ok */ 95 /* Gets deleted by QListBox, so this is ok */
80 m_list->insertItem(new IRCListBoxServer(server)); 96 m_list->insertItem(new IRCListBoxServer(server));
81 } 97 }
82} 98}
83 99
84void IRCServerList::delServer() { 100void IRCServerList::delServer()
101{
85 int index = m_list->currentItem(); 102 int index = m_list->currentItem();
86 if (index != -1) { 103 if (index != -1)
104 {
87 m_list->removeItem(index); 105 m_list->removeItem(index);
88 } 106 }
89} 107}
90 108
91void IRCServerList::editServer() { 109void IRCServerList::editServer()
110{
92 int index = m_list->currentItem(); 111 int index = m_list->currentItem();
93 if (index != -1) { 112 if (index != -1)
113 {
94 IRCListBoxServer *item = (IRCListBoxServer *)m_list->item(index); 114 IRCListBoxServer *item = (IRCListBoxServer *)m_list->item(index);
95 IRCServer server = item->server(); 115 IRCServer server = item->server();
96 IRCServerEditor editor(server, this, "ServerEditor", TRUE); 116 IRCServerEditor editor(server, this, "ServerEditor", TRUE);
97 if (editor.exec() == QDialog::Accepted) { 117 if (editor.exec() == QDialog::Accepted)
118 {
98 server = editor.getServer(); 119 server = editor.getServer();
99 item->setServer(server); 120 item->setServer(server);
100 } 121 }
101 } 122 }
102} 123}
103 124
104int IRCServerList::exec() { 125int IRCServerList::exec()
126{
105 int returncode = QDialog::exec(); 127 int returncode = QDialog::exec();
106 /* Now save the changes */ 128 /* Now save the changes */
107 m_config->setGroup("OpieIRC"); 129 m_config->setGroup("OpieIRC");
108 m_config->writeEntry("ServerCount", QString::number(m_list->count())); 130 m_config->writeEntry("ServerCount", QString::number(m_list->count()));
109 for (unsigned int i=0; i<m_list->count(); i++) { 131 for (unsigned int i=0; i<m_list->count(); i++)
132 {
110 IRCServer server = ((IRCListBoxServer *)m_list->item(i))->server(); 133 IRCServer server = ((IRCListBoxServer *)m_list->item(i))->server();
111 m_config->setGroup("OpieIRC"); 134 m_config->setGroup("OpieIRC");
112 m_config->writeEntry("Server"+QString::number(i), server.name()); 135 m_config->writeEntry("Server"+QString::number(i), server.name());
@@ -122,14 +145,17 @@ int IRCServerList::exec() {
122 return returncode; 145 return returncode;
123} 146}
124 147
125bool IRCServerList::hasServer() { 148bool IRCServerList::hasServer()
149{
126 return (m_list->currentItem() != -1); 150 return (m_list->currentItem() != -1);
127} 151}
128 152
129IRCServer IRCServerList::server() { 153IRCServer IRCServerList::server()
154{
130 return ((IRCListBoxServer *)m_list->item(m_list->currentItem()))->server(); 155 return ((IRCListBoxServer *)m_list->item(m_list->currentItem()))->server();
131} 156}
132 157
133IRCServerList::~IRCServerList() { 158IRCServerList::~IRCServerList()
159{
134 delete m_config; 160 delete m_config;
135} 161}