changeset 15316:35fe4b9909a8

keep history in gui widget in chronological order, top to bottom * history-docwidget.cc (history_dock_widget::event_accepted): Insert new items at the bottom of the list. Scroll to bottom of list view widget after inserting new items.
author John W. Eaton <jwe@octave.org>
date Thu, 06 Sep 2012 13:49:04 -0400
parents 67ef63ead023
children ba243f0234b0
files libgui/src/history-dockwidget.cc
diffstat 1 files changed, 10 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/src/history-dockwidget.cc
+++ b/libgui/src/history-dockwidget.cc
@@ -50,13 +50,20 @@
       // them to our history.
       if (clientHistoryLength < serverHistoryLength)
         {
+          int elts_to_add = serverHistoryLength - clientHistoryLength;
+
+          _history_model->insertRows (clientHistoryLength, elts_to_add);
+
           for (int i = clientHistoryLength; i < serverHistoryLength; i++)
             {
-              _history_model->insertRow (0);
-              _history_model->setData (_history_model->index (0),
-                QString (command_history::get_entry (i).c_str ()));
+              std::string entry = command_history::get_entry (i);
+
+              _history_model->setData (_history_model->index (i),
+                                       QString::fromStdString (entry));
             }
         }
+
+      _history_list_view->scrollToBottom ();
     }
 
   // Post a new update event in a given time. This prevents flooding the