Mercurial > octave-nkf
annotate libgui/src/history-dockwidget.cc @ 15447:352349219529
Added multiline copy and execution to command history in IDE (bug #36884)
* history-dockwidget.cc (history_dock_widget::ctxMenu) : New function.
(history_dock_widget::handle_contextmenu_copy) : New function.
(history_dock_widget::handle_contextmenu_evaluate) : New function.
(history_dock_widget::history_dock_widget) : Connected popup menu to QListView.
(history_dock_widget::handle_double_click) : Append <CR> to selected history to actually execute the command.
author | John Swensen <jpswensen@gmail.com> |
---|---|
date | Thu, 27 Sep 2012 13:24:59 -0400 |
parents | 7f423c6111c6 |
children | bbbb89cc338f |
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 |
15447
352349219529
Added multiline copy and execution to command history in IDE (bug #36884)
John Swensen <jpswensen@gmail.com>
parents:
15402
diff
changeset
|
27 #include <QApplication> |
352349219529
Added multiline copy and execution to command history in IDE (bug #36884)
John Swensen <jpswensen@gmail.com>
parents:
15402
diff
changeset
|
28 #include <QClipboard> |
15155
9e62d5a3a45e
partial cleanup of include files in gui sources
John W. Eaton <jwe@octave.org>
parents:
14814
diff
changeset
|
29 #include <QVBoxLayout> |
15447
352349219529
Added multiline copy and execution to command history in IDE (bug #36884)
John Swensen <jpswensen@gmail.com>
parents:
15402
diff
changeset
|
30 #include <QMenu> |
15155
9e62d5a3a45e
partial cleanup of include files in gui sources
John W. Eaton <jwe@octave.org>
parents:
14814
diff
changeset
|
31 |
15340
9d0cdd49054b
keep history in gui widget at bottom when new items are added
John W. Eaton <jwe@octave.org>
parents:
15318
diff
changeset
|
32 #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
|
33 |
15402
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
34 #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
|
35 |
14707
674740c44c09
Changed various files to matche file naming conventions.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14703
diff
changeset
|
36 #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
|
37 #include "octave-link.h" |
13495 | 38 |
15368
36ececf69385
avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents:
15367
diff
changeset
|
39 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
|
40 : QDockWidget (p) |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
41 { |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
42 setObjectName ("HistoryDockWidget"); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
43 construct (); |
13495 | 44 } |
45 | |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
46 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
|
47 history_dock_widget::construct () |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
48 { |
14720
cecc7da96e2a
Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
49 _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
|
50 _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
|
51 _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
|
52 _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
|
53 _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
|
54 _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
|
55 _history_list_view->setStatusTip (tr ("Doubleclick a command to transfer it to the terminal.")); |
15447
352349219529
Added multiline copy and execution to command history in IDE (bug #36884)
John Swensen <jpswensen@gmail.com>
parents:
15402
diff
changeset
|
56 _history_list_view->setSelectionMode (QAbstractItemView::ExtendedSelection); |
352349219529
Added multiline copy and execution to command history in IDE (bug #36884)
John Swensen <jpswensen@gmail.com>
parents:
15402
diff
changeset
|
57 _history_list_view->setContextMenuPolicy(Qt::CustomContextMenu); |
352349219529
Added multiline copy and execution to command history in IDE (bug #36884)
John Swensen <jpswensen@gmail.com>
parents:
15402
diff
changeset
|
58 connect(_history_list_view, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(ctxMenu(const QPoint &))); |
352349219529
Added multiline copy and execution to command history in IDE (bug #36884)
John Swensen <jpswensen@gmail.com>
parents:
15402
diff
changeset
|
59 |
14720
cecc7da96e2a
Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
60 _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
|
61 _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
|
62 QVBoxLayout *vbox_layout = new QVBoxLayout (); |
13495 | 63 |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
64 setWindowTitle (tr ("Command History")); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
65 setWidget (new QWidget ()); |
13495 | 66 |
15368
36ececf69385
avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents:
15367
diff
changeset
|
67 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
|
68 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
|
69 vbox_layout->setMargin (2); |
13495 | 70 |
15368
36ececf69385
avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents:
15367
diff
changeset
|
71 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
|
72 |
14720
cecc7da96e2a
Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
73 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
|
74 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
|
75 &_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
|
76 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
|
77 |
cecc7da96e2a
Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
78 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
|
79 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
|
80 this, |
cecc7da96e2a
Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
81 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
|
82 |
cecc7da96e2a
Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
83 connect (this, |
cecc7da96e2a
Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
84 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
|
85 this, |
cecc7da96e2a
Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
86 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
|
87 |
cecc7da96e2a
Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
88 _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
|
89 _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
|
90 |
cecc7da96e2a
Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
91 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
|
92 SIGNAL (timeout ()), |
cecc7da96e2a
Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
93 this, |
cecc7da96e2a
Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
94 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
|
95 |
cecc7da96e2a
Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
96 _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
|
97 |
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
|
98 setFocusProxy (_filter_line_edit); |
13495 | 99 } |
13536
869c62c15e95
Few minor improvements, added advanced settings for file browser.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13518
diff
changeset
|
100 |
15447
352349219529
Added multiline copy and execution to command history in IDE (bug #36884)
John Swensen <jpswensen@gmail.com>
parents:
15402
diff
changeset
|
101 void history_dock_widget::ctxMenu(const QPoint &pos) { |
352349219529
Added multiline copy and execution to command history in IDE (bug #36884)
John Swensen <jpswensen@gmail.com>
parents:
15402
diff
changeset
|
102 QMenu *menu = new QMenu; |
352349219529
Added multiline copy and execution to command history in IDE (bug #36884)
John Swensen <jpswensen@gmail.com>
parents:
15402
diff
changeset
|
103 menu->addAction(tr("Copy"), this, SLOT(handle_contextmenu_copy(bool))); |
352349219529
Added multiline copy and execution to command history in IDE (bug #36884)
John Swensen <jpswensen@gmail.com>
parents:
15402
diff
changeset
|
104 menu->addAction(tr("Evaluate"), this, SLOT(handle_contextmenu_evaluate(bool))); |
352349219529
Added multiline copy and execution to command history in IDE (bug #36884)
John Swensen <jpswensen@gmail.com>
parents:
15402
diff
changeset
|
105 menu->exec(_history_list_view->mapToGlobal(pos)); |
352349219529
Added multiline copy and execution to command history in IDE (bug #36884)
John Swensen <jpswensen@gmail.com>
parents:
15402
diff
changeset
|
106 } |
352349219529
Added multiline copy and execution to command history in IDE (bug #36884)
John Swensen <jpswensen@gmail.com>
parents:
15402
diff
changeset
|
107 |
352349219529
Added multiline copy and execution to command history in IDE (bug #36884)
John Swensen <jpswensen@gmail.com>
parents:
15402
diff
changeset
|
108 void history_dock_widget::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
|
109 { |
352349219529
Added multiline copy and execution to command history in IDE (bug #36884)
John Swensen <jpswensen@gmail.com>
parents:
15402
diff
changeset
|
110 QString text; |
352349219529
Added multiline copy and execution to command history in IDE (bug #36884)
John Swensen <jpswensen@gmail.com>
parents:
15402
diff
changeset
|
111 QItemSelectionModel *selectionModel = _history_list_view->selectionModel(); |
352349219529
Added multiline copy and execution to command history in IDE (bug #36884)
John Swensen <jpswensen@gmail.com>
parents:
15402
diff
changeset
|
112 QModelIndexList rows = selectionModel->selectedRows(); |
352349219529
Added multiline copy and execution to command history in IDE (bug #36884)
John Swensen <jpswensen@gmail.com>
parents:
15402
diff
changeset
|
113 QModelIndexList::iterator it; |
352349219529
Added multiline copy and execution to command history in IDE (bug #36884)
John Swensen <jpswensen@gmail.com>
parents:
15402
diff
changeset
|
114 for (it=rows.begin() ; it != rows.end(); it++) { |
352349219529
Added multiline copy and execution to command history in IDE (bug #36884)
John Swensen <jpswensen@gmail.com>
parents:
15402
diff
changeset
|
115 if ((*it).isValid()) { |
352349219529
Added multiline copy and execution to command history in IDE (bug #36884)
John Swensen <jpswensen@gmail.com>
parents:
15402
diff
changeset
|
116 text += (*it).data().toString()+"\n"; |
352349219529
Added multiline copy and execution to command history in IDE (bug #36884)
John Swensen <jpswensen@gmail.com>
parents:
15402
diff
changeset
|
117 } |
352349219529
Added multiline copy and execution to command history in IDE (bug #36884)
John Swensen <jpswensen@gmail.com>
parents:
15402
diff
changeset
|
118 } |
352349219529
Added multiline copy and execution to command history in IDE (bug #36884)
John Swensen <jpswensen@gmail.com>
parents:
15402
diff
changeset
|
119 QApplication::clipboard()->setText(text); |
352349219529
Added multiline copy and execution to command history in IDE (bug #36884)
John Swensen <jpswensen@gmail.com>
parents:
15402
diff
changeset
|
120 } |
352349219529
Added multiline copy and execution to command history in IDE (bug #36884)
John Swensen <jpswensen@gmail.com>
parents:
15402
diff
changeset
|
121 |
352349219529
Added multiline copy and execution to command history in IDE (bug #36884)
John Swensen <jpswensen@gmail.com>
parents:
15402
diff
changeset
|
122 void history_dock_widget::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
|
123 { |
352349219529
Added multiline copy and execution to command history in IDE (bug #36884)
John Swensen <jpswensen@gmail.com>
parents:
15402
diff
changeset
|
124 QItemSelectionModel *selectionModel = _history_list_view->selectionModel(); |
352349219529
Added multiline copy and execution to command history in IDE (bug #36884)
John Swensen <jpswensen@gmail.com>
parents:
15402
diff
changeset
|
125 QModelIndexList rows = selectionModel->selectedRows(); |
352349219529
Added multiline copy and execution to command history in IDE (bug #36884)
John Swensen <jpswensen@gmail.com>
parents:
15402
diff
changeset
|
126 QModelIndexList::iterator it; |
352349219529
Added multiline copy and execution to command history in IDE (bug #36884)
John Swensen <jpswensen@gmail.com>
parents:
15402
diff
changeset
|
127 for (it=rows.begin() ; it != rows.end(); it++) { |
352349219529
Added multiline copy and execution to command history in IDE (bug #36884)
John Swensen <jpswensen@gmail.com>
parents:
15402
diff
changeset
|
128 if ((*it).isValid()) { |
352349219529
Added multiline copy and execution to command history in IDE (bug #36884)
John Swensen <jpswensen@gmail.com>
parents:
15402
diff
changeset
|
129 emit command_double_clicked ((*it).data().toString()+"\n"); |
352349219529
Added multiline copy and execution to command history in IDE (bug #36884)
John Swensen <jpswensen@gmail.com>
parents:
15402
diff
changeset
|
130 } |
352349219529
Added multiline copy and execution to command history in IDE (bug #36884)
John Swensen <jpswensen@gmail.com>
parents:
15402
diff
changeset
|
131 } |
352349219529
Added multiline copy and execution to command history in IDE (bug #36884)
John Swensen <jpswensen@gmail.com>
parents:
15402
diff
changeset
|
132 } |
352349219529
Added multiline copy and execution to command history in IDE (bug #36884)
John Swensen <jpswensen@gmail.com>
parents:
15402
diff
changeset
|
133 |
13536
869c62c15e95
Few minor improvements, added advanced settings for file browser.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13518
diff
changeset
|
134 void |
14712
5cb54cca8a06
Completion of code reformatting.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14709
diff
changeset
|
135 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
|
136 { |
15447
352349219529
Added multiline copy and execution to command history in IDE (bug #36884)
John Swensen <jpswensen@gmail.com>
parents:
15402
diff
changeset
|
137 emit command_double_clicked (modelIndex.data().toString()+"\n"); |
13546
5ef33f99a078
Command get inserted by double clicking in the command history again.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13545
diff
changeset
|
138 } |
13577
e440b3f32f02
Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13549
diff
changeset
|
139 |
e440b3f32f02
Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13549
diff
changeset
|
140 void |
14712
5cb54cca8a06
Completion of code reformatting.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14709
diff
changeset
|
141 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
|
142 { |
e440b3f32f02
Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13549
diff
changeset
|
143 if (visible) |
14712
5cb54cca8a06
Completion of code reformatting.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14709
diff
changeset
|
144 emit active_changed (true); |
13577
e440b3f32f02
Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13549
diff
changeset
|
145 } |
e440b3f32f02
Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13549
diff
changeset
|
146 |
e440b3f32f02
Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13549
diff
changeset
|
147 void |
14720
cecc7da96e2a
Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
148 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
|
149 { |
15402
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
150 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
|
151 } |
cecc7da96e2a
Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
152 |
cecc7da96e2a
Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
153 void |
14814
61c80e9326a8
Clearing the command history works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14812
diff
changeset
|
154 history_dock_widget::reset_model () |
61c80e9326a8
Clearing the command history works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14812
diff
changeset
|
155 { |
61c80e9326a8
Clearing the command history works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14812
diff
changeset
|
156 _history_model->setStringList (QStringList ()); |
61c80e9326a8
Clearing the command history works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14812
diff
changeset
|
157 } |
61c80e9326a8
Clearing the command history works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14812
diff
changeset
|
158 |
61c80e9326a8
Clearing the command history works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14812
diff
changeset
|
159 void |
15368
36ececf69385
avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents:
15367
diff
changeset
|
160 history_dock_widget::closeEvent (QCloseEvent *e) |
13577
e440b3f32f02
Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13549
diff
changeset
|
161 { |
14712
5cb54cca8a06
Completion of code reformatting.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14709
diff
changeset
|
162 emit active_changed (false); |
15368
36ececf69385
avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents:
15367
diff
changeset
|
163 QDockWidget::closeEvent (e); |
13577
e440b3f32f02
Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13549
diff
changeset
|
164 } |
15402
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 void |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
167 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
|
168 { |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
169 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
|
170 |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
171 // 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
|
172 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
|
173 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
|
174 |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
175 // 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
|
176 // 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
|
177 if (clientHistoryLength < serverHistoryLength) |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
178 { |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
179 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
|
180 |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
181 _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
|
182 |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
183 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
|
184 { |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
185 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
|
186 |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
187 _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
|
188 QString::fromStdString (entry)); |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
189 } |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
190 |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
191 // 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
|
192 // _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
|
193 // 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
|
194 // 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
|
195 // 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
|
196 |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
197 scroll_window = true; |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
198 } |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
199 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
|
200 { |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
201 scroll_window = false; |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
202 |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
203 _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
|
204 } |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
205 |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
206 // 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
|
207 // event queue. |
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
208 _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
|
209 } |