changeset 24733:e15d53d2de1e

move more GUI classse inside octave namespace * documentation-dock-widget.h, documentation-dock-widget.cc, files-dock-widget.h, files-dock-widget.cc, find-files-dialog.h, find-files-dialog.cc, find-files-model.h, find-files-model.cc, history-dock-widget.h, history-dock-widget.cc, terminal-dock-widget.h, terminal-dock-widget.cc: Move classes inside octave namespace.
author John W. Eaton <jwe@octave.org>
date Sun, 11 Feb 2018 09:20:36 -0500
parents f079a0856321
children 5d8c4cbc56d7
files libgui/src/documentation-dock-widget.cc libgui/src/documentation-dock-widget.h libgui/src/files-dock-widget.cc libgui/src/files-dock-widget.h libgui/src/find-files-dialog.cc libgui/src/find-files-dialog.h libgui/src/find-files-model.cc libgui/src/find-files-model.h libgui/src/history-dock-widget.cc libgui/src/history-dock-widget.h libgui/src/terminal-dock-widget.cc libgui/src/terminal-dock-widget.h
diffstat 12 files changed, 1828 insertions(+), 1869 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/src/documentation-dock-widget.cc	Sat Feb 10 23:32:04 2018 -0500
+++ b/libgui/src/documentation-dock-widget.cc	Sun Feb 11 09:20:36 2018 -0500
@@ -29,65 +29,62 @@
 #include "help.h"
 #include "interpreter-private.h"
 
-documentation_dock_widget::documentation_dock_widget (QWidget *p)
-  : octave_dock_widget (p)
+namespace octave
 {
-  setObjectName ("DocumentationDockWidget");
-  setWindowIcon (QIcon (":/actions/icons/logo.png"));
-  set_title (tr ("Documentation"));
-  setStatusTip (tr ("See the documentation for help."));
+  documentation_dock_widget::documentation_dock_widget (QWidget *p)
+    : octave_dock_widget (p)
+  {
+    setObjectName ("DocumentationDockWidget");
+    setWindowIcon (QIcon (":/actions/icons/logo.png"));
+    set_title (tr ("Documentation"));
+    setStatusTip (tr ("See the documentation for help."));
 
-  m_webinfo = new octave::webinfo (this);
-  setWidget (m_webinfo);
-  setFocusProxy (m_webinfo);
+    m_webinfo = new octave::webinfo (this);
+    setWidget (m_webinfo);
+    setFocusProxy (m_webinfo);
 
-  connect (p, SIGNAL (show_doc_signal (const QString&)),
-           this, SLOT (showDoc (const QString&)));
-}
+    connect (p, SIGNAL (show_doc_signal (const QString&)),
+             this, SLOT (showDoc (const QString&)));
+  }
 
-void
-documentation_dock_widget::notice_settings (const QSettings *settings)
-{
-  m_webinfo->notice_settings (settings);
-}
+  void documentation_dock_widget::notice_settings (const QSettings *settings)
+  {
+    m_webinfo->notice_settings (settings);
+  }
 
-void
-documentation_dock_widget::load_info_file (void)
-{
-  octave::help_system& help_sys
-    = octave::__get_help_system__ ("doc widget: load_info_file");
+  void documentation_dock_widget::load_info_file (void)
+  {
+    octave::help_system& help_sys
+      = octave::__get_help_system__ ("doc widget: load_info_file");
 
-  QString info_file = QString::fromStdString (help_sys.info_file ());
+    QString info_file = QString::fromStdString (help_sys.info_file ());
 
-  m_webinfo->load_info_file (info_file);
-}
+    m_webinfo->load_info_file (info_file);
+  }
 
-void
-documentation_dock_widget::copyClipboard (void)
-{
-  m_webinfo->copyClipboard ();
-}
+  void documentation_dock_widget::copyClipboard (void)
+  {
+    m_webinfo->copyClipboard ();
+  }
 
-void
-documentation_dock_widget::pasteClipboard (void)
-{
-  m_webinfo->pasteClipboard ();
-}
+  void documentation_dock_widget::pasteClipboard (void)
+  {
+    m_webinfo->pasteClipboard ();
+  }
 
-void
-documentation_dock_widget::selectAll (void)
-{
-  m_webinfo->selectAll ();
-}
+  void documentation_dock_widget::selectAll (void)
+  {
+    m_webinfo->selectAll ();
+  }
 
-void
-documentation_dock_widget::showDoc (const QString& name)
-{
-  // show the doc pane without focus for carrying on typing in the console
-  if (! isVisible ())
-    setVisible (true);
+  void documentation_dock_widget::showDoc (const QString& name)
+  {
+    // show the doc pane without focus for carrying on typing in the console
+    if (! isVisible ())
+      setVisible (true);
 
-  raise ();
+    raise ();
 
-  m_webinfo->load_ref (name);
+    m_webinfo->load_ref (name);
+  }
 }
--- a/libgui/src/documentation-dock-widget.h	Sat Feb 10 23:32:04 2018 -0500
+++ b/libgui/src/documentation-dock-widget.h	Sun Feb 11 09:20:36 2018 -0500
@@ -27,31 +27,34 @@
 
 #include "webinfo.h"
 
-class documentation_dock_widget : public octave_dock_widget
+namespace octave
 {
-  Q_OBJECT
-
-public:
+  class documentation_dock_widget : public octave_dock_widget
+  {
+    Q_OBJECT
 
-  documentation_dock_widget (QWidget *parent = nullptr);
+  public:
+
+    documentation_dock_widget (QWidget *parent = nullptr);
 
-public slots:
+  public slots:
 
-  void notice_settings (const QSettings *settings);
+    void notice_settings (const QSettings *settings);
 
-  void load_info_file (void);
+    void load_info_file (void);
+
+  protected slots:
 
-protected slots:
+    void copyClipboard (void);
+    void pasteClipboard (void);
+    void selectAll (void);
 
-  void copyClipboard (void);
-  void pasteClipboard (void);
-  void selectAll (void);
+    void showDoc (const QString & name);
+
+  private:
 
-  void showDoc (const QString & name);
-
-private:
-
-  octave::webinfo *m_webinfo;
-};
+    octave::webinfo *m_webinfo;
+  };
+}
 
 #endif
--- a/libgui/src/files-dock-widget.cc	Sat Feb 10 23:32:04 2018 -0500
+++ b/libgui/src/files-dock-widget.cc	Sun Feb 11 09:20:36 2018 -0500
@@ -48,927 +48,895 @@
 #include "load-save.h"
 #include "oct-env.h"
 
