Diffstat (limited to 'noncore/net/opieirc/ircserverlist.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/opieirc/ircserverlist.cpp | 72 |
1 files changed, 49 insertions, 23 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,2 +1,10 @@ | |||
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> |
@@ -4,18 +12,20 @@ | |||
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 | ||
9 | class IRCListBoxServer : public QListBoxText { | 15 | class IRCListBoxServer : public QListBoxText |
16 | { | ||
10 | public: | 17 | public: |
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()); |
@@ -25,5 +35,6 @@ protected: | |||
25 | }; | 35 | }; |
26 | 36 | ||
27 | IRCServerList::IRCServerList(QWidget* parent, const char *name, bool modal, WFlags) : QDialog(parent, name, modal, WStyle_ContextHelp) { | 37 | IRCServerList::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")); |
@@ -49,9 +60,12 @@ IRCServerList::IRCServerList(QWidget* parent, const char *name, bool modal, WFla | |||
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); |
@@ -69,11 +83,13 @@ IRCServerList::IRCServerList(QWidget* parent, const char *name, bool modal, WFla | |||
69 | } | 83 | } |
70 | 84 | ||
71 | showMaximized(); | 85 | QPEApplication::showDialog( this ); |
72 | } | 86 | } |
73 | 87 | ||
74 | void IRCServerList::addServer() { | 88 | void 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 */ |
@@ -82,18 +98,23 @@ void IRCServerList::addServer() { | |||
82 | } | 98 | } |
83 | 99 | ||
84 | void IRCServerList::delServer() { | 100 | void 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 | ||
91 | void IRCServerList::editServer() { | 109 | void 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); |
@@ -102,10 +123,12 @@ void IRCServerList::editServer() { | |||
102 | } | 123 | } |
103 | 124 | ||
104 | int IRCServerList::exec() { | 125 | int 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"); |
@@ -123,13 +146,16 @@ int IRCServerList::exec() { | |||
123 | } | 146 | } |
124 | 147 | ||
125 | bool IRCServerList::hasServer() { | 148 | bool IRCServerList::hasServer() |
149 | { | ||
126 | return (m_list->currentItem() != -1); | 150 | return (m_list->currentItem() != -1); |
127 | } | 151 | } |
128 | 152 | ||
129 | IRCServer IRCServerList::server() { | 153 | IRCServer 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 | ||
133 | IRCServerList::~IRCServerList() { | 158 | IRCServerList::~IRCServerList() |
159 | { | ||
134 | delete m_config; | 160 | delete m_config; |
135 | } | 161 | } |