www.pudn.com > qt_mysql.zip > MyReplaceDlg.cpp


// MyReplaceDlg.cpp: implementation of the MyReplaceDlg class. 
// 
////////////////////////////////////////////////////////////////////// 
#include "my.h" 
#include "MyFindDlg.h" 
#include "MyReplaceDlg.h" 
 
////////////////////////////////////////////////////////////////////// 
// Construction/Destruction 
////////////////////////////////////////////////////////////////////// 
 
MyReplaceDlg::MyReplaceDlg(QWidget * parent , const char * name) 
{ 
	this->setCaption("Replace"); 
	setMaximumSize( 410, 160 ); 
	setGeometry(205,220,410,160); 
 
	QLabel* labrep=new QLabel("Replace With",this); 
	labrep->setGeometry(20,50,120,20); 
	m_editRep=new QTextEdit(this); 
	m_editRep->setGeometry(100,50,180,20); 
 
	m_chkcase->setGeometry(130,85,120,20); 
 
	QPushButton* butRep=new QPushButton("Replace",this); 
	QPushButton* butRepAll=new QPushButton("Replace All",this); 
	butRep->setGeometry(300,75,100,20); 
	butRepAll->setGeometry(300,100,100,20); 
 
	m_cancelbut->setGeometry(300,125,100,20); 
	connect(butRep,SIGNAL(clicked()),this,SLOT(replaceString())); 
	connect(butRepAll,SIGNAL(clicked()),this,SLOT(replaceAll())); 
} 
 
MyReplaceDlg::~MyReplaceDlg() 
{ 
 
} 
 
bool MyReplaceDlg::replaceString() 
{ 
	assert(m_edit); 
	if (!m_edit->hasSelectedText()){ 
		if (!findNextString()) 
			return FALSE; 
	} 
	m_editRep->selectAll(); 
	m_editRep->copy(); 
	m_edit->paste(); 
	return TRUE; 
} 
 
bool MyReplaceDlg::replaceAll() 
{ 
	while (replaceString()); 
	return TRUE; 
}