-class FileTreeViewer : public QTreeView
-{
-public:
-
-  FileTreeViewer (QWidget *p) : QTreeView (p) { }
-
-  ~FileTreeViewer (void) = default;
-
-  void mousePressEvent (QMouseEvent *e)
-  {
-    if (e->button () != Qt::RightButton)
-      QTreeView::mousePressEvent (e);
-  }
-};
-
-files_dock_widget::files_dock_widget (QWidget *p)
-  : octave_dock_widget (p)
-{
-  setObjectName ("FilesDockWidget");
-  setWindowIcon (QIcon (":/actions/icons/logo.png"));
-  set_title (tr ("File Browser"));
-  setToolTip (tr ("Browse your files"));
-
-  m_sig_mapper = nullptr;
-
-  m_columns_shown = QStringList ();
-  m_columns_shown.append (tr ("File size"));
-  m_columns_shown.append (tr ("File type"));
-  m_columns_shown.append (tr ("Date modified"));
-  m_columns_shown.append (tr ("Show hidden"));
-  m_columns_shown.append (tr ("Alternating row colors"));
-
-  m_columns_shown_keys = QStringList ();
-  m_columns_shown_keys.append ("filesdockwidget/showFileSize");
-  m_columns_shown_keys.append ("filesdockwidget/showFileType");
-  m_columns_shown_keys.append ("filesdockwidget/showLastModified");
-  m_columns_shown_keys.append ("filesdockwidget/showHiddenFiles");
-  m_columns_shown_keys.append ("filesdockwidget/useAlternatingRowColors");
-
-  QWidget *container = new QWidget (this);
-
-  setWidget (container);
-
-  connect (this, SIGNAL (open_file (const QString&)),
-           main_win (), SLOT (open_file (const QString&)));
-
-  connect (this, SIGNAL (displayed_directory_changed (const QString&)),
-           main_win (), SLOT (set_current_working_directory (const QString&)));
-
-  // Create a toolbar
-  m_navigation_tool_bar = new QToolBar ("", container);
-  m_navigation_tool_bar->setAllowedAreas (Qt::TopToolBarArea);
-  m_navigation_tool_bar->setMovable (false);
-
-  m_current_directory = new QComboBox (m_navigation_tool_bar);
-  m_current_directory->setToolTip (tr ("Enter the path or filename"));
-  m_current_directory->setEditable (true);
-  m_current_directory->setMaxCount (MaxMRUDirs);
-  m_current_directory->setInsertPolicy (QComboBox::NoInsert);
-  m_current_directory->setSizeAdjustPolicy (
-    QComboBox::AdjustToMinimumContentsLengthWithIcon);
-  QSizePolicy sizePol (QSizePolicy::Expanding, QSizePolicy::Preferred);
-  m_current_directory->setSizePolicy (sizePol);
-
-  QAction *directory_up_action = new QAction (resource_manager::icon ("go-up"),
-                                              "", m_navigation_tool_bar);
-  directory_up_action->setToolTip (tr ("One directory up"));
-
-  m_sync_browser_directory_action
-    = new QAction (resource_manager::icon ("go-first"),
-                   tr ("Show Octave directory"), m_navigation_tool_bar);
-  m_sync_browser_directory_action->setToolTip (
-    tr ("Go to current Octave directory"));
-  m_sync_browser_directory_action->setEnabled ("false");
-
-  m_sync_octave_directory_action
-    = new QAction (resource_manager::icon ("go-last"),
-                   tr ("Set Octave directory"), m_navigation_tool_bar);
-  m_sync_octave_directory_action->setToolTip (
-    tr ("Set Octave directory to current browser directory"));
-  m_sync_octave_directory_action->setEnabled ("false");
-
-  QToolButton *popdown_button = new QToolButton ();
-  popdown_button->setToolTip (tr ("Actions on current directory"));
-  QMenu *popdown_menu = new QMenu ();
-  popdown_menu->addAction (resource_manager::icon ("user-home"),
-                           tr ("Show Home Directory"),
-                           this, SLOT (popdownmenu_home (bool)));
-  popdown_menu->addAction (m_sync_browser_directory_action);
-  popdown_menu->addAction (m_sync_octave_directory_action);
-  popdown_button->setMenu (popdown_menu);
-  popdown_button->setPopupMode (QToolButton::InstantPopup);
-  popdown_button->setDefaultAction (new QAction (
-                            resource_manager::icon ("applications-system"), "",
-                            m_navigation_tool_bar));
-
-  popdown_menu->addSeparator ();
-  popdown_menu->addAction (resource_manager::icon ("folder"),
-                           tr ("Set Browser Directory..."),
-                           this, SLOT (popdownmenu_search_dir (bool)));
-  popdown_menu->addSeparator ();
-  popdown_menu->addAction (resource_manager::icon ("edit-find"),
-                           tr ("Find Files..."),
-                           this, SLOT (popdownmenu_findfiles (bool)));
-  popdown_menu->addSeparator ();
-  popdown_menu->addAction (resource_manager::icon ("document-new"),
-                           tr ("New File..."),
-                           this, SLOT (popdownmenu_newfile (bool)));
-  popdown_menu->addAction (resource_manager::icon ("folder-new"),
-                           tr ("New Directory..."),
-                           this, SLOT (popdownmenu_newdir (bool)));
-
-  m_navigation_tool_bar->addWidget (m_current_directory);
-  m_navigation_tool_bar->addAction (directory_up_action);
-  m_navigation_tool_bar->addWidget (popdown_button);
-
-  connect (directory_up_action, SIGNAL (triggered ()), this,
-           SLOT (change_directory_up ()));
-  connect (m_sync_octave_directory_action, SIGNAL (triggered ()), this,
-           SLOT (do_sync_octave_directory ()));
-  connect (m_sync_browser_directory_action, SIGNAL (triggered ()), this,
-           SLOT (do_sync_browser_directory ()));
-
-  QSettings *settings = resource_manager::get_settings ();
-  // FIXME: what should happen if settings is 0?
-
-  // Create the QFileSystemModel starting in the desired directory
-  QDir startup_dir;  // take current dir
-
-  if (settings->value ("filesdockwidget/restore_last_dir",false).toBool ())
-    {
-      // restore last dir from previous session
-      QStringList last_dirs
-        = settings->value ("filesdockwidget/mru_dir_list").toStringList ();
-      if (last_dirs.length () > 0)
-        startup_dir = QDir (last_dirs.at (0));  // last dir in previous session
-    }
-  else if (! settings->value ("filesdockwidget/startup_dir").toString ().isEmpty ())
-    {
-      // do not restore but there is a startup dir configured
-      startup_dir
-        = QDir (settings->value ("filesdockwidget/startup_dir").toString ());
-    }
-
-  if (! startup_dir.exists ())
-    {
-      // the configured startup dir does not exist, take actual one
-      startup_dir = QDir ();
-    }
-
-  m_file_system_model = new QFileSystemModel (this);
-  QModelIndex rootPathIndex = m_file_system_model->setRootPath (
-                                startup_dir.absolutePath ());
-
-  // Attach the model to the QTreeView and set the root index
-  m_file_tree_view = new FileTreeViewer (container);
-  m_file_tree_view->setSelectionMode (QAbstractItemView::ExtendedSelection);
-  m_file_tree_view->setModel (m_file_system_model);
-  m_file_tree_view->setRootIndex (rootPathIndex);
-  m_file_tree_view->setSortingEnabled (true);
-  m_file_tree_view->setAlternatingRowColors (true);
-  m_file_tree_view->setAnimated (true);
-  m_file_tree_view->setToolTip (
-    tr ("Activate to open in editor, right click for alternatives"));
-
-  // get sort column and order as well as cloumn state (order and width)
-
-  m_file_tree_view->sortByColumn (
-    settings->value ("filesdockwidget/sort_files_by_column",0).toInt (),
-    static_cast<Qt::SortOrder>
-    (settings->value ("filesdockwidget/sort_files_by_order",
-                      Qt::AscendingOrder).toUInt ())
-  );
-  m_file_tree_view->header ()->restoreState (
-    settings->value ("filesdockwidget/column_state").toByteArray ());
-
-  QStringList mru_dirs =
-    settings->value ("filesdockwidget/mru_dir_list").toStringList ();
-  m_current_directory->addItems (mru_dirs);
-
-  m_current_directory->setEditText (
-    m_file_system_model->fileInfo (rootPathIndex).  absoluteFilePath ());
-
-  connect (m_file_tree_view, SIGNAL (activated (const QModelIndex &)),
-           this, SLOT (item_double_clicked (const QModelIndex &)));
-
-  // add context menu to tree_view
-  m_file_tree_view->setContextMenuPolicy (Qt::CustomContextMenu);
-  connect (m_file_tree_view,
-           SIGNAL (customContextMenuRequested (const QPoint &)),
-           this, SLOT (contextmenu_requested (const QPoint &)));
-
-  m_file_tree_view->header ()->setContextMenuPolicy (Qt::CustomContextMenu);
-  connect (m_file_tree_view->header (),
-           SIGNAL (customContextMenuRequested (const QPoint &)),
-           this, SLOT (headercontextmenu_requested (const QPoint &)));
-
-  // Layout the widgets vertically with the toolbar on top
-  QVBoxLayout *vbox_layout = new QVBoxLayout ();
-  vbox_layout->setSpacing (0);
-  vbox_layout->addWidget (m_navigation_tool_bar);
-  vbox_layout->addWidget (m_file_tree_view);
-  vbox_layout->setMargin (1);
-
-  container->setLayout (vbox_layout);
-
-  // FIXME: Add right-click contextual menus for copying, pasting,
-  //        deleting files (and others).
-
-  connect (m_current_directory->lineEdit (), SIGNAL (returnPressed ()),
-           this, SLOT (accept_directory_line_edit ()));
-
-  connect (m_current_directory, SIGNAL (activated (const QString &)),
-           this, SLOT (set_current_directory (const QString &)));
-
-  connect (this, SIGNAL (run_file_signal (const QFileInfo&)),
-           main_win (), SLOT (run_file_in_terminal (const QFileInfo&)));
-
-  QCompleter *completer = new QCompleter (m_file_system_model, this);
-  m_current_directory->setCompleter (completer);
-
-  setFocusProxy (m_current_directory);
-
-  m_sync_octave_dir = true;   // default, overwirtten with notice_settings ()
-  m_octave_dir = "";
-}
-
-void
-files_dock_widget::save_settings (void)
+namespace octave
 {
-  QSettings *settings = resource_manager::get_settings ();
+  class FileTreeViewer : public QTreeView
+  {
+  public:
 
-  if (! settings)
-    return;
+    FileTreeViewer (QWidget *p) : QTreeView (p) { }
+
+    ~FileTreeViewer (void) = default;
 
-  int sort_column = m_file_tree_view->header ()->sortIndicatorSection ();
-  Qt::SortOrder sort_order = m_file_tree_view->header ()->sortIndicatorOrder ();
-  settings->setValue ("filesdockwidget/sort_files_by_column", sort_column);
-  settings->setValue ("filesdockwidget/sort_files_by_order", sort_order);
-  settings->setValue ("filesdockwidget/column_state",
-                      m_file_tree_view->header ()->saveState ());
+    void mousePressEvent (QMouseEvent *e)
+    {
+      if (e->button () != Qt::RightButton)
+        QTreeView::mousePressEvent (e);
+    }
+  };
+
+  files_dock_widget::files_dock_widget (QWidget *p)
+    : octave_dock_widget (p)
+  {
+    setObjectName ("FilesDockWidget");
+    setWindowIcon (QIcon (":/actions/icons/logo.png"));
+    set_title (tr ("File Browser"));
+    setToolTip (tr ("Browse your files"));
 
-  QStringList dirs;
-  for (int i=0; i< m_current_directory->count (); i++)
-    {
-      dirs.append (m_current_directory->itemText (i));
-    }
-  settings->setValue ("filesdockwidget/mru_dir_list", dirs);
+    m_sig_mapper = nullptr;
+
+    m_columns_shown = QStringList ();
+    m_columns_shown.append (tr ("File size"));
+    m_columns_shown.append (tr ("File type"));
+    m_columns_shown.append (tr ("Date modified"));
+    m_columns_shown.append (tr ("Show hidden"));
+    m_columns_shown.append (tr ("Alternating row colors"));
 
-  settings->sync ();
-
-  octave_dock_widget::save_settings ();
+    m_columns_shown_keys = QStringList ();
+    m_columns_shown_keys.append ("filesdockwidget/showFileSize");
+    m_columns_shown_keys.append ("filesdockwidget/showFileType");
+    m_columns_shown_keys.append ("filesdockwidget/showLastModified");
+    m_columns_shown_keys.append ("filesdockwidget/showHiddenFiles");
+    m_columns_shown_keys.append ("filesdockwidget/useAlternatingRowColors");
 
-  if (m_sig_mapper)
-    delete m_sig_mapper;
-}
+    QWidget *container = new QWidget (this);
+
+    setWidget (container);
+
+    connect (this, SIGNAL (open_file (const QString&)),
+             main_win (), SLOT (open_file (const QString&)));
 
-void
-files_dock_widget::item_double_clicked (const QModelIndex& index)
-{
-  // Retrieve the file info associated with the model index.
-  QFileInfo fileInfo = m_file_system_model->fileInfo (index);
-  set_current_directory (fileInfo.absoluteFilePath ());
-}
+    connect (this, SIGNAL (displayed_directory_changed (const QString&)),
+             main_win (), SLOT (set_current_working_directory (const QString&)));
+
+    // Create a toolbar
+    m_navigation_tool_bar = new QToolBar ("", container);
+    m_navigation_tool_bar->setAllowedAreas (Qt::TopToolBarArea);
+    m_navigation_tool_bar->setMovable (false);
 
-void
-files_dock_widget::set_current_directory (const QString& dir)
-{
-  display_directory (dir);
-}
+    m_current_directory = new QComboBox (m_navigation_tool_bar);
+    m_current_directory->setToolTip (tr ("Enter the path or filename"));
+    m_current_directory->setEditable (true);
+    m_current_directory->setMaxCount (MaxMRUDirs);
+    m_current_directory->setInsertPolicy (QComboBox::NoInsert);
+    m_current_directory->setSizeAdjustPolicy (
+                                              QComboBox::AdjustToMinimumContentsLengthWithIcon);
+    QSizePolicy sizePol (QSizePolicy::Expanding, QSizePolicy::Preferred);
+    m_current_directory->setSizePolicy (sizePol);
+
+    QAction *directory_up_action = new QAction (resource_manager::icon ("go-up"),
+                                                "", m_navigation_tool_bar);
+    directory_up_action->setToolTip (tr ("One directory up"));
 
-void
-files_dock_widget::accept_directory_line_edit (void)
-{
-  display_directory (m_current_directory->currentText ());
-}
+    m_sync_browser_directory_action
+      = new QAction (resource_manager::icon ("go-first"),
+                     tr ("Show Octave directory"), m_navigation_tool_bar);
+    m_sync_browser_directory_action->setToolTip (
+                                                 tr ("Go to current Octave directory"));
+    m_sync_browser_directory_action->setEnabled ("false");
+
+    m_sync_octave_directory_action
+      = new QAction (resource_manager::icon ("go-last"),
+                     tr ("Set Octave directory"), m_navigation_tool_bar);
+    m_sync_octave_directory_action->setToolTip (
+                                                tr ("Set Octave directory to current browser directory"));
+    m_sync_octave_directory_action->setEnabled ("false");
 
-void
-files_dock_widget::change_directory_up (void)
-{
-  QDir dir
-    = QDir (m_file_system_model->filePath (m_file_tree_view->rootIndex ()));
-
-  dir.cdUp ();
-  display_directory (dir.absolutePath ());
-}
+    QToolButton *popdown_button = new QToolButton ();
+    popdown_button->setToolTip (tr ("Actions on current directory"));
+    QMenu *popdown_menu = new QMenu ();
+    popdown_menu->addAction (resource_manager::icon ("user-home"),
+                             tr ("Show Home Directory"),
+                             this, SLOT (popdownmenu_home (bool)));
+    popdown_menu->addAction (m_sync_browser_directory_action);
+    popdown_menu->addAction (m_sync_octave_directory_action);
+    popdown_button->setMenu (popdown_menu);
+    popdown_button->setPopupMode (QToolButton::InstantPopup);
+    popdown_button->setDefaultAction (new QAction (
+                                                   resource_manager::icon ("applications-system"), "",
+                                                   m_navigation_tool_bar));
 
-void
-files_dock_widget::do_sync_octave_directory (void)
-{
-  QDir dir
-    = QDir (m_file_system_model->filePath (m_file_tree_view->rootIndex ()));
+    popdown_menu->addSeparator ();
+    popdown_menu->addAction (resource_manager::icon ("folder"),
+                             tr ("Set Browser Directory..."),
+                             this, SLOT (popdownmenu_search_dir (bool)));
+    popdown_menu->addSeparator ();
+    popdown_menu->addAction (resource_manager::icon ("edit-find"),
+                             tr ("Find Files..."),
+                             this, SLOT (popdownmenu_findfiles (bool)));
+    popdown_menu->addSeparator ();
+    popdown_menu->addAction (resource_manager::icon ("document-new"),
+                             tr ("New File..."),
+                             this, SLOT (popdownmenu_newfile (bool)));
+    popdown_menu->addAction (resource_manager::icon ("folder-new"),
+                             tr ("New Directory..."),
+                             this, SLOT (popdownmenu_newdir (bool)));
 
-  emit displayed_directory_changed (dir.absolutePath ());
-}
+    m_navigation_tool_bar->addWidget (m_current_directory);
+    m_navigation_tool_bar->addAction (directory_up_action);
+    m_navigation_tool_bar->addWidget (popdown_button);
+
+    connect (directory_up_action, SIGNAL (triggered ()), this,
+             SLOT (change_directory_up ()));
+    connect (m_sync_octave_directory_action, SIGNAL (triggered ()), this,
+             SLOT (do_sync_octave_directory ()));
+    connect (m_sync_browser_directory_action, SIGNAL (triggered ()), this,
+             SLOT (do_sync_browser_directory ()));
 
-void
-files_dock_widget::do_sync_browser_directory (void)
-{
-  display_directory (m_octave_dir,false);  // false: no sync of octave dir
-}
+    QSettings *settings = resource_manager::get_settings ();
+    // FIXME: what should happen if settings is 0?
+
+    // Create the QFileSystemModel starting in the desired directory
+    QDir startup_dir;  // take current dir
 
-void
-files_dock_widget::update_octave_directory (const QString& dir)
-{
-  m_octave_dir = dir;
-  if (m_sync_octave_dir)
-    display_directory (m_octave_dir,false);  // false: no sync of octave dir
-}
+    if (settings->value ("filesdockwidget/restore_last_dir",false).toBool ())
+      {
+        // restore last dir from previous session
+        QStringList last_dirs
+          = settings->value ("filesdockwidget/mru_dir_list").toStringList ();
+        if (last_dirs.length () > 0)
+          startup_dir = QDir (last_dirs.at (0));  // last dir in previous session
+      }
+    else if (! settings->value ("filesdockwidget/startup_dir").toString ().isEmpty ())
+      {
+        // do not restore but there is a startup dir configured
+        startup_dir
+          = QDir (settings->value ("filesdockwidget/startup_dir").toString ());
+      }
+
+    if (! startup_dir.exists ())
+      {
+        // the configured startup dir does not exist, take actual one
+        startup_dir = QDir ();
+      }
+
+    m_file_system_model = new QFileSystemModel (this);
+    QModelIndex rootPathIndex = m_file_system_model->setRootPath (
+                                                                  startup_dir.absolutePath ());
 
-void
-files_dock_widget::display_directory (const QString& dir, bool set_octave_dir)
-{
-  QFileInfo fileInfo (dir);
-  if (fileInfo.exists ())
-    {
-      if (fileInfo.isDir ())
-        {
-          m_file_tree_view->setRootIndex (m_file_system_model->
-                                         index (fileInfo.absoluteFilePath ()));
-          m_file_system_model->setRootPath (fileInfo.absoluteFilePath ());
-          if (m_sync_octave_dir && set_octave_dir)
-            process_set_current_dir (fileInfo.absoluteFilePath ());
+    // Attach the model to the QTreeView and set the root index
+    m_file_tree_view = new FileTreeViewer (container);
+    m_file_tree_view->setSelectionMode (QAbstractItemView::ExtendedSelection);
+    m_file_tree_view->setModel (m_file_system_model);
+    m_file_tree_view->setRootIndex (rootPathIndex);
+    m_file_tree_view->setSortingEnabled (true);
+    m_file_tree_view->setAlternatingRowColors (true);
+    m_file_tree_view->setAnimated (true);
+    m_file_tree_view->setToolTip (
+                                  tr ("Activate to open in editor, right click for alternatives"));
+
+    // get sort column and order as well as cloumn state (order and width)
+
+    m_file_tree_view->sortByColumn (
+                                    settings->value ("filesdockwidget/sort_files_by_column",0).toInt (),
+                                    static_cast<Qt::SortOrder>
+                                    (settings->value ("filesdockwidget/sort_files_by_order",
+                                                      Qt::AscendingOrder).toUInt ())
+                                    );
+    m_file_tree_view->header ()->restoreState (
+                                               settings->value ("filesdockwidget/column_state").toByteArray ());
+
+    QStringList mru_dirs =
+      settings->value ("filesdockwidget/mru_dir_list").toStringList ();
+    m_current_directory->addItems (mru_dirs);
+
+    m_current_directory->setEditText (
+                                      m_file_system_model->fileInfo (rootPathIndex).  absoluteFilePath ());
+
+    connect (m_file_tree_view, SIGNAL (activated (const QModelIndex &)),
+             this, SLOT (item_double_clicked (const QModelIndex &)));
 
-          // see if its in the list, and if it is,
-          // remove it and then, put at top of the list
-          int index
-            = m_current_directory->findText (fileInfo.absoluteFilePath ());
-          if (index != -1)
-            {
-              m_current_directory->removeItem (index);
-            }
-          m_current_directory->insertItem (0, fileInfo.absoluteFilePath ());
-          m_current_directory->setCurrentIndex (0);
-        }
-      else
-        {
-          QString abs_fname = fileInfo.absoluteFilePath ();
+    // add context menu to tree_view
+    m_file_tree_view->setContextMenuPolicy (Qt::CustomContextMenu);
+    connect (m_file_tree_view,
+             SIGNAL (customContextMenuRequested (const QPoint &)),
+             this, SLOT (contextmenu_requested (const QPoint &)));
+
+    m_file_tree_view->header ()->setContextMenuPolicy (Qt::CustomContextMenu);
+    connect (m_file_tree_view->header (),
+             SIGNAL (customContextMenuRequested (const QPoint &)),
+             this, SLOT (headercontextmenu_requested (const QPoint &)));
 
-          QString suffix = fileInfo.suffix ().toLower ();
-          QSettings *settings = resource_manager::get_settings ();
-          QString ext = settings->value ("filesdockwidget/txt_file_extensions",
-                                         "m;c;cc;cpp;h;txt").toString ();
-          QStringList extensions = ext.split (";", QString::SkipEmptyParts);
+    // Layout the widgets vertically with the toolbar on top
+    QVBoxLayout *vbox_layout = new QVBoxLayout ();
+    vbox_layout->setSpacing (0);
+    vbox_layout->addWidget (m_navigation_tool_bar);
+    vbox_layout->addWidget (m_file_tree_view);
+    vbox_layout->setMargin (1);
+
+    container->setLayout (vbox_layout);
+
+    // FIXME: Add right-click contextual menus for copying, pasting,
+    //        deleting files (and others).
+
+    connect (m_current_directory->lineEdit (), SIGNAL (returnPressed ()),
+             this, SLOT (accept_directory_line_edit ()));
+
+    connect (m_current_directory, SIGNAL (activated (const QString &)),
+             this, SLOT (set_current_directory (const QString &)));
+
+    connect (this, SIGNAL (run_file_signal (const QFileInfo&)),
+             main_win (), SLOT (run_file_in_terminal (const QFileInfo&)));
 
-          if (QFile::exists (abs_fname))
-            {
-              if (is_octave_data_file (abs_fname.toStdString ()))
-                emit load_file_signal (abs_fname);
-              else if (extensions.contains (suffix))
-                emit open_file (fileInfo.absoluteFilePath ());
-              else
-                open_item_in_app (m_file_tree_view->selectionModel ()
-                                  ->currentIndex ());
-            }
-        }
-    }
-}
+    QCompleter *completer = new QCompleter (m_file_system_model, this);
+    m_current_directory->setCompleter (completer);
+
+    setFocusProxy (m_current_directory);
+
+    m_sync_octave_dir = true;   // default, overwirtten with notice_settings ()
+    m_octave_dir = "";
+  }
+
+  void files_dock_widget::save_settings (void)
+  {
+    QSettings *settings = resource_manager::get_settings ();
+
+    if (! settings)
+      return;
 
-void
-files_dock_widget::open_item_in_app (const QModelIndex& index)
-{
-  // Retrieve the file info associated with the model index.
-  QFileInfo fileInfo = m_file_system_model->fileInfo (index);
+    int sort_column = m_file_tree_view->header ()->sortIndicatorSection ();
+    Qt::SortOrder sort_order = m_file_tree_view->header ()->sortIndicatorOrder ();
+    settings->setValue ("filesdockwidget/sort_files_by_column", sort_column);
+    settings->setValue ("filesdockwidget/sort_files_by_order", sort_order);
+    settings->setValue ("filesdockwidget/column_state",
+                        m_file_tree_view->header ()->saveState ());
+
+    QStringList dirs;
+    for (int i=0; i< m_current_directory->count (); i++)
+      {
+        dirs.append (m_current_directory->itemText (i));
+      }
+    settings->setValue ("filesdockwidget/mru_dir_list", dirs);
 
-  QString file = fileInfo.absoluteFilePath ();
+    settings->sync ();
+
+    octave_dock_widget::save_settings ();
 
-  QDesktopServices::openUrl (QUrl::fromLocalFile (file));
-}
+    if (m_sig_mapper)
+      delete m_sig_mapper;
+  }
+
+  void files_dock_widget::item_double_clicked (const QModelIndex& index)
+  {
+    // Retrieve the file info associated with the model index.
+    QFileInfo fileInfo = m_file_system_model->fileInfo (index);
+    set_current_directory (fileInfo.absoluteFilePath ());
+  }
 
-void files_dock_widget::toggle_header (int col)
-{
-  QSettings *settings = resource_manager::get_settings ();
+  void files_dock_widget::set_current_directory (const QString& dir)
+  {
+    display_directory (dir);
+  }
+
+  void files_dock_widget::accept_directory_line_edit (void)
+  {
+    display_directory (m_current_directory->currentText ());
+  }
 
-  QString key = m_columns_shown_keys.at (col);
-  bool shown = settings->value (key,false).toBool ();
-  settings->setValue (key, ! shown);
-  settings->sync ();
+  void files_dock_widget::change_directory_up (void)
+  {
+    QDir dir
+      = QDir (m_file_system_model->filePath (m_file_tree_view->rootIndex ()));
+
+    dir.cdUp ();
+    display_directory (dir.absolutePath ());
+  }
+
+  void files_dock_widget::do_sync_octave_directory (void)
+  {
+    QDir dir
+      = QDir (m_file_system_model->filePath (m_file_tree_view->rootIndex ()));
 
-  switch (col)
-    {
-    case 0:
-    case 1:
-    case 2:
-      // toggle column visibility
-      m_file_tree_view->setColumnHidden (col + 1, shown);
-      break;
-    case 3:
-    case 4:
-      // other actions depending on new settings
-      notice_settings (settings);
-      break;
-    }
-}
+    emit displayed_directory_changed (dir.absolutePath ());
+  }
+
+  void files_dock_widget::do_sync_browser_directory (void)
+  {
+    display_directory (m_octave_dir,false);  // false: no sync of octave dir
+  }
 
