GNU Octave  4.4.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
files-dock-widget.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2011-2018 Jacob Dawid
4 
5 This file is part of Octave.
6 
7 Octave is free software: you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with Octave; see the file COPYING. If not, see
19 <https://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if ! defined (octave_files_dock_widget_h)
24 #define octave_files_dock_widget_h 1
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>
37 #include <QMouseEvent>
38 #include <QSignalMapper>
39 
40 #include <QComboBox>
41 #include "octave-dock-widget.h"
42 
43 namespace octave
44 {
45  //! Dock widget to display files in the current directory.
46 
48  {
49  Q_OBJECT
50 
51  public:
52 
53  files_dock_widget (QWidget *parent = nullptr);
54 
55  ~files_dock_widget (void) = default;
56 
57  public slots:
58 
59  //! Slot for handling a change in directory via double click.
60 
61  void item_double_clicked (const QModelIndex & index);
62 
63  //! Slot for handling the up-directory button in the toolbar.
64 
65  void change_directory_up (void);
66 
67  //! Slot for handling the sync octave directory button in the toolbar.
68 
69  void do_sync_octave_directory (void);
70 
71  //! Slot for handling the sync browser directory button in the toolbar.
72 
73  void do_sync_browser_directory (void);
74 
75  //! Sets the current directory being displayed.
76 
77  void set_current_directory (const QString& dir);
78 
79  //! Accepts user input a the line edit for the current directory.
80 
81  void accept_directory_line_edit (void);
82 
83  //! Set the internal variable that holds the actual octave variable.
84 
85  void update_octave_directory (const QString& dir);
86 
87  //! Tells the widget to react on changed settings.
88 
89  void notice_settings (const QSettings *settings);
90 
91  void save_settings (void);
92 
93  private slots:
94 
95  void headercontextmenu_requested (const QPoint& pos);
96  void toggle_header (int col);
97 
98  //! Context menu wanted.
99 
100  void contextmenu_requested (const QPoint& pos);
101 
102  //! Context menu actions.
103  //!@{
104  void contextmenu_open (bool);
105  void contextmenu_open_in_editor (bool);
106  void contextmenu_open_in_app (bool);
107  void contextmenu_copy_selection (bool);
108  void contextmenu_run (bool);
109  void contextmenu_load (bool);
110  void contextmenu_rename (bool);
111  void contextmenu_delete (bool);
112  void contextmenu_newfile (bool);
113  void contextmenu_newdir (bool);
114  void contextmenu_setcurrentdir (bool);
115  void contextmenu_findfiles (bool);
116  //!@}
117 
118  //! Popdown menu options.
119  //!@{
120  void popdownmenu_newfile (bool);
121  void popdownmenu_newdir (bool);
122  void popdownmenu_search_dir (bool);
123  void popdownmenu_findfiles (bool);
124  void popdownmenu_home (bool);
125  //!@}
126 
127  //! Inherited from octave_doc_widget.
128  //!@{
129  void copyClipboard ();
130  void pasteClipboard ();
131  void selectAll ();
132  //!@}
133 
134  signals:
135 
136  //! Emitted, whenever the user requested to open a file.
137 
138  void open_file (const QString& fileName);
139 
140  //! Emitted, whenever the currently displayed directory changed.
141 
142  void displayed_directory_changed (const QString& dir);
143 
144  //! Emitted, whenever the user requested to load a file.
145 
146  void load_file_signal (const QString& fileName);
147 
148  //! Emitted, whenever the user requested to run a file.
149 
150  void run_file_signal (const QFileInfo& info);
151 
152  //! Emitted, whenever wants to search for a file .
153 
154  void find_files_signal (const QString& startdir);
155 
156  //! Emitted, whenever the user removes or renames a file.
157 
158  void file_remove_signal (const QString& old_name, const QString& new_name);
159 
160  //! Emitted, when a file or directory is renamed.
161 
162  void file_renamed_signal (bool);
163 
164  private:
165 
166  void process_new_file (const QString& parent_name);
167  void process_new_dir (const QString& parent_name);
168  void process_set_current_dir (const QString& parent_name);
169  void process_find_files (const QString& dir_name);
170 
171  //! set a new directory or open a file
172 
173  void display_directory (const QString& dir, bool set_octave_dir = true);
174 
175  void open_item_in_app (const QModelIndex& index);
176 
177  //! Variables for the actions
178 
182 
183  //! The file system model.
184 
185  QFileSystemModel *m_file_system_model;
186 
187  //! The file system view.
188  //!@{
191  //!@}
192 
193  //! Flag if syncing with Octave.
194 
196 
197  //! The actual Octave directory.
198 
199  QString m_octave_dir;
200 
201  enum { MaxMRUDirs = 10 };
202 
203  QStringList m_columns_shown;
204  QStringList m_columns_shown_keys;
205  QSignalMapper *m_sig_mapper;
206  };
207 }
208 
209 #endif
void open_file(const QString &fileName)
Emitted, whenever the user requested to open a file.
void contextmenu_rename(bool)
Context menu actions.
void item_double_clicked(const QModelIndex &index)
Slot for handling a change in directory via double click.
void contextmenu_newdir(bool)
Context menu actions.
void contextmenu_load(bool)
Context menu actions.
void do_sync_browser_directory(void)
Slot for handling the sync browser directory button in the toolbar.
void contextmenu_open_in_editor(bool)
Context menu actions.
Dock widget to display files in the current directory.
~files_dock_widget(void)=default
QComboBox * m_current_directory
The file system view.
void find_files_signal(const QString &startdir)
Emitted, whenever wants to search for a file .
void load_file_signal(const QString &fileName)
Emitted, whenever the user requested to load a file.
void popdownmenu_newfile(bool)
Popdown menu options.
void file_remove_signal(const QString &old_name, const QString &new_name)
Emitted, whenever the user removes or renames a file.
bool m_sync_octave_dir
Flag if syncing with Octave.
QString m_octave_dir
The actual Octave directory.
void selectAll()
Inherited from octave_doc_widget.
void contextmenu_run(bool)
Context menu actions.
void displayed_directory_changed(const QString &dir)
Emitted, whenever the currently displayed directory changed.
QFileSystemModel * m_file_system_model
The file system model.
void update_octave_directory(const QString &dir)
Set the internal variable that holds the actual octave variable.
void popdownmenu_search_dir(bool)
Popdown menu options.
void contextmenu_delete(bool)
Context menu actions.
QToolBar * m_navigation_tool_bar
Variables for the actions.
void notice_settings(const QSettings *settings)
Tells the widget to react on changed settings.
void accept_directory_line_edit(void)
Accepts user input a the line edit for the current directory.
void contextmenu_copy_selection(bool)
Context menu actions.
void contextmenu_open_in_app(bool)
Context menu actions.
void open_item_in_app(const QModelIndex &index)
void change_directory_up(void)
Slot for handling the up-directory button in the toolbar.
void contextmenu_open(bool)
Context menu actions.
void process_new_dir(const QString &parent_name)
void do_sync_octave_directory(void)
Slot for handling the sync octave directory button in the toolbar.
void contextmenu_findfiles(bool)
Context menu actions.
void popdownmenu_newdir(bool)
Popdown menu options.
void process_set_current_dir(const QString &parent_name)
files_dock_widget(QWidget *parent=nullptr)
QTreeView * m_file_tree_view
The file system view.
void display_directory(const QString &dir, bool set_octave_dir=true)
set a new directory or open a file
void run_file_signal(const QFileInfo &info)
Emitted, whenever the user requested to run a file.
void set_current_directory(const QString &dir)
Sets the current directory being displayed.
void headercontextmenu_requested(const QPoint &pos)
void contextmenu_newfile(bool)
Context menu actions.
void contextmenu_requested(const QPoint &pos)
Context menu wanted.
void file_renamed_signal(bool)
Emitted, when a file or directory is renamed.
void process_new_file(const QString &parent_name)
void process_find_files(const QString &dir_name)
void copyClipboard()
Inherited from octave_doc_widget.
void pasteClipboard()
Inherited from octave_doc_widget.
void popdownmenu_home(bool)
Popdown menu options.
void contextmenu_setcurrentdir(bool)
Context menu actions.
void popdownmenu_findfiles(bool)
Popdown menu options.