annotate libgui/src/history-dockwidget.cc @ 15388:24b5348d38e7

merge event_accepted and event_reject into a single function * history-dockwidget.cc, history-dockwidget.h (history_dock_widget::handle_event): New function from merging history_dock_widget::event_accepted and history_dock_widget::event_reject into single fucntion with argument. * file-editor-tab.cc, file-editor-tab.h (file_editor_tab::handle_event): Likewise. * main-window.cc, main-window.h (main_window::handle_event): Likewise. * octave-event-observer.h (octave_event_observer::handle_event): New pure virtual function. (octave_event_observer::event_accepted, octave_event_observer::event_reject): Delete. * octave_link.cc, octave-link.h (octave_link::handle_event): Likewise. * workspace-model.cc, workspace-model.h (workspace_model::handle_event): Likewise. * octave-link.cc (octave_link::do_process_events): Call octave_event::handle_event with the return value from octave_event::perform instead of calling octave_event::accept and octave_event::reject. * octave-event.h (octave_event:handle_event): New function. (octave_event::accept, octave_event::reject): Delete.
author John W. Eaton <jwe@octave.org>
date Fri, 14 Sep 2012 11:14:27 -0400
parents f9ee3befcd6b
children 7f423c6111c6
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 */
13495
11e03a76d8c0 Added source files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
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
9e62d5a3a45e partial cleanup of include files in gui sources
John W. Eaton <jwe@octave.org>
parents: 14814
diff changeset
29 #include "cmd-hist.h"
9e62d5a3a45e partial cleanup of include files in gui sources
John W. Eaton <jwe@octave.org>
parents: 14814
diff changeset
30
15340
9d0cdd49054b keep history in gui widget at bottom when new items are added
John W. Eaton <jwe@octave.org>
parents: 15318
diff changeset
31 #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
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"
13495
11e03a76d8c0 Added source files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
34
15368
36ececf69385 avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents: 15367
diff changeset
35 history_dock_widget::history_dock_widget (QWidget * p)
36ececf69385 avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents: 15367
diff changeset
36 : QDockWidget (p), octave_event_observer ()
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
37 {
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
38 setObjectName ("HistoryDockWidget");
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
39 construct ();
13495
11e03a76d8c0 Added source files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
40 }
11e03a76d8c0 Added source files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
41
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
42 void
15388
24b5348d38e7 merge event_accepted and event_reject into a single function
John W. Eaton <jwe@octave.org>
parents: 15387
diff changeset
43 history_dock_widget::handle_event (octave_event *e, bool accept)
14720
cecc7da96e2a Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14712
diff changeset
44 {
15340
9d0cdd49054b keep history in gui widget at bottom when new items are added
John W. Eaton <jwe@octave.org>
parents: 15318
diff changeset
45 static bool scroll_window = false;
9d0cdd49054b keep history in gui widget at bottom when new items are added
John W. Eaton <jwe@octave.org>
parents: 15318
diff changeset
46
15388
24b5348d38e7 merge event_accepted and event_reject into a single function
John W. Eaton <jwe@octave.org>
parents: 15387
diff changeset
47 if (accept)
14720
cecc7da96e2a Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14712
diff changeset
48 {
15388
24b5348d38e7 merge event_accepted and event_reject into a single function
John W. Eaton <jwe@octave.org>
parents: 15387
diff changeset
49 if (dynamic_cast <octave_update_history_event*> (e))
14720
cecc7da96e2a Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14712
diff changeset
50 {
15388
24b5348d38e7 merge event_accepted and event_reject into a single function
John W. Eaton <jwe@octave.org>
parents: 15387
diff changeset
51 // Determine the client's (our) history length and the one of the server.
24b5348d38e7 merge event_accepted and event_reject into a single function
John W. Eaton <jwe@octave.org>
parents: 15387
diff changeset
52 int clientHistoryLength = _history_model->rowCount ();
24b5348d38e7 merge event_accepted and event_reject into a single function
John W. Eaton <jwe@octave.org>
parents: 15387
diff changeset
53 int serverHistoryLength = command_history::length ();
15315
35fe4b9909a8 keep history in gui widget in chronological order, top to bottom
John W. Eaton <jwe@octave.org>
parents: 15204
diff changeset
54
15388
24b5348d38e7 merge event_accepted and event_reject into a single function
John W. Eaton <jwe@octave.org>
parents: 15387
diff changeset
55 // If were behind the server, iterate through all new entries and add
24b5348d38e7 merge event_accepted and event_reject into a single function
John W. Eaton <jwe@octave.org>
parents: 15387
diff changeset
56 // them to our history.
24b5348d38e7 merge event_accepted and event_reject into a single function
John W. Eaton <jwe@octave.org>
parents: 15387
diff changeset
57 if (clientHistoryLength < serverHistoryLength)
14720
cecc7da96e2a Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14712
diff changeset
58 {
15388
24b5348d38e7 merge event_accepted and event_reject into a single function
John W. Eaton <jwe@octave.org>
parents: 15387
diff changeset
59 int elts_to_add = serverHistoryLength - clientHistoryLength;
24b5348d38e7 merge event_accepted and event_reject into a single function
John W. Eaton <jwe@octave.org>
parents: 15387
diff changeset
60
24b5348d38e7 merge event_accepted and event_reject into a single function
John W. Eaton <jwe@octave.org>
parents: 15387
diff changeset
61 _history_model->insertRows (clientHistoryLength, elts_to_add);
15315
35fe4b9909a8 keep history in gui widget in chronological order, top to bottom
John W. Eaton <jwe@octave.org>
parents: 15204
diff changeset
62
15388
24b5348d38e7 merge event_accepted and event_reject into a single function
John W. Eaton <jwe@octave.org>
parents: 15387
diff changeset
63 for (int i = clientHistoryLength; i < serverHistoryLength; i++)
24b5348d38e7 merge event_accepted and event_reject into a single function
John W. Eaton <jwe@octave.org>
parents: 15387
diff changeset
64 {
24b5348d38e7 merge event_accepted and event_reject into a single function
John W. Eaton <jwe@octave.org>
parents: 15387
diff changeset
65 std::string entry = command_history::get_entry (i);
24b5348d38e7 merge event_accepted and event_reject into a single function
John W. Eaton <jwe@octave.org>
parents: 15387
diff changeset
66
24b5348d38e7 merge event_accepted and event_reject into a single function
John W. Eaton <jwe@octave.org>
parents: 15387
diff changeset
67 _history_model->setData (_history_model->index (i),
24b5348d38e7 merge event_accepted and event_reject into a single function
John W. Eaton <jwe@octave.org>
parents: 15387
diff changeset
68 QString::fromStdString (entry));
24b5348d38e7 merge event_accepted and event_reject into a single function
John W. Eaton <jwe@octave.org>
parents: 15387
diff changeset
69 }
15340
9d0cdd49054b keep history in gui widget at bottom when new items are added
John W. Eaton <jwe@octave.org>
parents: 15318
diff changeset
70
15388
24b5348d38e7 merge event_accepted and event_reject into a single function
John W. Eaton <jwe@octave.org>
parents: 15387
diff changeset
71 // FIXME -- does this behavior make sense? Calling
24b5348d38e7 merge event_accepted and event_reject into a single function
John W. Eaton <jwe@octave.org>
parents: 15387
diff changeset
72 // _history_list_view->scrollToBottom () here doesn't seem to
24b5348d38e7 merge event_accepted and event_reject into a single function
John W. Eaton <jwe@octave.org>
parents: 15387
diff changeset
73 // have any effect. Instead, we need to request that action
24b5348d38e7 merge event_accepted and event_reject into a single function
John W. Eaton <jwe@octave.org>
parents: 15387
diff changeset
74 // and wait until the next event occurs in which no items
24b5348d38e7 merge event_accepted and event_reject into a single function
John W. Eaton <jwe@octave.org>
parents: 15387
diff changeset
75 // are added to the history list.
15315
35fe4b9909a8 keep history in gui widget in chronological order, top to bottom
John W. Eaton <jwe@octave.org>
parents: 15204
diff changeset
76
15388
24b5348d38e7 merge event_accepted and event_reject into a single function
John W. Eaton <jwe@octave.org>
parents: 15387
diff changeset
77 scroll_window = true;
24b5348d38e7 merge event_accepted and event_reject into a single function
John W. Eaton <jwe@octave.org>
parents: 15387
diff changeset
78 }
24b5348d38e7 merge event_accepted and event_reject into a single function
John W. Eaton <jwe@octave.org>
parents: 15387
diff changeset
79 else if (scroll_window)
24b5348d38e7 merge event_accepted and event_reject into a single function
John W. Eaton <jwe@octave.org>
parents: 15387
diff changeset
80 {
24b5348d38e7 merge event_accepted and event_reject into a single function
John W. Eaton <jwe@octave.org>
parents: 15387
diff changeset
81 scroll_window = false;
15340
9d0cdd49054b keep history in gui widget at bottom when new items are added
John W. Eaton <jwe@octave.org>
parents: 15318
diff changeset
82
15388
24b5348d38e7 merge event_accepted and event_reject into a single function
John W. Eaton <jwe@octave.org>
parents: 15387
diff changeset
83 _history_list_view->scrollToBottom ();
24b5348d38e7 merge event_accepted and event_reject into a single function
John W. Eaton <jwe@octave.org>
parents: 15387
diff changeset
84 }
15340
9d0cdd49054b keep history in gui widget at bottom when new items are added
John W. Eaton <jwe@octave.org>
parents: 15318
diff changeset
85 }
14720
cecc7da96e2a Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14712
diff changeset
86
15388
24b5348d38e7 merge event_accepted and event_reject into a single function
John W. Eaton <jwe@octave.org>
parents: 15387
diff changeset
87 // Post a new update event in a given time. This prevents flooding the
24b5348d38e7 merge event_accepted and event_reject into a single function
John W. Eaton <jwe@octave.org>
parents: 15387
diff changeset
88 // event queue.
24b5348d38e7 merge event_accepted and event_reject into a single function
John W. Eaton <jwe@octave.org>
parents: 15387
diff changeset
89 _update_history_model_timer.start ();
24b5348d38e7 merge event_accepted and event_reject into a single function
John W. Eaton <jwe@octave.org>
parents: 15387
diff changeset
90 }
24b5348d38e7 merge event_accepted and event_reject into a single function
John W. Eaton <jwe@octave.org>
parents: 15387
diff changeset
91 else
24b5348d38e7 merge event_accepted and event_reject into a single function
John W. Eaton <jwe@octave.org>
parents: 15387
diff changeset
92 {
24b5348d38e7 merge event_accepted and event_reject into a single function
John W. Eaton <jwe@octave.org>
parents: 15387
diff changeset
93 // octave_event::perform failed to handle event.
24b5348d38e7 merge event_accepted and event_reject into a single function
John W. Eaton <jwe@octave.org>
parents: 15387
diff changeset
94 }
14720
cecc7da96e2a Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14712
diff changeset
95 }
cecc7da96e2a Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14712
diff changeset
96
cecc7da96e2a Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14712
diff changeset
97 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
98 history_dock_widget::construct ()
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
99 {
14720
cecc7da96e2a Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14712
diff changeset
100 _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
101 _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
102 _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
103 _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
104 _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
105 _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
106 _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
107 _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
108 _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
109 QVBoxLayout *vbox_layout = new QVBoxLayout ();
13495
11e03a76d8c0 Added source files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
110
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
111 setWindowTitle (tr ("Command History"));
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
112 setWidget (new QWidget ());
13495
11e03a76d8c0 Added source files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
113
15368
36ececf69385 avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents: 15367
diff changeset
114 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
115 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
116 vbox_layout->setMargin (2);
13495
11e03a76d8c0 Added source files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
117
15368
36ececf69385 avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents: 15367
diff changeset
118 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
119
14720
cecc7da96e2a Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14712
diff changeset
120 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
121 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
122 &_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
123 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
124
cecc7da96e2a Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14712
diff changeset
125 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
126 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
127 this,
cecc7da96e2a Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14712
diff changeset
128 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
129
cecc7da96e2a Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14712
diff changeset
130 connect (this,
cecc7da96e2a Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14712
diff changeset
131 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
132 this,
cecc7da96e2a Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14712
diff changeset
133 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
134
cecc7da96e2a Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14712
diff changeset
135 _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
136 _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
137
cecc7da96e2a Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14712
diff changeset
138 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
139 SIGNAL (timeout ()),
cecc7da96e2a Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14712
diff changeset
140 this,
cecc7da96e2a Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14712
diff changeset
141 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
142
cecc7da96e2a Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14712
diff changeset
143 _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
144
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
145 setFocusProxy (_filter_line_edit);
13495
11e03a76d8c0 Added source files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
146 }
13536
869c62c15e95 Few minor improvements, added advanced settings for file browser.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13518
diff changeset
147
869c62c15e95 Few minor improvements, added advanced settings for file browser.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13518
diff changeset
148 void
14712
5cb54cca8a06 Completion of code reformatting.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14709
diff changeset
149 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
150 {
14712
5cb54cca8a06 Completion of code reformatting.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14709
diff changeset
151 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
152 }
13577
e440b3f32f02 Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13549
diff changeset
153
e440b3f32f02 Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13549
diff changeset
154 void
14712
5cb54cca8a06 Completion of code reformatting.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14709
diff changeset
155 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
156 {
e440b3f32f02 Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13549
diff changeset
157 if (visible)
14712
5cb54cca8a06 Completion of code reformatting.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14709
diff changeset
158 emit active_changed (true);
13577
e440b3f32f02 Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13549
diff changeset
159 }
e440b3f32f02 Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13549
diff changeset
160
e440b3f32f02 Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13549
diff changeset
161 void
14720
cecc7da96e2a Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14712
diff changeset
162 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
163 {
15371
eec0d1fcba4f use Octave singleton style for octave_link class
John W. Eaton <jwe@octave.org>
parents: 15368
diff changeset
164 octave_link::post_event (new octave_update_history_event (*this));
14720
cecc7da96e2a Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14712
diff changeset
165 }
cecc7da96e2a Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14712
diff changeset
166
cecc7da96e2a Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14712
diff changeset
167 void
14814
61c80e9326a8 Clearing the command history works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14812
diff changeset
168 history_dock_widget::reset_model ()
61c80e9326a8 Clearing the command history works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14812
diff changeset
169 {
61c80e9326a8 Clearing the command history works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14812
diff changeset
170 _history_model->setStringList (QStringList ());
61c80e9326a8 Clearing the command history works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14812
diff changeset
171 }
61c80e9326a8 Clearing the command history works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14812
diff changeset
172
61c80e9326a8 Clearing the command history works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14812
diff changeset
173 void
15368
36ececf69385 avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents: 15367
diff changeset
174 history_dock_widget::closeEvent (QCloseEvent *e)
13577
e440b3f32f02 Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13549
diff changeset
175 {
14712
5cb54cca8a06 Completion of code reformatting.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14709
diff changeset
176 emit active_changed (false);
15368
36ececf69385 avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents: 15367
diff changeset
177 QDockWidget::closeEvent (e);
13577
e440b3f32f02 Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13549
diff changeset
178 }