-void
-files_dock_widget::headercontextmenu_requested (const QPoint& mpos)
-{
-  QMenu menu (this);
+  void files_dock_widget::update_octave_directory (const QString& dir)
+  {
+    m_octave_dir = dir;
+    if (m_sync_octave_dir)
+      display_directory (m_octave_dir,false);  // false: no sync of octave dir
+  }
+
+  void files_dock_widget::display_directory (const QString& dir, bool set_octave_dir)
+  {
+    QFileInfo fileInfo (dir);
+    if (fileInfo.exists ())
+      {
+        if (fileInfo.isDir ())
+          {
+            m_file_tree_view->setRootIndex (m_file_system_model->
+                                            index (fileInfo.absoluteFilePath ()));
+            m_file_system_model->setRootPath (fileInfo.absoluteFilePath ());
+            if (m_sync_octave_dir && set_octave_dir)
+              process_set_current_dir (fileInfo.absoluteFilePath ());
 
-  if (m_sig_mapper)
-    delete m_sig_mapper;
-  m_sig_mapper = new QSignalMapper (this);
+            // see if its in the list, and if it is,
+            // remove it and then, put at top of the list
+            int index
+              = m_current_directory->findText (fileInfo.absoluteFilePath ());
+            if (index != -1)
+              {
+                m_current_directory->removeItem (index);
+              }
+            m_current_directory->insertItem (0, fileInfo.absoluteFilePath ());
+            m_current_directory->setCurrentIndex (0);
+          }
+        else
+          {
+            QString abs_fname = fileInfo.absoluteFilePath ();
 
-  QSettings *settings = resource_manager::get_settings ();
+            QString suffix = fileInfo.suffix ().toLower ();
+            QSettings *settings = resource_manager::get_settings ();
+            QString ext = settings->value ("filesdockwidget/txt_file_extensions",
+                                           "m;c;cc;cpp;h;txt").toString ();
+            QStringList extensions = ext.split (";", QString::SkipEmptyParts);
 
-  for (int i = 0; i < m_columns_shown.size (); i++)
-    {
-      QAction *action = menu.addAction (m_columns_shown.at (i),
-                                        m_sig_mapper, SLOT (map ()));
-      m_sig_mapper->setMapping (action, i);
-      action->setCheckable (true);
-      action->setChecked (
-            settings->value (m_columns_shown_keys.at (i),true).toBool ());
-    }
+            if (QFile::exists (abs_fname))
+              {
+                if (is_octave_data_file (abs_fname.toStdString ()))
+                  emit load_file_signal (abs_fname);
+                else if (extensions.contains (suffix))
+                  emit open_file (fileInfo.absoluteFilePath ());
+                else
+                  open_item_in_app (m_file_tree_view->selectionModel ()
+                                    ->currentIndex ());
+              }
+          }
+      }
+  }
 
-  connect (m_sig_mapper, SIGNAL (mapped (int)),
-           this, SLOT (toggle_header (int)));
+  void files_dock_widget::open_item_in_app (const QModelIndex& index)
+  {
+    // Retrieve the file info associated with the model index.
+    QFileInfo fileInfo = m_file_system_model->fileInfo (index);
 
-  menu.exec (m_file_tree_view->mapToGlobal (mpos));
-}
+    QString file = fileInfo.absoluteFilePath ();
 
-void
-files_dock_widget::contextmenu_requested (const QPoint& mpos)
-{
+    QDesktopServices::openUrl (QUrl::fromLocalFile (file));
+  }
 
-  QMenu menu (this);
+  void files_dock_widget::toggle_header (int col)
+  {
+    QSettings *settings = resource_manager::get_settings ();
 
-  QModelIndex index = m_file_tree_view->indexAt (mpos);
+    QString key = m_columns_shown_keys.at (col);
+    bool shown = settings->value (key,false).toBool ();
+    settings->setValue (key, ! shown);
+    settings->sync ();
 
-  if (index.isValid ())
-    {
-      QFileInfo info = m_file_system_model->fileInfo (index);
+    switch (col)
+      {
+      case 0:
+      case 1:
+      case 2:
+        // toggle column visibility
+        m_file_tree_view->setColumnHidden (col + 1, shown);
+        break;
+      case 3:
+      case 4:
+        // other actions depending on new settings
+        notice_settings (settings);
+        break;
+      }
+  }
 
-      QItemSelectionModel *m = m_file_tree_view->selectionModel ();
-      QModelIndexList sel = m->selectedRows ();
+  void files_dock_widget::headercontextmenu_requested (const QPoint& mpos)
+  {
+    QMenu menu (this);
+
+    if (m_sig_mapper)
+      delete m_sig_mapper;
+    m_sig_mapper = new QSignalMapper (this);
+
+    QSettings *settings = resource_manager::get_settings ();
 
-      // check if item at mouse position is seleccted
-      if (! sel.contains (index))
-        {
-          // is not selected -> clear actual selection and select this item
-          m->setCurrentIndex (index,
-                              QItemSelectionModel::Clear
-                              | QItemSelectionModel::Select
-                              | QItemSelectionModel::Rows);
-        }
+    for (int i = 0; i < m_columns_shown.size (); i++)
+      {
+        QAction *action = menu.addAction (m_columns_shown.at (i),
+                                          m_sig_mapper, SLOT (map ()));
+        m_sig_mapper->setMapping (action, i);
+        action->setCheckable (true);
+        action->setChecked (
+                            settings->value (m_columns_shown_keys.at (i),true).toBool ());
+      }
+
+    connect (m_sig_mapper, SIGNAL (mapped (int)),
+             this, SLOT (toggle_header (int)));
+
+    menu.exec (m_file_tree_view->mapToGlobal (mpos));
+  }
+
+  void files_dock_widget::contextmenu_requested (const QPoint& mpos)
+  {
+
+    QMenu menu (this);
 
-      // construct the context menu depending on item
-      menu.addAction (resource_manager::icon ("document-open"), tr ("Open"),
-                      this, SLOT (contextmenu_open (bool)));
+    QModelIndex index = m_file_tree_view->indexAt (mpos);
+
+    if (index.isValid ())
+      {
+        QFileInfo info = m_file_system_model->fileInfo (index);
+
+        QItemSelectionModel *m = m_file_tree_view->selectionModel ();
+        QModelIndexList sel = m->selectedRows ();
 
-      if (info.isDir ())
-        {
-          menu.addAction (tr ("Open in System File Explorer"),
-                          this, SLOT (contextmenu_open_in_app (bool)));
-        }
+        // check if item at mouse position is seleccted
+        if (! sel.contains (index))
+          {
+            // is not selected -> clear actual selection and select this item
+            m->setCurrentIndex (index,
+                                QItemSelectionModel::Clear
+                                | QItemSelectionModel::Select
+                                | QItemSelectionModel::Rows);
+          }
 
-      if (info.isFile ())
-        menu.addAction (tr ("Open in Text Editor"),
-                        this, SLOT (contextmenu_open_in_editor (bool)));
+        // construct the context menu depending on item
+        menu.addAction (resource_manager::icon ("document-open"), tr ("Open"),
+                        this, SLOT (contextmenu_open (bool)));
 
-      menu.addAction (tr ("Copy Selection to Clipboard"),
-                      this, SLOT (contextmenu_copy_selection (bool)));
+        if (info.isDir ())
+          {
+            menu.addAction (tr ("Open in System File Explorer"),
+                            this, SLOT (contextmenu_open_in_app (bool)));
+          }
 
-      if (info.isFile () && info.suffix () == "m")
-        menu.addAction (resource_manager::icon ("media-playback-start"),
-                        tr ("Run"), this, SLOT (contextmenu_run (bool)));
-
-      if (info.isFile ())
-        menu.addAction (tr ("Load Data"), this, SLOT (contextmenu_load (bool)));
+        if (info.isFile ())
+          menu.addAction (tr ("Open in Text Editor"),
+                          this, SLOT (contextmenu_open_in_editor (bool)));
 
-      if (info.isDir ())
-        {
-          menu.addSeparator ();
-          menu.addAction (resource_manager::icon ("go-first"),
-                          tr ("Set Current Directory"),
-                          this, SLOT (contextmenu_setcurrentdir (bool)));
-          menu.addSeparator ();
-          menu.addAction (resource_manager::icon ("edit-find"),
-                          tr ("Find Files..."), this,
-                          SLOT (contextmenu_findfiles (bool)));
-        }
+        menu.addAction (tr ("Copy Selection to Clipboard"),
+                        this, SLOT (contextmenu_copy_selection (bool)));
+
+        if (info.isFile () && info.suffix () == "m")
+          menu.addAction (resource_manager::icon ("media-playback-start"),
+                          tr ("Run"), this, SLOT (contextmenu_run (bool)));
+
+        if (info.isFile ())
+          menu.addAction (tr ("Load Data"), this, SLOT (contextmenu_load (bool)));
 
-      menu.addSeparator ();
-      menu.addAction (tr ("Rename..."), this, SLOT (contextmenu_rename (bool)));
-      menu.addAction (resource_manager::icon ("edit-delete"),
-                      tr ("Delete..."), this, SLOT (contextmenu_delete (bool)));
+        if (info.isDir ())
+          {
+            menu.addSeparator ();
+            menu.addAction (resource_manager::icon ("go-first"),
+                            tr ("Set Current Directory"),
+                            this, SLOT (contextmenu_setcurrentdir (bool)));
+            menu.addSeparator ();
+            menu.addAction (resource_manager::icon ("edit-find"),
+                            tr ("Find Files..."), this,
+                            SLOT (contextmenu_findfiles (bool)));
+          }
+
+        menu.addSeparator ();
+        menu.addAction (tr ("Rename..."), this, SLOT (contextmenu_rename (bool)));
+        menu.addAction (resource_manager::icon ("edit-delete"),
+                        tr ("Delete..."), this, SLOT (contextmenu_delete (bool)));
 
-      if (info.isDir ())
-        {
-          menu.addSeparator ();
-          menu.addAction (resource_manager::icon ("document-new"),
-                          tr ("New File..."),
-                          this, SLOT (contextmenu_newfile (bool)));
-          menu.addAction (resource_manager::icon ("folder-new"),
-                          tr ("New Directory..."),
-                          this, SLOT (contextmenu_newdir (bool)));
-        }
+        if (info.isDir ())
+          {
+            menu.addSeparator ();
+            menu.addAction (resource_manager::icon ("document-new"),
+                            tr ("New File..."),
+                            this, SLOT (contextmenu_newfile (bool)));
+            menu.addAction (resource_manager::icon ("folder-new"),
+                            tr ("New Directory..."),
+                            this, SLOT (contextmenu_newdir (bool)));
+          }
 
-      // show the menu
-      menu.exec (m_file_tree_view->mapToGlobal (mpos));
-
-    }
-}
+        // show the menu
+        menu.exec (m_file_tree_view->mapToGlobal (mpos));
 
-void
-files_dock_widget::contextmenu_open (bool)
-{
-
-  QItemSelectionModel *m = m_file_tree_view->selectionModel ();
-  QModelIndexList rows = m->selectedRows ();
+      }
+  }
 
-  for (QModelIndexList::iterator it = rows.begin (); it != rows.end (); it++)
-    {
-      QFileInfo file = m_file_system_model->fileInfo (*it);
-      if (file.exists ())
-        display_directory (file.absoluteFilePath ());
-    }
-}
+  void files_dock_widget::contextmenu_open (bool)
+  {
+
+    QItemSelectionModel *m = m_file_tree_view->selectionModel ();
+    QModelIndexList rows = m->selectedRows ();
 
-void
-files_dock_widget::contextmenu_open_in_editor (bool)
-{
+    for (QModelIndexList::iterator it = rows.begin (); it != rows.end (); it++)
+      {
+        QFileInfo file = m_file_system_model->fileInfo (*it);
+        if (file.exists ())
+          display_directory (file.absoluteFilePath ());
+      }
+  }
 
-  QItemSelectionModel *m = m_file_tree_view->selectionModel ();
-  QModelIndexList rows = m->selectedRows ();
+  void files_dock_widget::contextmenu_open_in_editor (bool)
+  {
+
+    QItemSelectionModel *m = m_file_tree_view->selectionModel ();
+    QModelIndexList rows = m->selectedRows ();
 
-  for (QModelIndexList::iterator it = rows.begin (); it != rows.end (); it++)
-    {
-      QFileInfo file = m_file_system_model->fileInfo (*it);
-      if (file.exists ())
-        emit open_file (file.absoluteFilePath ());
-    }
-}
-
-void
-files_dock_widget::contextmenu_open_in_app (bool)
-{
-  QItemSelectionModel *m = m_file_tree_view->selectionModel ();
-  QModelIndexList rows = m->selectedRows ();
+    for (QModelIndexList::iterator it = rows.begin (); it != rows.end (); it++)
+      {
+        QFileInfo file = m_file_system_model->fileInfo (*it);
+        if (file.exists ())
+          emit open_file (file.absoluteFilePath ());
+      }
+  }
 
-  for (QModelIndexList::iterator it = rows.begin (); it != rows.end (); it++)
-    open_item_in_app (*it);
-}
+  void files_dock_widget::contextmenu_open_in_app (bool)
+  {
+    QItemSelectionModel *m = m_file_tree_view->selectionModel ();
+    QModelIndexList rows = m->selectedRows ();
 
-void
-files_dock_widget::contextmenu_copy_selection (bool)
-{
-  QItemSelectionModel *m = m_file_tree_view->selectionModel ();
-  QModelIndexList rows = m->selectedRows ();
+    for (QModelIndexList::iterator it = rows.begin (); it != rows.end (); it++)
+      open_item_in_app (*it);
+  }
 
-  QStringList selection;
-
-  for (QModelIndexList::iterator it = rows.begin (); it != rows.end (); it++)
-    {
-      QFileInfo info = m_file_system_model->fileInfo (*it);
+  void files_dock_widget::contextmenu_copy_selection (bool)
+  {
+    QItemSelectionModel *m = m_file_tree_view->selectionModel ();
+    QModelIndexList rows = m->selectedRows ();
 
-      selection << info.fileName ();
-    }
+    QStringList selection;
 
-  QClipboard *clipboard = QApplication::clipboard ();
-
-  clipboard->setText (selection.join ("\n"));
-}
+    for (QModelIndexList::iterator it = rows.begin (); it != rows.end (); it++)
+      {
+        QFileInfo info = m_file_system_model->fileInfo (*it);
 
-void
-files_dock_widget::contextmenu_load (bool)
-{
-  QItemSelectionModel *m = m_file_tree_view->selectionModel ();
-  QModelIndexList rows = m->selectedRows ();
+        selection << info.fileName ();
+      }
 
-  if (rows.size () > 0)
-    {
-      QModelIndex index = rows[0];
+    QClipboard *clipboard = QApplication::clipboard ();
 
-      QFileInfo info = m_file_system_model->fileInfo (index);
+    clipboard->setText (selection.join ("\n"));
+  }
 
-      emit load_file_signal (info.fileName ());
-    }
-}
+  void files_dock_widget::contextmenu_load (bool)
+  {
+    QItemSelectionModel *m = m_file_tree_view->selectionModel ();
+    QModelIndexList rows = m->selectedRows ();
+
+    if (rows.size () > 0)
+      {
+        QModelIndex index = rows[0];
 
-void
-files_dock_widget::contextmenu_run (bool)
-{
-  QItemSelectionModel *m = m_file_tree_view->selectionModel ();
-  QModelIndexList rows = m->selectedRows ();
+        QFileInfo info = m_file_system_model->fileInfo (index);
 
-  if (rows.size () > 0)
-    {
-      QModelIndex index = rows[0];
+        emit load_file_signal (info.fileName ());
+      }
+  }
 
-      QFileInfo info = m_file_system_model->fileInfo (index);
-      emit run_file_signal (info);
-    }
-}
+  void files_dock_widget::contextmenu_run (bool)
+  {
+    QItemSelectionModel *m = m_file_tree_view->selectionModel ();
+    QModelIndexList rows = m->selectedRows ();
 
-void
-files_dock_widget::contextmenu_rename (bool)
-{
-  QItemSelectionModel *m = m_file_tree_view->selectionModel ();
-  QModelIndexList rows = m->selectedRows ();
-  if (rows.size () > 0)
-    {
-      QModelIndex index = rows[0];
+    if (rows.size () > 0)
+      {
+        QModelIndex index = rows[0];
 
-      QFileInfo info = m_file_system_model->fileInfo (index);
-      QDir path = info.absoluteDir ();
-      QString old_name = info.fileName ();
-      bool ok;
+        QFileInfo info = m_file_system_model->fileInfo (index);
+        emit run_file_signal (info);
+      }
+  }
 
-      QString new_name
-        = QInputDialog::getText (this, tr ("Rename file/directory"),
-                                 tr ("Rename file/directory:\n")
-                                 + old_name + tr ("\n to: "),
-                                 QLineEdit::Normal, old_name, &ok);
-      if (ok && new_name.length () > 0)
-        {
-          new_name = path.absolutePath () + '/' + new_name;
-          old_name = path.absolutePath () + '/' + old_name;
-          // editor: close old
-          emit file_remove_signal (old_name, new_name);
-          // Do the renaming
-          bool st = path.rename (old_name, new_name);
-          // editor: load new/old file depending on success
-          emit file_renamed_signal (st);
-          // Clear cache of file browser
-          m_file_system_model->revert ();
-        }
-    }
+  void files_dock_widget::contextmenu_rename (bool)
+  {
+    QItemSelectionModel *m = m_file_tree_view->selectionModel ();
+    QModelIndexList rows = m->selectedRows ();
+    if (rows.size () > 0)
+      {
+        QModelIndex index = rows[0];
 
-}
+        QFileInfo info = m_file_system_model->fileInfo (index);
+        QDir path = info.absoluteDir ();
+        QString old_name = info.fileName ();
+        bool ok;
 
-void
-files_dock_widget::contextmenu_delete (bool)
-{
-  QItemSelectionModel *m = m_file_tree_view->selectionModel ();
-  QModelIndexList rows = m->selectedRows ();
-
-  for (QModelIndexList::iterator it = rows.begin (); it != rows.end (); it++)
-    {
-      QModelIndex index = *it;
-
-      QFileInfo info = m_file_system_model->fileInfo (index);
+        QString new_name
+          = QInputDialog::getText (this, tr ("Rename file/directory"),
+                                   tr ("Rename file/directory:\n")
+                                   + old_name + tr ("\n to: "),
+                                   QLineEdit::Normal, old_name, &ok);
+        if (ok && new_name.length () > 0)
+          {
+            new_name = path.absolutePath () + '/' + new_name;
+            old_name = path.absolutePath () + '/' + old_name;
+            // editor: close old
+            emit file_remove_signal (old_name, new_name);
+            // Do the renaming
+            bool st = path.rename (old_name, new_name);
+            // editor: load new/old file depending on success
+            emit file_renamed_signal (st);
+            // Clear cache of file browser
+            m_file_system_model->revert ();
+          }
+      }
 
-      if (QMessageBox::question (this, tr ("Delete file/directory"),
-                                 tr ("Are you sure you want to delete\n")
-                                 + info.filePath (),
-                                 QMessageBox::Yes | QMessageBox::No)
-          == QMessageBox::Yes)
-        {
-          if (info.isDir ())
-            {
-              // see if direcory is empty
-              QDir path (info.absoluteFilePath ());
-              QList<QFileInfo> fileLst = path.entryInfoList (QDir::AllEntries |
-                                         QDir::NoDotAndDotDot);
+  }
+
+  void files_dock_widget::contextmenu_delete (bool)
+  {
+    QItemSelectionModel *m = m_file_tree_view->selectionModel ();
+    QModelIndexList rows = m->selectedRows ();
+
+    for (QModelIndexList::iterator it = rows.begin (); it != rows.end (); it++)
+      {
+        QModelIndex index = *it;
+
+        QFileInfo info = m_file_system_model->fileInfo (index);
 
-              if (fileLst.count () != 0)
-                QMessageBox::warning (this, tr ("Delete file/directory"),
-                                      tr ("Can not delete a directory that is not empty"));
-              else
-                m_file_system_model->rmdir (index);
-            }
-          else
-            {
-              // Close the file in the editor if open
-              emit file_remove_signal (info.filePath (), QString ());
-              // Remove the file.
-              bool st = m_file_system_model->remove (index);
-              // reload the old file if removing was not successful
-              if (! st)
-                emit file_renamed_signal (false);
-            }
+        if (QMessageBox::question (this, tr ("Delete file/directory"),
+                                   tr ("Are you sure you want to delete\n")
+                                   + info.filePath (),
+                                   QMessageBox::Yes | QMessageBox::No)
+            == QMessageBox::Yes)
+          {
+            if (info.isDir ())
+              {
+                // see if direcory is empty
+                QDir path (info.absoluteFilePath ());
+                QList<QFileInfo> fileLst = path.entryInfoList (QDir::AllEntries |
+                                                               QDir::NoDotAndDotDot);
 
-          m_file_system_model->revert ();
-
-        }
-    }
-}
+                if (fileLst.count () != 0)
+                  QMessageBox::warning (this, tr ("Delete file/directory"),
+                                        tr ("Can not delete a directory that is not empty"));
+                else
+                  m_file_system_model->rmdir (index);
+              }
+            else
+              {
+                // Close the file in the editor if open
+                emit file_remove_signal (info.filePath (), QString ());
+                // Remove the file.
+                bool st = m_file_system_model->remove (index);
+                // reload the old file if removing was not successful
+                if (! st)
+                  emit file_renamed_signal (false);
+              }
 
-void
-files_dock_widget::contextmenu_newfile (bool)
-{
-  QItemSelectionModel *m = m_file_tree_view->selectionModel ();
-  QModelIndexList rows = m->selectedRows ();
+            m_file_system_model->revert ();
 
-  if (rows.size () > 0)
-    {
-      QModelIndex index = rows[0];
+          }
+      }
+  }
 
-      QFileInfo info = m_file_system_model->fileInfo (index);
-      QString parent_dir = info.filePath ();
+  void files_dock_widget::contextmenu_newfile (bool)
+  {
+    QItemSelectionModel *m = m_file_tree_view->selectionModel ();
+    QModelIndexList rows = m->selectedRows ();
 
-      process_new_file (parent_dir);
-    }
-}
+    if (rows.size () > 0)
+      {
+        QModelIndex index = rows[0];
 
-void
-files_dock_widget::contextmenu_newdir (bool)
-{
-  QItemSelectionModel *m = m_file_tree_view->selectionModel ();
-  QModelIndexList rows = m->selectedRows ();
+        QFileInfo info = m_file_system_model->fileInfo (index);
+        QString parent_dir = info.filePath ();
+
+        process_new_file (parent_dir);
+      }
+  }
 
-  if (rows.size () > 0)
-    {
-      QModelIndex index = rows[0];
+  void files_dock_widget::contextmenu_newdir (bool)
+  {
+    QItemSelectionModel *m = m_file_tree_view->selectionModel ();
+    QModelIndexList rows = m->selectedRows ();
 
-      QFileInfo info = m_file_system_model->fileInfo (index);
-      QString parent_dir = info.filePath ();
+    if (rows.size () > 0)
+      {
+        QModelIndex index = rows[0];
 
-      process_new_dir (parent_dir);
-    }
-}
+        QFileInfo info = m_file_system_model->fileInfo (index);
+        QString parent_dir = info.filePath ();
+
+        process_new_dir (parent_dir);
+      }
+  }
 
