annotate libgui/src/history-dockwidget.h @ 16431:5982d469f79b

use signal for setting, appending to, and clearing history widget * history-dockwidget.h, history-dockwidget.cc (history_dock_widget::request_history_model_update, history_dock_widget::reset_model, history_dock_widget::update_history_callback): Delete. (history_dock_widget::set_history, history_dock_widget::append_history, history_dock_widget::clear_history): New functions. * main-window.h, main-window.cc (main_window::update_history): Delete. (main_window::construct): Delete connection from _octave_qt_event_listener::update_history_signal to main_window::update_history. Connect _octave_qt_link::set_history_signal to _history_dock_widget::set_history. Connect _octave_qt_link::append_history_signal to _history_dock_widget::append_history. Connect _octave_qt_link::clear_history_signal to _history_dock_widget::clear_history. (main_window::clear_history_callback): Call Fhistory instead of command_history::clear and _history_dock_widget->reset_model. * octave-main-thread.cc (octave_main_thread::run): Don't call octave_link::update_history. * octave-qt-event-listener.h, octave-qt-event-listener.cc (octave_qt_event_listener::update_history): Delete. (octave_qt_event_listener::update_history_signal): Delete. * octave-qt-link.h, octave-qt-link.cc (octave_qt_link::do_update_history): Delete. (octave_qt_link::do_set_history,octave_qt_link::do_append_history, octave_qt_link::do_clear_history): New functions. (octave_qt_link::do_post_input_event): Don't call do_update_history. (set_history_signal, append_history_signal, clear_history_signal): New signals. * octave-event-listener.h (octave_event_listener::update_history): Delete. * input.cc (octave_base_reader::octave_gets): Call command_history::add. * oct-hist.cc (do_history): New option, -c. Call octave_link history functions as needed. (initialize_history): Call octave_link::set_history. (octave_history_write_timestamp): Call octave_link::append_history. (Fedit_history): Document -c. * octave-link.h (octave_link::update_history, octave_link::do_update_history): Delete. (octave_link::set_history, octave_link::append_history, octave_link::clear_history, octave_link::do_set_history, octave_link::do_append_history, octave_link::do_clear_history, octave_link::do_pre_input_event, octave_link::do_post_input_event): New functions.
author John W. Eaton <jwe@octave.org>
date Thu, 04 Apr 2013 13:20:43 -0400
parents d4b6ad43bc87
children e3b33a7530bc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15204
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
1 /*
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
2
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
3 Copyright (C) 2011-2012 Jacob Dawid
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
4
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
5 This file is part of Octave.
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
6
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
8 under the terms of the GNU General Public License as published by the
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
9 Free Software Foundation; either version 3 of the License, or (at your
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
10 option) any later version.
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
11
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
15 for more details.
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
16
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
17 You should have received a copy of the GNU General Public License
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
18 along with Octave; see the file COPYING. If not, see
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
19 <http://www.gnu.org/licenses/>.
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
20
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
21 */
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
22
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
23 #ifndef HISTORYDOCKWIDGET_H
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
24 #define HISTORYDOCKWIDGET_H
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
25
13545
ffc2e1d1ad5f History can be filtered with an input search box while typing.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13536
diff changeset
26 #include <QLineEdit>
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
27 #include <QListView>
13545
ffc2e1d1ad5f History can be filtered with an input search box while typing.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13536
diff changeset
28 #include <QSortFilterProxyModel>
14720
cecc7da96e2a Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14712
diff changeset
29 #include <QStringListModel>
16057
c3057d80cf91 Created common octave_dock_widget class
Richard Crozier <richard.crozier@yahoo.co.uk>
parents: 15552
diff changeset
30 #include "octave-dock-widget.h"
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
31
16057
c3057d80cf91 Created common octave_dock_widget class
Richard Crozier <richard.crozier@yahoo.co.uk>
parents: 15552
diff changeset
32 class history_dock_widget : public octave_dock_widget
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
33 {
15367
501a9cc2c68f maint: whitespace cleanup in GUI code
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15300
diff changeset
34 Q_OBJECT
501a9cc2c68f maint: whitespace cleanup in GUI code
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15300
diff changeset
35 public:
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
36 history_dock_widget (QWidget *parent = 0);
14720
cecc7da96e2a Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14712
diff changeset
37
13536
869c62c15e95 Few minor improvements, added advanced settings for file browser.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13518
diff changeset
38 public slots:
16431
5982d469f79b use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents: 16350
diff changeset
39 void set_history (const QStringList& hist);
5982d469f79b use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents: 16350
diff changeset
40 void append_history (const QString& hist_entry);
5982d469f79b use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents: 16350
diff changeset
41 void clear_history (void);
13546
5ef33f99a078 Command get inserted by double clicking in the command history again.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13545
diff changeset
42
13517
86adc9c4ec4b History deactivated.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13506
diff changeset
43 signals:
15300
fd27e10b9b05 pass QString by const reference instead of value
John W. Eaton <jwe@octave.org>
parents: 15204
diff changeset
44 void information (const QString& message);
14863
3ff18e21c742 Added a few comments.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14814
diff changeset
45
3ff18e21c742 Added a few comments.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14814
diff changeset
46 /** Emitted, whenever the user double-clicked a command in the history. */
15300
fd27e10b9b05 pass QString by const reference instead of value
John W. Eaton <jwe@octave.org>
parents: 15204
diff changeset
47 void command_double_clicked (const QString& command);
14863
3ff18e21c742 Added a few comments.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14814
diff changeset
48
13546
5ef33f99a078 Command get inserted by double clicking in the command history again.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13545
diff changeset
49 private slots:
14712
5cb54cca8a06 Completion of code reformatting.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14709
diff changeset
50 void handle_double_click (QModelIndex modelIndex);
15447
352349219529 Added multiline copy and execution to command history in IDE (bug #36884)
John Swensen <jpswensen@gmail.com>
parents: 15402
diff changeset
51 void handle_contextmenu_copy(bool flag);
352349219529 Added multiline copy and execution to command history in IDE (bug #36884)
John Swensen <jpswensen@gmail.com>
parents: 15402
diff changeset
52 void handle_contextmenu_evaluate(bool flag);
352349219529 Added multiline copy and execution to command history in IDE (bug #36884)
John Swensen <jpswensen@gmail.com>
parents: 15402
diff changeset
53 void ctxMenu(const QPoint &pos);
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
54
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
55 private:
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
56 void construct ();
14720
cecc7da96e2a Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14712
diff changeset
57 QListView *_history_list_view;
cecc7da96e2a Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14712
diff changeset
58 QLineEdit *_filter_line_edit;
cecc7da96e2a Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14712
diff changeset
59 QSortFilterProxyModel _sort_filter_proxy_model;
cecc7da96e2a Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14712
diff changeset
60
cecc7da96e2a Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14712
diff changeset
61 /** Stores the current history_model. */
cecc7da96e2a Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14712
diff changeset
62 QStringListModel *_history_model;
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
63 };
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
64
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
65 #endif // HISTORYDOCKWIDGET_H