Source Code (Use browser search to find items of interest.)
Class Index
kdelibs'KLineEditDlg (./kdelibs/kdeui/klineeditdlg.h:34)
class KLineEditDlg : public KDialogBase
{
Q_OBJECT
public:
/**
* Create a dialog that asks for a single line of text. _value is the initial
* value of the line. _text appears as label on top of the entry box.
*
* @param _text Text of the label
* @param _value Initial value of the inputline
*/
KLineEditDlg( const QString& _text, const QString& _value, QWidget *parent );
virtual ~KLineEditDlg();
/**
* @return the value the user entered
*/
QString text() { return edit->text(); }
/**
* Static convenience function to get a textual input from the user.
*
* @param _text Text of the label
* @param _value Initial value of the inputline
* @param ok this bool will be set to true if user pressed "Ok"
*/
static QString getText(const QString &_text, const QString& _value,
bool *ok, QWidget *parent );
public slots:
/**
* Clears the edit widget
*/
void slotClear();
protected:
/**
* The line edit widget
*/
QLineEdit *edit;
};
kdelibs'KLineEditDlg::KLineEditDlg() (./kdelibs/kdeui/klineeditdlg.cpp:36)
KLineEditDlg::KLineEditDlg( const QString&_text, const QString& _value,
QWidget *parent )
: KDialogBase( Plain, QString::null, Ok|Cancel|User1, Ok, parent, 0L, true,
true, i18n("C&lear") )
{
QVBoxLayout *topLayout = new QVBoxLayout( plainPage(), 0, spacingHint() );
QLabel *label = new QLabel(_text, plainPage() );
topLayout->addWidget( label, 1 );
edit = new KLineEdit( plainPage(), 0L );
edit->setMinimumWidth(edit->sizeHint().width() * 3);
connect( edit, SIGNAL(returnPressed()), SLOT(accept()) );
topLayout->addWidget( edit, 1 );
connect( this, SIGNAL(user1Clicked()), edit, SLOT(doClear()) );
edit->setText( _value );
edit->setSelection(0, edit->text().length());
edit->setFocus();
}
#if 0
KLineEditDlg::KLineEditDlg( const QString&_text, const QString& _value,
QWidget *parent, bool _file_mode )
: QDialog( parent, 0L, true )
{
QGridLayout *layout = new QGridLayout(this, 4, 3, 10);
QLabel *label = new QLabel(_text, this);
layout->addWidget(label, 0, 0, AlignLeft);
edit = new KLineEdit( this, 0L );
edit->setMinimumWidth(edit->sizeHint().width() * 3);
connect( edit, SIGNAL(returnPressed()), SLOT(accept()) );
if ( _file_mode ) {
completion = new KURLCompletion();
edit->setCompletionObject( completion );
edit->setAutoDeleteCompletionObject( true );
} else
completion = 0L;
layout->addMultiCellWidget(edit, 1, 1, 0, _file_mode ? 1 : 2);
layout->setColStretch(1, 1);
if (_file_mode) {
QPushButton *browse = new QPushButton(i18n("&Browse..."), this);
layout->addWidget(browse, 1, 2, AlignCenter);
connect(browse, SIGNAL(clicked()),
SLOT(slotBrowse()));
}
QFrame *hLine = new QFrame(this);
hLine->setFrameStyle(QFrame::Sunken|QFrame::HLine);
layout->addMultiCellWidget(hLine, 2, 2, 0, 2);
KButtonBox *bBox = new KButtonBox(this);
layout->addMultiCellWidget(bBox, 3, 3, 0, 2);
QPushButton *ok = bBox->addButton(i18n("&OK"));
ok->setDefault(true);
connect( ok, SIGNAL(clicked()), SLOT(accept()));
bBox->addStretch(1);
QPushButton *clear = bBox->addButton(i18n("C&lear"));
connect( clear, SIGNAL(clicked()), SLOT(slotClear()));
bBox->addStretch(1);
QPushButton *cancel = bBox->addButton(i18n("&Cancel"));
connect( cancel, SIGNAL(clicked()), SLOT(reject()));
bBox->layout();
layout->activate();
edit->setText( _value );
edit->setSelection(0, edit->text().length());
edit->setFocus();
}
kdelibs'KLineEditDlg::~KLineEditDlg() (./kdelibs/kdeui/klineeditdlg.cpp:121)
KLineEditDlg::~KLineEditDlg()
{
}
kdelibs'KLineEditDlg::slotClear() (./kdelibs/kdeui/klineeditdlg.cpp:125)
void KLineEditDlg::slotClear()
{
edit->setText(QString::null);
}
kdelibs'KLineEditDlg::getText() (./kdelibs/kdeui/klineeditdlg.cpp:130)
QString KLineEditDlg::getText(const QString &_text, const QString& _value,
bool *ok, QWidget *parent )
{
KLineEditDlg* dlg = new KLineEditDlg(_text, _value, parent );
#if 0
dlg->setCaption( caption );
if ( !_text.isEmpty() )
dlg->lineEdit()->selectAll();
#endif
bool ok_ = FALSE;
QString result;
ok_ = dlg->exec() == QDialog::Accepted;
if ( ok )
*ok = ok_;
if ( ok_ )
result = dlg->text();
delete dlg;
return result;
}