-void
-files_dock_widget::contextmenu_setcurrentdir (bool)
-{
-  QItemSelectionModel *m = m_file_tree_view->selectionModel ();
-  QModelIndexList rows = m->selectedRows ();
+  void files_dock_widget::contextmenu_setcurrentdir (bool)
+  {
+    QItemSelectionModel *m = m_file_tree_view->selectionModel ();
+    QModelIndexList rows = m->selectedRows ();
 
-  if (rows.size () > 0)
-    {
-      QModelIndex index = rows[0];
+    if (rows.size () > 0)
+      {
+        QModelIndex index = rows[0];
 
-      QFileInfo info = m_file_system_model->fileInfo (index);
+        QFileInfo info = m_file_system_model->fileInfo (index);
 
-      if (info.isDir ())
-        {
-          process_set_current_dir (info.absoluteFilePath ());
-        }
-    }
-}
+        if (info.isDir ())
+          {
+            process_set_current_dir (info.absoluteFilePath ());
+          }
+      }
+  }
 
-void
-files_dock_widget::contextmenu_findfiles (bool)
-{
-  QItemSelectionModel *m = m_file_tree_view->selectionModel ();
-  QModelIndexList rows = m->selectedRows ();
+  void files_dock_widget::contextmenu_findfiles (bool)
+  {
+    QItemSelectionModel *m = m_file_tree_view->selectionModel ();
+    QModelIndexList rows = m->selectedRows ();
 
-  if (rows.size () > 0)
-    {
-      QModelIndex index = rows[0];
+    if (rows.size () > 0)
+      {
+        QModelIndex index = rows[0];
 
-      QFileInfo info = m_file_system_model->fileInfo (index);
+        QFileInfo info = m_file_system_model->fileInfo (index);
 
-      if (info.isDir ())
-        {
-          process_find_files (info.absoluteFilePath ());
-        }
-    }
-}
+        if (info.isDir ())
+          {
+            process_find_files (info.absoluteFilePath ());
+          }
+      }
+  }
 
-void
-files_dock_widget::notice_settings (const QSettings *settings)
-{
-  // Qsettings pointer is checked before emitting.
+  void files_dock_widget::notice_settings (const QSettings *settings)
+  {
+    // Qsettings pointer is checked before emitting.
 
-  int icon_size_settings = settings->value ("toolbar_icon_size",0).toInt ();
-  QStyle *st = style ();
-  int icon_size = st->pixelMetric (QStyle::PM_ToolBarIconSize);
+    int icon_size_settings = settings->value ("toolbar_icon_size",0).toInt ();
+    QStyle *st = style ();
+    int icon_size = st->pixelMetric (QStyle::PM_ToolBarIconSize);
 
-  if (icon_size_settings == 1)
-    icon_size = st->pixelMetric (QStyle::PM_LargeIconSize);
-  else if (icon_size_settings == -1)
-    icon_size = st->pixelMetric (QStyle::PM_SmallIconSize);
+    if (icon_size_settings == 1)
+      icon_size = st->pixelMetric (QStyle::PM_LargeIconSize);
+    else if (icon_size_settings == -1)
+      icon_size = st->pixelMetric (QStyle::PM_SmallIconSize);
 
-  m_navigation_tool_bar->setIconSize (QSize (icon_size,icon_size));
+    m_navigation_tool_bar->setIconSize (QSize (icon_size,icon_size));
 
-  // filenames are always shown, other columns can be hidden by settings
-  for (int i = 0; i < 3; i++)
-    m_file_tree_view->setColumnHidden (i + 1,
-        ! settings->value (m_columns_shown_keys.at (i),false).toBool ());
+    // filenames are always shown, other columns can be hidden by settings
+    for (int i = 0; i < 3; i++)
+      m_file_tree_view->setColumnHidden (i + 1,
+                                         ! settings->value (m_columns_shown_keys.at (i),false).toBool ());
 
-  if (settings->value (m_columns_shown_keys.at (3),false).toBool ())
-    m_file_system_model->setFilter (QDir::NoDotAndDotDot | QDir::AllEntries
-                                   | QDir::Hidden);
-  else
-    m_file_system_model->setFilter (QDir::NoDotAndDotDot | QDir::AllEntries);
+    if (settings->value (m_columns_shown_keys.at (3),false).toBool ())
+      m_file_system_model->setFilter (QDir::NoDotAndDotDot | QDir::AllEntries
+                                      | QDir::Hidden);
+    else
+      m_file_system_model->setFilter (QDir::NoDotAndDotDot | QDir::AllEntries);
 
-  m_file_tree_view->setAlternatingRowColors (
-    settings->value (m_columns_shown_keys.at (4),true).toBool ());
-  m_file_tree_view->setModel (m_file_system_model);
-
-  // enable the buttons to sync octave/browser dir
-  // only if this is not done by default
-  m_sync_octave_dir
-    = settings->value ("filesdockwidget/sync_octave_directory",true).toBool ();
-  m_sync_octave_directory_action->setEnabled (! m_sync_octave_dir);
-  m_sync_browser_directory_action->setEnabled (! m_sync_octave_dir);
+    m_file_tree_view->setAlternatingRowColors (
+                                               settings->value (m_columns_shown_keys.at (4),true).toBool ());
+    m_file_tree_view->setModel (m_file_system_model);
 
-  if (m_sync_octave_dir)
-    display_directory (m_octave_dir);  // sync browser to octave dir
+    // enable the buttons to sync octave/browser dir
+    // only if this is not done by default
+    m_sync_octave_dir
+      = settings->value ("filesdockwidget/sync_octave_directory",true).toBool ();
+    m_sync_octave_directory_action->setEnabled (! m_sync_octave_dir);
+    m_sync_browser_directory_action->setEnabled (! m_sync_octave_dir);
 
-}
+    if (m_sync_octave_dir)
+      display_directory (m_octave_dir);  // sync browser to octave dir
 
-void
-files_dock_widget::popdownmenu_home (bool)
-{
-  QString dir
-    = QString::fromStdString (octave::sys::env::get_home_directory ());
+  }
 
-  if (dir.isEmpty ())
-    dir = QDir::homePath ();
+  void files_dock_widget::popdownmenu_home (bool)
+  {
+    QString dir
+      = QString::fromStdString (octave::sys::env::get_home_directory ());
 
-  set_current_directory (dir);
-}
+    if (dir.isEmpty ())
+      dir = QDir::homePath ();
 
-void
-files_dock_widget::popdownmenu_search_dir (bool)
-{
-  QString dir = QFileDialog::getExistingDirectory
-                  (this, tr ("Set directory of file browser"),
-                   m_file_system_model->rootPath (),
-                   QFileDialog::ShowDirsOnly
-                   | QFileDialog::DontUseNativeDialog);
-  set_current_directory (dir);
-}
+    set_current_directory (dir);
+  }
 
-void
-files_dock_widget::popdownmenu_findfiles (bool)
-{
-  process_find_files (m_file_system_model->rootPath ());
-}
+  void files_dock_widget::popdownmenu_search_dir (bool)
+  {
+    QString dir = QFileDialog::getExistingDirectory
+      (this, tr ("Set directory of file browser"),
+       m_file_system_model->rootPath (),
+       QFileDialog::ShowDirsOnly
+       | QFileDialog::DontUseNativeDialog);
+    set_current_directory (dir);
+  }
 
-void
-files_dock_widget::popdownmenu_newdir (bool)
-{
-  process_new_dir (m_file_system_model->rootPath ());
-}
+  void files_dock_widget::popdownmenu_findfiles (bool)
+  {
+    process_find_files (m_file_system_model->rootPath ());
+  }
+
+  void files_dock_widget::popdownmenu_newdir (bool)
+  {
+    process_new_dir (m_file_system_model->rootPath ());
+  }
 
-void
-files_dock_widget::popdownmenu_newfile (bool)
-{
-  process_new_file (m_file_system_model->rootPath ());
-}
+  void files_dock_widget::popdownmenu_newfile (bool)
+  {
+    process_new_file (m_file_system_model->rootPath ());
+  }
 
-void
-files_dock_widget::process_new_file (const QString& parent_dir)
-{
-  bool ok;
+  void files_dock_widget::process_new_file (const QString& parent_dir)
+  {
+    bool ok;
 
-  QString name = QInputDialog::getText (this, tr ("Create File"),
-       tr ("Create file in\n","String ends with \\n!") + parent_dir,
-       QLineEdit::Normal, tr ("New File.txt"), &ok);
-  if (ok && name.length () > 0)
-    {
-      name = parent_dir + '/' + name;
+    QString name = QInputDialog::getText (this, tr ("Create File"),
+                                          tr ("Create file in\n","String ends with \\n!") + parent_dir,
+                                          QLineEdit::Normal, tr ("New File.txt"), &ok);
+    if (ok && name.length () > 0)
+      {
+        name = parent_dir + '/' + name;
 
-      QFile file (name);
-      file.open (QIODevice::WriteOnly);
-      m_file_system_model->revert ();
-    }
-}
+        QFile file (name);
+        file.open (QIODevice::WriteOnly);
+        m_file_system_model->revert ();
+      }
+  }
 
-void
-files_dock_widget::process_new_dir (const QString& parent_dir)
-{
-  bool ok;
+  void files_dock_widget::process_new_dir (const QString& parent_dir)
+  {
+    bool ok;
 
-  QString name = QInputDialog::getText (this, tr ("Create Directory"),
-                tr ("Create folder in\n","String ends with \\n!") + parent_dir,
-                QLineEdit::Normal, tr ("New Directory"), &ok);
-  if (ok && name.length () > 0)
-    {
-      QDir dir (parent_dir);
-      dir.mkdir (name);
-      m_file_system_model->revert ();
-    }
-}
+    QString name = QInputDialog::getText (this, tr ("Create Directory"),
+                                          tr ("Create folder in\n","String ends with \\n!") + parent_dir,
+                                          QLineEdit::Normal, tr ("New Directory"), &ok);
+    if (ok && name.length () > 0)
+      {
+        QDir dir (parent_dir);
+        dir.mkdir (name);
+        m_file_system_model->revert ();
+      }
+  }
 
-void files_dock_widget::process_set_current_dir (const QString & dir)
-{
-  emit displayed_directory_changed (dir);
-}
+  void files_dock_widget::process_set_current_dir (const QString & dir)
+  {
+    emit displayed_directory_changed (dir);
+  }
 
-void files_dock_widget::process_find_files (const QString & dir)
-{
-  emit find_files_signal (dir);
-}
+  void files_dock_widget::process_find_files (const QString & dir)
+  {
+    emit find_files_signal (dir);
+  }
 
-void
-files_dock_widget::copyClipboard ()
-{
-  if (m_file_tree_view->hasFocus ())
-    contextmenu_copy_selection (true);
-  if (m_current_directory->hasFocus ())
-    {
-      QClipboard *clipboard = QApplication::clipboard ();
+  void files_dock_widget::copyClipboard ()
+  {
+    if (m_file_tree_view->hasFocus ())
+      contextmenu_copy_selection (true);
+    if (m_current_directory->hasFocus ())
+      {
+        QClipboard *clipboard = QApplication::clipboard ();
 
-      QLineEdit *edit = m_current_directory->lineEdit ();
-      if (edit && edit->hasSelectedText ())
-        {
-          clipboard->setText (edit->selectedText ());
-        }
-    }
-}
+        QLineEdit *edit = m_current_directory->lineEdit ();
+        if (edit && edit->hasSelectedText ())
+          {
+            clipboard->setText (edit->selectedText ());
+          }
+      }
+  }
 
-void
-files_dock_widget::pasteClipboard ()
-{
-  if (m_current_directory->hasFocus ())
-    {
-      QClipboard *clipboard = QApplication::clipboard ();
-      QString str = clipboard->text ();
-      QLineEdit *edit = m_current_directory->lineEdit ();
-      if (edit && str.length () > 0)
-        edit->insert (str);
-    }
-}
+  void files_dock_widget::pasteClipboard ()
+  {
+    if (m_current_directory->hasFocus ())
+      {
+        QClipboard *clipboard = QApplication::clipboard ();
+        QString str = clipboard->text ();
+        QLineEdit *edit = m_current_directory->lineEdit ();
+        if (edit && str.length () > 0)
+          edit->insert (str);
+      }
+  }
 
-void
-files_dock_widget::selectAll ()
-{
-  if (m_file_tree_view->hasFocus ())
-    m_file_tree_view->selectAll ();
-  if (m_current_directory->hasFocus ())
-    {
-      QLineEdit *edit = m_current_directory->lineEdit ();
-      if (edit)
-        {
-          edit->selectAll ();
-        }
-    }
+  void files_dock_widget::selectAll ()
+  {
+    if (m_file_tree_view->hasFocus ())
+      m_file_tree_view->selectAll ();
+    if (m_current_directory->hasFocus ())
+      {
+        QLineEdit *edit = m_current_directory->lineEdit ();
+        if (edit)
+          {
+            edit->selectAll ();
+          }
+      }
+  }
 }
--- a/libgui/src/files-dock-widget.h	Sat Feb 10 23:32:04 2018 -0500
+++ b/libgui/src/files-dock-widget.h	Sun Feb 11 09:20:36 2018 -0500
@@ -40,167 +40,170 @@
 #include <QComboBox>
 #include "octave-dock-widget.h"
 
-//!  Dock widget to display files in the current directory.
-
-class files_dock_widget : public octave_dock_widget
+namespace octave
 {
-  Q_OBJECT
+  //!  Dock widget to display files in the current directory.
 
-public:
+  class files_dock_widget : public octave_dock_widget
+  {
+    Q_OBJECT
 
-  files_dock_widget (QWidget *parent = nullptr);
+  public:
 
-  ~files_dock_widget (void) = default;
+    files_dock_widget (QWidget *parent = nullptr);
 
-public slots:
+    ~files_dock_widget (void) = default;
 
-  //! Slot for handling a change in directory via double click.
+  public slots:
 
-  void item_double_clicked (const QModelIndex & index);
+    //! Slot for handling a change in directory via double click.
 
-  //! Slot for handling the up-directory button in the toolbar.
+    void item_double_clicked (const QModelIndex & index);
 
-  void change_directory_up (void);
+    //! Slot for handling the up-directory button in the toolbar.
 
-  //! Slot for handling the sync octave directory button in the toolbar.
+    void change_directory_up (void);
 
-  void do_sync_octave_directory (void);
+    //! Slot for handling the sync octave directory button in the toolbar.
 
-  //! Slot for handling the sync browser directory button in the toolbar.
+    void do_sync_octave_directory (void);
 
-  void do_sync_browser_directory (void);
+    //! Slot for handling the sync browser directory button in the toolbar.
 
-  //! Sets the current directory being displayed.
+    void do_sync_browser_directory (void);
 
-  void set_current_directory (const QString& dir);
+    //! Sets the current directory being displayed.
 
-  //! Accepts user input a the line edit for the current directory.
+    void set_current_directory (const QString& dir);
 
-  void accept_directory_line_edit (void);
+    //! Accepts user input a the line edit for the current directory.
 
-  //! Set the internal variable that holds the actual octave variable.
+    void accept_directory_line_edit (void);
 
-  void update_octave_directory (const QString& dir);
+    //! Set the internal variable that holds the actual octave variable.
 
-  //! Tells the widget to react on changed settings.
+    void update_octave_directory (const QString& dir);
 
-  void notice_settings (const QSettings *settings);
+    //! Tells the widget to react on changed settings.
 
-  void save_settings (void);
+    void notice_settings (const QSettings *settings);
 
-private slots:
+    void save_settings (void);
 
-  void headercontextmenu_requested (const QPoint& pos);
-  void toggle_header (int col);
+  private slots:
+
+    void headercontextmenu_requested (const QPoint& pos);
+    void toggle_header (int col);
 
-  //! Context menu wanted.
+    //! Context menu wanted.
 
-  void contextmenu_requested (const QPoint& pos);
+    void contextmenu_requested (const QPoint& pos);
 
-  //! Context menu actions.
-  //!@{
-  void contextmenu_open (bool);
-  void contextmenu_open_in_editor (bool);
-  void contextmenu_open_in_app (bool);
-  void contextmenu_copy_selection (bool);
-  void contextmenu_run (bool);
-  void contextmenu_load (bool);
-  void contextmenu_rename (bool);
-  void contextmenu_delete (bool);
-  void contextmenu_newfile (bool);
-  void contextmenu_newdir (bool);
-  void contextmenu_setcurrentdir (bool);
-  void contextmenu_findfiles (bool);
-  //!@}
+    //! Context menu actions.
+    //!@{
+    void contextmenu_open (bool);
+    void contextmenu_open_in_editor (bool);
+    void contextmenu_open_in_app (bool);
+    void contextmenu_copy_selection (bool);
+    void contextmenu_run (bool);
+    void contextmenu_load (bool);
+    void contextmenu_rename (bool);
+    void contextmenu_delete (bool);
+    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);
-  void popdownmenu_home (bool);
-  //!@}
+    //! Popdown menu options.
+    //!@{
+    void popdownmenu_newfile (bool);
+    void popdownmenu_newdir (bool);
+    void popdownmenu_search_dir (bool);
+    void popdownmenu_findfiles (bool);
+    void popdownmenu_home (bool);
+    //!@}
 
-  //! Inherited from octave_doc_widget.
-  //!@{
-  void copyClipboard ();
-  void pasteClipboard ();
-  void selectAll ();
-  //!@}
+    //! Inherited from octave_doc_widget.
+    //!@{
+    void copyClipboard ();
+    void pasteClipboard ();
+    void selectAll ();
+    //!@}
 
-signals:
+  signals:
 
-  //! Emitted, whenever the user requested to open a file.
+    //! Emitted, whenever the user requested to open a file.
 
-  void open_file (const QString& fileName);
+    void open_file (const QString& fileName);
 
-  //! Emitted, whenever the currently displayed directory changed.
+    //! Emitted, whenever the currently displayed directory changed.
 
-  void displayed_directory_changed (const QString& dir);
+    void displayed_directory_changed (const QString& dir);
 
-  //! Emitted, whenever the user requested to load a file.
+    //! Emitted, whenever the user requested to load a file.
 
-  void load_file_signal (const QString& fileName);
+    void load_file_signal (const QString& fileName);
 
-  //! Emitted, whenever the user requested to run a file.
+    //! Emitted, whenever the user requested to run a file.
 
-  void run_file_signal (const QFileInfo& info);
+    void run_file_signal (const QFileInfo& info);
 
-  //! Emitted, whenever wants to search for a file .
+    //! Emitted, whenever wants to search for a file .
 
-  void find_files_signal (const QString& startdir);
+    void find_files_signal (const QString& startdir);
 
-  //! Emitted, whenever the user removes or renames a file.
+    //! Emitted, whenever the user removes or renames a file.
 
-  void file_remove_signal (const QString& old_name, const QString& new_name);
+    void file_remove_signal (const QString& old_name, const QString& new_name);
 
-  //! Emitted, when a file or directory is renamed.
+    //! Emitted, when a file or directory is renamed.
 
-  void file_renamed_signal (bool);
+    void file_renamed_signal (bool);
 
-private:
+  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);
+    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
+    //! set a new directory or open a file
 
