From: stv Date: Tue, 7 Jun 2005 06:26:26 +0000 (+0000) Subject: IPAL9013: Undo/Redo disabled and removed from context popup menu of Python Console. X-Git-Tag: T3_0_0_a2~19 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=d500afd564031d89350f416167f52fb6f9b46345;p=modules%2Fgui.git IPAL9013: Undo/Redo disabled and removed from context popup menu of Python Console. --- diff --git a/src/PythonConsole/PythonConsole_PyEditor.cxx b/src/PythonConsole/PythonConsole_PyEditor.cxx index ba55b25ca..7ba34c58d 100755 --- a/src/PythonConsole/PythonConsole_PyEditor.cxx +++ b/src/PythonConsole/PythonConsole_PyEditor.cxx @@ -24,21 +24,20 @@ // File : PythonConsole_PyEditor.cxx // Author : Nicolas REJNERI // Module : SALOME -// $Header$ #include // this include must be first (see PyInterp_base.h)! + #include + #include -#include #include #include #include +#include -//#include "utilities.h" using namespace std; - //#ifdef _DEBUG_ //static int MYDEBUG = 1; //#else @@ -105,6 +104,7 @@ PythonConsole_PyEditor::PythonConsole_PyEditor(PyInterp_base* theInterp, QWidget QFont aFont = SUIT_Tools::stringToFont( fntSet ); setFont(aFont); setTextFormat(QTextEdit::PlainText); + setUndoRedoEnabled( false ); _currentPrompt = READY_PROMPT; setWordWrap(NoWrap); @@ -307,8 +307,6 @@ void PythonConsole_PyEditor::keyPressEvent( QKeyEvent* e ) bool ctrlPressed = e->state() & ControlButton; // check if is pressed bool shftPressed = e->state() & ShiftButton; - // check if is pressed - bool altPressed = e->state() & AltButton; // process + key-bindings if ( aKey == Key_C && ctrlPressed ) { @@ -701,3 +699,22 @@ void PythonConsole_PyEditor::onPyInterpChanged( PyInterp_base* interp ) } } } + +QPopupMenu* PythonConsole_PyEditor::createPopupMenu( const QPoint& pos ) +{ + QPopupMenu* popup = QTextEdit::createPopupMenu( pos ); + + QValueList ids; + for ( int i = 0; popup && i < popup->count(); i++ ) + { + if ( !popup->isItemEnabled( popup->idAt( i ) ) ) + ids.append( popup->idAt( i ) ); + } + + for ( QValueList::const_iterator it = ids.begin(); it != ids.end(); ++it ) + popup->removeItem( *it ); + + SUIT_Tools::simplifySeparators( popup ); + + return popup; +} diff --git a/src/PythonConsole/PythonConsole_PyEditor.h b/src/PythonConsole/PythonConsole_PyEditor.h index 821fdec87..b5d303a60 100755 --- a/src/PythonConsole/PythonConsole_PyEditor.h +++ b/src/PythonConsole/PythonConsole_PyEditor.h @@ -24,7 +24,6 @@ // File : PythonConsole_PyEditor.h // Author : Nicolas REJNERI // Module : SALOME -// $Header$ #ifndef PythonConsole_PyEditor_H #define PythonConsole_PyEditor_H @@ -59,6 +58,8 @@ protected: public slots: void handleReturn(); void onPyInterpChanged( PyInterp_base* ); + + virtual QPopupMenu* createPopupMenu( const QPoint& ); private: QString _buf;