Salome HOME
7755e156e1210db0443d911a74b45146dc382d3b
[modules/gui.git] / tools / PyConsole / src / PyConsole_Event.cxx
1 // Copyright (C) 2007-2022  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 // File   : PyConsole_Event.cxx
23 // Author : Vadim SANDLER (Open CASCADE S.A.S), Adrien Bruneton (CEA/DEN)
24
25 #include "PyConsole_Event.h"
26
27 /*!
28   \class PyConsole_PrintEvent
29   \brief Python command output backend event.
30   \internal
31 */
32
33 /*!
34   \brief Constructor
35   \param message message text (python trace)
36   \param isError default to \c false - if \c true indicates that an error is being printed.
37 */
38 PyConsole_PrintEvent::PyConsole_PrintEvent( const QString& message, bool isError )
39   : QEvent( (QEvent::Type)EVENT_ID ), myText( message ), myError( isError )
40 {
41 }
42
43 /*!
44   \brief Get message
45   \return message text (python trace)
46 */
47 QString PyConsole_PrintEvent::text() const
48 {
49   return myText;
50 }
51
52 /*!
53   \brief Get error flag
54   \return \c true if this is an error message
55 */
56 bool PyConsole_PrintEvent::isError() const
57 {
58   return myError;
59 }
60
61 /*!
62   \class PyConsole_CompletionEvent
63   \brief Python command completion event.
64   \internal
65 */
66
67 /*!
68   \brief Constructor
69   \param request python request
70   \param s status of execution of completion command
71   \param ms command matches (completions)
72   \param d docstring of the match (in case if there is sinlge match)
73 */
74 PyConsole_CompletionEvent::PyConsole_CompletionEvent( PyInterp_Request* request,
75                                                       bool s,
76                                                       const QStringList& ms,
77                                                       const QString& d )
78   : PyInterp_Event( (QEvent::Type)EVENT_ID, request ),
79     myStatus( s ), myMatches( ms ), myDoc( d )
80 {}
81
82 /*!
83   \brief Get status of execution of completion command
84   \return execution status
85 */
86 bool PyConsole_CompletionEvent::status() const
87 {
88   return myStatus;
89 }
90
91 /*!
92   \brief Get matches (completions)
93   \return detected command matches (completions)
94 */
95 QStringList PyConsole_CompletionEvent::matches() const
96 {
97   return myMatches;
98 }
99
100 /*!
101   \brief Get docstring
102   \return docstring of the match (in case if there is sinlge match)
103 */
104 QString PyConsole_CompletionEvent::doc() const
105 {
106   return myDoc;
107 }