annotate libgui/src/m-editor/find-dialog.cc @ 17790:86c6ae5f969e

Use GNU style coding conventions for code in libgui/ * libgui/qterminal/libqterminal/QTerminal.h, libgui/src/color-picker.cc, libgui/src/color-picker.h, libgui/src/dialog.cc, libgui/src/dialog.h, libgui/src/documentation-dock-widget.cc, libgui/src/files-dock-widget.cc, libgui/src/files-dock-widget.h, libgui/src/find-files-dialog.cc, libgui/src/find-files-dialog.h, libgui/src/find-files-model.cc, libgui/src/find-files-model.h, libgui/src/history-dock-widget.cc, libgui/src/history-dock-widget.h, libgui/src/m-editor/file-editor-interface.h, libgui/src/m-editor/file-editor-tab.cc, libgui/src/m-editor/file-editor-tab.h, libgui/src/m-editor/file-editor.cc, libgui/src/m-editor/find-dialog.cc, libgui/src/m-editor/find-dialog.h, libgui/src/m-editor/octave-qscintilla.cc, libgui/src/main-window.cc, libgui/src/main-window.h, libgui/src/news-dock-widget.h, libgui/src/octave-dock-widget.cc, libgui/src/octave-dock-widget.h, libgui/src/octave-gui.cc, libgui/src/octave-qt-link.cc, libgui/src/octave-qt-link.h, libgui/src/qtinfo/parser.cc, libgui/src/qtinfo/parser.h, libgui/src/qtinfo/webinfo.cc, libgui/src/qtinfo/webinfo.h, libgui/src/resource-manager.cc, libgui/src/settings-dialog.cc, libgui/src/settings-dialog.h, libgui/src/terminal-dock-widget.cc, libgui/src/welcome-wizard.cc, libgui/src/workspace-model.cc, libgui/src/workspace-model.h, libgui/src/workspace-view.cc, libgui/src/workspace-view.h: Use GNU style coding conventions for code in libgui/
author Rik <rik@octave.org>
date Tue, 29 Oct 2013 09:54:40 -0700
parents c2e43dd6eb70
children 36063e43c511 5f7f58866922 cae24b7cfaf4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15177
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
1 /****************************************************************************
16520
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
2
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
3 Find dialog derived from an example from Qt Toolkit (license below (**))
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
4
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
5 Copyright (C) 2012-2013 Torsten <ttl@justmail.de>
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
6 Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
7 All rights reserved.
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
8 Contact: Nokia Corporation (qt-info@nokia.com)
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
9
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
10 This file is part of Octave.
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
11
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
12 Octave is free software; you can redistribute it and/or modify it
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
13 under the terms of the GNU General Public License as published by the
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
14 Free Software Foundation; either version 3 of the License, or (at your
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
15 option) any later version.
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
16
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
17 Octave is distributed in the hope that it will be useful, but WITHOUT
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
18 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
19 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
20 for more details.
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
21
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
22 You should have received a copy of the GNU General Public License
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
23 along with Octave; see the file COPYING. If not, see
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
24 <http://www.gnu.org/licenses/>.
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
25
15177
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
26 ** This file is part of the examples of the Qt Toolkit.
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
27 **
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
28 ** $QT_BEGIN_LICENSE:LGPL$
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
29 ** Commercial Usage
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
30 ** Licensees holding valid Qt Commercial licenses may use this file in
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
31 ** accordance with the Qt Commercial License Agreement provided with the
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
32 ** Software or, alternatively, in accordance with the terms contained in
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
33 ** a written agreement between you and Nokia.
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
34 **
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
35 ** GNU Lesser General Public License Usage
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
36 ** Alternatively, this file may be used under the terms of the GNU Lesser
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
37 ** General Public License version 2.1 as published by the Free Software
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
38 ** Foundation and appearing in the file LICENSE.LGPL included in the
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
39 ** packaging of this file. Please review the following information to
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
40 ** ensure the GNU Lesser General Public License version 2.1 requirements
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
41 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
42 **
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
43 ** In addition, as a special exception, Nokia gives you certain additional
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
44 ** rights. These rights are described in the Nokia Qt LGPL Exception
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
45 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
46 **
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
47 ** GNU General Public License Usage
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
48 ** Alternatively, this file may be used under the terms of the GNU
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
49 ** General Public License version 3.0 as published by the Free Software
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
50 ** Foundation and appearing in the file LICENSE.GPL included in the
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
51 ** packaging of this file. Please review the following information to
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
52 ** ensure the GNU General Public License version 3.0 requirements will be
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
53 ** met: http://www.gnu.org/copyleft/gpl.html.
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
54 **
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
55 ** If you have questions regarding the use of this file, please contact
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
56 ** Nokia at qt-info@nokia.com.
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
57 ** $QT_END_LICENSE$
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
58 **
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
59 ****************************************************************************/
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
60
15286
ae9079bbc627 Add '#include <config.h>' to C++ files in libgui/src
Rik <rik@octave.org>
parents: 15257
diff changeset
61 #ifdef HAVE_CONFIG_H
ae9079bbc627 Add '#include <config.h>' to C++ files in libgui/src
Rik <rik@octave.org>
parents: 15257
diff changeset
62 #include <config.h>
ae9079bbc627 Add '#include <config.h>' to C++ files in libgui/src
Rik <rik@octave.org>
parents: 15257
diff changeset
63 #endif
ae9079bbc627 Add '#include <config.h>' to C++ files in libgui/src
Rik <rik@octave.org>
parents: 15257
diff changeset
64
15873
7d300b85ee25 allow build to proceed if either Qt or QScintilla is missing
John W. Eaton <jwe@octave.org>
parents: 15368
diff changeset
65 #ifdef HAVE_QSCINTILLA
7d300b85ee25 allow build to proceed if either Qt or QScintilla is missing
John W. Eaton <jwe@octave.org>
parents: 15368
diff changeset
66
15177
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
67 #include <QtGui>
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
68 #include <QIcon>
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
69 #include "find-dialog.h"
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
70
15368
36ececf69385 avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents: 15367
diff changeset
71 find_dialog::find_dialog (QsciScintilla* edit_area, QWidget *p)
36ececf69385 avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents: 15367
diff changeset
72 : QDialog (p)
15177
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
73 {
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
74 setWindowTitle ("Find and Replace");
16511
eee1b78d031f gui: fix backward search in find dialog
Torsten <ttl@justmail.de>
parents: 15988
diff changeset
75 setWindowIcon (QIcon(":/actions/icons/search.png"));
15177
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
76
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
77 _search_label = new QLabel (tr ("Find &what:"));
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
78 _search_line_edit = new QLineEdit;
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
79 _search_label->setBuddy (_search_line_edit);
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
80 _replace_label = new QLabel (tr ("Re&place with:"));
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
81 _replace_line_edit = new QLineEdit;
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
82 _replace_label->setBuddy (_replace_line_edit);
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
83
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
84 _case_check_box = new QCheckBox (tr ("Match &case"));
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
85 _from_start_check_box = new QCheckBox (tr ("Search from &start"));
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
86 _wrap_check_box = new QCheckBox (tr ("&Wrap while searching"));
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
87 _wrap_check_box->setChecked(true);
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
88 _find_next_button = new QPushButton (tr ("&Find Next"));
16520
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
89 _find_prev_button = new QPushButton (tr ("Find &Previous"));
15177
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
90 _replace_button = new QPushButton (tr ("&Replace"));
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
91 _replace_all_button = new QPushButton (tr ("Replace &All"));
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
92
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
93 _more_button = new QPushButton (tr ("&More"));
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
94 _more_button->setCheckable (true);
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
95 _more_button->setAutoDefault (false);
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
96
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
97 _button_box = new QDialogButtonBox (Qt::Vertical);
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
98 _button_box->addButton (_find_next_button, QDialogButtonBox::ActionRole);
16520
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
99 _button_box->addButton (_find_prev_button, QDialogButtonBox::ActionRole);
15177
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
100 _button_box->addButton (_replace_button, QDialogButtonBox::ActionRole);
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
101 _button_box->addButton (_replace_all_button, QDialogButtonBox::ActionRole);
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
102 _button_box->addButton (_more_button, QDialogButtonBox::ActionRole);
16516
7af39cc90982 * find-dialog.cc(constructor): add close button to the find dialog
Torsten <ttl@justmail.de>
parents: 16511
diff changeset
103 _button_box->addButton (QDialogButtonBox::Close);
15177
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
104
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
105 _extension = new QWidget (this);
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
106 _whole_words_check_box = new QCheckBox (tr ("&Whole words"));
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
107 _regex_check_box = new QCheckBox (tr ("Regular E&xpressions"));
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
108 _backward_check_box = new QCheckBox (tr ("Search &backward"));
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
109 _search_selection_check_box = new QCheckBox (tr ("Search se&lection"));
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
110 _search_selection_check_box->setCheckable (false); // TODO: Not implemented.
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
111 _search_selection_check_box->setEnabled (false);
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
112
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
113 _edit_area = edit_area;
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
114 connect (_find_next_button, SIGNAL (clicked ()),
16520
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
115 this, SLOT (find_next ()));
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
116 connect (_find_prev_button, SIGNAL (clicked ()),
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
117 this, SLOT (find_prev ()));
15177
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
118 connect (_more_button, SIGNAL (toggled (bool)),
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
119 _extension, SLOT (setVisible (bool)));
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
120 connect (_replace_button, SIGNAL (clicked ()),
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
121 this, SLOT (replace ()));
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
122 connect (_replace_all_button, SIGNAL (clicked ()),
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
123 this, SLOT (replace_all ()));
16511
eee1b78d031f gui: fix backward search in find dialog
Torsten <ttl@justmail.de>
parents: 15988
diff changeset
124 connect (_backward_check_box, SIGNAL (stateChanged (int)),
eee1b78d031f gui: fix backward search in find dialog
Torsten <ttl@justmail.de>
parents: 15988
diff changeset
125 this, SLOT (handle_backward_search_changed (int)));
16516
7af39cc90982 * find-dialog.cc(constructor): add close button to the find dialog
Torsten <ttl@justmail.de>
parents: 16511
diff changeset
126 connect (_button_box, SIGNAL (rejected ()),
7af39cc90982 * find-dialog.cc(constructor): add close button to the find dialog
Torsten <ttl@justmail.de>
parents: 16511
diff changeset
127 this, SLOT (close ()));
15177
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
128
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
129 QVBoxLayout *extension_layout = new QVBoxLayout ();
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
130 extension_layout->setMargin (0);
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
131 extension_layout->addWidget (_whole_words_check_box);
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
132 extension_layout->addWidget (_backward_check_box);
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
133 extension_layout->addWidget (_search_selection_check_box);
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
134 _extension->setLayout (extension_layout);
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
135
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
136 QGridLayout *top_left_layout = new QGridLayout;
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
137 top_left_layout->addWidget (_search_label, 1, 1);
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
138 top_left_layout->addWidget (_search_line_edit, 1, 2);
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
139 top_left_layout->addWidget (_replace_label, 2, 1);
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
140 top_left_layout->addWidget (_replace_line_edit, 2, 2);
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
141
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
142 QVBoxLayout *left_layout = new QVBoxLayout;
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
143 left_layout->addLayout (top_left_layout);
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
144 left_layout->insertStretch (1, 5);
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
145 left_layout->addWidget (_case_check_box);
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
146 left_layout->addWidget (_from_start_check_box);
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
147 left_layout->addWidget (_wrap_check_box);
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
148 left_layout->addWidget (_regex_check_box);
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
149
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
150 QGridLayout *main_layout = new QGridLayout;
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
151 main_layout->setSizeConstraint (QLayout::SetFixedSize);
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
152 main_layout->addLayout (left_layout, 0, 0);
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
153 main_layout->addWidget (_button_box, 0, 1);
16516
7af39cc90982 * find-dialog.cc(constructor): add close button to the find dialog
Torsten <ttl@justmail.de>
parents: 16511
diff changeset
154 main_layout->addWidget (_extension, 1, 0);
15177
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
155 setLayout (main_layout);
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
156
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
157 _extension->hide ();
16516
7af39cc90982 * find-dialog.cc(constructor): add close button to the find dialog
Torsten <ttl@justmail.de>
parents: 16511
diff changeset
158 _find_next_button->setDefault (true);
16511
eee1b78d031f gui: fix backward search in find dialog
Torsten <ttl@justmail.de>
parents: 15988
diff changeset
159 _find_result_available = false;
eee1b78d031f gui: fix backward search in find dialog
Torsten <ttl@justmail.de>
parents: 15988
diff changeset
160
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17007
diff changeset
161 // move dialog to side of the parent if there is room on the desktop to do so.
17007
c2e43dd6eb70 Dont display find dialog out of desktop bounds (bug #39518)
John Donoghue <john.donoghue@ieee.org>
parents: 16736
diff changeset
162 QWidget * desktop = QApplication::desktop ();
c2e43dd6eb70 Dont display find dialog out of desktop bounds (bug #39518)
John Donoghue <john.donoghue@ieee.org>
parents: 16736
diff changeset
163 int xp = p->x () + p->frameGeometry ().width ();
c2e43dd6eb70 Dont display find dialog out of desktop bounds (bug #39518)
John Donoghue <john.donoghue@ieee.org>
parents: 16736
diff changeset
164 int yp= p->y ();
c2e43dd6eb70 Dont display find dialog out of desktop bounds (bug #39518)
John Donoghue <john.donoghue@ieee.org>
parents: 16736
diff changeset
165 if (desktop != 0 && sizeHint ().isValid ())
c2e43dd6eb70 Dont display find dialog out of desktop bounds (bug #39518)
John Donoghue <john.donoghue@ieee.org>
parents: 16736
diff changeset
166 {
c2e43dd6eb70 Dont display find dialog out of desktop bounds (bug #39518)
John Donoghue <john.donoghue@ieee.org>
parents: 16736
diff changeset
167 if (xp + sizeHint ().width () > desktop->width ())
c2e43dd6eb70 Dont display find dialog out of desktop bounds (bug #39518)
John Donoghue <john.donoghue@ieee.org>
parents: 16736
diff changeset
168 xp = desktop->width () - sizeHint ().width ();
c2e43dd6eb70 Dont display find dialog out of desktop bounds (bug #39518)
John Donoghue <john.donoghue@ieee.org>
parents: 16736
diff changeset
169 }
c2e43dd6eb70 Dont display find dialog out of desktop bounds (bug #39518)
John Donoghue <john.donoghue@ieee.org>
parents: 16736
diff changeset
170
c2e43dd6eb70 Dont display find dialog out of desktop bounds (bug #39518)
John Donoghue <john.donoghue@ieee.org>
parents: 16736
diff changeset
171 move (xp, yp);
16520
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
172
15177
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
173 }
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
174
16511
eee1b78d031f gui: fix backward search in find dialog
Torsten <ttl@justmail.de>
parents: 15988
diff changeset
175 // set text of "search from start" depending on backward search
eee1b78d031f gui: fix backward search in find dialog
Torsten <ttl@justmail.de>
parents: 15988
diff changeset
176 void
eee1b78d031f gui: fix backward search in find dialog
Torsten <ttl@justmail.de>
parents: 15988
diff changeset
177 find_dialog::handle_backward_search_changed (int backward)
eee1b78d031f gui: fix backward search in find dialog
Torsten <ttl@justmail.de>
parents: 15988
diff changeset
178 {
eee1b78d031f gui: fix backward search in find dialog
Torsten <ttl@justmail.de>
parents: 15988
diff changeset
179 if (backward)
eee1b78d031f gui: fix backward search in find dialog
Torsten <ttl@justmail.de>
parents: 15988
diff changeset
180 _from_start_check_box->setText (tr ("Search from end"));
eee1b78d031f gui: fix backward search in find dialog
Torsten <ttl@justmail.de>
parents: 15988
diff changeset
181 else
eee1b78d031f gui: fix backward search in find dialog
Torsten <ttl@justmail.de>
parents: 15988
diff changeset
182 _from_start_check_box->setText (tr ("Search from start"));
eee1b78d031f gui: fix backward search in find dialog
Torsten <ttl@justmail.de>
parents: 15988
diff changeset
183 }
15988
38348a6c3db0 gui: initialize search text in the find dialog with selected text in editor file
Torsten <ttl@justmail.de>
parents: 15873
diff changeset
184
38348a6c3db0 gui: initialize search text in the find dialog with selected text in editor file
Torsten <ttl@justmail.de>
parents: 15873
diff changeset
185 // initialize search text with selected text if this is in one single line
38348a6c3db0 gui: initialize search text in the find dialog with selected text in editor file
Torsten <ttl@justmail.de>
parents: 15873
diff changeset
186 void
38348a6c3db0 gui: initialize search text in the find dialog with selected text in editor file
Torsten <ttl@justmail.de>
parents: 15873
diff changeset
187 find_dialog::init_search_text ()
38348a6c3db0 gui: initialize search text in the find dialog with selected text in editor file
Torsten <ttl@justmail.de>
parents: 15873
diff changeset
188 {
38348a6c3db0 gui: initialize search text in the find dialog with selected text in editor file
Torsten <ttl@justmail.de>
parents: 15873
diff changeset
189 if (_edit_area->hasSelectedText ())
38348a6c3db0 gui: initialize search text in the find dialog with selected text in editor file
Torsten <ttl@justmail.de>
parents: 15873
diff changeset
190 {
38348a6c3db0 gui: initialize search text in the find dialog with selected text in editor file
Torsten <ttl@justmail.de>
parents: 15873
diff changeset
191 int lbeg, lend, cbeg, cend;
38348a6c3db0 gui: initialize search text in the find dialog with selected text in editor file
Torsten <ttl@justmail.de>
parents: 15873
diff changeset
192 _edit_area->getSelection(&lbeg,&cbeg,&lend,&cend);
38348a6c3db0 gui: initialize search text in the find dialog with selected text in editor file
Torsten <ttl@justmail.de>
parents: 15873
diff changeset
193 if (lbeg == lend)
38348a6c3db0 gui: initialize search text in the find dialog with selected text in editor file
Torsten <ttl@justmail.de>
parents: 15873
diff changeset
194 _search_line_edit->setText (_edit_area->selectedText ());
38348a6c3db0 gui: initialize search text in the find dialog with selected text in editor file
Torsten <ttl@justmail.de>
parents: 15873
diff changeset
195 }
38348a6c3db0 gui: initialize search text in the find dialog with selected text in editor file
Torsten <ttl@justmail.de>
parents: 15873
diff changeset
196 }
38348a6c3db0 gui: initialize search text in the find dialog with selected text in editor file
Torsten <ttl@justmail.de>
parents: 15873
diff changeset
197
16520
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
198 void
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
199 find_dialog::find_next ()
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
200 {
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
201 find (!_backward_check_box->isChecked ());
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
202 }
15988
38348a6c3db0 gui: initialize search text in the find dialog with selected text in editor file
Torsten <ttl@justmail.de>
parents: 15873
diff changeset
203
15177
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
204 void
16520
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
205 find_dialog::find_prev ()
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
206 {
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
207 find (_backward_check_box->isChecked ());
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
208 }
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
209
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
210 void
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
211 find_dialog::find (bool forward)
15177
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
212 {
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
213 int line = -1, col = -1;
16511
eee1b78d031f gui: fix backward search in find dialog
Torsten <ttl@justmail.de>
parents: 15988
diff changeset
214 bool do_wrap = _wrap_check_box->isChecked ();
16520
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
215 bool do_forward = true;
16511
eee1b78d031f gui: fix backward search in find dialog
Torsten <ttl@justmail.de>
parents: 15988
diff changeset
216
eee1b78d031f gui: fix backward search in find dialog
Torsten <ttl@justmail.de>
parents: 15988
diff changeset
217 if (_find_result_available)
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17007
diff changeset
218 {
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17007
diff changeset
219 // we found a match last time, cursor is at the end of the match
16520
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
220 if (!forward)
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17007
diff changeset
221 {
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17007
diff changeset
222 // backward: go back one position or we will find the same again
16520
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
223 do_forward = false;
16511
eee1b78d031f gui: fix backward search in find dialog
Torsten <ttl@justmail.de>
parents: 15988
diff changeset
224 _edit_area->getCursorPosition (&line,&col);
eee1b78d031f gui: fix backward search in find dialog
Torsten <ttl@justmail.de>
parents: 15988
diff changeset
225 if (col > 0)
eee1b78d031f gui: fix backward search in find dialog
Torsten <ttl@justmail.de>
parents: 15988
diff changeset
226 _edit_area->setCursorPosition (line,--col);
eee1b78d031f gui: fix backward search in find dialog
Torsten <ttl@justmail.de>
parents: 15988
diff changeset
227 }
eee1b78d031f gui: fix backward search in find dialog
Torsten <ttl@justmail.de>
parents: 15988
diff changeset
228 }
15177
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
229
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
230 _find_result_available = false;
16511
eee1b78d031f gui: fix backward search in find dialog
Torsten <ttl@justmail.de>
parents: 15988
diff changeset
231
15177
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
232 if (_from_start_check_box->isChecked ())
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
233 {
16511
eee1b78d031f gui: fix backward search in find dialog
Torsten <ttl@justmail.de>
parents: 15988
diff changeset
234 line = 0;
eee1b78d031f gui: fix backward search in find dialog
Torsten <ttl@justmail.de>
parents: 15988
diff changeset
235 col = 0;
eee1b78d031f gui: fix backward search in find dialog
Torsten <ttl@justmail.de>
parents: 15988
diff changeset
236 if (_backward_check_box->isChecked ())
eee1b78d031f gui: fix backward search in find dialog
Torsten <ttl@justmail.de>
parents: 15988
diff changeset
237 do_wrap = true;
15177
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
238 }
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
239
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
240 if (_edit_area)
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
241 {
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17007
diff changeset
242 _find_result_available
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17007
diff changeset
243 = _edit_area->findFirst (_search_line_edit->text (),
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17007
diff changeset
244 _regex_check_box->isChecked (),
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17007
diff changeset
245 _case_check_box->isChecked (),
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17007
diff changeset
246 _whole_words_check_box->isChecked (),
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17007
diff changeset
247 do_wrap,
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17007
diff changeset
248 do_forward,
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17007
diff changeset
249 line,col,
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17007
diff changeset
250 true
16736
68ca4122e568 * find-dialog.cc(find): fix ifdef for qscintilla version according to cset 16733
Torsten <ttl@justmail.de>
parents: 16520
diff changeset
251 #ifdef HAVE_QSCI_VERSION_2_6_0
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17007
diff changeset
252 , true
15257
7ee62f559a73 Fix compilation under Windows with GUI and LLVM enabled.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15196
diff changeset
253 #endif
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17007
diff changeset
254 );
15177
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
255 }
16511
eee1b78d031f gui: fix backward search in find dialog
Torsten <ttl@justmail.de>
parents: 15988
diff changeset
256 if (_find_result_available)
eee1b78d031f gui: fix backward search in find dialog
Torsten <ttl@justmail.de>
parents: 15988
diff changeset
257 _from_start_check_box->setChecked (0);
eee1b78d031f gui: fix backward search in find dialog
Torsten <ttl@justmail.de>
parents: 15988
diff changeset
258 else
16520
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
259 no_matches_message ();
15177
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
260 }
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
261
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
262
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
263 void
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
264 find_dialog::replace ()
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
265 {
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
266 if (_edit_area)
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
267 {
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
268 _edit_area->replace (_replace_line_edit->text ());
16520
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
269 if (!_edit_area->findNext())
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
270 no_matches_message ();
15177
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
271 }
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
272 }
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
273
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
274 void
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
275 find_dialog::replace_all ()
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
276 {
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
277 int count = 0;
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
278
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
279 // check whether find & replace srings are different (avoid endless loop!)
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
280 int strDiff;
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
281 Qt::CaseSensitivity cs;
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
282 if (_case_check_box->isChecked())
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
283 {
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
284 cs = Qt::CaseSensitive;
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
285 }
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
286 else
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
287 {
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
288 cs = Qt::CaseInsensitive;
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
289 }
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17007
diff changeset
290 strDiff = QString::compare (_search_line_edit->text(),
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17007
diff changeset
291 _replace_line_edit->text(), cs);
15177
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
292
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
293 // replace all if strings are different
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
294 if (_edit_area && strDiff )
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
295 {
16520
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
296 find (!_backward_check_box->isChecked ()); // find first occurence
15177
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
297 while (_find_result_available) // while search string is found
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
298 {
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
299 _edit_area->replace (_replace_line_edit->text ()); // replace
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
300 count++; // inc counter
16520
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
301 _find_result_available = _edit_area->findNext(); // and find next
15177
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
302 }
16520
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
303 QMessageBox msg_box (QMessageBox::Information, tr ("Replace Result"),
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
304 tr ("%1 items replaced").arg(count),
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
305 QMessageBox::Ok, this);
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
306 msg_box.exec ();
15177
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
307 }
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
308 // TODO: Show number of replaced strings
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
309 }
15873
7d300b85ee25 allow build to proceed if either Qt or QScintilla is missing
John W. Eaton <jwe@octave.org>
parents: 15368
diff changeset
310
16520
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
311 void
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
312 find_dialog::no_matches_message ()
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
313 {
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17007
diff changeset
314 QMessageBox msg_box (QMessageBox::Information, tr ("Find Result"),
16520
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
315 tr ("No more matches found"), QMessageBox::Ok, this);
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
316 msg_box.exec ();
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
317 }
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
318
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
319
15873
7d300b85ee25 allow build to proceed if either Qt or QScintilla is missing
John W. Eaton <jwe@octave.org>
parents: 15368
diff changeset
320 #endif