annotate libgui/src/files-dock-widget.cc @ 16499:facf00ce97d3

gui: configurable synchronization between file browser and octave directory * default-qt-settings: all settings of the file browser are now located in its section, new setting sync_octave_directory * files-dock-widget.cc(constructor): make QToolBar and QAction variables local, add two buttons for syncing from octave to file browser and vice versa, change status-tips into tool-tips * files-dock-widget.cc(set_current_directory): do not emit signal displayed_directory_changed (would change octave dir) * files-dock-widget.cc(do_sync_octave_directory): new function for manually setting the octave dir to the one in the file browser * files-dock-widget.cc(do_sync_browser_directory): new function for manually setting the file browser to the octave directory * files-dock-widget.cc(update_octave_directory): new function called from the main-window when the octave directory has changed * files-doc-widget.cc(display_directory): new second parameter (bool, default is true) determining whether the signal with the new displayed directory should be emitted if synchronizing is enabled * files-dock-widget.cc(notice-settings): read new setting, enalbe or disable the sync buttons and set file browser to octave directory depending on setting * files-dock-widget.h: removed QToolBar and QAction variibles, new varaibles for storing the actual octave directory and whether syncing is desired or not, new functions (do_sync_octave_directory, do_sync_browser_directory, update_octave_directory), function display_directory with second parameter (bool, default true) * libgui/src/icons/ok.png,libgui/src/icons/reload.png: new icons for the toolbar * main-window.cc(change_directory): call new function update_octave_directory instead of display_directory * main-window.cc(construct-window-menu): rename "Current Directory" into "File Browser" * libgui/src/module.mk: new files icons/ok.png and icons/reload.png * settings-dialog.cc(constructor,write_changed_settings): all files-dock-widgets settings in a section, new setting sync_octave_directory * settings-dialog.ui: new setting sync_octave_directory
author Torsten <ttl@justmail.de>
date Thu, 11 Apr 2013 19:01:55 +0200
parents 605d7f0ee0d8
children c1ff738d606d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15204
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
1 /*
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
2
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
3 Copyright (C) 2011-2012 Jacob Dawid
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
4
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
5 This file is part of Octave.
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
6
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
8 under the terms of the GNU General Public License as published by the
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
9 Free Software Foundation; either version 3 of the License, or (at your
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
10 option) any later version.
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
11
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
15 for more details.
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
16
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
17 You should have received a copy of the GNU General Public License
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
18 along with Octave; see the file COPYING. If not, see
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
19 <http://www.gnu.org/licenses/>.
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
20
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
21 */
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
22
15286
ae9079bbc627 Add '#include <config.h>' to C++ files in libgui/src
Rik <rik@octave.org>
parents: 15204
diff changeset
23 #ifdef HAVE_CONFIG_H
ae9079bbc627 Add '#include <config.h>' to C++ files in libgui/src
Rik <rik@octave.org>
parents: 15204
diff changeset
24 #include <config.h>
ae9079bbc627 Add '#include <config.h>' to C++ files in libgui/src
Rik <rik@octave.org>
parents: 15204
diff changeset
25 #endif
ae9079bbc627 Add '#include <config.h>' to C++ files in libgui/src
Rik <rik@octave.org>
parents: 15204
diff changeset
26
14707
674740c44c09 Changed various files to matche file naming conventions.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14703
diff changeset
27 #include "resource-manager.h"
16460
4d4e7c6f839d use consistent names for dock-widget files
John W. Eaton <jwe@octave.org>
parents: 16455
diff changeset
28 #include "files-dock-widget.h"
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
29
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
30 #include <QApplication>
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
31 #include <QFileInfo>
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
32 #include <QCompleter>
13531
bb3676025b36 User can set a custom file editor instead of the built-in one.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13522
diff changeset
33 #include <QSettings>
bb3676025b36 User can set a custom file editor instead of the built-in one.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13522
diff changeset
34 #include <QProcess>
13539
a4b5cad8f7c6 Added command line parser class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13537
diff changeset
35 #include <QDebug>
15461
1e64aff609c3 save/restore column state and sorting (column and order) in files-widget
Torsten <ttl@justmail.de>
parents: 15368
diff changeset
36 #include <QHeaderView>
16498
605d7f0ee0d8 Added Filesdockwidget recently viewed directory pulldownlist
John Donoghue <john.donoghue@ieee.org>
parents: 16487
diff changeset
37 #include <QLineEdit>
605d7f0ee0d8 Added Filesdockwidget recently viewed directory pulldownlist
John Donoghue <john.donoghue@ieee.org>
parents: 16487
diff changeset
38 #include <QSizePolicy>
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
39
15368
36ececf69385 avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents: 15367
diff changeset
40 files_dock_widget::files_dock_widget (QWidget *p)
16057
c3057d80cf91 Created common octave_dock_widget class
Richard Crozier <richard.crozier@yahoo.co.uk>
parents: 15552
diff changeset
41 : octave_dock_widget (p)
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
42 {
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
43 setObjectName ("FilesDockWidget");
15552
bbbb89cc338f make a floating widget behave like a normal window (bug #37190)
Torsten <ttl@justmail.de>
parents: 15461
diff changeset
44 setWindowIcon (QIcon(":/actions/icons/logo.png"));
16437
919796a440c6 use signal for changing directory
John W. Eaton <jwe@octave.org>
parents: 16413
diff changeset
45 setWindowTitle (tr ("File Browser"));
16499
facf00ce97d3 gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents: 16498
diff changeset
46 setToolTip (tr ("Browse your files."));
16450
3207f1d62e74 improve encapsulation of file browser window object
John W. Eaton <jwe@octave.org>
parents: 16437
diff changeset
47
3207f1d62e74 improve encapsulation of file browser window object
John W. Eaton <jwe@octave.org>
parents: 16437
diff changeset
48 QWidget *container = new QWidget (this);
3207f1d62e74 improve encapsulation of file browser window object
John W. Eaton <jwe@octave.org>
parents: 16437
diff changeset
49
3207f1d62e74 improve encapsulation of file browser window object
John W. Eaton <jwe@octave.org>
parents: 16437
diff changeset
50 setWidget (container);
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
51
16455
38ed6bdd1f7f move signal/slot connections from main window to sub window where possible
John W. Eaton <jwe@octave.org>
parents: 16450
diff changeset
52 connect (this, SIGNAL (open_file (const QString&)),
38ed6bdd1f7f move signal/slot connections from main window to sub window where possible
John W. Eaton <jwe@octave.org>
parents: 16450
diff changeset
53 parent (), SLOT (open_file (const QString&)));
38ed6bdd1f7f move signal/slot connections from main window to sub window where possible
John W. Eaton <jwe@octave.org>
parents: 16450
diff changeset
54
38ed6bdd1f7f move signal/slot connections from main window to sub window where possible
John W. Eaton <jwe@octave.org>
parents: 16450
diff changeset
55 connect (this, SIGNAL (displayed_directory_changed (const QString&)),
38ed6bdd1f7f move signal/slot connections from main window to sub window where possible
John W. Eaton <jwe@octave.org>
parents: 16450
diff changeset
56 parent (), SLOT (set_current_working_directory (const QString&)));
38ed6bdd1f7f move signal/slot connections from main window to sub window where possible
John W. Eaton <jwe@octave.org>
parents: 16450
diff changeset
57
16487
6a18d8b0f982 gui: fix notification of files-dock-widget when settings may have changed
Torsten <ttl@justmail.de>
parents: 16461
diff changeset
58 connect (parent (), SIGNAL (settings_changed (const QSettings *)),
6a18d8b0f982 gui: fix notification of files-dock-widget when settings may have changed
Torsten <ttl@justmail.de>
parents: 16461
diff changeset
59 this, SLOT (notice_settings (const QSettings *)));
6a18d8b0f982 gui: fix notification of files-dock-widget when settings may have changed
Torsten <ttl@justmail.de>
parents: 16461
diff changeset
60
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
61 // Create a toolbar
16499
facf00ce97d3 gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents: 16498
diff changeset
62 QToolBar *navigation_tool_bar = new QToolBar ("", container);
facf00ce97d3 gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents: 16498
diff changeset
63 navigation_tool_bar->setAllowedAreas (Qt::TopToolBarArea);
facf00ce97d3 gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents: 16498
diff changeset
64 navigation_tool_bar->setMovable (false);
facf00ce97d3 gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents: 16498
diff changeset
65 navigation_tool_bar->setIconSize (QSize (20, 20));
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
66
16499
facf00ce97d3 gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents: 16498
diff changeset
67 _current_directory = new QComboBox (navigation_tool_bar);
facf00ce97d3 gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents: 16498
diff changeset
68 _current_directory->setToolTip (tr ("Enter the path or filename"));
16498
605d7f0ee0d8 Added Filesdockwidget recently viewed directory pulldownlist
John Donoghue <john.donoghue@ieee.org>
parents: 16487
diff changeset
69 _current_directory->setEditable(true);
605d7f0ee0d8 Added Filesdockwidget recently viewed directory pulldownlist
John Donoghue <john.donoghue@ieee.org>
parents: 16487
diff changeset
70 _current_directory->setMaxCount(MaxMRUDirs);
605d7f0ee0d8 Added Filesdockwidget recently viewed directory pulldownlist
John Donoghue <john.donoghue@ieee.org>
parents: 16487
diff changeset
71 _current_directory->setInsertPolicy(QComboBox::NoInsert);
16499
facf00ce97d3 gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents: 16498
diff changeset
72 _current_directory->setSizeAdjustPolicy (QComboBox::AdjustToMinimumContentsLengthWithIcon);
16498
605d7f0ee0d8 Added Filesdockwidget recently viewed directory pulldownlist
John Donoghue <john.donoghue@ieee.org>
parents: 16487
diff changeset
73 QSizePolicy sizePol(QSizePolicy::Expanding, QSizePolicy::Preferred);
605d7f0ee0d8 Added Filesdockwidget recently viewed directory pulldownlist
John Donoghue <john.donoghue@ieee.org>
parents: 16487
diff changeset
74 _current_directory->setSizePolicy(sizePol);
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
75
16499
facf00ce97d3 gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents: 16498
diff changeset
76 QAction *directory_up_action = new QAction (QIcon(":/actions/icons/up.png"),
facf00ce97d3 gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents: 16498
diff changeset
77 "", navigation_tool_bar);
facf00ce97d3 gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents: 16498
diff changeset
78 directory_up_action->setToolTip (tr ("Move up one directory"));
facf00ce97d3 gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents: 16498
diff changeset
79
facf00ce97d3 gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents: 16498
diff changeset
80 _sync_browser_directory_action = new QAction (QIcon(":/actions/icons/reload.png"),
facf00ce97d3 gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents: 16498
diff changeset
81 "", navigation_tool_bar);
facf00ce97d3 gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents: 16498
diff changeset
82 _sync_browser_directory_action->setToolTip (tr ("Goto current octave directory"));
facf00ce97d3 gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents: 16498
diff changeset
83 _sync_browser_directory_action->setEnabled ("false");
facf00ce97d3 gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents: 16498
diff changeset
84
facf00ce97d3 gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents: 16498
diff changeset
85 _sync_octave_directory_action = new QAction (QIcon(":/actions/icons/ok.png"),
facf00ce97d3 gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents: 16498
diff changeset
86 "", navigation_tool_bar);
facf00ce97d3 gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents: 16498
diff changeset
87 _sync_octave_directory_action->setToolTip (tr ("Set octave directroy to current browser directory"));
facf00ce97d3 gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents: 16498
diff changeset
88 _sync_octave_directory_action->setEnabled ("false");
facf00ce97d3 gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents: 16498
diff changeset
89
facf00ce97d3 gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents: 16498
diff changeset
90 navigation_tool_bar->addWidget (_current_directory);
facf00ce97d3 gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents: 16498
diff changeset
91 navigation_tool_bar->addAction (directory_up_action);
facf00ce97d3 gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents: 16498
diff changeset
92 navigation_tool_bar->addAction (_sync_browser_directory_action);
facf00ce97d3 gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents: 16498
diff changeset
93 navigation_tool_bar->addAction (_sync_octave_directory_action);
facf00ce97d3 gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents: 16498
diff changeset
94
facf00ce97d3 gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents: 16498
diff changeset
95 connect (directory_up_action, SIGNAL (triggered ()), this,
16437
919796a440c6 use signal for changing directory
John W. Eaton <jwe@octave.org>
parents: 16413
diff changeset
96 SLOT (change_directory_up ()));
16499
facf00ce97d3 gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents: 16498
diff changeset
97 connect (_sync_octave_directory_action, SIGNAL (triggered ()), this,
facf00ce97d3 gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents: 16498
diff changeset
98 SLOT (do_sync_octave_directory ()));
facf00ce97d3 gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents: 16498
diff changeset
99 connect (_sync_browser_directory_action, SIGNAL (triggered ()), this,
facf00ce97d3 gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents: 16498
diff changeset
100 SLOT (do_sync_browser_directory ()));
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
101
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
102 // TODO: Add other buttons for creating directories
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
103
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
104 // Create the QFileSystemModel starting in the home directory
14803
625be3eb27c5 Current directories now synchronize on top, in the file browser and the cwd in octave.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14728
diff changeset
105 QString homePath = QDir::homePath ();
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
106
14712
5cb54cca8a06 Completion of code reformatting.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14709
diff changeset
107 _file_system_model = new QFileSystemModel (this);
5cb54cca8a06 Completion of code reformatting.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14709
diff changeset
108 _file_system_model->setFilter (QDir::NoDotAndDotDot | QDir::AllEntries);
14803
625be3eb27c5 Current directories now synchronize on top, in the file browser and the cwd in octave.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14728
diff changeset
109 QModelIndex rootPathIndex = _file_system_model->setRootPath (homePath);
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
110
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
111 // Attach the model to the QTreeView and set the root index
16450
3207f1d62e74 improve encapsulation of file browser window object
John W. Eaton <jwe@octave.org>
parents: 16437
diff changeset
112 _file_tree_view = new QTreeView (container);
14712
5cb54cca8a06 Completion of code reformatting.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14709
diff changeset
113 _file_tree_view->setModel (_file_system_model);
5cb54cca8a06 Completion of code reformatting.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14709
diff changeset
114 _file_tree_view->setRootIndex (rootPathIndex);
5cb54cca8a06 Completion of code reformatting.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14709
diff changeset
115 _file_tree_view->setSortingEnabled (true);
5cb54cca8a06 Completion of code reformatting.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14709
diff changeset
116 _file_tree_view->setAlternatingRowColors (true);
5cb54cca8a06 Completion of code reformatting.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14709
diff changeset
117 _file_tree_view->setAnimated (true);
16499
facf00ce97d3 gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents: 16498
diff changeset
118 _file_tree_view->setToolTip (tr ("Doubleclick a file to open it"));
13549
807e5e9b7591 Added lots of status tips.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13539
diff changeset
119
15461
1e64aff609c3 save/restore column state and sorting (column and order) in files-widget
Torsten <ttl@justmail.de>
parents: 15368
diff changeset
120 // get sort column and order as well as cloumn state (order and width)
1e64aff609c3 save/restore column state and sorting (column and order) in files-widget
Torsten <ttl@justmail.de>
parents: 15368
diff changeset
121 QSettings *settings = resource_manager::get_settings ();
1e64aff609c3 save/restore column state and sorting (column and order) in files-widget
Torsten <ttl@justmail.de>
parents: 15368
diff changeset
122 // FIXME -- what should happen if settings is 0?
1e64aff609c3 save/restore column state and sorting (column and order) in files-widget
Torsten <ttl@justmail.de>
parents: 15368
diff changeset
123 _file_tree_view->sortByColumn (
1e64aff609c3 save/restore column state and sorting (column and order) in files-widget
Torsten <ttl@justmail.de>
parents: 15368
diff changeset
124 settings->value ("filesdockwidget/sort_files_by_column",0).toInt (),
1e64aff609c3 save/restore column state and sorting (column and order) in files-widget
Torsten <ttl@justmail.de>
parents: 15368
diff changeset
125 static_cast<Qt::SortOrder>(settings->value ("filesdockwidget/sort_files_by_order",Qt::AscendingOrder).toUInt ())
1e64aff609c3 save/restore column state and sorting (column and order) in files-widget
Torsten <ttl@justmail.de>
parents: 15368
diff changeset
126 );
1e64aff609c3 save/restore column state and sorting (column and order) in files-widget
Torsten <ttl@justmail.de>
parents: 15368
diff changeset
127 _file_tree_view->header ()->restoreState (settings->value ("filesdockwidget/column_state").toByteArray ());
1e64aff609c3 save/restore column state and sorting (column and order) in files-widget
Torsten <ttl@justmail.de>
parents: 15368
diff changeset
128
16498
605d7f0ee0d8 Added Filesdockwidget recently viewed directory pulldownlist
John Donoghue <john.donoghue@ieee.org>
parents: 16487
diff changeset
129 QStringList mru_dirs = settings->value ("filesdockwidget/mru_dir_list").toStringList ();
605d7f0ee0d8 Added Filesdockwidget recently viewed directory pulldownlist
John Donoghue <john.donoghue@ieee.org>
parents: 16487
diff changeset
130 _current_directory->addItems(mru_dirs);
605d7f0ee0d8 Added Filesdockwidget recently viewed directory pulldownlist
John Donoghue <john.donoghue@ieee.org>
parents: 16487
diff changeset
131
605d7f0ee0d8 Added Filesdockwidget recently viewed directory pulldownlist
John Donoghue <john.donoghue@ieee.org>
parents: 16487
diff changeset
132 _current_directory->setEditText(_file_system_model->fileInfo (rootPathIndex).
15367
501a9cc2c68f maint: whitespace cleanup in GUI code
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15300
diff changeset
133 absoluteFilePath ());
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
134
16450
3207f1d62e74 improve encapsulation of file browser window object
John W. Eaton <jwe@octave.org>
parents: 16437
diff changeset
135 connect (_file_tree_view, SIGNAL (doubleClicked (const QModelIndex &)),
3207f1d62e74 improve encapsulation of file browser window object
John W. Eaton <jwe@octave.org>
parents: 16437
diff changeset
136 this, SLOT (item_double_clicked (const QModelIndex &)));
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
137
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
138 // Layout the widgets vertically with the toolbar on top
15368
36ececf69385 avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents: 15367
diff changeset
139 QVBoxLayout *vbox_layout = new QVBoxLayout ();
36ececf69385 avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents: 15367
diff changeset
140 vbox_layout->setSpacing (0);
16499
facf00ce97d3 gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents: 16498
diff changeset
141 vbox_layout->addWidget (navigation_tool_bar);
15368
36ececf69385 avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents: 15367
diff changeset
142 vbox_layout->addWidget (_file_tree_view);
36ececf69385 avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents: 15367
diff changeset
143 vbox_layout->setMargin (1);
16450
3207f1d62e74 improve encapsulation of file browser window object
John W. Eaton <jwe@octave.org>
parents: 16437
diff changeset
144
3207f1d62e74 improve encapsulation of file browser window object
John W. Eaton <jwe@octave.org>
parents: 16437
diff changeset
145 container->setLayout (vbox_layout);
3207f1d62e74 improve encapsulation of file browser window object
John W. Eaton <jwe@octave.org>
parents: 16437
diff changeset
146
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
147 // TODO: Add right-click contextual menus for copying, pasting, deleting files (and others)
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
148
16498
605d7f0ee0d8 Added Filesdockwidget recently viewed directory pulldownlist
John Donoghue <john.donoghue@ieee.org>
parents: 16487
diff changeset
149 connect (_current_directory->lineEdit(), SIGNAL (returnPressed ()),
605d7f0ee0d8 Added Filesdockwidget recently viewed directory pulldownlist
John Donoghue <john.donoghue@ieee.org>
parents: 16487
diff changeset
150 this, SLOT (accept_directory_line_edit ()));
605d7f0ee0d8 Added Filesdockwidget recently viewed directory pulldownlist
John Donoghue <john.donoghue@ieee.org>
parents: 16487
diff changeset
151
605d7f0ee0d8 Added Filesdockwidget recently viewed directory pulldownlist
John Donoghue <john.donoghue@ieee.org>
parents: 16487
diff changeset
152 connect (_current_directory, SIGNAL (activated (const QString &)),
605d7f0ee0d8 Added Filesdockwidget recently viewed directory pulldownlist
John Donoghue <john.donoghue@ieee.org>
parents: 16487
diff changeset
153 this, SLOT (set_current_directory (const QString &)));
14803
625be3eb27c5 Current directories now synchronize on top, in the file browser and the cwd in octave.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14728
diff changeset
154
16450
3207f1d62e74 improve encapsulation of file browser window object
John W. Eaton <jwe@octave.org>
parents: 16437
diff changeset
155 QCompleter *completer = new QCompleter (_file_system_model, this);
14712
5cb54cca8a06 Completion of code reformatting.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14709
diff changeset
156 _current_directory->setCompleter (completer);
13577
e440b3f32f02 Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13549
diff changeset
157
14812
9d9eb9bac65e Improved menu structure of file, edit and window menu. Removed ambiguous shortcuts, improved focus handling for operating the GUI with the keyboard. Added new shortcuts to focus subwindows directly.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14803
diff changeset
158 setFocusProxy (_current_directory);
16499
facf00ce97d3 gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents: 16498
diff changeset
159
facf00ce97d3 gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents: 16498
diff changeset
160 _sync_octave_dir = true; // default, overwirtten with notice_settings ()
facf00ce97d3 gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents: 16498
diff changeset
161 _octave_dir = "";
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
162 }
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
163
15461
1e64aff609c3 save/restore column state and sorting (column and order) in files-widget
Torsten <ttl@justmail.de>
parents: 15368
diff changeset
164 files_dock_widget::~files_dock_widget ()
1e64aff609c3 save/restore column state and sorting (column and order) in files-widget
Torsten <ttl@justmail.de>
parents: 15368
diff changeset
165 {
1e64aff609c3 save/restore column state and sorting (column and order) in files-widget
Torsten <ttl@justmail.de>
parents: 15368
diff changeset
166 QSettings *settings = resource_manager::get_settings ();
1e64aff609c3 save/restore column state and sorting (column and order) in files-widget
Torsten <ttl@justmail.de>
parents: 15368
diff changeset
167 int sort_column = _file_tree_view->header ()->sortIndicatorSection ();
1e64aff609c3 save/restore column state and sorting (column and order) in files-widget
Torsten <ttl@justmail.de>
parents: 15368
diff changeset
168 Qt::SortOrder sort_order = _file_tree_view->header ()->sortIndicatorOrder ();
1e64aff609c3 save/restore column state and sorting (column and order) in files-widget
Torsten <ttl@justmail.de>
parents: 15368
diff changeset
169 settings->setValue ("filesdockwidget/sort_files_by_column", sort_column);
1e64aff609c3 save/restore column state and sorting (column and order) in files-widget
Torsten <ttl@justmail.de>
parents: 15368
diff changeset
170 settings->setValue ("filesdockwidget/sort_files_by_order", sort_order);
16175
6f83158c714c gui: make sure settings are really written into the settings file
Torsten <ttl@justmail.de>
parents: 16057
diff changeset
171 settings->setValue ("filesdockwidget/column_state", _file_tree_view->header ()->saveState ());
16498
605d7f0ee0d8 Added Filesdockwidget recently viewed directory pulldownlist
John Donoghue <john.donoghue@ieee.org>
parents: 16487
diff changeset
172
605d7f0ee0d8 Added Filesdockwidget recently viewed directory pulldownlist
John Donoghue <john.donoghue@ieee.org>
parents: 16487
diff changeset
173 QStringList dirs;
605d7f0ee0d8 Added Filesdockwidget recently viewed directory pulldownlist
John Donoghue <john.donoghue@ieee.org>
parents: 16487
diff changeset
174 for(int i=0; i< _current_directory->count(); i++)
605d7f0ee0d8 Added Filesdockwidget recently viewed directory pulldownlist
John Donoghue <john.donoghue@ieee.org>
parents: 16487
diff changeset
175 {
605d7f0ee0d8 Added Filesdockwidget recently viewed directory pulldownlist
John Donoghue <john.donoghue@ieee.org>
parents: 16487
diff changeset
176 dirs.append(_current_directory->itemText(i));
605d7f0ee0d8 Added Filesdockwidget recently viewed directory pulldownlist
John Donoghue <john.donoghue@ieee.org>
parents: 16487
diff changeset
177 }
605d7f0ee0d8 Added Filesdockwidget recently viewed directory pulldownlist
John Donoghue <john.donoghue@ieee.org>
parents: 16487
diff changeset
178 settings->setValue ("filesdockwidget/mru_dir_list", dirs);
605d7f0ee0d8 Added Filesdockwidget recently viewed directory pulldownlist
John Donoghue <john.donoghue@ieee.org>
parents: 16487
diff changeset
179
16175
6f83158c714c gui: make sure settings are really written into the settings file
Torsten <ttl@justmail.de>
parents: 16057
diff changeset
180 settings->sync ();
15461
1e64aff609c3 save/restore column state and sorting (column and order) in files-widget
Torsten <ttl@justmail.de>
parents: 15368
diff changeset
181 }
1e64aff609c3 save/restore column state and sorting (column and order) in files-widget
Torsten <ttl@justmail.de>
parents: 15368
diff changeset
182
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
183 void
16437
919796a440c6 use signal for changing directory
John W. Eaton <jwe@octave.org>
parents: 16413
diff changeset
184 files_dock_widget::item_double_clicked (const QModelIndex& index)
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
185 {
13531
bb3676025b36 User can set a custom file editor instead of the built-in one.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13522
diff changeset
186 // Retrieve the file info associated with the model index.
14712
5cb54cca8a06 Completion of code reformatting.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14709
diff changeset
187 QFileInfo fileInfo = _file_system_model->fileInfo (index);
16437
919796a440c6 use signal for changing directory
John W. Eaton <jwe@octave.org>
parents: 16413
diff changeset
188 set_current_directory (fileInfo.absoluteFilePath ());
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
189 }
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
190
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
191 void
16437
919796a440c6 use signal for changing directory
John W. Eaton <jwe@octave.org>
parents: 16413
diff changeset
192 files_dock_widget::set_current_directory (const QString& dir)
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
193 {
16437
919796a440c6 use signal for changing directory
John W. Eaton <jwe@octave.org>
parents: 16413
diff changeset
194 display_directory (dir);
14803
625be3eb27c5 Current directories now synchronize on top, in the file browser and the cwd in octave.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14728
diff changeset
195 }
625be3eb27c5 Current directories now synchronize on top, in the file browser and the cwd in octave.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14728
diff changeset
196
625be3eb27c5 Current directories now synchronize on top, in the file browser and the cwd in octave.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14728
diff changeset
197 void
16437
919796a440c6 use signal for changing directory
John W. Eaton <jwe@octave.org>
parents: 16413
diff changeset
198 files_dock_widget::accept_directory_line_edit (void)
14803
625be3eb27c5 Current directories now synchronize on top, in the file browser and the cwd in octave.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14728
diff changeset
199 {
16498
605d7f0ee0d8 Added Filesdockwidget recently viewed directory pulldownlist
John Donoghue <john.donoghue@ieee.org>
parents: 16487
diff changeset
200 display_directory (_current_directory->currentText ());
14803
625be3eb27c5 Current directories now synchronize on top, in the file browser and the cwd in octave.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14728
diff changeset
201 }
625be3eb27c5 Current directories now synchronize on top, in the file browser and the cwd in octave.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14728
diff changeset
202
625be3eb27c5 Current directories now synchronize on top, in the file browser and the cwd in octave.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14728
diff changeset
203 void
16437
919796a440c6 use signal for changing directory
John W. Eaton <jwe@octave.org>
parents: 16413
diff changeset
204 files_dock_widget::change_directory_up (void)
14803
625be3eb27c5 Current directories now synchronize on top, in the file browser and the cwd in octave.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14728
diff changeset
205 {
625be3eb27c5 Current directories now synchronize on top, in the file browser and the cwd in octave.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14728
diff changeset
206 QDir dir = QDir (_file_system_model->filePath (_file_tree_view->rootIndex ()));
625be3eb27c5 Current directories now synchronize on top, in the file browser and the cwd in octave.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14728
diff changeset
207 dir.cdUp ();
625be3eb27c5 Current directories now synchronize on top, in the file browser and the cwd in octave.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14728
diff changeset
208 display_directory (dir.absolutePath ());
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
209 }
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
210
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
211 void
16499
facf00ce97d3 gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents: 16498
diff changeset
212 files_dock_widget::do_sync_octave_directory (void)
facf00ce97d3 gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents: 16498
diff changeset
213 {
facf00ce97d3 gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents: 16498
diff changeset
214 QDir dir = QDir (_file_system_model->filePath (_file_tree_view->rootIndex ()));
facf00ce97d3 gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents: 16498
diff changeset
215 emit displayed_directory_changed (dir.absolutePath ());
facf00ce97d3 gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents: 16498
diff changeset
216 }
facf00ce97d3 gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents: 16498
diff changeset
217
facf00ce97d3 gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents: 16498
diff changeset
218 void
facf00ce97d3 gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents: 16498
diff changeset
219 files_dock_widget::do_sync_browser_directory (void)
facf00ce97d3 gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents: 16498
diff changeset
220 {
facf00ce97d3 gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents: 16498
diff changeset
221 display_directory (_octave_dir,false); // false: no sync of octave dir
facf00ce97d3 gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents: 16498
diff changeset
222 }
facf00ce97d3 gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents: 16498
diff changeset
223
facf00ce97d3 gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents: 16498
diff changeset
224 void
facf00ce97d3 gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents: 16498
diff changeset
225 files_dock_widget::update_octave_directory (const QString& dir)
facf00ce97d3 gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents: 16498
diff changeset
226 {
facf00ce97d3 gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents: 16498
diff changeset
227 _octave_dir = dir;
facf00ce97d3 gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents: 16498
diff changeset
228 if (_sync_octave_dir)
facf00ce97d3 gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents: 16498
diff changeset
229 display_directory (_octave_dir,false); // false: no sync of octave dir
facf00ce97d3 gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents: 16498
diff changeset
230 }
facf00ce97d3 gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents: 16498
diff changeset
231
facf00ce97d3 gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents: 16498
diff changeset
232 void
facf00ce97d3 gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents: 16498
diff changeset
233 files_dock_widget::display_directory (const QString& dir, bool set_octave_dir)
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
234 {
16437
919796a440c6 use signal for changing directory
John W. Eaton <jwe@octave.org>
parents: 16413
diff changeset
235 QFileInfo fileInfo (dir);
14803
625be3eb27c5 Current directories now synchronize on top, in the file browser and the cwd in octave.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14728
diff changeset
236 if (fileInfo.exists ())
625be3eb27c5 Current directories now synchronize on top, in the file browser and the cwd in octave.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14728
diff changeset
237 {
625be3eb27c5 Current directories now synchronize on top, in the file browser and the cwd in octave.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14728
diff changeset
238 if (fileInfo.isDir ())
625be3eb27c5 Current directories now synchronize on top, in the file browser and the cwd in octave.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14728
diff changeset
239 {
625be3eb27c5 Current directories now synchronize on top, in the file browser and the cwd in octave.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14728
diff changeset
240 _file_tree_view->setRootIndex (_file_system_model->
15367
501a9cc2c68f maint: whitespace cleanup in GUI code
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15300
diff changeset
241 index (fileInfo.absoluteFilePath ()));
14803
625be3eb27c5 Current directories now synchronize on top, in the file browser and the cwd in octave.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14728
diff changeset
242 _file_system_model->setRootPath (fileInfo.absoluteFilePath ());
16437
919796a440c6 use signal for changing directory
John W. Eaton <jwe@octave.org>
parents: 16413
diff changeset
243 _file_system_model->sort (0, Qt::AscendingOrder);
16499
facf00ce97d3 gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents: 16498
diff changeset
244 if (_sync_octave_dir && set_octave_dir)
facf00ce97d3 gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents: 16498
diff changeset
245 emit displayed_directory_changed (fileInfo.absoluteFilePath ());
16498
605d7f0ee0d8 Added Filesdockwidget recently viewed directory pulldownlist
John Donoghue <john.donoghue@ieee.org>
parents: 16487
diff changeset
246
605d7f0ee0d8 Added Filesdockwidget recently viewed directory pulldownlist
John Donoghue <john.donoghue@ieee.org>
parents: 16487
diff changeset
247 // see if its in the list, and if it is, remove it and then, put at top of the list
605d7f0ee0d8 Added Filesdockwidget recently viewed directory pulldownlist
John Donoghue <john.donoghue@ieee.org>
parents: 16487
diff changeset
248 int index = _current_directory->findText(fileInfo.absoluteFilePath ());
605d7f0ee0d8 Added Filesdockwidget recently viewed directory pulldownlist
John Donoghue <john.donoghue@ieee.org>
parents: 16487
diff changeset
249 if(index != -1)
605d7f0ee0d8 Added Filesdockwidget recently viewed directory pulldownlist
John Donoghue <john.donoghue@ieee.org>
parents: 16487
diff changeset
250 {
605d7f0ee0d8 Added Filesdockwidget recently viewed directory pulldownlist
John Donoghue <john.donoghue@ieee.org>
parents: 16487
diff changeset
251 _current_directory->removeItem(index);
605d7f0ee0d8 Added Filesdockwidget recently viewed directory pulldownlist
John Donoghue <john.donoghue@ieee.org>
parents: 16487
diff changeset
252 }
605d7f0ee0d8 Added Filesdockwidget recently viewed directory pulldownlist
John Donoghue <john.donoghue@ieee.org>
parents: 16487
diff changeset
253 _current_directory->insertItem(0, fileInfo.absoluteFilePath ());
605d7f0ee0d8 Added Filesdockwidget recently viewed directory pulldownlist
John Donoghue <john.donoghue@ieee.org>
parents: 16487
diff changeset
254 _current_directory->setCurrentIndex(0);
14803
625be3eb27c5 Current directories now synchronize on top, in the file browser and the cwd in octave.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14728
diff changeset
255 }
625be3eb27c5 Current directories now synchronize on top, in the file browser and the cwd in octave.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14728
diff changeset
256 else
625be3eb27c5 Current directories now synchronize on top, in the file browser and the cwd in octave.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14728
diff changeset
257 {
625be3eb27c5 Current directories now synchronize on top, in the file browser and the cwd in octave.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14728
diff changeset
258 if (QFile::exists (fileInfo.absoluteFilePath ()))
625be3eb27c5 Current directories now synchronize on top, in the file browser and the cwd in octave.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14728
diff changeset
259 emit open_file (fileInfo.absoluteFilePath ());
625be3eb27c5 Current directories now synchronize on top, in the file browser and the cwd in octave.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14728
diff changeset
260 }
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
261 }
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
262 }
13536
869c62c15e95 Few minor improvements, added advanced settings for file browser.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13535
diff changeset
263
869c62c15e95 Few minor improvements, added advanced settings for file browser.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13535
diff changeset
264 void
16413
28136851099a remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16410
diff changeset
265 files_dock_widget::notice_settings (const QSettings *settings)
13536
869c62c15e95 Few minor improvements, added advanced settings for file browser.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13535
diff changeset
266 {
16413
28136851099a remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16410
diff changeset
267 // Qsettings pointer is checked before emitting.
15164
bc801a44bb1f follow Octave pattern for resource_manager singleton
John W. Eaton <jwe@octave.org>
parents: 14812
diff changeset
268
16410
f62163bed4dc gui: always show file names in file dock widget
Torsten <ttl@justmail.de>
parents: 16379
diff changeset
269 // file names are always shown, other columns can be hidden by settings
f62163bed4dc gui: always show file names in file dock widget
Torsten <ttl@justmail.de>
parents: 16379
diff changeset
270 _file_tree_view->setColumnHidden (0, false);
16499
facf00ce97d3 gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents: 16498
diff changeset
271 _file_tree_view->setColumnHidden (1, !settings->value ("filesdockwidget/showFileSize",false).toBool ());
facf00ce97d3 gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents: 16498
diff changeset
272 _file_tree_view->setColumnHidden (2, !settings->value ("filesdockwidget/showFileType",false).toBool ());
facf00ce97d3 gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents: 16498
diff changeset
273 _file_tree_view->setColumnHidden (3, !settings->value ("filesdockwidget/showLastModified",false).toBool ());
facf00ce97d3 gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents: 16498
diff changeset
274 _file_tree_view->setAlternatingRowColors (settings->value ("filesdockwidget/useAlternatingRowColors",true).toBool ());
facf00ce97d3 gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents: 16498
diff changeset
275 if (settings->value ("filesdockwidget/showHiddenFiles",false).toBool ())
16379
4bb1b82076e5 gui: provide defaults for all values read from the settings file
Torsten <ttl@justmail.de>
parents: 16175
diff changeset
276 {
4bb1b82076e5 gui: provide defaults for all values read from the settings file
Torsten <ttl@justmail.de>
parents: 16175
diff changeset
277 // TODO: React on option for hidden files.
4bb1b82076e5 gui: provide defaults for all values read from the settings file
Torsten <ttl@justmail.de>
parents: 16175
diff changeset
278 }
16499
facf00ce97d3 gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents: 16498
diff changeset
279 // enalbe the buttons to sync octave/browser dir only if this is not done by default
facf00ce97d3 gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents: 16498
diff changeset
280 _sync_octave_dir = settings->value ("filesdockwidget/sync_octave_directory",false).toBool ();
facf00ce97d3 gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents: 16498
diff changeset
281 _sync_octave_directory_action->setEnabled (!_sync_octave_dir);
facf00ce97d3 gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents: 16498
diff changeset
282 _sync_browser_directory_action->setEnabled (!_sync_octave_dir);
facf00ce97d3 gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents: 16498
diff changeset
283
facf00ce97d3 gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents: 16498
diff changeset
284 if (_sync_octave_dir)
facf00ce97d3 gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents: 16498
diff changeset
285 display_directory (_octave_dir); // sync browser to octave dir
facf00ce97d3 gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents: 16498
diff changeset
286
13536
869c62c15e95 Few minor improvements, added advanced settings for file browser.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13535
diff changeset
287 }