From 5bd8a5df6d5ad6af71b2ec7b3280e5c9c80792ec Mon Sep 17 00:00:00 2001 From: stv Date: Tue, 2 Oct 2007 11:10:58 +0000 Subject: [PATCH] no message --- src/PyConsole/PyConsole_Console.cxx | 2 -- src/PyConsole/PyConsole_Editor.cxx | 41 ++++++++-------------------- src/PyInterp/PyInterp_Dispatcher.cxx | 2 +- src/PyInterp/PyInterp_Dispatcher.h | 7 +++-- 4 files changed, 17 insertions(+), 35 deletions(-) diff --git a/src/PyConsole/PyConsole_Console.cxx b/src/PyConsole/PyConsole_Console.cxx index 85ba6c722..897a4a907 100644 --- a/src/PyConsole/PyConsole_Console.cxx +++ b/src/PyConsole/PyConsole_Console.cxx @@ -25,8 +25,6 @@ \brief Python console widget. */ -#include - #include "PyConsole_Console.h" #include "PyConsole_Editor.h" diff --git a/src/PyConsole/PyConsole_Editor.cxx b/src/PyConsole/PyConsole_Editor.cxx index 2fee0d516..a0b4536ff 100644 --- a/src/PyConsole/PyConsole_Editor.cxx +++ b/src/PyConsole/PyConsole_Editor.cxx @@ -123,6 +123,7 @@ static QString DOTS_PROMPT = "... "; class ExecCommand : public PyInterp_LockRequest { public: + enum { ES_PRINT = PyInterp_Event::ES_USER + 1 }; /*! \brief Constructor. @@ -137,7 +138,7 @@ public: PyConsole_Editor* theListener, bool sync = false ) : PyInterp_LockRequest( theInterp, theListener, sync ), - myCommand( theCommand ), myState( PyInterp_Event::OK ) + myCommand( theCommand ), myState( PyInterp_Event::ES_OK ) {} protected: @@ -153,9 +154,9 @@ protected: int ret = getInterp()->run( myCommand.toLatin1() ); // SUIT_Session::SetPythonExecuted(false); // enable GUI user actions if ( ret < 0 ) - myState = PyInterp_Event::ERRORS; + myState = PyInterp_Event::ES_ERROR; else if ( ret > 0 ) - myState = PyInterp_Event::INCOMPLETE; + myState = PyInterp_Event::ES_INCOMPLETE; } } @@ -165,6 +166,8 @@ protected: */ virtual QEvent* createEvent() const { + if ( IsSync() ) + QCoreApplication::sendPostedEvents( listener(), ES_PRINT ); return new PyInterp_Event( myState, (PyInterp_Request*)this ); } @@ -173,12 +176,10 @@ private: int myState; //!< Python command execution status }; -#define PRINT_EVENT 65432 - class PrintEvent : public QEvent { public: - PrintEvent( const char* c ) : QEvent( (QEvent::Type)PRINT_EVENT ), myText( c ) {} + PrintEvent( const char* c ) : QEvent( (QEvent::Type)ExecCommand::ES_PRINT ), myText( c ) {} QString text() const { return myText; } private: QString myText; @@ -863,32 +864,14 @@ void PyConsole_Editor::customEvent( QEvent* event ) { switch( event->type() ) { - case PRINT_EVENT: + case ExecCommand::ES_PRINT: { PrintEvent* pe=(PrintEvent*)event; - - // [ BEGIN ] workaround for the synchronous mode (1.) - if ( isSync() ) { - QTextCursor cur = textCursor(); - cur.movePosition( QTextCursor::End ); - cur.movePosition( QTextCursor::Left, QTextCursor::KeepAnchor, PROMPT_SIZE ); - cur.removeSelectedText(); - setTextCursor( cur ); - } - // [ END ] workaround for the synchronous mode (1.) - addText( pe->text() ); - - // [ BEGIN ] workaround for the synchronous mode (2.) - if ( isSync() ) { - addText( myPrompt ); - } - // [ END ] workaround for the synchronous mode (2.) - return; } - case PyInterp_Event::OK: - case PyInterp_Event::ERRORS: + case PyInterp_Event::ES_OK: + case PyInterp_Event::ES_ERROR: { // clear command buffer myCommandBuffer.truncate( 0 ); @@ -904,7 +887,7 @@ void PyConsole_Editor::customEvent( QEvent* event ) myEventLoop->exit(); break; } - case PyInterp_Event::INCOMPLETE: + case PyInterp_Event::ES_INCOMPLETE: { // extend command buffer (multi-line command) myCommandBuffer.append( "\n" ); @@ -929,7 +912,7 @@ void PyConsole_Editor::customEvent( QEvent* event ) // unset history browsing mode myCmdInHistory = -1; - if ( (int)event->type() == (int)PyInterp_Event::OK && myQueue.count() > 0 ) + if ( (int)event->type() == (int)PyInterp_Event::ES_OK && myQueue.count() > 0 ) { // process the next sheduled command from the queue (if there is any) QString nextcmd = myQueue[0]; diff --git a/src/PyInterp/PyInterp_Dispatcher.cxx b/src/PyInterp/PyInterp_Dispatcher.cxx index 917298417..6ff519b1f 100755 --- a/src/PyInterp/PyInterp_Dispatcher.cxx +++ b/src/PyInterp/PyInterp_Dispatcher.cxx @@ -66,7 +66,7 @@ void PyInterp_Request::Destroy( PyInterp_Request* request ) QEvent* PyInterp_Request::createEvent() const { - return new PyInterp_Event( PyInterp_Event::NOTIFY, (PyInterp_Request*)this ); + return new PyInterp_Event( PyInterp_Event::ES_NOTIFY, (PyInterp_Request*)this ); } void PyInterp_Request::processEvent( QObject* o ) diff --git a/src/PyInterp/PyInterp_Dispatcher.h b/src/PyInterp/PyInterp_Dispatcher.h index 6f6240794..237e5e650 100755 --- a/src/PyInterp/PyInterp_Dispatcher.h +++ b/src/PyInterp/PyInterp_Dispatcher.h @@ -73,11 +73,12 @@ protected: virtual void processEvent( QObject* ); -private: - void process(); QObject* listener() const { return myListener; } void setListener( QObject* ); +private: + void process(); + private: QMutex myMutex; bool myIsSync; @@ -105,7 +106,7 @@ class PYINTERP_EXPORT PyInterp_Event : public QEvent PyInterp_Event( const PyInterp_Event& ); public: - enum { NOTIFY = QEvent::User + 5000, OK, ERROR, INCOMPLETE, LAST }; + enum { ES_NOTIFY = QEvent::User + 5000, ES_OK, ES_ERROR, ES_INCOMPLETE, ES_USER } ExecState; PyInterp_Event( int type, PyInterp_Request* request ) : QEvent( (QEvent::Type)type ), myRequest( request ) {} -- 2.39.2