20 #include "browsedialog.h"
21 #include "cupsdconf.h"
23 #include <tqlineedit.h>
24 #include <tqpushbutton.h>
25 #include <tqcombobox.h>
28 #include <tqwhatsthis.h>
31 #include <tdelocale.h>
33 BrowseDialog::BrowseDialog(TQWidget *parent,
const char *name)
34 : KDialogBase(parent, name, true, TQString::null, Ok|Cancel, Ok, true)
36 TQWidget *dummy =
new TQWidget(
this);
38 type_ =
new TQComboBox(dummy);
39 from_ =
new TQLineEdit(dummy);
40 to_ =
new TQLineEdit(dummy);
41 type_->insertItem(i18n(
"Send"));
42 type_->insertItem(i18n(
"Allow"));
43 type_->insertItem(i18n(
"Deny"));
44 type_->insertItem(i18n(
"Relay"));
45 type_->insertItem(i18n(
"Poll"));
47 TQLabel *l1 =
new TQLabel(i18n(
"Type:"), dummy);
48 TQLabel *l2 =
new TQLabel(i18n(
"From:"), dummy);
49 TQLabel *l3 =
new TQLabel(i18n(
"To:"), dummy);
51 TQGridLayout *m1 =
new TQGridLayout(dummy, 3, 2, 0, 5);
52 m1->addWidget(l1, 0, 0, TQt::AlignRight);
53 m1->addWidget(l2, 1, 0, TQt::AlignRight);
54 m1->addWidget(l3, 2, 0, TQt::AlignRight);
55 m1->addWidget(type_, 0, 1);
56 m1->addWidget(from_, 1, 1);
57 m1->addWidget(to_, 2, 1);
59 connect(type_, TQ_SIGNAL(activated(
int)), TQ_SLOT(slotTypeChanged(
int)));
60 slotTypeChanged(type_->currentItem());
62 setCaption(i18n(
"Browse Address"));
66 TQString BrowseDialog::addressString()
69 switch (type_->currentItem())
87 if (from_->isEnabled())
88 s.append(
" ").append(from_->text());
90 s.append(
" ").append(to_->text());
94 void BrowseDialog::setInfos(CupsdConf *conf)
96 TQWhatsThis::add(type_, conf->comments_.toolTip(
"browsetype"));
99 TQString BrowseDialog::newAddress(TQWidget *parent, CupsdConf *conf)
101 BrowseDialog dlg(parent);
105 return dlg.addressString();
107 return TQString::null;
110 TQString BrowseDialog::editAddress(
const TQString& s, TQWidget *parent, CupsdConf *conf)
112 BrowseDialog dlg(parent);
114 TQStringList l = TQStringList::split(TQRegExp(
"\\s"), s,
false);
117 if (l[0] ==
"Send") dlg.type_->setCurrentItem(0);
118 else if (l[0] ==
"Allow") dlg.type_->setCurrentItem(1);
119 else if (l[0] ==
"Deny") dlg.type_->setCurrentItem(2);
120 else if (l[0] ==
"Relay") dlg.type_->setCurrentItem(3);
121 else if (l[0] ==
"Poll") dlg.type_->setCurrentItem(4);
122 dlg.slotTypeChanged(dlg.type_->currentItem());
124 if (dlg.from_->isEnabled())
125 dlg.from_->setText(l[index++]);
126 if (dlg.to_->isEnabled())
127 dlg.to_->setText(l[index]);
131 return dlg.addressString();
133 return TQString::null;
136 void BrowseDialog::slotTypeChanged(
int index)
138 bool useFrom(
true), useTo(
true);
141 case 0: useFrom =
false;
break;
144 case 2: useTo =
false;
break;
146 from_->setEnabled(useFrom);
147 to_->setEnabled(useTo);
150 #include "browsedialog.moc"