From ec3b1baf5c369b9e60b3bcaf4c8fa40f8faa3642 Mon Sep 17 00:00:00 2001 From: sln Date: Fri, 25 May 2007 12:18:15 +0000 Subject: [PATCH] Bug NPAL16035: Pb with the history list of salome (GUI) Case when two long commands are executed consequently fixed --- src/PythonConsole/PythonConsole_PyEditor.cxx | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/PythonConsole/PythonConsole_PyEditor.cxx b/src/PythonConsole/PythonConsole_PyEditor.cxx index 6de0f03c8..baa34cac9 100755 --- a/src/PythonConsole/PythonConsole_PyEditor.cxx +++ b/src/PythonConsole/PythonConsole_PyEditor.cxx @@ -812,13 +812,26 @@ void PythonConsole_PyEditor::scrollViewAfterHistoryUsing( const QString& command { if ( !command.isEmpty() ) { + if ( command == QString( BEGIN_HISTORY_PY ) ) + { + ensureCursorVisible(); + return; + } + int aCommandLength = QFontMetrics( currentFont() ).width( command ); int aVisibleWidth = visibleWidth(); - if ( aCommandLength < aVisibleWidth ) + QScrollBar* aBar = horizontalScrollBar(); + if ( aBar ) { - QScrollBar* aBar = horizontalScrollBar(); - if ( aBar ) + if ( aCommandLength <= aVisibleWidth ) aBar->setValue( aBar->minValue() ); + else if ( aVisibleWidth > 0 ) + { + double aRatio = aCommandLength / contentsWidth(); + double aPos = ( aBar->maxValue() - aBar->minValue() ) * aRatio; + aBar->setValue( (int)aPos ); + ensureCursorVisible(); + } } } } -- 2.39.2