comparison libgui/src/files-dock-widget.cc @ 16504:49b059bf27c7

allow loading files from file browser * files-dock-widget.h, files-dock-widget.cc (files_dock_widget::contextmenu_requested): Create menu item for loading files. (files_dock_widget::contextmenu_load): New function. (files_dock_widget::load_file_signal): New signal. * main-window.h, main-window.cc (main_window::construct): Connect file_browser_window::load_file_signal to main_window::handle_load_workspace_request. (main_window::load_workspace_callback): Update workspace after loading file. (main_window::handle_load_workspace_request): New argument for passing file name.
author John W. Eaton <jwe@octave.org>
date Fri, 12 Apr 2013 14:51:47 -0400
parents c1ff738d606d
children 8a4960f2c7c3
comparison
equal deleted inserted replaced
16503:c1ff738d606d 16504:49b059bf27c7
281 if (index.isValid()) 281 if (index.isValid())
282 { 282 {
283 QFileInfo info = _file_system_model->fileInfo(index); 283 QFileInfo info = _file_system_model->fileInfo(index);
284 284
285 menu.addAction(tr("Open"), this, SLOT(contextmenu_open(bool))); 285 menu.addAction(tr("Open"), this, SLOT(contextmenu_open(bool)));
286 menu.addAction(tr("Load Data"), this, SLOT(contextmenu_load(bool)));
286 menu.addSeparator(); 287 menu.addSeparator();
287 menu.addAction(tr("Rename"), this, SLOT(contextmenu_rename(bool))); 288 menu.addAction(tr("Rename"), this, SLOT(contextmenu_rename(bool)));
288 menu.addAction(tr("Delete"), this, SLOT(contextmenu_delete(bool))); 289 menu.addAction(tr("Delete"), this, SLOT(contextmenu_delete(bool)));
289 290
290 if(info.isDir()) 291 if(info.isDir())
307 QModelIndexList rows = m->selectedRows (); 308 QModelIndexList rows = m->selectedRows ();
308 309
309 for( QModelIndexList::iterator it = rows.begin (); it != rows.end (); it++) 310 for( QModelIndexList::iterator it = rows.begin (); it != rows.end (); it++)
310 { 311 {
311 item_double_clicked(*it); 312 item_double_clicked(*it);
313 }
314 }
315
316 void
317 files_dock_widget::contextmenu_load (bool)
318 {
319 QItemSelectionModel *m = _file_tree_view->selectionModel ();
320 QModelIndexList rows = m->selectedRows ();
321
322 if (rows.size () > 0)
323 {
324 QModelIndex index = rows[0];
325
326 QFileInfo info = _file_system_model->fileInfo(index);
327
328 emit load_file_signal (info.fileName ());
312 } 329 }
313 } 330 }
314 331
315 void 332 void
316 files_dock_widget::contextmenu_rename (bool) 333 files_dock_widget::contextmenu_rename (bool)