Mercurial > hg > octave-lyh
changeset 15300:fd27e10b9b05
pass QString by const reference instead of value
* files-dockwidget.cc, files-dockwidget.h, history-dockwidget.h,
file-editor-interface.h, file-editor-tab.cc, file-editor-tab.h,
file-editor.cc, file-editor.h, main-window.cc, main-window.h,
octave-qt-event-listener.h, parser.cc, parser.h, webinfo.cc,
webinfo.h, resource-manager.cc, resource-manager.h: For all functions
that take QString arguments, use "const Qstring&" instead of passing
QString by value.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 05 Sep 2012 11:41:21 -0400 |
parents | 8bd5c490b787 |
children | 3d05b55c91c7 |
files | libgui/src/files-dockwidget.cc libgui/src/files-dockwidget.h libgui/src/history-dockwidget.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/file-editor.h libgui/src/main-window.cc libgui/src/main-window.h libgui/src/octave-qt-event-listener.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/resource-manager.h |
diffstat | 17 files changed, 81 insertions(+), 75 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/src/files-dockwidget.cc +++ b/libgui/src/files-dockwidget.cc @@ -119,7 +119,7 @@ } void -files_dock_widget::set_current_directory (QString currentDirectory) +files_dock_widget::set_current_directory (const QString& currentDirectory) { display_directory (currentDirectory); } @@ -139,7 +139,7 @@ } void -files_dock_widget::display_directory (QString directory) +files_dock_widget::display_directory (const QString& directory) { QFileInfo fileInfo (directory); if (fileInfo.exists ())
--- a/libgui/src/files-dockwidget.h +++ b/libgui/src/files-dockwidget.h @@ -57,12 +57,12 @@ void do_up_directory (); /** Sets the current directory being displayed. */ - void set_current_directory (QString currentDirectory); + void set_current_directory (const QString& currentDirectory); /** Accepts user input a the line edit for the current directory. */ void handle_directory_entered (); - void display_directory (QString directory); + void display_directory (const QString& directory); /** Tells the widget to react on changed settings. */ void notice_settings (); @@ -72,10 +72,10 @@ signals: /** Emitted, whenever the user requested to open a file. */ - void open_file (QString fileName); + void open_file (const QString& fileName); /** Emitted, whenever the currently displayed directory changed. */ - void displayed_directory_changed (QString directory); + void displayed_directory_changed (const QString& directory); /** Custom signal that tells if a user has clicke away that dock widget. */ void active_changed (bool active);
--- a/libgui/src/history-dockwidget.h +++ b/libgui/src/history-dockwidget.h @@ -48,10 +48,10 @@ void reset_model (); signals: - void information (QString message); + void information (const QString& message); /** Emitted, whenever the user double-clicked a command in the history. */ - void command_double_clicked (QString command); + void command_double_clicked (const QString& command); /** Custom signal that tells if a user has clicked away that dock widget. */ void active_changed (bool active);
--- a/libgui/src/m-editor/file-editor-interface.h +++ b/libgui/src/m-editor/file-editor-interface.h @@ -57,7 +57,7 @@ public slots: virtual void request_new_file () = 0; virtual void request_open_file () = 0; - virtual void request_open_file (QString fileName) = 0; + virtual void request_open_file (const QString& fileName) = 0; signals: void active_changed (bool active);
--- a/libgui/src/m-editor/file-editor-tab.cc +++ b/libgui/src/m-editor/file-editor-tab.cc @@ -198,7 +198,7 @@ } void -file_editor_tab::set_file_name (QString fileName) +file_editor_tab::set_file_name (const QString& fileName) { _file_name = fileName; update_lexer (); @@ -436,7 +436,7 @@ } int -file_editor_tab::check_file_modified (QString msg, int cancelButton) +file_editor_tab::check_file_modified (const QString& msg, int cancelButton) { int decision = QMessageBox::Yes; if (_edit_area->isModified ()) @@ -626,7 +626,7 @@ } void -file_editor_tab::load_file (QString fileName) +file_editor_tab::load_file (const QString& fileName) { if (!_file_editor->isVisible ()) { @@ -675,7 +675,7 @@ } bool -file_editor_tab::save_file (QString saveFileName) +file_editor_tab::save_file (const QString& saveFileName) { // it is a new file with the name "<unnamed>" -> call saveFielAs if (saveFileName == UNNAMED_FILE || saveFileName.isEmpty ()) @@ -777,7 +777,7 @@ } void -file_editor_tab::file_has_changed (QString fileName) +file_editor_tab::file_has_changed (const QString& fileName) { Q_UNUSED (fileName); if (QFile::exists (_file_name))
--- a/libgui/src/m-editor/file-editor-tab.h +++ b/libgui/src/m-editor/file-editor-tab.h @@ -65,23 +65,23 @@ void set_modified (bool modified = true); bool open_file (); - void load_file (QString fileName); + void load_file (const QString& fileName); void new_file (); bool save_file (); - bool save_file(QString saveFileName); + bool save_file (const QString& saveFileName); bool save_file_as(); void run_file (); - void file_has_changed (QString fileName); + void file_has_changed (const QString& fileName); signals: - void file_name_changed (QString fileName); + void file_name_changed (const QString& fileName); void editor_state_changed (); void close_request (); protected: void closeEvent (QCloseEvent *event); - void set_file_name (QString fileName); + void set_file_name (const QString& fileName); private: void update_lexer (); @@ -89,7 +89,7 @@ void request_remove_breakpoint (int line); void update_tracked_file (); - int check_file_modified (QString msg, int cancelButton); + int check_file_modified (const QString& msg, int cancelButton); void do_comment_selected_text (bool comment); file_editor * _file_editor;
--- a/libgui/src/m-editor/file-editor.cc +++ b/libgui/src/m-editor/file-editor.cc @@ -111,7 +111,7 @@ } void -file_editor::request_open_file (QString fileName) +file_editor::request_open_file (const QString& fileName) { if (!isVisible ()) { @@ -279,7 +279,7 @@ } void -file_editor::handle_file_name_changed (QString fileName) +file_editor::handle_file_name_changed (const QString& fileName) { QObject *senderObject = sender (); file_editor_tab *fileEditorTab
--- a/libgui/src/m-editor/file-editor.h +++ b/libgui/src/m-editor/file-editor.h @@ -50,7 +50,7 @@ public: file_editor (QTerminal *terminal, main_window *m); ~file_editor (); - void loadFile (QString fileName); + void loadFile (const QString& fileName); QTerminal * terminal (); main_window * get_main_window (); @@ -64,7 +64,7 @@ public slots: void request_new_file (); void request_open_file (); - void request_open_file (QString fileName); + void request_open_file (const QString& fileName); void request_undo (); void request_redo (); @@ -88,7 +88,7 @@ void request_uncomment_selected_text (); void request_find (); - void handle_file_name_changed (QString fileName); + void handle_file_name_changed (const QString& fileName); void handle_tab_close_request (int index); void handle_tab_close_request (); void active_tab_changed (int index);
--- a/libgui/src/main-window.cc +++ b/libgui/src/main-window.cc @@ -85,14 +85,14 @@ } void -main_window::open_file (QString file_name) +main_window::open_file (const QString& file_name) { _file_editor->request_open_file (file_name); focus_editor (); } void -main_window::report_status_message (QString statusMessage) +main_window::report_status_message (const QString& statusMessage) { _status_bar->showMessage (statusMessage, 1000); } @@ -140,7 +140,7 @@ } void -main_window::handle_command_double_clicked (QString command) +main_window::handle_command_double_clicked (const QString& command) { _terminal->sendText (command); _terminal->setFocus (); @@ -216,7 +216,7 @@ } void -main_window::current_working_directory_has_changed (QString directory) +main_window::current_working_directory_has_changed (const QString& directory) { if (_current_directory_combo_box->count () > 31) { @@ -244,7 +244,7 @@ } void -main_window::set_current_working_directory (QString directory) +main_window::set_current_working_directory (const QString& directory) { octave_link::instance () ->post_event (new octave_change_directory_event (*this,
--- a/libgui/src/main-window.h +++ b/libgui/src/main-window.h @@ -83,15 +83,15 @@ void settings_changed (); public slots: - void report_status_message (QString statusMessage); + void report_status_message (const QString& statusMessage); void handle_save_workspace_request (); void handle_load_workspace_request (); void handle_clear_workspace_request (); void handle_clear_history_request (); - void handle_command_double_clicked (QString command); + void handle_command_double_clicked (const QString& command); void new_file (); void open_file (); - void open_file (QString file_name); + void open_file (const QString& file_name); void open_bug_tracker_page (); void open_agora_page (); void open_octave_forge_page (); @@ -100,9 +100,9 @@ void notice_settings (); void prepare_for_quit (); void reset_windows (); - void current_working_directory_has_changed (QString directory); + void current_working_directory_has_changed (const QString& directory); void change_current_working_directory (); - void set_current_working_directory (QString directory); + void set_current_working_directory (const QString& directory); void current_working_directory_up (); void focus_command_window ();
--- a/libgui/src/octave-qt-event-listener.h +++ b/libgui/src/octave-qt-event-listener.h @@ -41,7 +41,7 @@ void quit_debug_mode (); signals: - void current_directory_has_changed_signal (QString directory); + void current_directory_has_changed_signal (const QString& directory); void entered_debug_mode_signal (); void quit_debug_mode_signal (); };
--- a/libgui/src/qtinfo/parser.cc +++ b/libgui/src/qtinfo/parser.cc @@ -41,7 +41,7 @@ } void -parser::set_info_path (QString infoPath) +parser::set_info_path (const QString& infoPath) { this->_info_path = infoPath; @@ -100,7 +100,7 @@ } int -parser::is_ref (QString node) +parser::is_ref (const QString& node) { if (_ref_map.contains (node)) { @@ -112,8 +112,10 @@ } QString -parser::search_node (QString node) +parser::search_node (const QString& node_arg) { + QString node = node_arg; + QFileInfo file_info; QString ref; @@ -152,7 +154,7 @@ } QString -parser::search_node (QString node, QIODevice *io) +parser::search_node (const QString& node, QIODevice *io) { while (!io->atEnd ()) { @@ -186,7 +188,7 @@ } static QString -get_first_line (QString text) +get_first_line (const QString& text) { int n = text.indexOf ("\n"); @@ -200,7 +202,7 @@ } static QString -parser_node (QString text, QString node_name) +parser_node (const QString& text, const QString& node_name) { QString firstLine = get_first_line (text); QStringList nodes = firstLine.split (","); @@ -217,31 +219,31 @@ } QString -parser::get_node_name (QString text) +parser::get_node_name (const QString& text) { return parser_node (text, "Node:"); } QString -parser::get_node_up (QString text) +parser::get_node_up (const QString& text) { return parser_node (text, "Up:"); } QString -parser::get_node_next (QString text) +parser::get_node_next (const QString& text) { return parser_node (text, "Next:"); } QString -parser::get_node_prev (QString text) +parser::get_node_prev (const QString& text) { return parser_node (text, "Prev:"); } static void -replace_links (QString &text) +replace_links (QString& text) { QRegExp re ("(\\*[N|n]ote|\n\\*)([ |\n]+)([^:]+):([^:\\.,]*)([:,\\.])"); int i = 0, f; @@ -282,7 +284,7 @@ } static void -replace_colons (QString &text) +replace_colons (QString& text) { QRegExp re ("`([^']+)'"); int i = 0, f; @@ -298,7 +300,7 @@ } static void -info_to_html (QString &text) +info_to_html (QString& text) { text.replace ("&", "&"); text.replace ("<", "<"); @@ -311,8 +313,11 @@ } QString -parser::node_text_to_html (QString text, int anchorPos, QString anchor) +parser::node_text_to_html (const QString& text_arg, int anchorPos, + const QString& anchor) { + QString text = text_arg; + QString nodeName = get_node_name (text); QString nodeUp = get_node_up (text); QString nodeNext = get_node_next (text); @@ -479,7 +484,7 @@ } static void -replace (QString &text, QRegExp re, QString after) +replace (QString& text, const QRegExp& re, const QString& after) { int pos = 0; @@ -495,7 +500,7 @@ } QString -parser::global_search (QString text, int max_founds) +parser::global_search (const QString& text, int max_founds) { QString results; QStringList words = text.split (" ",QString::SkipEmptyParts);
--- a/libgui/src/qtinfo/parser.h +++ b/libgui/src/qtinfo/parser.h @@ -45,20 +45,21 @@ public: parser (QObject *parent = 0); - void set_info_path (QString _info_path); + void set_info_path (const QString& _info_path); QString get_info_path (); - QString search_node (QString node); - QString global_search (QString text, int maxFounds); + QString search_node (const QString& node); + QString global_search (const QString& text, int maxFounds); /** Checks if this node is reference. If node is reference, it will be returned its position * in text, else it will be returned -1. */ - int is_ref (QString node); + int is_ref (const QString& node); /**Translates text of node to Html. If anchorPos is not -1, then anchor is inserted in that * position. */ - QString node_text_to_html (QString text, int anchorPos=-1, QString anchor=QString()); + QString node_text_to_html (const QString& text, int anchorPos = -1, + const QString& anchor = QString ()); private: struct node_position @@ -78,12 +79,12 @@ int real_size; }; - QString search_node (QString node, QIODevice * io); + QString search_node (const QString& node, QIODevice * io); QString get_next_node (QIODevice * io); - QString get_node_name (QString text); - QString get_node_up (QString text); - QString get_node_next (QString text); - QString get_node_prev (QString text); + QString get_node_name (const QString& text); + QString get_node_up (const QString& text); + QString get_node_next (const QString& text); + QString get_node_prev (const QString& text); /** Parses info files and gets map of node positions.*/ void parse_info_map();
--- a/libgui/src/qtinfo/webinfo.cc +++ b/libgui/src/qtinfo/webinfo.cc @@ -31,7 +31,7 @@ webinfo::webinfo (QWidget *parent) - :QWidget (parent) + : QWidget (parent) { _font_web = font (); @@ -90,14 +90,14 @@ } void -webinfo::set_info_path (QString info_path) +webinfo::set_info_path (const QString& info_path) { _parser.set_info_path (info_path); load_node ("Top"); } void -webinfo::load_node (QString node_name) +webinfo::load_node (const QString& node_name) { //Check if node has been already opened. for (int i = 0;i < _tab_bar->count (); i++) @@ -142,7 +142,7 @@ } QTextBrowser * -webinfo::addNewTab(QString name) +webinfo::addNewTab (const QString& name) { _text_browser = new QTextBrowser (this); _text_browser->setOpenLinks (false);
--- a/libgui/src/qtinfo/webinfo.h +++ b/libgui/src/qtinfo/webinfo.h @@ -31,11 +31,11 @@ Q_OBJECT public: webinfo (QWidget *parent = 0); - void set_info_path (QString info_path); - void load_node (QString node_name); + void set_info_path (const QString& info_path); + void load_node (const QString& node_name); public slots: - void link_clicked (const QUrl &link); + void link_clicked (const QUrl& link); void current_tab_changed (int index); void close_tab (); void search (); @@ -55,6 +55,6 @@ parser _parser; QFont _font_web; - QTextBrowser *addNewTab (QString name); + QTextBrowser *addNewTab (const QString& name); void closeTab(int index); };
--- a/libgui/src/resource-manager.cc +++ b/libgui/src/resource-manager.cc @@ -53,7 +53,7 @@ } QString -resource_manager::find_translator_file (QString language) +resource_manager::find_translator_file (const QString& language) { // TODO: Quick hack to be able to test language files. return QString ("../languages/%1.qm").arg (language); @@ -127,7 +127,7 @@ } void -resource_manager::do_set_settings (QString file) +resource_manager::do_set_settings (const QString& file) { delete settings; settings = new QSettings (file, QSettings::IniFormat);
--- a/libgui/src/resource-manager.h +++ b/libgui/src/resource-manager.h @@ -54,13 +54,13 @@ instance->do_reload_settings (); } - static void set_settings (QString file) + static void set_settings (const QString& file) { if (instance_ok ()) instance->do_set_settings (file); } - static QString find_translator_file (QString language); + static QString find_translator_file (const QString& language); static void update_network_settings (void) { @@ -101,7 +101,7 @@ void do_reload_settings (void); - void do_set_settings (QString file); + void do_set_settings (const QString& file); void do_update_network_settings (void);