annotate libgui/src/history-dock-widget.cc @ 17790:86c6ae5f969e

Use GNU style coding conventions for code in libgui/ * libgui/qterminal/libqterminal/QTerminal.h, libgui/src/color-picker.cc, libgui/src/color-picker.h, libgui/src/dialog.cc, libgui/src/dialog.h, libgui/src/documentation-dock-widget.cc, libgui/src/files-dock-widget.cc, libgui/src/files-dock-widget.h, libgui/src/find-files-dialog.cc, libgui/src/find-files-dialog.h, libgui/src/find-files-model.cc, libgui/src/find-files-model.h, libgui/src/history-dock-widget.cc, libgui/src/history-dock-widget.h, libgui/src/m-editor/file-editor-interface.h, libgui/src/m-editor/file-editor-tab.cc, libgui/src/m-editor/file-editor-tab.h, libgui/src/m-editor/file-editor.cc, libgui/src/m-editor/find-dialog.cc, libgui/src/m-editor/find-dialog.h, libgui/src/m-editor/octave-qscintilla.cc, libgui/src/main-window.cc, libgui/src/main-window.h, libgui/src/news-dock-widget.h, libgui/src/octave-dock-widget.cc, libgui/src/octave-dock-widget.h, libgui/src/octave-gui.cc, libgui/src/octave-qt-link.cc, libgui/src/octave-qt-link.h, libgui/src/qtinfo/parser.cc, libgui/src/qtinfo/parser.h, libgui/src/qtinfo/webinfo.cc, libgui/src/qtinfo/webinfo.h, libgui/src/resource-manager.cc, libgui/src/settings-dialog.cc, libgui/src/settings-dialog.h, libgui/src/terminal-dock-widget.cc, libgui/src/welcome-wizard.cc, libgui/src/workspace-model.cc, libgui/src/workspace-model.h, libgui/src/workspace-view.cc, libgui/src/workspace-view.h: Use GNU style coding conventions for code in libgui/
author Rik <rik@octave.org>
date Tue, 29 Oct 2013 09:54:40 -0700
parents d63878346099
children 752f6b358754
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
17744
d63878346099 maint: Update copyright notices for release.
John W. Eaton <jwe@octave.org>
parents: 17254
diff changeset
3 Copyright (C) 2011-2013 Jacob Dawid
15204
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
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>
17208
2527bc7200ee Only scroll history window if it is positioned at bottom.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16881
diff changeset
31 #include <QScrollBar>
15155
9e62d5a3a45e partial cleanup of include files in gui sources
John W. Eaton <jwe@octave.org>
parents: 14814
diff changeset
32
15340
9d0cdd49054b keep history in gui widget at bottom when new items are added
John W. Eaton <jwe@octave.org>
parents: 15318
diff changeset
33 #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
34
15402
7f423c6111c6 refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents: 15388
diff changeset
35 #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
36
16460
4d4e7c6f839d use consistent names for dock-widget files
John W. Eaton <jwe@octave.org>
parents: 16455
diff changeset
37 #include "history-dock-widget.h"
13495
11e03a76d8c0 Added source files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
38
16447
e3b33a7530bc improve encapsulation of history window object
John W. Eaton <jwe@octave.org>
parents: 16441
diff changeset
39 history_dock_widget::history_dock_widget (QWidget *p)
16057
c3057d80cf91 Created common octave_dock_widget class
Richard Crozier <richard.crozier@yahoo.co.uk>
parents: 15900
diff changeset
40 : octave_dock_widget (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");
16447
e3b33a7530bc improve encapsulation of history window object
John W. Eaton <jwe@octave.org>
parents: 16441
diff changeset
43 setStatusTip (tr ("Browse and search the command history."));
e3b33a7530bc improve encapsulation of history window object
John W. Eaton <jwe@octave.org>
parents: 16441
diff changeset
44
16455
38ed6bdd1f7f move signal/slot connections from main window to sub window where possible
John W. Eaton <jwe@octave.org>
parents: 16452
diff changeset
45 connect (this, SIGNAL (command_create_script (const QString&)),
38ed6bdd1f7f move signal/slot connections from main window to sub window where possible
John W. Eaton <jwe@octave.org>
parents: 16452
diff changeset
46 p, SLOT (new_file (const QString&)));
38ed6bdd1f7f move signal/slot connections from main window to sub window where possible
John W. Eaton <jwe@octave.org>
parents: 16452
diff changeset
47
38ed6bdd1f7f move signal/slot connections from main window to sub window where possible
John W. Eaton <jwe@octave.org>
parents: 16452
diff changeset
48 connect (this, SIGNAL (information (const QString&)),
38ed6bdd1f7f move signal/slot connections from main window to sub window where possible
John W. Eaton <jwe@octave.org>
parents: 16452
diff changeset
49 p, SLOT (report_status_message (const QString&)));
16447
e3b33a7530bc improve encapsulation of history window object
John W. Eaton <jwe@octave.org>
parents: 16441
diff changeset
50
e3b33a7530bc improve encapsulation of history window object
John W. Eaton <jwe@octave.org>
parents: 16441
diff changeset
51 connect (this, SIGNAL (command_double_clicked (const QString&)),
16570
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16461
diff changeset
52 p, SLOT (execute_command_in_terminal (const QString&)));
16447
e3b33a7530bc improve encapsulation of history window object
John W. Eaton <jwe@octave.org>
parents: 16441
diff changeset
53
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
54 construct ();
13495
11e03a76d8c0 Added source files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
55 }
11e03a76d8c0 Added source files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
56
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
57 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
58 history_dock_widget::construct ()
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
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 _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
61 _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
62 _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
63 _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
64 _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
65 _history_list_view->setEditTriggers (QAbstractItemView::NoEditTriggers);
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
66 _history_list_view->setStatusTip (
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
67 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
68 _history_list_view->setSelectionMode (QAbstractItemView::ExtendedSelection);
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
69 _history_list_view->setContextMenuPolicy (Qt::CustomContextMenu);
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
70 connect (_history_list_view,
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
71 SIGNAL (customContextMenuRequested (const QPoint &)), this,
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
72 SLOT (ctxMenu (const QPoint &)));
15447
352349219529 Added multiline copy and execution to command history in IDE (bug #36884)
John Swensen <jpswensen@gmail.com>
parents: 15402
diff changeset
73
14720
cecc7da96e2a Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14712
diff changeset
74 _filter_line_edit = new QLineEdit (this);
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
75 _filter_line_edit->setStatusTip (
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
76 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
77 QVBoxLayout *vbox_layout = new QVBoxLayout ();
13495
11e03a76d8c0 Added source files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
78
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
79 setWindowIcon (QIcon (":/actions/icons/logo.png"));
16798
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents: 16570
diff changeset
80 set_title (tr ("Command History"));
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
81 setWidget (new QWidget ());
13495
11e03a76d8c0 Added source files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
82
15368
36ececf69385 avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents: 15367
diff changeset
83 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
84 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
85 vbox_layout->setMargin (2);
13495
11e03a76d8c0 Added source files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
86
15368
36ececf69385 avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents: 15367
diff changeset
87 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
88
16057
c3057d80cf91 Created common octave_dock_widget class
Richard Crozier <richard.crozier@yahoo.co.uk>
parents: 15900
diff changeset
89 connect (_filter_line_edit, SIGNAL (textEdited (QString)),
c3057d80cf91 Created common octave_dock_widget class
Richard Crozier <richard.crozier@yahoo.co.uk>
parents: 15900
diff changeset
90 &_sort_filter_proxy_model, SLOT (setFilterWildcard (QString)));
14720
cecc7da96e2a Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14712
diff changeset
91
16057
c3057d80cf91 Created common octave_dock_widget class
Richard Crozier <richard.crozier@yahoo.co.uk>
parents: 15900
diff changeset
92 connect (_history_list_view, SIGNAL (doubleClicked (QModelIndex)),
c3057d80cf91 Created common octave_dock_widget class
Richard Crozier <richard.crozier@yahoo.co.uk>
parents: 15900
diff changeset
93 this, SLOT (handle_double_click (QModelIndex)));
15552
bbbb89cc338f make a floating widget behave like a normal window (bug #37190)
Torsten <ttl@justmail.de>
parents: 15447
diff changeset
94
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
95 setFocusProxy (_filter_line_edit);
13495
11e03a76d8c0 Added source files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
96 }
13536
869c62c15e95 Few minor improvements, added advanced settings for file browser.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13518
diff changeset
97
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
98 void history_dock_widget::ctxMenu (const QPoint &xpos)
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
99 {
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
100 QMenu menu (this);
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
101 menu.addAction (tr ("Copy"), this, SLOT (handle_contextmenu_copy (bool)));
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
102 menu.addAction (tr ("Evaluate"), this,
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
103 SLOT (handle_contextmenu_evaluate (bool)));
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
104 menu.addAction (tr ("Create script"), this,
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
105 SLOT (handle_contextmenu_create_script (bool)));
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
106 menu.exec (_history_list_view->mapToGlobal (xpos));
15447
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
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
109 void history_dock_widget::handle_contextmenu_copy (bool)
15447
352349219529 Added multiline copy and execution to command history in IDE (bug #36884)
John Swensen <jpswensen@gmail.com>
parents: 15402
diff changeset
110 {
352349219529 Added multiline copy and execution to command history in IDE (bug #36884)
John Swensen <jpswensen@gmail.com>
parents: 15402
diff changeset
111 QString text;
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
112 QItemSelectionModel *selectionModel = _history_list_view->selectionModel ();
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
113 QModelIndexList rows = selectionModel->selectedRows ();
15447
352349219529 Added multiline copy and execution to command history in IDE (bug #36884)
John Swensen <jpswensen@gmail.com>
parents: 15402
diff changeset
114 QModelIndexList::iterator it;
17254
7fb4461997aa Adjust history window copy/evaluate and remove carriage returns (bug #39722)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 17208
diff changeset
115 bool prev_valid_row = false;
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
116 for (it = rows.begin (); it != rows.end (); it++)
17254
7fb4461997aa Adjust history window copy/evaluate and remove carriage returns (bug #39722)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 17208
diff changeset
117 {
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
118 if ((*it).isValid ())
17254
7fb4461997aa Adjust history window copy/evaluate and remove carriage returns (bug #39722)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 17208
diff changeset
119 {
7fb4461997aa Adjust history window copy/evaluate and remove carriage returns (bug #39722)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 17208
diff changeset
120 if (prev_valid_row)
7fb4461997aa Adjust history window copy/evaluate and remove carriage returns (bug #39722)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 17208
diff changeset
121 text += "\n";
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
122 text += (*it).data ().toString ();
17254
7fb4461997aa Adjust history window copy/evaluate and remove carriage returns (bug #39722)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 17208
diff changeset
123 prev_valid_row = true;
7fb4461997aa Adjust history window copy/evaluate and remove carriage returns (bug #39722)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 17208
diff changeset
124 }
15447
352349219529 Added multiline copy and execution to command history in IDE (bug #36884)
John Swensen <jpswensen@gmail.com>
parents: 15402
diff changeset
125 }
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
126 QApplication::clipboard ()->setText (text);
15447
352349219529 Added multiline copy and execution to command history in IDE (bug #36884)
John Swensen <jpswensen@gmail.com>
parents: 15402
diff changeset
127 }
352349219529 Added multiline copy and execution to command history in IDE (bug #36884)
John Swensen <jpswensen@gmail.com>
parents: 15402
diff changeset
128
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
129 void history_dock_widget::handle_contextmenu_evaluate (bool)
15447
352349219529 Added multiline copy and execution to command history in IDE (bug #36884)
John Swensen <jpswensen@gmail.com>
parents: 15402
diff changeset
130 {
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
131 QItemSelectionModel *selectionModel = _history_list_view->selectionModel ();
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
132 QModelIndexList rows = selectionModel->selectedRows ();
15447
352349219529 Added multiline copy and execution to command history in IDE (bug #36884)
John Swensen <jpswensen@gmail.com>
parents: 15402
diff changeset
133 QModelIndexList::iterator it;
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
134 for (it = rows.begin () ; it != rows.end (); it++)
17254
7fb4461997aa Adjust history window copy/evaluate and remove carriage returns (bug #39722)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 17208
diff changeset
135 {
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
136 if ((*it).isValid ())
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
137 emit command_double_clicked ((*it).data ().toString ());
15447
352349219529 Added multiline copy and execution to command history in IDE (bug #36884)
John Swensen <jpswensen@gmail.com>
parents: 15402
diff changeset
138 }
352349219529 Added multiline copy and execution to command history in IDE (bug #36884)
John Swensen <jpswensen@gmail.com>
parents: 15402
diff changeset
139 }
352349219529 Added multiline copy and execution to command history in IDE (bug #36884)
John Swensen <jpswensen@gmail.com>
parents: 15402
diff changeset
140
13536
869c62c15e95 Few minor improvements, added advanced settings for file browser.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13518
diff changeset
141 void
16452
744ff2fe11ce add create script context menu to history window
John Donoghue <john.donoghue@ieee.org>
parents: 16447
diff changeset
142 history_dock_widget::handle_contextmenu_create_script (bool)
744ff2fe11ce add create script context menu to history window
John Donoghue <john.donoghue@ieee.org>
parents: 16447
diff changeset
143 {
744ff2fe11ce add create script context menu to history window
John Donoghue <john.donoghue@ieee.org>
parents: 16447
diff changeset
144 QString text;
744ff2fe11ce add create script context menu to history window
John Donoghue <john.donoghue@ieee.org>
parents: 16447
diff changeset
145 QItemSelectionModel *selectionModel = _history_list_view->selectionModel ();
744ff2fe11ce add create script context menu to history window
John Donoghue <john.donoghue@ieee.org>
parents: 16447
diff changeset
146 QModelIndexList rows = selectionModel->selectedRows ();
744ff2fe11ce add create script context menu to history window
John Donoghue <john.donoghue@ieee.org>
parents: 16447
diff changeset
147
17254
7fb4461997aa Adjust history window copy/evaluate and remove carriage returns (bug #39722)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 17208
diff changeset
148 bool prev_valid_row = false;
16452
744ff2fe11ce add create script context menu to history window
John Donoghue <john.donoghue@ieee.org>
parents: 16447
diff changeset
149 for (QModelIndexList::iterator it = rows.begin (); it != rows.end (); it++)
744ff2fe11ce add create script context menu to history window
John Donoghue <john.donoghue@ieee.org>
parents: 16447
diff changeset
150 {
744ff2fe11ce add create script context menu to history window
John Donoghue <john.donoghue@ieee.org>
parents: 16447
diff changeset
151 if ((*it).isValid ())
17254
7fb4461997aa Adjust history window copy/evaluate and remove carriage returns (bug #39722)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 17208
diff changeset
152 {
7fb4461997aa Adjust history window copy/evaluate and remove carriage returns (bug #39722)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 17208
diff changeset
153 if (prev_valid_row)
7fb4461997aa Adjust history window copy/evaluate and remove carriage returns (bug #39722)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 17208
diff changeset
154 text += "\n";
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
155 text += (*it).data ().toString ();
17254
7fb4461997aa Adjust history window copy/evaluate and remove carriage returns (bug #39722)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 17208
diff changeset
156 prev_valid_row = true;
7fb4461997aa Adjust history window copy/evaluate and remove carriage returns (bug #39722)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 17208
diff changeset
157 }
16452
744ff2fe11ce add create script context menu to history window
John Donoghue <john.donoghue@ieee.org>
parents: 16447
diff changeset
158 }
744ff2fe11ce add create script context menu to history window
John Donoghue <john.donoghue@ieee.org>
parents: 16447
diff changeset
159
744ff2fe11ce add create script context menu to history window
John Donoghue <john.donoghue@ieee.org>
parents: 16447
diff changeset
160 if (text.length () > 0)
744ff2fe11ce add create script context menu to history window
John Donoghue <john.donoghue@ieee.org>
parents: 16447
diff changeset
161 emit command_create_script (text);
744ff2fe11ce add create script context menu to history window
John Donoghue <john.donoghue@ieee.org>
parents: 16447
diff changeset
162 }
744ff2fe11ce add create script context menu to history window
John Donoghue <john.donoghue@ieee.org>
parents: 16447
diff changeset
163
744ff2fe11ce add create script context menu to history window
John Donoghue <john.donoghue@ieee.org>
parents: 16447
diff changeset
164
744ff2fe11ce add create script context menu to history window
John Donoghue <john.donoghue@ieee.org>
parents: 16447
diff changeset
165 void
14712
5cb54cca8a06 Completion of code reformatting.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14709
diff changeset
166 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
167 {
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
168 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
169 }
13577
e440b3f32f02 Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13549
diff changeset
170
e440b3f32f02 Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13549
diff changeset
171 void
16431
5982d469f79b use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents: 16351
diff changeset
172 history_dock_widget::set_history (const QStringList& hist)
14720
cecc7da96e2a Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14712
diff changeset
173 {
16431
5982d469f79b use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents: 16351
diff changeset
174 _history_model->setStringList (hist);
5982d469f79b use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents: 16351
diff changeset
175 _history_list_view->scrollToBottom ();
14720
cecc7da96e2a Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14712
diff changeset
176 }
cecc7da96e2a Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14712
diff changeset
177
cecc7da96e2a Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14712
diff changeset
178 void
16431
5982d469f79b use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents: 16351
diff changeset
179 history_dock_widget::append_history (const QString& hist_entry)
5982d469f79b use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents: 16351
diff changeset
180 {
5982d469f79b use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents: 16351
diff changeset
181 QStringList lst = _history_model->stringList ();
5982d469f79b use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents: 16351
diff changeset
182 lst.append (hist_entry);
17208
2527bc7200ee Only scroll history window if it is positioned at bottom.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16881
diff changeset
183
2527bc7200ee Only scroll history window if it is positioned at bottom.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16881
diff changeset
184 QScrollBar *scroll_bar = _history_list_view->verticalScrollBar ();
2527bc7200ee Only scroll history window if it is positioned at bottom.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16881
diff changeset
185
2527bc7200ee Only scroll history window if it is positioned at bottom.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16881
diff changeset
186 bool at_bottom = scroll_bar->maximum () - scroll_bar->value () < 1;
2527bc7200ee Only scroll history window if it is positioned at bottom.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16881
diff changeset
187
16431
5982d469f79b use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents: 16351
diff changeset
188 _history_model->setStringList (lst);
17208
2527bc7200ee Only scroll history window if it is positioned at bottom.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16881
diff changeset
189
2527bc7200ee Only scroll history window if it is positioned at bottom.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16881
diff changeset
190 // Scroll if slider position at bottom.
2527bc7200ee Only scroll history window if it is positioned at bottom.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16881
diff changeset
191 if (at_bottom)
2527bc7200ee Only scroll history window if it is positioned at bottom.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16881
diff changeset
192 _history_list_view->scrollToBottom ();
16431
5982d469f79b use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents: 16351
diff changeset
193 }
5982d469f79b use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents: 16351
diff changeset
194
5982d469f79b use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents: 16351
diff changeset
195 void
5982d469f79b use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents: 16351
diff changeset
196 history_dock_widget::clear_history (void)
14814
61c80e9326a8 Clearing the command history works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14812
diff changeset
197 {
61c80e9326a8 Clearing the command history works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14812
diff changeset
198 _history_model->setStringList (QStringList ());
61c80e9326a8 Clearing the command history works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14812
diff changeset
199 }
16881
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16798
diff changeset
200
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16798
diff changeset
201 void
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16798
diff changeset
202 history_dock_widget::copyClipboard ()
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16798
diff changeset
203 {
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
204 if (_history_list_view->hasFocus ())
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
205 handle_contextmenu_copy (true);
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
206 if (_filter_line_edit->hasFocus () && _filter_line_edit->hasSelectedText ())
16881
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16798
diff changeset
207 {
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16798
diff changeset
208 QClipboard *clipboard = QApplication::clipboard ();
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16798
diff changeset
209 clipboard->setText ( _filter_line_edit->selectedText ());
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16798
diff changeset
210 }
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16798
diff changeset
211 }
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16798
diff changeset
212
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16798
diff changeset
213 void
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16798
diff changeset
214 history_dock_widget::pasteClipboard ()
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16798
diff changeset
215 {
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
216 if (_filter_line_edit->hasFocus ())
17254
7fb4461997aa Adjust history window copy/evaluate and remove carriage returns (bug #39722)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 17208
diff changeset
217 {
7fb4461997aa Adjust history window copy/evaluate and remove carriage returns (bug #39722)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 17208
diff changeset
218 QClipboard *clipboard = QApplication::clipboard ();
7fb4461997aa Adjust history window copy/evaluate and remove carriage returns (bug #39722)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 17208
diff changeset
219 QString str = clipboard->text ();
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
220 if (str.length () > 0)
17254
7fb4461997aa Adjust history window copy/evaluate and remove carriage returns (bug #39722)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 17208
diff changeset
221 _filter_line_edit->insert (str);
7fb4461997aa Adjust history window copy/evaluate and remove carriage returns (bug #39722)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 17208
diff changeset
222 }
16881
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16798
diff changeset
223 }
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16798
diff changeset
224