# HG changeset patch # User Daniel J Sebald # Date 1375924684 18000 # Node ID 7fb4461997aa212b9e44397351c7c0eb7d78f32b # Parent e3870f594d8b9ee68fa81a53e5b58684c388ae95 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. diff -r e3870f594d8b -r 7fb4461997aa libgui/src/history-dock-widget.cc --- 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); + } }