# HG changeset patch # User Jacob Dawid # Date 1343898525 -7200 # Node ID 4c4f2fb07a50aa5412914f15ae33860a602c8ca7 # Parent 48ae6a7c69c12ee316fb2fe69f8e702fa1a27c0b Added find functionality in editor by to.lil. * find.png: Added find icon. * find-dialog.cc: Added find dialog. * find-dialog.h: Added find dialog. * file-editor-tab.cc: Integrated find dialog. * file-editor-tab.h: Added new method for find. * file-editor.cc: Added new actions, menus and toolbuttons. * file-editor.h: Added new method/slot for find. diff --git a/gui/src/icons/find.png b/gui/src/icons/find.png new file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..a3e5175b9098d3ccb097e5c633beb1f10fe22ca9 GIT binary patch literal 1777 zc$@+81`hd&P)~85REq%Lf@44KU(|gXdKjsY1iT+2H@cZ-0 z^ZR~3`R14Bmq!vpa4So`rS7)@ZUg+^0KBmGK;_-b%14$gUeY_upR@U^?#=S&Y+kZ> zN$=gu%12(K`Gi7K==wCxADqGN zw7>6kx!zS(bq9c^X}e<4=)HPOUr|<3j@@n}CB;o35Fi?h(bLn-hK)5JDT?yFjgLOu zbJGM|igNhR$B!+os8~+R`4$Y*BsdYm<+PKXoyGKY94$1tA~%2T3ZE|>fOsta+|}M* zoGurV1iiieL}Oh{P6n~aG8GleIobHvrH^dbcoX@TG%?R%5bKNm9|{IvJUn z%*o9qJ1Ya9*8>8Ql9CB)8m$-3qlH3fp%8)2%Y-$Jq@-jJ;PZOO&dOj;ZY~*_ndosH zB}oO7l`kDUwE8O(2nK^soo)U*hH22=-im)lHY3-r(%&~gvYJe?s^Uw}z~k{SG(5zD z!fyf4*Vl{B<3+Yu>F8)DtZ9U`FgY{*czr(F+gowF-5mSV8_ZiU|0&?qmjJ4(tGB6Y z$~x_On00Hvi@*dS={2Pi5kPSW)_6TxxDMn@?wDduEj zBipub$M2tkMYb@l>j=QRpYEjiXX!Wu<#?aPTkBZhyAy)bV$C?ae>p z#DxQTKZd zr&(LN9+yQyG9{*UosJ7_abO2Oi}Z28>}N%v&ZJ=w!-|13s_uMr#{$7Z$B({m+;Fsl$|RZq{An9XV< zI6ltk@HJ-pXVE>`L%JsuRdu7PDa@ic)Gd48tiBCJX(= z$dW{|I~mzxK}}UT{pvaV`F`{y4Ov*k(CBa|8jmMT(~R`@_nk8g;~9WJAn;;N&dfVy zSym=PlU7++Qq*Ks^5^?WPE~O!E|OA`X@31YvLvz4UyMkY7>41r3L%7$;JO?}2ooU$ z0+W&6F^q&ksxJ)@H9;oc)7{-JA?*RecDubZ7K;r4IGxU)w70hv0LcQe4VgOxrZd%- zhTUNUNif_qikUDG!u+?F1VRWQ>$=`MbZy9V*d2ruVZz}s%N|@xLN|zL5ypl_aSSVT z4|GQnoHb4JEz>lc{$mahi^T>^(`+(L^DP8ty9c_Xj$wtdp;01QgoJLe?7^jk!(qaS zFb=zep=(2?uIs%L;P-euuN>I7e^tZ&Q>5j2$yBqs+BraXR~O!lG}b<|#;AF$=4Hb$ zwhAG>v`}s=Ns?R^i)CN^EA@}R{bGYUOylOZ0k#gqfIb>u4LRt=-WuJ)PJpgwSqgeglMRvsw4m z)$LldsA!STDqC%?B!y@+VqCa*VXCgK?zpCD`-Bi3U)YB8=gx+!z5Ow{4R9OaRs;MCoH_~0 Tjwl_{00000NkvXXu0mjf+=+ts diff --git a/gui/src/m-editor/file-editor-tab.cc b/gui/src/m-editor/file-editor-tab.cc --- a/gui/src/m-editor/file-editor-tab.cc +++ b/gui/src/m-editor/file-editor-tab.cc @@ -17,6 +17,7 @@ #include "file-editor-tab.h" #include "file-editor.h" +#include "find-dialog.h" #include "octave-link.h" @@ -375,7 +376,14 @@ } void -file_editor_tab::update_window_title(bool modified) +file_editor_tab::find () +{ + find_dialog dialog (_edit_area); + dialog.exec (); +} + +void +file_editor_tab::update_window_title (bool modified) { QString title(_file_name); if ( !_long_title ) diff --git a/gui/src/m-editor/file-editor-tab.h b/gui/src/m-editor/file-editor-tab.h --- a/gui/src/m-editor/file-editor-tab.h +++ b/gui/src/m-editor/file-editor-tab.h @@ -41,6 +41,7 @@ void handle_margin_clicked (int line, int margin, Qt::KeyboardModifiers state); void comment_selected_text (); void uncomment_selected_text (); + void find (); void remove_bookmark (); void toggle_bookmark (); void next_bookmark (); diff --git a/gui/src/m-editor/file-editor.cc b/gui/src/m-editor/file-editor.cc --- a/gui/src/m-editor/file-editor.cc +++ b/gui/src/m-editor/file-editor.cc @@ -114,145 +114,153 @@ void file_editor::request_undo () { - file_editor_tab *activeFileEditorTab = active_editor_tab (); - if (activeFileEditorTab) - activeFileEditorTab->undo (); + file_editor_tab *_active_file_editor_tab = active_editor_tab (); + if (_active_file_editor_tab) + _active_file_editor_tab->undo (); } void file_editor::request_redo () { - file_editor_tab *activeFileEditorTab = active_editor_tab (); - if (activeFileEditorTab) - activeFileEditorTab->redo (); + file_editor_tab *_active_file_editor_tab = active_editor_tab (); + if (_active_file_editor_tab) + _active_file_editor_tab->redo (); } void file_editor::request_copy () { - file_editor_tab *activeFileEditorTab = active_editor_tab (); - if (activeFileEditorTab) - activeFileEditorTab->copy (); + file_editor_tab *_active_file_editor_tab = active_editor_tab (); + if (_active_file_editor_tab) + _active_file_editor_tab->copy (); } void file_editor::request_cut () { - file_editor_tab *activeFileEditorTab = active_editor_tab (); - if (activeFileEditorTab) - activeFileEditorTab->cut (); + file_editor_tab *_active_file_editor_tab = active_editor_tab (); + if (_active_file_editor_tab) + _active_file_editor_tab->cut (); } void file_editor::request_paste () { - file_editor_tab *activeFileEditorTab = active_editor_tab (); - if (activeFileEditorTab) - activeFileEditorTab->paste (); + file_editor_tab *_active_file_editor_tab = active_editor_tab (); + if (_active_file_editor_tab) + _active_file_editor_tab->paste (); } void file_editor::request_save_file () { - file_editor_tab *activeFileEditorTab = active_editor_tab (); - if (activeFileEditorTab) - activeFileEditorTab->save_file (); + file_editor_tab *_active_file_editor_tab = active_editor_tab (); + if (_active_file_editor_tab) + _active_file_editor_tab->save_file (); } void file_editor::request_save_file_as () { - file_editor_tab *activeFileEditorTab = active_editor_tab (); - if (activeFileEditorTab) - activeFileEditorTab->save_file_as (); + file_editor_tab *_active_file_editor_tab = active_editor_tab (); + if (_active_file_editor_tab) + _active_file_editor_tab->save_file_as (); } void file_editor::request_run_file () { - file_editor_tab *activeFileEditorTab = active_editor_tab (); - if (activeFileEditorTab) - activeFileEditorTab->run_file (); + file_editor_tab *_active_file_editor_tab = active_editor_tab (); + if (_active_file_editor_tab) + _active_file_editor_tab->run_file (); } void file_editor::request_toggle_bookmark () { - file_editor_tab *activeFileEditorTab = active_editor_tab (); - if (activeFileEditorTab) - activeFileEditorTab->toggle_bookmark (); + file_editor_tab *_active_file_editor_tab = active_editor_tab (); + if (_active_file_editor_tab) + _active_file_editor_tab->toggle_bookmark (); } void file_editor::request_next_bookmark () { - file_editor_tab *activeFileEditorTab = active_editor_tab (); - if (activeFileEditorTab) - activeFileEditorTab->next_bookmark (); + file_editor_tab *_active_file_editor_tab = active_editor_tab (); + if (_active_file_editor_tab) + _active_file_editor_tab->next_bookmark (); } void file_editor::request_previous_bookmark () { - file_editor_tab *activeFileEditorTab = active_editor_tab (); - if (activeFileEditorTab) - activeFileEditorTab->previous_bookmark (); + file_editor_tab *_active_file_editor_tab = active_editor_tab (); + if (_active_file_editor_tab) + _active_file_editor_tab->previous_bookmark (); } void file_editor::request_remove_bookmark () { - file_editor_tab *activeFileEditorTab = active_editor_tab (); - if (activeFileEditorTab) - activeFileEditorTab->remove_bookmark (); + file_editor_tab *_active_file_editor_tab = active_editor_tab (); + if (_active_file_editor_tab) + _active_file_editor_tab->remove_bookmark (); } void file_editor::request_toggle_breakpoint () { - file_editor_tab *activeFileEditorTab = active_editor_tab (); - if (activeFileEditorTab) - activeFileEditorTab->toggle_breakpoint (); + file_editor_tab *_active_file_editor_tab = active_editor_tab (); + if (_active_file_editor_tab) + _active_file_editor_tab->toggle_breakpoint (); } void file_editor::request_next_breakpoint () { - file_editor_tab *activeFileEditorTab = active_editor_tab (); - if (activeFileEditorTab) - activeFileEditorTab->next_breakpoint (); + file_editor_tab *_active_file_editor_tab = active_editor_tab (); + if (_active_file_editor_tab) + _active_file_editor_tab->next_breakpoint (); } void file_editor::request_previous_breakpoint () { - file_editor_tab *activeFileEditorTab = active_editor_tab (); - if (activeFileEditorTab) - activeFileEditorTab->previous_breakpoint (); + file_editor_tab *_active_file_editor_tab = active_editor_tab (); + if (_active_file_editor_tab) + _active_file_editor_tab->previous_breakpoint (); } void file_editor::request_remove_breakpoint () { - file_editor_tab *activeFileEditorTab = active_editor_tab (); - if (activeFileEditorTab) - activeFileEditorTab->remove_all_breakpoints (); + file_editor_tab *_active_file_editor_tab = active_editor_tab (); + if (_active_file_editor_tab) + _active_file_editor_tab->remove_all_breakpoints (); } void file_editor::request_comment_selected_text () { - file_editor_tab *activeFileEditorTab = active_editor_tab (); - if (activeFileEditorTab) - activeFileEditorTab->comment_selected_text (); + file_editor_tab *_active_file_editor_tab = active_editor_tab (); + if (_active_file_editor_tab) + _active_file_editor_tab->comment_selected_text (); } void file_editor::request_uncomment_selected_text () { - file_editor_tab *activeFileEditorTab = active_editor_tab (); - if (activeFileEditorTab) - activeFileEditorTab->uncomment_selected_text (); + file_editor_tab *_active_file_editor_tab = active_editor_tab (); + if (_active_file_editor_tab) + _active_file_editor_tab->uncomment_selected_text (); +} + +void +file_editor::request_find () +{ + file_editor_tab *_active_file_editor_tab = active_editor_tab (); + if (_active_file_editor_tab) + _active_file_editor_tab->find (); } void @@ -349,10 +357,10 @@ QAction *redo_action = new QAction (QIcon(":/actions/icons/redo.png"), tr("&Redo"), _tool_bar); - _copy_action = new QAction (QIcon::fromTheme ("edit-copy"), + _copy_action = new QAction (QIcon(":/actions/icons/editcopy.png"), tr ("&Copy"), _tool_bar); - _cut_action = new QAction (QIcon::fromTheme ("edit-cut"), + _cut_action = new QAction (QIcon(":/actions/icons/editcut.png"), tr ("Cu&t"), _tool_bar); QAction *paste_action @@ -371,6 +379,9 @@ QAction *comment_selection_action = new QAction (tr ("&Comment Selected Text"),_tool_bar); QAction *uncomment_selection_action = new QAction (tr ("&Uncomment Selected Text"),_tool_bar); + QAction *find_action = new QAction (QIcon(":/actions/icons/find.png"), + tr ("&Find"), _tool_bar); + _run_action = new QAction (QIcon(":/actions/icons/artsbuilderexecute.png"), tr("Save File And Run"), _tool_bar); @@ -389,6 +400,8 @@ comment_selection_action->setShortcutContext (Qt::WindowShortcut); uncomment_selection_action->setShortcut (Qt::ControlModifier + Qt::Key_8); uncomment_selection_action->setShortcutContext(Qt::WindowShortcut); + find_action->setShortcut (Qt::ControlModifier+Qt::Key_F); + find_action->setShortcutContext (Qt::WindowShortcut); // toolbar _tool_bar->addAction (new_action); @@ -400,8 +413,9 @@ _tool_bar->addAction (redo_action); _tool_bar->addAction (_copy_action); _tool_bar->addAction (_cut_action); + _tool_bar->addSeparator (); _tool_bar->addAction (paste_action); - _tool_bar->addSeparator (); + _tool_bar->addAction (find_action); _tool_bar->addAction (_run_action); // menu bar @@ -421,6 +435,8 @@ editMenu->addAction (_cut_action); editMenu->addAction (paste_action); editMenu->addSeparator (); + editMenu->addAction (find_action); + editMenu->addSeparator (); editMenu->addAction (comment_selection_action); editMenu->addAction (uncomment_selection_action); editMenu->addSeparator (); @@ -491,6 +507,8 @@ SIGNAL (triggered ()), this, SLOT (request_comment_selected_text ())); connect (uncomment_selection_action, SIGNAL (triggered ()), this, SLOT (request_uncomment_selected_text ())); + connect (find_action, + SIGNAL (triggered ()), this, SLOT (request_find ())); connect (_tab_widget, SIGNAL (tabCloseRequested (int)), this, SLOT (handle_tab_close_request (int))); connect (_tab_widget, diff --git a/gui/src/m-editor/file-editor.h b/gui/src/m-editor/file-editor.h --- a/gui/src/m-editor/file-editor.h +++ b/gui/src/m-editor/file-editor.h @@ -80,6 +80,7 @@ void request_comment_selected_text (); void request_uncomment_selected_text (); + void request_find (); void handle_file_name_changed (QString fileName); void handle_tab_close_request (int index); diff --git a/gui/src/m-editor/find-dialog.cc b/gui/src/m-editor/find-dialog.cc new file mode 100644 --- /dev/null +++ b/gui/src/m-editor/find-dialog.cc @@ -0,0 +1,129 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include "find-dialog.h" + +find_dialog::find_dialog (QsciScintilla* edit_area, QWidget *parent) + : QDialog (parent) +{ + setWindowTitle ("Search file"); + _label = new QLabel (tr ("Find &what:")); + _search_line_edit = new QLineEdit; + _label->setBuddy (_search_line_edit); + + _case_check_box = new QCheckBox (tr ("Match &case")); + _from_start_check_box = new QCheckBox (tr ("Search from &start")); + _from_start_check_box->setChecked (true); + + _find_next_button = new QPushButton (tr ("&Find Next")); + _find_next_button->setDefault (true); + + _more_button = new QPushButton (tr ("&More")); + _more_button->setCheckable (true); + _more_button->setAutoDefault (false); + + _button_box = new QDialogButtonBox (Qt::Vertical); + _button_box->addButton (_find_next_button, QDialogButtonBox::ActionRole); + _button_box->addButton (_more_button, QDialogButtonBox::ActionRole); + + _extension = new QWidget (this); + _whole_words_check_box = new QCheckBox (tr ("&Whole words")); + _regex_check_box = new QCheckBox (tr ("Regular E&xpressions")); + _backward_check_box = new QCheckBox (tr ("Search &backward")); + _search_selection_check_box = new QCheckBox (tr ("Search se&lection")); + + edit_area = edit_area; + connect (_find_next_button, SIGNAL (clicked ()), this, SLOT (search_next ())); + connect (_more_button, SIGNAL (toggled (bool)), _extension, SLOT (setVisible (bool))); + + QVBoxLayout *extension_layout = new QVBoxLayout (); + extension_layout->setMargin (0); + extension_layout->addWidget (_whole_words_check_box); + extension_layout->addWidget (_regex_check_box); + extension_layout->addWidget (_backward_check_box); + extension_layout->addWidget (_search_selection_check_box); + _extension->setLayout (extension_layout); + + QHBoxLayout *top_left_layout = new QHBoxLayout; + top_left_layout->addWidget (_label); + top_left_layout->addWidget (_search_line_edit); + + QVBoxLayout *left_layout = new QVBoxLayout; + left_layout->addLayout (top_left_layout); + left_layout->addWidget (_case_check_box); + left_layout->addWidget (_from_start_check_box); + left_layout->addStretch (1); + + QGridLayout *main_layout = new QGridLayout; + main_layout->setSizeConstraint (QLayout::SetFixedSize); + main_layout->addLayout (left_layout, 0, 0); + main_layout->addWidget (_button_box, 0, 1); + main_layout->addWidget (_extension, 1, 0, 1, 2); + setLayout (main_layout); + _extension->hide (); +} + +void +find_dialog::search_next () +{ + int line = -1, col = -1; + if (_from_start_check_box->isChecked ()) + { + line = 1; + col = 1; + } + + if (_edit_area) + { + _edit_area->findFirst (_search_line_edit->text (), + _regex_check_box->isChecked (), + _case_check_box->isChecked (), + _whole_words_check_box->isChecked (), + true, + !_backward_check_box->isChecked (), + line, + col, + true, + true + ); + } +} diff --git a/gui/src/m-editor/find-dialog.h b/gui/src/m-editor/find-dialog.h new file mode 100644 --- /dev/null +++ b/gui/src/m-editor/find-dialog.h @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef FIND_DIALOG_H +#define FIND_DIALOG_H + +#include +#include + +class QCheckBox; +class QDialogButtonBox; +class QGroupBox; +class QLabel; +class QLineEdit; +class QPushButton; + +class find_dialog : public QDialog +{ + Q_OBJECT +public: + find_dialog (QsciScintilla* edit_area, QWidget *parent = 0); + +private slots: + void search_next (); + +private: + QLabel *_label; + QLineEdit *_search_line_edit; + QCheckBox *_case_check_box; + QCheckBox *_from_start_check_box; + QCheckBox *_whole_words_check_box; + QCheckBox *_regex_check_box; + QCheckBox *_search_selection_check_box; + QCheckBox *_backward_check_box; + QDialogButtonBox *_button_box; + QPushButton *_find_next_button; + QPushButton *_more_button; + QWidget *_extension; + QsciScintilla *_edit_area; +}; + +#endif // FIND_DIALOG_H + diff --git a/gui/src/octave-adapter/octave-link.h b/gui/src/octave-adapter/octave-link.h --- a/gui/src/octave-adapter/octave-link.h +++ b/gui/src/octave-adapter/octave-link.h @@ -54,6 +54,7 @@ #include "utils.h" #include "variables.h" #include "oct-mutex.h" +#include "profiler.h" // Standard includes #include diff --git a/gui/src/qtinfo/webinfo.cc b/gui/src/qtinfo/webinfo.cc --- a/gui/src/qtinfo/webinfo.cc +++ b/gui/src/qtinfo/webinfo.cc @@ -28,9 +28,11 @@ _font_web = font (); QVBoxLayout *layout = new QVBoxLayout (); + layout->setMargin (0); setLayout (layout); QHBoxLayout *hboxLayout = new QHBoxLayout (); + hboxLayout->setMargin (2); layout->addLayout (hboxLayout); _close_tab_button = new QPushButton (this); diff --git a/gui/src/resource.qrc b/gui/src/resource.qrc --- a/gui/src/resource.qrc +++ b/gui/src/resource.qrc @@ -21,5 +21,6 @@ icons/stop.png icons/zoom-in.png icons/zoom-out.png + icons/find.png diff --git a/gui/src/src.pro b/gui/src/src.pro --- a/gui/src/src.pro +++ b/gui/src/src.pro @@ -84,6 +84,7 @@ m-editor/lexer-octave-gui.cc \ m-editor/file-editor.cc \ m-editor/file-editor-tab.cc \ + m-editor/find-dialog.cc \ qtinfo/parser.cc \ qtinfo/webinfo.cc \ main-window.cc \ @@ -109,6 +110,7 @@ m-editor/file-editor.h \ m-editor/file-editor-interface.h \ m-editor/file-editor-tab.h \ + m-editor/find-dialog.h \ qtinfo/parser.h \ qtinfo/webinfo.h \ symbol-information.h \