-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfinddialog.cpp
116 lines (102 loc) · 3.02 KB
/
finddialog.cpp
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#include "finddialog.h"
FindDialog::FindDialog(QWidget *parent)
:QDialog(parent)
{
setWindowTitle(tr("Find"));
find_label = new QLabel(tr("Find"));
ignore_label = new QLabel(tr("Case-sensitive"));
next_label = new QLabel(tr("Backward"));
back_label = new QLabel(tr("Forward"));
find_edit = new QLineEdit;
find_button = new QPushButton(tr("Next one"));
next_radio = new QRadioButton;
back_radio = new QRadioButton;
ignore_flag = new QCheckBox;
find_edit->setText(tr(""));
QGridLayout *grid_layout = new QGridLayout(this);
grid_layout->addWidget(find_label,0,0);
grid_layout->addWidget(find_edit,0,1);
grid_layout->addWidget(find_button,0,3);
QHBoxLayout *ignore_layout = new QHBoxLayout;
ignore_layout->setSpacing(10);
ignore_layout->addWidget(ignore_label);
ignore_layout->addWidget(ignore_flag);
QHBoxLayout *radio_layout = new QHBoxLayout;
radio_layout->addWidget(next_label);
radio_layout->addWidget(next_radio);
radio_layout->addWidget(back_label);
radio_layout->addWidget(back_radio);
QGroupBox *group_radio = new QGroupBox(tr("Direction"),this);
group_radio->setLayout(radio_layout);
QHBoxLayout *do_radio = new QHBoxLayout;
do_radio->addWidget(group_radio);
grid_layout->addLayout(ignore_layout,1,0);
grid_layout->addLayout(do_radio,1,1);
this->setMaximumSize(300,100);
next_radio->setChecked(true);
find_button->setEnabled(false);
connect(find_edit,SIGNAL(textChanged(QString)),this,SLOT(findButtonState()));
connect(find_button,SIGNAL(clicked(bool)),this,SLOT(findDataButtonClickedState()));
}
FindDialog::~FindDialog()
{
if(find_edit){
delete find_edit;
}
if(find_label){
delete find_label;
}
if(ignore_label){
delete ignore_label;
}
if(next_label){
delete next_label;
}
if(back_label){
delete back_label;
}
if(find_button){
delete find_button;
}
if(next_radio){
delete next_radio;
}
if(back_radio){
delete back_radio;
}
if(ignore_flag){
delete ignore_flag;
}
}
void FindDialog::findButtonState()
{
if(find_edit->text().isEmpty()){
find_button->setEnabled(false);
}
else{
find_button->setEnabled(true);
}
}
void FindDialog::findDataButtonClickedState()
{
if(find_edit->text().isEmpty()){
return;
}
QString str = find_edit->text();
if(next_radio->isChecked()){
if(ignore_flag->isChecked()){
emit findTextDataButtonClickedSignal(str,true,true);
}
else{
emit findTextDataButtonClickedSignal(str,false,true);
}
}
if(back_radio->isChecked()){
if(ignore_flag->isChecked()){
emit findTextDataButtonClickedSignal(str,true,false);
}
else{
emit findTextDataButtonClickedSignal(str,false,false);
}
}
}