Mercurial > octave
annotate libgui/src/octave-cmd.h @ 21148:e8c3590da9ff
update directory in gui after add-path/change-dir dialog
* file-editor-tab.cc (file_editor_tab): get main window from editor which is
given as argument;
(add_breakpoint_callback, remove_breakpoint_callback,
remove_all_breakpoints_callback): call file_in_path via the instance of
octave_qt_link since it is not static anymore
* file-editor-tab.h: include main-window.h, contructor gets editor widget as
first argument, store the main window widget in a class variable
* file-editor.cc (request_new_file, request_open_file): pass own pointer
to a new file editor tab
* main-window.cc (run_file_callback): pass the instance of octave_qt_link
to the octave cmd
* main-window.h: new function returning the instance of octave_qt_link
* octave-cmd.cc (execute): call file_in_path via instance (not static)
* octave-cmd.h: instance of octave_qt_link is given as argument and stored
in a class variable
* octave-qt-link.cc (file_in_path): update gui directory when user wants to
change the directory
* octave-qt-link.h: file_in_path is normal memebr, not static anymore
author | Torsten <ttl@justmail.de> |
---|---|
date | Fri, 29 Jan 2016 06:24:34 +0100 |
parents | 4a7d9c335402 |
children | f7d1050b9b53 |
rev | line source |
---|---|
19773
034bcac0b61c
use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
1 /* |
034bcac0b61c
use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
2 |
034bcac0b61c
use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
3 Copyright (C) 2014 Torsten |
034bcac0b61c
use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
4 |
034bcac0b61c
use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
5 This file is part of Octave. |
034bcac0b61c
use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
6 |
034bcac0b61c
use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
7 Octave is free software; you can redistribute it and/or modify it |
034bcac0b61c
use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
8 under the terms of the GNU General Public License as published by the |
034bcac0b61c
use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
9 Free Software Foundation; either version 3 of the License, or (at your |
034bcac0b61c
use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
10 option) any later version. |
034bcac0b61c
use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
11 |
034bcac0b61c
use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
034bcac0b61c
use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
034bcac0b61c
use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
034bcac0b61c
use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
15 for more details. |
034bcac0b61c
use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
16 |
034bcac0b61c
use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
17 You should have received a copy of the GNU General Public License |
034bcac0b61c
use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
18 along with Octave; see the file COPYING. If not, see |
034bcac0b61c
use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
19 <http://www.gnu.org/licenses/>. |
034bcac0b61c
use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
20 |
034bcac0b61c
use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
21 */ |
034bcac0b61c
use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
22 |
034bcac0b61c
use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
23 // Author: Torsten <ttl@justmail.de> |
034bcac0b61c
use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
24 |
20791
f7084eae3318
maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents:
19806
diff
changeset
|
25 #if ! defined (octave_cmd_h) |
19773
034bcac0b61c
use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
26 #define octave_cmd_h 1 |
034bcac0b61c
use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
27 |
21028
4a7d9c335402
GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents:
21027
diff
changeset
|
28 #include <QSemaphore> |
4a7d9c335402
GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents:
21027
diff
changeset
|
29 #include <QMutex> |
19773
034bcac0b61c
use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
30 #include <QString> |
034bcac0b61c
use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
31 #include <QFileInfo> |
034bcac0b61c
use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
32 |
21028
4a7d9c335402
GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents:
21027
diff
changeset
|
33 #include "octave-qt-link.h" |
4a7d9c335402
GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents:
21027
diff
changeset
|
34 |
19773
034bcac0b61c
use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
35 class octave_cmd |
034bcac0b61c
use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
36 { |
034bcac0b61c
use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
37 public: |
034bcac0b61c
use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
38 |
034bcac0b61c
use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
39 octave_cmd () { }; |
034bcac0b61c
use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
40 virtual ~octave_cmd () { }; |
034bcac0b61c
use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
41 |
034bcac0b61c
use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
42 virtual void execute () { }; |
034bcac0b61c
use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
43 }; |
034bcac0b61c
use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
44 |
034bcac0b61c
use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
45 |
034bcac0b61c
use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
46 // --------------------------------------------------------------------- |
034bcac0b61c
use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
47 // class octave_cmd_exec |
034bcac0b61c
use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
48 |
034bcac0b61c
use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
49 class octave_cmd_exec : public octave_cmd |
034bcac0b61c
use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
50 { |
034bcac0b61c
use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
51 public: |
034bcac0b61c
use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
52 |
034bcac0b61c
use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
53 octave_cmd_exec (const QString& cmd) : octave_cmd () { _cmd = cmd; }; |
034bcac0b61c
use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
54 void execute (); |
034bcac0b61c
use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
55 |
21027
8000dacaea98
GUI: no more extra command queue for debug commands
Torsten <ttl@justmail.de>
parents:
20791
diff
changeset
|
56 protected: |
19773
034bcac0b61c
use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
57 |
034bcac0b61c
use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
58 QString _cmd; |
034bcac0b61c
use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
59 }; |
034bcac0b61c
use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
60 |
034bcac0b61c
use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
61 |
034bcac0b61c
use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
62 // --------------------------------------------------------------------- |
034bcac0b61c
use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
63 // class octave_cmd_eval |
034bcac0b61c
use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
64 |
034bcac0b61c
use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
65 class octave_cmd_eval : public octave_cmd |
034bcac0b61c
use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
66 { |
034bcac0b61c
use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
67 public: |
034bcac0b61c
use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
68 |
21148
e8c3590da9ff
update directory in gui after add-path/change-dir dialog
Torsten <ttl@justmail.de>
parents:
21028
diff
changeset
|
69 octave_cmd_eval (const QFileInfo& info, |
e8c3590da9ff
update directory in gui after add-path/change-dir dialog
Torsten <ttl@justmail.de>
parents:
21028
diff
changeset
|
70 octave_qt_link* octave_qt_link) : octave_cmd () |
e8c3590da9ff
update directory in gui after add-path/change-dir dialog
Torsten <ttl@justmail.de>
parents:
21028
diff
changeset
|
71 { _info = info; |
e8c3590da9ff
update directory in gui after add-path/change-dir dialog
Torsten <ttl@justmail.de>
parents:
21028
diff
changeset
|
72 _octave_qt_link = octave_qt_link; |
e8c3590da9ff
update directory in gui after add-path/change-dir dialog
Torsten <ttl@justmail.de>
parents:
21028
diff
changeset
|
73 }; |
e8c3590da9ff
update directory in gui after add-path/change-dir dialog
Torsten <ttl@justmail.de>
parents:
21028
diff
changeset
|
74 |
19773
034bcac0b61c
use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
75 void execute (); |
034bcac0b61c
use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
76 |
21027
8000dacaea98
GUI: no more extra command queue for debug commands
Torsten <ttl@justmail.de>
parents:
20791
diff
changeset
|
77 protected: |
19773
034bcac0b61c
use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
78 |
034bcac0b61c
use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
79 QFileInfo _info; |
21148
e8c3590da9ff
update directory in gui after add-path/change-dir dialog
Torsten <ttl@justmail.de>
parents:
21028
diff
changeset
|
80 octave_qt_link *_octave_qt_link; |
19773
034bcac0b61c
use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
81 }; |
21027
8000dacaea98
GUI: no more extra command queue for debug commands
Torsten <ttl@justmail.de>
parents:
20791
diff
changeset
|
82 |
8000dacaea98
GUI: no more extra command queue for debug commands
Torsten <ttl@justmail.de>
parents:
20791
diff
changeset
|
83 |
8000dacaea98
GUI: no more extra command queue for debug commands
Torsten <ttl@justmail.de>
parents:
20791
diff
changeset
|
84 // --------------------------------------------------------------------- |
8000dacaea98
GUI: no more extra command queue for debug commands
Torsten <ttl@justmail.de>
parents:
20791
diff
changeset
|
85 // class octave_cmd_debug |
8000dacaea98
GUI: no more extra command queue for debug commands
Torsten <ttl@justmail.de>
parents:
20791
diff
changeset
|
86 |
8000dacaea98
GUI: no more extra command queue for debug commands
Torsten <ttl@justmail.de>
parents:
20791
diff
changeset
|
87 class octave_cmd_debug : public octave_cmd_exec |
8000dacaea98
GUI: no more extra command queue for debug commands
Torsten <ttl@justmail.de>
parents:
20791
diff
changeset
|
88 { |
8000dacaea98
GUI: no more extra command queue for debug commands
Torsten <ttl@justmail.de>
parents:
20791
diff
changeset
|
89 public: |
8000dacaea98
GUI: no more extra command queue for debug commands
Torsten <ttl@justmail.de>
parents:
20791
diff
changeset
|
90 |
8000dacaea98
GUI: no more extra command queue for debug commands
Torsten <ttl@justmail.de>
parents:
20791
diff
changeset
|
91 octave_cmd_debug (const QString& cmd, bool suppress_location) |
8000dacaea98
GUI: no more extra command queue for debug commands
Torsten <ttl@justmail.de>
parents:
20791
diff
changeset
|
92 : octave_cmd_exec (cmd) |
8000dacaea98
GUI: no more extra command queue for debug commands
Torsten <ttl@justmail.de>
parents:
20791
diff
changeset
|
93 { |
8000dacaea98
GUI: no more extra command queue for debug commands
Torsten <ttl@justmail.de>
parents:
20791
diff
changeset
|
94 _suppress_dbg_location = suppress_location; |
8000dacaea98
GUI: no more extra command queue for debug commands
Torsten <ttl@justmail.de>
parents:
20791
diff
changeset
|
95 }; |
8000dacaea98
GUI: no more extra command queue for debug commands
Torsten <ttl@justmail.de>
parents:
20791
diff
changeset
|
96 |
8000dacaea98
GUI: no more extra command queue for debug commands
Torsten <ttl@justmail.de>
parents:
20791
diff
changeset
|
97 void execute (); |
8000dacaea98
GUI: no more extra command queue for debug commands
Torsten <ttl@justmail.de>
parents:
20791
diff
changeset
|
98 |
8000dacaea98
GUI: no more extra command queue for debug commands
Torsten <ttl@justmail.de>
parents:
20791
diff
changeset
|
99 protected: |
8000dacaea98
GUI: no more extra command queue for debug commands
Torsten <ttl@justmail.de>
parents:
20791
diff
changeset
|
100 |
8000dacaea98
GUI: no more extra command queue for debug commands
Torsten <ttl@justmail.de>
parents:
20791
diff
changeset
|
101 bool _suppress_dbg_location; |
8000dacaea98
GUI: no more extra command queue for debug commands
Torsten <ttl@justmail.de>
parents:
20791
diff
changeset
|
102 }; |
21028
4a7d9c335402
GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents:
21027
diff
changeset
|
103 |
4a7d9c335402
GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents:
21027
diff
changeset
|
104 |
4a7d9c335402
GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents:
21027
diff
changeset
|
105 /** |
4a7d9c335402
GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents:
21027
diff
changeset
|
106 * @class octave_command_queue |
4a7d9c335402
GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents:
21027
diff
changeset
|
107 * |
4a7d9c335402
GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents:
21027
diff
changeset
|
108 * Queuing commands from the GUI for the worker thread |
4a7d9c335402
GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents:
21027
diff
changeset
|
109 */ |
4a7d9c335402
GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents:
21027
diff
changeset
|
110 // --------------------------------------------------------------------- |
4a7d9c335402
GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents:
21027
diff
changeset
|
111 // class octave_command_queue: queue of octave commands |
4a7d9c335402
GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents:
21027
diff
changeset
|
112 |
4a7d9c335402
GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents:
21027
diff
changeset
|
113 class octave_command_queue : QObject |
4a7d9c335402
GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents:
21027
diff
changeset
|
114 { |
4a7d9c335402
GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents:
21027
diff
changeset
|
115 Q_OBJECT; |
4a7d9c335402
GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents:
21027
diff
changeset
|
116 |
4a7d9c335402
GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents:
21027
diff
changeset
|
117 public: |
4a7d9c335402
GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents:
21027
diff
changeset
|
118 |
4a7d9c335402
GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents:
21027
diff
changeset
|
119 octave_command_queue (void) : QObject (), |
4a7d9c335402
GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents:
21027
diff
changeset
|
120 _queue (QList<octave_cmd *> ()), |
4a7d9c335402
GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents:
21027
diff
changeset
|
121 _processing (1), |
4a7d9c335402
GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents:
21027
diff
changeset
|
122 _queue_mutex () { }; |
4a7d9c335402
GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents:
21027
diff
changeset
|
123 ~octave_command_queue (void) { }; |
4a7d9c335402
GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents:
21027
diff
changeset
|
124 |
4a7d9c335402
GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents:
21027
diff
changeset
|
125 /** |
4a7d9c335402
GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents:
21027
diff
changeset
|
126 * Adds a new octave command to the command queue. |
4a7d9c335402
GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents:
21027
diff
changeset
|
127 * @param cmd The octave command to be queued |
4a7d9c335402
GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents:
21027
diff
changeset
|
128 */ |
4a7d9c335402
GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents:
21027
diff
changeset
|
129 void add_cmd (octave_cmd *cmd); |
4a7d9c335402
GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents:
21027
diff
changeset
|
130 /** |
4a7d9c335402
GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents:
21027
diff
changeset
|
131 * Callback routine for executing the command by the worker thread |
4a7d9c335402
GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents:
21027
diff
changeset
|
132 */ |
4a7d9c335402
GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents:
21027
diff
changeset
|
133 void execute_command_callback (void); |
4a7d9c335402
GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents:
21027
diff
changeset
|
134 |
4a7d9c335402
GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents:
21027
diff
changeset
|
135 private: |
4a7d9c335402
GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents:
21027
diff
changeset
|
136 |
4a7d9c335402
GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents:
21027
diff
changeset
|
137 QList<octave_cmd *> _queue; |
4a7d9c335402
GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents:
21027
diff
changeset
|
138 QSemaphore _processing; |
4a7d9c335402
GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents:
21027
diff
changeset
|
139 QMutex _queue_mutex; |
4a7d9c335402
GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents:
21027
diff
changeset
|
140 }; |
4a7d9c335402
GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents:
21027
diff
changeset
|
141 |
19773
034bcac0b61c
use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
142 #endif |