# HG changeset patch
# User John Swensen <jpswensen@gmail.com>
# Date 1384802389 18000
#      Mon Nov 18 14:19:49 2013 -0500
# Node ID 926e004c99a70cb7629a66da7fd5b13fd402faaa
# Parent  3341d2f1e5db8ad4e14cf31960f2ec739c47d9ac
Added a context menu for changing which column are visible by right clicking on the header row of the file manager.

diff -r 3341d2f1e5db -r 926e004c99a7 libgui/src/files-dock-widget.cc
--- a/libgui/src/files-dock-widget.cc	Mon Nov 18 09:23:15 2013 +0100
+++ b/libgui/src/files-dock-widget.cc	Mon Nov 18 14:19:49 2013 -0500
@@ -195,6 +195,11 @@
            SIGNAL (customContextMenuRequested (const QPoint &)),
            this, SLOT (contextmenu_requested (const QPoint &)));
 
+  _file_tree_view->header()->setContextMenuPolicy (Qt::CustomContextMenu);
+  connect (_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);
@@ -350,6 +355,76 @@
   QDesktopServices::openUrl (QUrl::fromLocalFile (file));
 }
 
+void files_dock_widget::toggle_headercontextitem_filesize()
+{
+  QSettings *settings = resource_manager::get_settings ();
+  settings->setValue ("filesdockwidget/showFileSize", 
+                      !settings->value ("filesdockwidget/showFileSize",false).toBool ());
+  settings->sync();
+  this->notice_settings(settings);
+}
+
+void files_dock_widget::toggle_headercontextitem_filetype()
+{
+  QSettings *settings = resource_manager::get_settings ();
+  settings->setValue ("filesdockwidget/showFileType",
+                      !settings->value ("filesdockwidget/showFileType",false).toBool ());
+  settings->sync();
+  this->notice_settings(settings);
+}
+
+void files_dock_widget::toggle_headercontextitem_datemodified()
+{
+  QSettings *settings = resource_manager::get_settings ();
+  settings->setValue ("filesdockwidget/showLastModified",
+                      !settings->value ("filesdockwidget/showLastModified",false).toBool ());
+  settings->sync();
+  this->notice_settings(settings);
+}
+
+void files_dock_widget::toggle_headercontextitem_showhidden()
+{
+  QSettings *settings = resource_manager::get_settings ();
+  settings->setValue ("filesdockwidget/showHiddenFiles",
+                      !settings->value ("filesdockwidget/showHiddenFiles",false).toBool ());
+  settings->sync();
+  this->notice_settings(settings);
+}
+
+void
+files_dock_widget::headercontextmenu_requested (const QPoint& mpos)
+{
+  QMenu menu (this);
+
+  QSettings *settings = resource_manager::get_settings ();
+
+  QAction fileSizeAction(tr ("File size"), &menu);
+  fileSizeAction.setCheckable(true);
+  fileSizeAction.setChecked(settings->value ("filesdockwidget/showFileSize",false).toBool ());
+  connect (&fileSizeAction, SIGNAL(triggered()), this, SLOT (toggle_headercontextitem_filesize()));
+  menu.addAction (&fileSizeAction);
+
+  QAction fileTypeAction(tr ("File type"), &menu);
+  fileTypeAction.setCheckable(true);
+  fileTypeAction.setChecked(settings->value ("filesdockwidget/showFileType",false).toBool ());
+  connect (&fileTypeAction, SIGNAL(triggered()), this, SLOT (toggle_headercontextitem_filetype()));
+  menu.addAction (&fileTypeAction);
+
+  QAction dateModifiedAction(tr ("Date modified"), &menu);
+  dateModifiedAction.setCheckable(true);
+  dateModifiedAction.setChecked(settings->value ("filesdockwidget/showLastModified",false).toBool ());
+  connect (&dateModifiedAction, SIGNAL(triggered()), this, SLOT (toggle_headercontextitem_datemodified()));
+  menu.addAction (&dateModifiedAction);
+
+  QAction showHiddenAction(tr ("Show hidden"), &menu);
+  showHiddenAction.setCheckable(true);
+  showHiddenAction.setChecked(settings->value ("filesdockwidget/showHiddenFiles",false).toBool ());
+  connect (&showHiddenAction, SIGNAL(triggered()), this, SLOT (toggle_headercontextitem_showhidden()));
+  menu.addAction (&showHiddenAction);
+
+  menu.exec (_file_tree_view->mapToGlobal (mpos));
+}
+
 void
 files_dock_widget::contextmenu_requested (const QPoint& mpos)
 {
diff -r 3341d2f1e5db -r 926e004c99a7 libgui/src/files-dock-widget.h
--- a/libgui/src/files-dock-widget.h	Mon Nov 18 09:23:15 2013 +0100
+++ b/libgui/src/files-dock-widget.h	Mon Nov 18 14:19:49 2013 -0500
@@ -83,6 +83,13 @@
   /** context menu wanted */
   void contextmenu_requested (const QPoint& pos);
 
+  void toggle_headercontextitem_filesize ();
+  void toggle_headercontextitem_filetype ();
+  void toggle_headercontextitem_datemodified ();
+  void toggle_headercontextitem_showhidden ();
+
+  void headercontextmenu_requested (const QPoint& pos);
+
   /* context menu actions */
   void contextmenu_open (bool);
   void contextmenu_open_in_app (bool);
