diff libgui/src/history-dockwidget.cc @ 16452:744ff2fe11ce

add create script context menu to history window * history-dockwidget.h (history_doc_widget::command_create_script): New signal. * history-dockwidget.cc, history-dockwidget.h (history_dock_widget::ctxMenu): New menu item, Create script. (history_dock_widget::handle_contextmenu_create_script): New function. * file-editor-interface.h (file-editor-interface::request_new_file): New argument, commands. * file-editor-tab.h, file-editor-tab.cc (file_editor_tab::new_file): New argument, commands. * m-editor/file-editor.h, m-editor/file-editor.cc (file_editor::new_file, file_editor::request_new_file): New argument, commands. * main-window.h, main-window.cc (main_window::new_file): New argument, commands. main_window::construct): Connect history_window::command_create_script signal to main_window::new_file.
author John Donoghue <john.donoghue@ieee.org>
date Sat, 06 Apr 2013 23:58:58 -0400
parents e3b33a7530bc
children 38ed6bdd1f7f
line wrap: on
line diff
--- a/libgui/src/history-dockwidget.cc	Sat Apr 06 23:43:23 2013 -0400
+++ b/libgui/src/history-dockwidget.cc	Sat Apr 06 23:58:58 2013 -0400
@@ -98,6 +98,7 @@
     QMenu menu(this);
     menu.addAction(tr("Copy"), this, SLOT(handle_contextmenu_copy(bool)));
     menu.addAction(tr("Evaluate"), this, SLOT(handle_contextmenu_evaluate(bool)));
+    menu.addAction(tr("Create script"), this, SLOT(handle_contextmenu_create_script(bool)));
     menu.exec(_history_list_view->mapToGlobal(xpos));
 }
 
@@ -128,6 +129,24 @@
 }
 
 void
+history_dock_widget::handle_contextmenu_create_script (bool)
+{
+  QString text;
+  QItemSelectionModel *selectionModel = _history_list_view->selectionModel ();
+  QModelIndexList rows = selectionModel->selectedRows ();
+
+  for (QModelIndexList::iterator it = rows.begin (); it != rows.end (); it++)
+    {
+      if ((*it).isValid ())
+        text += (*it).data().toString() + "\n";
+    }
+
+  if (text.length () > 0)
+    emit command_create_script (text);
+}
+
+
+void
 history_dock_widget::handle_double_click (QModelIndex modelIndex)
 {
   emit command_double_clicked (modelIndex.data().toString()+"\n");