diff libgui/src/octave-cmd.h @ 19978:034bcac0b61c

use of C++ API for running a file (bug #42307) * octave-cmd.cc: New file providing the new command class octave_cmd; (prepare_command_editor): common action that all derived command classes use for method execute; (octave_cmd_exec::execute): execute method of derived class for executing ordinary commands in the terminal; (octave_cmd_eval::execute): execute method of derived class for running a file (as function if it is a valid identifier or as script) * octave-cmd.h: providing base and derived classes * main-window.cc (main_window): _cmd_queue is not a pointer anymore; (~main_window): _cmd_queue is not a pointer anymore; (execute_command_in_terminal): use new command class for queuing a command; (run_file_in_terminal): check for valid identifier moved from here to the execute method of the related command class; (run_file_callback): use new class for queuing command, path check moved from here into the execute method of the command class; (queue_command): gets new command class instead of a string as input; (closeEvent): queue command class instead of string; (execute_command_callback): command queue contains command class instances; * main-window.h: use new octave-cmd class for queue_command, the command queue is not a pointer anymore * module.mk: new files octave-cmd.cc and octave-cmd.h
author Torsten <ttl@justmail.de>
date Thu, 19 Feb 2015 22:05:12 +0100
parents
children c5f0df2a7291
line wrap: on
line diff
new file mode 100644
--- /dev/null
+++ b/libgui/src/octave-cmd.h
@@ -0,0 +1,73 @@
+/*
+
+Copyright (C) 2014 Torsten
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 3 of the License, or (at your
+option) any later version.
+
+Octave is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, see
+<http://www.gnu.org/licenses/>.
+
+*/
+
+// Author: Torsten <ttl@justmail.de>
+
+#if !defined (octave_cmd_h)
+#define octave_cmd_h 1
+
+#include <QString>
+#include <QFileInfo>
+
+class octave_cmd
+{
+public:
+
+  octave_cmd () { };
+  virtual ~octave_cmd () { };
+
+  virtual void execute () { };
+  void prepare_command_editor (const QString& cmd);
+};
+
+
+// ---------------------------------------------------------------------
+//  class octave_cmd_exec
+
+class octave_cmd_exec : public octave_cmd
+{
+public:
+
+  octave_cmd_exec (const QString& cmd) : octave_cmd () { _cmd = cmd; };
+  void execute ();
+
+private:
+
+  QString _cmd;
+};
+
+
+// ---------------------------------------------------------------------
+//  class octave_cmd_eval
+
+class octave_cmd_eval : public octave_cmd
+{
+public:
+
+  octave_cmd_eval (const QFileInfo& info) : octave_cmd () { _info = info; };
+  void execute ();
+
+private:
+
+  QFileInfo _info;
+};
+#endif