-  void display_directory (const QString& dir, bool set_octave_dir = true);
+    void display_directory (const QString& dir, bool set_octave_dir = true);
 
-  void open_item_in_app (const QModelIndex& index);
+    void open_item_in_app (const QModelIndex& index);
 
-  //! Variables for the actions
+    //! Variables for the actions
 
-  QToolBar *m_navigation_tool_bar;
-  QAction *m_sync_octave_directory_action;
-  QAction *m_sync_browser_directory_action;
+    QToolBar *m_navigation_tool_bar;
+    QAction *m_sync_octave_directory_action;
+    QAction *m_sync_browser_directory_action;
 
-  //! The file system model.
+    //! The file system model.
 
-  QFileSystemModel *m_file_system_model;
+    QFileSystemModel *m_file_system_model;
 
-  //! The file system view.
-  //!@{
-  QTreeView *m_file_tree_view;
-  QComboBox *m_current_directory;
-  //!@}
+    //! The file system view.
+    //!@{
+    QTreeView *m_file_tree_view;
+    QComboBox *m_current_directory;
+    //!@}
 
-  //! Flag if syncing with Octave.
+    //! Flag if syncing with Octave.
+
+    bool m_sync_octave_dir;
 
-  bool m_sync_octave_dir;
+    //! The actual Octave directory.
 
-  //! The actual Octave directory.
+    QString m_octave_dir;
 
-  QString m_octave_dir;
+    enum { MaxMRUDirs = 10 };
 
-  enum { MaxMRUDirs = 10 };
-
-  QStringList m_columns_shown;
-  QStringList m_columns_shown_keys;
-  QSignalMapper *m_sig_mapper;
-};
+    QStringList m_columns_shown;
+    QStringList m_columns_shown_keys;
+    QSignalMapper *m_sig_mapper;
+  };
+}
 
 #endif
--- a/libgui/src/find-files-dialog.cc	Sat Feb 10 23:32:04 2018 -0500
+++ b/libgui/src/find-files-dialog.cc	Sun Feb 11 09:20:36 2018 -0500
@@ -46,368 +46,363 @@
 #include "find-files-model.h"
 #include "resource-manager.h"
 
-find_files_dialog::find_files_dialog (QWidget *p)
-  : QDialog (p)
+namespace octave
 {
-  setWindowTitle (tr ("Find Files"));
-  setWindowIcon (resource_manager::icon ("edit-find"));
-
-  m_dir_iterator = nullptr;
+  find_files_dialog::find_files_dialog (QWidget *p)
+    : QDialog (p)
+  {
+    setWindowTitle (tr ("Find Files"));
+    setWindowIcon (resource_manager::icon ("edit-find"));
 
-  m_timer = new QTimer (this);
-  connect (m_timer, SIGNAL (timeout (void)),
-           this, SLOT (look_for_files (void)));
+    m_dir_iterator = nullptr;
 
-  QSettings *settings = resource_manager::get_settings ();
+    m_timer = new QTimer (this);
+    connect (m_timer, SIGNAL (timeout (void)),
+             this, SLOT (look_for_files (void)));
 
-  QLabel *file_name_label = new QLabel (tr ("Named:"));
-  m_file_name_edit = new QLineEdit;
-  m_file_name_edit->setToolTip (tr ("Enter the filename search expression"));
+    QSettings *settings = resource_manager::get_settings ();
 
-  m_file_name_edit->setText (settings->value ("findfiles/file_name",
-                                              "*").toString ());
-  file_name_label->setBuddy (m_file_name_edit);
+    QLabel *file_name_label = new QLabel (tr ("Named:"));
+    m_file_name_edit = new QLineEdit;
+    m_file_name_edit->setToolTip (tr ("Enter the filename search expression"));
 
-  QLabel *start_dir_label = new QLabel (tr ("Start in:"));
+    m_file_name_edit->setText (settings->value ("findfiles/file_name",
+                                                "*").toString ());
+    file_name_label->setBuddy (m_file_name_edit);
 
-  m_start_dir_edit = new QLineEdit;
-  m_start_dir_edit->setText (settings->value ("findfiles/start_dir",
-                                              QDir::currentPath ()).toString ());
-  m_start_dir_edit->setToolTip (tr ("Enter the start directory"));
-  start_dir_label->setBuddy (m_start_dir_edit);
+    QLabel *start_dir_label = new QLabel (tr ("Start in:"));
 
-  m_browse_button = new QPushButton (tr ("Browse..."));
-  m_browse_button->setToolTip (tr ("Browse for start directory"));
-  connect (m_browse_button, SIGNAL (clicked (void)),
-           this, SLOT (browse_folders (void)));
-
-  m_recurse_dirs_check = new QCheckBox (tr ("Search subdirectories"));
-  m_recurse_dirs_check->setChecked (settings->value ("findfiles/recurse_dirs",
-                                                     false).toBool ());
-  m_recurse_dirs_check->setToolTip (tr ("Search recursively through directories for matching files"));
+    m_start_dir_edit = new QLineEdit;
+    m_start_dir_edit->setText (settings->value ("findfiles/start_dir",
+                                                QDir::currentPath ()).toString ());
+    m_start_dir_edit->setToolTip (tr ("Enter the start directory"));
+    start_dir_label->setBuddy (m_start_dir_edit);
 
-  m_include_dirs_check = new QCheckBox (tr ("Include directory names"));
-  m_include_dirs_check->setChecked (settings->value ("findfiles/include_dirs",
-                                                     false).toBool ());
-  m_include_dirs_check->setToolTip (tr ("Include matching directories in search results"));
-
-  m_name_case_check = new QCheckBox (tr ("Name case insensitive"));
-  m_name_case_check->setChecked (settings->value ("findfiles/name_case",
-                                                  false).toBool ());
-  m_name_case_check->setToolTip (tr ("Set matching name is case insensitive"));
+    m_browse_button = new QPushButton (tr ("Browse..."));
+    m_browse_button->setToolTip (tr ("Browse for start directory"));
+    connect (m_browse_button, SIGNAL (clicked (void)),
+             this, SLOT (browse_folders (void)));
 
-  m_contains_text_check = new QCheckBox (tr ("Contains text:"));
-  m_contains_text_check->setToolTip (tr ("Enter the file content search expression"));
-  m_contains_text_check->setChecked (settings->value ("findfiles/check_text",
-                                                      false).toBool ());
+    m_recurse_dirs_check = new QCheckBox (tr ("Search subdirectories"));
+    m_recurse_dirs_check->setChecked (settings->value ("findfiles/recurse_dirs",
+                                                       false).toBool ());
+    m_recurse_dirs_check->setToolTip (tr ("Search recursively through directories for matching files"));
 
-  m_contains_text_edit = new QLineEdit ();
-  m_contains_text_edit->setToolTip (tr ("Text to match"));
-  m_contains_text_edit->setText (settings->value ("findfiles/contains_text",
-                                                  "").toString ());
+    m_include_dirs_check = new QCheckBox (tr ("Include directory names"));
+    m_include_dirs_check->setChecked (settings->value ("findfiles/include_dirs",
+                                                       false).toBool ());
+    m_include_dirs_check->setToolTip (tr ("Include matching directories in search results"));
 
-  m_content_case_check = new QCheckBox (tr ("Text case insensitive"));
-  m_content_case_check->setChecked (settings->value ("findfiles/content_case",
-                                                     false).toBool ());
-  m_content_case_check->setToolTip (tr ("Set text content is case insensitive"));
+    m_name_case_check = new QCheckBox (tr ("Name case insensitive"));
+    m_name_case_check->setChecked (settings->value ("findfiles/name_case",
+                                                    false).toBool ());
+    m_name_case_check->setToolTip (tr ("Set matching name is case insensitive"));
 
-  find_files_model *model = new find_files_model (this);
+    m_contains_text_check = new QCheckBox (tr ("Contains text:"));
+    m_contains_text_check->setToolTip (tr ("Enter the file content search expression"));
+    m_contains_text_check->setChecked (settings->value ("findfiles/check_text",
+                                                        false).toBool ());
 
-  m_file_list = new QTableView;
-  m_file_list->setWordWrap (false);
-  m_file_list->setModel (model);
-  m_file_list->setShowGrid (false);
-  m_file_list->setSelectionBehavior (QAbstractItemView::SelectRows);
-  m_file_list->setSelectionMode (QAbstractItemView::SingleSelection);
-  m_file_list->setAlternatingRowColors (true);
-  m_file_list->setToolTip (tr ("Search results"));
-  m_file_list->setSortingEnabled (true);
-  m_file_list->horizontalHeader ()->restoreState (settings->value ("findfiles/column_state").toByteArray ());
-  m_file_list->horizontalHeader ()->setSortIndicatorShown (true);
-#if defined (HAVE_QT4)
-  m_file_list->horizontalHeader ()->setClickable (true);
-#else
-  m_file_list->horizontalHeader ()->setSectionsClickable (true);
-#endif
-  m_file_list->horizontalHeader ()->setStretchLastSection (true);
-  m_file_list->sortByColumn (settings->value ("findfiles/sort_files_by_column",0).toInt (),
-                             static_cast<Qt::SortOrder>
-                             (settings->value ("findfiles/sort_files_by_order",
-                                               Qt::AscendingOrder).toUInt ()));
+    m_contains_text_edit = new QLineEdit ();
+    m_contains_text_edit->setToolTip (tr ("Text to match"));
+    m_contains_text_edit->setText (settings->value ("findfiles/contains_text",
+                                                    "").toString ());
+
+    m_content_case_check = new QCheckBox (tr ("Text case insensitive"));
+    m_content_case_check->setChecked (settings->value ("findfiles/content_case",
+                                                       false).toBool ());
+    m_content_case_check->setToolTip (tr ("Set text content is case insensitive"));
+
+    find_files_model *model = new find_files_model (this);
 
-  connect (m_file_list, SIGNAL (doubleClicked (const QModelIndex&)),
-           this, SLOT (item_double_clicked (const QModelIndex &)));
-
-  m_status_bar = new QStatusBar;
-  m_status_bar->showMessage (tr ("Idle."));
+    m_file_list = new QTableView;
+    m_file_list->setWordWrap (false);
+    m_file_list->setModel (model);
+    m_file_list->setShowGrid (false);
+    m_file_list->setSelectionBehavior (QAbstractItemView::SelectRows);
+    m_file_list->setSelectionMode (QAbstractItemView::SingleSelection);
+    m_file_list->setAlternatingRowColors (true);
+    m_file_list->setToolTip (tr ("Search results"));
+    m_file_list->setSortingEnabled (true);
+    m_file_list->horizontalHeader ()->restoreState (settings->value ("findfiles/column_state").toByteArray ());
+    m_file_list->horizontalHeader ()->setSortIndicatorShown (true);
+#if defined (HAVE_QT4)
+    m_file_list->horizontalHeader ()->setClickable (true);
+#else
+    m_file_list->horizontalHeader ()->setSectionsClickable (true);
+#endif
+    m_file_list->horizontalHeader ()->setStretchLastSection (true);
+    m_file_list->sortByColumn (settings->value ("findfiles/sort_files_by_column",0).toInt (),
+                               static_cast<Qt::SortOrder>
+                               (settings->value ("findfiles/sort_files_by_order",
+                                                 Qt::AscendingOrder).toUInt ()));
 
-  m_find_button = new QPushButton (tr ("Find"));
-  m_find_button->setToolTip (tr ("Start search for matching files"));
-  connect (m_find_button, SIGNAL (clicked (void)),
-           this, SLOT (start_find (void)));
-
-  m_stop_button = new QPushButton (tr ("Stop"));
-  m_stop_button->setToolTip (tr ("Stop searching"));
-  m_stop_button->setEnabled (false);
-  connect (m_stop_button, SIGNAL (clicked (void)),
-           this, SLOT (stop_find (void)));
+    connect (m_file_list, SIGNAL (doubleClicked (const QModelIndex&)),
+             this, SLOT (item_double_clicked (const QModelIndex &)));
 
-  // layout everything
-  QDialogButtonBox *button_box = new QDialogButtonBox (Qt::Vertical);
-  button_box->addButton (m_find_button, QDialogButtonBox::ActionRole);
-  button_box->addButton (m_stop_button, QDialogButtonBox::ActionRole);
+    m_status_bar = new QStatusBar;
+    m_status_bar->showMessage (tr ("Idle."));
 
-  // add dialog close button
-  m_close_button = button_box->addButton (QDialogButtonBox::Close);
-  connect (button_box, SIGNAL (rejected (void)), this, SLOT (close (void)));
+    m_find_button = new QPushButton (tr ("Find"));
+    m_find_button->setToolTip (tr ("Start search for matching files"));
+    connect (m_find_button, SIGNAL (clicked (void)),
+             this, SLOT (start_find (void)));
+
+    m_stop_button = new QPushButton (tr ("Stop"));
+    m_stop_button->setToolTip (tr ("Stop searching"));
+    m_stop_button->setEnabled (false);
+    connect (m_stop_button, SIGNAL (clicked (void)),
+             this, SLOT (stop_find (void)));
 
-  // name options
-  QGroupBox *name_group = new QGroupBox (tr ("Filename/location"));
-  QGridLayout *name_layout = new QGridLayout;
-  name_group->setLayout (name_layout);
-
-  name_layout->addWidget (file_name_label,1,1, 1,1);
-  name_layout->addWidget (m_file_name_edit,1,2, 1,-1);
+    // layout everything
+    QDialogButtonBox *button_box = new QDialogButtonBox (Qt::Vertical);
+    button_box->addButton (m_find_button, QDialogButtonBox::ActionRole);
+    button_box->addButton (m_stop_button, QDialogButtonBox::ActionRole);
 
-  name_layout->addWidget (start_dir_label,2,1);
-  name_layout->addWidget (m_start_dir_edit,2,2,1,3);
-  name_layout->addWidget (m_browse_button,2,5);
-  name_layout->setColumnStretch (2,1);
+    // add dialog close button
+    m_close_button = button_box->addButton (QDialogButtonBox::Close);
+    connect (button_box, SIGNAL (rejected (void)), this, SLOT (close (void)));
 
-  name_layout->addWidget (m_recurse_dirs_check,3,1);
-  name_layout->addWidget (m_include_dirs_check,3,2);
-  name_layout->addWidget (m_name_case_check,3,3);
+    // name options
+    QGroupBox *name_group = new QGroupBox (tr ("Filename/location"));
+    QGridLayout *name_layout = new QGridLayout;
+    name_group->setLayout (name_layout);
 
-  // content options
-  QGroupBox *content_group = new QGroupBox (tr ("File contents"));
-  QGridLayout *content_layout = new QGridLayout;
-  content_group->setLayout (content_layout);
-  content_layout->addWidget (m_contains_text_check,4,1);
-  content_layout->addWidget (m_contains_text_edit,4,2,1,3);
-  content_layout->setColumnStretch (2,1);
-  content_layout->addWidget (m_content_case_check,5,1);
+    name_layout->addWidget (file_name_label,1,1, 1,1);
+    name_layout->addWidget (m_file_name_edit,1,2, 1,-1);
+
+    name_layout->addWidget (start_dir_label,2,1);
+    name_layout->addWidget (m_start_dir_edit,2,2,1,3);
+    name_layout->addWidget (m_browse_button,2,5);
+    name_layout->setColumnStretch (2,1);
 
-  QGridLayout *main_layout = new QGridLayout;
-  main_layout->setSizeConstraint (QLayout::SetFixedSize);
-  main_layout->addWidget (name_group, 0, 0);
-  main_layout->addWidget (content_group, 1, 0);
-  main_layout->addWidget (button_box, 0, 1,3,1);
-  main_layout->addWidget (m_file_list,2,0);
-  main_layout->setRowStretch (2,1);
-  main_layout->addWidget (m_status_bar,3,0,1,-1);
+    name_layout->addWidget (m_recurse_dirs_check,3,1);
+    name_layout->addWidget (m_include_dirs_check,3,2);
+    name_layout->addWidget (m_name_case_check,3,3);
 
-  setLayout (main_layout);
-
-  connect (this, SIGNAL (finished (int)), this, SLOT (handle_done (int)));
-}
+    // content options
+    QGroupBox *content_group = new QGroupBox (tr ("File contents"));
+    QGridLayout *content_layout = new QGridLayout;
+    content_group->setLayout (content_layout);
+    content_layout->addWidget (m_contains_text_check,4,1);
+    content_layout->addWidget (m_contains_text_edit,4,2,1,3);
+    content_layout->setColumnStretch (2,1);
+    content_layout->addWidget (m_content_case_check,5,1);
 
-find_files_dialog::~find_files_dialog (void)
-{
-  delete m_dir_iterator;
-}
+    QGridLayout *main_layout = new QGridLayout;
+    main_layout->setSizeConstraint (QLayout::SetFixedSize);
+    main_layout->addWidget (name_group, 0, 0);
+    main_layout->addWidget (content_group, 1, 0);
+    main_layout->addWidget (button_box, 0, 1,3,1);
+    main_layout->addWidget (m_file_list,2,0);
+    main_layout->setRowStretch (2,1);
+    main_layout->addWidget (m_status_bar,3,0,1,-1);
 
-void
-find_files_dialog::save_settings (void)
-{
-  QSettings *settings = resource_manager::get_settings ();
+    setLayout (main_layout);
+
+    connect (this, SIGNAL (finished (int)), this, SLOT (handle_done (int)));
+  }
 
-  if (! settings)
-    return;
+  find_files_dialog::~find_files_dialog (void)
+  {
+    delete m_dir_iterator;
+  }
+
+  void find_files_dialog::save_settings (void)
+  {
+    QSettings *settings = resource_manager::get_settings ();
 
-  int sort_column = m_file_list->horizontalHeader ()->sortIndicatorSection ();
-  Qt::SortOrder sort_order
-    = m_file_list->horizontalHeader ()->sortIndicatorOrder ();
-  settings->setValue ("findfiles/sort_files_by_column", sort_column);
-  settings->setValue ("findfiles/sort_files_by_order", sort_order);
-  settings->setValue ("findfiles/column_state",
-                      m_file_list->horizontalHeader ()->saveState ());
+    if (! settings)
+      return;
 
-  settings->setValue ("findfiles/file_name", m_file_name_edit->text ());
+    int sort_column = m_file_list->horizontalHeader ()->sortIndicatorSection ();
+    Qt::SortOrder sort_order
+      = m_file_list->horizontalHeader ()->sortIndicatorOrder ();
+    settings->setValue ("findfiles/sort_files_by_column", sort_column);
+    settings->setValue ("findfiles/sort_files_by_order", sort_order);
+    settings->setValue ("findfiles/column_state",
+                        m_file_list->horizontalHeader ()->saveState ());
 
-  settings->setValue ("findfiles/start_dir", m_start_dir_edit->text ());
+    settings->setValue ("findfiles/file_name", m_file_name_edit->text ());
 
-  settings->setValue ("findfiles/recurse_dirs", m_recurse_dirs_check->text ());
-  settings->setValue ("findfiles/include_dirs", m_include_dirs_check->text ());
-  settings->setValue ("findfiles/name_case", m_name_case_check->text ());
+    settings->setValue ("findfiles/start_dir", m_start_dir_edit->text ());
+
+    settings->setValue ("findfiles/recurse_dirs", m_recurse_dirs_check->text ());
+    settings->setValue ("findfiles/include_dirs", m_include_dirs_check->text ());
+    settings->setValue ("findfiles/name_case", m_name_case_check->text ());
 
-  settings->setValue ("findfiles/contains_text", m_contains_text_edit->text ());
-  settings->setValue ("findfiles/check_text",
-                      m_contains_text_check->isChecked ());
-  settings->setValue ("findfiles/content_case",
-                      m_content_case_check->isChecked ());
+    settings->setValue ("findfiles/contains_text", m_contains_text_edit->text ());
+    settings->setValue ("findfiles/check_text",
+                        m_contains_text_check->isChecked ());
+    settings->setValue ("findfiles/content_case",
+                        m_content_case_check->isChecked ());
 
-  settings->sync ();
-}
+    settings->sync ();
+  }
 
