summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings/ppp/accounts.cpp
Unidiff
Diffstat (limited to 'noncore/settings/networksettings/ppp/accounts.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/networksettings/ppp/accounts.cpp104
1 files changed, 54 insertions, 50 deletions
diff --git a/noncore/settings/networksettings/ppp/accounts.cpp b/noncore/settings/networksettings/ppp/accounts.cpp
index d902517..19db9ef 100644
--- a/noncore/settings/networksettings/ppp/accounts.cpp
+++ b/noncore/settings/networksettings/ppp/accounts.cpp
@@ -53,7 +53,7 @@ void parseargs(char* buf, char** args);
53AccountWidget::AccountWidget( QWidget *parent, const char *name ) 53AccountWidget::AccountWidget( QWidget *parent, const char *name )
54 : QWidget( parent, name ) 54 : QWidget( parent, name )
55{ 55{
56 int min = 0; 56// int min = 0;
57 QVBoxLayout *l1 = new QVBoxLayout(this, 10, 10); 57 QVBoxLayout *l1 = new QVBoxLayout(this, 10, 10);
58 58
59 // add a hbox 59 // add a hbox
@@ -61,7 +61,7 @@ AccountWidget::AccountWidget( QWidget *parent, const char *name )
61// l1->addLayout(l11); 61// l1->addLayout(l11);
62 62
63 accountlist_l = new QListBox(this); 63 accountlist_l = new QListBox(this);
64 accountlist_l->setMinimumSize(160, 128); 64// accountlist_l->setMinimumSize(160, 128);
65 connect(accountlist_l, SIGNAL(highlighted(int)), 65 connect(accountlist_l, SIGNAL(highlighted(int)),
66 this, SLOT(slotListBoxSelect(int))); 66 this, SLOT(slotListBoxSelect(int)));
67 connect(accountlist_l, SIGNAL(selected(int)), 67 connect(accountlist_l, SIGNAL(selected(int)),
@@ -74,9 +74,9 @@ AccountWidget::AccountWidget( QWidget *parent, const char *name )
74 connect(edit_b, SIGNAL(clicked()), SLOT(editaccount())); 74 connect(edit_b, SIGNAL(clicked()), SLOT(editaccount()));
75 QWhatsThis::add(edit_b, i18n("Allows you to modify the selected account")); 75 QWhatsThis::add(edit_b, i18n("Allows you to modify the selected account"));
76 76
77 min = edit_b->sizeHint().width(); 77// min = edit_b->sizeHint().width();
78 min = QMAX(70,min); 78// min = QMAX(70,min);
79 edit_b->setMinimumWidth(min); 79// edit_b->setMinimumWidth(min);
80 80
81 l1->addWidget(edit_b); 81 l1->addWidget(edit_b);
82 82
@@ -165,10 +165,10 @@ AccountWidget::AccountWidget( QWidget *parent, const char *name )
165// l122->addStretch(1); 165// l122->addStretch(1);
166 166
167 //load up account list from gppdata to the list box 167 //load up account list from gppdata to the list box
168 if(gpppdata.count() > 0) { 168 if(PPPData::data()->count() > 0) {
169 for(int i=0; i <= gpppdata.count()-1; i++) { 169 for(int i=0; i <= PPPData::data()->count()-1; i++) {
170 gpppdata.setAccountbyIndex(i); 170 PPPData::data()->setAccountbyIndex(i);
171 accountlist_l->insertItem(gpppdata.accname()); 171 accountlist_l->insertItem(PPPData::data()->accname());
172 } 172 }
173 } 173 }
174 174
@@ -184,8 +184,8 @@ void AccountWidget::slotListBoxSelect(int idx) {
184 edit_b->setEnabled((bool)(idx != -1)); 184 edit_b->setEnabled((bool)(idx != -1));
185 copy_b->setEnabled((bool)(idx != -1)); 185 copy_b->setEnabled((bool)(idx != -1));
186 if(idx!=-1) { 186 if(idx!=-1) {
187 QString account = gpppdata.accname(); 187 QString account = PPPData::data()->accname();
188 gpppdata.setAccountbyIndex(accountlist_l->currentItem()); 188 PPPData::data()->setAccountbyIndex(accountlist_l->currentItem());
189// reset->setEnabled(TRUE); 189// reset->setEnabled(TRUE);
190// costlabel->setEnabled(TRUE); 190// costlabel->setEnabled(TRUE);
191// costedit->setEnabled(TRUE); 191// costedit->setEnabled(TRUE);
@@ -193,9 +193,9 @@ void AccountWidget::slotListBoxSelect(int idx) {
193 193
194// vollabel->setEnabled(TRUE); 194// vollabel->setEnabled(TRUE);
195// voledit->setEnabled(TRUE); 195// voledit->setEnabled(TRUE);
196 int bytes = gpppdata.totalBytes(); 196// int bytes = PPPData::data()->totalBytes();
197// voledit->setText(prettyPrintVolume(bytes)); 197// voledit->setText(prettyPrintVolume(bytes));
198 gpppdata.setAccount(account); 198 PPPData::data()->setAccount(account);
199 } else{ 199 } else{
200 // reset->setEnabled(FALSE); 200 // reset->setEnabled(FALSE);
201// costlabel->setEnabled(FALSE); 201// costlabel->setEnabled(FALSE);
@@ -240,14 +240,14 @@ void AccountWidget::slotListBoxSelect(int idx) {
240 240
241 241
242void AccountWidget::editaccount() { 242void AccountWidget::editaccount() {
243 gpppdata.setAccount(accountlist_l->text(accountlist_l->currentItem())); 243 PPPData::data()->setAccount(accountlist_l->text(accountlist_l->currentItem()));
244 244
245 int result = doTab(); 245 int result = doTab();
246 246
247 if(result == QDialog::Accepted) { 247 if(result == QDialog::Accepted) {
248 accountlist_l->changeItem(gpppdata.accname(),accountlist_l->currentItem()); 248 accountlist_l->changeItem(PPPData::data()->accname(),accountlist_l->currentItem());
249// emit resetaccounts(); 249// emit resetaccounts();
250 gpppdata.save(); 250 PPPData::data()->save();
251 } 251 }
252} 252}
253 253
@@ -271,15 +271,15 @@ void AccountWidget::newaccount() {
271// switch(query) { 271// switch(query) {
272// case QMessageBox::Yes: 272// case QMessageBox::Yes:
273// { 273// {
274// if (gpppdata.newaccount() == -1) 274// if (PPPData::data()->newaccount() == -1)
275 // return; 275 // return;
276// // ProviderDB pdb(this); 276// // ProviderDB pdb(this);
277// // result = pdb.exec(); 277// // result = pdb.exec();
278// break; 278// break;
279// } 279// }
280// case QMessageBox::No: 280// case QMessageBox::No:
281 if (gpppdata.newaccount() == -1){ 281 if (PPPData::data()->newaccount() == -1){
282 qDebug("gpppdata.newaccount() == -1"); 282 qDebug("PPPData::data()->newaccount() == -1");
283 return; 283 return;
284 } 284 }
285 result = doTab(); 285 result = doTab();
@@ -289,13 +289,13 @@ void AccountWidget::newaccount() {
289// } 289// }
290 290
291 if(result == QDialog::Accepted) { 291 if(result == QDialog::Accepted) {
292 accountlist_l->insertItem(gpppdata.accname()); 292 accountlist_l->insertItem(PPPData::data()->accname());
293 accountlist_l->setSelected(accountlist_l->findItem(gpppdata.accname()), 293 accountlist_l->setSelected(accountlist_l->findItem(PPPData::data()->accname()),
294 true); 294 true);
295// emit resetaccounts(); 295// emit resetaccounts();
296 gpppdata.save(); 296 PPPData::data()->save();
297 } else 297 } else
298 gpppdata.deleteAccount(); 298 PPPData::data()->deleteAccount();
299} 299}
300 300
301 301
@@ -310,11 +310,11 @@ void AccountWidget::copyaccount() {
310 return; 310 return;
311 } 311 }
312 312
313 gpppdata.copyaccount(accountlist_l->currentItem()); 313 PPPData::data()->copyaccount(accountlist_l->currentItem());
314 314
315 accountlist_l->insertItem(gpppdata.accname()); 315 accountlist_l->insertItem(PPPData::data()->accname());
316// emit resetaccounts(); 316// emit resetaccounts();
317 gpppdata.save(); 317 PPPData::data()->save();
318} 318}
319 319
320 320
@@ -326,11 +326,11 @@ void AccountWidget::deleteaccount() {
326 if(QMessageBox::warning(this, s, i18n("Confirm")) != QMessageBox::Yes) 326 if(QMessageBox::warning(this, s, i18n("Confirm")) != QMessageBox::Yes)
327 return; 327 return;
328 328
329 if(gpppdata.deleteAccount(accountlist_l->text(accountlist_l->currentItem()))) 329 if(PPPData::data()->deleteAccount(accountlist_l->text(accountlist_l->currentItem())))
330 accountlist_l->removeItem(accountlist_l->currentItem()); 330 accountlist_l->removeItem(accountlist_l->currentItem());
331 331
332 emit resetaccounts(); 332 emit resetaccounts();
333 gpppdata.save(); 333 PPPData::data()->save();
334 334
335 slotListBoxSelect(accountlist_l->currentItem()); 335 slotListBoxSelect(accountlist_l->currentItem());
336 336
@@ -338,41 +338,45 @@ void AccountWidget::deleteaccount() {
338 338
339 339
340int AccountWidget::doTab(){ 340int AccountWidget::doTab(){
341 QDialog *dlg = new QDialog( this ); 341 QDialog *dlg = new QDialog( this, "newAccount", true );
342 tabWindow = new QTabWidget( dlg ); 342 QVBoxLayout *layout = new QVBoxLayout( dlg );
343 // tabWindow = new KDialogBase( KDialogBase::Tabbed, QString::null, 343 layout->setSpacing( 0 );
344// KDialogBase::Ok|KDialogBase::Cancel, KDialogBase::Ok, 344 layout->setMargin( 1 );
345// 0, 0, true); 345
346// KWin::setIcons(tabWindow->winId(), kapp->icon(), kapp->miniIcon()); 346 tabWindow = new QTabWidget( dlg, "tabWindow" );
347 layout->addWidget( tabWindow );
348
347 bool isnewaccount; 349 bool isnewaccount;
348 350
349 if(gpppdata.accname().isEmpty()) { 351 if(PPPData::data()->accname().isEmpty()) {
350 tabWindow->setCaption(i18n("New Account")); 352 dlg->setCaption(i18n("New Account"));
351 isnewaccount = true; 353 isnewaccount = true;
352 } else { 354 } else {
353 QString tit = i18n("Edit Account: "); 355 QString tit = i18n("Edit Account: ");
354 tit += gpppdata.accname(); 356 tit += PPPData::data()->accname();
355 tabWindow->setCaption(tit); 357 dlg->setCaption(tit);
356 isnewaccount = false; 358 isnewaccount = false;
357 } 359 }
358 360
359 dial_w = new DialWidget( tabWindow ); 361 dial_w = new DialWidget( tabWindow, isnewaccount, "Dial Setup");
360 tabWindow->addTab( dial_w, i18n("Dial") );//, i18n("Dial Setup")), isnewaccount); 362 tabWindow->addTab( dial_w, i18n("Dial") );
361 ip_w = new IPWidget( tabWindow ); 363 ip_w = new IPWidget( tabWindow, isnewaccount, i18n("IP Setup"));
362 tabWindow->addTab( ip_w, i18n("IP") );//, i18n("IP Setup")), isnewaccount); 364 tabWindow->addTab( ip_w, i18n("IP") );
363 gateway_w = new GatewayWidget( tabWindow ); 365 gateway_w = new GatewayWidget( tabWindow, isnewaccount, i18n("Gateway Setup"));
364 tabWindow->addTab( gateway_w, i18n("Gateway") );//, i18n("Gateway Setup")), isnewaccount); 366 tabWindow->addTab( gateway_w, i18n("Gateway") );
365 dns_w = new DNSWidget( tabWindow ); 367 dns_w = new DNSWidget( tabWindow, isnewaccount, i18n("DNS Servers") );
366 tabWindow->addTab( dns_w, i18n("DNS") );//, i18n("DNS Servers")), isnewaccount); 368 tabWindow->addTab( dns_w, i18n("DNS") );
367 script_w = new ScriptWidget( tabWindow ); 369 script_w = new ScriptWidget( tabWindow, isnewaccount, i18n("Edit Login Script"));
368 tabWindow->addTab( script_w, i18n("Login Script") ); //, i18n("Edit Login Script")), isnewaccount); 370 tabWindow->addTab( script_w, i18n("Login Script") );
369 ExecWidget *exec_w = new ExecWidget( tabWindow ); 371 ExecWidget *exec_w = new ExecWidget( tabWindow, isnewaccount, i18n("Execute Programs"));
370 tabWindow->addTab( exec_w, i18n("Execute") );//, i18n("Execute Programs")), isnewaccount); 372 tabWindow->addTab( exec_w, i18n("Execute") );
371// acct = new AccountingSelector( tabWindow, isnewaccount ); 373// acct = new AccountingSelector( tabWindow, isnewaccount );
372// tabWindow->addTab( acct, i18n("Accounting")); 374// tabWindow->addTab( acct, i18n("Accounting"));
373 375
374 int result = 0; 376 int result = 0;
375 bool ok = false; 377 bool ok = false;
378 qDebug("AccountWidget::doTab dlg->showMinimized");
379 dlg->showMinimized();
376 while (!ok){ 380 while (!ok){
377 381
378 result = dlg->exec(); 382 result = dlg->exec();