blob: 87a6d88c6bc96e582723657888ce738d6154ed31 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
#include "searchtextdialog.h"
#include "ui_searchtextdialog.h"
#include "searchtextlocator.h"
#include "common/unused.h"
SearchTextDialog::SearchTextDialog(SearchTextLocator* textLocator, QWidget *parent) :
QDialog(parent),
ui(new Ui::SearchTextDialog), textLocator(textLocator)
{
ui->setupUi(this);
connect(textLocator, SIGNAL(replaceAvailable(bool)), this, SLOT(setReplaceAvailable(bool)));
}
SearchTextDialog::~SearchTextDialog()
{
delete ui;
}
void SearchTextDialog::changeEvent(QEvent *e)
{
QDialog::changeEvent(e);
switch (e->type()) {
case QEvent::LanguageChange:
ui->retranslateUi(this);
break;
default:
break;
}
}
void SearchTextDialog::showEvent(QShowEvent* e)
{
UNUSED(e);
ui->findEdit->setFocus();
ui->findEdit->selectAll();
configModifiedState = true;
setReplaceAvailable(false);
}
void SearchTextDialog::applyConfigToLocator()
{
if (!configModifiedState)
return;
textLocator->setCaseSensitive(ui->caseSensitiveCheck->isChecked());
textLocator->setSearchBackwards(ui->backwardsCheck->isChecked());
textLocator->setRegularExpression(ui->regExpCheck->isChecked());
textLocator->setLookupString(ui->findEdit->text());
configModifiedState = false;
}
void SearchTextDialog::setReplaceAvailable(bool available)
{
ui->replaceButton->setEnabled(available);
}
void SearchTextDialog::on_findButton_clicked()
{
applyConfigToLocator();
textLocator->find();
}
void SearchTextDialog::on_replaceButton_clicked()
{
applyConfigToLocator();
textLocator->setReplaceString(ui->replaceEdit->text());
textLocator->replaceAndFind();
}
void SearchTextDialog::on_replaceAllButton_clicked()
{
applyConfigToLocator();
textLocator->setReplaceString(ui->replaceEdit->text());
textLocator->replaceAll();
}
|