Mercurial > octave
annotate libgui/src/m-editor/find-dialog.cc @ 18854:0a66861d8069 gui-release
implementation of search in selection in gui editor (bbug #41196)
* configure.ac: do the check OCTAVE_CHECK_FUNC_QSCI_FINDSELECTION
* acinclude.m4 (OCTAVE_CHECK_FUNC_QSCI_FINDSELECTION): new function testing
whether QsciScintilla::findFirstInSelection is available (added in 2.7)
* find-dialog.cc (constructor): box for searching in selection enabled when
function is available, connect signals when search has changed and when
search selection is activated to the new related slots, initialize new
flag for indicating an ongoing replace;
(handle_search_text_changed): new slot reseting search result;
(handle_sel_search_changed): new slot reseting search result;
(handle_selection_changed): new slot enabling check box for search selection,
nothing is done when the change was due to a replace operation;
(find): revise calculation of cursor position for starting the search at end,
add searching in selection if related check box is checked, use backward
search when replacing all
(do_replace): set flag for an active replace operation indicating that the
selection is not changed by the user;
(replace): switch to robust backward search, using new function do_replace;
(replace_all): recover cursor position only when nor searching in selection,
reset search result after operation, using new function do_replace
* find-dialog.h: new flag for active replace operation, new slots
author | Torsten <ttl@justmail.de> |
---|---|
date | Sun, 22 Jun 2014 15:42:00 +0200 |
parents | 12291fb903de |
children | 2b82d2f29a7b 521d4959fc42 |
rev | line source |
---|---|
15177
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
1 /**************************************************************************** |
16520
086b5e81245b
find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents:
16516
diff
changeset
|
2 |
086b5e81245b
find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents:
16516
diff
changeset
|
3 Find dialog derived from an example from Qt Toolkit (license below (**)) |
086b5e81245b
find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents:
16516
diff
changeset
|
4 |
086b5e81245b
find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents:
16516
diff
changeset
|
5 Copyright (C) 2012-2013 Torsten <ttl@justmail.de> |
086b5e81245b
find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents:
16516
diff
changeset
|
6 Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
086b5e81245b
find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents:
16516
diff
changeset
|
7 All rights reserved. |
086b5e81245b
find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents:
16516
diff
changeset
|
8 Contact: Nokia Corporation (qt-info@nokia.com) |
086b5e81245b
find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents:
16516
diff
changeset
|
9 |
086b5e81245b
find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents:
16516
diff
changeset
|
10 This file is part of Octave. |
086b5e81245b
find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents:
16516
diff
changeset
|
11 |
086b5e81245b
find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents:
16516
diff
changeset
|
12 Octave is free software; you can redistribute it and/or modify it |
086b5e81245b
find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents:
16516
diff
changeset
|
13 under the terms of the GNU General Public License as published by the |
086b5e81245b
find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents:
16516
diff
changeset
|
14 Free Software Foundation; either version 3 of the License, or (at your |
086b5e81245b
find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents:
16516
diff
changeset
|
15 option) any later version. |
086b5e81245b
find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents:
16516
diff
changeset
|
16 |
086b5e81245b
find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents:
16516
diff
changeset
|
17 Octave is distributed in the hope that it will be useful, but WITHOUT |
086b5e81245b
find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents:
16516
diff
changeset
|
18 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
086b5e81245b
find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents:
16516
diff
changeset
|
19 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
086b5e81245b
find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents:
16516
diff
changeset
|
20 for more details. |
086b5e81245b
find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents:
16516
diff
changeset
|
21 |
086b5e81245b
find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents:
16516
diff
changeset
|
22 You should have received a copy of the GNU General Public License |
086b5e81245b
find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents:
16516
diff
changeset
|
23 along with Octave; see the file COPYING. If not, see |
086b5e81245b
find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents:
16516
diff
changeset
|
24 <http://www.gnu.org/licenses/>. |
086b5e81245b
find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents:
16516
diff
changeset
|
25 |
15177
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
26 ** This file is part of the examples of the Qt Toolkit. |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
27 ** |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
28 ** $QT_BEGIN_LICENSE:LGPL$ |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
29 ** Commercial Usage |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
30 ** Licensees holding valid Qt Commercial licenses may use this file in |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
31 ** accordance with the Qt Commercial License Agreement provided with the |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
32 ** Software or, alternatively, in accordance with the terms contained in |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
33 ** a written agreement between you and Nokia. |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
34 ** |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
35 ** GNU Lesser General Public License Usage |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
36 ** Alternatively, this file may be used under the terms of the GNU Lesser |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
37 ** General Public License version 2.1 as published by the Free Software |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
38 ** Foundation and appearing in the file LICENSE.LGPL included in the |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
39 ** packaging of this file. Please review the following information to |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
40 ** ensure the GNU Lesser General Public License version 2.1 requirements |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
41 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
42 ** |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
43 ** In addition, as a special exception, Nokia gives you certain additional |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
44 ** rights. These rights are described in the Nokia Qt LGPL Exception |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
45 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
46 ** |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
47 ** GNU General Public License Usage |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
48 ** Alternatively, this file may be used under the terms of the GNU |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
49 ** General Public License version 3.0 as published by the Free Software |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
50 ** Foundation and appearing in the file LICENSE.GPL included in the |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
51 ** packaging of this file. Please review the following information to |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
52 ** ensure the GNU General Public License version 3.0 requirements will be |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
53 ** met: http://www.gnu.org/copyleft/gpl.html. |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
54 ** |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
55 ** If you have questions regarding the use of this file, please contact |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
56 ** Nokia at qt-info@nokia.com. |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
57 ** $QT_END_LICENSE$ |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
58 ** |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
59 ****************************************************************************/ |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
60 |
15286
ae9079bbc627
Add '#include <config.h>' to C++ files in libgui/src
Rik <rik@octave.org>
parents:
15257
diff
changeset
|
61 #ifdef HAVE_CONFIG_H |
ae9079bbc627
Add '#include <config.h>' to C++ files in libgui/src
Rik <rik@octave.org>
parents:
15257
diff
changeset
|
62 #include <config.h> |
ae9079bbc627
Add '#include <config.h>' to C++ files in libgui/src
Rik <rik@octave.org>
parents:
15257
diff
changeset
|
63 #endif |
ae9079bbc627
Add '#include <config.h>' to C++ files in libgui/src
Rik <rik@octave.org>
parents:
15257
diff
changeset
|
64 |
15873
7d300b85ee25
allow build to proceed if either Qt or QScintilla is missing
John W. Eaton <jwe@octave.org>
parents:
15368
diff
changeset
|
65 #ifdef HAVE_QSCINTILLA |
7d300b85ee25
allow build to proceed if either Qt or QScintilla is missing
John W. Eaton <jwe@octave.org>
parents:
15368
diff
changeset
|
66 |
15177
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
67 #include <QtGui> |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
68 #include <QIcon> |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
69 #include "find-dialog.h" |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
70 |
15368
36ececf69385
avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents:
15367
diff
changeset
|
71 find_dialog::find_dialog (QsciScintilla* edit_area, QWidget *p) |
36ececf69385
avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents:
15367
diff
changeset
|
72 : QDialog (p) |
15177
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
73 { |
18283
12291fb903de
fix missing translations (bug #41200)
Torsten <ttl@justmail.de>
parents:
18269
diff
changeset
|
74 setWindowTitle (tr ("Find and Replace")); |
18261 | 75 setWindowIcon (QIcon(":/actions/icons/find.png")); |
15177
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
76 |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
77 _search_label = new QLabel (tr ("Find &what:")); |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
78 _search_line_edit = new QLineEdit; |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
79 _search_label->setBuddy (_search_line_edit); |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
80 _replace_label = new QLabel (tr ("Re&place with:")); |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
81 _replace_line_edit = new QLineEdit; |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
82 _replace_label->setBuddy (_replace_line_edit); |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
83 |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
84 _case_check_box = new QCheckBox (tr ("Match &case")); |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
85 _from_start_check_box = new QCheckBox (tr ("Search from &start")); |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
86 _wrap_check_box = new QCheckBox (tr ("&Wrap while searching")); |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
87 _wrap_check_box->setChecked(true); |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
88 _find_next_button = new QPushButton (tr ("&Find Next")); |
16520
086b5e81245b
find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents:
16516
diff
changeset
|
89 _find_prev_button = new QPushButton (tr ("Find &Previous")); |
15177
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
90 _replace_button = new QPushButton (tr ("&Replace")); |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
91 _replace_all_button = new QPushButton (tr ("Replace &All")); |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
92 |
18257
cae24b7cfaf4
minor fix of text strings and related translations (part of bug #41201)
Torsten <ttl@justmail.de>
parents:
17790
diff
changeset
|
93 _more_button = new QPushButton (tr ("&More...")); |
15177
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
94 _more_button->setCheckable (true); |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
95 _more_button->setAutoDefault (false); |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
96 |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
97 _button_box = new QDialogButtonBox (Qt::Vertical); |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
98 _button_box->addButton (_find_next_button, QDialogButtonBox::ActionRole); |
16520
086b5e81245b
find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents:
16516
diff
changeset
|
99 _button_box->addButton (_find_prev_button, QDialogButtonBox::ActionRole); |
15177
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
100 _button_box->addButton (_replace_button, QDialogButtonBox::ActionRole); |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
101 _button_box->addButton (_replace_all_button, QDialogButtonBox::ActionRole); |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
102 _button_box->addButton (_more_button, QDialogButtonBox::ActionRole); |
16516
7af39cc90982
* find-dialog.cc(constructor): add close button to the find dialog
Torsten <ttl@justmail.de>
parents:
16511
diff
changeset
|
103 _button_box->addButton (QDialogButtonBox::Close); |
15177
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
104 |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
105 _extension = new QWidget (this); |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
106 _whole_words_check_box = new QCheckBox (tr ("&Whole words")); |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
107 _regex_check_box = new QCheckBox (tr ("Regular E&xpressions")); |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
108 _backward_check_box = new QCheckBox (tr ("Search &backward")); |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
109 _search_selection_check_box = new QCheckBox (tr ("Search se&lection")); |
18854
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
110 #ifdef HAVE_QSCI_FINDSELECTION |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
111 _search_selection_check_box->setCheckable (true); |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
112 _search_selection_check_box->setEnabled (edit_area->hasSelectedText ()); |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
113 #else |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
114 _search_selection_check_box->setCheckable (false); |
15177
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
115 _search_selection_check_box->setEnabled (false); |
18854
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
116 #endif |
15177
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
117 |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
118 _edit_area = edit_area; |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
119 connect (_find_next_button, SIGNAL (clicked ()), |
16520
086b5e81245b
find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents:
16516
diff
changeset
|
120 this, SLOT (find_next ())); |
086b5e81245b
find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents:
16516
diff
changeset
|
121 connect (_find_prev_button, SIGNAL (clicked ()), |
086b5e81245b
find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents:
16516
diff
changeset
|
122 this, SLOT (find_prev ())); |
15177
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
123 connect (_more_button, SIGNAL (toggled (bool)), |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
124 _extension, SLOT (setVisible (bool))); |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
125 connect (_replace_button, SIGNAL (clicked ()), |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
126 this, SLOT (replace ())); |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
127 connect (_replace_all_button, SIGNAL (clicked ()), |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
128 this, SLOT (replace_all ())); |
16511
eee1b78d031f
gui: fix backward search in find dialog
Torsten <ttl@justmail.de>
parents:
15988
diff
changeset
|
129 connect (_backward_check_box, SIGNAL (stateChanged (int)), |
eee1b78d031f
gui: fix backward search in find dialog
Torsten <ttl@justmail.de>
parents:
15988
diff
changeset
|
130 this, SLOT (handle_backward_search_changed (int))); |
16516
7af39cc90982
* find-dialog.cc(constructor): add close button to the find dialog
Torsten <ttl@justmail.de>
parents:
16511
diff
changeset
|
131 connect (_button_box, SIGNAL (rejected ()), |
7af39cc90982
* find-dialog.cc(constructor): add close button to the find dialog
Torsten <ttl@justmail.de>
parents:
16511
diff
changeset
|
132 this, SLOT (close ())); |
18854
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
133 connect (_search_line_edit, SIGNAL (textChanged (QString)), |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
134 this, SLOT (handle_search_text_changed (QString))); |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
135 |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
136 #ifdef HAVE_QSCI_FINDSELECTION |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
137 connect (_edit_area, SIGNAL (copyAvailable (bool)), |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
138 this, SLOT (handle_selection_changed (bool))); |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
139 connect (_search_selection_check_box, SIGNAL (stateChanged (int)), |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
140 this, SLOT (handle_sel_search_changed (int))); |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
141 #endif |
15177
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
142 |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
143 QVBoxLayout *extension_layout = new QVBoxLayout (); |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
144 extension_layout->setMargin (0); |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
145 extension_layout->addWidget (_whole_words_check_box); |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
146 extension_layout->addWidget (_backward_check_box); |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
147 extension_layout->addWidget (_search_selection_check_box); |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
148 _extension->setLayout (extension_layout); |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
149 |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
150 QGridLayout *top_left_layout = new QGridLayout; |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
151 top_left_layout->addWidget (_search_label, 1, 1); |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
152 top_left_layout->addWidget (_search_line_edit, 1, 2); |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
153 top_left_layout->addWidget (_replace_label, 2, 1); |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
154 top_left_layout->addWidget (_replace_line_edit, 2, 2); |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
155 |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
156 QVBoxLayout *left_layout = new QVBoxLayout; |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
157 left_layout->addLayout (top_left_layout); |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
158 left_layout->insertStretch (1, 5); |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
159 left_layout->addWidget (_case_check_box); |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
160 left_layout->addWidget (_from_start_check_box); |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
161 left_layout->addWidget (_wrap_check_box); |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
162 left_layout->addWidget (_regex_check_box); |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
163 |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
164 QGridLayout *main_layout = new QGridLayout; |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
165 main_layout->setSizeConstraint (QLayout::SetFixedSize); |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
166 main_layout->addLayout (left_layout, 0, 0); |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
167 main_layout->addWidget (_button_box, 0, 1); |
16516
7af39cc90982
* find-dialog.cc(constructor): add close button to the find dialog
Torsten <ttl@justmail.de>
parents:
16511
diff
changeset
|
168 main_layout->addWidget (_extension, 1, 0); |
15177
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
169 setLayout (main_layout); |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
170 |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
171 _extension->hide (); |
16516
7af39cc90982
* find-dialog.cc(constructor): add close button to the find dialog
Torsten <ttl@justmail.de>
parents:
16511
diff
changeset
|
172 _find_next_button->setDefault (true); |
16511
eee1b78d031f
gui: fix backward search in find dialog
Torsten <ttl@justmail.de>
parents:
15988
diff
changeset
|
173 _find_result_available = false; |
18184
5f7f58866922
fix search and replace all in find dialog (bug #41051)
Torsten <ttl@justmail.de>
parents:
17790
diff
changeset
|
174 _rep_all = 0; |
18854
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
175 _rep_active = false; |
16511
eee1b78d031f
gui: fix backward search in find dialog
Torsten <ttl@justmail.de>
parents:
15988
diff
changeset
|
176 |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17007
diff
changeset
|
177 // move dialog to side of the parent if there is room on the desktop to do so. |
17007
c2e43dd6eb70
Dont display find dialog out of desktop bounds (bug #39518)
John Donoghue <john.donoghue@ieee.org>
parents:
16736
diff
changeset
|
178 QWidget * desktop = QApplication::desktop (); |
c2e43dd6eb70
Dont display find dialog out of desktop bounds (bug #39518)
John Donoghue <john.donoghue@ieee.org>
parents:
16736
diff
changeset
|
179 int xp = p->x () + p->frameGeometry ().width (); |
c2e43dd6eb70
Dont display find dialog out of desktop bounds (bug #39518)
John Donoghue <john.donoghue@ieee.org>
parents:
16736
diff
changeset
|
180 int yp= p->y (); |
c2e43dd6eb70
Dont display find dialog out of desktop bounds (bug #39518)
John Donoghue <john.donoghue@ieee.org>
parents:
16736
diff
changeset
|
181 if (desktop != 0 && sizeHint ().isValid ()) |
c2e43dd6eb70
Dont display find dialog out of desktop bounds (bug #39518)
John Donoghue <john.donoghue@ieee.org>
parents:
16736
diff
changeset
|
182 { |
c2e43dd6eb70
Dont display find dialog out of desktop bounds (bug #39518)
John Donoghue <john.donoghue@ieee.org>
parents:
16736
diff
changeset
|
183 if (xp + sizeHint ().width () > desktop->width ()) |
c2e43dd6eb70
Dont display find dialog out of desktop bounds (bug #39518)
John Donoghue <john.donoghue@ieee.org>
parents:
16736
diff
changeset
|
184 xp = desktop->width () - sizeHint ().width (); |
c2e43dd6eb70
Dont display find dialog out of desktop bounds (bug #39518)
John Donoghue <john.donoghue@ieee.org>
parents:
16736
diff
changeset
|
185 } |
c2e43dd6eb70
Dont display find dialog out of desktop bounds (bug #39518)
John Donoghue <john.donoghue@ieee.org>
parents:
16736
diff
changeset
|
186 |
c2e43dd6eb70
Dont display find dialog out of desktop bounds (bug #39518)
John Donoghue <john.donoghue@ieee.org>
parents:
16736
diff
changeset
|
187 move (xp, yp); |
16520
086b5e81245b
find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents:
16516
diff
changeset
|
188 |
15177
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
189 } |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
190 |
16511
eee1b78d031f
gui: fix backward search in find dialog
Torsten <ttl@justmail.de>
parents:
15988
diff
changeset
|
191 // set text of "search from start" depending on backward search |
eee1b78d031f
gui: fix backward search in find dialog
Torsten <ttl@justmail.de>
parents:
15988
diff
changeset
|
192 void |
eee1b78d031f
gui: fix backward search in find dialog
Torsten <ttl@justmail.de>
parents:
15988
diff
changeset
|
193 find_dialog::handle_backward_search_changed (int backward) |
eee1b78d031f
gui: fix backward search in find dialog
Torsten <ttl@justmail.de>
parents:
15988
diff
changeset
|
194 { |
eee1b78d031f
gui: fix backward search in find dialog
Torsten <ttl@justmail.de>
parents:
15988
diff
changeset
|
195 if (backward) |
eee1b78d031f
gui: fix backward search in find dialog
Torsten <ttl@justmail.de>
parents:
15988
diff
changeset
|
196 _from_start_check_box->setText (tr ("Search from end")); |
eee1b78d031f
gui: fix backward search in find dialog
Torsten <ttl@justmail.de>
parents:
15988
diff
changeset
|
197 else |
eee1b78d031f
gui: fix backward search in find dialog
Torsten <ttl@justmail.de>
parents:
15988
diff
changeset
|
198 _from_start_check_box->setText (tr ("Search from start")); |
eee1b78d031f
gui: fix backward search in find dialog
Torsten <ttl@justmail.de>
parents:
15988
diff
changeset
|
199 } |
15988
38348a6c3db0
gui: initialize search text in the find dialog with selected text in editor file
Torsten <ttl@justmail.de>
parents:
15873
diff
changeset
|
200 |
18854
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
201 // search text has changed: reset the search |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
202 void |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
203 find_dialog::handle_search_text_changed (QString) |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
204 { |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
205 if (_search_selection_check_box->isChecked ()) |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
206 _find_result_available = false; |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
207 } |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
208 |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
209 #ifdef HAVE_QSCI_FINDSELECTION |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
210 void |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
211 find_dialog::handle_sel_search_changed (int selected) |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
212 { |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
213 _from_start_check_box->setEnabled (! selected); |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
214 _find_result_available = false; |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
215 } |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
216 |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
217 void |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
218 find_dialog::handle_selection_changed (bool has_selected) |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
219 { |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
220 if (_rep_active) |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
221 return; |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
222 |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
223 _search_selection_check_box->setEnabled (has_selected); |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
224 _find_result_available = false; |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
225 if (! has_selected) |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
226 _search_selection_check_box->setChecked (false); |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
227 } |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
228 #endif |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
229 |
15988
38348a6c3db0
gui: initialize search text in the find dialog with selected text in editor file
Torsten <ttl@justmail.de>
parents:
15873
diff
changeset
|
230 // initialize search text with selected text if this is in one single line |
38348a6c3db0
gui: initialize search text in the find dialog with selected text in editor file
Torsten <ttl@justmail.de>
parents:
15873
diff
changeset
|
231 void |
38348a6c3db0
gui: initialize search text in the find dialog with selected text in editor file
Torsten <ttl@justmail.de>
parents:
15873
diff
changeset
|
232 find_dialog::init_search_text () |
38348a6c3db0
gui: initialize search text in the find dialog with selected text in editor file
Torsten <ttl@justmail.de>
parents:
15873
diff
changeset
|
233 { |
38348a6c3db0
gui: initialize search text in the find dialog with selected text in editor file
Torsten <ttl@justmail.de>
parents:
15873
diff
changeset
|
234 if (_edit_area->hasSelectedText ()) |
38348a6c3db0
gui: initialize search text in the find dialog with selected text in editor file
Torsten <ttl@justmail.de>
parents:
15873
diff
changeset
|
235 { |
38348a6c3db0
gui: initialize search text in the find dialog with selected text in editor file
Torsten <ttl@justmail.de>
parents:
15873
diff
changeset
|
236 int lbeg, lend, cbeg, cend; |
38348a6c3db0
gui: initialize search text in the find dialog with selected text in editor file
Torsten <ttl@justmail.de>
parents:
15873
diff
changeset
|
237 _edit_area->getSelection(&lbeg,&cbeg,&lend,&cend); |
38348a6c3db0
gui: initialize search text in the find dialog with selected text in editor file
Torsten <ttl@justmail.de>
parents:
15873
diff
changeset
|
238 if (lbeg == lend) |
38348a6c3db0
gui: initialize search text in the find dialog with selected text in editor file
Torsten <ttl@justmail.de>
parents:
15873
diff
changeset
|
239 _search_line_edit->setText (_edit_area->selectedText ()); |
38348a6c3db0
gui: initialize search text in the find dialog with selected text in editor file
Torsten <ttl@justmail.de>
parents:
15873
diff
changeset
|
240 } |
38348a6c3db0
gui: initialize search text in the find dialog with selected text in editor file
Torsten <ttl@justmail.de>
parents:
15873
diff
changeset
|
241 } |
38348a6c3db0
gui: initialize search text in the find dialog with selected text in editor file
Torsten <ttl@justmail.de>
parents:
15873
diff
changeset
|
242 |
16520
086b5e81245b
find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents:
16516
diff
changeset
|
243 void |
086b5e81245b
find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents:
16516
diff
changeset
|
244 find_dialog::find_next () |
086b5e81245b
find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents:
16516
diff
changeset
|
245 { |
086b5e81245b
find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents:
16516
diff
changeset
|
246 find (!_backward_check_box->isChecked ()); |
086b5e81245b
find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents:
16516
diff
changeset
|
247 } |
15988
38348a6c3db0
gui: initialize search text in the find dialog with selected text in editor file
Torsten <ttl@justmail.de>
parents:
15873
diff
changeset
|
248 |
15177
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
249 void |
16520
086b5e81245b
find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents:
16516
diff
changeset
|
250 find_dialog::find_prev () |
086b5e81245b
find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents:
16516
diff
changeset
|
251 { |
086b5e81245b
find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents:
16516
diff
changeset
|
252 find (_backward_check_box->isChecked ()); |
086b5e81245b
find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents:
16516
diff
changeset
|
253 } |
086b5e81245b
find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents:
16516
diff
changeset
|
254 |
086b5e81245b
find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents:
16516
diff
changeset
|
255 void |
086b5e81245b
find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents:
16516
diff
changeset
|
256 find_dialog::find (bool forward) |
15177
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
257 { |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
258 int line = -1, col = -1; |
16511
eee1b78d031f
gui: fix backward search in find dialog
Torsten <ttl@justmail.de>
parents:
15988
diff
changeset
|
259 bool do_wrap = _wrap_check_box->isChecked (); |
18184
5f7f58866922
fix search and replace all in find dialog (bug #41051)
Torsten <ttl@justmail.de>
parents:
17790
diff
changeset
|
260 bool do_forward = forward; |
16511
eee1b78d031f
gui: fix backward search in find dialog
Torsten <ttl@justmail.de>
parents:
15988
diff
changeset
|
261 |
18184
5f7f58866922
fix search and replace all in find dialog (bug #41051)
Torsten <ttl@justmail.de>
parents:
17790
diff
changeset
|
262 if (_rep_all) |
15177
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
263 { |
18184
5f7f58866922
fix search and replace all in find dialog (bug #41051)
Torsten <ttl@justmail.de>
parents:
17790
diff
changeset
|
264 if (_rep_all == 1) |
5f7f58866922
fix search and replace all in find dialog (bug #41051)
Torsten <ttl@justmail.de>
parents:
17790
diff
changeset
|
265 { |
5f7f58866922
fix search and replace all in find dialog (bug #41051)
Torsten <ttl@justmail.de>
parents:
17790
diff
changeset
|
266 line = 0; |
5f7f58866922
fix search and replace all in find dialog (bug #41051)
Torsten <ttl@justmail.de>
parents:
17790
diff
changeset
|
267 col = 0; |
5f7f58866922
fix search and replace all in find dialog (bug #41051)
Torsten <ttl@justmail.de>
parents:
17790
diff
changeset
|
268 } |
5f7f58866922
fix search and replace all in find dialog (bug #41051)
Torsten <ttl@justmail.de>
parents:
17790
diff
changeset
|
269 do_wrap = false; |
18854
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
270 // The following line is a workaround for the issue that when replacing |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
271 // a text with a new one with different size within the selection, |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
272 // the selection is not updated leading to missing or extra replacements. |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
273 // This does not happen, when the selection is search backwards |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
274 do_forward = ! _search_selection_check_box->isChecked (); |
18184
5f7f58866922
fix search and replace all in find dialog (bug #41051)
Torsten <ttl@justmail.de>
parents:
17790
diff
changeset
|
275 } |
5f7f58866922
fix search and replace all in find dialog (bug #41051)
Torsten <ttl@justmail.de>
parents:
17790
diff
changeset
|
276 else |
5f7f58866922
fix search and replace all in find dialog (bug #41051)
Torsten <ttl@justmail.de>
parents:
17790
diff
changeset
|
277 { |
5f7f58866922
fix search and replace all in find dialog (bug #41051)
Torsten <ttl@justmail.de>
parents:
17790
diff
changeset
|
278 if (_from_start_check_box->isChecked ()) |
5f7f58866922
fix search and replace all in find dialog (bug #41051)
Torsten <ttl@justmail.de>
parents:
17790
diff
changeset
|
279 { |
18854
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
280 if (do_forward) |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
281 { |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
282 line = 0; |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
283 col = 0; |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
284 } |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
285 else |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
286 { |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
287 line = _edit_area->lines () - 1; |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
288 col = _edit_area->text (line).length () - 1; |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
289 if (col == -1) |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
290 col = 0; |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
291 } |
18184
5f7f58866922
fix search and replace all in find dialog (bug #41051)
Torsten <ttl@justmail.de>
parents:
17790
diff
changeset
|
292 } |
15177
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
293 } |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
294 |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
295 if (_edit_area) |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
296 { |
18854
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
297 if (_edit_area->hasSelectedText () |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
298 && _search_selection_check_box->isChecked ()) |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
299 { |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
300 #ifdef HAVE_QSCI_FINDSELECTION |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
301 if (_find_result_available) |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
302 _find_result_available = _edit_area->findNext (); |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
303 else |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
304 _find_result_available |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
305 = _edit_area->findFirstInSelection ( |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
306 _search_line_edit->text (), |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
307 _regex_check_box->isChecked (), |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
308 _case_check_box->isChecked (), |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
309 _whole_words_check_box->isChecked (), |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
310 do_forward, |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
311 true |
16736
68ca4122e568
* find-dialog.cc(find): fix ifdef for qscintilla version according to cset 16733
Torsten <ttl@justmail.de>
parents:
16520
diff
changeset
|
312 #ifdef HAVE_QSCI_VERSION_2_6_0 |
18854
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
313 , true |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
314 #endif |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
315 ); |
15257
7ee62f559a73
Fix compilation under Windows with GUI and LLVM enabled.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15196
diff
changeset
|
316 #endif |
18854
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
317 } |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
318 else |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
319 { |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
320 _find_result_available |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
321 = _edit_area->findFirst (_search_line_edit->text (), |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
322 _regex_check_box->isChecked (), |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
323 _case_check_box->isChecked (), |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
324 _whole_words_check_box->isChecked (), |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
325 do_wrap, |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
326 do_forward, |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
327 line,col, |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
328 true |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
329 #ifdef HAVE_QSCI_VERSION_2_6_0 |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
330 , true |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
331 #endif |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
332 ); |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
333 } |
15177
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
334 } |
18854
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
335 |
16511
eee1b78d031f
gui: fix backward search in find dialog
Torsten <ttl@justmail.de>
parents:
15988
diff
changeset
|
336 if (_find_result_available) |
eee1b78d031f
gui: fix backward search in find dialog
Torsten <ttl@justmail.de>
parents:
15988
diff
changeset
|
337 _from_start_check_box->setChecked (0); |
18184
5f7f58866922
fix search and replace all in find dialog (bug #41051)
Torsten <ttl@justmail.de>
parents:
17790
diff
changeset
|
338 else if (! _rep_all) |
16520
086b5e81245b
find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents:
16516
diff
changeset
|
339 no_matches_message (); |
15177
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
340 } |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
341 |
18854
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
342 void |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
343 find_dialog::do_replace () |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
344 { |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
345 _rep_active = true; // changes in selection not made by the user |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
346 _edit_area->replace (_replace_line_edit->text ()); |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
347 _rep_active = false; |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
348 } |
15177
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
349 |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
350 void |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
351 find_dialog::replace () |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
352 { |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
353 if (_edit_area) |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
354 { |
18854
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
355 // The following line is a workaround for the issue that when replacing |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
356 // a text with a new one with different size within the selection, |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
357 // the selection is not updated leading to missing or extra replacements. |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
358 // This does not happen, when the selection is search backwards |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
359 if (_search_selection_check_box->isChecked ()) |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
360 _backward_check_box->setChecked (true); |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
361 |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
362 // do the replace if we have selected text |
18184
5f7f58866922
fix search and replace all in find dialog (bug #41051)
Torsten <ttl@justmail.de>
parents:
17790
diff
changeset
|
363 if (_find_result_available && _edit_area->hasSelectedText ()) |
18854
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
364 do_replace (); |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
365 |
18184
5f7f58866922
fix search and replace all in find dialog (bug #41051)
Torsten <ttl@justmail.de>
parents:
17790
diff
changeset
|
366 find_next (); |
15177
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
367 } |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
368 } |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
369 |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
370 void |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
371 find_dialog::replace_all () |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
372 { |
18184
5f7f58866922
fix search and replace all in find dialog (bug #41051)
Torsten <ttl@justmail.de>
parents:
17790
diff
changeset
|
373 int line, col; |
15177
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
374 |
18184
5f7f58866922
fix search and replace all in find dialog (bug #41051)
Torsten <ttl@justmail.de>
parents:
17790
diff
changeset
|
375 if (_edit_area) |
15177
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
376 { |
18184
5f7f58866922
fix search and replace all in find dialog (bug #41051)
Torsten <ttl@justmail.de>
parents:
17790
diff
changeset
|
377 _edit_area->getCursorPosition (&line,&col); |
15177
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
378 |
18184
5f7f58866922
fix search and replace all in find dialog (bug #41051)
Torsten <ttl@justmail.de>
parents:
17790
diff
changeset
|
379 _rep_all = 1; |
5f7f58866922
fix search and replace all in find dialog (bug #41051)
Torsten <ttl@justmail.de>
parents:
17790
diff
changeset
|
380 find_next (); // find first occurence (forward) |
15177
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
381 while (_find_result_available) // while search string is found |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
382 { |
18854
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
383 do_replace (); |
18184
5f7f58866922
fix search and replace all in find dialog (bug #41051)
Torsten <ttl@justmail.de>
parents:
17790
diff
changeset
|
384 _rep_all++; // inc counter |
5f7f58866922
fix search and replace all in find dialog (bug #41051)
Torsten <ttl@justmail.de>
parents:
17790
diff
changeset
|
385 find_next (); // find next |
15177
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
386 } |
18184
5f7f58866922
fix search and replace all in find dialog (bug #41051)
Torsten <ttl@justmail.de>
parents:
17790
diff
changeset
|
387 |
16520
086b5e81245b
find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents:
16516
diff
changeset
|
388 QMessageBox msg_box (QMessageBox::Information, tr ("Replace Result"), |
18184
5f7f58866922
fix search and replace all in find dialog (bug #41051)
Torsten <ttl@justmail.de>
parents:
17790
diff
changeset
|
389 tr ("%1 items replaced").arg(_rep_all-1), |
16520
086b5e81245b
find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents:
16516
diff
changeset
|
390 QMessageBox::Ok, this); |
086b5e81245b
find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents:
16516
diff
changeset
|
391 msg_box.exec (); |
18184
5f7f58866922
fix search and replace all in find dialog (bug #41051)
Torsten <ttl@justmail.de>
parents:
17790
diff
changeset
|
392 |
5f7f58866922
fix search and replace all in find dialog (bug #41051)
Torsten <ttl@justmail.de>
parents:
17790
diff
changeset
|
393 _rep_all = 0; |
18854
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
394 _find_result_available = false; |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
395 |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
396 if (! _search_selection_check_box->isChecked ()) |
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
397 _edit_area->setCursorPosition (line,col); |
15177
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
398 } |
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
399 } |
15873
7d300b85ee25
allow build to proceed if either Qt or QScintilla is missing
John W. Eaton <jwe@octave.org>
parents:
15368
diff
changeset
|
400 |
16520
086b5e81245b
find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents:
16516
diff
changeset
|
401 void |
086b5e81245b
find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents:
16516
diff
changeset
|
402 find_dialog::no_matches_message () |
086b5e81245b
find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents:
16516
diff
changeset
|
403 { |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17007
diff
changeset
|
404 QMessageBox msg_box (QMessageBox::Information, tr ("Find Result"), |
16520
086b5e81245b
find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents:
16516
diff
changeset
|
405 tr ("No more matches found"), QMessageBox::Ok, this); |
086b5e81245b
find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents:
16516
diff
changeset
|
406 msg_box.exec (); |
086b5e81245b
find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents:
16516
diff
changeset
|
407 } |
086b5e81245b
find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents:
16516
diff
changeset
|
408 |
086b5e81245b
find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents:
16516
diff
changeset
|
409 |
15873
7d300b85ee25
allow build to proceed if either Qt or QScintilla is missing
John W. Eaton <jwe@octave.org>
parents:
15368
diff
changeset
|
410 #endif |