Next, here is the source code section:
#include <QtGui>
#include "finddialog.h"
Finddialog::finddialog (qwidget *parent)
: Qdialog (parent)
{
label = new Qlabel (tr ("Find &what:");
lineedit = new Qlineedit;
Label->setbuddy (Lineedit);
Casecheckbox = new Qcheckbox (tr ("Match &case"));
Backwardcheckbox = new Qcheckbox (tr ("Search &backford"));
Findbutton = new Qpushbutton (tr ("&find"));
Findbutton->setdefault (TRUE);
findbutton->setenabled (FALSE);
CloseButton = new Qpushbutton (tr ("close"));
Connect (Lineedit, SIGNAL (textchanged (const qstring&)), this, SLOT (Enablefindbutton (const qstring&)));
Connect (Findbutton, SIGNAL (clicked ()), this, SLOT (findclicked ()));
Connect (CloseButton, SIGNAL (clicked ()), this, SLOT (Close ()));
qhboxlayout *topleftlayout = new Qhboxlayout;
topleftlayout->addwidget (label);
Topleftlayout->addwidget (Lineedit);
qvboxlayout *leftlayout = new Qvboxlayout;
leftlayout->addlayout (topleftlayout);
Leftlayout->addwidget (Casecheckbox);
Leftlayout->addwidget (Backwardcheckbox);
qvboxlayout *rightlayout = new Qvboxlayout;
Rightlayout->addwidget (Findbutton);
Rightlayout->addwidget (CloseButton);
Rightlayout->addstretch ();
qhboxlayout *mainlayout = new Qhboxlayout;
mainlayout->addlayout (leftlayout);
mainlayout->addlayout (rightlayout);
setlayout (mainlayout);
setwindowtitle (tr ("find"));
Setfixedheight (Sizehint (). height ());
}
Finddialog::~finddialog ()
{
}
void finddialog::findclicked ()
{
QString Text = Lineedit->text ();
qt::casesensitivity cs = casecheckbox->ischecked ()? qt::caseinsensitive:qt::casesensitive;
if (backwardcheckbox->ischecked ()) {
emit findprevious (text, CS);
} else {
emit FindNext (text, CS);
}
}
void Finddialog::enablefindbutton (const QString &text)
{
findbutton->setenabled (!text.isempty ());
}