annotate libgui/src/qt-interpreter-events.cc @ 27600:bb9aecedc167

use single QVariant object for return values in qt_interpreter_events class * qt-interpreter-events.h, qt-interpreter-events.cc (qt_interpreter_events::m_result): New QVariant data member. (qt_interpreter_events::m_shutdown_confirm_result, (qt_interpreter_events::m_get_named_icon_result): Delete. Use m_result to store and retrieve results instead.
author John W. Eaton <jwe@octave.org>
date Thu, 31 Oct 2019 11:40:30 -0400
parents ada24a1979c0
children 7a748f7545c9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
16415
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1 /*
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2
26376
00f796120a6d maint: Update copyright dates in all source files.
John W. Eaton <jwe@octave.org>
parents: 26117
diff changeset
3 Copyright (C) 2013-2019 John W. Eaton
00f796120a6d maint: Update copyright dates in all source files.
John W. Eaton <jwe@octave.org>
parents: 26117
diff changeset
4 Copyright (C) 2011-2019 Jacob Dawid
00f796120a6d maint: Update copyright dates in all source files.
John W. Eaton <jwe@octave.org>
parents: 26117
diff changeset
5 Copyright (C) 2011-2019 John P. Swensen
16415
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
6
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
7 This file is part of Octave.
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
8
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24301
diff changeset
9 Octave is free software: you can redistribute it and/or modify it
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22417
diff changeset
10 under the terms of the GNU General Public License as published by
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24301
diff changeset
11 the Free Software Foundation, either version 3 of the License, or
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22417
diff changeset
12 (at your option) any later version.
16415
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
13
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22417
diff changeset
14 Octave is distributed in the hope that it will be useful, but
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22417
diff changeset
15 WITHOUT ANY WARRANTY; without even the implied warranty of
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22417
diff changeset
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22417
diff changeset
17 GNU General Public License for more details.
16415
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
18
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
19 You should have received a copy of the GNU General Public License
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
20 along with Octave; see the file COPYING. If not, see
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24301
diff changeset
21 <https://www.gnu.org/licenses/>.
16415
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
22
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
23 */
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
24
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21717
diff changeset
25 #if defined (HAVE_CONFIG_H)
21301
40de9f8f23a6 Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents: 21203
diff changeset
26 # include "config.h"
16415
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
27 #endif
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
28
17884
766ad9be2966 Prompt for non-existent new file when using edit.m from GUI (bug #40450)
Torsten <ttl@justmail.de>
parents: 17824
diff changeset
29 #include <QDialog>
766ad9be2966 Prompt for non-existent new file when using edit.m from GUI (bug #40450)
Torsten <ttl@justmail.de>
parents: 17824
diff changeset
30 #include <QDir>
27600
bb9aecedc167 use single QVariant object for return values in qt_interpreter_events class
John W. Eaton <jwe@octave.org>
parents: 27599
diff changeset
31 #include <QIcon>
24641
7d177be54c37 pass variable value to variable editor in addition to variable name
John W. Eaton <jwe@octave.org>
parents: 24632
diff changeset
32 #include <QMetaType>
21158
65827e9cccb8 Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21148
diff changeset
33 #include <QPushButton>
24641
7d177be54c37 pass variable value to variable editor in addition to variable name
John W. Eaton <jwe@octave.org>
parents: 24632
diff changeset
34 #include <QStringList>
16431
5982d469f79b use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents: 16426
diff changeset
35
27412
da1f59fe04b3 try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents: 27409
diff changeset
36 #include "dialog.h"
27588
f0e3f3e28a8e move qt_interpreter_events object from interpreter_qobject to octave_qobject
John W. Eaton <jwe@octave.org>
parents: 27553
diff changeset
37 #include "octave-qobject.h"
27412
da1f59fe04b3 try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents: 27409
diff changeset
38 #include "qt-interpreter-events.h"
da1f59fe04b3 try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents: 27409
diff changeset
39 #include "resource-manager.h"
da1f59fe04b3 try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents: 27409
diff changeset
40
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
41 #include "oct-env.h"
16431
5982d469f79b use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents: 16426
diff changeset
42 #include "str-vec.h"
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
43
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
44 #include "builtin-defun-decls.h"
16547
3cd80afc3509 improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents: 16528
diff changeset
45 #include "error.h"
23438
d24d01273bd0 eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
46 #include "interpreter-private.h"
16635
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16581
diff changeset
47 #include "load-path.h"
27412
da1f59fe04b3 try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents: 27409
diff changeset
48 #include "oct-map.h"
25557
bb779fc2d0db do not attempt to open a file when debugging a command line fct (bug #54231)
Torsten <mttl@mailbox.org>
parents: 25407
diff changeset
49 #include "octave.h"
27412
da1f59fe04b3 try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents: 27409
diff changeset
50 #include "ov.h"
26117
a6df420457ac use symbol_info_list instead of symbol_scope to pass workspace info to gui
John W. Eaton <jwe@octave.org>
parents: 25948
diff changeset
51 #include "syminfo.h"
16635
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16581
diff changeset
52 #include "utils.h"
16468
0f143f68078d use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents: 16443
diff changeset
53
24645
f61502510d08 restore ability to select variables for editing from workspace widget
John W. Eaton <jwe@octave.org>
parents: 24641
diff changeset
54 Q_DECLARE_METATYPE (octave_value)
26117
a6df420457ac use symbol_info_list instead of symbol_scope to pass workspace info to gui
John W. Eaton <jwe@octave.org>
parents: 25948
diff changeset
55 Q_DECLARE_METATYPE (octave::symbol_info_list)
27302
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27284
diff changeset
56 Q_DECLARE_METATYPE (octave::fcn_callback)
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27284
diff changeset
57 Q_DECLARE_METATYPE (octave::meth_callback)
17884
766ad9be2966 Prompt for non-existent new file when using edit.m from GUI (bug #40450)
Torsten <ttl@justmail.de>
parents: 17824
diff changeset
58
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
59 namespace octave
24641
7d177be54c37 pass variable value to variable editor in addition to variable name
John W. Eaton <jwe@octave.org>
parents: 24632
diff changeset
60 {
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
61 static QStringList
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
62 make_qstring_list (const std::list<std::string>& lst)
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
63 {
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
64 QStringList retval;
16512
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
65
27550
b8f51d2dba6d * qt-interpreter-events.cc: Use range-based for loop where possible.
John W. Eaton <jwe@octave.org>
parents: 27549
diff changeset
66 for (const auto& s : lst)
b8f51d2dba6d * qt-interpreter-events.cc: Use range-based for loop where possible.
John W. Eaton <jwe@octave.org>
parents: 27549
diff changeset
67 retval.append (QString::fromStdString (s));
16512
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
68
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
69 return retval;
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
70 }
16512
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
71
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
72 static QStringList
27263
99aa1bcb8848 rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27261
diff changeset
73 make_filter_list (const event_manager::filter_list& lst)
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
74 {
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
75 QStringList retval;
16579
7f8db1942dc0 Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents: 16570
diff changeset
76
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
77 // We have pairs of data, first being the list of extensions
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
78 // exta;exb;extc etc second the name to use as filter name
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
79 // (optional). Qt wants a list of filters in the format of
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
80 // 'FilterName (space separated exts)'.
16579
7f8db1942dc0 Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents: 16570
diff changeset
81
27550
b8f51d2dba6d * qt-interpreter-events.cc: Use range-based for loop where possible.
John W. Eaton <jwe@octave.org>
parents: 27549
diff changeset
82 for (const auto& ext_name : lst)
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
83 {
27550
b8f51d2dba6d * qt-interpreter-events.cc: Use range-based for loop where possible.
John W. Eaton <jwe@octave.org>
parents: 27549
diff changeset
84 QString ext = QString::fromStdString (ext_name.first);
b8f51d2dba6d * qt-interpreter-events.cc: Use range-based for loop where possible.
John W. Eaton <jwe@octave.org>
parents: 27549
diff changeset
85 QString name = QString::fromStdString (ext_name.second);
16579
7f8db1942dc0 Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents: 16570
diff changeset
86
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
87 // Strip out extensions from name and replace ';' with spaces in
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
88 // list.
16580
adc150db1809 style fixes for uigetfile changes
John W. Eaton <jwe@octave.org>
parents: 16579
diff changeset
89
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
90 name.replace (QRegExp ("\\(.*\\)"), "");
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
91 ext.replace (";", " ");
16579
7f8db1942dc0 Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents: 16570
diff changeset
92
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
93 if (name.isEmpty ())
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
94 {
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
95 // No name field. Build one from the extensions.
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
96 name = ext.toUpper () + " Files";
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
97 }
16579
7f8db1942dc0 Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents: 16570
diff changeset
98
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
99 retval.append (name + " (" + ext + ')');
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
100 }
16579
7f8db1942dc0 Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents: 16570
diff changeset
101
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
102 return retval;
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
103 }
16512
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
104
27588
f0e3f3e28a8e move qt_interpreter_events object from interpreter_qobject to octave_qobject
John W. Eaton <jwe@octave.org>
parents: 27553
diff changeset
105 qt_interpreter_events::qt_interpreter_events (base_qobject& oct_qobj)
27600
bb9aecedc167 use single QVariant object for return values in qt_interpreter_events class
John W. Eaton <jwe@octave.org>
parents: 27599
diff changeset
106 : interpreter_events (), m_octave_qobj (oct_qobj), m_result (),
bb9aecedc167 use single QVariant object for return values in qt_interpreter_events class
John W. Eaton <jwe@octave.org>
parents: 27599
diff changeset
107 m_mutex (), m_waitcondition (), m_uiwidget_creator ()
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
108 {
27551
564bba235594 move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents: 27550
diff changeset
109 qRegisterMetaType<QIntList> ("QIntList");
564bba235594 move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents: 27550
diff changeset
110 qRegisterMetaType<QFloatList> ("QFloatList");
564bba235594 move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents: 27550
diff changeset
111
27442
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
112 qRegisterMetaType<octave_value> ("octave_value");
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
113 qRegisterMetaType<symbol_info_list> ("symbol_info_list");
20091
89d843d6de14 Add mutex lock to shutdown confirmation for proper thread timing (bug #44751).
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19970
diff changeset
114
27442
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
115 qRegisterMetaType<fcn_callback> ("fcn_callback");
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
116 qRegisterMetaType<meth_callback> ("meth_callback");
27588
f0e3f3e28a8e move qt_interpreter_events object from interpreter_qobject to octave_qobject
John W. Eaton <jwe@octave.org>
parents: 27553
diff changeset
117
f0e3f3e28a8e move qt_interpreter_events object from interpreter_qobject to octave_qobject
John W. Eaton <jwe@octave.org>
parents: 27553
diff changeset
118 connect (this, SIGNAL (confirm_shutdown_signal (void)),
f0e3f3e28a8e move qt_interpreter_events object from interpreter_qobject to octave_qobject
John W. Eaton <jwe@octave.org>
parents: 27553
diff changeset
119 this, SLOT (confirm_shutdown_octave (void)));
27599
ada24a1979c0 improve thread safety of qt_interpreter_events::get_named_icon
John W. Eaton <jwe@octave.org>
parents: 27589
diff changeset
120
ada24a1979c0 improve thread safety of qt_interpreter_events::get_named_icon
John W. Eaton <jwe@octave.org>
parents: 27589
diff changeset
121 connect (this, SIGNAL (get_named_icon_signal (const QString&)),
ada24a1979c0 improve thread safety of qt_interpreter_events::get_named_icon
John W. Eaton <jwe@octave.org>
parents: 27589
diff changeset
122 this, SLOT (get_named_icon_slot (const QString&)));
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
123 }
16579
7f8db1942dc0 Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents: 16570
diff changeset
124
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
125 std::list<std::string>
27284
1a8762e5662b remove "do_" prefix from interpreter_events class methods
John W. Eaton <jwe@octave.org>
parents: 27276
diff changeset
126 qt_interpreter_events::file_dialog (const filter_list& filter,
1a8762e5662b remove "do_" prefix from interpreter_events class methods
John W. Eaton <jwe@octave.org>
parents: 27276
diff changeset
127 const std::string& title,
1a8762e5662b remove "do_" prefix from interpreter_events class methods
John W. Eaton <jwe@octave.org>
parents: 27276
diff changeset
128 const std::string& filename,
1a8762e5662b remove "do_" prefix from interpreter_events class methods
John W. Eaton <jwe@octave.org>
parents: 27276
diff changeset
129 const std::string& dirname,
1a8762e5662b remove "do_" prefix from interpreter_events class methods
John W. Eaton <jwe@octave.org>
parents: 27276
diff changeset
130 const std::string& multimode)
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
131 {
27552
de5129cb0796 refactor dialog functions
John W. Eaton <jwe@octave.org>
parents: 27551
diff changeset
132 QStringList lst
27553
9b72eb111b7e eliminate global uiwidget_creator variable
John W. Eaton <jwe@octave.org>
parents: 27552
diff changeset
133 = m_uiwidget_creator.file_dialog (make_filter_list (filter),
9b72eb111b7e eliminate global uiwidget_creator variable
John W. Eaton <jwe@octave.org>
parents: 27552
diff changeset
134 QString::fromStdString (title),
9b72eb111b7e eliminate global uiwidget_creator variable
John W. Eaton <jwe@octave.org>
parents: 27552
diff changeset
135 QString::fromStdString (filename),
9b72eb111b7e eliminate global uiwidget_creator variable
John W. Eaton <jwe@octave.org>
parents: 27552
diff changeset
136 QString::fromStdString (dirname),
9b72eb111b7e eliminate global uiwidget_creator variable
John W. Eaton <jwe@octave.org>
parents: 27552
diff changeset
137 QString::fromStdString (multimode));
27552
de5129cb0796 refactor dialog functions
John W. Eaton <jwe@octave.org>
parents: 27551
diff changeset
138
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
139 std::list<std::string> retval;
20091
89d843d6de14 Add mutex lock to shutdown confirmation for proper thread timing (bug #44751).
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19970
diff changeset
140
27552
de5129cb0796 refactor dialog functions
John W. Eaton <jwe@octave.org>
parents: 27551
diff changeset
141 for (const auto& s : lst)
27550
b8f51d2dba6d * qt-interpreter-events.cc: Use range-based for loop where possible.
John W. Eaton <jwe@octave.org>
parents: 27549
diff changeset
142 retval.push_back (s.toStdString ());
16579
7f8db1942dc0 Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents: 16570
diff changeset
143
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
144 return retval;
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
145 }
16579
7f8db1942dc0 Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents: 16570
diff changeset
146
27442
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
147 std::list<std::string>
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
148 qt_interpreter_events::input_dialog (const std::list<std::string>& prompt,
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
149 const std::string& title,
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
150 const std::list<float>& nr,
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
151 const std::list<float>& nc,
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
152 const std::list<std::string>& defaults)
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
153 {
27552
de5129cb0796 refactor dialog functions
John W. Eaton <jwe@octave.org>
parents: 27551
diff changeset
154 QStringList lst
27553
9b72eb111b7e eliminate global uiwidget_creator variable
John W. Eaton <jwe@octave.org>
parents: 27552
diff changeset
155 = m_uiwidget_creator.input_dialog (make_qstring_list (prompt),
9b72eb111b7e eliminate global uiwidget_creator variable
John W. Eaton <jwe@octave.org>
parents: 27552
diff changeset
156 QString::fromStdString (title),
9b72eb111b7e eliminate global uiwidget_creator variable
John W. Eaton <jwe@octave.org>
parents: 27552
diff changeset
157 QFloatList::fromStdList (nr),
9b72eb111b7e eliminate global uiwidget_creator variable
John W. Eaton <jwe@octave.org>
parents: 27552
diff changeset
158 QFloatList::fromStdList (nc),
9b72eb111b7e eliminate global uiwidget_creator variable
John W. Eaton <jwe@octave.org>
parents: 27552
diff changeset
159 make_qstring_list (defaults));
27442
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
160 std::list<std::string> retval;
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
161
27552
de5129cb0796 refactor dialog functions
John W. Eaton <jwe@octave.org>
parents: 27551
diff changeset
162 for (const auto& s : lst)
27550
b8f51d2dba6d * qt-interpreter-events.cc: Use range-based for loop where possible.
John W. Eaton <jwe@octave.org>
parents: 27549
diff changeset
163 retval.push_back (s.toStdString ());
27442
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
164
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
165 return retval;
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
166 }
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
167
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
168 std::pair<std::list<int>, int>
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
169 qt_interpreter_events::list_dialog (const std::list<std::string>& list,
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
170 const std::string& mode,
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
171 int width, int height,
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
172 const std::list<int>& initial,
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
173 const std::string& name,
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
174 const std::list<std::string>& prompt,
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
175 const std::string& ok_string,
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
176 const std::string& cancel_string)
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
177 {
27552
de5129cb0796 refactor dialog functions
John W. Eaton <jwe@octave.org>
parents: 27551
diff changeset
178 QPair<QIntList, int> result
27553
9b72eb111b7e eliminate global uiwidget_creator variable
John W. Eaton <jwe@octave.org>
parents: 27552
diff changeset
179 = m_uiwidget_creator.list_dialog (make_qstring_list (list),
9b72eb111b7e eliminate global uiwidget_creator variable
John W. Eaton <jwe@octave.org>
parents: 27552
diff changeset
180 QString::fromStdString (mode),
9b72eb111b7e eliminate global uiwidget_creator variable
John W. Eaton <jwe@octave.org>
parents: 27552
diff changeset
181 width, height,
9b72eb111b7e eliminate global uiwidget_creator variable
John W. Eaton <jwe@octave.org>
parents: 27552
diff changeset
182 QList<int>::fromStdList (initial),
9b72eb111b7e eliminate global uiwidget_creator variable
John W. Eaton <jwe@octave.org>
parents: 27552
diff changeset
183 QString::fromStdString (name),
9b72eb111b7e eliminate global uiwidget_creator variable
John W. Eaton <jwe@octave.org>
parents: 27552
diff changeset
184 make_qstring_list (prompt),
9b72eb111b7e eliminate global uiwidget_creator variable
John W. Eaton <jwe@octave.org>
parents: 27552
diff changeset
185 QString::fromStdString (ok_string),
9b72eb111b7e eliminate global uiwidget_creator variable
John W. Eaton <jwe@octave.org>
parents: 27552
diff changeset
186 QString::fromStdString (cancel_string));
27442
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
187
27552
de5129cb0796 refactor dialog functions
John W. Eaton <jwe@octave.org>
parents: 27551
diff changeset
188 return std::pair<std::list<int>, int> (result.first.toStdList (),
de5129cb0796 refactor dialog functions
John W. Eaton <jwe@octave.org>
parents: 27551
diff changeset
189 result.second);
27442
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
190 }
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
191
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
192 std::string
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
193 qt_interpreter_events::question_dialog (const std::string& msg,
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
194 const std::string& title,
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
195 const std::string& btn1,
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
196 const std::string& btn2,
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
197 const std::string& btn3,
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
198 const std::string& btndef)
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
199 {
27552
de5129cb0796 refactor dialog functions
John W. Eaton <jwe@octave.org>
parents: 27551
diff changeset
200 QString icon = "quest";
de5129cb0796 refactor dialog functions
John W. Eaton <jwe@octave.org>
parents: 27551
diff changeset
201 QStringList buttons;
27442
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
202 QStringList role;
27552
de5129cb0796 refactor dialog functions
John W. Eaton <jwe@octave.org>
parents: 27551
diff changeset
203
27442
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
204 // Must use ResetRole which is left-aligned for all OS and WM.
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
205 role << "ResetRole" << "ResetRole" << "ResetRole";
27552
de5129cb0796 refactor dialog functions
John W. Eaton <jwe@octave.org>
parents: 27551
diff changeset
206
de5129cb0796 refactor dialog functions
John W. Eaton <jwe@octave.org>
parents: 27551
diff changeset
207 buttons << QString::fromStdString (btn1);
27442
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
208 if (btn2 == "")
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
209 role.removeAt (0);
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
210 else
27552
de5129cb0796 refactor dialog functions
John W. Eaton <jwe@octave.org>
parents: 27551
diff changeset
211 buttons << QString::fromStdString (btn2);
de5129cb0796 refactor dialog functions
John W. Eaton <jwe@octave.org>
parents: 27551
diff changeset
212 buttons << QString::fromStdString (btn3);
27442
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
213
27552
de5129cb0796 refactor dialog functions
John W. Eaton <jwe@octave.org>
parents: 27551
diff changeset
214 QString answer
27553
9b72eb111b7e eliminate global uiwidget_creator variable
John W. Eaton <jwe@octave.org>
parents: 27552
diff changeset
215 = m_uiwidget_creator.message_dialog (QString::fromStdString (msg),
9b72eb111b7e eliminate global uiwidget_creator variable
John W. Eaton <jwe@octave.org>
parents: 27552
diff changeset
216 QString::fromStdString (title),
9b72eb111b7e eliminate global uiwidget_creator variable
John W. Eaton <jwe@octave.org>
parents: 27552
diff changeset
217 icon, buttons,
9b72eb111b7e eliminate global uiwidget_creator variable
John W. Eaton <jwe@octave.org>
parents: 27552
diff changeset
218 QString::fromStdString (btndef),
9b72eb111b7e eliminate global uiwidget_creator variable
John W. Eaton <jwe@octave.org>
parents: 27552
diff changeset
219 role);
27442
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
220
27552
de5129cb0796 refactor dialog functions
John W. Eaton <jwe@octave.org>
parents: 27551
diff changeset
221 return answer.toStdString ();
27442
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
222 }
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
223
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
224 void qt_interpreter_events::update_path_dialog (void)
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
225 {
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
226 emit update_path_dialog_signal ();
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
227 }
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
228
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
229 void qt_interpreter_events::show_preferences (void)
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
230 {
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
231 emit show_preferences_signal ();
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
232 }
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
233
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
234 void qt_interpreter_events::show_doc (const std::string& file)
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
235 {
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
236 emit show_doc_signal (QString::fromStdString (file));
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
237 }
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
238
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
239 bool qt_interpreter_events::edit_file (const std::string& file)
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
240 {
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
241 emit edit_file_signal (QString::fromStdString (file));
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
242
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
243 return true;
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
244 }
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
245
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
246 void qt_interpreter_events::edit_variable (const std::string& expr,
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
247 const octave_value& val)
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
248 {
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
249 emit edit_variable_signal (QString::fromStdString (expr), val);
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
250 }
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
251
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
252 bool qt_interpreter_events::confirm_shutdown (void)
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
253 {
27589
12cfa32dc29e use QMutexLocker to manage locks in qt_interpreter_events methods
John W. Eaton <jwe@octave.org>
parents: 27588
diff changeset
254 QMutexLocker autolock (&m_mutex);
27442
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
255
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
256 emit confirm_shutdown_signal ();
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
257
27588
f0e3f3e28a8e move qt_interpreter_events object from interpreter_qobject to octave_qobject
John W. Eaton <jwe@octave.org>
parents: 27553
diff changeset
258 // Wait for result.
27442
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
259 wait ();
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
260
27600
bb9aecedc167 use single QVariant object for return values in qt_interpreter_events class
John W. Eaton <jwe@octave.org>
parents: 27599
diff changeset
261 return m_result.toBool ();
27442
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
262 }
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
263
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
264 bool qt_interpreter_events::prompt_new_edit_file (const std::string& file)
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
265 {
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
266 QSettings *settings = resource_manager::get_settings ();
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
267
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
268 if (! settings || settings->value ("editor/create_new_file",false).toBool ())
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
269 return true;
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
270
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
271 std::string abs_fname = sys::env::make_absolute (file);
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
272
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
273 QStringList btn;
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
274 QStringList role;
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
275 role << "YesRole" << "RejectRole";
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
276 btn << tr ("Create") << tr ("Cancel");
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
277
27553
9b72eb111b7e eliminate global uiwidget_creator variable
John W. Eaton <jwe@octave.org>
parents: 27552
diff changeset
278 QString answer = m_uiwidget_creator.message_dialog
27442
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
279 (tr ("File\n%1\ndoes not exist. Do you want to create it?").
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
280 arg (QString::fromStdString (abs_fname)),
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
281 tr ("Octave Editor"), "quest", btn, tr ("Create"), role);
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
282
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
283 return (answer == tr ("Create"));
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
284 }
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
285
27264
378d3c91f85b style fixes for event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27263
diff changeset
286 // Prompt to allow file to be run by setting cwd (or if
27552
de5129cb0796 refactor dialog functions
John W. Eaton <jwe@octave.org>
parents: 27551
diff changeset
287 // addpath_option==true, alternatively setting the path).
27264
378d3c91f85b style fixes for event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27263
diff changeset
288
378d3c91f85b style fixes for event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27263
diff changeset
289 int
27284
1a8762e5662b remove "do_" prefix from interpreter_events class methods
John W. Eaton <jwe@octave.org>
parents: 27276
diff changeset
290 qt_interpreter_events::debug_cd_or_addpath_error (const std::string& file,
1a8762e5662b remove "do_" prefix from interpreter_events class methods
John W. Eaton <jwe@octave.org>
parents: 27276
diff changeset
291 const std::string& dir,
1a8762e5662b remove "do_" prefix from interpreter_events class methods
John W. Eaton <jwe@octave.org>
parents: 27276
diff changeset
292 bool addpath_option)
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
293 {
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
294 int retval = -1;
16565
e4b94abfeb96 use generic dialog for cd or addpath question
John W. Eaton <jwe@octave.org>
parents: 16551
diff changeset
295
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
296 QString qdir = QString::fromStdString (dir);
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
297 QString qfile = QString::fromStdString (file);
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
298 QString msg
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
299 = (addpath_option
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
300 ? tr ("The file %1 does not exist in the load path. To run or debug the function you are editing, you must either change to the directory %2 or add that directory to the load path.").arg (qfile).arg (qdir)
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
301 : tr ("The file %1 is shadowed by a file with the same name in the load path. To run or debug the function you are editing, change to the directory %2.").arg (qfile).arg (qdir));
16565
e4b94abfeb96 use generic dialog for cd or addpath question
John W. Eaton <jwe@octave.org>
parents: 16551
diff changeset
302
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
303 QString title = tr ("Change Directory or Add Directory to Load Path");
16565
e4b94abfeb96 use generic dialog for cd or addpath question
John W. Eaton <jwe@octave.org>
parents: 16551
diff changeset
304
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
305 QString cd_txt = tr ("&Change Directory");
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
306 QString addpath_txt = tr ("&Add Directory to Load Path");
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
307 QString cancel_txt = tr ("Cancel");
16547
3cd80afc3509 improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents: 16528
diff changeset
308
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
309 QStringList btn;
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
310 QStringList role;
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
311 btn << cd_txt;
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
312 role << "YesRole";
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
313 if (addpath_option)
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
314 {
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
315 btn << addpath_txt;
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
316 role << "AcceptRole";
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
317 }
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
318 btn << cancel_txt;
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
319 role << "RejectRole";
21311
718332a58d35 Fix left mouse button in editor margin bug from cset 65827e9cccb8
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21310
diff changeset
320
27552
de5129cb0796 refactor dialog functions
John W. Eaton <jwe@octave.org>
parents: 27551
diff changeset
321 QString result
27553
9b72eb111b7e eliminate global uiwidget_creator variable
John W. Eaton <jwe@octave.org>
parents: 27552
diff changeset
322 = m_uiwidget_creator.message_dialog (msg, title, "quest", btn,
9b72eb111b7e eliminate global uiwidget_creator variable
John W. Eaton <jwe@octave.org>
parents: 27552
diff changeset
323 cancel_txt, role);
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
324
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
325 if (result == cd_txt)
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
326 retval = 1;
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
327 else if (result == addpath_txt)
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
328 retval = 2;
16565
e4b94abfeb96 use generic dialog for cd or addpath question
John W. Eaton <jwe@octave.org>
parents: 16551
diff changeset
329
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
330 return retval;
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
331 }
16547
3cd80afc3509 improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents: 16528
diff changeset
332
27599
ada24a1979c0 improve thread safety of qt_interpreter_events::get_named_icon
John W. Eaton <jwe@octave.org>
parents: 27589
diff changeset
333 uint8NDArray qt_interpreter_events::get_named_icon (const std::string& name)
27442
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
334 {
27599
ada24a1979c0 improve thread safety of qt_interpreter_events::get_named_icon
John W. Eaton <jwe@octave.org>
parents: 27589
diff changeset
335 QMutexLocker autolock (&m_mutex);
ada24a1979c0 improve thread safety of qt_interpreter_events::get_named_icon
John W. Eaton <jwe@octave.org>
parents: 27589
diff changeset
336
ada24a1979c0 improve thread safety of qt_interpreter_events::get_named_icon
John W. Eaton <jwe@octave.org>
parents: 27589
diff changeset
337 emit get_named_icon_signal (QString::fromStdString (name));
ada24a1979c0 improve thread safety of qt_interpreter_events::get_named_icon
John W. Eaton <jwe@octave.org>
parents: 27589
diff changeset
338
ada24a1979c0 improve thread safety of qt_interpreter_events::get_named_icon
John W. Eaton <jwe@octave.org>
parents: 27589
diff changeset
339 // Wait for result.
ada24a1979c0 improve thread safety of qt_interpreter_events::get_named_icon
John W. Eaton <jwe@octave.org>
parents: 27589
diff changeset
340 wait ();
ada24a1979c0 improve thread safety of qt_interpreter_events::get_named_icon
John W. Eaton <jwe@octave.org>
parents: 27589
diff changeset
341
ada24a1979c0 improve thread safety of qt_interpreter_events::get_named_icon
John W. Eaton <jwe@octave.org>
parents: 27589
diff changeset
342 uint8NDArray empty_img;
ada24a1979c0 improve thread safety of qt_interpreter_events::get_named_icon
John W. Eaton <jwe@octave.org>
parents: 27589
diff changeset
343
27600
bb9aecedc167 use single QVariant object for return values in qt_interpreter_events class
John W. Eaton <jwe@octave.org>
parents: 27599
diff changeset
344 QIcon icon = m_result.value<QIcon> ();
bb9aecedc167 use single QVariant object for return values in qt_interpreter_events class
John W. Eaton <jwe@octave.org>
parents: 27599
diff changeset
345
bb9aecedc167 use single QVariant object for return values in qt_interpreter_events class
John W. Eaton <jwe@octave.org>
parents: 27599
diff changeset
346 if (icon.isNull ())
27599
ada24a1979c0 improve thread safety of qt_interpreter_events::get_named_icon
John W. Eaton <jwe@octave.org>
parents: 27589
diff changeset
347 return empty_img;
ada24a1979c0 improve thread safety of qt_interpreter_events::get_named_icon
John W. Eaton <jwe@octave.org>
parents: 27589
diff changeset
348
27600
bb9aecedc167 use single QVariant object for return values in qt_interpreter_events class
John W. Eaton <jwe@octave.org>
parents: 27599
diff changeset
349 QImage img = icon.pixmap (QSize (32, 32)).toImage ();
27599
ada24a1979c0 improve thread safety of qt_interpreter_events::get_named_icon
John W. Eaton <jwe@octave.org>
parents: 27589
diff changeset
350
ada24a1979c0 improve thread safety of qt_interpreter_events::get_named_icon
John W. Eaton <jwe@octave.org>
parents: 27589
diff changeset
351 if (img.format () != QImage::Format_ARGB32_Premultiplied)
ada24a1979c0 improve thread safety of qt_interpreter_events::get_named_icon
John W. Eaton <jwe@octave.org>
parents: 27589
diff changeset
352 return empty_img;
ada24a1979c0 improve thread safety of qt_interpreter_events::get_named_icon
John W. Eaton <jwe@octave.org>
parents: 27589
diff changeset
353
ada24a1979c0 improve thread safety of qt_interpreter_events::get_named_icon
John W. Eaton <jwe@octave.org>
parents: 27589
diff changeset
354 dim_vector dims (img.height (), img.width (), 4);
ada24a1979c0 improve thread safety of qt_interpreter_events::get_named_icon
John W. Eaton <jwe@octave.org>
parents: 27589
diff changeset
355
ada24a1979c0 improve thread safety of qt_interpreter_events::get_named_icon
John W. Eaton <jwe@octave.org>
parents: 27589
diff changeset
356 uint8NDArray retval (dims, 0);
ada24a1979c0 improve thread safety of qt_interpreter_events::get_named_icon
John W. Eaton <jwe@octave.org>
parents: 27589
diff changeset
357
ada24a1979c0 improve thread safety of qt_interpreter_events::get_named_icon
John W. Eaton <jwe@octave.org>
parents: 27589
diff changeset
358 uint8_t *bits = img.bits ();
ada24a1979c0 improve thread safety of qt_interpreter_events::get_named_icon
John W. Eaton <jwe@octave.org>
parents: 27589
diff changeset
359
ada24a1979c0 improve thread safety of qt_interpreter_events::get_named_icon
John W. Eaton <jwe@octave.org>
parents: 27589
diff changeset
360 for (int i = 0; i < img.height (); i++)
27442
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
361 {
27599
ada24a1979c0 improve thread safety of qt_interpreter_events::get_named_icon
John W. Eaton <jwe@octave.org>
parents: 27589
diff changeset
362 for (int j = 0; j < img.width (); j++)
27442
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
363 {
27599
ada24a1979c0 improve thread safety of qt_interpreter_events::get_named_icon
John W. Eaton <jwe@octave.org>
parents: 27589
diff changeset
364 retval(i,j,2) = bits[0];
ada24a1979c0 improve thread safety of qt_interpreter_events::get_named_icon
John W. Eaton <jwe@octave.org>
parents: 27589
diff changeset
365 retval(i,j,1) = bits[1];
ada24a1979c0 improve thread safety of qt_interpreter_events::get_named_icon
John W. Eaton <jwe@octave.org>
parents: 27589
diff changeset
366 retval(i,j,0) = bits[2];
ada24a1979c0 improve thread safety of qt_interpreter_events::get_named_icon
John W. Eaton <jwe@octave.org>
parents: 27589
diff changeset
367 retval(i,j,3) = bits[3];
ada24a1979c0 improve thread safety of qt_interpreter_events::get_named_icon
John W. Eaton <jwe@octave.org>
parents: 27589
diff changeset
368
ada24a1979c0 improve thread safety of qt_interpreter_events::get_named_icon
John W. Eaton <jwe@octave.org>
parents: 27589
diff changeset
369 bits += 4;
27442
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
370 }
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
371 }
27599
ada24a1979c0 improve thread safety of qt_interpreter_events::get_named_icon
John W. Eaton <jwe@octave.org>
parents: 27589
diff changeset
372
27442
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
373 return retval;
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
374 }
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
375
27599
ada24a1979c0 improve thread safety of qt_interpreter_events::get_named_icon
John W. Eaton <jwe@octave.org>
parents: 27589
diff changeset
376 void qt_interpreter_events::get_named_icon_slot (const QString& name)
ada24a1979c0 improve thread safety of qt_interpreter_events::get_named_icon
John W. Eaton <jwe@octave.org>
parents: 27589
diff changeset
377 {
ada24a1979c0 improve thread safety of qt_interpreter_events::get_named_icon
John W. Eaton <jwe@octave.org>
parents: 27589
diff changeset
378 lock ();
ada24a1979c0 improve thread safety of qt_interpreter_events::get_named_icon
John W. Eaton <jwe@octave.org>
parents: 27589
diff changeset
379
27600
bb9aecedc167 use single QVariant object for return values in qt_interpreter_events class
John W. Eaton <jwe@octave.org>
parents: 27599
diff changeset
380 m_result = QVariant::fromValue (resource_manager::icon (name));
27599
ada24a1979c0 improve thread safety of qt_interpreter_events::get_named_icon
John W. Eaton <jwe@octave.org>
parents: 27589
diff changeset
381
ada24a1979c0 improve thread safety of qt_interpreter_events::get_named_icon
John W. Eaton <jwe@octave.org>
parents: 27589
diff changeset
382 unlock ();
ada24a1979c0 improve thread safety of qt_interpreter_events::get_named_icon
John W. Eaton <jwe@octave.org>
parents: 27589
diff changeset
383
ada24a1979c0 improve thread safety of qt_interpreter_events::get_named_icon
John W. Eaton <jwe@octave.org>
parents: 27589
diff changeset
384 wake_all ();
ada24a1979c0 improve thread safety of qt_interpreter_events::get_named_icon
John W. Eaton <jwe@octave.org>
parents: 27589
diff changeset
385 }
ada24a1979c0 improve thread safety of qt_interpreter_events::get_named_icon
John W. Eaton <jwe@octave.org>
parents: 27589
diff changeset
386
27442
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
387 std::string
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
388 qt_interpreter_events::gui_preference (const std::string& key,
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
389 const std::string& value)
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
390 {
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
391 QString pref_value;
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
392
27589
12cfa32dc29e use QMutexLocker to manage locks in qt_interpreter_events methods
John W. Eaton <jwe@octave.org>
parents: 27588
diff changeset
393 QMutexLocker autolock (&m_mutex);
27442
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
394
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
395 // Emit the signal for changing or getting a preference
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
396 emit gui_preference_signal (QString::fromStdString (key),
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
397 QString::fromStdString (value), &pref_value);
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
398
27589
12cfa32dc29e use QMutexLocker to manage locks in qt_interpreter_events methods
John W. Eaton <jwe@octave.org>
parents: 27588
diff changeset
399 // Wait for response (pref_value).
27442
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
400 wait ();
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
401
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
402 return pref_value.toStdString ();
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
403 }
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
404
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
405 bool qt_interpreter_events::copy_image_to_clipboard (const std::string& file)
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
406 {
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
407 emit copy_image_to_clipboard_signal (QString::fromStdString (file), true);
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
408
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
409 return true;
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
410 }
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
411
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
412 void qt_interpreter_events::execute_command_in_terminal
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
413 (const std::string& command)
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
414 {
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
415 emit execute_command_in_terminal_signal (QString::fromStdString (command));
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
416 }
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
417
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
418 void qt_interpreter_events::register_doc (const std::string& file)
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
419 {
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
420 emit register_doc_signal (QString::fromStdString (file));
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
421 }
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
422
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
423 void qt_interpreter_events::unregister_doc (const std::string& file)
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
424 {
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
425 emit unregister_doc_signal (QString::fromStdString (file));
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
426 }
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
427
27409
a0d49e55acae rename change_directory to directory_changed in event manager
John W. Eaton <jwe@octave.org>
parents: 27396
diff changeset
428 void qt_interpreter_events::directory_changed (const std::string& dir)
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
429 {
27409
a0d49e55acae rename change_directory to directory_changed in event manager
John W. Eaton <jwe@octave.org>
parents: 27396
diff changeset
430 emit directory_changed_signal (QString::fromStdString (dir));
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
431 }
16437
919796a440c6 use signal for changing directory
John W. Eaton <jwe@octave.org>
parents: 16432
diff changeset
432
27284
1a8762e5662b remove "do_" prefix from interpreter_events class methods
John W. Eaton <jwe@octave.org>
parents: 27276
diff changeset
433 void qt_interpreter_events::file_remove (const std::string& old_name,
1a8762e5662b remove "do_" prefix from interpreter_events class methods
John W. Eaton <jwe@octave.org>
parents: 27276
diff changeset
434 const std::string& new_name)
25742
d3c6de326bae close/reload editor tab when file is (re)moved in gui terminal (bug #43922)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
435 {
27589
12cfa32dc29e use QMutexLocker to manage locks in qt_interpreter_events methods
John W. Eaton <jwe@octave.org>
parents: 27588
diff changeset
436 QMutexLocker autolock (&m_mutex);
25742
d3c6de326bae close/reload editor tab when file is (re)moved in gui terminal (bug #43922)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
437
d3c6de326bae close/reload editor tab when file is (re)moved in gui terminal (bug #43922)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
438 // Emit the signal for the editor for closing the file if it is open
d3c6de326bae close/reload editor tab when file is (re)moved in gui terminal (bug #43922)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
439 emit file_remove_signal (QString::fromStdString (old_name),
d3c6de326bae close/reload editor tab when file is (re)moved in gui terminal (bug #43922)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
440 QString::fromStdString (new_name));
d3c6de326bae close/reload editor tab when file is (re)moved in gui terminal (bug #43922)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
441
27589
12cfa32dc29e use QMutexLocker to manage locks in qt_interpreter_events methods
John W. Eaton <jwe@octave.org>
parents: 27588
diff changeset
442 // Wait for file removal to complete before continuing.
25742
d3c6de326bae close/reload editor tab when file is (re)moved in gui terminal (bug #43922)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
443 wait ();
d3c6de326bae close/reload editor tab when file is (re)moved in gui terminal (bug #43922)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
444 }
d3c6de326bae close/reload editor tab when file is (re)moved in gui terminal (bug #43922)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
445
27284
1a8762e5662b remove "do_" prefix from interpreter_events class methods
John W. Eaton <jwe@octave.org>
parents: 27276
diff changeset
446 void qt_interpreter_events::file_renamed (bool load_new)
25742
d3c6de326bae close/reload editor tab when file is (re)moved in gui terminal (bug #43922)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
447 {
d3c6de326bae close/reload editor tab when file is (re)moved in gui terminal (bug #43922)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
448 emit file_renamed_signal (load_new);
d3c6de326bae close/reload editor tab when file is (re)moved in gui terminal (bug #43922)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
449 }
d3c6de326bae close/reload editor tab when file is (re)moved in gui terminal (bug #43922)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
450
27284
1a8762e5662b remove "do_" prefix from interpreter_events class methods
John W. Eaton <jwe@octave.org>
parents: 27276
diff changeset
451 void qt_interpreter_events::set_workspace (bool top_level, bool debug,
1a8762e5662b remove "do_" prefix from interpreter_events class methods
John W. Eaton <jwe@octave.org>
parents: 27276
diff changeset
452 const symbol_info_list& syminfo,
1a8762e5662b remove "do_" prefix from interpreter_events class methods
John W. Eaton <jwe@octave.org>
parents: 27276
diff changeset
453 bool update_variable_editor)
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
454 {
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
455 if (! top_level && ! debug)
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
456 return;
19904
793230bb81d4 don't update workspace viewer unless at top level (bug #44156)
John W. Eaton <jwe@octave.org>
parents: 19714
diff changeset
457
26117
a6df420457ac use symbol_info_list instead of symbol_scope to pass workspace info to gui
John W. Eaton <jwe@octave.org>
parents: 25948
diff changeset
458 emit set_workspace_signal (top_level, debug, syminfo);
23927
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents: 23807
diff changeset
459
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
460 if (update_variable_editor)
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
461 emit refresh_variable_editor_signal ();
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
462 }
16468
0f143f68078d use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents: 16443
diff changeset
463
27284
1a8762e5662b remove "do_" prefix from interpreter_events class methods
John W. Eaton <jwe@octave.org>
parents: 27276
diff changeset
464 void qt_interpreter_events::clear_workspace (void)
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
465 {
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
466 emit clear_workspace_signal ();
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
467 }
16415
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
468
27284
1a8762e5662b remove "do_" prefix from interpreter_events class methods
John W. Eaton <jwe@octave.org>
parents: 27276
diff changeset
469 void qt_interpreter_events::set_history (const string_vector& hist)
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
470 {
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
471 QStringList qt_hist;
16431
5982d469f79b use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents: 16426
diff changeset
472
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
473 for (octave_idx_type i = 0; i < hist.numel (); i++)
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
474 qt_hist.append (QString::fromStdString (hist[i]));
16431
5982d469f79b use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents: 16426
diff changeset
475
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
476 emit set_history_signal (qt_hist);
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
477 }
16415
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
478
27284
1a8762e5662b remove "do_" prefix from interpreter_events class methods
John W. Eaton <jwe@octave.org>
parents: 27276
diff changeset
479 void qt_interpreter_events::append_history (const std::string& hist_entry)
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
480 {
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
481 emit append_history_signal (QString::fromStdString (hist_entry));
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
482 }
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
483
27284
1a8762e5662b remove "do_" prefix from interpreter_events class methods
John W. Eaton <jwe@octave.org>
parents: 27276
diff changeset
484 void qt_interpreter_events::clear_history (void)
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
485 {
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
486 emit clear_history_signal ();
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
487 }
16431
5982d469f79b use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents: 16426
diff changeset
488
27284
1a8762e5662b remove "do_" prefix from interpreter_events class methods
John W. Eaton <jwe@octave.org>
parents: 27276
diff changeset
489 void qt_interpreter_events::pre_input_event (void)
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
490 { }
16415
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
491
27284
1a8762e5662b remove "do_" prefix from interpreter_events class methods
John W. Eaton <jwe@octave.org>
parents: 27276
diff changeset
492 void qt_interpreter_events::post_input_event (void)
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
493 { }
16415
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
494
27392
820a87b87c01 clean up use of interpreter in qt_interpreter_events::enter_debugger_event
John W. Eaton <jwe@octave.org>
parents: 27311
diff changeset
495 void qt_interpreter_events::enter_debugger_event (const std::string& /*fcn_name*/,
820a87b87c01 clean up use of interpreter in qt_interpreter_events::enter_debugger_event
John W. Eaton <jwe@octave.org>
parents: 27311
diff changeset
496 const std::string& fcn_file_name,
27284
1a8762e5662b remove "do_" prefix from interpreter_events class methods
John W. Eaton <jwe@octave.org>
parents: 27276
diff changeset
497 int line)
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
498 {
27392
820a87b87c01 clean up use of interpreter in qt_interpreter_events::enter_debugger_event
John W. Eaton <jwe@octave.org>
parents: 27311
diff changeset
499 if (fcn_file_name.empty ())
25557
bb779fc2d0db do not attempt to open a file when debugging a command line fct (bug #54231)
Torsten <mttl@mailbox.org>
parents: 25407
diff changeset
500 return;
bb779fc2d0db do not attempt to open a file when debugging a command line fct (bug #54231)
Torsten <mttl@mailbox.org>
parents: 25407
diff changeset
501
27392
820a87b87c01 clean up use of interpreter in qt_interpreter_events::enter_debugger_event
John W. Eaton <jwe@octave.org>
parents: 27311
diff changeset
502 insert_debugger_pointer (fcn_file_name, line);
16415
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
503
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
504 emit enter_debugger_signal ();
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
505 }
16438
a971d8bdaadc use signals instead of event queue for entering/leaving debug mode
John W. Eaton <jwe@octave.org>
parents: 16437
diff changeset
506
27264
378d3c91f85b style fixes for event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27263
diff changeset
507 void
27284
1a8762e5662b remove "do_" prefix from interpreter_events class methods
John W. Eaton <jwe@octave.org>
parents: 27276
diff changeset
508 qt_interpreter_events::execute_in_debugger_event (const std::string& file,
1a8762e5662b remove "do_" prefix from interpreter_events class methods
John W. Eaton <jwe@octave.org>
parents: 27276
diff changeset
509 int line)
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
510 {
27284
1a8762e5662b remove "do_" prefix from interpreter_events class methods
John W. Eaton <jwe@octave.org>
parents: 27276
diff changeset
511 delete_debugger_pointer (file, line);
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
512 }
16415
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
513
27284
1a8762e5662b remove "do_" prefix from interpreter_events class methods
John W. Eaton <jwe@octave.org>
parents: 27276
diff changeset
514 void qt_interpreter_events::exit_debugger_event (void)
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
515 {
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
516 emit exit_debugger_signal ();
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
517 }
16415
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
518
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
519 // Display (if @insert true) or remove the appropriate symbol for a breakpoint
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
520 // in @file at @line with condition @cond.
27284
1a8762e5662b remove "do_" prefix from interpreter_events class methods
John W. Eaton <jwe@octave.org>
parents: 27276
diff changeset
521 void qt_interpreter_events::update_breakpoint (bool insert,
1a8762e5662b remove "do_" prefix from interpreter_events class methods
John W. Eaton <jwe@octave.org>
parents: 27276
diff changeset
522 const std::string& file,
1a8762e5662b remove "do_" prefix from interpreter_events class methods
John W. Eaton <jwe@octave.org>
parents: 27276
diff changeset
523 int line,
1a8762e5662b remove "do_" prefix from interpreter_events class methods
John W. Eaton <jwe@octave.org>
parents: 27276
diff changeset
524 const std::string& cond)
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
525 {
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
526 emit update_breakpoint_marker_signal (insert, QString::fromStdString (file),
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
527 line, QString::fromStdString (cond));
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
528 }
16438
a971d8bdaadc use signals instead of event queue for entering/leaving debug mode
John W. Eaton <jwe@octave.org>
parents: 16437
diff changeset
529
27264
378d3c91f85b style fixes for event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27263
diff changeset
530 void
27284
1a8762e5662b remove "do_" prefix from interpreter_events class methods
John W. Eaton <jwe@octave.org>
parents: 27276
diff changeset
531 qt_interpreter_events::insert_debugger_pointer (const std::string& file,
1a8762e5662b remove "do_" prefix from interpreter_events class methods
John W. Eaton <jwe@octave.org>
parents: 27276
diff changeset
532 int line)
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
533 {
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
534 emit insert_debugger_pointer_signal (QString::fromStdString (file), line);
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
535 }
17010
c50ee84842a9 Add preferences and prefdir functions
John Donoghue <john.donoghue@ieee.org>
parents: 16658
diff changeset
536
27264
378d3c91f85b style fixes for event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27263
diff changeset
537 void
27284
1a8762e5662b remove "do_" prefix from interpreter_events class methods
John W. Eaton <jwe@octave.org>
parents: 27276
diff changeset
538 qt_interpreter_events::delete_debugger_pointer (const std::string& file,
1a8762e5662b remove "do_" prefix from interpreter_events class methods
John W. Eaton <jwe@octave.org>
parents: 27276
diff changeset
539 int line)
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
540 {
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
541 emit delete_debugger_pointer_signal (QString::fromStdString (file), line);
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
542 }
27588
f0e3f3e28a8e move qt_interpreter_events object from interpreter_qobject to octave_qobject
John W. Eaton <jwe@octave.org>
parents: 27553
diff changeset
543
f0e3f3e28a8e move qt_interpreter_events object from interpreter_qobject to octave_qobject
John W. Eaton <jwe@octave.org>
parents: 27553
diff changeset
544 void
f0e3f3e28a8e move qt_interpreter_events object from interpreter_qobject to octave_qobject
John W. Eaton <jwe@octave.org>
parents: 27553
diff changeset
545 qt_interpreter_events::confirm_shutdown_octave (void)
f0e3f3e28a8e move qt_interpreter_events object from interpreter_qobject to octave_qobject
John W. Eaton <jwe@octave.org>
parents: 27553
diff changeset
546 {
f0e3f3e28a8e move qt_interpreter_events object from interpreter_qobject to octave_qobject
John W. Eaton <jwe@octave.org>
parents: 27553
diff changeset
547 lock ();
f0e3f3e28a8e move qt_interpreter_events object from interpreter_qobject to octave_qobject
John W. Eaton <jwe@octave.org>
parents: 27553
diff changeset
548
27600
bb9aecedc167 use single QVariant object for return values in qt_interpreter_events class
John W. Eaton <jwe@octave.org>
parents: 27599
diff changeset
549 m_result = m_octave_qobj.confirm_shutdown ();
27588
f0e3f3e28a8e move qt_interpreter_events object from interpreter_qobject to octave_qobject
John W. Eaton <jwe@octave.org>
parents: 27553
diff changeset
550
f0e3f3e28a8e move qt_interpreter_events object from interpreter_qobject to octave_qobject
John W. Eaton <jwe@octave.org>
parents: 27553
diff changeset
551 unlock ();
f0e3f3e28a8e move qt_interpreter_events object from interpreter_qobject to octave_qobject
John W. Eaton <jwe@octave.org>
parents: 27553
diff changeset
552
f0e3f3e28a8e move qt_interpreter_events object from interpreter_qobject to octave_qobject
John W. Eaton <jwe@octave.org>
parents: 27553
diff changeset
553 wake_all ();
f0e3f3e28a8e move qt_interpreter_events object from interpreter_qobject to octave_qobject
John W. Eaton <jwe@octave.org>
parents: 27553
diff changeset
554 }
17029
359c5ca795cd Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents: 17010
diff changeset
555 }