-void find_files_dialog::set_search_dir (const QString& dir)
-{
-  stop_find ();
-  m_start_dir_edit->setText (dir);
-}
+  void find_files_dialog::set_search_dir (const QString& dir)
+  {
+    stop_find ();
+    m_start_dir_edit->setText (dir);
+  }
 
-void
-find_files_dialog::start_find (void)
-{
-  stop_find ();
+  void find_files_dialog::start_find (void)
+  {
+    stop_find ();
 
-  find_files_model *m = static_cast<find_files_model *> (m_file_list->model ());
-  m->clear ();
-
-  QDirIterator::IteratorFlags flags = QDirIterator::NoIteratorFlags;
-  if (m_recurse_dirs_check->isChecked ())
-    flags |= QDirIterator::Subdirectories;
+    find_files_model *m = static_cast<find_files_model *> (m_file_list->model ());
+    m->clear ();
 
-  QDir::Filters filters = QDir::Dirs | QDir::NoDotAndDotDot | QDir::Files;
-  if (! m_name_case_check->isChecked ())
-    filters |= QDir::CaseSensitive;
+    QDirIterator::IteratorFlags flags = QDirIterator::NoIteratorFlags;
+    if (m_recurse_dirs_check->isChecked ())
+      flags |= QDirIterator::Subdirectories;
 
-  QStringList nameFilters;
-  nameFilters.append (m_file_name_edit->text ());
+    QDir::Filters filters = QDir::Dirs | QDir::NoDotAndDotDot | QDir::Files;
+    if (! m_name_case_check->isChecked ())
+      filters |= QDir::CaseSensitive;
 
-  if (m_dir_iterator)
-    delete m_dir_iterator;
+    QStringList nameFilters;
+    nameFilters.append (m_file_name_edit->text ());
 
-  m_dir_iterator = new QDirIterator (m_start_dir_edit->text (), nameFilters,
-                                     filters, flags);
+    if (m_dir_iterator)
+      delete m_dir_iterator;
 
-  // enable/disable widgets
-  m_find_button->setEnabled (false);
-  m_stop_button->setEnabled (true);
-  m_close_button->setEnabled (false);
-  m_browse_button->setEnabled (false);
-  m_start_dir_edit->setEnabled (false);
-  m_file_name_edit->setEnabled (false);
-  m_recurse_dirs_check->setEnabled (false);
-  m_include_dirs_check->setEnabled (false);
-  m_name_case_check->setEnabled (false);
-  m_contains_text_check->setEnabled (false);
-  m_content_case_check->setEnabled (false);
-  m_contains_text_edit->setEnabled (false);
+    m_dir_iterator = new QDirIterator (m_start_dir_edit->text (), nameFilters,
+                                       filters, flags);
 
-  m_status_bar->showMessage (tr ("Searching..."));
-  m_timer->start (0);
-}
+    // enable/disable widgets
+    m_find_button->setEnabled (false);
+    m_stop_button->setEnabled (true);
+    m_close_button->setEnabled (false);
+    m_browse_button->setEnabled (false);
+    m_start_dir_edit->setEnabled (false);
+    m_file_name_edit->setEnabled (false);
+    m_recurse_dirs_check->setEnabled (false);
+    m_include_dirs_check->setEnabled (false);
+    m_name_case_check->setEnabled (false);
+    m_contains_text_check->setEnabled (false);
+    m_content_case_check->setEnabled (false);
+    m_contains_text_edit->setEnabled (false);
 
-void
-find_files_dialog::stop_find (void)
-{
-  m_timer->stop ();
+    m_status_bar->showMessage (tr ("Searching..."));
+    m_timer->start (0);
+  }
 
-  m_find_button->setEnabled (true);
-  m_stop_button->setEnabled (false);
-  m_close_button->setEnabled (true);
-  m_browse_button->setEnabled (true);
-  m_start_dir_edit->setEnabled (true);
-  m_file_name_edit->setEnabled (true);
-  m_recurse_dirs_check->setEnabled (true);
-  m_include_dirs_check->setEnabled (true);
-  m_name_case_check->setEnabled (true);
-  m_contains_text_check->setEnabled (true);
-  m_content_case_check->setEnabled (true);
-  m_contains_text_edit->setEnabled (true);
+  void find_files_dialog::stop_find (void)
+  {
+    m_timer->stop ();
 
-  find_files_model *m = static_cast<find_files_model *> (m_file_list->model ());
-  QString res_str = QString (tr ("%1 match (es)")).arg (m->rowCount ());
-
-  m_status_bar->showMessage (res_str);
-}
+    m_find_button->setEnabled (true);
+    m_stop_button->setEnabled (false);
+    m_close_button->setEnabled (true);
+    m_browse_button->setEnabled (true);
+    m_start_dir_edit->setEnabled (true);
+    m_file_name_edit->setEnabled (true);
+    m_recurse_dirs_check->setEnabled (true);
+    m_include_dirs_check->setEnabled (true);
+    m_name_case_check->setEnabled (true);
+    m_contains_text_check->setEnabled (true);
+    m_content_case_check->setEnabled (true);
+    m_contains_text_edit->setEnabled (true);
 
-void
-find_files_dialog::browse_folders (void)
-{
-  QString dir =
-    QFileDialog::getExistingDirectory (this, tr ("Set search directory"),
-                                       m_start_dir_edit->text ());
+    find_files_model *m = static_cast<find_files_model *> (m_file_list->model ());
+    QString res_str = QString (tr ("%1 match (es)")).arg (m->rowCount ());
+
+    m_status_bar->showMessage (res_str);
+  }
 
-  if (! dir.isEmpty ())
-    m_start_dir_edit->setText (dir);
-}
+  void find_files_dialog::browse_folders (void)
+  {
+    QString dir =
+      QFileDialog::getExistingDirectory (this, tr ("Set search directory"),
+                                         m_start_dir_edit->text ());
 
-void
-find_files_dialog::item_double_clicked (const QModelIndex& idx)
-{
-  find_files_model *m = static_cast<find_files_model *> (m_file_list->model ());
+    if (! dir.isEmpty ())
+      m_start_dir_edit->setText (dir);
+  }
 
-  QFileInfo info = m->fileInfo (idx);
+  void find_files_dialog::item_double_clicked (const QModelIndex& idx)
+  {
+    find_files_model *m = static_cast<find_files_model *> (m_file_list->model ());
+
+    QFileInfo info = m->fileInfo (idx);
 
-  if (idx.column () == 1)
-    {
-      // clicked in directory part
-      emit dir_selected (info.absolutePath ());
-    }
-  else
-    {
-      // clicked in filename part
-      if (info.isDir ())
-        emit dir_selected (info.absoluteFilePath ());
-      else
-        emit file_selected (info.absoluteFilePath ());
-    }
-}
+    if (idx.column () == 1)
+      {
+        // clicked in directory part
+        emit dir_selected (info.absolutePath ());
+      }
+    else
+      {
+        // clicked in filename part
+        if (info.isDir ())
+          emit dir_selected (info.absoluteFilePath ());
+        else
+          emit file_selected (info.absoluteFilePath ());
+      }
+  }
 
-void
-find_files_dialog::look_for_files (void)
-{
-  if (m_dir_iterator && m_dir_iterator->hasNext ())
-    {
-      QFileInfo info (m_dir_iterator->next ());
+  void find_files_dialog::look_for_files (void)
+  {
+    if (m_dir_iterator && m_dir_iterator->hasNext ())
+      {
+        QFileInfo info (m_dir_iterator->next ());
 
-      find_files_model *m
-        = static_cast<find_files_model *> (m_file_list->model ());
-
-      if (is_match (info))
-        m->addFile (info);
-    }
-  else
-    {
-      stop_find ();
-    }
-}
+        find_files_model *m
+          = static_cast<find_files_model *> (m_file_list->model ());
 
-void
-find_files_dialog::handle_done (int)
-{
-  // make sure we stopped processing
-  stop_find ();
-}
+        if (is_match (info))
+          m->addFile (info);
+      }
+    else
+      {
+        stop_find ();
+      }
+  }
 
-bool
-find_files_dialog::is_match (const QFileInfo& info)
-{
-  bool match = true;
-  if (info.isDir ())
-    {
-      if (! m_include_dirs_check->isChecked ()) match = false;
-      if (m_contains_text_check->isChecked ()) match = false;
-    }
-  else
-    {
-      // a file
-      if (m_contains_text_check->isChecked ())
-        {
-          match = false;
+  void find_files_dialog::handle_done (int)
+  {
+    // make sure we stopped processing
+    stop_find ();
+  }
 
-          QFile file (info.absoluteFilePath ());
-          if (file.open (QIODevice::ReadOnly))
-            {
-              QTextStream stream (&file);
+  bool find_files_dialog::is_match (const QFileInfo& info)
+  {
+    bool match = true;
+    if (info.isDir ())
+      {
+        if (! m_include_dirs_check->isChecked ()) match = false;
+        if (m_contains_text_check->isChecked ()) match = false;
+      }
+    else
+      {
+        // a file
+        if (m_contains_text_check->isChecked ())
+          {
+            match = false;
 
-              QString line;
-              QString match_str = m_contains_text_edit->text ();
-
-              Qt::CaseSensitivity cs = m_content_case_check->isChecked () ?
-                Qt::CaseInsensitive : Qt::CaseSensitive;
+            QFile file (info.absoluteFilePath ());
+            if (file.open (QIODevice::ReadOnly))
+              {
+                QTextStream stream (&file);
 
-              do
-                {
-                  line = stream.readLine ();
-                  match = line.contains (match_str, cs);
-                }
-              while (! line.isNull () && match == false);
-            }
+                QString line;
+                QString match_str = m_contains_text_edit->text ();
+
+                Qt::CaseSensitivity cs = m_content_case_check->isChecked () ?
+                  Qt::CaseInsensitive : Qt::CaseSensitive;
 
-        }
-    }
+                do
+                  {
+                    line = stream.readLine ();
+                    match = line.contains (match_str, cs);
+                  }
+                while (! line.isNull () && match == false);
+              }
 
-  return match;
+          }
+      }
+
+    return match;
+  }
 }
--- a/libgui/src/find-files-dialog.h	Sat Feb 10 23:32:04 2018 -0500
+++ b/libgui/src/find-files-dialog.h	Sun Feb 11 09:20:36 2018 -0500
@@ -34,56 +34,59 @@
 class QCheckBox;
 class QStatusBar;
 
-class find_files_dialog : public QDialog
+namespace octave
 {
-  Q_OBJECT
+  class find_files_dialog : public QDialog
+  {
+    Q_OBJECT
 
-public:
+  public:
 
-  find_files_dialog (QWidget *parent = nullptr);
+    find_files_dialog (QWidget *parent = nullptr);
 
-  virtual ~find_files_dialog (void);
+    virtual ~find_files_dialog (void);
 
-  void save_settings (void);
+    void save_settings (void);
 
-signals:
+  signals:
 
-  void file_selected (const QString& fileName);
-  void dir_selected (const QString& fileName);
+    void file_selected (const QString& fileName);
+    void dir_selected (const QString& fileName);
 
-public slots:
+  public slots:
 
-  void set_search_dir (const QString& dir);
+    void set_search_dir (const QString& dir);
 
-private slots:
+  private slots:
 
-  void start_find (void);
-  void stop_find (void);
-  void browse_folders (void);
-  void look_for_files (void);
-  void item_double_clicked (const QModelIndex&);
-  void handle_done (int);
+    void start_find (void);
+    void stop_find (void);
+    void browse_folders (void);
+    void look_for_files (void);
+    void item_double_clicked (const QModelIndex&);
+    void handle_done (int);
 
-private:
+  private:
 
-  bool is_match (const QFileInfo& info);
+    bool is_match (const QFileInfo& info);
 
-  QLineEdit *m_start_dir_edit;
-  QLineEdit *m_file_name_edit;
-  QPushButton *m_stop_button;
-  QPushButton *m_find_button;
-  QPushButton *m_close_button;
-  QPushButton *m_browse_button;
-  QTableView *m_file_list;
-  QTimer *m_timer;
-  QCheckBox *m_recurse_dirs_check;
-  QCheckBox *m_include_dirs_check;
-  QCheckBox *m_name_case_check;
-  QCheckBox *m_contains_text_check;
-  QCheckBox *m_content_case_check;
-  QLineEdit *m_contains_text_edit;
-  QDirIterator *m_dir_iterator;
-  QStatusBar *m_status_bar;
-};
+    QLineEdit *m_start_dir_edit;
+    QLineEdit *m_file_name_edit;
+    QPushButton *m_stop_button;
+    QPushButton *m_find_button;
+    QPushButton *m_close_button;
+    QPushButton *m_browse_button;
+    QTableView *m_file_list;
+    QTimer *m_timer;
+    QCheckBox *m_recurse_dirs_check;
+    QCheckBox *m_include_dirs_check;
+    QCheckBox *m_name_case_check;
+    QCheckBox *m_contains_text_check;
+    QCheckBox *m_content_case_check;
+    QLineEdit *m_contains_text_edit;
+    QDirIterator *m_dir_iterator;
+    QStatusBar *m_status_bar;
+  };
+}
 
 #endif
--- a/libgui/src/find-files-model.cc	Sat Feb 10 23:32:04 2018 -0500
+++ b/libgui/src/find-files-model.cc	Sun Feb 11 09:20:36 2018 -0500
@@ -29,187 +29,182 @@
 
 #include "find-files-model.h"
 
-class find_file_less_than
+namespace octave
 {
-public:
-
-  find_file_less_than (int ord) { m_sortorder = ord; }
-
-  QVariant getValue (const QFileInfo& f) const
+  class find_file_less_than
   {
-    QVariant val;
-
-    int col = (m_sortorder > 0) ? m_sortorder : -m_sortorder;
+  public:
 
-    switch (col-1)
-      {
-      case 0:
-        val = QVariant (f.fileName ());
-        break;
+    find_file_less_than (int ord) { m_sortorder = ord; }
 
-      case 1:
-        val = QVariant (f.absolutePath ());
-        break;
+    QVariant getValue (const QFileInfo& f) const
+    {
+      QVariant val;
 
-      default:
-        break;
-      }
-
-    return val;
-  }
+      int col = (m_sortorder > 0) ? m_sortorder : -m_sortorder;
 
-  bool lessThan (const QVariant& left, const QVariant& right) const
-  {
-    return
-      left.toString ().compare (right.toString (), Qt::CaseInsensitive) < 0;
-  }
-
-  bool operator () (const QFileInfo& left, const QFileInfo& right) const
-  {
-    QVariant leftval = getValue (left);
-    QVariant rightval = getValue (right);
+      switch (col-1)
+        {
+        case 0:
+          val = QVariant (f.fileName ());
+          break;
 
-    if (m_sortorder > 0)
-      return lessThan (leftval, rightval);
-    else
-      return ! lessThan (leftval, rightval);
-  }
-
-private:
+        case 1:
+          val = QVariant (f.absolutePath ());
+          break;
 
-  int m_sortorder;
-};
+        default:
+          break;
+        }
 
-find_files_model::find_files_model (QObject *p)
-  : QAbstractListModel (p)
-{
-  m_columnNames.append (tr ("Filename"));
-  m_columnNames.append (tr ("Directory"));
-  m_sortorder = 0;
-}
+      return val;
+    }
 
-void
-find_files_model::clear (void)
-{
-  beginResetModel ();
-
-  m_files.clear ();
-
-  endResetModel ();
-}
+    bool lessThan (const QVariant& left, const QVariant& right) const
+    {
+      return
+        left.toString ().compare (right.toString (), Qt::CaseInsensitive) < 0;
+    }
 
