author | tille <tille> | 2003-06-12 16:27:32 (UTC) |
---|---|---|
committer | tille <tille> | 2003-06-12 16:27:32 (UTC) |
commit | 212f79ac5305c32d0752cc358c2636df0bc7e523 (patch) (unidiff) | |
tree | 324658eb2308a54507edb5a58330aa7de258f3bb | |
parent | f0f9cf3fa486a577770e3c0e89280c66ea331e73 (diff) | |
download | opie-212f79ac5305c32d0752cc358c2636df0bc7e523.zip opie-212f79ac5305c32d0752cc358c2636df0bc7e523.tar.gz opie-212f79ac5305c32d0752cc358c2636df0bc7e523.tar.bz2 |
fix delete account
-rw-r--r-- | noncore/settings/networksettings/ppp/accounts.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/noncore/settings/networksettings/ppp/accounts.cpp b/noncore/settings/networksettings/ppp/accounts.cpp index 04905e8..fa1c43b 100644 --- a/noncore/settings/networksettings/ppp/accounts.cpp +++ b/noncore/settings/networksettings/ppp/accounts.cpp | |||
@@ -1,355 +1,357 @@ | |||
1 | /* | 1 | /* |
2 | * kPPP: A pppd front end for the KDE project | 2 | * kPPP: A pppd front end for the KDE project |
3 | * | 3 | * |
4 | * $Id$ | 4 | * $Id$ |
5 | * | 5 | * |
6 | * Copyright (C) 1997 Bernd Johannes Wuebben | 6 | * Copyright (C) 1997 Bernd Johannes Wuebben |
7 | * wuebben@math.cornell.edu | 7 | * wuebben@math.cornell.edu |
8 | * | 8 | * |
9 | * based on EzPPP: | 9 | * based on EzPPP: |
10 | * Copyright (C) 1997 Jay Painter | 10 | * Copyright (C) 1997 Jay Painter |
11 | * | 11 | * |
12 | * This program is free software; you can redistribute it and/or | 12 | * This program is free software; you can redistribute it and/or |
13 | * modify it under the terms of the GNU Library General Public | 13 | * modify it under the terms of the GNU Library General Public |
14 | * License as published by the Free Software Foundation; either | 14 | * License as published by the Free Software Foundation; either |
15 | * version 2 of the License, or (at your option) any later version. | 15 | * version 2 of the License, or (at your option) any later version. |
16 | * | 16 | * |
17 | * This program is distributed in the hope that it will be useful, | 17 | * This program is distributed in the hope that it will be useful, |
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
20 | * Library General Public License for more details. | 20 | * Library General Public License for more details. |
21 | * | 21 | * |
22 | * You should have received a copy of the GNU Library General Public | 22 | * You should have received a copy of the GNU Library General Public |
23 | * License along with this program; if not, write to the Free | 23 | * License along with this program; if not, write to the Free |
24 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 24 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
25 | */ | 25 | */ |
26 | 26 | ||
27 | #include <qdir.h> | 27 | #include <qdir.h> |
28 | #include <stdlib.h> | 28 | #include <stdlib.h> |
29 | #include <qlayout.h> | 29 | #include <qlayout.h> |
30 | #include <qtabwidget.h> | 30 | #include <qtabwidget.h> |
31 | #include <qtabdialog.h> | 31 | #include <qtabdialog.h> |
32 | #include <qwhatsthis.h> | 32 | #include <qwhatsthis.h> |
33 | #include <qmessagebox.h> | 33 | #include <qmessagebox.h> |
34 | 34 | ||
35 | #include <qapplication.h> | 35 | #include <qapplication.h> |
36 | #include <qbuttongroup.h> | 36 | #include <qbuttongroup.h> |
37 | #include <qmessagebox.h> | 37 | #include <qmessagebox.h> |
38 | #include <qvgroupbox.h> | 38 | #include <qvgroupbox.h> |
39 | 39 | ||
40 | #include "accounts.h" | 40 | #include "accounts.h" |
41 | #include "authwidget.h" | 41 | #include "authwidget.h" |
42 | #include "pppdata.h" | 42 | #include "pppdata.h" |
43 | #include "edit.h" | 43 | #include "edit.h" |
44 | 44 | ||
45 | void parseargs(char* buf, char** args); | 45 | void parseargs(char* buf, char** args); |
46 | 46 | ||
47 | AccountWidget::AccountWidget( PPPData *pd, QWidget *parent, const char *name ) | 47 | AccountWidget::AccountWidget( PPPData *pd, QWidget *parent, const char *name ) |
48 | : QWidget( parent, name )//, _pppdata(pd) | 48 | : QWidget( parent, name )//, _pppdata(pd) |
49 | { | 49 | { |
50 | _pppdata = pd; | 50 | _pppdata = pd; |
51 | QVBoxLayout *l1 = new QVBoxLayout(this, 10, 10); | 51 | QVBoxLayout *l1 = new QVBoxLayout(this, 10, 10); |
52 | accountlist_l = new QListBox(this); | 52 | accountlist_l = new QListBox(this); |
53 | 53 | ||
54 | connect(accountlist_l, SIGNAL(highlighted(int)), | 54 | connect(accountlist_l, SIGNAL(highlighted(int)), |
55 | this, SLOT(slotListBoxSelect(int))); | 55 | this, SLOT(slotListBoxSelect(int))); |
56 | connect(accountlist_l, SIGNAL(selected(int)), | 56 | connect(accountlist_l, SIGNAL(selected(int)), |
57 | this, SLOT(editaccount())); | 57 | this, SLOT(editaccount())); |
58 | l1->addWidget(accountlist_l, 10); | 58 | l1->addWidget(accountlist_l, 10); |
59 | 59 | ||
60 | edit_b = new QPushButton(tr("&Edit..."), this); | 60 | edit_b = new QPushButton(tr("&Edit..."), this); |
61 | connect(edit_b, SIGNAL(clicked()), SLOT(editaccount())); | 61 | connect(edit_b, SIGNAL(clicked()), SLOT(editaccount())); |
62 | QWhatsThis::add(edit_b, tr("Allows you to modify the selected account")); | 62 | QWhatsThis::add(edit_b, tr("Allows you to modify the selected account")); |
63 | l1->addWidget(edit_b); | 63 | l1->addWidget(edit_b); |
64 | 64 | ||
65 | new_b = new QPushButton(tr("&New..."), this); | 65 | new_b = new QPushButton(tr("&New..."), this); |
66 | connect(new_b, SIGNAL(clicked()), SLOT(newaccount())); | 66 | connect(new_b, SIGNAL(clicked()), SLOT(newaccount())); |
67 | l1->addWidget(new_b); | 67 | l1->addWidget(new_b); |
68 | QWhatsThis::add(new_b, tr("Create a new dialup connection\n" | 68 | QWhatsThis::add(new_b, tr("Create a new dialup connection\n" |
69 | "to the Internet")); | 69 | "to the Internet")); |
70 | 70 | ||
71 | copy_b = new QPushButton(tr("Co&py"), this); | 71 | copy_b = new QPushButton(tr("Co&py"), this); |
72 | connect(copy_b, SIGNAL(clicked()), SLOT(copyaccount())); | 72 | connect(copy_b, SIGNAL(clicked()), SLOT(copyaccount())); |
73 | l1->addWidget(copy_b); | 73 | l1->addWidget(copy_b); |
74 | QWhatsThis::add(copy_b, | 74 | QWhatsThis::add(copy_b, |
75 | tr("Makes a copy of the selected account. All\n" | 75 | tr("Makes a copy of the selected account. All\n" |
76 | "settings of the selected account are copied\n" | 76 | "settings of the selected account are copied\n" |
77 | "to a new account, that you can modify to fit your\n" | 77 | "to a new account, that you can modify to fit your\n" |
78 | "needs")); | 78 | "needs")); |
79 | 79 | ||
80 | delete_b = new QPushButton(tr("De&lete"), this); | 80 | delete_b = new QPushButton(tr("De&lete"), this); |
81 | connect(delete_b, SIGNAL(clicked()), SLOT(deleteaccount())); | 81 | connect(delete_b, SIGNAL(clicked()), SLOT(deleteaccount())); |
82 | l1->addWidget(delete_b); | 82 | l1->addWidget(delete_b); |
83 | QWhatsThis::add(delete_b, | 83 | QWhatsThis::add(delete_b, |
84 | tr("<p>Deletes the selected account\n\n" | 84 | tr("<p>Deletes the selected account\n\n" |
85 | "<font color=\"red\"><b>Use with care!</b></font>")); | 85 | "<font color=\"red\"><b>Use with care!</b></font>")); |
86 | 86 | ||
87 | QHBoxLayout *l12 = new QHBoxLayout; | 87 | QHBoxLayout *l12 = new QHBoxLayout; |
88 | l1->addStretch(1); | 88 | l1->addStretch(1); |
89 | l1->addLayout(l12); | 89 | l1->addLayout(l12); |
90 | 90 | ||
91 | int currAccId = _pppdata->currentAccountID(); | 91 | int currAccId = _pppdata->currentAccountID(); |
92 | qDebug("currentAccountID %i", currAccId); | 92 | qDebug("currentAccountID %i", currAccId); |
93 | 93 | ||
94 | //load up account list from gppdata to the list box | 94 | //load up account list from gppdata to the list box |
95 | if(_pppdata->count() > 0) { | 95 | if(_pppdata->count() > 0) { |
96 | for(int i=0; i <= _pppdata->count()-1; i++) { | 96 | for(int i=0; i <= _pppdata->count()-1; i++) { |
97 | _pppdata->setAccountbyIndex(i); | 97 | _pppdata->setAccountbyIndex(i); |
98 | accountlist_l->insertItem(_pppdata->accname()); | 98 | accountlist_l->insertItem(_pppdata->accname()); |
99 | } | 99 | } |
100 | } | 100 | } |
101 | _pppdata->setAccountbyIndex( currAccId ); | 101 | _pppdata->setAccountbyIndex( currAccId ); |
102 | 102 | ||
103 | qDebug("setting listview index to %i",_pppdata->currentAccountID() ); | 103 | qDebug("setting listview index to %i",_pppdata->currentAccountID() ); |
104 | accountlist_l->setCurrentItem( _pppdata->currentAccountID() ); | 104 | accountlist_l->setCurrentItem( _pppdata->currentAccountID() ); |
105 | slotListBoxSelect( _pppdata->currentAccountID() ); | 105 | slotListBoxSelect( _pppdata->currentAccountID() ); |
106 | 106 | ||
107 | l1->activate(); | 107 | l1->activate(); |
108 | } | 108 | } |
109 | 109 | ||
110 | 110 | ||
111 | 111 | ||
112 | void AccountWidget::slotListBoxSelect(int idx) { | 112 | void AccountWidget::slotListBoxSelect(int idx) { |
113 | delete_b->setEnabled((bool)(idx != -1)); | 113 | delete_b->setEnabled((bool)(idx != -1)); |
114 | edit_b->setEnabled((bool)(idx != -1)); | 114 | edit_b->setEnabled((bool)(idx != -1)); |
115 | copy_b->setEnabled((bool)(idx != -1)); | 115 | copy_b->setEnabled((bool)(idx != -1)); |
116 | if(idx!=-1) { | 116 | if(idx!=-1) { |
117 | qDebug("setting account to %i", idx); | 117 | qDebug("setting account to %i", idx); |
118 | QString account = _pppdata->accname(); | 118 | QString account = _pppdata->accname(); |
119 | _pppdata->setAccountbyIndex(accountlist_l->currentItem()); | 119 | _pppdata->setAccountbyIndex(accountlist_l->currentItem()); |
120 | } | 120 | } |
121 | } | 121 | } |
122 | 122 | ||
123 | void AccountWidget::editaccount() { | 123 | void AccountWidget::editaccount() { |
124 | _pppdata->setAccount(accountlist_l->text(accountlist_l->currentItem())); | 124 | _pppdata->setAccount(accountlist_l->text(accountlist_l->currentItem())); |
125 | 125 | ||
126 | int result = doTab(); | 126 | int result = doTab(); |
127 | 127 | ||
128 | if(result == QDialog::Accepted) { | 128 | if(result == QDialog::Accepted) { |
129 | accountlist_l->changeItem(_pppdata->accname(),accountlist_l->currentItem()); | 129 | accountlist_l->changeItem(_pppdata->accname(),accountlist_l->currentItem()); |
130 | // emit resetaccounts(); | 130 | // emit resetaccounts(); |
131 | _pppdata->save(); | 131 | _pppdata->save(); |
132 | } | 132 | } |
133 | } | 133 | } |
134 | 134 | ||
135 | 135 | ||
136 | void AccountWidget::newaccount() { | 136 | void AccountWidget::newaccount() { |
137 | 137 | ||
138 | if(accountlist_l->count() == MAX_ACCOUNTS) { | 138 | if(accountlist_l->count() == MAX_ACCOUNTS) { |
139 | QMessageBox::information(this, "sorry", | 139 | QMessageBox::information(this, "sorry", |
140 | tr("Maximum number of accounts reached.")); | 140 | tr("Maximum number of accounts reached.")); |
141 | return; | 141 | return; |
142 | } | 142 | } |
143 | 143 | ||
144 | int result; | 144 | int result; |
145 | if (_pppdata->newaccount() == -1){ | 145 | if (_pppdata->newaccount() == -1){ |
146 | qDebug("_pppdata->newaccount() == -1"); | 146 | qDebug("_pppdata->newaccount() == -1"); |
147 | return; | 147 | return; |
148 | } | 148 | } |
149 | result = doTab(); | 149 | result = doTab(); |
150 | 150 | ||
151 | if(result == QDialog::Accepted) { | 151 | if(result == QDialog::Accepted) { |
152 | accountlist_l->insertItem(_pppdata->accname()); | 152 | accountlist_l->insertItem(_pppdata->accname()); |
153 | accountlist_l->setSelected(accountlist_l->findItem(_pppdata->accname()),true); | 153 | accountlist_l->setSelected(accountlist_l->findItem(_pppdata->accname()),true); |
154 | 154 | ||
155 | _pppdata->save(); | 155 | _pppdata->save(); |
156 | } else | 156 | } else |
157 | _pppdata->deleteAccount(); | 157 | _pppdata->deleteAccount(); |
158 | } | 158 | } |
159 | 159 | ||
160 | 160 | ||
161 | void AccountWidget::copyaccount() { | 161 | void AccountWidget::copyaccount() { |
162 | if(accountlist_l->count() == MAX_ACCOUNTS) { | 162 | if(accountlist_l->count() == MAX_ACCOUNTS) { |
163 | QMessageBox::information(this, "sorry", tr("Maximum number of accounts reached.")); | 163 | QMessageBox::information(this, "sorry", tr("Maximum number of accounts reached.")); |
164 | return; | 164 | return; |
165 | } | 165 | } |
166 | 166 | ||
167 | if(accountlist_l->currentItem()<0) { | 167 | if(accountlist_l->currentItem()<0) { |
168 | QMessageBox::information(this, "sorry", tr("No account selected.")); | 168 | QMessageBox::information(this, "sorry", tr("No account selected.")); |
169 | return; | 169 | return; |
170 | } | 170 | } |
171 | 171 | ||
172 | _pppdata->copyaccount(accountlist_l->currentItem()); | 172 | _pppdata->copyaccount(accountlist_l->currentItem()); |
173 | 173 | ||
174 | accountlist_l->insertItem(_pppdata->accname()); | 174 | accountlist_l->insertItem(_pppdata->accname()); |
175 | // emit resetaccounts(); | 175 | // emit resetaccounts(); |
176 | _pppdata->save(); | 176 | _pppdata->save(); |
177 | } | 177 | } |
178 | 178 | ||
179 | 179 | ||
180 | void AccountWidget::deleteaccount() { | 180 | void AccountWidget::deleteaccount() { |
181 | 181 | ||
182 | QString s = tr("Are you sure you want to delete\nthe account \"%1\"?") | 182 | QString s = tr("Are you sure you want to delete\nthe account \"%1\"?") |
183 | .arg(accountlist_l->text(accountlist_l->currentItem())); | 183 | .arg(accountlist_l->text(accountlist_l->currentItem())); |
184 | 184 | ||
185 | if(QMessageBox::warning(this, s, tr("Confirm")) != QMessageBox::Yes) | 185 | if(QMessageBox::warning(this,tr("Confirm"),s, |
186 | QMessageBox::Yes,QMessageBox::No | ||
187 | ) != QMessageBox::Yes) | ||
186 | return; | 188 | return; |
187 | 189 | ||
188 | if(_pppdata->deleteAccount(accountlist_l->text(accountlist_l->currentItem()))) | 190 | if(_pppdata->deleteAccount(accountlist_l->text(accountlist_l->currentItem()))) |
189 | accountlist_l->removeItem(accountlist_l->currentItem()); | 191 | accountlist_l->removeItem(accountlist_l->currentItem()); |
190 | 192 | ||
191 | emit resetaccounts(); | 193 | emit resetaccounts(); |
192 | _pppdata->save(); | 194 | _pppdata->save(); |
193 | 195 | ||
194 | slotListBoxSelect(accountlist_l->currentItem()); | 196 | slotListBoxSelect(accountlist_l->currentItem()); |
195 | 197 | ||
196 | } | 198 | } |
197 | 199 | ||
198 | 200 | ||
199 | int AccountWidget::doTab(){ | 201 | int AccountWidget::doTab(){ |
200 | QDialog *dlg = new QDialog( 0, "newAccount", true ); | 202 | QDialog *dlg = new QDialog( 0, "newAccount", true ); |
201 | QVBoxLayout *layout = new QVBoxLayout( dlg ); | 203 | QVBoxLayout *layout = new QVBoxLayout( dlg ); |
202 | layout->setSpacing( 0 ); | 204 | layout->setSpacing( 0 ); |
203 | layout->setMargin( 1 ); | 205 | layout->setMargin( 1 ); |
204 | 206 | ||
205 | tabWindow = new QTabWidget( dlg, "tabWindow" ); | 207 | tabWindow = new QTabWidget( dlg, "tabWindow" ); |
206 | layout->addWidget( tabWindow ); | 208 | layout->addWidget( tabWindow ); |
207 | 209 | ||
208 | bool isnewaccount; | 210 | bool isnewaccount; |
209 | 211 | ||
210 | if(_pppdata->accname().isEmpty()) { | 212 | if(_pppdata->accname().isEmpty()) { |
211 | dlg->setCaption(tr("New Account")); | 213 | dlg->setCaption(tr("New Account")); |
212 | isnewaccount = true; | 214 | isnewaccount = true; |
213 | } else { | 215 | } else { |
214 | QString tit = tr("Edit Account: "); | 216 | QString tit = tr("Edit Account: "); |
215 | tit += _pppdata->accname(); | 217 | tit += _pppdata->accname(); |
216 | dlg->setCaption(tit); | 218 | dlg->setCaption(tit); |
217 | isnewaccount = false; | 219 | isnewaccount = false; |
218 | } | 220 | } |
219 | 221 | ||
220 | // // DIAL WIDGET | 222 | // // DIAL WIDGET |
221 | dial_w = new DialWidget( _pppdata, tabWindow, isnewaccount, "Dial Setup"); | 223 | dial_w = new DialWidget( _pppdata, tabWindow, isnewaccount, "Dial Setup"); |
222 | tabWindow->addTab( dial_w, tr("Dial") ); | 224 | tabWindow->addTab( dial_w, tr("Dial") ); |
223 | 225 | ||
224 | // // AUTH WIDGET | 226 | // // AUTH WIDGET |
225 | auth_w = new AuthWidget( _pppdata, tabWindow, isnewaccount, tr("Edit Login Script")); | 227 | auth_w = new AuthWidget( _pppdata, tabWindow, isnewaccount, tr("Edit Login Script")); |
226 | tabWindow->addTab( auth_w, tr("Authentication") ); | 228 | tabWindow->addTab( auth_w, tr("Authentication") ); |
227 | 229 | ||
228 | // // IP WIDGET | 230 | // // IP WIDGET |
229 | ip_w = new IPWidget( _pppdata, tabWindow, isnewaccount, tr("IP Setup")); | 231 | ip_w = new IPWidget( _pppdata, tabWindow, isnewaccount, tr("IP Setup")); |
230 | tabWindow->addTab( ip_w, tr("IP") ); | 232 | tabWindow->addTab( ip_w, tr("IP") ); |
231 | 233 | ||
232 | // // GATEWAY WIDGET | 234 | // // GATEWAY WIDGET |
233 | gateway_w = new GatewayWidget( _pppdata, tabWindow, isnewaccount, tr("Gateway Setup")); | 235 | gateway_w = new GatewayWidget( _pppdata, tabWindow, isnewaccount, tr("Gateway Setup")); |
234 | tabWindow->addTab( gateway_w, tr("Gateway") ); | 236 | tabWindow->addTab( gateway_w, tr("Gateway") ); |
235 | 237 | ||
236 | // // DNS WIDGET | 238 | // // DNS WIDGET |
237 | dns_w = new DNSWidget( _pppdata, tabWindow, isnewaccount, tr("DNS Servers") ); | 239 | dns_w = new DNSWidget( _pppdata, tabWindow, isnewaccount, tr("DNS Servers") ); |
238 | tabWindow->addTab( dns_w, tr("DNS") ); | 240 | tabWindow->addTab( dns_w, tr("DNS") ); |
239 | 241 | ||
240 | // // EXECUTE WIDGET | 242 | // // EXECUTE WIDGET |
241 | ExecWidget *exec_w = new ExecWidget( _pppdata, tabWindow, isnewaccount, tr("Execute Programs")); | 243 | ExecWidget *exec_w = new ExecWidget( _pppdata, tabWindow, isnewaccount, tr("Execute Programs")); |
242 | tabWindow->addTab( exec_w, tr("Execute") ); | 244 | tabWindow->addTab( exec_w, tr("Execute") ); |
243 | 245 | ||
244 | int result = 0; | 246 | int result = 0; |
245 | bool ok = false; | 247 | bool ok = false; |
246 | 248 | ||
247 | while (!ok){ | 249 | while (!ok){ |
248 | dlg->showMaximized(); | 250 | dlg->showMaximized(); |
249 | result = dlg->exec(); | 251 | result = dlg->exec(); |
250 | ok = true; | 252 | ok = true; |
251 | 253 | ||
252 | if(result == QDialog::Accepted) { | 254 | if(result == QDialog::Accepted) { |
253 | if (!auth_w->check()){ | 255 | if (!auth_w->check()){ |
254 | ok = false; | 256 | ok = false; |
255 | } else if(!dial_w->save()) { | 257 | } else if(!dial_w->save()) { |
256 | QMessageBox::critical(this, "error", tr( "You must enter a unique account name")); | 258 | QMessageBox::critical(this, "error", tr( "You must enter a unique account name")); |
257 | ok = false; | 259 | ok = false; |
258 | }else{ | 260 | }else{ |
259 | ip_w->save(); | 261 | ip_w->save(); |
260 | dns_w->save(); | 262 | dns_w->save(); |
261 | gateway_w->save(); | 263 | gateway_w->save(); |
262 | auth_w->save(); | 264 | auth_w->save(); |
263 | exec_w->save(); | 265 | exec_w->save(); |
264 | } | 266 | } |
265 | } | 267 | } |
266 | } | 268 | } |
267 | 269 | ||
268 | delete dlg; | 270 | delete dlg; |
269 | 271 | ||
270 | return result; | 272 | return result; |
271 | } | 273 | } |
272 | 274 | ||
273 | 275 | ||
274 | QString AccountWidget::prettyPrintVolume(unsigned int n) { | 276 | QString AccountWidget::prettyPrintVolume(unsigned int n) { |
275 | int idx = 0; | 277 | int idx = 0; |
276 | const QString quant[] = {tr("Byte"), tr("KB"), | 278 | const QString quant[] = {tr("Byte"), tr("KB"), |
277 | tr("MB"), tr("GB"), QString::null}; | 279 | tr("MB"), tr("GB"), QString::null}; |
278 | 280 | ||
279 | float n1 = n; | 281 | float n1 = n; |
280 | while(n >= 1024 && quant[idx] != QString::null) { | 282 | while(n >= 1024 && quant[idx] != QString::null) { |
281 | idx++; | 283 | idx++; |
282 | n /= 1024; | 284 | n /= 1024; |
283 | } | 285 | } |
284 | 286 | ||
285 | int i = idx; | 287 | int i = idx; |
286 | while(i--) | 288 | while(i--) |
287 | n1 = n1 / 1024.0; | 289 | n1 = n1 / 1024.0; |
288 | 290 | ||
289 | QString s = QString::number( n1, 'f', idx==0 ? 0 : 1 ); | 291 | QString s = QString::number( n1, 'f', idx==0 ? 0 : 1 ); |
290 | s += " " + quant[idx]; | 292 | s += " " + quant[idx]; |
291 | return s; | 293 | return s; |
292 | } | 294 | } |
293 | 295 | ||
294 | 296 | ||
295 | ///////////////////////////////////////////////////////////////////////////// | 297 | ///////////////////////////////////////////////////////////////////////////// |
296 | // | 298 | // |
297 | // Queries the user what to reset: costs, volume or both | 299 | // Queries the user what to reset: costs, volume or both |
298 | // | 300 | // |
299 | ///////////////////////////////////////////////////////////////////////////// | 301 | ///////////////////////////////////////////////////////////////////////////// |
300 | // QueryReset::QueryReset(QWidget *parent) : QDialog(parent, 0, true) { | 302 | // QueryReset::QueryReset(QWidget *parent) : QDialog(parent, 0, true) { |
301 | // // KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon()); | 303 | // // KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon()); |
302 | // setCaption(tr("Reset Accounting")); | 304 | // setCaption(tr("Reset Accounting")); |
303 | 305 | ||
304 | // QVBoxLayout *tl = new QVBoxLayout(this, 10, 10); | 306 | // QVBoxLayout *tl = new QVBoxLayout(this, 10, 10); |
305 | // QVGroupBox *f = new QVGroupBox(tr("What to Reset"), this); | 307 | // QVGroupBox *f = new QVGroupBox(tr("What to Reset"), this); |
306 | 308 | ||
307 | // QVBoxLayout *l1 = new QVBoxLayout(this, 10, 10); | 309 | // QVBoxLayout *l1 = new QVBoxLayout(this, 10, 10); |
308 | // // costs = new QCheckBox(tr("Reset the accumulated phone costs"), f); | 310 | // // costs = new QCheckBox(tr("Reset the accumulated phone costs"), f); |
309 | // // costs->setChecked(true); | 311 | // // costs->setChecked(true); |
310 | // // l1->addWidget(costs); | 312 | // // l1->addWidget(costs); |
311 | // // QWhatsThis::add(costs, tr("Check this to set the phone costs\n" | 313 | // // QWhatsThis::add(costs, tr("Check this to set the phone costs\n" |
312 | // // "to zero. Typically you'll want to\n" | 314 | // // "to zero. Typically you'll want to\n" |
313 | // // "do this once a month.")); | 315 | // // "do this once a month.")); |
314 | 316 | ||
315 | // // volume = new QCheckBox(tr("Reset volume accounting"), f); | 317 | // // volume = new QCheckBox(tr("Reset volume accounting"), f); |
316 | // // volume->setChecked(true); | 318 | // // volume->setChecked(true); |
317 | // // l1->addWidget(volume); | 319 | // // l1->addWidget(volume); |
318 | // // QWhatsThis::add(volume, tr("Check this to set the volume accounting\n" | 320 | // // QWhatsThis::add(volume, tr("Check this to set the volume accounting\n" |
319 | // // "to zero. Typically you'll want to do this\n" | 321 | // // "to zero. Typically you'll want to do this\n" |
320 | // // "once a month.")); | 322 | // // "once a month.")); |
321 | 323 | ||
322 | // l1->activate(); | 324 | // l1->activate(); |
323 | 325 | ||
324 | // // this activates the f-layout and sets minimumSize() | 326 | // // this activates the f-layout and sets minimumSize() |
325 | // f->show(); | 327 | // f->show(); |
326 | 328 | ||
327 | // tl->addWidget(f); | 329 | // tl->addWidget(f); |
328 | 330 | ||
329 | // QButtonGroup *bbox = new QButtonGroup(this); | 331 | // QButtonGroup *bbox = new QButtonGroup(this); |
330 | // // bbox->addStretch(1); | 332 | // // bbox->addStretch(1); |
331 | // QPushButton *ok = new QPushButton( bbox, tr("OK") ); | 333 | // QPushButton *ok = new QPushButton( bbox, tr("OK") ); |
332 | // bbox->insert(ok); | 334 | // bbox->insert(ok); |
333 | // ok->setDefault(true); | 335 | // ok->setDefault(true); |
334 | // QPushButton *cancel = new QPushButton( bbox, tr("Cancel") ); | 336 | // QPushButton *cancel = new QPushButton( bbox, tr("Cancel") ); |
335 | // bbox->insert(cancel); | 337 | // bbox->insert(cancel); |
336 | 338 | ||
337 | // connect(ok, SIGNAL(clicked()), | 339 | // connect(ok, SIGNAL(clicked()), |
338 | // this, SLOT(accepted())); | 340 | // this, SLOT(accepted())); |
339 | // connect(cancel, SIGNAL(clicked()), | 341 | // connect(cancel, SIGNAL(clicked()), |
340 | // this, SLOT(reject())); | 342 | // this, SLOT(reject())); |
341 | 343 | ||
342 | // bbox->layout(); | 344 | // bbox->layout(); |
343 | // tl->addWidget(bbox); | 345 | // tl->addWidget(bbox); |
344 | 346 | ||
345 | // } | 347 | // } |
346 | 348 | ||
347 | 349 | ||
348 | // void QueryReset::accepted() { | 350 | // void QueryReset::accepted() { |
349 | // int result = costs->isChecked() ? COSTS : 0; | 351 | // int result = costs->isChecked() ? COSTS : 0; |
350 | // result += volume->isChecked() ? VOLUME : 0; | 352 | // result += volume->isChecked() ? VOLUME : 0; |
351 | 353 | ||
352 | // done(result); | 354 | // done(result); |
353 | // } | 355 | // } |
354 | 356 | ||
355 | 357 | ||