21 #include <tqvalidator.h>
22 #include <tqpushbutton.h>
23 #include <tqlineedit.h>
26 #undef Unsorted // Required for --enable-final (tqdir.h)
27 #include <tqfiledialog.h>
29 #include <kbuttonbox.h>
31 #include <kapplication.h>
32 #include <klineedit.h>
33 #include <kstdguiitem.h>
35 #include "klineeditdlg.h"
39 :
KDialogBase( Plain, TQString::null, Ok|Cancel|User1, Ok, parent, 0L, true,
43 TQLabel *label =
new TQLabel(_text,
plainPage() );
44 topLayout->addWidget( label, 1 );
47 edit->setMinimumWidth(
edit->sizeHint().width() * 3);
48 label->setBuddy(
edit);
50 connect(
edit, TQT_SIGNAL(textChanged(
const TQString&)),
52 topLayout->addWidget(
edit, 1 );
56 if ( _value.isEmpty() )
61 edit->setSelection(0,
edit->text().length());
69 TQWidget *parent,
bool _file_mode )
70 : TQDialog( parent, 0L, true )
72 TQGridLayout *layout =
new TQGridLayout(
this, 4, 3, 10);
74 TQLabel *label =
new TQLabel(_text,
this);
75 layout->addWidget(label, 0, 0, AlignLeft);
78 edit->setMinimumWidth(
edit->sizeHint().width() * 3);
79 connect(
edit, TQT_SIGNAL(returnPressed()), TQT_SLOT(accept()) );
82 completion =
new KURLCompletion();
88 layout->addMultiCellWidget(
edit, 1, 1, 0, _file_mode ? 1 : 2);
89 layout->setColStretch(1, 1);
92 TQPushButton *browse =
new TQPushButton(i18n(
"&Browse..."),
this);
93 layout->addWidget(browse, 1, 2, AlignCenter);
94 connect(browse, TQT_SIGNAL(clicked()),
95 TQT_SLOT(slotBrowse()));
98 TQFrame *hLine =
new TQFrame(
this);
99 hLine->setFrameStyle(TQFrame::Sunken|TQFrame::HLine);
100 layout->addMultiCellWidget(hLine, 2, 2, 0, 2);
103 layout->addMultiCellWidget(bBox, 3, 3, 0, 2);
105 TQPushButton *ok = bBox->
addButton(KStdGuiItem::ok());
106 ok->setDefault(
true);
107 connect( ok, TQT_SIGNAL(clicked()), TQT_SLOT(accept()));
112 connect( clear, TQT_SIGNAL(clicked()), TQT_SLOT(
slotClear()));
117 connect( cancel, TQT_SIGNAL(clicked()), TQT_SLOT(reject()));
124 edit->setSelection(0,
edit->text().length());
130 KLineEditDlg::~KLineEditDlg()
142 if (
edit->validator() ) {
143 TQString str =
edit->text();
144 int index =
edit->cursorPosition();
145 on = (
edit->validator()->validate( str, index )
146 == TQValidator::Acceptable );
148 on = !text.isEmpty();
160 bool *ok, TQWidget *parent, TQValidator *_validator )
163 dlg.
lineEdit()->setValidator( _validator );
166 bool ok_ = dlg.exec() == TQDialog::Accepted;
171 return TQString::null;
175 const TQString& _value,
176 bool *ok, TQWidget *parent, TQValidator *_validator )
180 dlg.
lineEdit()->setValidator( _validator );
183 bool ok_ = dlg.exec() == TQDialog::Accepted;
188 return TQString::null;
191 void KLineEditDlg::virtual_hook(
int id,
void* data )
192 { KDialogBase::virtual_hook(
id, data ); }
194 #include "klineeditdlg.moc"