Salome HOME
Revert "Synchronize adm files"
[modules/gui.git] / src / PyConsole / PyConsole_Request.h
1 // Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 // Author : Adrien Bruneton (CEA/DEN)
20 // Created on: 3 avr. 2013
21
22
23 #ifndef PYCONSOLE_REQUEST_H_
24 #define PYCONSOLE_REQUEST_H_
25
26 #include "PyConsole.h"
27 #include "PyInterp_Request.h"
28
29 #include <vector>
30 #include <QString>
31 #include <QEvent>
32
33 class PyInterp_Interp;
34 class PyConsole_Editor;
35
36 /*!
37   \class ExecCommand
38   \brief Python command execution request.
39   \internal
40 */
41 class ExecCommand : public PyInterp_LockRequest
42 {
43 public:
44   /*!
45     \brief Constructor.
46
47     Creates new python command execution request.
48     \param theInterp   python interpreter
49     \param theCommand  python command
50     \param theListener widget to get the notification messages
51     \param sync        if True the request is processed synchronously
52   */
53   ExecCommand( PyInterp_Interp*        theInterp,
54                const QString&          theCommand,
55                PyConsole_Editor*       theListener,
56                bool                    sync = false );
57
58 protected:
59   /*!
60     \brief Execute the python command in the interpreter and
61            get its execution status.
62   */
63   virtual void execute();
64
65   /*!
66     \brief Create and return a notification event.
67     \return new notification event
68   */
69   virtual QEvent* createEvent();
70
71 private:
72   QString myCommand;   //!< Python command
73   int     myState;     //!< Python command execution status
74 };
75
76 class PyConsole_EnhInterp;
77 class PyConsole_EnhEditor;
78
79 class CompletionCommand : public PyInterp_LockRequest
80 {
81 public:
82   CompletionCommand( PyConsole_EnhInterp*      theInterp,
83                const QString&          input,
84                const QString&          startMatch,
85                PyConsole_EnhEditor*    theListener,
86                bool                    sync = false );
87
88
89 protected:
90   /** List of separators identifying the last parsable token for completion */
91   static const std::vector<QString> SEPARATORS;
92
93   /** String to be passed to the dir() command */
94   QString _dirArg;
95   /** Begining of the command (as typed by the user) */
96   QString _startMatch;
97   /** was the completion command successful */
98   bool _tabSuccess;
99
100   virtual void execute();
101   virtual QEvent* createEvent();
102
103 };
104
105 #endif /* PYCONSOLE_REQUEST_H_ */