Mercurial > octave
annotate libgui/src/history-dock-widget.cc @ 24011:9107bae20480
style fixes for some GUI source files
* color-picker.cc, color-picker.h, documentation-dock-widget.cc,
documentation-dock-widget.h, external-editor-interface.cc,
external-editor-interface.h, find-files-dialog.cc,
find-files-dialog.h, find-files-model.cc, find-files-model.h,
history-dock-widget.cc, history-dock-widget.h, settings-dialog.cc,
settings-dialog.h, terminal-dock-widget.cc, thread-manager.cc,
thread-manager.h: Use m_ prefix for member variables, order
functions consistently in header and source files, and follow more
Octave coding conventions.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 06 Sep 2017 09:25:46 -0400 |
parents | b481a9baeb61 |
children | 194eb4bd202b |
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 |
23219
3ac9f9ecfae5
maint: Update copyright dates.
John W. Eaton <jwe@octave.org>
parents:
23083
diff
changeset
|
3 Copyright (C) 2011-2017 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 |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22411
diff
changeset
|
8 under the terms of the GNU General Public License as published by |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22411
diff
changeset
|
9 the Free Software Foundation; either version 3 of the License, or |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22411
diff
changeset
|
10 (at your option) any later version. |
15204
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
11 |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22411
diff
changeset
|
12 Octave is distributed in the hope that it will be useful, but |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22411
diff
changeset
|
13 WITHOUT ANY WARRANTY; without even the implied warranty of |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22411
diff
changeset
|
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22411
diff
changeset
|
15 GNU General Public License for more details. |
15204
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 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21568
diff
changeset
|
23 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21203
diff
changeset
|
24 # include "config.h" |
15155
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> |
18732
0f9ed79fb206
fix performance issue of history viewer with large history entries (bug #42255)
Torsten <ttl@justmail.de>
parents:
18555
diff
changeset
|
32 #include <QDesktopWidget> |
19563
a402493c0605
provide the same filter for history view as for workspace view
Torsten <ttl@justmail.de>
parents:
18732
diff
changeset
|
33 #include <QCompleter> |
a402493c0605
provide the same filter for history view as for workspace view
Torsten <ttl@justmail.de>
parents:
18732
diff
changeset
|
34 #include <QLabel> |
a402493c0605
provide the same filter for history view as for workspace view
Torsten <ttl@justmail.de>
parents:
18732
diff
changeset
|
35 |
15340
9d0cdd49054b
keep history in gui widget at bottom when new items are added
John W. Eaton <jwe@octave.org>
parents:
15318
diff
changeset
|
36 #include "error.h" |
19563
a402493c0605
provide the same filter for history view as for workspace view
Torsten <ttl@justmail.de>
parents:
18732
diff
changeset
|
37 #include "resource-manager.h" |
15340
9d0cdd49054b
keep history in gui widget at bottom when new items are added
John W. Eaton <jwe@octave.org>
parents:
15318
diff
changeset
|
38 |
15402
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
39 #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
|
40 |
16460
4d4e7c6f839d
use consistent names for dock-widget files
John W. Eaton <jwe@octave.org>
parents:
16455
diff
changeset
|
41 #include "history-dock-widget.h" |
13495 | 42 |
16447
e3b33a7530bc
improve encapsulation of history window object
John W. Eaton <jwe@octave.org>
parents:
16441
diff
changeset
|
43 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
|
44 : octave_dock_widget (p) |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
45 { |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
46 setObjectName ("HistoryDockWidget"); |
16447
e3b33a7530bc
improve encapsulation of history window object
John W. Eaton <jwe@octave.org>
parents:
16441
diff
changeset
|
47 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
|
48 |
16455
38ed6bdd1f7f
move signal/slot connections from main window to sub window where possible
John W. Eaton <jwe@octave.org>
parents:
16452
diff
changeset
|
49 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
|
50 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
|
51 |
38ed6bdd1f7f
move signal/slot connections from main window to sub window where possible
John W. Eaton <jwe@octave.org>
parents:
16452
diff
changeset
|
52 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
|
53 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
|
54 |
e3b33a7530bc
improve encapsulation of history window object
John W. Eaton <jwe@octave.org>
parents:
16441
diff
changeset
|
55 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
|
56 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
|
57 |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
58 construct (); |
13495 | 59 } |
60 | |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
61 void |
24011
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
62 history_dock_widget::set_history (const QStringList& hist) |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
63 { |
24011
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
64 m_history_model->setStringList (hist); |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
65 m_history_list_view->scrollToBottom (); |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
66 } |
15447
352349219529
Added multiline copy and execution to command history in IDE (bug #36884)
John Swensen <jpswensen@gmail.com>
parents:
15402
diff
changeset
|
67 |
24011
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
68 void |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
69 history_dock_widget::append_history (const QString& hist_entry) |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
70 { |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
71 QStringList lst = m_history_model->stringList (); |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
72 lst.append (hist_entry); |
19563
a402493c0605
provide the same filter for history view as for workspace view
Torsten <ttl@justmail.de>
parents:
18732
diff
changeset
|
73 |
24011
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
74 QScrollBar *scroll_bar = m_history_list_view->verticalScrollBar (); |
13495 | 75 |
24011
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
76 bool at_bottom = scroll_bar->maximum () - scroll_bar->value () < 1; |
20570
734d446560a8
possibility to hide filters in history and workspace view (bug#45428)
Torsten <ttl@justmail.de>
parents:
20392
diff
changeset
|
77 |
24011
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
78 m_history_model->setStringList (lst); |
19563
a402493c0605
provide the same filter for history view as for workspace view
Torsten <ttl@justmail.de>
parents:
18732
diff
changeset
|
79 |
24011
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
80 // Scroll if slider position at bottom. |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
81 if (at_bottom) |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
82 m_history_list_view->scrollToBottom (); |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
83 } |
19563
a402493c0605
provide the same filter for history view as for workspace view
Torsten <ttl@justmail.de>
parents:
18732
diff
changeset
|
84 |
24011
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
85 void |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
86 history_dock_widget::clear_history (void) |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
87 { |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
88 m_history_model->setStringList (QStringList ()); |
13495 | 89 } |
13536
869c62c15e95
Few minor improvements, added advanced settings for file browser.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13518
diff
changeset
|
90 |
22177
6e9f5408c0db
Save settings in Qt convention, delete all children in destructors (bug #45366)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
21724
diff
changeset
|
91 void |
6e9f5408c0db
Save settings in Qt convention, delete all children in destructors (bug #45366)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
21724
diff
changeset
|
92 history_dock_widget::save_settings (void) |
19563
a402493c0605
provide the same filter for history view as for workspace view
Torsten <ttl@justmail.de>
parents:
18732
diff
changeset
|
93 { |
a402493c0605
provide the same filter for history view as for workspace view
Torsten <ttl@justmail.de>
parents:
18732
diff
changeset
|
94 QSettings *settings = resource_manager::get_settings (); |
a402493c0605
provide the same filter for history view as for workspace view
Torsten <ttl@justmail.de>
parents:
18732
diff
changeset
|
95 |
22177
6e9f5408c0db
Save settings in Qt convention, delete all children in destructors (bug #45366)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
21724
diff
changeset
|
96 if (! settings) |
6e9f5408c0db
Save settings in Qt convention, delete all children in destructors (bug #45366)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
21724
diff
changeset
|
97 return; |
6e9f5408c0db
Save settings in Qt convention, delete all children in destructors (bug #45366)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
21724
diff
changeset
|
98 |
19563
a402493c0605
provide the same filter for history view as for workspace view
Torsten <ttl@justmail.de>
parents:
18732
diff
changeset
|
99 settings->setValue ("history_dock_widget/filter_active", |
24011
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
100 m_filter_checkbox->isChecked ()); |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
101 settings->setValue ("history_dock_widget/filter_shown", m_filter_shown); |
19563
a402493c0605
provide the same filter for history view as for workspace view
Torsten <ttl@justmail.de>
parents:
18732
diff
changeset
|
102 |
a402493c0605
provide the same filter for history view as for workspace view
Torsten <ttl@justmail.de>
parents:
18732
diff
changeset
|
103 QStringList mru; |
24011
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
104 for (int i = 0; i < m_filter->count (); i++) |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
105 mru.append (m_filter->itemText (i)); |
19563
a402493c0605
provide the same filter for history view as for workspace view
Torsten <ttl@justmail.de>
parents:
18732
diff
changeset
|
106 settings->setValue ("history_dock_widget/mru_list", mru); |
a402493c0605
provide the same filter for history view as for workspace view
Torsten <ttl@justmail.de>
parents:
18732
diff
changeset
|
107 |
a402493c0605
provide the same filter for history view as for workspace view
Torsten <ttl@justmail.de>
parents:
18732
diff
changeset
|
108 settings->sync (); |
22177
6e9f5408c0db
Save settings in Qt convention, delete all children in destructors (bug #45366)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
21724
diff
changeset
|
109 |
6e9f5408c0db
Save settings in Qt convention, delete all children in destructors (bug #45366)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
21724
diff
changeset
|
110 octave_dock_widget::save_settings (); |
19563
a402493c0605
provide the same filter for history view as for workspace view
Torsten <ttl@justmail.de>
parents:
18732
diff
changeset
|
111 } |
a402493c0605
provide the same filter for history view as for workspace view
Torsten <ttl@justmail.de>
parents:
18732
diff
changeset
|
112 |
a402493c0605
provide the same filter for history view as for workspace view
Torsten <ttl@justmail.de>
parents:
18732
diff
changeset
|
113 void |
24011
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
114 history_dock_widget::update_filter_history (void) |
19563
a402493c0605
provide the same filter for history view as for workspace view
Torsten <ttl@justmail.de>
parents:
18732
diff
changeset
|
115 { |
24011
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
116 QString text = m_filter->currentText (); // get current text |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
117 int index = m_filter->findText (text); // and its actual index |
19563
a402493c0605
provide the same filter for history view as for workspace view
Torsten <ttl@justmail.de>
parents:
18732
diff
changeset
|
118 |
24011
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
119 if (index > -1) |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
120 m_filter->removeItem (index); // remove if already existing |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
121 |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
122 m_filter->insertItem (0, text); // (re)insert at beginning |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
123 m_filter->setCurrentIndex (0); |
19563
a402493c0605
provide the same filter for history view as for workspace view
Torsten <ttl@justmail.de>
parents:
18732
diff
changeset
|
124 } |
a402493c0605
provide the same filter for history view as for workspace view
Torsten <ttl@justmail.de>
parents:
18732
diff
changeset
|
125 |
a402493c0605
provide the same filter for history view as for workspace view
Torsten <ttl@justmail.de>
parents:
18732
diff
changeset
|
126 void |
24011
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
127 history_dock_widget::filter_activate (bool state) |
19563
a402493c0605
provide the same filter for history view as for workspace view
Torsten <ttl@justmail.de>
parents:
18732
diff
changeset
|
128 { |
24011
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
129 m_filter->setEnabled (state); |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
130 m_sort_filter_proxy_model.setDynamicSortFilter (state); |
19563
a402493c0605
provide the same filter for history view as for workspace view
Torsten <ttl@justmail.de>
parents:
18732
diff
changeset
|
131 |
24011
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
132 if (state) |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
133 m_sort_filter_proxy_model.setFilterWildcard (m_filter->currentText ()); |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
134 else |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
135 m_sort_filter_proxy_model.setFilterWildcard (QString ()); |
19563
a402493c0605
provide the same filter for history view as for workspace view
Torsten <ttl@justmail.de>
parents:
18732
diff
changeset
|
136 } |
a402493c0605
provide the same filter for history view as for workspace view
Torsten <ttl@justmail.de>
parents:
18732
diff
changeset
|
137 |
24011
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
138 void |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
139 history_dock_widget::ctxMenu (const QPoint& xpos) |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
140 { |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
141 QMenu menu (this); |
20392
a8cc8318da8c
show history context menu only for clicks on entries
Torsten <ttl@justmail.de>
parents:
19908
diff
changeset
|
142 |
24011
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
143 QModelIndex index = m_history_list_view->indexAt (xpos); |
20392
a8cc8318da8c
show history context menu only for clicks on entries
Torsten <ttl@justmail.de>
parents:
19908
diff
changeset
|
144 |
a8cc8318da8c
show history context menu only for clicks on entries
Torsten <ttl@justmail.de>
parents:
19908
diff
changeset
|
145 if (index.isValid () && index.column () == 0) |
a8cc8318da8c
show history context menu only for clicks on entries
Torsten <ttl@justmail.de>
parents:
19908
diff
changeset
|
146 { |
a8cc8318da8c
show history context menu only for clicks on entries
Torsten <ttl@justmail.de>
parents:
19908
diff
changeset
|
147 menu.addAction (resource_manager::icon ("edit-copy"), |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
148 tr ("Copy"), this, SLOT (handle_contextmenu_copy (bool))); |
20392
a8cc8318da8c
show history context menu only for clicks on entries
Torsten <ttl@justmail.de>
parents:
19908
diff
changeset
|
149 menu.addAction (tr ("Evaluate"), this, |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
150 SLOT (handle_contextmenu_evaluate (bool))); |
20392
a8cc8318da8c
show history context menu only for clicks on entries
Torsten <ttl@justmail.de>
parents:
19908
diff
changeset
|
151 menu.addAction (resource_manager::icon ("document-new"), |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
152 tr ("Create script"), this, |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
153 SLOT (handle_contextmenu_create_script (bool))); |
20392
a8cc8318da8c
show history context menu only for clicks on entries
Torsten <ttl@justmail.de>
parents:
19908
diff
changeset
|
154 } |
24011
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
155 if (m_filter_shown) |
20570
734d446560a8
possibility to hide filters in history and workspace view (bug#45428)
Torsten <ttl@justmail.de>
parents:
20392
diff
changeset
|
156 menu.addAction (tr ("Hide filter"), this, |
734d446560a8
possibility to hide filters in history and workspace view (bug#45428)
Torsten <ttl@justmail.de>
parents:
20392
diff
changeset
|
157 SLOT (handle_contextmenu_filter ())); |
734d446560a8
possibility to hide filters in history and workspace view (bug#45428)
Torsten <ttl@justmail.de>
parents:
20392
diff
changeset
|
158 else |
734d446560a8
possibility to hide filters in history and workspace view (bug#45428)
Torsten <ttl@justmail.de>
parents:
20392
diff
changeset
|
159 menu.addAction (tr ("Show filter"), this, |
734d446560a8
possibility to hide filters in history and workspace view (bug#45428)
Torsten <ttl@justmail.de>
parents:
20392
diff
changeset
|
160 SLOT (handle_contextmenu_filter ())); |
734d446560a8
possibility to hide filters in history and workspace view (bug#45428)
Torsten <ttl@justmail.de>
parents:
20392
diff
changeset
|
161 |
24011
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
162 menu.exec (m_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
|
163 } |
352349219529
Added multiline copy and execution to command history in IDE (bug #36884)
John Swensen <jpswensen@gmail.com>
parents:
15402
diff
changeset
|
164 |
24011
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
165 void |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
166 history_dock_widget::handle_double_click (QModelIndex modelIndex) |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
167 { |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
168 emit command_double_clicked (modelIndex.data ().toString ()); |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
169 } |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
170 |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
171 void |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
172 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
|
173 { |
352349219529
Added multiline copy and execution to command history in IDE (bug #36884)
John Swensen <jpswensen@gmail.com>
parents:
15402
diff
changeset
|
174 QString text; |
24011
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
175 QItemSelectionModel *selectionModel = m_history_list_view->selectionModel (); |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
176 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
|
177 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
|
178 bool prev_valid_row = false; |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
179 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
|
180 { |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
181 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
|
182 { |
7fb4461997aa
Adjust history window copy/evaluate and remove carriage returns (bug #39722)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
17208
diff
changeset
|
183 if (prev_valid_row) |
23787
b481a9baeb61
Replace += "\n" with += '\n' which avoids string constructor for performance.
Rik <rik@octave.org>
parents:
23433
diff
changeset
|
184 text += '\n'; |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
185 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
|
186 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
|
187 } |
15447
352349219529
Added multiline copy and execution to command history in IDE (bug #36884)
John Swensen <jpswensen@gmail.com>
parents:
15402
diff
changeset
|
188 } |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
189 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
|
190 } |
352349219529
Added multiline copy and execution to command history in IDE (bug #36884)
John Swensen <jpswensen@gmail.com>
parents:
15402
diff
changeset
|
191 |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
192 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
|
193 { |
24011
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
194 QItemSelectionModel *selectionModel = m_history_list_view->selectionModel (); |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
195 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
|
196 QModelIndexList::iterator it; |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
197 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
|
198 { |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
199 if ((*it).isValid ()) |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
200 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
|
201 } |
352349219529
Added multiline copy and execution to command history in IDE (bug #36884)
John Swensen <jpswensen@gmail.com>
parents:
15402
diff
changeset
|
202 } |
352349219529
Added multiline copy and execution to command history in IDE (bug #36884)
John Swensen <jpswensen@gmail.com>
parents:
15402
diff
changeset
|
203 |
13536
869c62c15e95
Few minor improvements, added advanced settings for file browser.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13518
diff
changeset
|
204 void |
16452
744ff2fe11ce
add create script context menu to history window
John Donoghue <john.donoghue@ieee.org>
parents:
16447
diff
changeset
|
205 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
|
206 { |
744ff2fe11ce
add create script context menu to history window
John Donoghue <john.donoghue@ieee.org>
parents:
16447
diff
changeset
|
207 QString text; |
24011
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
208 QItemSelectionModel *selectionModel = m_history_list_view->selectionModel (); |
16452
744ff2fe11ce
add create script context menu to history window
John Donoghue <john.donoghue@ieee.org>
parents:
16447
diff
changeset
|
209 QModelIndexList rows = selectionModel->selectedRows (); |
744ff2fe11ce
add create script context menu to history window
John Donoghue <john.donoghue@ieee.org>
parents:
16447
diff
changeset
|
210 |
17254
7fb4461997aa
Adjust history window copy/evaluate and remove carriage returns (bug #39722)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
17208
diff
changeset
|
211 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
|
212 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
|
213 { |
744ff2fe11ce
add create script context menu to history window
John Donoghue <john.donoghue@ieee.org>
parents:
16447
diff
changeset
|
214 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
|
215 { |
7fb4461997aa
Adjust history window copy/evaluate and remove carriage returns (bug #39722)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
17208
diff
changeset
|
216 if (prev_valid_row) |
23787
b481a9baeb61
Replace += "\n" with += '\n' which avoids string constructor for performance.
Rik <rik@octave.org>
parents:
23433
diff
changeset
|
217 text += '\n'; |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
218 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
|
219 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
|
220 } |
16452
744ff2fe11ce
add create script context menu to history window
John Donoghue <john.donoghue@ieee.org>
parents:
16447
diff
changeset
|
221 } |
744ff2fe11ce
add create script context menu to history window
John Donoghue <john.donoghue@ieee.org>
parents:
16447
diff
changeset
|
222 |
744ff2fe11ce
add create script context menu to history window
John Donoghue <john.donoghue@ieee.org>
parents:
16447
diff
changeset
|
223 if (text.length () > 0) |
744ff2fe11ce
add create script context menu to history window
John Donoghue <john.donoghue@ieee.org>
parents:
16447
diff
changeset
|
224 emit command_create_script (text); |
744ff2fe11ce
add create script context menu to history window
John Donoghue <john.donoghue@ieee.org>
parents:
16447
diff
changeset
|
225 } |
744ff2fe11ce
add create script context menu to history window
John Donoghue <john.donoghue@ieee.org>
parents:
16447
diff
changeset
|
226 |
20570
734d446560a8
possibility to hide filters in history and workspace view (bug#45428)
Torsten <ttl@justmail.de>
parents:
20392
diff
changeset
|
227 void |
734d446560a8
possibility to hide filters in history and workspace view (bug#45428)
Torsten <ttl@justmail.de>
parents:
20392
diff
changeset
|
228 history_dock_widget::handle_contextmenu_filter (void) |
734d446560a8
possibility to hide filters in history and workspace view (bug#45428)
Torsten <ttl@justmail.de>
parents:
20392
diff
changeset
|
229 { |
24011
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
230 m_filter_shown = ! m_filter_shown; |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
231 m_filter_widget->setVisible (m_filter_shown); |
14720
cecc7da96e2a
Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
232 } |
cecc7da96e2a
Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
233 |
cecc7da96e2a
Added update events for the command history model and workspace model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
234 void |
24011
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
235 history_dock_widget::copyClipboard (void) |
16431
5982d469f79b
use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents:
16351
diff
changeset
|
236 { |
24011
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
237 if (m_history_list_view->hasFocus ()) |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
238 handle_contextmenu_copy (true); |
24011
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
239 if (m_filter->lineEdit ()->hasFocus () |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
240 && m_filter->lineEdit ()->hasSelectedText ()) |
16881
944ade6e7f66
Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents:
16798
diff
changeset
|
241 { |
944ade6e7f66
Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents:
16798
diff
changeset
|
242 QClipboard *clipboard = QApplication::clipboard (); |
24011
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
243 clipboard->setText (m_filter->lineEdit ()->selectedText ()); |
16881
944ade6e7f66
Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents:
16798
diff
changeset
|
244 } |
944ade6e7f66
Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents:
16798
diff
changeset
|
245 } |
944ade6e7f66
Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents:
16798
diff
changeset
|
246 |
944ade6e7f66
Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents:
16798
diff
changeset
|
247 void |
24011
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
248 history_dock_widget::pasteClipboard (void) |
16881
944ade6e7f66
Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents:
16798
diff
changeset
|
249 { |
24011
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
250 if (m_filter->lineEdit ()->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
|
251 { |
7fb4461997aa
Adjust history window copy/evaluate and remove carriage returns (bug #39722)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
17208
diff
changeset
|
252 QClipboard *clipboard = QApplication::clipboard (); |
21568
3d60ed163b70
maint: Eliminate bad spacing around '='.
Rik <rik@octave.org>
parents:
21301
diff
changeset
|
253 QString str = clipboard->text (); |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
254 if (str.length () > 0) |
24011
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
255 m_filter->lineEdit ()->insert (str); |
17254
7fb4461997aa
Adjust history window copy/evaluate and remove carriage returns (bug #39722)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
17208
diff
changeset
|
256 } |
16881
944ade6e7f66
Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents:
16798
diff
changeset
|
257 } |
944ade6e7f66
Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents:
16798
diff
changeset
|
258 |
18555
2d5d0d86432e
gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents:
17935
diff
changeset
|
259 void |
24011
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
260 history_dock_widget::selectAll (void) |
18555
2d5d0d86432e
gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents:
17935
diff
changeset
|
261 { |
24011
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
262 if (m_filter->lineEdit ()->hasFocus ()) |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
263 m_filter->lineEdit ()->selectAll (); |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
264 |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
265 if (m_history_list_view->hasFocus ()) |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
266 m_history_list_view->selectAll (); |
18555
2d5d0d86432e
gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents:
17935
diff
changeset
|
267 } |
20692
950c8a092db7
check whether filter is active or not when history widget becomes visible
Torsten <ttl@justmail.de>
parents:
20392
diff
changeset
|
268 |
24011
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
269 void |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
270 history_dock_widget::handle_visibility (bool visible) |
20692
950c8a092db7
check whether filter is active or not when history widget becomes visible
Torsten <ttl@justmail.de>
parents:
20392
diff
changeset
|
271 { |
950c8a092db7
check whether filter is active or not when history widget becomes visible
Torsten <ttl@justmail.de>
parents:
20392
diff
changeset
|
272 octave_dock_widget::handle_visibility (visible); |
950c8a092db7
check whether filter is active or not when history widget becomes visible
Torsten <ttl@justmail.de>
parents:
20392
diff
changeset
|
273 |
950c8a092db7
check whether filter is active or not when history widget becomes visible
Torsten <ttl@justmail.de>
parents:
20392
diff
changeset
|
274 if (visible) |
950c8a092db7
check whether filter is active or not when history widget becomes visible
Torsten <ttl@justmail.de>
parents:
20392
diff
changeset
|
275 { |
24011
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
276 int filter_state = m_filter_checkbox->isChecked (); |
20692
950c8a092db7
check whether filter is active or not when history widget becomes visible
Torsten <ttl@justmail.de>
parents:
20392
diff
changeset
|
277 filter_activate (filter_state); |
950c8a092db7
check whether filter is active or not when history widget becomes visible
Torsten <ttl@justmail.de>
parents:
20392
diff
changeset
|
278 } |
21568
3d60ed163b70
maint: Eliminate bad spacing around '='.
Rik <rik@octave.org>
parents:
21301
diff
changeset
|
279 } |
24011
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
280 |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
281 void |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
282 history_dock_widget::construct (void) |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
283 { |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
284 m_history_model = new QStringListModel (); |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
285 m_sort_filter_proxy_model.setSourceModel (m_history_model); |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
286 m_history_list_view = new QListView (this); |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
287 m_history_list_view->setModel (&m_sort_filter_proxy_model); |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
288 m_history_list_view->setAlternatingRowColors (true); |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
289 m_history_list_view->setEditTriggers (QAbstractItemView::NoEditTriggers); |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
290 m_history_list_view->setStatusTip ( |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
291 tr ("Double-click a command to transfer it to the terminal.")); |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
292 m_history_list_view->setSelectionMode (QAbstractItemView::ExtendedSelection); |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
293 m_history_list_view->setContextMenuPolicy (Qt::CustomContextMenu); |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
294 connect (m_history_list_view, |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
295 SIGNAL (customContextMenuRequested (const QPoint &)), this, |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
296 SLOT (ctxMenu (const QPoint &))); |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
297 |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
298 m_filter = new QComboBox (this); |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
299 m_filter->setToolTip (tr ("Enter text to filter the command history")); |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
300 m_filter->setEditable (true); |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
301 m_filter->setMaxCount (MaxFilterHistory); |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
302 m_filter->setInsertPolicy (QComboBox::NoInsert); |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
303 m_filter->setSizeAdjustPolicy ( |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
304 QComboBox::AdjustToMinimumContentsLengthWithIcon); |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
305 QSizePolicy sizePol (QSizePolicy::Expanding, QSizePolicy::Preferred); |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
306 m_filter->setSizePolicy (sizePol); |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
307 m_filter->completer ()->setCaseSensitivity (Qt::CaseSensitive); |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
308 |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
309 QLabel *filter_label = new QLabel (tr ("Filter")); |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
310 |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
311 m_filter_checkbox = new QCheckBox (); |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
312 |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
313 setWindowIcon (QIcon (":/actions/icons/logo.png")); |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
314 set_title (tr ("Command History")); |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
315 setWidget (new QWidget ()); |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
316 |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
317 m_filter_widget = new QWidget (this); |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
318 QHBoxLayout *filter_layout = new QHBoxLayout (); |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
319 filter_layout->addWidget (filter_label); |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
320 filter_layout->addWidget (m_filter_checkbox); |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
321 filter_layout->addWidget (m_filter); |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
322 filter_layout->setMargin(0); |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
323 m_filter_widget->setLayout (filter_layout); |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
324 |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
325 QVBoxLayout *hist_layout = new QVBoxLayout (); |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
326 hist_layout->addWidget (m_filter_widget); |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
327 hist_layout->addWidget (m_history_list_view); |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
328 |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
329 hist_layout->setMargin (2); |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
330 widget ()->setLayout (hist_layout); |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
331 |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
332 // Init state of the filter |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
333 QSettings *settings = resource_manager::get_settings (); |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
334 |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
335 m_filter_shown |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
336 = settings->value ("history_dock_widget/filter_shown",true).toBool (); |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
337 m_filter_widget->setVisible (m_filter_shown); |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
338 |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
339 m_filter->addItems (settings->value ("history_dock_widget/mru_list").toStringList ()); |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
340 |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
341 bool filter_state |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
342 = settings->value ("history_dock_widget/filter_active", false).toBool (); |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
343 m_filter_checkbox->setChecked (filter_state); |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
344 filter_activate (filter_state); |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
345 |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
346 // Connect signals and slots |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
347 connect (m_filter, SIGNAL (editTextChanged (const QString&)), |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
348 &m_sort_filter_proxy_model, |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
349 SLOT (setFilterWildcard (const QString&))); |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
350 connect (m_filter_checkbox, SIGNAL (toggled (bool)), |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
351 this, SLOT (filter_activate (bool))); |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
352 connect (m_filter->lineEdit (), SIGNAL (editingFinished (void)), |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
353 this, SLOT (updatem_filter_history (void))); |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
354 |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
355 connect (m_history_list_view, SIGNAL (doubleClicked (QModelIndex)), |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
356 this, SLOT (handle_double_click (QModelIndex))); |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
357 |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
358 // shrink max. displayed entry size to desktop width |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
359 QSize screen = QDesktopWidget ().screenGeometry ().size (); |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
360 int w = screen.width (); |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
361 QFontMetrics fm = m_history_list_view->fontMetrics (); |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
362 int h = fm.height (); |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
363 m_history_list_view->setGridSize (QSize (w,h)); |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
364 m_history_list_view->setTextElideMode (Qt::ElideRight); |
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23787
diff
changeset
|
365 } |