20 #include "addressdialog.h"
22 #include <tqcombobox.h>
23 #include <tqlineedit.h>
27 #include <tdelocale.h>
29 AddressDialog::AddressDialog(TQWidget *parent,
const char *name)
30 : KDialogBase(Swallow, i18n(
"ACL Address"), Ok|Cancel, Ok, parent, name, true, true)
32 TQWidget *w =
new TQWidget(
this);
33 type_ =
new TQComboBox(w);
34 address_ =
new TQLineEdit(w);
36 type_->insertItem(i18n(
"Allow"));
37 type_->insertItem(i18n(
"Deny"));
39 TQLabel *l1 =
new TQLabel(i18n(
"Type:"), w);
40 TQLabel *l2 =
new TQLabel(i18n(
"Address:"), w);
42 TQGridLayout *m1 =
new TQGridLayout(w, 2, 2, 0, 5);
43 m1->setColStretch(1, 1);
44 m1->addWidget(l1, 0, 0, TQt::AlignRight);
45 m1->addWidget(l2, 1, 0, TQt::AlignRight);
46 m1->addWidget(type_, 0, 1);
47 m1->addWidget(address_, 1, 1);
53 TQString AddressDialog::addressString()
56 if (type_->currentItem() == 0)
60 if (address_->text().isEmpty())
63 s.append(address_->text());
67 TQString AddressDialog::newAddress(TQWidget *parent)
69 AddressDialog dlg(parent);
71 return dlg.addressString();
73 return TQString::null;
76 TQString AddressDialog::editAddress(
const TQString& addr, TQWidget *parent)
78 AddressDialog dlg(parent);
79 int p = addr.find(
' ');
82 dlg.type_->setCurrentItem(addr.left(p).lower() ==
"deny" ? 1 : 0);
83 dlg.address_->setText(addr.mid(p+1));
86 return dlg.addressString();
88 return TQString::null;