# HG changeset patch
# User John Donoghue <john.donoghue@ieee.org>
# Date 1369446340 14400
# Node ID d4bcb38ad0560096bb9c009fa6f4fdfb2a73c775
# Parent  bf1de4943a5d6723ab655ab5b58907da53e8842d
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.

diff -r bf1de4943a5d -r d4bcb38ad056 libgui/src/files-dock-widget.cc
--- a/libgui/src/files-dock-widget.cc	Fri May 24 10:30:18 2013 -0400
+++ b/libgui/src/files-dock-widget.cc	Fri May 24 21:45:40 2013 -0400
@@ -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);
+}
+
diff -r bf1de4943a5d -r d4bcb38ad056 libgui/src/files-dock-widget.h
--- a/libgui/src/files-dock-widget.h	Fri May 24 10:30:18 2013 -0400
+++ b/libgui/src/files-dock-widget.h	Fri May 24 21:45:40 2013 -0400
@@ -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);
diff -r bf1de4943a5d -r d4bcb38ad056 libgui/src/main-window.cc
--- a/libgui/src/main-window.cc	Fri May 24 10:30:18 2013 -0400
+++ b/libgui/src/main-window.cc	Fri May 24 21:45:40 2013 -0400
@@ -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");
