Mercurial > hg > octave-shane
changeset 16699:d4bcb38ad056
Added find files context menu to files-dock-widget
* libgui/src/files-dock-widget.cc, libgui/src/files-dock-widget.h
(files_dock_widget::files_dock_widget): added Find Files popdown menu.
(files_dock_widget::contextmenu_requested): Added Find Files context menu item.
(files_dock_widget::contextmenu_findfiles): New function.
(files_dock_widget::popdownmenu_findfiles): New function.
(files_dock_widget::process_find_files): New function.
(files_dock_widget::find_files_signal): New signal.
* libgui/src/main-window.cc:
(main_window::construct): Connected files_dock_widget::find_files_signal to main_window::find_files signal.
author | John Donoghue <john.donoghue@ieee.org> |
---|---|
date | Fri, 24 May 2013 21:45:40 -0400 |
parents | bf1de4943a5d |
children | cd7d08b8c928 |
files | libgui/src/files-dock-widget.cc libgui/src/files-dock-widget.h libgui/src/main-window.cc |
diffstat | 3 files changed, 45 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/src/files-dock-widget.cc +++ b/libgui/src/files-dock-widget.cc @@ -119,6 +119,9 @@ tr ("Search directory"), this, SLOT (popdownmenu_search_dir (bool))); popdown_menu->addSeparator(); + popdown_menu->addAction( tr ("Find Files ..."), + this, SLOT(popdownmenu_findfiles(bool))); + popdown_menu->addSeparator(); popdown_menu->addAction(QIcon(":/actions/icons/filenew.png"), tr ("New File"), this, SLOT(popdownmenu_newfile(bool))); @@ -359,6 +362,8 @@ menu.addAction (QIcon (":/actions/icons/ok.png"), tr ("Set Current Directory"), this, SLOT (contextmenu_setcurrentdir (bool))); + menu.addSeparator (); + menu.addAction (tr ("Find Files ..."), this, SLOT(contextmenu_findfiles(bool))); } menu.addSeparator(); @@ -576,6 +581,25 @@ } } +void +files_dock_widget::contextmenu_findfiles (bool) +{ + QItemSelectionModel *m = _file_tree_view->selectionModel (); + QModelIndexList rows = m->selectedRows (); + + if(rows.size() > 0) + { + QModelIndex index = rows[0]; + + QFileInfo info = _file_system_model->fileInfo(index); + + if(info.isDir()) + { + process_find_files(info.absoluteFilePath ()); + } + } +} + void files_dock_widget::notice_settings (const QSettings *settings) { @@ -615,6 +639,12 @@ } void +files_dock_widget::popdownmenu_findfiles (bool) +{ + process_find_files(_file_system_model->rootPath()); +} + +void files_dock_widget::popdownmenu_newdir (bool) { process_new_dir(_file_system_model->rootPath()); @@ -662,3 +692,9 @@ { emit displayed_directory_changed (dir); } + +void files_dock_widget::process_find_files(const QString & dir) +{ + emit find_files_signal(dir); +} +
--- a/libgui/src/files-dock-widget.h +++ b/libgui/src/files-dock-widget.h @@ -94,11 +94,13 @@ void contextmenu_newfile (bool); void contextmenu_newdir (bool); void contextmenu_setcurrentdir (bool); + void contextmenu_findfiles (bool); /* popdown menu options */ void popdownmenu_newfile(bool); void popdownmenu_newdir(bool); void popdownmenu_search_dir (bool); + void popdownmenu_findfiles (bool); signals: @@ -114,10 +116,14 @@ /** Emitted, whenever the user requested to run a file. */ void run_file_signal (const QFileInfo& info); + /** Emitted, whenever wants to search for a file . */ + void find_files_signal (const QString &startdir); + private: void process_new_file(const QString &parent_name); void process_new_dir(const QString &parent_name); void process_set_current_dir(const QString &parent_name); + void process_find_files(const QString &dir_name); /** set a new directory or open a file **/ void display_directory (const QString& dir, bool set_octave_dir = true);
--- a/libgui/src/main-window.cc +++ b/libgui/src/main-window.cc @@ -796,6 +796,9 @@ connect (file_browser_window, SIGNAL (load_file_signal (const QString&)), this, SLOT (handle_load_workspace_request (const QString&))); + connect (file_browser_window, SIGNAL (find_files_signal (const QString&)), + this, SLOT (find_files (const QString&))); + connect_uiwidget_links (); setWindowTitle ("Octave");