changeset 17254:7fb4461997aa

Adjust history window copy/evaluate and remove carriage returns (bug #39722) * history-dock-widget.cc (history_dock_widget::handle_contextmenu_copy): Add prev_valid_row variable and only add carriage-return between valid lines of text. (history_dock_widget::handle_contextmenu_evaluate): Remove "\n" from end of line sent to Octave core. (history_dock_widget::handle_contextmenu_create_script) Add prev_valid_row variable and only add carriage-return between valid lines of text. (history_dock_widget::handle_double_click) Remove "\n" from end of line sent to Octave core. (history_dock_widget::pasteClipboard) Format consistent with elsewhere.
author Daniel J Sebald <daniel.sebald@ieee.org>
date Wed, 07 Aug 2013 20:18:04 -0500
parents e3870f594d8b
children a28c0d73e253 92effb035b97
files libgui/src/history-dock-widget.cc
diffstat 1 files changed, 28 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/src/history-dock-widget.cc	Wed Aug 14 16:45:50 2013 -0500
+++ b/libgui/src/history-dock-widget.cc	Wed Aug 07 20:18:04 2013 -0500
@@ -105,11 +105,17 @@
   QItemSelectionModel *selectionModel = _history_list_view->selectionModel();
   QModelIndexList rows = selectionModel->selectedRows();
   QModelIndexList::iterator it;
-  for (it=rows.begin() ; it != rows.end(); it++) {
-    if ((*it).isValid()) {
-      text += (*it).data().toString()+"\n";
+  bool prev_valid_row = false;
+  for (it = rows.begin(); it != rows.end(); it++)
+    {
+      if ((*it).isValid())
+        {
+          if (prev_valid_row)
+            text += "\n";
+          text += (*it).data().toString();
+          prev_valid_row = true;
+        }
     }
-  }
   QApplication::clipboard()->setText(text);
 }
 
@@ -118,11 +124,11 @@
   QItemSelectionModel *selectionModel = _history_list_view->selectionModel();
   QModelIndexList rows = selectionModel->selectedRows();
   QModelIndexList::iterator it;
-  for (it=rows.begin() ; it != rows.end(); it++) {
-    if ((*it).isValid()) {
-      emit command_double_clicked ((*it).data().toString()+"\n");
+  for (it = rows.begin() ; it != rows.end(); it++)
+    {
+      if ((*it).isValid())
+        emit command_double_clicked ((*it).data().toString());
     }
-  }
 }
 
 void
@@ -132,10 +138,16 @@
   QItemSelectionModel *selectionModel = _history_list_view->selectionModel ();
   QModelIndexList rows = selectionModel->selectedRows ();
 
+  bool prev_valid_row = false;
   for (QModelIndexList::iterator it = rows.begin (); it != rows.end (); it++)
     {
       if ((*it).isValid ())
-        text += (*it).data().toString() + "\n";
+        {
+          if (prev_valid_row)
+            text += "\n";
+          text += (*it).data().toString();
+          prev_valid_row = true;
+        }
     }
 
   if (text.length () > 0)
@@ -146,7 +158,7 @@
 void
 history_dock_widget::handle_double_click (QModelIndex modelIndex)
 {
-  emit command_double_clicked (modelIndex.data().toString()+"\n");
+  emit command_double_clicked (modelIndex.data().toString());
 }
 
 void
@@ -195,11 +207,11 @@
 history_dock_widget::pasteClipboard ()
 {
   if(_filter_line_edit->hasFocus ())
-  {
-     QClipboard *clipboard = QApplication::clipboard ();
-     QString str =  clipboard->text ();
-     if (str.length() > 0)
-       _filter_line_edit->insert (str);
-  } 
+    {
+      QClipboard *clipboard = QApplication::clipboard ();
+      QString str =  clipboard->text ();
+      if (str.length() > 0)
+        _filter_line_edit->insert (str);
+    }
 }