Mercurial > octave
view libgui/src/variable-editor.h @ 24642:d58543eb53e9
improve efficiency of variable editor
* variable-editor.h, variable-editor.cc
(variable_editor::clear_data_cache): Delete.
Use variable_editor::refresh instead.
(variable_editor::double_click): pass value at current index to sub
editor.
* variable-editor-model.h, variable-editor-model.cc
(cell::state_t, cell::state): Delete enum, data member, and all uses.
(cell::m_defined): New data member.
(impl::m_value): New data member.
(impl::m_type): Delete data member and all uses.
(impl::update, impl::value_at, impl::clear, impl::reset,
impl::make_label, impl::invalidate): New functions.
(impl::is_set, impl::is_notavail, impl::is_pending, impl::pending,
impl::notavail, impl::unset): Delete.
(impl::data): Call update.
(variable_editor_model::variable_editor_model): Pass value to impl
constructor. Initialize model size here.
(variable_editor_model::value_at, variable_editor_model::invalidate,
variable_editor_model::data_error,
variable_editor_model::clear_data_cell,
variable_editor_model::type_is_editable,
variable_editor_model::evaluation_error): New functions.
(variable_editor_model::data): Simplify.
(variable_editor_model::update_data_cache): Rename from
variable_editor_model::clear_data_cache. Change all uses.
(variable_editor_model::received_data,
variable_editor_model::received_no_data,
variable_editor_model::received_unset_data,
variable_editor_model::get_data_oct,
variable_editor_model::display_invalid): Delete.
(variable_editor_model::user_error): Rename from
variable_editor_model::received_user_error. Change all uses.
(variable_editor_model::update_data): Rename from
variable_editor_model::received_initialize_data. Change all uses.
Simplify.
(variable_editor_model::set_data_oct,
variable_editor_model::init_from_oct,
variable_editor_model::eval_oct,
variable_editor_model::retrieve_variable): Simplify. Use exception
handling. Avoid unnecessary evaluation.
Update signal and slot names for consistency and clarity.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 26 Jan 2018 00:11:11 -0500 |
parents | 7d177be54c37 |
children | 456b486ae5e6 |
line wrap: on
line source
/* Copyright (C) 2013-2017 John W. Eaton Copyright (C) 2015 Michael Barnes Copyright (C) 2013 RĂ¼diger Sonderfeld This file is part of Octave. Octave is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Octave is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Octave; see the file COPYING. If not, see <https://www.gnu.org/licenses/>. */ #if ! defined (variable_editor_h) #define variable_editor_h 1 #include <QHeaderView> #include <QSettings> #include "octave-dock-widget.h" class octave_value; class QTabWidget; class QToolBar; class QMainWindow; class QTableView; class QModelIndex; class variable_editor : public octave_dock_widget { Q_OBJECT public: variable_editor (QWidget *parent = nullptr); ~variable_editor (void); // No copying! variable_editor (const variable_editor&) = delete; variable_editor& operator = (const variable_editor&) = delete; void edit_variable (const QString& name, const octave_value& val); void refresh (void); bool has_focus (void); static QList<QColor> default_colors (void); static QStringList color_names (void); public slots: void callUpdate (const QModelIndex&,const QModelIndex&); void notice_settings (const QSettings *); protected slots: void closeEvent (QCloseEvent *); void closeTab (int idx); void contextmenu_requested (const QPoint& pt); void columnmenu_requested (const QPoint& pt); void rowmenu_requested (const QPoint& pt); void double_click (const QModelIndex& idx); void save (void); void clearContent (void); void cutClipboard (void); void copyClipboard (void); void pasteClipboard (void); void pasteTableClipboard (void); void createVariable (void); void transposeContent (void); void up (void); void delete_selected (void); // Send command to Octave interpreter. // %1 in CMD is replaced with the value of selected_to_octave. void relay_command (const QString& cmd); signals: void updated (void); void finished (void); void command_requested (const QString& cmd); private: QMainWindow *m_main; QToolBar *m_tool_bar; QTabWidget *m_tab_widget; int m_default_width; int m_default_height; int m_add_font_height; bool m_autofit; bool m_autofit_max; bool m_use_terminal_font; bool m_alternate_rows; QString m_stylesheet; QFont m_font; // If use_terminal_font is true then this will be different since // "font" will contain the terminal font. QFont m_sel_font; QList<QColor> m_table_colors; QList<int> octave_to_coords (QString&); // Get the real variable name from the tab text QString real_var_name (int index); // Convert selection to an Octave expression. QString selected_to_octave (void); void update_colors (void); void construct_tool_bar (void); }; #endif