Diffstat (limited to 'noncore/net/opieirc/ircserverlist.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/opieirc/ircserverlist.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
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 | |||
@@ -61,88 +61,97 @@ IRCServerList::IRCServerList(QWidget* parent, const char *name, bool modal, WFla | |||
61 | int count = m_config->readNumEntry("ServerCount", 0); | 61 | int count = m_config->readNumEntry("ServerCount", 0); |
62 | if (count) | 62 | if (count) |
63 | { | 63 | { |
64 | for (int i=0; i<count; i++) | 64 | for (int i=0; i<count; i++) |
65 | { | 65 | { |
66 | m_config->setGroup("OpieIRC"); | 66 | m_config->setGroup("OpieIRC"); |
67 | QString name = m_config->readEntry("Server"+QString::number(i)); | 67 | QString name = m_config->readEntry("Server"+QString::number(i)); |
68 | if (name.length() > 0) | 68 | if (name.length() > 0) |
69 | { | 69 | { |
70 | IRCServer server; | 70 | IRCServer server; |
71 | m_config->setGroup(name); | 71 | m_config->setGroup(name); |
72 | server.setName(name); | 72 | server.setName(name); |
73 | server.setHostname(m_config->readEntry("Hostname")); | 73 | server.setHostname(m_config->readEntry("Hostname")); |
74 | server.setPort(m_config->readNumEntry("Port")); | 74 | server.setPort(m_config->readNumEntry("Port")); |
75 | server.setUsername(m_config->readEntry("Username")); | 75 | server.setUsername(m_config->readEntry("Username")); |
76 | server.setPassword(m_config->readEntry("Password")); | 76 | server.setPassword(m_config->readEntry("Password")); |
77 | server.setNick(m_config->readEntry("Nick")); | 77 | server.setNick(m_config->readEntry("Nick")); |
78 | server.setRealname(m_config->readEntry("Realname")); | 78 | server.setRealname(m_config->readEntry("Realname")); |
79 | server.setChannels(m_config->readEntry("Channels")); | 79 | server.setChannels(m_config->readEntry("Channels")); |
80 | m_list->insertItem(new IRCListBoxServer(server)); | 80 | m_list->insertItem(new IRCListBoxServer(server)); |
81 | } | 81 | } |
82 | } | 82 | } |
83 | } | 83 | } |
84 | 84 | ||
85 | connect(m_list, SIGNAL(doubleClicked(QListBoxItem*)), | ||
86 | this, SLOT(acceptOnClick(QListBoxItem *))); | ||
87 | connect(m_list, SIGNAL(returnPressed(QListBoxItem*)), | ||
88 | this, SLOT(acceptOnClick(QListBoxItem*))); | ||
89 | |||
85 | QPEApplication::showDialog( this ); | 90 | QPEApplication::showDialog( this ); |
86 | } | 91 | } |
87 | 92 | ||
88 | void IRCServerList::addServer() | 93 | void IRCServerList::addServer() |
89 | { | 94 | { |
90 | IRCServer server; | 95 | IRCServer server; |
91 | IRCServerEditor editor(server, this, "ServerEditor", TRUE); | 96 | IRCServerEditor editor(server, this, "ServerEditor", TRUE); |
92 | if (editor.exec() == QDialog::Accepted) | 97 | if (editor.exec() == QDialog::Accepted) |
93 | { | 98 | { |
94 | server = editor.getServer(); | 99 | server = editor.getServer(); |
95 | /* Gets deleted by QListBox, so this is ok */ | 100 | /* Gets deleted by QListBox, so this is ok */ |
96 | m_list->insertItem(new IRCListBoxServer(server)); | 101 | m_list->insertItem(new IRCListBoxServer(server)); |
97 | } | 102 | } |
98 | } | 103 | } |
99 | 104 | ||
100 | void IRCServerList::delServer() | 105 | void IRCServerList::delServer() |
101 | { | 106 | { |
102 | int index = m_list->currentItem(); | 107 | int index = m_list->currentItem(); |
103 | if (index != -1) | 108 | if (index != -1) |
104 | { | 109 | { |
105 | m_list->removeItem(index); | 110 | m_list->removeItem(index); |
106 | } | 111 | } |
107 | } | 112 | } |
108 | 113 | ||
109 | void IRCServerList::editServer() | 114 | void IRCServerList::editServer() |
110 | { | 115 | { |
111 | int index = m_list->currentItem(); | 116 | int index = m_list->currentItem(); |
112 | if (index != -1) | 117 | if (index != -1) |
113 | { | 118 | { |
114 | IRCListBoxServer *item = (IRCListBoxServer *)m_list->item(index); | 119 | IRCListBoxServer *item = (IRCListBoxServer *)m_list->item(index); |
115 | IRCServer server = item->server(); | 120 | IRCServer server = item->server(); |
116 | IRCServerEditor editor(server, this, "ServerEditor", TRUE); | 121 | IRCServerEditor editor(server, this, "ServerEditor", TRUE); |
117 | if (editor.exec() == QDialog::Accepted) | 122 | if (editor.exec() == QDialog::Accepted) |
118 | { | 123 | { |
119 | server = editor.getServer(); | 124 | server = editor.getServer(); |
120 | item->setServer(server); | 125 | item->setServer(server); |
121 | } | 126 | } |
122 | } | 127 | } |
123 | } | 128 | } |
124 | 129 | ||
130 | void IRCServerList::acceptOnClick( QListBoxItem* ) { | ||
131 | accept(); | ||
132 | } | ||
133 | |||
125 | int IRCServerList::exec() | 134 | int IRCServerList::exec() |
126 | { | 135 | { |
127 | int returncode = QDialog::exec(); | 136 | int returncode = QDialog::exec(); |
128 | /* Now save the changes */ | 137 | /* Now save the changes */ |
129 | m_config->setGroup("OpieIRC"); | 138 | m_config->setGroup("OpieIRC"); |
130 | m_config->writeEntry("ServerCount", QString::number(m_list->count())); | 139 | m_config->writeEntry("ServerCount", QString::number(m_list->count())); |
131 | for (unsigned int i=0; i<m_list->count(); i++) | 140 | for (unsigned int i=0; i<m_list->count(); i++) |
132 | { | 141 | { |
133 | IRCServer server = ((IRCListBoxServer *)m_list->item(i))->server(); | 142 | IRCServer server = ((IRCListBoxServer *)m_list->item(i))->server(); |
134 | m_config->setGroup("OpieIRC"); | 143 | m_config->setGroup("OpieIRC"); |
135 | m_config->writeEntry("Server"+QString::number(i), server.name()); | 144 | m_config->writeEntry("Server"+QString::number(i), server.name()); |
136 | m_config->setGroup(server.name()); | 145 | m_config->setGroup(server.name()); |
137 | m_config->writeEntry("Hostname", server.hostname()); | 146 | m_config->writeEntry("Hostname", server.hostname()); |
138 | m_config->writeEntry("Port", QString::number(server.port())); | 147 | m_config->writeEntry("Port", QString::number(server.port())); |
139 | m_config->writeEntry("Username", server.username()); | 148 | m_config->writeEntry("Username", server.username()); |
140 | m_config->writeEntry("Password", server.password()); | 149 | m_config->writeEntry("Password", server.password()); |
141 | m_config->writeEntry("Nick", server.nick()); | 150 | m_config->writeEntry("Nick", server.nick()); |
142 | m_config->writeEntry("Realname", server.realname()); | 151 | m_config->writeEntry("Realname", server.realname()); |
143 | m_config->writeEntry("Channels", server.channels()); | 152 | m_config->writeEntry("Channels", server.channels()); |
144 | } | 153 | } |
145 | return returncode; | 154 | return returncode; |
146 | } | 155 | } |
147 | 156 | ||
148 | bool IRCServerList::hasServer() | 157 | bool IRCServerList::hasServer() |