annotate libgui/src/history-dockwidget.h @ 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 501a9cc2c68f
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 */
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
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
26 #include <QDockWidget>
13545
ffc2e1d1ad5f History can be filtered with an input search box while typing.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13536
diff changeset
27 #include <QLineEdit>
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
28 #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
29 #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
30 #include <QStringListModel>
cecc7da96e2a Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14712
diff changeset
31 #include <QTimer>
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
32
14720
cecc7da96e2a Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14712
diff changeset
33 #include "octave-link.h"
cecc7da96e2a Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14712
diff changeset
34 #include "octave-event-observer.h"
cecc7da96e2a Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14712
diff changeset
35
cecc7da96e2a Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14712
diff changeset
36 class history_dock_widget : public QDockWidget, public octave_event_observer
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
37 {
15367
501a9cc2c68f maint: whitespace cleanup in GUI code
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15300
diff changeset
38 Q_OBJECT
501a9cc2c68f maint: whitespace cleanup in GUI code
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15300
diff changeset
39 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
40 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
41
15388
24b5348d38e7 merge event_accepted and event_reject into a single function
John W. Eaton <jwe@octave.org>
parents: 15367
diff changeset
42 void handle_event (octave_event *e, bool accept);
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
43
13536
869c62c15e95 Few minor improvements, added advanced settings for file browser.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13518
diff changeset
44 public slots:
14712
5cb54cca8a06 Completion of code reformatting.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14709
diff changeset
45 void handle_visibility_changed (bool visible);
14720
cecc7da96e2a Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14712
diff changeset
46 void request_history_model_update ();
14814
61c80e9326a8 Clearing the command history works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14720
diff changeset
47 void reset_model ();
13546
5ef33f99a078 Command get inserted by double clicking in the command history again.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13545
diff changeset
48
13517
86adc9c4ec4b History deactivated.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13506
diff changeset
49 signals:
15300
fd27e10b9b05 pass QString by const reference instead of value
John W. Eaton <jwe@octave.org>
parents: 15204
diff changeset
50 void information (const QString& message);
14863
3ff18e21c742 Added a few comments.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14814
diff changeset
51
3ff18e21c742 Added a few comments.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14814
diff changeset
52 /** 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
53 void command_double_clicked (const QString& command);
14863
3ff18e21c742 Added a few comments.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14814
diff changeset
54
13677
f27573828e92 Properly implemented shutdown of callback thread.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13674
diff changeset
55 /** Custom signal that tells if a user has clicked away that dock widget. */
14712
5cb54cca8a06 Completion of code reformatting.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14709
diff changeset
56 void active_changed (bool active);
13577
e440b3f32f02 Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13547
diff changeset
57 protected:
e440b3f32f02 Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13547
diff changeset
58 void closeEvent (QCloseEvent *event);
13546
5ef33f99a078 Command get inserted by double clicking in the command history again.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13545
diff changeset
59 private slots:
14712
5cb54cca8a06 Completion of code reformatting.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14709
diff changeset
60 void handle_double_click (QModelIndex modelIndex);
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
61
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
62 private:
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
63 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
64 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
65 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
66 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
67
cecc7da96e2a Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14712
diff changeset
68 /** 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
69 QStringListModel *_history_model;
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 QTimer _update_history_model_timer;
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
72 };
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
73
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
74 #endif // HISTORYDOCKWIDGET_H