Mercurial > octave
annotate libgui/src/history-dockwidget.cc @ 15402:7f423c6111c6
refactor GUI event handling to use new event_queue class
* octave-link.h, octave-link.cc (event_queue): Delete.
(gui_event_queue): New event_queue variable. Change all uses of
event_queue to user gui_event_queue instead.
(octave_link::handle_event): Delete.
(octave_link::post_event, octave_link::do_post_event): Provide methods
that work directly with member functions pointers and data.
* octave-event.h, octave-event.cc, octave-event-observer.h: Delete.
Delete all uses.
* libgui/src/module.mk (noinst_HEADERS): Delete octave-event.h and
octave-event-observer.h from the list.
(src_libgui_src_la_SOURCES): Delete octave-event.cc from the list.
* workspace-view.h, history-dockwidget.h, main-window.h:
Don't include octave-link.h.
* history-dockwidget.cc (history_dock_widget::handle_event): Delete.
(history_dock_widget::handle_event): New function adapted from
handle_event.
(history_dock_widget::request_history_model_update): Update for new
event callback mechanism.
* history-dockwidget.h: Update decls.
* file-editor-tab.cc (file_editor_tab::handle_event): Delete.
(file_editor_tab::run_file_callback,
file_editor_tab::add_breakpoint_callback,
file_editor_tab::remove_breakpoint_callback,
file_editor_tab::remove_all_breakpoints_callback):
New functions adapted from handle_event and corresponding octave_event
classes.
(file_editor_tab::request_add_breakpoint,
file_editor_tab::request_remove_breakpoint,
file_editor_tab::remove_all_breakpoints, file_editor_tab::run_file):
Update for new event callback mechanism.
* file-editor-tab.h: Update decls.
(file_editor_tab::bp_info): New nested struct.
* main-window.cc (main_window::handle_event): Delete.
(main_window::save_workspace_callback,
main_window::load_workspace_callback,
main_window::clear_workspace_callback,
main_window::clear_history_callback,
main_window::change_directory_callback,
main_window::debug_continue_callback,
main_window::debug_step_into_callback,
main_window::debug_step_over_callback,
main_window::debug_step_out_callback,
main_window::debug_quit_callback, main_window::exit_callback):
New functions.
(main_window::handle_save_workspace_request,
main_window::handle_load_workspace_request,
main_window::handle_clear_workspace_request,
main_window::handle_clear_history_request,
main_window::change_current_working_directory,
main_window::set_current_working_directory,
main_window::debug_continue, main_window::debug_step_into,
main_window::debug_step_over, main_window::debug_step_out,
main_window::debug_quit):
Update for new event callback mechanism.
* main-window.h: Update decls.
* workspace-model.cc (workspace_model::handle_event): Delete.
(workspace_model::update_workspace_callback): New function.
(workspace_model::request_update_workspace): Update for new event
callback mechanism.
* workspace-model.h: Update decls.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 17 Sep 2012 23:07:22 -0400 |
parents | 24b5348d38e7 |
children | 352349219529 |
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 */ |
13495 | 22 |
15155
9e62d5a3a45e
partial cleanup of include files in gui sources
John W. Eaton <jwe@octave.org>
parents:
14814
diff
changeset
|
23 #ifdef HAVE_CONFIG_H |
9e62d5a3a45e
partial cleanup of include files in gui sources
John W. Eaton <jwe@octave.org>
parents:
14814
diff
changeset
|
24 #include <config.h> |
9e62d5a3a45e
partial cleanup of include files in gui sources
John W. Eaton <jwe@octave.org>
parents:
14814
diff
changeset
|
25 #endif |
9e62d5a3a45e
partial cleanup of include files in gui sources
John W. Eaton <jwe@octave.org>
parents:
14814
diff
changeset
|
26 |
9e62d5a3a45e
partial cleanup of include files in gui sources
John W. Eaton <jwe@octave.org>
parents:
14814
diff
changeset
|
27 #include <QVBoxLayout> |
9e62d5a3a45e
partial cleanup of include files in gui sources
John W. Eaton <jwe@octave.org>
parents:
14814
diff
changeset
|
28 |
15340
9d0cdd49054b
keep history in gui widget at bottom when new items are added
John W. Eaton <jwe@octave.org>
parents:
15318
diff
changeset
|
29 #include "error.h" |
9d0cdd49054b
keep history in gui widget at bottom when new items are added
John W. Eaton <jwe@octave.org>
parents:
15318
diff
changeset
|
30 |
15402
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
31 #include "cmd-hist.h" |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
32 |
14707
674740c44c09
Changed various files to matche file naming conventions.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14703
diff
changeset
|
33 #include "history-dockwidget.h" |
15402
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
34 #include "octave-link.h" |
13495 | 35 |
15368
36ececf69385
avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents:
15367
diff
changeset
|
36 history_dock_widget::history_dock_widget (QWidget * p) |
15402
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
37 : QDockWidget (p) |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
38 { |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
39 setObjectName ("HistoryDockWidget"); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
40 construct (); |
13495 | 41 } |
42 | |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
43 void |
14709
f50591409306
Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14707
diff
changeset
|
44 history_dock_widget::construct () |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
45 { |
14720
cecc7da96e2a
Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
46 _history_model = new QStringListModel (); |
cecc7da96e2a
Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
47 _sort_filter_proxy_model.setSourceModel (_history_model); |
cecc7da96e2a
Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
48 _history_list_view = new QListView (this); |
cecc7da96e2a
Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
49 _history_list_view->setModel (&_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
|
50 _history_list_view->setAlternatingRowColors (true); |
cecc7da96e2a
Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
51 _history_list_view->setEditTriggers (QAbstractItemView::NoEditTriggers); |
cecc7da96e2a
Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
52 _history_list_view->setStatusTip (tr ("Doubleclick a command to transfer it to the terminal.")); |
cecc7da96e2a
Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
53 _filter_line_edit = new QLineEdit (this); |
cecc7da96e2a
Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
54 _filter_line_edit->setStatusTip (tr ("Enter text to filter the command history.")); |
15368
36ececf69385
avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents:
15367
diff
changeset
|
55 QVBoxLayout *vbox_layout = new QVBoxLayout (); |
13495 | 56 |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
57 setWindowTitle (tr ("Command History")); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
58 setWidget (new QWidget ()); |
13495 | 59 |
15368
36ececf69385
avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents:
15367
diff
changeset
|
60 vbox_layout->addWidget (_history_list_view); |
36ececf69385
avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents:
15367
diff
changeset
|
61 vbox_layout->addWidget (_filter_line_edit); |
36ececf69385
avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents:
15367
diff
changeset
|
62 vbox_layout->setMargin (2); |
13495 | 63 |
15368
36ececf69385
avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents:
15367
diff
changeset
|
64 widget ()->setLayout (vbox_layout); |
13545
ffc2e1d1ad5f
History can be filtered with an input search box while typing.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13536
diff
changeset
|
65 |
14720
cecc7da96e2a
Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
66 connect (_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
|
67 SIGNAL (textEdited (QString)), |
cecc7da96e2a
Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
68 &_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
|
69 SLOT (setFilterWildcard (QString))); |
cecc7da96e2a
Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
70 |
cecc7da96e2a
Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
71 connect (_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
|
72 SIGNAL (doubleClicked (QModelIndex)), |
cecc7da96e2a
Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
73 this, |
cecc7da96e2a
Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
74 SLOT (handle_double_click (QModelIndex))); |
cecc7da96e2a
Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
75 |
cecc7da96e2a
Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
76 connect (this, |
cecc7da96e2a
Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
77 SIGNAL (visibilityChanged (bool)), |
cecc7da96e2a
Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
78 this, |
cecc7da96e2a
Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
79 SLOT (handle_visibility_changed (bool))); |
cecc7da96e2a
Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
80 |
cecc7da96e2a
Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
81 _update_history_model_timer.setInterval (200); |
14750
4812bcd524a1
Fixed flooding the event queue by only an event after the last one has been processed.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14720
diff
changeset
|
82 _update_history_model_timer.setSingleShot (true); |
14720
cecc7da96e2a
Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
83 |
cecc7da96e2a
Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
84 connect (&_update_history_model_timer, |
cecc7da96e2a
Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
85 SIGNAL (timeout ()), |
cecc7da96e2a
Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
86 this, |
cecc7da96e2a
Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
87 SLOT (request_history_model_update ())); |
cecc7da96e2a
Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
88 |
cecc7da96e2a
Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
89 _update_history_model_timer.start (); |
14812
9d9eb9bac65e
Improved menu structure of file, edit and window menu. Removed ambiguous shortcuts, improved focus handling for operating the GUI with the keyboard. Added new shortcuts to focus subwindows directly.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14750
diff
changeset
|
90 |
9d9eb9bac65e
Improved menu structure of file, edit and window menu. Removed ambiguous shortcuts, improved focus handling for operating the GUI with the keyboard. Added new shortcuts to focus subwindows directly.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14750
diff
changeset
|
91 setFocusProxy (_filter_line_edit); |
13495 | 92 } |
13536
869c62c15e95
Few minor improvements, added advanced settings for file browser.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13518
diff
changeset
|
93 |
869c62c15e95
Few minor improvements, added advanced settings for file browser.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13518
diff
changeset
|
94 void |
14712
5cb54cca8a06
Completion of code reformatting.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14709
diff
changeset
|
95 history_dock_widget::handle_double_click (QModelIndex modelIndex) |
13546
5ef33f99a078
Command get inserted by double clicking in the command history again.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13545
diff
changeset
|
96 { |
14712
5cb54cca8a06
Completion of code reformatting.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14709
diff
changeset
|
97 emit command_double_clicked (modelIndex.data().toString()); |
13546
5ef33f99a078
Command get inserted by double clicking in the command history again.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13545
diff
changeset
|
98 } |
13577
e440b3f32f02
Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13549
diff
changeset
|
99 |
e440b3f32f02
Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13549
diff
changeset
|
100 void |
14712
5cb54cca8a06
Completion of code reformatting.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14709
diff
changeset
|
101 history_dock_widget::handle_visibility_changed (bool visible) |
13577
e440b3f32f02
Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13549
diff
changeset
|
102 { |
e440b3f32f02
Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13549
diff
changeset
|
103 if (visible) |
14712
5cb54cca8a06
Completion of code reformatting.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14709
diff
changeset
|
104 emit active_changed (true); |
13577
e440b3f32f02
Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13549
diff
changeset
|
105 } |
e440b3f32f02
Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13549
diff
changeset
|
106 |
e440b3f32f02
Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13549
diff
changeset
|
107 void |
14720
cecc7da96e2a
Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
108 history_dock_widget::request_history_model_update () |
cecc7da96e2a
Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
109 { |
15402
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
110 octave_link::post_event (this, &history_dock_widget::update_history_callback); |
14720
cecc7da96e2a
Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
111 } |
cecc7da96e2a
Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
112 |
cecc7da96e2a
Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
113 void |
14814
61c80e9326a8
Clearing the command history works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14812
diff
changeset
|
114 history_dock_widget::reset_model () |
61c80e9326a8
Clearing the command history works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14812
diff
changeset
|
115 { |
61c80e9326a8
Clearing the command history works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14812
diff
changeset
|
116 _history_model->setStringList (QStringList ()); |
61c80e9326a8
Clearing the command history works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14812
diff
changeset
|
117 } |
61c80e9326a8
Clearing the command history works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14812
diff
changeset
|
118 |
61c80e9326a8
Clearing the command history works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14812
diff
changeset
|
119 void |
15368
36ececf69385
avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents:
15367
diff
changeset
|
120 history_dock_widget::closeEvent (QCloseEvent *e) |
13577
e440b3f32f02
Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13549
diff
changeset
|
121 { |
14712
5cb54cca8a06
Completion of code reformatting.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14709
diff
changeset
|
122 emit active_changed (false); |
15368
36ececf69385
avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents:
15367
diff
changeset
|
123 QDockWidget::closeEvent (e); |
13577
e440b3f32f02
Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13549
diff
changeset
|
124 } |
15402
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
125 |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
126 void |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
127 history_dock_widget::update_history_callback (void) |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
128 { |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
129 static bool scroll_window = false; |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
130 |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
131 // Determine the client's (our) history length and the one of the server. |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
132 int clientHistoryLength = _history_model->rowCount (); |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
133 int serverHistoryLength = command_history::length (); |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
134 |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
135 // If were behind the server, iterate through all new entries and add |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
136 // them to our history. |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
137 if (clientHistoryLength < serverHistoryLength) |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
138 { |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
139 int elts_to_add = serverHistoryLength - clientHistoryLength; |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
140 |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
141 _history_model->insertRows (clientHistoryLength, elts_to_add); |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
142 |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
143 for (int i = clientHistoryLength; i < serverHistoryLength; i++) |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
144 { |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
145 std::string entry = command_history::get_entry (i); |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
146 |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
147 _history_model->setData (_history_model->index (i), |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
148 QString::fromStdString (entry)); |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
149 } |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
150 |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
151 // FIXME -- does this behavior make sense? Calling |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
152 // _history_list_view->scrollToBottom () here doesn't seem to |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
153 // have any effect. Instead, we need to request that action |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
154 // and wait until the next event occurs in which no items |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
155 // are added to the history list. |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
156 |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
157 scroll_window = true; |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
158 } |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
159 else if (scroll_window) |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
160 { |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
161 scroll_window = false; |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
162 |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
163 _history_list_view->scrollToBottom (); |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
164 } |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
165 |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
166 // Post a new update event in a given time. This prevents flooding the |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
167 // event queue. |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
168 _update_history_model_timer.start (); |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
169 } |