annotate libgui/src/octave-qt-link.cc @ 24645:f61502510d08

restore ability to select variables for editing from workspace widget * octave-qt-link.h, octave-qt-link.cc: Declare octave::symbol_scope as a Qt metatype. (octave_qt_link::set_workspace_signal): Pass scope instead of individual lists of scope things. Change all uses. (octave_qt_link::do_set_workspace): Pass scope instead of list of workspace_element objects. * octave-link.h, octave-link.cc (octave_link::set_workspace, octave_link::do_set_workspace): Pass scope instead of list of workspace_element objects. Change all uses. * workspace-model.h, workspace-model.cc (workspace_model::m_scope): New data member. (workspace_model::set_workspace): Pass and store scope instead of individual lists of scope things. Change all uses. (workspace_model::clear_data): Also invalidate m_scope. (workspace_model::update_table): Unpack scope info here without using an intermediate list of workspace elements. (workspace_model::scope): New function. * workspace-view.h, workspace-view.cc (workspace_view::edit_variable_signal): Also pass value object. Change all uses. (workspace_view::setModel): Also extract value from scope. * workspace-element.h: Delete. * libinterp/corefcn/module.mk: Update. * symscope.h, symscope.cc (symbol_scope::workspace_info, symbol_scope::symbol_scope_rep::workspace_info): Delete.
author John W. Eaton <jwe@octave.org>
date Sat, 27 Jan 2018 09:06:50 -0500
parents 7d177be54c37
children ea1c88bd4430
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
23219
3ac9f9ecfae5 maint: Update copyright dates.
John W. Eaton <jwe@octave.org>
parents: 23083
diff changeset
3 Copyright (C) 2013-2017 John W. Eaton
22323
bac0d6f07a3e maint: Update copyright notices for 2016.
John W. Eaton <jwe@octave.org>
parents: 22177
diff changeset
4 Copyright (C) 2011-2016 Jacob Dawid
bac0d6f07a3e maint: Update copyright notices for 2016.
John W. Eaton <jwe@octave.org>
parents: 22177
diff changeset
5 Copyright (C) 2011-2016 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>
24641
7d177be54c37 pass variable value to variable editor in addition to variable name
John W. Eaton <jwe@octave.org>
parents: 24632
diff changeset
31 #include <QMetaType>
21158
65827e9cccb8 Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21148
diff changeset
32 #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
33 #include <QStringList>
16431
5982d469f79b use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents: 16426
diff changeset
34
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
35 #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
36 #include "str-vec.h"
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
37
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
38 #include "builtin-defun-decls.h"
16512
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
39 #include "dialog.h"
16547
3cd80afc3509 improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents: 16528
diff changeset
40 #include "error.h"
23438
d24d01273bd0 eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
41 #include "interpreter-private.h"
16635
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16581
diff changeset
42 #include "load-path.h"
24641
7d177be54c37 pass variable value to variable editor in addition to variable name
John W. Eaton <jwe@octave.org>
parents: 24632
diff changeset
43 #include "ov.h"
24645
f61502510d08 restore ability to select variables for editing from workspace widget
John W. Eaton <jwe@octave.org>
parents: 24641
diff changeset
44 #include "symscope.h"
16635
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16581
diff changeset
45 #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
46
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
47 #include "octave-gui.h"
16415
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
48 #include "octave-qt-link.h"
17884
766ad9be2966 Prompt for non-existent new file when using edit.m from GUI (bug #40450)
Torsten <ttl@justmail.de>
parents: 17824
diff changeset
49 #include "resource-manager.h"
24645
f61502510d08 restore ability to select variables for editing from workspace widget
John W. Eaton <jwe@octave.org>
parents: 24641
diff changeset
50
f61502510d08 restore ability to select variables for editing from workspace widget
John W. Eaton <jwe@octave.org>
parents: 24641
diff changeset
51 Q_DECLARE_METATYPE (octave_value)
f61502510d08 restore ability to select variables for editing from workspace widget
John W. Eaton <jwe@octave.org>
parents: 24641
diff changeset
52 Q_DECLARE_METATYPE (octave::symbol_scope)
17884
766ad9be2966 Prompt for non-existent new file when using edit.m from GUI (bug #40450)
Torsten <ttl@justmail.de>
parents: 17824
diff changeset
53
23128
982042b59c0a build: Eliminate unused parameter warning in octave-qt-link.cc.
Rik <rik@octave.org>
parents: 23119
diff changeset
54 octave_qt_link::octave_qt_link (QWidget *,
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
55 octave::gui_application *app_context)
23119
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
56 : octave_link (), m_app_context (app_context)
24641
7d177be54c37 pass variable value to variable editor in addition to variable name
John W. Eaton <jwe@octave.org>
parents: 24632
diff changeset
57 {
7d177be54c37 pass variable value to variable editor in addition to variable name
John W. Eaton <jwe@octave.org>
parents: 24632
diff changeset
58 qRegisterMetaType<octave_value> ("octave_value");
24645
f61502510d08 restore ability to select variables for editing from workspace widget
John W. Eaton <jwe@octave.org>
parents: 24641
diff changeset
59 qRegisterMetaType<octave::symbol_scope> ("symbol_scope");
24641
7d177be54c37 pass variable value to variable editor in addition to variable name
John W. Eaton <jwe@octave.org>
parents: 24632
diff changeset
60 }
16415
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
61
16443
7a2ee6ea7800 rename dbstop -> breakpoint in GUI interface functions
John W. Eaton <jwe@octave.org>
parents: 16438
diff changeset
62 bool
19714
21015ca26566 Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19697
diff changeset
63 octave_qt_link::do_confirm_shutdown (void)
21015ca26566 Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19697
diff changeset
64 {
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
65 // Lock the mutex before emitting signal.
24016
e327adeae7a0 hide mutex and wait condition data members in GUI objects
John W. Eaton <jwe@octave.org>
parents: 24015
diff changeset
66 lock ();
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
67
19714
21015ca26566 Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19697
diff changeset
68 emit confirm_shutdown_signal ();
21015ca26566 Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19697
diff changeset
69
21015ca26566 Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19697
diff changeset
70 // Wait while the GUI shuts down.
24016
e327adeae7a0 hide mutex and wait condition data members in GUI objects
John W. Eaton <jwe@octave.org>
parents: 24015
diff changeset
71 wait ();
19714
21015ca26566 Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19697
diff changeset
72
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
73 // The GUI has sent a signal and the thread has been awakened.
89d843d6de14 Add mutex lock to shutdown confirmation for proper thread timing (bug #44751).
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19970
diff changeset
74
24016
e327adeae7a0 hide mutex and wait condition data members in GUI objects
John W. Eaton <jwe@octave.org>
parents: 24015
diff changeset
75 unlock ();
19714
21015ca26566 Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19697
diff changeset
76
24015
5ecefb7425e3 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 24005
diff changeset
77 return m_shutdown_confirm_result;
16485
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16479
diff changeset
78 }
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16479
diff changeset
79
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16479
diff changeset
80 bool
20113
c36f2b083613 make copying figures to clipboard work (bug #44866)
John W. Eaton <jwe@octave.org>
parents: 20091
diff changeset
81 octave_qt_link::do_copy_image_to_clipboard (const std::string& file)
c36f2b083613 make copying figures to clipboard work (bug #44866)
John W. Eaton <jwe@octave.org>
parents: 20091
diff changeset
82 {
c36f2b083613 make copying figures to clipboard work (bug #44866)
John W. Eaton <jwe@octave.org>
parents: 20091
diff changeset
83 emit copy_image_to_clipboard_signal (QString::fromStdString (file), true);
c36f2b083613 make copying figures to clipboard work (bug #44866)
John W. Eaton <jwe@octave.org>
parents: 20091
diff changeset
84
c36f2b083613 make copying figures to clipboard work (bug #44866)
John W. Eaton <jwe@octave.org>
parents: 20091
diff changeset
85 return true;
c36f2b083613 make copying figures to clipboard work (bug #44866)
John W. Eaton <jwe@octave.org>
parents: 20091
diff changeset
86 }
c36f2b083613 make copying figures to clipboard work (bug #44866)
John W. Eaton <jwe@octave.org>
parents: 20091
diff changeset
87
c36f2b083613 make copying figures to clipboard work (bug #44866)
John W. Eaton <jwe@octave.org>
parents: 20091
diff changeset
88 bool
16443
7a2ee6ea7800 rename dbstop -> breakpoint in GUI interface functions
John W. Eaton <jwe@octave.org>
parents: 16438
diff changeset
89 octave_qt_link::do_edit_file (const std::string& file)
7a2ee6ea7800 rename dbstop -> breakpoint in GUI interface functions
John W. Eaton <jwe@octave.org>
parents: 16438
diff changeset
90 {
7a2ee6ea7800 rename dbstop -> breakpoint in GUI interface functions
John W. Eaton <jwe@octave.org>
parents: 16438
diff changeset
91 emit edit_file_signal (QString::fromStdString (file));
7a2ee6ea7800 rename dbstop -> breakpoint in GUI interface functions
John W. Eaton <jwe@octave.org>
parents: 16438
diff changeset
92
7a2ee6ea7800 rename dbstop -> breakpoint in GUI interface functions
John W. Eaton <jwe@octave.org>
parents: 16438
diff changeset
93 return true;
7a2ee6ea7800 rename dbstop -> breakpoint in GUI interface functions
John W. Eaton <jwe@octave.org>
parents: 16438
diff changeset
94 }
7a2ee6ea7800 rename dbstop -> breakpoint in GUI interface functions
John W. Eaton <jwe@octave.org>
parents: 16438
diff changeset
95
17884
766ad9be2966 Prompt for non-existent new file when using edit.m from GUI (bug #40450)
Torsten <ttl@justmail.de>
parents: 17824
diff changeset
96 bool
766ad9be2966 Prompt for non-existent new file when using edit.m from GUI (bug #40450)
Torsten <ttl@justmail.de>
parents: 17824
diff changeset
97 octave_qt_link::do_prompt_new_edit_file (const std::string& file)
766ad9be2966 Prompt for non-existent new file when using edit.m from GUI (bug #40450)
Torsten <ttl@justmail.de>
parents: 17824
diff changeset
98 {
766ad9be2966 Prompt for non-existent new file when using edit.m from GUI (bug #40450)
Torsten <ttl@justmail.de>
parents: 17824
diff changeset
99 QSettings *settings = resource_manager::get_settings ();
766ad9be2966 Prompt for non-existent new file when using edit.m from GUI (bug #40450)
Torsten <ttl@justmail.de>
parents: 17824
diff changeset
100
22177
6e9f5408c0db Save settings in Qt convention, delete all children in destructors (bug #45366)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 22173
diff changeset
101 if (! settings || settings->value ("editor/create_new_file",false).toBool ())
17884
766ad9be2966 Prompt for non-existent new file when using edit.m from GUI (bug #40450)
Torsten <ttl@justmail.de>
parents: 17824
diff changeset
102 return true;
766ad9be2966 Prompt for non-existent new file when using edit.m from GUI (bug #40450)
Torsten <ttl@justmail.de>
parents: 17824
diff changeset
103
766ad9be2966 Prompt for non-existent new file when using edit.m from GUI (bug #40450)
Torsten <ttl@justmail.de>
parents: 17824
diff changeset
104 QFileInfo file_info (QString::fromStdString (file));
766ad9be2966 Prompt for non-existent new file when using edit.m from GUI (bug #40450)
Torsten <ttl@justmail.de>
parents: 17824
diff changeset
105 QStringList btn;
766ad9be2966 Prompt for non-existent new file when using edit.m from GUI (bug #40450)
Torsten <ttl@justmail.de>
parents: 17824
diff changeset
106 QStringList role;
19314
2b708273548d button order in dialog for creating a non-existing file (bug #43537)
Torsten <ttl@justmail.de>
parents: 18345
diff changeset
107 role << "YesRole" << "RejectRole";
2b708273548d button order in dialog for creating a non-existing file (bug #43537)
Torsten <ttl@justmail.de>
parents: 18345
diff changeset
108 btn << tr ("Create") << tr ("Cancel");
17884
766ad9be2966 Prompt for non-existent new file when using edit.m from GUI (bug #40450)
Torsten <ttl@justmail.de>
parents: 17824
diff changeset
109
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
110 // Lock mutex before signaling.
24016
e327adeae7a0 hide mutex and wait condition data members in GUI objects
John W. Eaton <jwe@octave.org>
parents: 24015
diff changeset
111 uiwidget_creator.lock ();
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
112
17884
766ad9be2966 Prompt for non-existent new file when using edit.m from GUI (bug #40450)
Torsten <ttl@justmail.de>
parents: 17824
diff changeset
113 uiwidget_creator.signal_dialog (
766ad9be2966 Prompt for non-existent new file when using edit.m from GUI (bug #40450)
Torsten <ttl@justmail.de>
parents: 17824
diff changeset
114 tr ("File\n%1\ndoes not exist. Do you want to create it?").
766ad9be2966 Prompt for non-existent new file when using edit.m from GUI (bug #40450)
Torsten <ttl@justmail.de>
parents: 17824
diff changeset
115 arg (QDir::currentPath () + QDir::separator ()
766ad9be2966 Prompt for non-existent new file when using edit.m from GUI (bug #40450)
Torsten <ttl@justmail.de>
parents: 17824
diff changeset
116 + QString::fromStdString (file)),
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
117 tr ("Octave Editor"), "quest", btn, tr ("Create"), role);
17884
766ad9be2966 Prompt for non-existent new file when using edit.m from GUI (bug #40450)
Torsten <ttl@justmail.de>
parents: 17824
diff changeset
118
766ad9be2966 Prompt for non-existent new file when using edit.m from GUI (bug #40450)
Torsten <ttl@justmail.de>
parents: 17824
diff changeset
119 // Wait while the user is responding to message box.
24016
e327adeae7a0 hide mutex and wait condition data members in GUI objects
John W. Eaton <jwe@octave.org>
parents: 24015
diff changeset
120 uiwidget_creator.wait ();
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
121
89d843d6de14 Add mutex lock to shutdown confirmation for proper thread timing (bug #44751).
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19970
diff changeset
122 // The GUI has sent a signal and the thread has been awakened.
89d843d6de14 Add mutex lock to shutdown confirmation for proper thread timing (bug #44751).
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19970
diff changeset
123
17884
766ad9be2966 Prompt for non-existent new file when using edit.m from GUI (bug #40450)
Torsten <ttl@justmail.de>
parents: 17824
diff changeset
124 QString answer = uiwidget_creator.get_dialog_button ();
766ad9be2966 Prompt for non-existent new file when using edit.m from GUI (bug #40450)
Torsten <ttl@justmail.de>
parents: 17824
diff changeset
125
24016
e327adeae7a0 hide mutex and wait condition data members in GUI objects
John W. Eaton <jwe@octave.org>
parents: 24015
diff changeset
126 uiwidget_creator.unlock ();
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
127
19314
2b708273548d button order in dialog for creating a non-existing file (bug #43537)
Torsten <ttl@justmail.de>
parents: 18345
diff changeset
128 return (answer == tr ("Create"));
17884
766ad9be2966 Prompt for non-existent new file when using edit.m from GUI (bug #40450)
Torsten <ttl@justmail.de>
parents: 17824
diff changeset
129 }
766ad9be2966 Prompt for non-existent new file when using edit.m from GUI (bug #40450)
Torsten <ttl@justmail.de>
parents: 17824
diff changeset
130
16512
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
131 int
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
132 octave_qt_link::do_message_dialog (const std::string& dlg,
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
133 const std::string& msg,
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
134 const std::string& title)
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
135 {
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
136 // Lock mutex before signaling.
24016
e327adeae7a0 hide mutex and wait condition data members in GUI objects
John W. Eaton <jwe@octave.org>
parents: 24015
diff changeset
137 uiwidget_creator.lock ();
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
138
16512
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
139 uiwidget_creator.signal_dialog (QString::fromStdString (msg),
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
140 QString::fromStdString (title),
16551
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16547
diff changeset
141 QString::fromStdString (dlg),
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16547
diff changeset
142 QStringList (), QString (),
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16547
diff changeset
143 QStringList ());
16512
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
144
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
145 // Wait while the user is responding to message box.
24016
e327adeae7a0 hide mutex and wait condition data members in GUI objects
John W. Eaton <jwe@octave.org>
parents: 24015
diff changeset
146 uiwidget_creator.wait ();
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
147
89d843d6de14 Add mutex lock to shutdown confirmation for proper thread timing (bug #44751).
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19970
diff changeset
148 // The GUI has sent a signal and the thread has been awakened.
16512
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
149
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
150 int answer = uiwidget_creator.get_dialog_result ();
89d843d6de14 Add mutex lock to shutdown confirmation for proper thread timing (bug #44751).
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19970
diff changeset
151
24016
e327adeae7a0 hide mutex and wait condition data members in GUI objects
John W. Eaton <jwe@octave.org>
parents: 24015
diff changeset
152 uiwidget_creator.unlock ();
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
153
89d843d6de14 Add mutex lock to shutdown confirmation for proper thread timing (bug #44751).
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19970
diff changeset
154 return answer;
16512
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
155 }
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
156
16551
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16547
diff changeset
157 std::string
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16547
diff changeset
158 octave_qt_link::do_question_dialog (const std::string& msg,
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16547
diff changeset
159 const std::string& title,
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16547
diff changeset
160 const std::string& btn1,
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16547
diff changeset
161 const std::string& btn2,
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16547
diff changeset
162 const std::string& btn3,
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16547
diff changeset
163 const std::string& btndef)
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16547
diff changeset
164 {
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16547
diff changeset
165 QStringList btn;
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16547
diff changeset
166 QStringList role;
22807
b57fed33be6a Further fix to questdlg button order on all platforms (bug #49644).
Rik <rik@octave.org>
parents: 22755
diff changeset
167 // Must use ResetRole which is left-aligned for all OS and WM.
b57fed33be6a Further fix to questdlg button order on all platforms (bug #49644).
Rik <rik@octave.org>
parents: 22755
diff changeset
168 role << "ResetRole" << "ResetRole" << "ResetRole";
16551
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16547
diff changeset
169 btn << QString::fromStdString (btn1);
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16547
diff changeset
170 if (btn2 == "")
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16547
diff changeset
171 role.removeAt (0);
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16547
diff changeset
172 else
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16547
diff changeset
173 btn << QString::fromStdString (btn2);
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16547
diff changeset
174 btn << QString::fromStdString (btn3);
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16547
diff changeset
175
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
176 // Lock mutex before signaling.
24016
e327adeae7a0 hide mutex and wait condition data members in GUI objects
John W. Eaton <jwe@octave.org>
parents: 24015
diff changeset
177 uiwidget_creator.lock ();
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
178
16551
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16547
diff changeset
179 uiwidget_creator.signal_dialog (QString::fromStdString (msg),
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16547
diff changeset
180 QString::fromStdString (title),
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16547
diff changeset
181 "quest",
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16547
diff changeset
182 btn,
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16547
diff changeset
183 QString::fromStdString (btndef),
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16547
diff changeset
184 role);
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16547
diff changeset
185
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16547
diff changeset
186 // Wait while the user is responding to message box.
24016
e327adeae7a0 hide mutex and wait condition data members in GUI objects
John W. Eaton <jwe@octave.org>
parents: 24015
diff changeset
187 uiwidget_creator.wait ();
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
188
89d843d6de14 Add mutex lock to shutdown confirmation for proper thread timing (bug #44751).
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19970
diff changeset
189 // The GUI has sent a signal and the thread has been awakened.
16551
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16547
diff changeset
190
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
191 std::string answer = uiwidget_creator.get_dialog_button ().toStdString ();
89d843d6de14 Add mutex lock to shutdown confirmation for proper thread timing (bug #44751).
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19970
diff changeset
192
24016
e327adeae7a0 hide mutex and wait condition data members in GUI objects
John W. Eaton <jwe@octave.org>
parents: 24015
diff changeset
193 uiwidget_creator.unlock ();
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
194
89d843d6de14 Add mutex lock to shutdown confirmation for proper thread timing (bug #44751).
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19970
diff changeset
195 return answer;
16551
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16547
diff changeset
196 }
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16547
diff changeset
197
16512
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
198 static QStringList
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
199 make_qstring_list (const std::list<std::string>& lst)
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
200 {
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
201 QStringList retval;
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
202
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
203 for (std::list<std::string>::const_iterator it = lst.begin ();
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
204 it != lst.end (); it++)
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
205 {
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
206 retval.append (QString::fromStdString (*it));
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
207 }
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
208
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
209 return retval;
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
210 }
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
211
16579
7f8db1942dc0 Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents: 16570
diff changeset
212 static QStringList
16580
adc150db1809 style fixes for uigetfile changes
John W. Eaton <jwe@octave.org>
parents: 16579
diff changeset
213 make_filter_list (const octave_link::filter_list& lst)
16579
7f8db1942dc0 Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents: 16570
diff changeset
214 {
7f8db1942dc0 Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents: 16570
diff changeset
215 QStringList retval;
7f8db1942dc0 Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents: 16570
diff changeset
216
16580
adc150db1809 style fixes for uigetfile changes
John W. Eaton <jwe@octave.org>
parents: 16579
diff changeset
217 // We have pairs of data, first being the list of extensions
adc150db1809 style fixes for uigetfile changes
John W. Eaton <jwe@octave.org>
parents: 16579
diff changeset
218 // exta;exb;extc etc second the name to use as filter name
22173
8de49f15e182 doc: Fix "doubled words" typos (\b(\w+)\s+\1\b)
Andreas Weber <andy.weber.aw@gmail.com>
parents: 22089
diff changeset
219 // (optional). Qt wants a list of filters in the format of
16580
adc150db1809 style fixes for uigetfile changes
John W. Eaton <jwe@octave.org>
parents: 16579
diff changeset
220 // 'FilterName (space separated exts)'.
16579
7f8db1942dc0 Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents: 16570
diff changeset
221
16580
adc150db1809 style fixes for uigetfile changes
John W. Eaton <jwe@octave.org>
parents: 16579
diff changeset
222 for (octave_link::filter_list::const_iterator it = lst.begin ();
16579
7f8db1942dc0 Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents: 16570
diff changeset
223 it != lst.end (); it++)
7f8db1942dc0 Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents: 16570
diff changeset
224 {
16580
adc150db1809 style fixes for uigetfile changes
John W. Eaton <jwe@octave.org>
parents: 16579
diff changeset
225 QString ext = QString::fromStdString (it->first);
adc150db1809 style fixes for uigetfile changes
John W. Eaton <jwe@octave.org>
parents: 16579
diff changeset
226 QString name = QString::fromStdString (it->second);
16579
7f8db1942dc0 Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents: 16570
diff changeset
227
16580
adc150db1809 style fixes for uigetfile changes
John W. Eaton <jwe@octave.org>
parents: 16579
diff changeset
228 // Strip out extensions from name and replace ';' with spaces in
adc150db1809 style fixes for uigetfile changes
John W. Eaton <jwe@octave.org>
parents: 16579
diff changeset
229 // list.
adc150db1809 style fixes for uigetfile changes
John W. Eaton <jwe@octave.org>
parents: 16579
diff changeset
230
adc150db1809 style fixes for uigetfile changes
John W. Eaton <jwe@octave.org>
parents: 16579
diff changeset
231 name.replace (QRegExp ("\\(.*\\)"), "");
adc150db1809 style fixes for uigetfile changes
John W. Eaton <jwe@octave.org>
parents: 16579
diff changeset
232 ext.replace (";", " ");
16579
7f8db1942dc0 Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents: 16570
diff changeset
233
21885
0806871e3e1e maint: Prefer is_empty() rather than "length () == 0".
Rik <rik@octave.org>
parents: 21852
diff changeset
234 if (name.isEmpty ())
16579
7f8db1942dc0 Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents: 16570
diff changeset
235 {
16580
adc150db1809 style fixes for uigetfile changes
John W. Eaton <jwe@octave.org>
parents: 16579
diff changeset
236 // No name field. Build one from the extensions.
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
237 name = ext.toUpper () + " Files";
16579
7f8db1942dc0 Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents: 16570
diff changeset
238 }
7f8db1942dc0 Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents: 16570
diff changeset
239
23807
336f89b6208b Use character literals 'c' rather than string literals "c" when possible.
Rik <rik@octave.org>
parents: 23445
diff changeset
240 retval.append (name + " (" + ext + ')');
16579
7f8db1942dc0 Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents: 16570
diff changeset
241 }
7f8db1942dc0 Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents: 16570
diff changeset
242
7f8db1942dc0 Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents: 16570
diff changeset
243 return retval;
7f8db1942dc0 Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents: 16570
diff changeset
244 }
16512
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
245
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
246 std::pair<std::list<int>, int>
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
247 octave_qt_link::do_list_dialog (const std::list<std::string>& list,
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
248 const std::string& mode,
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
249 int width, int height,
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
250 const std::list<int>& initial,
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
251 const std::string& name,
16551
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16547
diff changeset
252 const std::list<std::string>& prompt,
16512
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
253 const std::string& ok_string,
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
254 const std::string& cancel_string)
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
255 {
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
256 // Lock mutex before signaling.
24016
e327adeae7a0 hide mutex and wait condition data members in GUI objects
John W. Eaton <jwe@octave.org>
parents: 24015
diff changeset
257 uiwidget_creator.lock ();
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
258
16512
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
259 uiwidget_creator.signal_listview (make_qstring_list (list),
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
260 QString::fromStdString (mode),
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
261 width, height,
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
262 QList<int>::fromStdList (initial),
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
263 QString::fromStdString (name),
16551
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16547
diff changeset
264 make_qstring_list (prompt),
16512
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
265 QString::fromStdString (ok_string),
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
266 QString::fromStdString (cancel_string));
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
267
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
268 // Wait while the user is responding to message box.
24016
e327adeae7a0 hide mutex and wait condition data members in GUI objects
John W. Eaton <jwe@octave.org>
parents: 24015
diff changeset
269 uiwidget_creator.wait ();
16512
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
270
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
271 // The GUI has sent a signal and the thread has been awakened.
89d843d6de14 Add mutex lock to shutdown confirmation for proper thread timing (bug #44751).
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19970
diff changeset
272
16512
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
273 const QIntList *selected = uiwidget_creator.get_list_index ();
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
274 int ok = uiwidget_creator.get_dialog_result ();
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
275
24016
e327adeae7a0 hide mutex and wait condition data members in GUI objects
John W. Eaton <jwe@octave.org>
parents: 24015
diff changeset
276 uiwidget_creator.unlock ();
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
277
16512
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
278 return std::pair<std::list<int>, int> (selected->toStdList (), ok);
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
279 }
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
280
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
281 std::list<std::string>
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
282 octave_qt_link::do_input_dialog (const std::list<std::string>& prompt,
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
283 const std::string& title,
16551
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16547
diff changeset
284 const std::list<float>& nr,
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16547
diff changeset
285 const std::list<float>& nc,
16512
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
286 const std::list<std::string>& defaults)
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
287 {
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
288 std::list<std::string> retval;
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
289
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
290 // Lock mutex before signaling.
24016
e327adeae7a0 hide mutex and wait condition data members in GUI objects
John W. Eaton <jwe@octave.org>
parents: 24015
diff changeset
291 uiwidget_creator.lock ();
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
292
16512
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
293 uiwidget_creator.signal_inputlayout (make_qstring_list (prompt),
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
294 QString::fromStdString (title),
16551
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16547
diff changeset
295 QFloatList::fromStdList (nr),
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16547
diff changeset
296 QFloatList::fromStdList (nc),
16512
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
297 make_qstring_list (defaults));
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
298
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
299 // Wait while the user is responding to message box.
24016
e327adeae7a0 hide mutex and wait condition data members in GUI objects
John W. Eaton <jwe@octave.org>
parents: 24015
diff changeset
300 uiwidget_creator.wait ();
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
301
89d843d6de14 Add mutex lock to shutdown confirmation for proper thread timing (bug #44751).
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19970
diff changeset
302 // The GUI has sent a signal and the thread has been awakened.
16512
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
303
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
304 const QStringList *inputLine = uiwidget_creator.get_string_list ();
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
305
24016
e327adeae7a0 hide mutex and wait condition data members in GUI objects
John W. Eaton <jwe@octave.org>
parents: 24015
diff changeset
306 uiwidget_creator.unlock ();
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
307
16512
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
308 for (QStringList::const_iterator it = inputLine->begin ();
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
309 it != inputLine->end (); it++)
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
310 {
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
311 retval.push_back (it->toStdString ());
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
312 }
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
313
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
314 return retval;
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
315 }
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
316
16579
7f8db1942dc0 Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents: 16570
diff changeset
317 std::list<std::string>
16580
adc150db1809 style fixes for uigetfile changes
John W. Eaton <jwe@octave.org>
parents: 16579
diff changeset
318 octave_qt_link::do_file_dialog (const filter_list& filter,
16579
7f8db1942dc0 Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents: 16570
diff changeset
319 const std::string& title,
7f8db1942dc0 Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents: 16570
diff changeset
320 const std::string& filename,
7f8db1942dc0 Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents: 16570
diff changeset
321 const std::string& dirname,
16581
fa4a035e0cf4 Add octave_link uiputfile implementation
John Donoghue <john.donoghue@ieee.org>
parents: 16580
diff changeset
322 const std::string& multimode)
16579
7f8db1942dc0 Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents: 16570
diff changeset
323 {
7f8db1942dc0 Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents: 16570
diff changeset
324 std::list<std::string> retval;
7f8db1942dc0 Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents: 16570
diff changeset
325
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
326 // Lock mutex before signaling.
24016
e327adeae7a0 hide mutex and wait condition data members in GUI objects
John W. Eaton <jwe@octave.org>
parents: 24015
diff changeset
327 uiwidget_creator.lock ();
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
328
16580
adc150db1809 style fixes for uigetfile changes
John W. Eaton <jwe@octave.org>
parents: 16579
diff changeset
329 uiwidget_creator.signal_filedialog (make_filter_list (filter),
adc150db1809 style fixes for uigetfile changes
John W. Eaton <jwe@octave.org>
parents: 16579
diff changeset
330 QString::fromStdString (title),
adc150db1809 style fixes for uigetfile changes
John W. Eaton <jwe@octave.org>
parents: 16579
diff changeset
331 QString::fromStdString (filename),
adc150db1809 style fixes for uigetfile changes
John W. Eaton <jwe@octave.org>
parents: 16579
diff changeset
332 QString::fromStdString (dirname),
16581
fa4a035e0cf4 Add octave_link uiputfile implementation
John Donoghue <john.donoghue@ieee.org>
parents: 16580
diff changeset
333 QString::fromStdString (multimode));
16579
7f8db1942dc0 Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents: 16570
diff changeset
334
7f8db1942dc0 Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents: 16570
diff changeset
335 // Wait while the user is responding to dialog.
24016
e327adeae7a0 hide mutex and wait condition data members in GUI objects
John W. Eaton <jwe@octave.org>
parents: 24015
diff changeset
336 uiwidget_creator.wait ();
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
337
89d843d6de14 Add mutex lock to shutdown confirmation for proper thread timing (bug #44751).
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19970
diff changeset
338 // The GUI has sent a signal and the thread has been awakened.
16579
7f8db1942dc0 Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents: 16570
diff changeset
339
16580
adc150db1809 style fixes for uigetfile changes
John W. Eaton <jwe@octave.org>
parents: 16579
diff changeset
340 // Add all the file dialog results to a string list.
16579
7f8db1942dc0 Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents: 16570
diff changeset
341 const QStringList *inputLine = uiwidget_creator.get_string_list ();
7f8db1942dc0 Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents: 16570
diff changeset
342
7f8db1942dc0 Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents: 16570
diff changeset
343 for (QStringList::const_iterator it = inputLine->begin ();
7f8db1942dc0 Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents: 16570
diff changeset
344 it != inputLine->end (); it++)
16580
adc150db1809 style fixes for uigetfile changes
John W. Eaton <jwe@octave.org>
parents: 16579
diff changeset
345 retval.push_back (it->toStdString ());
16579
7f8db1942dc0 Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents: 16570
diff changeset
346
7f8db1942dc0 Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents: 16570
diff changeset
347 retval.push_back (uiwidget_creator.get_dialog_path ()->toStdString ());
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
348 retval.push_back ((QString ("%1").arg (
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
349 uiwidget_creator.get_dialog_result ())).toStdString ());
16579
7f8db1942dc0 Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents: 16570
diff changeset
350
24016
e327adeae7a0 hide mutex and wait condition data members in GUI objects
John W. Eaton <jwe@octave.org>
parents: 24015
diff changeset
351 uiwidget_creator.unlock ();
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
352
16579
7f8db1942dc0 Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents: 16570
diff changeset
353 return retval;
7f8db1942dc0 Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents: 16570
diff changeset
354 }
7f8db1942dc0 Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents: 16570
diff changeset
355
21158
65827e9cccb8 Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21148
diff changeset
356 // Prompt to allow file to be run by setting cwd (or if addpath_option==true,
65827e9cccb8 Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21148
diff changeset
357 // alternatively setting the path).
65827e9cccb8 Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21148
diff changeset
358 // This uses a QMessageBox unlike other functions in this file,
65827e9cccb8 Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21148
diff changeset
359 // because uiwidget_creator.waitcondition.wait hangs when called from
21578
683a1beee538 maint: Use "FIXME:" for all code blocks needing further attention.
Rik <rik@octave.org>
parents: 21440
diff changeset
360 // file_editor_tab::handle_context_menu_break_condition(). (FIXME: why hang?)
16547
3cd80afc3509 improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents: 16528
diff changeset
361 int
3cd80afc3509 improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents: 16528
diff changeset
362 octave_qt_link::do_debug_cd_or_addpath_error (const std::string& file,
3cd80afc3509 improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents: 16528
diff changeset
363 const std::string& dir,
3cd80afc3509 improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents: 16528
diff changeset
364 bool addpath_option)
3cd80afc3509 improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents: 16528
diff changeset
365 {
16565
e4b94abfeb96 use generic dialog for cd or addpath question
John W. Eaton <jwe@octave.org>
parents: 16551
diff changeset
366 int retval = -1;
e4b94abfeb96 use generic dialog for cd or addpath question
John W. Eaton <jwe@octave.org>
parents: 16551
diff changeset
367
e4b94abfeb96 use generic dialog for cd or addpath question
John W. Eaton <jwe@octave.org>
parents: 16551
diff changeset
368 QString qdir = QString::fromStdString (dir);
e4b94abfeb96 use generic dialog for cd or addpath question
John W. Eaton <jwe@octave.org>
parents: 16551
diff changeset
369 QString qfile = QString::fromStdString (file);
21311
718332a58d35 Fix left mouse button in editor margin bug from cset 65827e9cccb8
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21310
diff changeset
370 QString msg
718332a58d35 Fix left mouse button in editor margin bug from cset 65827e9cccb8
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21310
diff changeset
371 = (addpath_option
718332a58d35 Fix left mouse button in editor margin bug from cset 65827e9cccb8
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21310
diff changeset
372 ? 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)
718332a58d35 Fix left mouse button in editor margin bug from cset 65827e9cccb8
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21310
diff changeset
373 : 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
374
21311
718332a58d35 Fix left mouse button in editor margin bug from cset 65827e9cccb8
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21310
diff changeset
375 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
376
24298
793779033e2c prevent extra ampersand under KDE in cd-or-add-to-path dialog (bug #52423)
Torsten <mttl@mailbox.org>
parents: 24004
diff changeset
377 QString cd_txt = tr ("&Change Directory");
793779033e2c prevent extra ampersand under KDE in cd-or-add-to-path dialog (bug #52423)
Torsten <mttl@mailbox.org>
parents: 24004
diff changeset
378 QString addpath_txt = tr ("&Add Directory to Load Path");
21311
718332a58d35 Fix left mouse button in editor margin bug from cset 65827e9cccb8
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21310
diff changeset
379 QString cancel_txt = tr ("Cancel");
16547
3cd80afc3509 improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents: 16528
diff changeset
380
21311
718332a58d35 Fix left mouse button in editor margin bug from cset 65827e9cccb8
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21310
diff changeset
381 QStringList btn;
718332a58d35 Fix left mouse button in editor margin bug from cset 65827e9cccb8
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21310
diff changeset
382 QStringList role;
718332a58d35 Fix left mouse button in editor margin bug from cset 65827e9cccb8
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21310
diff changeset
383 btn << cd_txt;
718332a58d35 Fix left mouse button in editor margin bug from cset 65827e9cccb8
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21310
diff changeset
384 role << "YesRole";
16565
e4b94abfeb96 use generic dialog for cd or addpath question
John W. Eaton <jwe@octave.org>
parents: 16551
diff changeset
385 if (addpath_option)
e4b94abfeb96 use generic dialog for cd or addpath question
John W. Eaton <jwe@octave.org>
parents: 16551
diff changeset
386 {
21311
718332a58d35 Fix left mouse button in editor margin bug from cset 65827e9cccb8
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21310
diff changeset
387 btn << addpath_txt;
718332a58d35 Fix left mouse button in editor margin bug from cset 65827e9cccb8
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21310
diff changeset
388 role << "AcceptRole";
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
389 }
21311
718332a58d35 Fix left mouse button in editor margin bug from cset 65827e9cccb8
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21310
diff changeset
390 btn << cancel_txt;
718332a58d35 Fix left mouse button in editor margin bug from cset 65827e9cccb8
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21310
diff changeset
391 role << "RejectRole";
718332a58d35 Fix left mouse button in editor margin bug from cset 65827e9cccb8
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21310
diff changeset
392
718332a58d35 Fix left mouse button in editor margin bug from cset 65827e9cccb8
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21310
diff changeset
393 // Lock mutex before signaling.
24016
e327adeae7a0 hide mutex and wait condition data members in GUI objects
John W. Eaton <jwe@octave.org>
parents: 24015
diff changeset
394 uiwidget_creator.lock ();
21311
718332a58d35 Fix left mouse button in editor margin bug from cset 65827e9cccb8
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21310
diff changeset
395
718332a58d35 Fix left mouse button in editor margin bug from cset 65827e9cccb8
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21310
diff changeset
396 uiwidget_creator.signal_dialog (msg, title, "quest", btn, cancel_txt, role);
16565
e4b94abfeb96 use generic dialog for cd or addpath question
John W. Eaton <jwe@octave.org>
parents: 16551
diff changeset
397
21311
718332a58d35 Fix left mouse button in editor margin bug from cset 65827e9cccb8
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21310
diff changeset
398 // Wait while the user is responding to message box.
24016
e327adeae7a0 hide mutex and wait condition data members in GUI objects
John W. Eaton <jwe@octave.org>
parents: 24015
diff changeset
399 uiwidget_creator.wait ();
21311
718332a58d35 Fix left mouse button in editor margin bug from cset 65827e9cccb8
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21310
diff changeset
400
718332a58d35 Fix left mouse button in editor margin bug from cset 65827e9cccb8
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21310
diff changeset
401 // The GUI has sent a signal and the thread has been awakened.
16547
3cd80afc3509 improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents: 16528
diff changeset
402
21311
718332a58d35 Fix left mouse button in editor margin bug from cset 65827e9cccb8
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21310
diff changeset
403 QString result = uiwidget_creator.get_dialog_button ();
718332a58d35 Fix left mouse button in editor margin bug from cset 65827e9cccb8
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21310
diff changeset
404
24016
e327adeae7a0 hide mutex and wait condition data members in GUI objects
John W. Eaton <jwe@octave.org>
parents: 24015
diff changeset
405 uiwidget_creator.unlock ();
21311
718332a58d35 Fix left mouse button in editor margin bug from cset 65827e9cccb8
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21310
diff changeset
406
718332a58d35 Fix left mouse button in editor margin bug from cset 65827e9cccb8
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21310
diff changeset
407 if (result == cd_txt)
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
408 retval = 1;
21311
718332a58d35 Fix left mouse button in editor margin bug from cset 65827e9cccb8
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21310
diff changeset
409 else if (result == addpath_txt)
16565
e4b94abfeb96 use generic dialog for cd or addpath question
John W. Eaton <jwe@octave.org>
parents: 16551
diff changeset
410 retval = 2;
e4b94abfeb96 use generic dialog for cd or addpath question
John W. Eaton <jwe@octave.org>
parents: 16551
diff changeset
411
e4b94abfeb96 use generic dialog for cd or addpath question
John W. Eaton <jwe@octave.org>
parents: 16551
diff changeset
412 return retval;
16547
3cd80afc3509 improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents: 16528
diff changeset
413 }
3cd80afc3509 improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents: 16528
diff changeset
414
16415
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
415 void
16437
919796a440c6 use signal for changing directory
John W. Eaton <jwe@octave.org>
parents: 16432
diff changeset
416 octave_qt_link::do_change_directory (const std::string& dir)
919796a440c6 use signal for changing directory
John W. Eaton <jwe@octave.org>
parents: 16432
diff changeset
417 {
24628
55da6c4f1382 update chdir handling in GUI
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
418 emit change_directory_signal (QString::fromStdString (dir));
16437
919796a440c6 use signal for changing directory
John W. Eaton <jwe@octave.org>
parents: 16432
diff changeset
419 }
919796a440c6 use signal for changing directory
John W. Eaton <jwe@octave.org>
parents: 16432
diff changeset
420
919796a440c6 use signal for changing directory
John W. Eaton <jwe@octave.org>
parents: 16432
diff changeset
421 void
16570
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16565
diff changeset
422 octave_qt_link::do_execute_command_in_terminal (const std::string& command)
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16565
diff changeset
423 {
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16565
diff changeset
424 emit execute_command_in_terminal_signal (QString::fromStdString (command));
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16565
diff changeset
425 }
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16565
diff changeset
426
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16565
diff changeset
427 void
20181
aa36fb998a4d maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents: 20136
diff changeset
428 octave_qt_link::do_set_workspace (bool top_level, bool debug,
24645
f61502510d08 restore ability to select variables for editing from workspace widget
John W. Eaton <jwe@octave.org>
parents: 24641
diff changeset
429 const octave::symbol_scope& scope,
24631
6de74d95a7a1 don't use "const bool&" unnecessarily
John W. Eaton <jwe@octave.org>
parents: 24628
diff changeset
430 bool update_variable_editor)
16415
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
431 {
19970
f7846f0ea6db GUI: enable workspace update when debugging (Bug #44455)
John Donoghue
parents: 19904
diff changeset
432 if (! top_level && ! debug)
19904
793230bb81d4 don't update workspace viewer unless at top level (bug #44156)
John W. Eaton <jwe@octave.org>
parents: 19714
diff changeset
433 return;
793230bb81d4 don't update workspace viewer unless at top level (bug #44156)
John W. Eaton <jwe@octave.org>
parents: 19714
diff changeset
434
24645
f61502510d08 restore ability to select variables for editing from workspace widget
John W. Eaton <jwe@octave.org>
parents: 24641
diff changeset
435 emit set_workspace_signal (top_level, debug, scope);
23927
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents: 23807
diff changeset
436
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents: 23807
diff changeset
437 if (update_variable_editor)
24632
e9f7cfd40f85 rename some signals and slots for consistency and clarity
John W. Eaton <jwe@octave.org>
parents: 24631
diff changeset
438 emit refresh_variable_editor_signal ();
16468
0f143f68078d use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents: 16443
diff changeset
439 }
0f143f68078d use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents: 16443
diff changeset
440
0f143f68078d use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents: 16443
diff changeset
441 void
0f143f68078d use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents: 16443
diff changeset
442 octave_qt_link::do_clear_workspace (void)
0f143f68078d use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents: 16443
diff changeset
443 {
0f143f68078d use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents: 16443
diff changeset
444 emit clear_workspace_signal ();
16415
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
445 }
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
446
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
447 void
16431
5982d469f79b use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents: 16426
diff changeset
448 octave_qt_link::do_set_history (const string_vector& hist)
16415
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
449 {
16431
5982d469f79b use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents: 16426
diff changeset
450 QStringList qt_hist;
5982d469f79b use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents: 16426
diff changeset
451
20232
a9574e3c6e9e Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents: 20181
diff changeset
452 for (octave_idx_type i = 0; i < hist.numel (); i++)
16431
5982d469f79b use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents: 16426
diff changeset
453 qt_hist.append (QString::fromStdString (hist[i]));
5982d469f79b use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents: 16426
diff changeset
454
5982d469f79b use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents: 16426
diff changeset
455 emit set_history_signal (qt_hist);
5982d469f79b use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents: 16426
diff changeset
456 }
16415
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
457
16431
5982d469f79b use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents: 16426
diff changeset
458 void
5982d469f79b use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents: 16426
diff changeset
459 octave_qt_link::do_append_history (const std::string& hist_entry)
5982d469f79b use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents: 16426
diff changeset
460 {
5982d469f79b use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents: 16426
diff changeset
461 emit append_history_signal (QString::fromStdString (hist_entry));
5982d469f79b use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents: 16426
diff changeset
462 }
5982d469f79b use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents: 16426
diff changeset
463
5982d469f79b use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents: 16426
diff changeset
464 void
5982d469f79b use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents: 16426
diff changeset
465 octave_qt_link::do_clear_history (void)
5982d469f79b use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents: 16426
diff changeset
466 {
5982d469f79b use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents: 16426
diff changeset
467 emit clear_history_signal ();
16415
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
468 }
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
469
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
470 void
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
471 octave_qt_link::do_pre_input_event (void)
22417
48c00363dc74 maint: Use '{ }' for empty function bodies in C++.
Rik <rik@octave.org>
parents: 22411
diff changeset
472 { }
16415
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
473
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
474 void
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
475 octave_qt_link::do_post_input_event (void)
22417
48c00363dc74 maint: Use '{ }' for empty function bodies in C++.
Rik <rik@octave.org>
parents: 22411
diff changeset
476 { }
16415
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
477
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
478 void
16419
16bfbf9136d3 avoid creating unnecessary octave_value objects for octave_link calls
John W. Eaton <jwe@octave.org>
parents: 16415
diff changeset
479 octave_qt_link::do_enter_debugger_event (const std::string& file, int line)
16415
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
480 {
16419
16bfbf9136d3 avoid creating unnecessary octave_value objects for octave_link calls
John W. Eaton <jwe@octave.org>
parents: 16415
diff changeset
481 do_insert_debugger_pointer (file, line);
16438
a971d8bdaadc use signals instead of event queue for entering/leaving debug mode
John W. Eaton <jwe@octave.org>
parents: 16437
diff changeset
482
a971d8bdaadc use signals instead of event queue for entering/leaving debug mode
John W. Eaton <jwe@octave.org>
parents: 16437
diff changeset
483 emit enter_debugger_signal ();
16415
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
484 }
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
485
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
486 void
16438
a971d8bdaadc use signals instead of event queue for entering/leaving debug mode
John W. Eaton <jwe@octave.org>
parents: 16437
diff changeset
487 octave_qt_link::do_execute_in_debugger_event (const std::string& file, int line)
16415
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
488 {
16419
16bfbf9136d3 avoid creating unnecessary octave_value objects for octave_link calls
John W. Eaton <jwe@octave.org>
parents: 16415
diff changeset
489 do_delete_debugger_pointer (file, line);
16415
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
490 }
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
491
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
492 void
16438
a971d8bdaadc use signals instead of event queue for entering/leaving debug mode
John W. Eaton <jwe@octave.org>
parents: 16437
diff changeset
493 octave_qt_link::do_exit_debugger_event (void)
a971d8bdaadc use signals instead of event queue for entering/leaving debug mode
John W. Eaton <jwe@octave.org>
parents: 16437
diff changeset
494 {
a971d8bdaadc use signals instead of event queue for entering/leaving debug mode
John W. Eaton <jwe@octave.org>
parents: 16437
diff changeset
495 emit exit_debugger_signal ();
a971d8bdaadc use signals instead of event queue for entering/leaving debug mode
John W. Eaton <jwe@octave.org>
parents: 16437
diff changeset
496 }
a971d8bdaadc use signals instead of event queue for entering/leaving debug mode
John W. Eaton <jwe@octave.org>
parents: 16437
diff changeset
497
21158
65827e9cccb8 Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21148
diff changeset
498 // Display (if @insert true) or remove the appropriate symbol for a breakpoint
65827e9cccb8 Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21148
diff changeset
499 // in @file at @line with condition @cond.
16438
a971d8bdaadc use signals instead of event queue for entering/leaving debug mode
John W. Eaton <jwe@octave.org>
parents: 16437
diff changeset
500 void
16415
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
501 octave_qt_link::do_update_breakpoint (bool insert,
21158
65827e9cccb8 Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21148
diff changeset
502 const std::string& file, int line,
65827e9cccb8 Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21148
diff changeset
503 const std::string& cond)
16415
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
504 {
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
505 emit update_breakpoint_marker_signal (insert, QString::fromStdString (file),
21158
65827e9cccb8 Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21148
diff changeset
506 line, QString::fromStdString (cond));
16415
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
507 }
16426
203976ae18d1 use signals for octave_link::enter_debugger_event and octave_link::exit_debugger_event
John W. Eaton <jwe@octave.org>
parents: 16424
diff changeset
508
203976ae18d1 use signals for octave_link::enter_debugger_event and octave_link::exit_debugger_event
John W. Eaton <jwe@octave.org>
parents: 16424
diff changeset
509 void
16528
9bc1f8278966 allow GUI to customize prompts at startup
John W. Eaton <jwe@octave.org>
parents: 16512
diff changeset
510 octave_qt_link::do_set_default_prompts (std::string& ps1, std::string& ps2,
9bc1f8278966 allow GUI to customize prompts at startup
John W. Eaton <jwe@octave.org>
parents: 16512
diff changeset
511 std::string& ps4)
9bc1f8278966 allow GUI to customize prompts at startup
John W. Eaton <jwe@octave.org>
parents: 16512
diff changeset
512 {
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
513 if (m_app_context->start_gui_p ())
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
514 {
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
515 ps1 = ">> ";
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
516 ps2 = "";
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
517 ps4 = "";
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
518 }
16528
9bc1f8278966 allow GUI to customize prompts at startup
John W. Eaton <jwe@octave.org>
parents: 16512
diff changeset
519 }
9bc1f8278966 allow GUI to customize prompts at startup
John W. Eaton <jwe@octave.org>
parents: 16512
diff changeset
520
16635
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16581
diff changeset
521 bool
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16581
diff changeset
522 octave_qt_link::file_in_path (const std::string& file, const std::string& dir)
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16581
diff changeset
523 {
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16581
diff changeset
524
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16581
diff changeset
525 bool ok = false;
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16581
diff changeset
526 bool addpath_option = true;
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16581
diff changeset
527
21732
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
528 std::string curr_dir = octave::sys::env::get_current_directory ();
16635
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16581
diff changeset
529
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16581
diff changeset
530 if (same_file (curr_dir, dir))
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16581
diff changeset
531 ok = true;
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16581
diff changeset
532 else
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16581
diff changeset
533 {
23445
8e310ef0fa97 move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents: 23438
diff changeset
534 octave::load_path& lp = octave::__get_load_path__ ("octave_qt_link::file_in_path");
23438
d24d01273bd0 eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
535
d24d01273bd0 eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
536 bool dir_in_load_path = lp.contains_canonical (dir);
16635
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16581
diff changeset
537
21717
efdf6424003a Allow GUI to set breakpoints in @class/method (bug #41514).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21578
diff changeset
538 // get base name, allowing "@class/method.m" (bug #41514)
efdf6424003a Allow GUI to set breakpoints in @class/method (bug #41514).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21578
diff changeset
539 std::string base_file = (file.length () > dir.length ())
efdf6424003a Allow GUI to set breakpoints in @class/method (bug #41514).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21578
diff changeset
540 ? file.substr (dir.length () + 1)
21732
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
541 : octave::sys::env::base_pathname (file);
21717
efdf6424003a Allow GUI to set breakpoints in @class/method (bug #41514).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21578
diff changeset
542
23438
d24d01273bd0 eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
543 std::string lp_file = lp.find_file (base_file);
16635
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16581
diff changeset
544
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16581
diff changeset
545 if (dir_in_load_path)
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16581
diff changeset
546 {
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16581
diff changeset
547 if (same_file (lp_file, file))
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16581
diff changeset
548 ok = true;
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16581
diff changeset
549 }
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16581
diff changeset
550 else
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16581
diff changeset
551 {
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16581
diff changeset
552 // File directory is not in path. Is the file in the path in
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16581
diff changeset
553 // the current directory? If so, then changing the current
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16581
diff changeset
554 // directory will be needed. Adding directory to path is
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16581
diff changeset
555 // not enough because the file in the current directory would
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16581
diff changeset
556 // still be found.
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16581
diff changeset
557
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16581
diff changeset
558 if (same_file (lp_file, base_file))
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16581
diff changeset
559 {
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16581
diff changeset
560 if (same_file (curr_dir, dir))
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16581
diff changeset
561 ok = true;
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16581
diff changeset
562 else
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16581
diff changeset
563 addpath_option = false;
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16581
diff changeset
564 }
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16581
diff changeset
565 }
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16581
diff changeset
566 }
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16581
diff changeset
567
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16581
diff changeset
568 if (! ok)
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16581
diff changeset
569 {
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16581
diff changeset
570 int action = debug_cd_or_addpath_error (file, dir, addpath_option);
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16581
diff changeset
571 switch (action)
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16581
diff changeset
572 {
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16581
diff changeset
573 case 1:
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16581
diff changeset
574 Fcd (ovl (dir));
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16581
diff changeset
575 ok = true;
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16581
diff changeset
576 break;
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16581
diff changeset
577
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16581
diff changeset
578 case 2:
23438
d24d01273bd0 eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
579 {
23445
8e310ef0fa97 move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents: 23438
diff changeset
580 octave::load_path& lp = octave::__get_load_path__ ("octave_qt_link::file_in_path");
23438
d24d01273bd0 eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
581
d24d01273bd0 eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
582 lp.prepend (dir);
d24d01273bd0 eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
583 ok = true;
d24d01273bd0 eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
584 }
16635
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16581
diff changeset
585 break;
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16581
diff changeset
586
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16581
diff changeset
587 default:
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16581
diff changeset
588 break;
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16581
diff changeset
589 }
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16581
diff changeset
590 }
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16581
diff changeset
591
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16581
diff changeset
592 return ok;
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16581
diff changeset
593 }
17010
c50ee84842a9 Add preferences and prefdir functions
John Donoghue <john.donoghue@ieee.org>
parents: 16658
diff changeset
594
c50ee84842a9 Add preferences and prefdir functions
John Donoghue <john.donoghue@ieee.org>
parents: 16658
diff changeset
595 void
24015
5ecefb7425e3 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 24005
diff changeset
596 octave_qt_link::do_show_preferences (void)
17010
c50ee84842a9 Add preferences and prefdir functions
John Donoghue <john.donoghue@ieee.org>
parents: 16658
diff changeset
597 {
c50ee84842a9 Add preferences and prefdir functions
John Donoghue <john.donoghue@ieee.org>
parents: 16658
diff changeset
598 emit show_preferences_signal ();
c50ee84842a9 Add preferences and prefdir functions
John Donoghue <john.donoghue@ieee.org>
parents: 16658
diff changeset
599 }
c50ee84842a9 Add preferences and prefdir functions
John Donoghue <john.donoghue@ieee.org>
parents: 16658
diff changeset
600
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
601 void
359c5ca795cd Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents: 17010
diff changeset
602 octave_qt_link::do_show_doc (const std::string& file)
359c5ca795cd Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents: 17010
diff changeset
603 {
359c5ca795cd Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents: 17010
diff changeset
604 emit show_doc_signal (QString::fromStdString (file));
359c5ca795cd Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents: 17010
diff changeset
605 }
17010
c50ee84842a9 Add preferences and prefdir functions
John Donoghue <john.donoghue@ieee.org>
parents: 16658
diff changeset
606
17920
5c3f22dd0bbb raise SIGINT in octave_interpreter instead of in QTerminal
John W. Eaton <jwe@octave.org>
parents: 17919
diff changeset
607 void
24641
7d177be54c37 pass variable value to variable editor in addition to variable name
John W. Eaton <jwe@octave.org>
parents: 24632
diff changeset
608 octave_qt_link::do_edit_variable (const std::string& expr, const octave_value& val)
23927
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents: 23807
diff changeset
609 {
24641
7d177be54c37 pass variable value to variable editor in addition to variable name
John W. Eaton <jwe@octave.org>
parents: 24632
diff changeset
610 emit edit_variable_signal (QString::fromStdString (expr), val);
23927
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents: 23807
diff changeset
611 }
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents: 23807
diff changeset
612
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents: 23807
diff changeset
613 void
24015
5ecefb7425e3 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 24005
diff changeset
614 octave_qt_link::do_insert_debugger_pointer (const std::string& file, int line)
17920
5c3f22dd0bbb raise SIGINT in octave_interpreter instead of in QTerminal
John W. Eaton <jwe@octave.org>
parents: 17919
diff changeset
615 {
24015
5ecefb7425e3 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 24005
diff changeset
616 emit insert_debugger_pointer_signal (QString::fromStdString (file), line);
17920
5c3f22dd0bbb raise SIGINT in octave_interpreter instead of in QTerminal
John W. Eaton <jwe@octave.org>
parents: 17919
diff changeset
617 }
24015
5ecefb7425e3 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 24005
diff changeset
618
5ecefb7425e3 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 24005
diff changeset
619 void
5ecefb7425e3 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 24005
diff changeset
620 octave_qt_link::do_delete_debugger_pointer (const std::string& file, int line)
5ecefb7425e3 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 24005
diff changeset
621 {
5ecefb7425e3 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 24005
diff changeset
622 emit delete_debugger_pointer_signal (QString::fromStdString (file), line);
5ecefb7425e3 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 24005
diff changeset
623 }