Mercurial > hg > octave-lyh
annotate libgui/src/files-dock-widget.h @ 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 |
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 */ |
13495 | 22 |
23 #ifndef FILESDOCKWIDGET_H | |
24 #define FILESDOCKWIDGET_H | |
25 | |
26 #include <QListView> | |
27 #include <QDate> | |
28 #include <QObject> | |
29 #include <QWidget> | |
30 #include <QListWidget> | |
31 #include <QFileSystemModel> | |
32 #include <QToolBar> | |
33 #include <QToolButton> | |
34 #include <QVBoxLayout> | |
35 #include <QAction> | |
36 #include <QTreeView> | |
16413
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16057
diff
changeset
|
37 #include <QSettings> |
13495 | 38 |
16498
605d7f0ee0d8
Added Filesdockwidget recently viewed directory pulldownlist
John Donoghue <john.donoghue@ieee.org>
parents:
16461
diff
changeset
|
39 #include <QComboBox> |
16057
c3057d80cf91
Created common octave_dock_widget class
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
15552
diff
changeset
|
40 #include "octave-dock-widget.h" |
13495 | 41 |
14863
3ff18e21c742
Added a few comments.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14803
diff
changeset
|
42 /** |
15367
501a9cc2c68f
maint: whitespace cleanup in GUI code
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15300
diff
changeset
|
43 \class files_dock_widget |
501a9cc2c68f
maint: whitespace cleanup in GUI code
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15300
diff
changeset
|
44 \brief Dock widget to display files in the current directory. |
501a9cc2c68f
maint: whitespace cleanup in GUI code
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15300
diff
changeset
|
45 */ |
16057
c3057d80cf91
Created common octave_dock_widget class
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
15552
diff
changeset
|
46 class files_dock_widget : public octave_dock_widget |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
47 { |
13536
869c62c15e95
Few minor improvements, added advanced settings for file browser.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13506
diff
changeset
|
48 Q_OBJECT |
16450
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 public: |
3207f1d62e74
improve encapsulation of file browser window object
John W. Eaton <jwe@octave.org>
parents:
16437
diff
changeset
|
51 |
14709
f50591409306
Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14707
diff
changeset
|
52 files_dock_widget (QWidget *parent = 0); |
16450
3207f1d62e74
improve encapsulation of file browser window object
John W. Eaton <jwe@octave.org>
parents:
16437
diff
changeset
|
53 |
15461
1e64aff609c3
save/restore column state and sorting (column and order) in files-widget
Torsten <ttl@justmail.de>
parents:
15367
diff
changeset
|
54 ~files_dock_widget (); |
13536
869c62c15e95
Few minor improvements, added advanced settings for file browser.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13506
diff
changeset
|
55 |
869c62c15e95
Few minor improvements, added advanced settings for file browser.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13506
diff
changeset
|
56 public slots: |
16057
c3057d80cf91
Created common octave_dock_widget class
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
15552
diff
changeset
|
57 |
13536
869c62c15e95
Few minor improvements, added advanced settings for file browser.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13506
diff
changeset
|
58 /** Slot for handling a change in directory via double click. */ |
14712
5cb54cca8a06
Completion of code reformatting.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14709
diff
changeset
|
59 void item_double_clicked (const QModelIndex & index); |
13495 | 60 |
13536
869c62c15e95
Few minor improvements, added advanced settings for file browser.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13506
diff
changeset
|
61 /** Slot for handling the up-directory button in the toolbar. */ |
16437
919796a440c6
use signal for changing directory
John W. Eaton <jwe@octave.org>
parents:
16413
diff
changeset
|
62 void change_directory_up (); |
14863
3ff18e21c742
Added a few comments.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14803
diff
changeset
|
63 |
16499
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
64 /** Slot for handling the sync octave directory button in the toolbar. */ |
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
65 void do_sync_octave_directory (); |
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
66 |
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
67 /** Slot for handling the sync browser directory button in the toolbar. */ |
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
68 void do_sync_browser_directory (); |
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
69 |
14863
3ff18e21c742
Added a few comments.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14803
diff
changeset
|
70 /** Sets the current directory being displayed. */ |
16437
919796a440c6
use signal for changing directory
John W. Eaton <jwe@octave.org>
parents:
16413
diff
changeset
|
71 void set_current_directory (const QString& dir); |
14863
3ff18e21c742
Added a few comments.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14803
diff
changeset
|
72 |
3ff18e21c742
Added a few comments.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14803
diff
changeset
|
73 /** Accepts user input a the line edit for the current directory. */ |
16437
919796a440c6
use signal for changing directory
John W. Eaton <jwe@octave.org>
parents:
16413
diff
changeset
|
74 void accept_directory_line_edit (); |
14863
3ff18e21c742
Added a few comments.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14803
diff
changeset
|
75 |
16499
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
76 /** set the internal variable that holds the actual octave variable **/ |
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
77 void update_octave_directory (const QString& dir); |
13495 | 78 |
14863
3ff18e21c742
Added a few comments.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14803
diff
changeset
|
79 /** Tells the widget to react on changed settings. */ |
16413
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16057
diff
changeset
|
80 void notice_settings (const QSettings *settings); |
14863
3ff18e21c742
Added a few comments.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14803
diff
changeset
|
81 |
16461
094bd3627ead
move common functionality to octave_dock_widget base class
John W. Eaton <jwe@octave.org>
parents:
16460
diff
changeset
|
82 signals: |
16450
3207f1d62e74
improve encapsulation of file browser window object
John W. Eaton <jwe@octave.org>
parents:
16437
diff
changeset
|
83 |
14863
3ff18e21c742
Added a few comments.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14803
diff
changeset
|
84 /** Emitted, whenever the user requested to open a file. */ |
15300
fd27e10b9b05
pass QString by const reference instead of value
John W. Eaton <jwe@octave.org>
parents:
15204
diff
changeset
|
85 void open_file (const QString& fileName); |
14863
3ff18e21c742
Added a few comments.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14803
diff
changeset
|
86 |
3ff18e21c742
Added a few comments.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14803
diff
changeset
|
87 /** Emitted, whenever the currently displayed directory changed. */ |
16437
919796a440c6
use signal for changing directory
John W. Eaton <jwe@octave.org>
parents:
16413
diff
changeset
|
88 void displayed_directory_changed (const QString& dir); |
13495 | 89 |
16461
094bd3627ead
move common functionality to octave_dock_widget base class
John W. Eaton <jwe@octave.org>
parents:
16460
diff
changeset
|
90 private: |
13577
e440b3f32f02
Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13536
diff
changeset
|
91 |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
92 // TODO: Add toolbar with buttons for navigating the path, creating dirs, etc |
13495 | 93 |
16499
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
94 /** set a new directory or open a file **/ |
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
95 void display_directory (const QString& dir, bool set_octave_dir = true); |
13495 | 96 |
16499
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
97 /** Variables for the actions **/ |
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
98 QAction * _sync_octave_directory_action; |
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
99 QAction * _sync_browser_directory_action; |
13495 | 100 |
14712
5cb54cca8a06
Completion of code reformatting.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14709
diff
changeset
|
101 /** The file system model. */ |
5cb54cca8a06
Completion of code reformatting.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14709
diff
changeset
|
102 QFileSystemModel *_file_system_model; |
13495 | 103 |
14712
5cb54cca8a06
Completion of code reformatting.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14709
diff
changeset
|
104 /** The file system view. */ |
5cb54cca8a06
Completion of code reformatting.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14709
diff
changeset
|
105 QTreeView * _file_tree_view; |
16498
605d7f0ee0d8
Added Filesdockwidget recently viewed directory pulldownlist
John Donoghue <john.donoghue@ieee.org>
parents:
16461
diff
changeset
|
106 QComboBox * _current_directory; |
605d7f0ee0d8
Added Filesdockwidget recently viewed directory pulldownlist
John Donoghue <john.donoghue@ieee.org>
parents:
16461
diff
changeset
|
107 |
16499
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
108 /** Internal variables **/ |
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
109 bool _sync_octave_dir; // flag if syncing with octave |
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
110 QString _octave_dir; // the actual octave dir |
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
111 |
16498
605d7f0ee0d8
Added Filesdockwidget recently viewed directory pulldownlist
John Donoghue <john.donoghue@ieee.org>
parents:
16461
diff
changeset
|
112 enum { MaxMRUDirs = 10 }; |
13495 | 113 }; |
114 | |
115 #endif // FILESDOCKWIDGET_H |