]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
Bug NPAL16035: Pb with the history list of salome (GUI)
authorsln <sln@opencascade.com>
Fri, 25 May 2007 12:18:15 +0000 (12:18 +0000)
committersln <sln@opencascade.com>
Fri, 25 May 2007 12:18:15 +0000 (12:18 +0000)
Case when two long commands are executed consequently fixed

src/PythonConsole/PythonConsole_PyEditor.cxx

index 6de0f03c84220fe8fa2ca66a59787feac34a34c1..baa34cac9348d9e61716164fa05bd022133a4396 100755 (executable)
@@ -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();
+      }
     }
   }
 }