1 // Find dialog derived from an example from Qt Toolkit (license below (**)) 2 3 //////////////////////////////////////////////////////////////////////// 4 // 5 // Copyright (C) 2009-2021 The Octave Project Developers 6 // 7 // See the file COPYRIGHT.md in the top-level directory of this 8 // or <https://octave.org/copyright/>. 9 // 10 // All rights reserved. 11 // Contact: Nokia Corporation (qt-info@nokia.com) 12 // 13 // This file is part of Octave. 14 // 15 // Octave is free software: you can redistribute it and/or modify it 16 // under the terms of the GNU General Public License as published by 17 // the Free Software Foundation, either version 3 of the License, or 18 // (at your option) any later version. 19 // 20 // Octave is distributed in the hope that it will be useful, but 21 // WITHOUT ANY WARRANTY; without even the implied warranty of 22 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 // GNU General Public License for more details. 24 // 25 // You should have received a copy of the GNU General Public License 26 // along with Octave; see the file COPYING. If not, see 27 // <https://www.gnu.org/licenses/>. 28 // 29 // ** This file is part of the examples of the Qt Toolkit. 30 // ** 31 // ** $QT_BEGIN_LICENSE:LGPL$ 32 // ** Commercial Usage 33 // ** Licensees holding valid Qt Commercial licenses may use this file in 34 // ** accordance with the Qt Commercial License Agreement provided with the 35 // ** Software or, alternatively, in accordance with the terms contained in 36 // ** a written agreement between you and Nokia. 37 // ** 38 // ** GNU Lesser General Public License Usage 39 // ** Alternatively, this file may be used under the terms of the GNU Lesser 40 // ** General Public License version 2.1 as published by the Free Software 41 // ** Foundation and appearing in the file LICENSE.LGPL included in the 42 // ** packaging of this file. Please review the following information to 43 // ** ensure the GNU Lesser General Public License version 2.1 requirements 44 // ** will be met: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 45 // ** 46 // ** In addition, as a special exception, Nokia gives you certain additional 47 // ** rights. These rights are described in the Nokia Qt LGPL Exception 48 // ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 49 // ** 50 // ** GNU General Public License Usage 51 // ** Alternatively, this file may be used under the terms of the GNU 52 // ** General Public License version 3.0 as published by the Free Software 53 // ** Foundation and appearing in the file LICENSE.GPL included in the 54 // ** packaging of this file. Please review the following information to 55 // ** ensure the GNU General Public License version 3.0 requirements will be 56 // ** met: https://www.gnu.org/copyleft/gpl.html. 57 // ** 58 // ** If you have questions regarding the use of this file, please contact 59 // ** Nokia at qt-info@nokia.com. 60 // ** $QT_END_LICENSE$ 61 // 62 //////////////////////////////////////////////////////////////////////// 63 64 #if ! defined (octave_find_dialog_h) 65 #define octave_find_dialog_h 1 66 67 #include <QDialog> 68 #include <QComboBox> 69 70 #include "octave-qscintilla.h" 71 #include "octave-dock-widget.h" 72 73 class QCheckBox; 74 class QDialogButtonBox; 75 class QGroupBox; 76 class QLabel; 77 class QLineEdit; 78 class QPushButton; 79 80 namespace octave 81 { 82 class base_qobject; 83 class file_editor; 84 85 class find_dialog : public QDialog 86 { 87 Q_OBJECT 88 89 public: 90 91 find_dialog (base_qobject& oct_qobj, octave_dock_widget *ed, QWidget *p); 92 93 //! Set dialog visible or not and storing the new visibility state 94 void set_visible (bool visible); 95 96 //! Init the search text with the selected text in the editor tab 97 void init_search_text (void); 98 99 //! Restore position and the search options from the given settings 100 //! where def_pos is the default position suitable for the current 101 //! editor position 102 void restore_settings (QPoint def_pos); 103 104 public slots: 105 106 void find_next (void); 107 void find_prev (void); 108 109 //! Slot for updating the edit area when the active tab has changed 110 void update_edit_area (octave_qscintilla*); 111 112 private slots: 113 114 void handle_sel_search_changed (int); 115 void handle_selection_changed (bool has_selected); 116 117 void handle_backward_search_changed (int); 118 119 void find (bool forward = true); 120 void replace (void); 121 void replace_all (void); 122 123 private: 124 125 base_qobject& m_octave_qobj; 126 127 //! Save position and the search options in the given settings 128 void save_settings (); 129 130 //! Reimplemented slot: close instead of hiding 131 void reject (); 132 133 //! Reimplemented close event 134 void closeEvent (QCloseEvent* e); 135 136 //! Update mru lists with new entry 137 void mru_update (QComboBox *mru); 138 139 void no_matches_message (void); 140 void do_replace (void); 141 142 void handle_search_text_changed (void); 143 void handle_replace_text_changed (void); 144 145 octave_dock_widget *m_editor; 146 147 QLabel *_search_label; 148 QComboBox *_search_line_edit; 149 QLabel *_replace_label; 150 QComboBox *_replace_line_edit; 151 QCheckBox *_case_check_box; 152 QCheckBox *_from_start_check_box; 153 QCheckBox *_wrap_check_box; 154 QCheckBox *_whole_words_check_box; 155 QCheckBox *_regex_check_box; 156 QCheckBox *_search_selection_check_box; 157 QCheckBox *_backward_check_box; 158 QDialogButtonBox *_button_box; 159 QPushButton *_find_next_button; 160 QPushButton *_find_prev_button; 161 QPushButton *_replace_button; 162 QPushButton *_replace_all_button; 163 QPushButton *_more_button; 164 QWidget *_extension; 165 octave_qscintilla *_edit_area; 166 bool _find_result_available; 167 int _rep_all; 168 bool _rep_active; 169 170 bool m_in_sel; 171 int m_sel_beg; 172 int m_sel_end; 173 174 QPoint m_last_position; 175 176 const int m_mru_length = 10; 177 }; 178 } 179 180 #endif 181