26 #include <QPushButton>
27 #include <QMessageBox>
28 #include <QVBoxLayout>
29 #include <QHBoxLayout>
34 : QDialog(App_, 0, true)
38 QVBoxLayout *all =
new QVBoxLayout(
this);
41 QGroupBox *g1 =
new QGroupBox(tr(
"Text to search for"));
42 QVBoxLayout *vbox1 =
new QVBoxLayout;
49 ReplaceGroup =
new QGroupBox(tr(
"Text to replace with"));
50 QVBoxLayout *vbox2 =
new QVBoxLayout;
57 AskBox =
new QCheckBox(tr(
"Ask before replacing"));
60 PositionBox =
new QCheckBox(tr(
"From cursor position"));
62 CaseBox =
new QCheckBox(tr(
"Case sensitive"));
64 WordBox =
new QCheckBox(tr(
"Whole words only"));
66 BackwardBox =
new QCheckBox(tr(
"Search backwards"));
69 QHBoxLayout *Buttons =
new QHBoxLayout();
70 all->addLayout(Buttons);
71 QPushButton *ButtonSearch =
new QPushButton(tr(
"Search"));
72 Buttons->addWidget(ButtonSearch);
73 QPushButton *ButtonCancel =
new QPushButton(tr(
"Cancel"));
74 Buttons->addWidget(ButtonCancel);
75 connect(ButtonSearch, SIGNAL(clicked()), SLOT(
slotSearch()));
76 connect(ButtonCancel, SIGNAL(clicked()), SLOT(reject()));
78 ButtonSearch->setDefault(
true);
89 setWindowTitle(tr(
"Replace Text"));
94 setWindowTitle(tr(
"Search Text"));
101 SearchEdit->setText(Doc->textCursor().selectedText());
114 int Line=0, Column=0, count=0, i;
116 Line = Doc->textCursor().blockNumber();
117 Column = Doc->textCursor().columnNumber();
120 Line = Doc->document()->blockCount();
130 findFlags = QTextDocument::FindCaseSensitively;
132 findFlags = findFlags | QTextDocument::FindWholeWords;
134 findFlags = findFlags | QTextDocument::FindBackward;
136 while ( Doc->find(
SearchEdit->text(), findFlags)) {
142 i = QMessageBox::Yes;
144 i = QMessageBox::information(
this,
145 tr(
"Replace..."), tr(
"Replace occurrence ?"),
146 QMessageBox::Yes | QMessageBox::Default, QMessageBox::No,
147 QMessageBox::Cancel | QMessageBox::Escape);
151 case QMessageBox::Yes:
155 case QMessageBox::No:
163 QMessageBox::information(
this, tr(
"Search..."),
164 tr(
"Search string not found!"));
168 QMessageBox::information(
this, tr(
"Replace..."),
169 tr(
"Replaced %1 occurrences!").arg(count));
Definition of the TextDoc class.
void searchText(bool, int)
void initSearch(bool replace=false)
The TextDoc class definition.