Mercurial > octave
annotate libgui/src/m-editor/find-dialog.cc @ 27837:6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
* find-dialog.cc (find_dialog): use a combo-box instead line edit for search
and replace texts, do not use signal on text changes anymore;
(save_settings): clean up mru lists and save them in the preferences file;
(restore_settings): get mru lists from preferences file, clip length to
its maximum length and add items to the combo-boxes
(handle_search_text_changed): return if current text is the first in the
mru list, update mru list;
(handle_replace_text_changed): new method for updating replace mru list
(mru_update): new method for doing the update of the desired mrulist,
removing empty entries, removing the current text an inserting the
current text at the beginning;
(init_search_text): updates due to changing from line edit to combo-box;
(find): call method for updating search text mru list with current text,
updates due to changing from line edit to combo-box;
(do_replace): updates due to changing from line edit to combo-box;
(replace, replace_all): call method for updating replace mru list with
current text;
* find-dialog.h: handle_search_text_changed with no argiments, new method
handle_replace_text_changed and mru_update, switched from line edit to
combo-box, new const for mru max length
author | Torsten Lilge <ttl-octave@mailbox.org> |
---|---|
date | Sun, 15 Dec 2019 10:38:14 +0100 |
parents | 5169ed0ff0f0 |
children | e79999c5d782 |
rev | line source |
---|---|
20946 | 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 |
27787
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
5 Copyright (C) 2012-2019 Torsten Lilge <ttl-octave@mailbox.org> |
16520
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 |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23449
diff
changeset
|
12 Octave is free software: you can redistribute it and/or modify it |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22411
diff
changeset
|
13 under the terms of the GNU General Public License as published by |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23449
diff
changeset
|
14 the Free Software Foundation, either version 3 of the License, or |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22411
diff
changeset
|
15 (at your option) any later version. |
16520
086b5e81245b
find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents:
16516
diff
changeset
|
16 |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22411
diff
changeset
|
17 Octave is distributed in the hope that it will be useful, but |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22411
diff
changeset
|
18 WITHOUT ANY WARRANTY; without even the implied warranty of |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22411
diff
changeset
|
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22411
diff
changeset
|
20 GNU General Public License for more details. |
16520
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 |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23449
diff
changeset
|
24 <https://www.gnu.org/licenses/>. |
16520
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 |
24893
a3eb0d746042
doc: use canonical https URLs for all external gnu.org references
Mike Miller <mtmiller@octave.org>
parents:
24716
diff
changeset
|
41 ** will be met: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
15177
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 |
24893
a3eb0d746042
doc: use canonical https URLs for all external gnu.org references
Mike Miller <mtmiller@octave.org>
parents:
24716
diff
changeset
|
53 ** met: https://www.gnu.org/copyleft/gpl.html. |
15177
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 ** |
20946 | 59 |
60 */ | |
15177
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
61 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21706
diff
changeset
|
62 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21203
diff
changeset
|
63 # include "config.h" |
15286
ae9079bbc627
Add '#include <config.h>' to C++ files in libgui/src
Rik <rik@octave.org>
parents:
15257
diff
changeset
|
64 #endif |
ae9079bbc627
Add '#include <config.h>' to C++ files in libgui/src
Rik <rik@octave.org>
parents:
15257
diff
changeset
|
65 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21706
diff
changeset
|
66 #if defined (HAVE_QSCINTILLA) |
15873
7d300b85ee25
allow build to proceed if either Qt or QScintilla is missing
John W. Eaton <jwe@octave.org>
parents:
15368
diff
changeset
|
67 |
22250
2fd4f1a3f4a8
allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
22169
diff
changeset
|
68 #include <QCheckBox> |
2fd4f1a3f4a8
allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
22169
diff
changeset
|
69 #include <QCheckBox> |
27837
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
70 #include <QCompleter> |
22250
2fd4f1a3f4a8
allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
22169
diff
changeset
|
71 #include <QDialogButtonBox> |
2fd4f1a3f4a8
allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
22169
diff
changeset
|
72 #include <QGridLayout> |
15177
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
73 #include <QIcon> |
22250
2fd4f1a3f4a8
allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
22169
diff
changeset
|
74 #include <QLabel> |
2fd4f1a3f4a8
allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
22169
diff
changeset
|
75 #include <QLineEdit> |
2fd4f1a3f4a8
allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
22169
diff
changeset
|
76 #include <QMessageBox> |
2fd4f1a3f4a8
allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
22169
diff
changeset
|
77 #include <QPushButton> |
2fd4f1a3f4a8
allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
22169
diff
changeset
|
78 #include <QVBoxLayout> |
2fd4f1a3f4a8
allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
22169
diff
changeset
|
79 |
15177
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
80 #include "find-dialog.h" |
27787
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
81 #include "gui-preferences-ed.h" |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
82 #include "resource-manager.h" |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
83 #include "octave-qobject.h" |
15177
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
84 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
85 namespace octave |
15177
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
86 { |
27787
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
87 find_dialog::find_dialog (base_qobject& oct_qobj, |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
88 octave_dock_widget *ed, QWidget *p) |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
89 : QDialog (p), m_octave_qobj (oct_qobj), m_editor (ed), |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
90 m_in_sel (false), m_sel_beg (-1), m_sel_end (-1) |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
91 { |
27787
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
92 setWindowTitle (tr ("Editor: Find and Replace")); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
93 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
|
94 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
95 _search_label = new QLabel (tr ("Find &what:")); |
27837
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
96 _search_line_edit = new QComboBox (this); |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
97 _search_line_edit->setToolTip (tr ("Enter text to search for")); |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
98 _search_line_edit->setEditable (true); |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
99 _search_line_edit->setMaxCount (m_mru_length); |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
100 _search_line_edit->completer ()->setCaseSensitivity (Qt::CaseSensitive); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
101 _search_label->setBuddy (_search_line_edit); |
27837
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
102 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
103 _replace_label = new QLabel (tr ("Re&place with:")); |
27837
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
104 _replace_line_edit = new QComboBox (this); |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
105 _replace_line_edit->setToolTip (tr ("Enter new text replacing search hits")); |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
106 _replace_line_edit->setEditable (true); |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
107 _replace_line_edit->setMaxCount (m_mru_length); |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
108 _replace_line_edit->completer ()->setCaseSensitivity (Qt::CaseSensitive); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
109 _replace_label->setBuddy (_replace_line_edit); |
15177
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
110 |
27837
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
111 int width = QFontMetrics (_search_line_edit->font ()).averageCharWidth(); |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
112 _search_line_edit->setFixedWidth (20*width); |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
113 _replace_line_edit->setFixedWidth (20*width); |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
114 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
115 _case_check_box = new QCheckBox (tr ("Match &case")); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
116 _from_start_check_box = new QCheckBox (tr ("Search from &start")); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
117 _wrap_check_box = new QCheckBox (tr ("&Wrap while searching")); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
118 _wrap_check_box->setChecked (true); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
119 _find_next_button = new QPushButton (tr ("&Find Next")); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
120 _find_prev_button = new QPushButton (tr ("Find &Previous")); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
121 _replace_button = new QPushButton (tr ("&Replace")); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
122 _replace_all_button = new QPushButton (tr ("Replace &All")); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
123 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
124 _more_button = new QPushButton (tr ("&More...")); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
125 _more_button->setCheckable (true); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
126 _more_button->setAutoDefault (false); |
15177
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
127 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
128 _button_box = new QDialogButtonBox (Qt::Vertical); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
129 _button_box->addButton (_find_next_button, QDialogButtonBox::ActionRole); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
130 _button_box->addButton (_find_prev_button, QDialogButtonBox::ActionRole); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
131 _button_box->addButton (_replace_button, QDialogButtonBox::ActionRole); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
132 _button_box->addButton (_replace_all_button, QDialogButtonBox::ActionRole); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
133 _button_box->addButton (_more_button, QDialogButtonBox::ActionRole); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
134 _button_box->addButton (QDialogButtonBox::Close); |
18854
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
135 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
136 _extension = new QWidget (this); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
137 _whole_words_check_box = new QCheckBox (tr ("&Whole words")); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
138 _regex_check_box = new QCheckBox (tr ("Regular E&xpressions")); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
139 _backward_check_box = new QCheckBox (tr ("Search &backward")); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
140 _search_selection_check_box = new QCheckBox (tr ("Search se&lection")); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
141 _search_selection_check_box->setCheckable (true); |
15177
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
142 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
143 connect (_find_next_button, SIGNAL (clicked ()), |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
144 this, SLOT (find_next ())); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
145 connect (_find_prev_button, SIGNAL (clicked ()), |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
146 this, SLOT (find_prev ())); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
147 connect (_more_button, SIGNAL (toggled (bool)), |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
148 _extension, SLOT (setVisible (bool))); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
149 connect (_replace_button, SIGNAL (clicked ()), |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
150 this, SLOT (replace ())); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
151 connect (_replace_all_button, SIGNAL (clicked ()), |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
152 this, SLOT (replace_all ())); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
153 connect (_backward_check_box, SIGNAL (stateChanged (int)), |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
154 this, SLOT (handle_backward_search_changed (int))); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
155 connect (_button_box, SIGNAL (rejected ()), |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
156 this, SLOT (close ())); |
18854
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
157 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
158 connect (_search_selection_check_box, SIGNAL (stateChanged (int)), |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
159 this, SLOT (handle_sel_search_changed (int))); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
160 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
161 QVBoxLayout *extension_layout = new QVBoxLayout (); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
162 extension_layout->setMargin (0); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
163 extension_layout->addWidget (_whole_words_check_box); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
164 extension_layout->addWidget (_backward_check_box); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
165 extension_layout->addWidget (_search_selection_check_box); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
166 _extension->setLayout (extension_layout); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
167 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
168 QGridLayout *top_left_layout = new QGridLayout; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
169 top_left_layout->addWidget (_search_label, 1, 1); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
170 top_left_layout->addWidget (_search_line_edit, 1, 2); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
171 top_left_layout->addWidget (_replace_label, 2, 1); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
172 top_left_layout->addWidget (_replace_line_edit, 2, 2); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
173 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
174 QVBoxLayout *left_layout = new QVBoxLayout; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
175 left_layout->addLayout (top_left_layout); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
176 left_layout->insertStretch (1, 5); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
177 left_layout->addWidget (_case_check_box); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
178 left_layout->addWidget (_from_start_check_box); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
179 left_layout->addWidget (_wrap_check_box); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
180 left_layout->addWidget (_regex_check_box); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
181 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
182 QGridLayout *main_layout = new QGridLayout; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
183 main_layout->setSizeConstraint (QLayout::SetFixedSize); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
184 main_layout->addLayout (left_layout, 0, 0); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
185 main_layout->addWidget (_button_box, 0, 1); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
186 main_layout->addWidget (_extension, 1, 0); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
187 setLayout (main_layout); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
188 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
189 _extension->hide (); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
190 _find_next_button->setDefault (true); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
191 _find_result_available = false; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
192 _rep_all = 0; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
193 _rep_active = false; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
194 |
27787
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
195 // Connect required external signals |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
196 connect (ed, SIGNAL (edit_area_changed (octave_qscintilla*)), |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
197 this, SLOT (update_edit_area (octave_qscintilla*))); |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
198 |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
199 setWindowModality (Qt::NonModal); |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
200 |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
201 setAttribute(Qt::WA_ShowWithoutActivating); |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
202 setAttribute(Qt::WA_DeleteOnClose); |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
203 } |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
204 |
27787
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
205 // The edit_area has changed: update relevant data of the file dialog |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
206 void find_dialog::update_edit_area (octave_qscintilla* edit_area) |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
207 { |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
208 _edit_area = edit_area; |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
209 _search_selection_check_box->setEnabled (edit_area->hasSelectedText ()); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
210 |
27787
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
211 connect (_edit_area, SIGNAL (copyAvailable (bool)), |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
212 this, SLOT (handle_selection_changed (bool)), |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
213 Qt::UniqueConnection); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
214 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
215 |
27787
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
216 void find_dialog::save_settings () |
27089
9326c2258e60
fix visibility of find dialog when editor is docked/undocked (bug #5)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26454
diff
changeset
|
217 { |
27787
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
218 resource_manager& rmgr = m_octave_qobj.get_resource_manager (); |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
219 gui_settings *s = rmgr.get_settings (); |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
220 |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
221 // Save position and fix offset it by the frame geometry |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
222 int fy = 2; |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
223 if (m_editor->isFloating ()) |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
224 fy = 1; |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
225 |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
226 int dy = geometry ().y () - frameGeometry ().y (); |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
227 QPoint dlg_pos = pos (); |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
228 |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
229 m_last_position = QPoint (dlg_pos.x (), dlg_pos.y () + fy*dy); |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
230 |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
231 s->setValue (ed_fdlg_pos.key, m_last_position); |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
232 |
27837
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
233 // Is current search/replace text in the mru list? |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
234 mru_update (_search_line_edit); |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
235 mru_update (_replace_line_edit); |
27787
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
236 |
27837
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
237 // Store mru lists |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
238 QStringList mru; |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
239 for (int i = 0; i < _search_line_edit->count (); i++) |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
240 mru.append (_search_line_edit->itemText (i)); |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
241 s->setValue (ed_fdlg_search.key, mru); |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
242 |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
243 mru.clear (); |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
244 for (int i = 0; i < _replace_line_edit->count (); i++) |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
245 mru.append (_replace_line_edit->itemText (i)); |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
246 s->setValue (ed_fdlg_replace.key, mru); |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
247 |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
248 // Store dialog's options |
27787
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
249 int opts = 0 |
27089
9326c2258e60
fix visibility of find dialog when editor is docked/undocked (bug #5)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26454
diff
changeset
|
250 + _extension->isVisible () * FIND_DLG_MORE |
9326c2258e60
fix visibility of find dialog when editor is docked/undocked (bug #5)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26454
diff
changeset
|
251 + _case_check_box->isChecked () * FIND_DLG_CASE |
9326c2258e60
fix visibility of find dialog when editor is docked/undocked (bug #5)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26454
diff
changeset
|
252 + _from_start_check_box->isChecked () * FIND_DLG_START |
9326c2258e60
fix visibility of find dialog when editor is docked/undocked (bug #5)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26454
diff
changeset
|
253 + _wrap_check_box->isChecked () * FIND_DLG_WRAP |
9326c2258e60
fix visibility of find dialog when editor is docked/undocked (bug #5)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26454
diff
changeset
|
254 + _regex_check_box->isChecked () * FIND_DLG_REGX |
9326c2258e60
fix visibility of find dialog when editor is docked/undocked (bug #5)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26454
diff
changeset
|
255 + _whole_words_check_box->isChecked () * FIND_DLG_WORDS |
9326c2258e60
fix visibility of find dialog when editor is docked/undocked (bug #5)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26454
diff
changeset
|
256 + _backward_check_box->isChecked () * FIND_DLG_BACK |
9326c2258e60
fix visibility of find dialog when editor is docked/undocked (bug #5)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26454
diff
changeset
|
257 + _search_selection_check_box->isChecked () * FIND_DLG_SEL; |
27787
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
258 s->setValue (ed_fdlg_opts.key, opts); |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
259 |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
260 s->sync (); |
27089
9326c2258e60
fix visibility of find dialog when editor is docked/undocked (bug #5)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26454
diff
changeset
|
261 } |
9326c2258e60
fix visibility of find dialog when editor is docked/undocked (bug #5)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26454
diff
changeset
|
262 |
27787
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
263 void find_dialog::restore_settings (QPoint ed_bottom_right) |
27089
9326c2258e60
fix visibility of find dialog when editor is docked/undocked (bug #5)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26454
diff
changeset
|
264 { |
27787
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
265 resource_manager& rmgr = m_octave_qobj.get_resource_manager (); |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
266 gui_settings *s = rmgr.get_settings (); |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
267 |
27837
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
268 // Get mru lists for search and replace text |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
269 QStringList mru = s->value (ed_fdlg_search.key).toStringList (); |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
270 while (mru.length () > m_mru_length) |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
271 mru.removeLast (); |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
272 _search_line_edit->addItems (mru); |
27787
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
273 |
27837
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
274 mru = s->value (ed_fdlg_replace.key).toStringList (); |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
275 while (mru.length () > m_mru_length) |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
276 mru.removeLast (); |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
277 _replace_line_edit->addItems (mru); |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
278 |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
279 // Get the dialog's options |
27787
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
280 int opts = s->value (ed_fdlg_opts.key, ed_fdlg_opts.def).toInt (); |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
281 |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
282 _extension->setVisible (FIND_DLG_MORE & opts); |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
283 _case_check_box->setChecked (FIND_DLG_CASE & opts); |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
284 _from_start_check_box->setChecked (FIND_DLG_START & opts); |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
285 _wrap_check_box->setChecked (FIND_DLG_WRAP & opts); |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
286 _regex_check_box->setChecked (FIND_DLG_REGX & opts); |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
287 _whole_words_check_box->setChecked (FIND_DLG_WORDS & opts); |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
288 _backward_check_box->setChecked (FIND_DLG_BACK & opts); |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
289 _search_selection_check_box->setChecked (FIND_DLG_SEL & opts); |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
290 |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
291 // Position: lower right of editor's position |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
292 int xp = ed_bottom_right.x () - sizeHint ().width (); |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
293 int yp = ed_bottom_right.y () - sizeHint ().height (); |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
294 |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
295 m_last_position = s->value (ed_fdlg_pos.key, QPoint (xp,yp)).toPoint (); |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
296 |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
297 move (m_last_position); |
27089
9326c2258e60
fix visibility of find dialog when editor is docked/undocked (bug #5)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26454
diff
changeset
|
298 } |
9326c2258e60
fix visibility of find dialog when editor is docked/undocked (bug #5)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26454
diff
changeset
|
299 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
300 // set text of "search from start" depending on backward search |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
301 void find_dialog::handle_backward_search_changed (int backward) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
302 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
303 if (backward) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
304 _from_start_check_box->setText (tr ("Search from end")); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
305 else |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
306 _from_start_check_box->setText (tr ("Search from start")); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
307 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
308 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
309 // search text has changed: reset the search |
27837
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
310 void find_dialog::handle_search_text_changed (void) |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
311 { |
27837
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
312 // Return if nothing has changed |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
313 if (_search_line_edit->currentText () == _search_line_edit->itemText (0)) |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
314 return; |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
315 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
316 if (_search_selection_check_box->isChecked ()) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
317 _find_result_available = false; |
27837
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
318 |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
319 mru_update (_search_line_edit); |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
320 } |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
321 |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
322 // replaced text has changed: reset the search |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
323 void find_dialog::handle_replace_text_changed (void) |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
324 { |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
325 // Return if nothing has changed |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
326 if (_replace_line_edit->currentText () |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
327 == _replace_line_edit->itemText (0)) |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
328 return; |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
329 |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
330 mru_update (_replace_line_edit); |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
331 } |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
332 |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
333 // Update the mru list |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
334 void find_dialog::mru_update (QComboBox *mru) |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
335 { |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
336 // Remove possible empty entries from the mru list |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
337 int index; |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
338 while ((index = mru->findText (QString ())) >= 0) |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
339 mru->removeItem (index); |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
340 |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
341 // Get current text and return if it is empty |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
342 QString text = mru->currentText (); |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
343 |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
344 if (text.isEmpty ()) |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
345 return; |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
346 |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
347 // Remove occurrences of the current text in the mru list |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
348 while ((index = mru->findText (text)) >= 0) |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
349 mru->removeItem (index); |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
350 |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
351 // Remove the last entry from the end if the list is full |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
352 if (mru->count () == m_mru_length) |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
353 mru->removeItem (m_mru_length -1); |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
354 |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
355 // Insert new item at the beginning and set it as current item |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
356 mru->insertItem (0, text); |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
357 mru->setCurrentIndex (0); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
358 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
359 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
360 void find_dialog::handle_sel_search_changed (int selected) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
361 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
362 _from_start_check_box->setEnabled (! selected); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
363 _find_result_available = false; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
364 } |
18854
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
365 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
366 void find_dialog::handle_selection_changed (bool has_selected) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
367 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
368 if (_rep_active) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
369 return; |
18854
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
370 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
371 _search_selection_check_box->setEnabled (has_selected); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
372 _find_result_available = false; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
373 } |
18854
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
374 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
375 // initialize search text with selected text if this is in one single line |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
376 void find_dialog::init_search_text (void) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
377 { |
26454
aced09cc1721
fix utilize pointer before verifying in find dialog (bug #55347)
Torsten <mttl@mailbox.org>
parents:
26376
diff
changeset
|
378 if (_edit_area && _edit_area->hasSelectedText ()) |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
379 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
380 int lbeg, lend, cbeg, cend; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
381 _edit_area->getSelection (&lbeg,&cbeg,&lend,&cend); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
382 if (lbeg == lend) |
27837
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
383 _search_line_edit->setCurrentText (_edit_area->selectedText ()); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
384 } |
20445
d3f39abe119b
GUI-Find: keep focus on Find What and select all text when dialog opens
Rafael Monteiro <rafaelgomesmonteiro@gmail.com>
parents:
20181
diff
changeset
|
385 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
386 // set focus to "Find what" and select all text |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
387 _search_line_edit->setFocus (); |
27837
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
388 _search_line_edit->lineEdit ()->selectAll (); |
21706
cce4eb3f6f7c
Prevent find dialog defaulting to "replace all" (bug #47561).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21301
diff
changeset
|
389 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
390 // Default to "find" next time. |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
391 // Otherwise, it defaults to the last action, which may be "replace all". |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
392 _find_next_button->setDefault (true); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
393 } |
15988
38348a6c3db0
gui: initialize search text in the find dialog with selected text in editor file
Torsten <ttl@justmail.de>
parents:
15873
diff
changeset
|
394 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
395 void find_dialog::find_next (void) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
396 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
397 find (! _backward_check_box->isChecked ()); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
398 } |
15988
38348a6c3db0
gui: initialize search text in the find dialog with selected text in editor file
Torsten <ttl@justmail.de>
parents:
15873
diff
changeset
|
399 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
400 void find_dialog::find_prev (void) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
401 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
402 find (_backward_check_box->isChecked ()); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
403 } |
16520
086b5e81245b
find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents:
16516
diff
changeset
|
404 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
405 void find_dialog::find (bool forward) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
406 { |
26454
aced09cc1721
fix utilize pointer before verifying in find dialog (bug #55347)
Torsten <mttl@mailbox.org>
parents:
26376
diff
changeset
|
407 if (! _edit_area) |
aced09cc1721
fix utilize pointer before verifying in find dialog (bug #55347)
Torsten <mttl@mailbox.org>
parents:
26376
diff
changeset
|
408 return; |
aced09cc1721
fix utilize pointer before verifying in find dialog (bug #55347)
Torsten <mttl@mailbox.org>
parents:
26376
diff
changeset
|
409 |
27837
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
410 handle_search_text_changed (); |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
411 |
27455
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
412 // line adn col: -1 means search starts at current position |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
413 int line = -1, col = -1; |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
414 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
415 bool do_wrap = _wrap_check_box->isChecked (); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
416 bool do_forward = forward; |
16511
eee1b78d031f
gui: fix backward search in find dialog
Torsten <ttl@justmail.de>
parents:
15988
diff
changeset
|
417 |
27455
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
418 // Initialize the selection begin and end if it is the first search |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
419 if (! _find_result_available) |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
420 { |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
421 if (_search_selection_check_box->isChecked () |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
422 && _edit_area->hasSelectedText ()) |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
423 { |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
424 int l1, c1, l2, c2; |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
425 _edit_area->getSelection (&l1, &c1, &l2, &c2); |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
426 |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
427 // Store the position of the selection |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
428 m_sel_beg = _edit_area->positionFromLineIndex (l1, c1); |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
429 m_sel_end = _edit_area->positionFromLineIndex (l2, c2); |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
430 m_in_sel = true; |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
431 } |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
432 else |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
433 m_in_sel = false; |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
434 } |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
435 |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
436 // Get the correct line/col for beginning the search |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
437 if (_rep_all) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
438 { |
27455
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
439 // Replace All |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
440 if (_rep_all == 1) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
441 { |
27455
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
442 // Start at the beginning of file/sel if it is the first try |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
443 if (m_in_sel) |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
444 _edit_area->lineIndexFromPosition (m_sel_beg, &line, &col); |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
445 else |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
446 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
447 line = 0; |
18854
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
448 col = 0; |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
449 } |
27455
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
450 } |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
451 do_wrap = false; // Never wrap when replacing all |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
452 } |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
453 else |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
454 { |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
455 // Normal search (not replace all): calculate start position of |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
456 // search (in file or selection) |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
457 if (_from_start_check_box->isChecked () |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
458 || (m_in_sel && (! _find_result_available))) |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
459 { |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
460 // From the beginning or the end of file/sel |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
461 if (do_forward) |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
462 { |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
463 // From the beginning |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
464 if (m_in_sel) |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
465 _edit_area->lineIndexFromPosition (m_sel_beg, &line, &col); |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
466 else |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
467 { |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
468 line = 0; |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
469 col = 0; |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
470 } |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
471 } |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
472 else |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
473 { |
27455
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
474 // From the end |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
475 if (m_in_sel) |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
476 _edit_area->lineIndexFromPosition (m_sel_end, &line, &col); |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
477 else |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
478 { |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
479 line = _edit_area->lines () - 1; |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
480 col = _edit_area->text (line).length () - 1; |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
481 if (col == -1) |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
482 col = 0; |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
483 } |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
484 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
485 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
486 else if (! do_forward) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
487 { |
27455
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
488 // Start from where the cursor is. Fix QScintilla's cursor |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
489 // positioning |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
490 _edit_area->getCursorPosition (&line,&col); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
491 if (_find_result_available && _edit_area->hasSelectedText ()) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
492 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
493 int currpos = _edit_area->positionFromLineIndex (line,col); |
27837
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
494 currpos -= (_search_line_edit->currentText ().length ()); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
495 if (currpos < 0) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
496 currpos = 0; |
27455
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
497 _edit_area->lineIndexFromPosition (currpos, &line, &col); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
498 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
499 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
500 } |
15177
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
501 |
27455
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
502 // Do the search |
27276
7455523fdf01
style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents:
27133
diff
changeset
|
503 _find_result_available |
27837
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
504 = _edit_area->findFirst (_search_line_edit->currentText (), |
27276
7455523fdf01
style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents:
27133
diff
changeset
|
505 _regex_check_box->isChecked (), |
7455523fdf01
style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents:
27133
diff
changeset
|
506 _case_check_box->isChecked (), |
7455523fdf01
style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents:
27133
diff
changeset
|
507 _whole_words_check_box->isChecked (), |
7455523fdf01
style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents:
27133
diff
changeset
|
508 do_wrap, |
7455523fdf01
style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents:
27133
diff
changeset
|
509 do_forward, |
7455523fdf01
style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents:
27133
diff
changeset
|
510 line,col, |
7455523fdf01
style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents:
27133
diff
changeset
|
511 true |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
512 #if defined (HAVE_QSCI_VERSION_2_6_0) |
27276
7455523fdf01
style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents:
27133
diff
changeset
|
513 , true |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
514 #endif |
27276
7455523fdf01
style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents:
27133
diff
changeset
|
515 ); |
27455
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
516 |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
517 if (_find_result_available) |
26454
aced09cc1721
fix utilize pointer before verifying in find dialog (bug #55347)
Torsten <mttl@mailbox.org>
parents:
26376
diff
changeset
|
518 { |
27455
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
519 // Search successful: reset search-from-start box and check for |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
520 // the current selection |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
521 _from_start_check_box->setChecked (0); |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
522 |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
523 if (m_in_sel) |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
524 { |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
525 _edit_area->getCursorPosition (&line,&col); |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
526 int pos = _edit_area->positionFromLineIndex (line, col); |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
527 |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
528 int l1, c1, l2, c2; |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
529 _edit_area->lineIndexFromPosition (m_sel_beg, &l1, &c1); |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
530 _edit_area->lineIndexFromPosition (m_sel_end, &l2, &c2); |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
531 _edit_area->show_selection_markers (l1, c1, l2, c2); |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
532 |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
533 // Check if new start position is still wihtin the selection |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
534 _find_result_available = pos >= m_sel_beg && pos <= m_sel_end; |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
535 } |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
536 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
537 |
27455
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
538 // No more search hits |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
539 if (! _find_result_available) |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
540 { |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
541 if (m_in_sel) |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
542 { |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
543 // Restore real selection and remove marker for selection |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
544 int l1, c1, l2, c2; |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
545 _edit_area->lineIndexFromPosition (m_sel_beg, &l1, &c1); |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
546 _edit_area->lineIndexFromPosition (m_sel_end, &l2, &c2); |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
547 _edit_area->setSelection (l1, c1, l2, c2); |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
548 _edit_area->clear_selection_markers (); |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
549 } |
26454
aced09cc1721
fix utilize pointer before verifying in find dialog (bug #55347)
Torsten <mttl@mailbox.org>
parents:
26376
diff
changeset
|
550 |
27455
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
551 // Display message if not replace all |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
552 if (! _rep_all) |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
553 no_matches_message (); |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
554 } |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
555 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
556 } |
18854
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
557 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
558 void find_dialog::do_replace (void) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
559 { |
26454
aced09cc1721
fix utilize pointer before verifying in find dialog (bug #55347)
Torsten <mttl@mailbox.org>
parents:
26376
diff
changeset
|
560 if (_edit_area) |
aced09cc1721
fix utilize pointer before verifying in find dialog (bug #55347)
Torsten <mttl@mailbox.org>
parents:
26376
diff
changeset
|
561 { |
aced09cc1721
fix utilize pointer before verifying in find dialog (bug #55347)
Torsten <mttl@mailbox.org>
parents:
26376
diff
changeset
|
562 _rep_active = true; // changes in selection not made by the user |
27455
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
563 |
27837
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
564 _edit_area->replace (_replace_line_edit->currentText ()); |
27455
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
565 if (m_in_sel) |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
566 { |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
567 // Update the length of the selection |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
568 m_sel_end = m_sel_end |
27837
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
569 - _search_line_edit->currentText ().toUtf8 ().size () |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
570 + _replace_line_edit->currentText ().toUtf8 ().size (); |
27455
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
571 } |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
572 |
26454
aced09cc1721
fix utilize pointer before verifying in find dialog (bug #55347)
Torsten <mttl@mailbox.org>
parents:
26376
diff
changeset
|
573 _rep_active = false; |
aced09cc1721
fix utilize pointer before verifying in find dialog (bug #55347)
Torsten <mttl@mailbox.org>
parents:
26376
diff
changeset
|
574 } |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
575 } |
15177
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
576 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
577 void find_dialog::replace (void) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
578 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
579 if (_edit_area) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
580 { |
27837
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
581 handle_replace_text_changed (); |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
582 |
27455
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
583 // Do the replace if we have selected text |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
584 if (_find_result_available && _edit_area->hasSelectedText ()) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
585 do_replace (); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
586 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
587 find_next (); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
588 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
589 } |
18854
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
590 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
591 void find_dialog::replace_all (void) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
592 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
593 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
|
594 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
595 if (_edit_area) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
596 { |
27837
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
597 handle_replace_text_changed (); |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
598 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
599 _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
|
600 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
601 _rep_all = 1; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
602 find_next (); // find first occurence (forward) |
27127
8854d65e3bcc
undo a complete replace all action in the editor (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26454
diff
changeset
|
603 |
8854d65e3bcc
undo a complete replace all action in the editor (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26454
diff
changeset
|
604 _edit_area->beginUndoAction (); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
605 while (_find_result_available) // while search string is found |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
606 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
607 do_replace (); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
608 _rep_all++; // inc counter |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
609 find_next (); // find next |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
610 } |
27127
8854d65e3bcc
undo a complete replace all action in the editor (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26454
diff
changeset
|
611 _edit_area->endUndoAction (); |
18184
5f7f58866922
fix search and replace all in find dialog (bug #41051)
Torsten <ttl@justmail.de>
parents:
17790
diff
changeset
|
612 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
613 QMessageBox msg_box (QMessageBox::Information, tr ("Replace Result"), |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
614 tr ("%1 items replaced").arg (_rep_all-1), |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
615 QMessageBox::Ok, this); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
616 msg_box.exec (); |
18184
5f7f58866922
fix search and replace all in find dialog (bug #41051)
Torsten <ttl@justmail.de>
parents:
17790
diff
changeset
|
617 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
618 _rep_all = 0; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
619 _find_result_available = false; |
18854
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
620 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
621 if (! _search_selection_check_box->isChecked ()) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
622 _edit_area->setCursorPosition (line,col); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
623 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
624 } |
15873
7d300b85ee25
allow build to proceed if either Qt or QScintilla is missing
John W. Eaton <jwe@octave.org>
parents:
15368
diff
changeset
|
625 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
626 void find_dialog::no_matches_message (void) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
627 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
628 QMessageBox msg_box (QMessageBox::Information, tr ("Find Result"), |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
629 tr ("No more matches found"), QMessageBox::Ok, this); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
630 msg_box.exec (); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
631 } |
27787
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
632 |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
633 void find_dialog::reject () |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
634 { |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
635 close (); |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
636 } |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
637 |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
638 void find_dialog::closeEvent (QCloseEvent *e) |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
639 { |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
640 save_settings (); |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
641 e->accept (); |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
642 } |
16520
086b5e81245b
find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents:
16516
diff
changeset
|
643 |
27787
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
644 // Show and hide with (re-)storing position, otherwise there is always |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
645 // a small shift each time the dialog is shown again |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
646 void find_dialog::set_visible (bool visible) |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
647 { |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
648 if (visible) |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
649 { |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
650 show (); |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
651 move (m_last_position); |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
652 } |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
653 else |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
654 { |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
655 m_last_position = pos (); |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
656 hide (); |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
657 } |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
658 } |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
659 |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
660 } |
15873
7d300b85ee25
allow build to proceed if either Qt or QScintilla is missing
John W. Eaton <jwe@octave.org>
parents:
15368
diff
changeset
|
661 #endif |