www.pudn.com > qt_mysql.zip > MyFindDlg.cpp
// MyFindDlg.cpp: implementation of the MyFindDlg class.
//
//////////////////////////////////////////////////////////////////////
#include "MyFindDlg.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
MyFindDlg::MyFindDlg(QWidget * parent, const char * name)
{
setCaption("Find");
setMaximumSize( 400, 130 );
setFont(QFont("Arial",10));
QLabel* fw=new QLabel("Find What",this);
m_fwedit=new QLineEdit(this);
QPushButton* fbut=new QPushButton("Find First",this);
QPushButton* fnbut=new QPushButton("Find Next",this);
m_cancelbut=new QPushButton("Cancel",this);
m_chkcase=new QCheckBox("Case Sensitive",this);
fw->setGeometry(20,25,120,20);
m_fwedit->setGeometry(100,25,180,20);
fbut->setGeometry(300,25,100,20);
fnbut->setGeometry(300,50,100,20);
m_cancelbut->setGeometry(300,75,100,20);
m_chkcase->setGeometry(130,50,120,20);
m_icharAt=m_iparaAt=0;
connect(m_cancelbut,SIGNAL(clicked()),this,SLOT(OnCancel()));
connect(fbut,SIGNAL(clicked()),this,SLOT(findString()));
connect(fnbut,SIGNAL(clicked()),this,SLOT(findNextString()));
}
MyFindDlg::~MyFindDlg()
{
}
void MyFindDlg::setEdit(QTextEdit *txtEdit)
{
m_edit=txtEdit;
}
void MyFindDlg::OnCancel()
{
reject();
}
bool MyFindDlg::findString()
{
m_icharAt=m_iparaAt=0;
return findNextString();
}
bool MyFindDlg::findNextString()
{
assert(m_edit);
QString sTmp=m_fwedit->text();
bool bFind=FALSE;
while (!(bFind=m_edit->find(sTmp,m_chkcase->isChecked(),FALSE,TRUE,&(m_iparaAt),&m_icharAt))
&& m_iparaAt < m_edit->paragraphs()){
m_iparaAt++;
}
if (!bFind){
QMessageBox::information(this,"No Found",
"Don't found the string what you want!");
return FALSE;
}
m_icharAt+=sTmp.length();
return TRUE;
}