-void
-find_files_model::addFile (const QFileInfo& info)
-{
-  beginInsertRows (QModelIndex (), m_files.size (), m_files.size ());
+    bool operator () (const QFileInfo& left, const QFileInfo& right) const
+    {
+      QVariant leftval = getValue (left);
+      QVariant rightval = getValue (right);
 
-  QList<QFileInfo>::Iterator it;
-  find_file_less_than less_than (m_sortorder);
-
-  for (it = m_files.begin (); it != m_files.end (); it++)
-    {
-      if (less_than (info, *it))
-        break;
+      if (m_sortorder > 0)
+        return lessThan (leftval, rightval);
+      else
+        return ! lessThan (leftval, rightval);
     }
 
-  m_files.insert (it, info);
+  private:
 
-  endInsertRows ();
-}
+    int m_sortorder;
+  };
 
-int
-find_files_model::rowCount (const QModelIndex &) const
-{
-  return m_files.size ();
-}
+  find_files_model::find_files_model (QObject *p)
+    : QAbstractListModel (p)
+  {
+    m_columnNames.append (tr ("Filename"));
+    m_columnNames.append (tr ("Directory"));
+    m_sortorder = 0;
+  }
 
-int
-find_files_model::columnCount (const QModelIndex &) const
-{
-  return m_columnNames.size ();
-}
+  void find_files_model::clear (void)
+  {
+    beginResetModel ();
+
+    m_files.clear ();
 
-QVariant
-find_files_model::data (const QModelIndex& idx, int role) const
-{
-  QVariant retval;
+    endResetModel ();
+  }
+
+  void find_files_model::addFile (const QFileInfo& info)
+  {
+    beginInsertRows (QModelIndex (), m_files.size (), m_files.size ());
+
+    QList<QFileInfo>::Iterator it;
+    find_file_less_than less_than (m_sortorder);
 
-  if (idx.isValid ())
-    {
-      if (role == Qt::DisplayRole)
-        {
-          switch (idx.column ())
-            {
-            case 0:
-              retval = QVariant (m_files[idx.row ()].fileName ());
-              break;
+    for (it = m_files.begin (); it != m_files.end (); it++)
+      {
+        if (less_than (info, *it))
+          break;
+      }
+
+    m_files.insert (it, info);
+
+    endInsertRows ();
+  }
+
+  int find_files_model::rowCount (const QModelIndex &) const
+  {
+    return m_files.size ();
+  }
 
-            case 1:
-              retval = QVariant (m_files[idx.row ()].absolutePath ());
-              break;
+  int find_files_model::columnCount (const QModelIndex &) const
+  {
+    return m_columnNames.size ();
+  }
+
+  QVariant find_files_model::data (const QModelIndex& idx, int role) const
+  {
+    QVariant retval;
 
-            default:
-              break;
-            }
-        }
-      else if (role == Qt::DecorationRole)
-        {
-          switch (idx.column ())
-            {
-            case 0:
-              retval = fileIcon (idx);
+    if (idx.isValid ())
+      {
+        if (role == Qt::DisplayRole)
+          {
+            switch (idx.column ())
+              {
+              case 0:
+                retval = QVariant (m_files[idx.row ()].fileName ());
+                break;
 
-            default:
-              break;
-            }
-        }
-    }
+              case 1:
+                retval = QVariant (m_files[idx.row ()].absolutePath ());
+                break;
+
+              default:
+                break;
+              }
+          }
+        else if (role == Qt::DecorationRole)
+          {
+            switch (idx.column ())
+              {
+              case 0:
+                retval = fileIcon (idx);
 
-  return retval;
-}
+              default:
+                break;
+              }
+          }
+      }
 
-QVariant
-find_files_model::headerData (int section, Qt::Orientation orientation,
-                              int role) const
-{
-  return ((orientation == Qt::Horizontal && role == Qt::DisplayRole)
-          ? m_columnNames[section] : QVariant ());
-}
+    return retval;
+  }
+
+  QVariant find_files_model::headerData (int section,
+                                         Qt::Orientation orientation,
+                                         int role) const
+  {
+    return ((orientation == Qt::Horizontal && role == Qt::DisplayRole)
+            ? m_columnNames[section] : QVariant ());
+  }
 
-void
-find_files_model::sort (int column, Qt::SortOrder order)
-{
-  if (column >= 0)
-    {
-      if (order == Qt::DescendingOrder)
-        m_sortorder = -(column+1);
-      else
-        m_sortorder = column+1;
-    }
-  else
-    m_sortorder = 0;
+  void find_files_model::sort (int column, Qt::SortOrder order)
+  {
+    if (column >= 0)
+      {
+        if (order == Qt::DescendingOrder)
+          m_sortorder = -(column+1);
+        else
+          m_sortorder = column+1;
+      }
+    else
+      m_sortorder = 0;
 
-  if (m_sortorder != 0)
-    {
-      beginResetModel ();
+    if (m_sortorder != 0)
+      {
+        beginResetModel ();
 
-      qSort (m_files.begin (), m_files.end (),
-             find_file_less_than (m_sortorder));
+        qSort (m_files.begin (), m_files.end (),
+               find_file_less_than (m_sortorder));
 
-      endResetModel ();
-    }
-}
+        endResetModel ();
+      }
+  }
 
-QFileInfo
-find_files_model::fileInfo (const QModelIndex & p) const
-{
-  return p.isValid () ? m_files[p.row ()] : QFileInfo ();
-}
+  QFileInfo find_files_model::fileInfo (const QModelIndex & p) const
+  {
+    return p.isValid () ? m_files[p.row ()] : QFileInfo ();
+  }
 
-QIcon
-find_files_model::fileIcon (const QModelIndex& p) const
-{
-  QFileIconProvider icon_provider;
+  QIcon find_files_model::fileIcon (const QModelIndex& p) const
+  {
+    QFileIconProvider icon_provider;
 
-  return p.isValid () ? icon_provider.icon (m_files[p.row ()]) : QIcon ();
+    return p.isValid () ? icon_provider.icon (m_files[p.row ()]) : QIcon ();
+  }
 }
--- a/libgui/src/find-files-model.h	Sat Feb 10 23:32:04 2018 -0500
+++ b/libgui/src/find-files-model.h	Sun Feb 11 09:20:36 2018 -0500
@@ -28,41 +28,43 @@
 #include <QFileInfo>
 #include <QIcon>
 
-
-class find_files_model : public QAbstractListModel
+namespace octave
 {
-  Q_OBJECT
+  class find_files_model : public QAbstractListModel
+  {
+    Q_OBJECT
 
-public:
+  public:
 
-  find_files_model (QObject *p = nullptr);
+    find_files_model (QObject *p = nullptr);
 
-  ~find_files_model (void) = default;
+    ~find_files_model (void) = default;
 
-  void clear (void);
+    void clear (void);
 
-  void addFile (const QFileInfo& info);
+    void addFile (const QFileInfo& info);
 
-  int rowCount (const QModelIndex& p = QModelIndex ()) const;
+    int rowCount (const QModelIndex& p = QModelIndex ()) const;
 
-  int columnCount (const QModelIndex& p = QModelIndex ()) const;
+    int columnCount (const QModelIndex& p = QModelIndex ()) const;
 
-  QVariant data (const QModelIndex& idx, int role) const;
+    QVariant data (const QModelIndex& idx, int role) const;
 
-  QVariant headerData (int section, Qt::Orientation orientation,
-                       int role = Qt::DisplayRole) const;
+    QVariant headerData (int section, Qt::Orientation orientation,
+                         int role = Qt::DisplayRole) const;
 
-  void sort (int column, Qt::SortOrder order = Qt::AscendingOrder);
+    void sort (int column, Qt::SortOrder order = Qt::AscendingOrder);
 
-  QFileInfo fileInfo (const QModelIndex& p) const;
+    QFileInfo fileInfo (const QModelIndex& p) const;
 
-  QIcon fileIcon (const QModelIndex& p) const;
+    QIcon fileIcon (const QModelIndex& p) const;
+
+  private:
 
-private:
-
-  QList<QFileInfo> m_files;
-  QStringList m_columnNames;
-  int m_sortorder;
-};
+    QList<QFileInfo> m_files;
+    QStringList m_columnNames;
+    int m_sortorder;
+  };
+}
 
 #endif
--- a/libgui/src/history-dock-widget.cc	Sat Feb 10 23:32:04 2018 -0500
+++ b/libgui/src/history-dock-widget.cc	Sun Feb 11 09:20:36 2018 -0500
@@ -40,326 +40,313 @@
 
 #include "history-dock-widget.h"
 
-history_dock_widget::history_dock_widget (QWidget *p)
-  : octave_dock_widget (p)
+namespace octave
 {
-  setObjectName ("HistoryDockWidget");
-  setStatusTip (tr ("Browse and search the command history."));
-
-  connect (this, SIGNAL (command_create_script (const QString&)),
-           p, SLOT (new_file (const QString&)));
+  history_dock_widget::history_dock_widget (QWidget *p)
+    : octave_dock_widget (p)
+  {
+    setObjectName ("HistoryDockWidget");
+    setStatusTip (tr ("Browse and search the command history."));
 
-  connect (this, SIGNAL (information (const QString&)),
-           p, SLOT (report_status_message (const QString&)));
+    connect (this, SIGNAL (command_create_script (const QString&)),
+             p, SLOT (new_file (const QString&)));
 
-  connect (this, SIGNAL (command_double_clicked (const QString&)),
-           p, SLOT (execute_command_in_terminal (const QString&)));
+    connect (this, SIGNAL (information (const QString&)),
+             p, SLOT (report_status_message (const QString&)));
 
-  construct ();
-}
+    connect (this, SIGNAL (command_double_clicked (const QString&)),
+             p, SLOT (execute_command_in_terminal (const QString&)));
 
-void
-history_dock_widget::set_history (const QStringList& hist)
-{
-  m_history_model->setStringList (hist);
-  m_history_list_view->scrollToBottom ();
-}
+    construct ();
+  }
+
+  void history_dock_widget::set_history (const QStringList& hist)
+  {
+    m_history_model->setStringList (hist);
+    m_history_list_view->scrollToBottom ();
+  }
 
-void
-history_dock_widget::append_history (const QString& hist_entry)
-{
-  QStringList lst = m_history_model->stringList ();
-  lst.append (hist_entry);
+  void history_dock_widget::append_history (const QString& hist_entry)
+  {
+    QStringList lst = m_history_model->stringList ();
+    lst.append (hist_entry);
 
-  QScrollBar *scroll_bar = m_history_list_view->verticalScrollBar ();
+    QScrollBar *scroll_bar = m_history_list_view->verticalScrollBar ();
 
-  bool at_bottom = scroll_bar->maximum () - scroll_bar->value () < 1;
+    bool at_bottom = scroll_bar->maximum () - scroll_bar->value () < 1;
 
-  m_history_model->setStringList (lst);
+    m_history_model->setStringList (lst);
 
-  // Scroll if slider position at bottom.
-  if (at_bottom)
-    m_history_list_view->scrollToBottom ();
-}
+    // Scroll if slider position at bottom.
+    if (at_bottom)
+      m_history_list_view->scrollToBottom ();
+  }
 
-void
-history_dock_widget::clear_history (void)
-{
-  m_history_model->setStringList (QStringList ());
-}
+  void history_dock_widget::clear_history (void)
+  {
+    m_history_model->setStringList (QStringList ());
+  }
 
-void
-history_dock_widget::save_settings (void)
-{
-  QSettings *settings = resource_manager::get_settings ();
+  void history_dock_widget::save_settings (void)
+  {
+    QSettings *settings = resource_manager::get_settings ();
 
-  if (! settings)
-    return;
+    if (! settings)
+      return;
 
-  settings->setValue ("history_dock_widget/filter_active",
-                      m_filter_checkbox->isChecked ());
-  settings->setValue ("history_dock_widget/filter_shown", m_filter_shown);
+    settings->setValue ("history_dock_widget/filter_active",
+                        m_filter_checkbox->isChecked ());
+    settings->setValue ("history_dock_widget/filter_shown", m_filter_shown);
 
-  QStringList mru;
-  for (int i = 0; i < m_filter->count (); i++)
-    mru.append (m_filter->itemText (i));
-  settings->setValue ("history_dock_widget/mru_list", mru);
+    QStringList mru;
+    for (int i = 0; i < m_filter->count (); i++)
+      mru.append (m_filter->itemText (i));
+    settings->setValue ("history_dock_widget/mru_list", mru);
 
-  settings->sync ();
+    settings->sync ();
 
-  octave_dock_widget::save_settings ();
-}
+    octave_dock_widget::save_settings ();
+  }
 
-void
-history_dock_widget::update_filter_history (void)
-{
-  QString text = m_filter->currentText ();   // get current text
-  int index = m_filter->findText (text);     // and its actual index
+  void history_dock_widget::update_filter_history (void)
+  {
+    QString text = m_filter->currentText ();   // get current text
+    int index = m_filter->findText (text);     // and its actual index
 
-  if (index > -1)
-    m_filter->removeItem (index);    // remove if already existing
+    if (index > -1)
+      m_filter->removeItem (index);    // remove if already existing
 
-  m_filter->insertItem (0, text);    // (re)insert at beginning
-  m_filter->setCurrentIndex (0);
-}
+    m_filter->insertItem (0, text);    // (re)insert at beginning
+    m_filter->setCurrentIndex (0);
+  }
+
+  void history_dock_widget::filter_activate (bool state)
+  {
+    m_filter->setEnabled (state);
+    m_sort_filter_proxy_model.setDynamicSortFilter (state);
 
-void
-history_dock_widget::filter_activate (bool state)
-{
-  m_filter->setEnabled (state);
-  m_sort_filter_proxy_model.setDynamicSortFilter (state);
+    if (state)
+      m_sort_filter_proxy_model.setFilterWildcard (m_filter->currentText ());
+    else
+      m_sort_filter_proxy_model.setFilterWildcard (QString ());
+  }
 
-  if (state)
-    m_sort_filter_proxy_model.setFilterWildcard (m_filter->currentText ());
-  else
-    m_sort_filter_proxy_model.setFilterWildcard (QString ());
-}
+  void history_dock_widget::ctxMenu (const QPoint& xpos)
+  {
+    QMenu menu (this);
 
-void
-history_dock_widget::ctxMenu (const QPoint& xpos)
-{
-  QMenu menu (this);
-
-  QModelIndex index = m_history_list_view->indexAt (xpos);
+    QModelIndex index = m_history_list_view->indexAt (xpos);
 
-  if (index.isValid () && index.column () == 0)
-    {
-      menu.addAction (resource_manager::icon ("edit-copy"),
-                      tr ("Copy"), this, SLOT (handle_contextmenu_copy (bool)));
-      menu.addAction (tr ("Evaluate"), this,
-                      SLOT (handle_contextmenu_evaluate (bool)));
-      menu.addAction (resource_manager::icon ("document-new"),
-                      tr ("Create script"), this,
-                      SLOT (handle_contextmenu_create_script (bool)));
-    }
-  if (m_filter_shown)
-    menu.addAction (tr ("Hide filter"), this,
-                    SLOT (handle_contextmenu_filter ()));
-  else
-    menu.addAction (tr ("Show filter"), this,
-                    SLOT (handle_contextmenu_filter ()));
+    if (index.isValid () && index.column () == 0)
+      {
+        menu.addAction (resource_manager::icon ("edit-copy"),
+                        tr ("Copy"), this, SLOT (handle_contextmenu_copy (bool)));
+        menu.addAction (tr ("Evaluate"), this,
+                        SLOT (handle_contextmenu_evaluate (bool)));
+        menu.addAction (resource_manager::icon ("document-new"),
+                        tr ("Create script"), this,
+                        SLOT (handle_contextmenu_create_script (bool)));
+      }
+    if (m_filter_shown)
+      menu.addAction (tr ("Hide filter"), this,
+                      SLOT (handle_contextmenu_filter ()));
+    else
+      menu.addAction (tr ("Show filter"), this,
+                      SLOT (handle_contextmenu_filter ()));
 
-  menu.exec (m_history_list_view->mapToGlobal (xpos));
-}
+    menu.exec (m_history_list_view->mapToGlobal (xpos));
+  }
 
-void
-history_dock_widget::handle_double_click (QModelIndex modelIndex)
-{
-  emit command_double_clicked (modelIndex.data ().toString ());
-}
+  void history_dock_widget::handle_double_click (QModelIndex modelIndex)
+  {
+    emit command_double_clicked (modelIndex.data ().toString ());
+  }
 
-void
-history_dock_widget::handle_contextmenu_copy (bool)
-{
-  QString text;
-  QItemSelectionModel *selectionModel = m_history_list_view->selectionModel ();
-  QModelIndexList rows = selectionModel->selectedRows ();
-  QModelIndexList::iterator it;
-  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);
-}
+  void history_dock_widget::handle_contextmenu_copy (bool)
+  {
+    QString text;
+    QItemSelectionModel *selectionModel = m_history_list_view->selectionModel ();
+    QModelIndexList rows = selectionModel->selectedRows ();
+    QModelIndexList::iterator it;
+    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);
+  }
 
-void history_dock_widget::handle_contextmenu_evaluate (bool)
-{
-  QItemSelectionModel *selectionModel = m_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 ());
-    }
-}
+  void history_dock_widget::handle_contextmenu_evaluate (bool)
+  {
+    QItemSelectionModel *selectionModel = m_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 ());
+      }
+  }
 
-void
-history_dock_widget::handle_contextmenu_create_script (bool)
-{
-  QString text;
-  QItemSelectionModel *selectionModel = m_history_list_view->selectionModel ();
-  QModelIndexList rows = selectionModel->selectedRows ();
+  void history_dock_widget::handle_contextmenu_create_script (bool)
+  {
+    QString text;
+    QItemSelectionModel *selectionModel = m_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 ())
-        {
-          if (prev_valid_row)
-            text += '\n';
-          text += (*it).data ().toString ();
-          prev_valid_row = true;
-        }
-    }
+    bool prev_valid_row = false;
+    for (QModelIndexList::iterator it = rows.begin (); it != rows.end (); it++)
+      {
+        if ((*it).isValid ())
+          {
+            if (prev_valid_row)
+              text += '\n';
+            text += (*it).data ().toString ();
+            prev_valid_row = true;
+          }
+      }
 
-  if (text.length () > 0)
-    emit command_create_script (text);
-}
+    if (text.length () > 0)
+      emit command_create_script (text);
+  }
 
-void
-history_dock_widget::handle_contextmenu_filter (void)
-{
-  m_filter_shown = ! m_filter_shown;
-  m_filter_widget->setVisible (m_filter_shown);
-}
+  void history_dock_widget::handle_contextmenu_filter (void)
+  {
+    m_filter_shown = ! m_filter_shown;
+    m_filter_widget->setVisible (m_filter_shown);
+  }
 
