Mercurial > hg > octave-lyh
changeset 15461:1e64aff609c3
save/restore column state and sorting (column and order) in files-widget
* files-dockwidget.cc: saving/restoring cloumn state and sorting in destructor/contructor
* files-dockwidget.h: added destructor
author | Torsten <ttl@justmail.de> |
---|---|
date | Sun, 30 Sep 2012 15:13:33 +0200 |
parents | 7f36f7dc25b2 |
children | e8b117b405f9 |
files | libgui/src/files-dockwidget.cc libgui/src/files-dockwidget.h |
diffstat | 2 files changed, 21 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/src/files-dockwidget.cc +++ b/libgui/src/files-dockwidget.cc @@ -33,6 +33,7 @@ #include <QSettings> #include <QProcess> #include <QDebug> +#include <QHeaderView> files_dock_widget::files_dock_widget (QWidget *p) : QDockWidget (p) @@ -81,6 +82,15 @@ _file_tree_view->setColumnHidden (3, true); _file_tree_view->setStatusTip (tr ("Doubleclick a file to open it.")); + // get sort column and order as well as cloumn state (order and width) + QSettings *settings = resource_manager::get_settings (); + // FIXME -- what should happen if settings is 0? + _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 ()) + ); + _file_tree_view->header ()->restoreState (settings->value ("filesdockwidget/column_state").toByteArray ()); + _current_directory->setText(_file_system_model->fileInfo (rootPathIndex). absoluteFilePath ()); @@ -109,6 +119,16 @@ setFocusProxy (_current_directory); } +files_dock_widget::~files_dock_widget () +{ + QSettings *settings = resource_manager::get_settings (); + int sort_column = _file_tree_view->header ()->sortIndicatorSection (); + Qt::SortOrder sort_order = _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", _file_tree_view->header ()->saveState ()); +} + void files_dock_widget::item_double_clicked (const QModelIndex & index) {