65 #ifdef HAVE_QSCINTILLA
74 setWindowTitle (tr (
"Find and Replace"));
75 setWindowIcon (QIcon(
":/actions/icons/find.png"));
77 _search_label =
new QLabel (tr (
"Find &what:"));
79 _search_label->setBuddy (_search_line_edit);
80 _replace_label =
new QLabel (tr (
"Re&place with:"));
82 _replace_label->setBuddy (_replace_line_edit);
84 _case_check_box =
new QCheckBox (tr (
"Match &case"));
85 _from_start_check_box =
new QCheckBox (tr (
"Search from &start"));
86 _wrap_check_box =
new QCheckBox (tr (
"&Wrap while searching"));
87 _wrap_check_box->setChecked(
true);
88 _find_next_button =
new QPushButton (tr (
"&Find Next"));
89 _find_prev_button =
new QPushButton (tr (
"Find &Previous"));
90 _replace_button =
new QPushButton (tr (
"&Replace"));
91 _replace_all_button =
new QPushButton (tr (
"Replace &All"));
94 _more_button->setCheckable (
true);
95 _more_button->setAutoDefault (
false);
97 _button_box =
new QDialogButtonBox (Qt::Vertical);
98 _button_box->addButton (_find_next_button, QDialogButtonBox::ActionRole);
99 _button_box->addButton (_find_prev_button, QDialogButtonBox::ActionRole);
100 _button_box->addButton (_replace_button, QDialogButtonBox::ActionRole);
101 _button_box->addButton (_replace_all_button, QDialogButtonBox::ActionRole);
102 _button_box->addButton (_more_button, QDialogButtonBox::ActionRole);
103 _button_box->addButton (QDialogButtonBox::Close);
105 _extension =
new QWidget (
this);
106 _whole_words_check_box =
new QCheckBox (tr (
"&Whole words"));
107 _regex_check_box =
new QCheckBox (tr (
"Regular E&xpressions"));
108 _backward_check_box =
new QCheckBox (tr (
"Search &backward"));
109 _search_selection_check_box =
new QCheckBox (tr (
"Search se&lection"));
110 #ifdef HAVE_QSCI_FINDSELECTION
111 _search_selection_check_box->setCheckable (
true);
112 _search_selection_check_box->setEnabled (edit_area->hasSelectedText ());
114 _search_selection_check_box->setCheckable (
false);
115 _search_selection_check_box->setEnabled (
false);
118 _edit_area = edit_area;
119 connect (_find_next_button, SIGNAL (clicked ()),
120 this, SLOT (find_next ()));
121 connect (_find_prev_button, SIGNAL (clicked ()),
122 this, SLOT (find_prev ()));
123 connect (_more_button, SIGNAL (toggled (
bool)),
124 _extension, SLOT (setVisible (
bool)));
125 connect (_replace_button, SIGNAL (clicked ()),
127 connect (_replace_all_button, SIGNAL (clicked ()),
128 this, SLOT (replace_all ()));
129 connect (_backward_check_box, SIGNAL (stateChanged (
int)),
130 this, SLOT (handle_backward_search_changed (
int)));
131 connect (_button_box, SIGNAL (rejected ()),
132 this, SLOT (close ()));
133 connect (_search_line_edit, SIGNAL (textChanged (QString)),
134 this, SLOT (handle_search_text_changed (QString)));
136 #ifdef HAVE_QSCI_FINDSELECTION
137 connect (_edit_area, SIGNAL (copyAvailable (
bool)),
138 this, SLOT (handle_selection_changed (
bool)));
139 connect (_search_selection_check_box, SIGNAL (stateChanged (
int)),
140 this, SLOT (handle_sel_search_changed (
int)));
143 QVBoxLayout *extension_layout =
new QVBoxLayout ();
144 extension_layout->setMargin (0);
145 extension_layout->addWidget (_whole_words_check_box);
146 extension_layout->addWidget (_backward_check_box);
147 extension_layout->addWidget (_search_selection_check_box);
148 _extension->setLayout (extension_layout);
150 QGridLayout *top_left_layout =
new QGridLayout;
151 top_left_layout->addWidget (_search_label, 1, 1);
152 top_left_layout->addWidget (_search_line_edit, 1, 2);
153 top_left_layout->addWidget (_replace_label, 2, 1);
154 top_left_layout->addWidget (_replace_line_edit, 2, 2);
156 QVBoxLayout *left_layout =
new QVBoxLayout;
157 left_layout->addLayout (top_left_layout);
158 left_layout->insertStretch (1, 5);
159 left_layout->addWidget (_case_check_box);
160 left_layout->addWidget (_from_start_check_box);
161 left_layout->addWidget (_wrap_check_box);
162 left_layout->addWidget (_regex_check_box);
164 QGridLayout *main_layout =
new QGridLayout;
165 main_layout->setSizeConstraint (QLayout::SetFixedSize);
166 main_layout->addLayout (left_layout, 0, 0);
167 main_layout->addWidget (_button_box, 0, 1);
168 main_layout->addWidget (_extension, 1, 0);
169 setLayout (main_layout);
172 _find_next_button->setDefault (
true);
173 _find_result_available =
false;
178 int xp = p->x () +20;
179 int yp = p->y () + p->frameGeometry ().height () - sizeHint ().height () -20;
206 #ifdef HAVE_QSCI_FINDSELECTION
208 find_dialog::handle_sel_search_changed (
int selected)
215 find_dialog::handle_selection_changed (
bool has_selected)
233 int lbeg, lend, cbeg, cend;
234 _edit_area->getSelection(&lbeg,&cbeg,&lend,&cend);
258 bool do_forward = forward;
291 else if (! do_forward)
298 int currpos =
_edit_area->positionFromLineIndex(line,col);
302 _edit_area->lineIndexFromPosition(currpos, &line,&col);
312 #ifdef HAVE_QSCI_FINDSELECTION
324 #ifdef HAVE_QSCI_VERSION_2_6_0
341 #ifdef HAVE_QSCI_VERSION_2_6_0
400 QMessageBox msg_box (QMessageBox::Information, tr (
"Replace Result"),
402 QMessageBox::Ok,
this);
416 QMessageBox msg_box (QMessageBox::Information, tr (
"Find Result"),
417 tr (
"No more matches found"), QMessageBox::Ok,
this);
void find(bool forward=true)
QCheckBox * _search_selection_check_box
void handle_backward_search_changed(int)
void no_matches_message()
bool _find_result_available
find_dialog(QsciScintilla *edit_area, QWidget *parent=0)
static void replace(QString &text, const QRegExp &re, const QString &after)
QCheckBox * _whole_words_check_box
QLineEdit * _replace_line_edit
QCheckBox * _backward_check_box
QLineEdit * _search_line_edit
QCheckBox * _regex_check_box
void handle_search_text_changed(QString new_search_text)
QCheckBox * _case_check_box
QCheckBox * _wrap_check_box
QsciScintilla * _edit_area
QCheckBox * _from_start_check_box