-void
-history_dock_widget::copyClipboard (void)
-{
-  if (m_history_list_view->hasFocus ())
-    handle_contextmenu_copy (true);
-  if (m_filter->lineEdit ()->hasFocus ()
-      && m_filter->lineEdit ()->hasSelectedText ())
-    {
-      QClipboard *clipboard = QApplication::clipboard ();
-      clipboard->setText (m_filter->lineEdit ()->selectedText ());
-    }
-}
+  void history_dock_widget::copyClipboard (void)
+  {
+    if (m_history_list_view->hasFocus ())
+      handle_contextmenu_copy (true);
+    if (m_filter->lineEdit ()->hasFocus ()
+        && m_filter->lineEdit ()->hasSelectedText ())
+      {
+        QClipboard *clipboard = QApplication::clipboard ();
+        clipboard->setText (m_filter->lineEdit ()->selectedText ());
+      }
+  }
 
-void
-history_dock_widget::pasteClipboard (void)
-{
-  if (m_filter->lineEdit ()->hasFocus ())
-    {
-      QClipboard *clipboard = QApplication::clipboard ();
-      QString str = clipboard->text ();
-      if (str.length () > 0)
-        m_filter->lineEdit ()->insert (str);
-    }
-}
+  void history_dock_widget::pasteClipboard (void)
+  {
+    if (m_filter->lineEdit ()->hasFocus ())
+      {
+        QClipboard *clipboard = QApplication::clipboard ();
+        QString str = clipboard->text ();
+        if (str.length () > 0)
+          m_filter->lineEdit ()->insert (str);
+      }
+  }
 
-void
-history_dock_widget::selectAll (void)
-{
-  if (m_filter->lineEdit ()->hasFocus ())
-    m_filter->lineEdit ()->selectAll ();
+  void history_dock_widget::selectAll (void)
+  {
+    if (m_filter->lineEdit ()->hasFocus ())
+      m_filter->lineEdit ()->selectAll ();
 
-  if (m_history_list_view->hasFocus ())
-    m_history_list_view->selectAll ();
-}
+    if (m_history_list_view->hasFocus ())
+      m_history_list_view->selectAll ();
+  }
 
-void
-history_dock_widget::handle_visibility (bool visible)
-{
-  octave_dock_widget::handle_visibility (visible);
+  void history_dock_widget::handle_visibility (bool visible)
+  {
+    octave_dock_widget::handle_visibility (visible);
 
-  if (visible)
-    {
-      int filter_state = m_filter_checkbox->isChecked ();
-      filter_activate (filter_state);
-    }
-}
+    if (visible)
+      {
+        int filter_state = m_filter_checkbox->isChecked ();
+        filter_activate (filter_state);
+      }
+  }
 
-void
-history_dock_widget::construct (void)
-{
-  m_history_model = new QStringListModel ();
-  m_sort_filter_proxy_model.setSourceModel (m_history_model);
-  m_history_list_view = new QListView (this);
-  m_history_list_view->setModel (&m_sort_filter_proxy_model);
-  m_history_list_view->setAlternatingRowColors (true);
-  m_history_list_view->setEditTriggers (QAbstractItemView::NoEditTriggers);
-  m_history_list_view->setStatusTip (
-    tr ("Double-click a command to transfer it to the terminal."));
-  m_history_list_view->setSelectionMode (QAbstractItemView::ExtendedSelection);
-  m_history_list_view->setContextMenuPolicy (Qt::CustomContextMenu);
-  connect (m_history_list_view,
-           SIGNAL (customContextMenuRequested (const QPoint &)), this,
-           SLOT (ctxMenu (const QPoint &)));
+  void history_dock_widget::construct (void)
+  {
+    m_history_model = new QStringListModel ();
+    m_sort_filter_proxy_model.setSourceModel (m_history_model);
+    m_history_list_view = new QListView (this);
+    m_history_list_view->setModel (&m_sort_filter_proxy_model);
+    m_history_list_view->setAlternatingRowColors (true);
+    m_history_list_view->setEditTriggers (QAbstractItemView::NoEditTriggers);
+    m_history_list_view->setStatusTip (
+                                       tr ("Double-click a command to transfer it to the terminal."));
+    m_history_list_view->setSelectionMode (QAbstractItemView::ExtendedSelection);
+    m_history_list_view->setContextMenuPolicy (Qt::CustomContextMenu);
+    connect (m_history_list_view,
+             SIGNAL (customContextMenuRequested (const QPoint &)), this,
+             SLOT (ctxMenu (const QPoint &)));
 
-  m_filter = new QComboBox (this);
-  m_filter->setToolTip (tr ("Enter text to filter the command history"));
-  m_filter->setEditable (true);
-  m_filter->setMaxCount (MaxFilterHistory);
-  m_filter->setInsertPolicy (QComboBox::NoInsert);
-  m_filter->setSizeAdjustPolicy (
-            QComboBox::AdjustToMinimumContentsLengthWithIcon);
-  QSizePolicy sizePol (QSizePolicy::Expanding, QSizePolicy::Preferred);
-  m_filter->setSizePolicy (sizePol);
-  m_filter->completer ()->setCaseSensitivity (Qt::CaseSensitive);
+    m_filter = new QComboBox (this);
+    m_filter->setToolTip (tr ("Enter text to filter the command history"));
+    m_filter->setEditable (true);
+    m_filter->setMaxCount (MaxFilterHistory);
+    m_filter->setInsertPolicy (QComboBox::NoInsert);
+    m_filter->setSizeAdjustPolicy (
+                                   QComboBox::AdjustToMinimumContentsLengthWithIcon);
+    QSizePolicy sizePol (QSizePolicy::Expanding, QSizePolicy::Preferred);
+    m_filter->setSizePolicy (sizePol);
+    m_filter->completer ()->setCaseSensitivity (Qt::CaseSensitive);
+
+    QLabel *filter_label = new QLabel (tr ("Filter"));
 
-  QLabel *filter_label = new QLabel (tr ("Filter"));
+    m_filter_checkbox = new QCheckBox ();
 
-  m_filter_checkbox = new QCheckBox ();
+    setWindowIcon (QIcon (":/actions/icons/logo.png"));
+    set_title (tr ("Command History"));
+    setWidget (new QWidget ());
 
-  setWindowIcon (QIcon (":/actions/icons/logo.png"));
-  set_title (tr ("Command History"));
-  setWidget (new QWidget ());
+    m_filter_widget = new QWidget (this);
+    QHBoxLayout *filter_layout = new QHBoxLayout ();
+    filter_layout->addWidget (filter_label);
+    filter_layout->addWidget (m_filter_checkbox);
+    filter_layout->addWidget (m_filter);
+    filter_layout->setMargin(0);
+    m_filter_widget->setLayout (filter_layout);
 
-  m_filter_widget = new QWidget (this);
-  QHBoxLayout *filter_layout = new QHBoxLayout ();
-  filter_layout->addWidget (filter_label);
-  filter_layout->addWidget (m_filter_checkbox);
-  filter_layout->addWidget (m_filter);
-  filter_layout->setMargin(0);
-  m_filter_widget->setLayout (filter_layout);
+    QVBoxLayout *hist_layout = new QVBoxLayout ();
+    hist_layout->addWidget (m_filter_widget);
+    hist_layout->addWidget (m_history_list_view);
 
-  QVBoxLayout *hist_layout = new QVBoxLayout ();
-  hist_layout->addWidget (m_filter_widget);
-  hist_layout->addWidget (m_history_list_view);
+    hist_layout->setMargin (2);
+    widget ()->setLayout (hist_layout);
+
+    // Init state of the filter
+    QSettings *settings = resource_manager::get_settings ();
 
-  hist_layout->setMargin (2);
-  widget ()->setLayout (hist_layout);
-
-  // Init state of the filter
-  QSettings *settings = resource_manager::get_settings ();
+    m_filter_shown
+      = settings->value ("history_dock_widget/filter_shown",true).toBool ();
+    m_filter_widget->setVisible (m_filter_shown);
 
-  m_filter_shown
-    = settings->value ("history_dock_widget/filter_shown",true).toBool ();
-  m_filter_widget->setVisible (m_filter_shown);
+    m_filter->addItems (settings->value ("history_dock_widget/mru_list").toStringList ());
 
-  m_filter->addItems (settings->value ("history_dock_widget/mru_list").toStringList ());
+    bool filter_state
+      = settings->value ("history_dock_widget/filter_active", false).toBool ();
+    m_filter_checkbox->setChecked (filter_state);
+    filter_activate (filter_state);
 
-  bool filter_state
-    = settings->value ("history_dock_widget/filter_active", false).toBool ();
-  m_filter_checkbox->setChecked (filter_state);
-  filter_activate (filter_state);
+    // Connect signals and slots
+    connect (m_filter, SIGNAL (editTextChanged (const QString&)),
+             &m_sort_filter_proxy_model,
+             SLOT (setFilterWildcard (const QString&)));
+    connect (m_filter_checkbox, SIGNAL (toggled (bool)),
+             this, SLOT (filter_activate (bool)));
+    connect (m_filter->lineEdit (), SIGNAL (editingFinished (void)),
+             this, SLOT (updatem_filter_history (void)));
 
-  // Connect signals and slots
-  connect (m_filter, SIGNAL (editTextChanged (const QString&)),
-           &m_sort_filter_proxy_model,
-           SLOT (setFilterWildcard (const QString&)));
-  connect (m_filter_checkbox, SIGNAL (toggled (bool)),
-           this, SLOT (filter_activate (bool)));
-  connect (m_filter->lineEdit (), SIGNAL (editingFinished (void)),
-           this, SLOT (updatem_filter_history (void)));
+    connect (m_history_list_view, SIGNAL (doubleClicked (QModelIndex)),
+             this, SLOT (handle_double_click (QModelIndex)));
 
-  connect (m_history_list_view, SIGNAL (doubleClicked (QModelIndex)),
-           this, SLOT (handle_double_click (QModelIndex)));
-
-  // shrink max. displayed entry size to desktop width
-  QSize screen = QDesktopWidget ().screenGeometry ().size ();
-  int w = screen.width ();
-  QFontMetrics fm = m_history_list_view->fontMetrics ();
-  int h = fm.height ();
-  m_history_list_view->setGridSize (QSize (w,h));
-  m_history_list_view->setTextElideMode (Qt::ElideRight);
+    // shrink max. displayed entry size to desktop width
+    QSize screen = QDesktopWidget ().screenGeometry ().size ();
+    int w = screen.width ();
+    QFontMetrics fm = m_history_list_view->fontMetrics ();
+    int h = fm.height ();
+    m_history_list_view->setGridSize (QSize (w,h));
+    m_history_list_view->setTextElideMode (Qt::ElideRight);
+  }
 }
--- a/libgui/src/history-dock-widget.h	Sat Feb 10 23:32:04 2018 -0500
+++ b/libgui/src/history-dock-widget.h	Sun Feb 11 09:20:36 2018 -0500
@@ -32,72 +32,75 @@
 
 #include "octave-dock-widget.h"
 
-class history_dock_widget : public octave_dock_widget
+namespace octave
 {
-  Q_OBJECT
-
-public:
+  class history_dock_widget : public octave_dock_widget
+  {
+    Q_OBJECT
 
-  history_dock_widget (QWidget *parent = nullptr);
+  public:
+
+    history_dock_widget (QWidget *parent = nullptr);
 
-  ~history_dock_widget (void) = default;
+    ~history_dock_widget (void) = default;
 
-public slots:
+  public slots:
 
-  void set_history (const QStringList& hist);
-  void append_history (const QString& hist_entry);
-  void clear_history (void);
-  void save_settings (void);
+    void set_history (const QStringList& hist);
+    void append_history (const QString& hist_entry);
+    void clear_history (void);
+    void save_settings (void);
 
-signals:
+  signals:
 
-  void information (const QString& message);
+    void information (const QString& message);
 
-  //! Signal emitted, whenever the user double-clicked a command in the
-  //! history.
+    //! Signal emitted, whenever the user double-clicked a command in the
+    //! history.
 
-  void command_double_clicked (const QString& command);
+    void command_double_clicked (const QString& command);
 
-  //! Signale emitted, whenever the user selects commands and chooses
-  //! "Create script" from the popup menu.
+    //! Signale emitted, whenever the user selects commands and chooses
+    //! "Create script" from the popup menu.
 
-  void command_create_script (const QString& commands);
+    void command_create_script (const QString& commands);
 
-private slots:
+  private slots:
 
-  void update_filter_history (void);
-  void filter_activate (bool enable);
+    void update_filter_history (void);
+    void filter_activate (bool enable);
 
-  void ctxMenu (const QPoint& pos);
-  void handle_double_click (QModelIndex modelIndex);
-  void handle_contextmenu_copy (bool flag);
-  void handle_contextmenu_evaluate (bool flag);
-  void handle_contextmenu_create_script (bool flag);
-  void handle_contextmenu_filter (void);
+    void ctxMenu (const QPoint& pos);
+    void handle_double_click (QModelIndex modelIndex);
+    void handle_contextmenu_copy (bool flag);
+    void handle_contextmenu_evaluate (bool flag);
+    void handle_contextmenu_create_script (bool flag);
+    void handle_contextmenu_filter (void);
 
-  void copyClipboard (void);
-  void pasteClipboard (void);
-  void selectAll (void);
+    void copyClipboard (void);
+    void pasteClipboard (void);
+    void selectAll (void);
 
-  virtual void handle_visibility (bool visible);
+    virtual void handle_visibility (bool visible);
+
+  private:
 
-private:
-
-  void construct (void);
+    void construct (void);
 
-  QListView *m_history_list_view;
-  QSortFilterProxyModel m_sort_filter_proxy_model;
+    QListView *m_history_list_view;
+    QSortFilterProxyModel m_sort_filter_proxy_model;
 
-  //! Stores the current history_model.
+    //! Stores the current history_model.
+
+    QStringListModel *m_history_model;
 
-  QStringListModel *m_history_model;
+    QCheckBox *m_filter_checkbox;
+    QComboBox *m_filter;
+    QWidget *m_filter_widget;
+    bool m_filter_shown;
 
-  QCheckBox *m_filter_checkbox;
-  QComboBox *m_filter;
-  QWidget *m_filter_widget;
-  bool m_filter_shown;
-
-  enum { MaxFilterHistory = 10 };
-};
+    enum { MaxFilterHistory = 10 };
+  };
+}
 
 #endif
--- a/libgui/src/terminal-dock-widget.cc	Sat Feb 10 23:32:04 2018 -0500
+++ b/libgui/src/terminal-dock-widget.cc	Sun Feb 11 09:20:36 2018 -0500
@@ -27,54 +27,54 @@
 
 #include "terminal-dock-widget.h"
 
-terminal_dock_widget::terminal_dock_widget (QWidget *p)
-  : octave_dock_widget (p), terminal (QTerminal::create (p))
+namespace octave
 {
-  terminal->setObjectName ("OctaveTerminal");
-  terminal->setFocusPolicy (Qt::StrongFocus);
-
-  setObjectName ("TerminalDockWidget");
-  setWindowIcon (QIcon (":/actions/icons/logo.png"));
-  set_title (tr ("Command Window"));
-
-  setWidget (terminal);
-  setFocusProxy (terminal);
+  terminal_dock_widget::terminal_dock_widget (QWidget *p)
+    : octave_dock_widget (p), terminal (QTerminal::create (p))
+  {
+    terminal->setObjectName ("OctaveTerminal");
+    terminal->setFocusPolicy (Qt::StrongFocus);
 
-  connect (terminal, SIGNAL (interrupt_signal (void)),
-           this, SLOT (terminal_interrupt (void)));
+    setObjectName ("TerminalDockWidget");
+    setWindowIcon (QIcon (":/actions/icons/logo.png"));
+    set_title (tr ("Command Window"));
+
+    setWidget (terminal);
+    setFocusProxy (terminal);
 
-  // Connect the visibility signal to the terminal for dis-/enabling timers
-  connect (this, SIGNAL (visibilityChanged (bool)),
-           terminal, SLOT (handle_visibility_changed (bool)));
-}
+    connect (terminal, SIGNAL (interrupt_signal (void)),
+             this, SLOT (terminal_interrupt (void)));
 
-terminal_dock_widget::~terminal_dock_widget (void)
-{
-  delete terminal;
-}
+    // Connect the visibility signal to the terminal for dis-/enabling timers
+    connect (this, SIGNAL (visibilityChanged (bool)),
+             terminal, SLOT (handle_visibility_changed (bool)));
+  }
 
-bool
-terminal_dock_widget::has_focus (void) const
-{
-  QWidget *w = widget ();
+  terminal_dock_widget::~terminal_dock_widget (void)
+  {
+    delete terminal;
+  }
 
-  return w->hasFocus ();
-}
+  bool terminal_dock_widget::has_focus (void) const
+  {
+    QWidget *w = widget ();
 
-void
-terminal_dock_widget::focus (void)
-{
-  octave_dock_widget::focus ();
+    return w->hasFocus ();
+  }
 
-  QWidget *w = widget ();
+  void terminal_dock_widget::focus (void)
+  {
+    octave_dock_widget::focus ();
+
+    QWidget *w = widget ();
 
-  w->setFocus ();
-  w->activateWindow ();
-  w->raise ();
+    w->setFocus ();
+    w->activateWindow ();
+    w->raise ();
+  }
+
+  void terminal_dock_widget::terminal_interrupt (void)
+  {
+    emit interrupt_signal ();
+  }
 }
-
-void
-terminal_dock_widget::terminal_interrupt (void)
-{
-  emit interrupt_signal ();
-}
--- a/libgui/src/terminal-dock-widget.h	Sat Feb 10 23:32:04 2018 -0500
+++ b/libgui/src/terminal-dock-widget.h	Sun Feb 11 09:20:36 2018 -0500
@@ -29,31 +29,34 @@
 #include "QTerminal.h"
 #include "octave-dock-widget.h"
 
-class terminal_dock_widget : public octave_dock_widget
+namespace octave
 {
-  Q_OBJECT
-
-public:
+  class terminal_dock_widget : public octave_dock_widget
+  {
+    Q_OBJECT
 
-  terminal_dock_widget (QWidget *parent = nullptr);
+  public:
+
+    terminal_dock_widget (QWidget *parent = nullptr);
 
-  ~terminal_dock_widget (void);
+    ~terminal_dock_widget (void);
 
-  bool has_focus (void) const;
+    bool has_focus (void) const;
 
-  void focus (void);
+    void focus (void);
+
+  signals:
 
-signals:
+    void interrupt_signal (void);
 
-  void interrupt_signal (void);
+  protected slots:
 
-protected slots:
+    void terminal_interrupt (void);
 
-  void terminal_interrupt (void);
+  private:
 
-private:
-
-  QTerminal *terminal;
-};
+    QTerminal *terminal;
+  };
+}
 
 #endif