GNU Octave 7.1.0
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-2022 The Octave Project Developers
4//
5// See the file COPYRIGHT.md in the top-level directory of this
6// distribution or <https://octave.org/copyright/>.
7//
8// This file is part of Octave.
9//
10// Octave is free software: you can redistribute it and/or modify it
11// under the terms of the GNU General Public License as published by
12// the Free Software Foundation, either version 3 of the License, or
13// (at your option) any later version.
14//
15// Octave is distributed in the hope that it will be useful, but
16// WITHOUT ANY WARRANTY; without even the implied warranty of
17// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18// GNU General Public License for more details.
19//
20// You should have received a copy of the GNU General Public License
21// along with Octave; see the file COPYING. If not, see
22// <https://www.gnu.org/licenses/>.
23//
24////////////////////////////////////////////////////////////////////////
25
26#if ! defined (octave_files_dock_widget_h)
27#define octave_files_dock_widget_h 1
28
29#include <QAction>
30#include <QComboBox>
31#include <QDate>
32#include <QFileSystemModel>
33#include <QList>
34#include <QListView>
35#include <QListWidget>
36#include <QMouseEvent>
37#include <QObject>
38#include <QSignalMapper>
39#include <QToolBar>
40#include <QToolButton>
41#include <QTreeView>
42#include <QVBoxLayout>
43#include <QWidget>
44
45#include "octave-dock-widget.h"
46
47namespace octave
48{
49 class base_qobject;
50
51 //! Dock widget to display files in the current directory.
52
54 {
55 Q_OBJECT
56
57 public:
58
59 files_dock_widget (QWidget *parent, base_qobject& oct_qobj);
60
61 ~files_dock_widget (void) = default;
62
63 signals:
64
65 //! Emitted, whenever the user requested to open a file.
66
67 void open_file (const QString& fileName);
68
69 //! Emitted, whenever the currently displayed directory changed.
70
71 void displayed_directory_changed (const QString& dir);
72
73 //! Emitted, whenever the user requested to load a file in the text editor.
74
75 void load_file_signal (const QString& fileName);
76
77 //! Emitted, whenever the user requested to open an unknown type file.
78
79 void open_any_signal (const QString& fileName);
80
81 //! Emitted, whenever the user requested to run a file.
82
83 void run_file_signal (const QFileInfo& info);
84
85 //! Emitted, whenever wants to search for a file .
86
87 void find_files_signal (const QString& startdir);
88
89 //! Emitted, whenever the user removes or renames a file.
90
91 void file_remove_signal (const QString& old_name, const QString& new_name);
92
93 //! Emitted, when a file or directory is renamed.
94
96
97 //! Emitted, when the path has to be modified
98
99 void modify_path_signal (const QStringList& dir_list, bool rm,
100 bool subdirs);
101
102 public slots:
103
104 //! Slot for handling a change in directory via double click.
105
106 void item_double_clicked (const QModelIndex& index);
107
108 //! Slot for handling the up-directory button in the toolbar.
109
110 void change_directory_up (void);
111
112 //! Slot for handling the sync octave directory button in the toolbar.
113
114 void do_sync_octave_directory (void);
115
116 //! Slot for handling the sync browser directory button in the toolbar.
117
118 void do_sync_browser_directory (void);
119
120 //! Sets the current directory being displayed.
121
122 void set_current_directory (const QString& dir);
123
124 //! Accepts user input a the line edit for the current directory.
125
126 void accept_directory_line_edit (void);
127
128 //! Set the internal variable that holds the actual octave variable.
129
130 void update_octave_directory (const QString& dir);
131
132 //! Tells the widget to react on changed settings.
133
135
136 void save_settings (void);
137
138 private slots:
139
140 void headercontextmenu_requested (const QPoint& pos);
141 void toggle_header (int col);
142
143 //! Context menu wanted.
144
145 void contextmenu_requested (const QPoint& pos);
146
147 //! Context menu actions.
148 //!@{
149 void contextmenu_open (bool);
150 void contextmenu_open_in_editor (bool);
151 void contextmenu_open_in_app (bool);
152 void contextmenu_copy_selection (bool);
153 void contextmenu_run (bool);
154 void contextmenu_load (bool);
155 void contextmenu_rename (bool);
156 void contextmenu_delete (bool);
157 void contextmenu_newfile (bool);
158 void contextmenu_newdir (bool);
159 void contextmenu_setcurrentdir (bool);
160 void contextmenu_add_to_path (bool, bool rm=false, bool subdirs=false);
162 void contextmenu_rm_from_path (bool);
164 void contextmenu_findfiles (bool);
165 //!@}
166
167 //! Popdown menu options.
168 //!@{
169 void popdownmenu_newfile (bool);
170 void popdownmenu_newdir (bool);
171 void popdownmenu_search_dir (bool);
172 void popdownmenu_findfiles (bool);
173 void popdownmenu_home (bool);
174 //!@}
175
176 //! Inherited from octave_doc_widget.
177 //!@{
178 void copyClipboard ();
179 void pasteClipboard ();
180 void selectAll ();
181 //!@}
182
183 private:
184
185 //! Get currently selected QFileInfo object.
186
188
189 //! Process new file/directory actions
190
191 void process_new_file (const QString& parent_name);
192 void process_new_dir (const QString& parent_name);
193
194 //! Process setting current dir or find in files
195
196 void process_set_current_dir (const QString& parent_name);
197 void process_find_files (const QString& dir_name);
198
199 //! set a new directory or open a file
200
201 void display_directory (const QString& dir, bool set_octave_dir = true);
202
203 void open_item_in_app (const QModelIndex& index);
204
205 //! Variables for the actions
206
210
211 //! The file system model.
212
213 QFileSystemModel *m_file_system_model;
214
215 //! The file system view.
216 //!@{
219 //!@}
220
221 //! Flag if syncing with Octave.
222
224
225 //! The actual Octave directory.
226
228
229 enum { MaxMRUDirs = 10 };
230
231 QStringList m_columns_shown;
234 QSignalMapper *m_sig_mapper;
235 };
236}
237
238#endif
Base class for Octave interfaces that use Qt.
Dock widget to display files in the current directory.
void contextmenu_copy_selection(bool)
Context menu actions.
void contextmenu_rm_from_path_subdirs(bool)
Context menu actions.
QString m_octave_dir
The actual Octave directory.
void contextmenu_add_to_path_subdirs(bool)
Context menu actions.
void contextmenu_add_to_path(bool, bool rm=false, bool subdirs=false)
Context menu actions.
void process_new_dir(const QString &parent_name)
void do_sync_browser_directory(void)
Slot for handling the sync browser directory button in the toolbar.
~files_dock_widget(void)=default
void open_item_in_app(const QModelIndex &index)
void process_new_file(const QString &parent_name)
Process new file/directory actions.
void headercontextmenu_requested(const QPoint &pos)
void contextmenu_run(bool)
Context menu actions.
void open_file(const QString &fileName)
Emitted, whenever the user requested to open a file.
void open_any_signal(const QString &fileName)
Emitted, whenever the user requested to open an unknown type file.
void update_octave_directory(const QString &dir)
Set the internal variable that holds the actual octave variable.
void contextmenu_rm_from_path(bool)
Context menu actions.
void process_set_current_dir(const QString &parent_name)
Process setting current dir or find in files.
QList< QFileInfo > get_selected_items_info(bool)
Get currently selected QFileInfo object.
QTreeView * m_file_tree_view
The file system view.
void modify_path_signal(const QStringList &dir_list, bool rm, bool subdirs)
Emitted, when the path has to be modified.
void notice_settings(const gui_settings *settings)
Tells the widget to react on changed settings.
void contextmenu_load(bool)
Context menu actions.
void copyClipboard()
Inherited from octave_doc_widget.
void selectAll()
Inherited from octave_doc_widget.
QToolBar * m_navigation_tool_bar
Variables for the actions.
void change_directory_up(void)
Slot for handling the up-directory button in the toolbar.
void run_file_signal(const QFileInfo &info)
Emitted, whenever the user requested to run a file.
void accept_directory_line_edit(void)
Accepts user input a the line edit for the current directory.
void popdownmenu_newdir(bool)
Popdown menu options.
void contextmenu_newdir(bool)
Context menu actions.
void display_directory(const QString &dir, bool set_octave_dir=true)
set a new directory or open a file
void popdownmenu_search_dir(bool)
Popdown menu options.
void popdownmenu_home(bool)
Popdown menu options.
void contextmenu_open(bool)
Context menu actions.
files_dock_widget(QWidget *parent, base_qobject &oct_qobj)
void contextmenu_open_in_editor(bool)
Context menu actions.
void item_double_clicked(const QModelIndex &index)
Slot for handling a change in directory via double click.
bool m_sync_octave_dir
Flag if syncing with Octave.
void pasteClipboard()
Inherited from octave_doc_widget.
void contextmenu_newfile(bool)
Context menu actions.
QFileSystemModel * m_file_system_model
The file system model.
void contextmenu_requested(const QPoint &pos)
Context menu wanted.
void do_sync_octave_directory(void)
Slot for handling the sync octave directory button in the toolbar.
void file_remove_signal(const QString &old_name, const QString &new_name)
Emitted, whenever the user removes or renames a file.
void popdownmenu_findfiles(bool)
Popdown menu options.
QComboBox * m_current_directory
The file system view.
void process_find_files(const QString &dir_name)
void contextmenu_rename(bool)
Context menu actions.
QList< QVariant > m_columns_shown_defs
void find_files_signal(const QString &startdir)
Emitted, whenever wants to search for a file .
void contextmenu_setcurrentdir(bool)
Context menu actions.
void contextmenu_delete(bool)
Context menu actions.
void load_file_signal(const QString &fileName)
Emitted, whenever the user requested to load a file in the text editor.
void popdownmenu_newfile(bool)
Popdown menu options.
void set_current_directory(const QString &dir)
Sets the current directory being displayed.
void file_renamed_signal(bool)
Emitted, when a file or directory is renamed.
void contextmenu_findfiles(bool)
Context menu actions.
void contextmenu_open_in_app(bool)
Context menu actions.
void displayed_directory_changed(const QString &dir)
Emitted, whenever the currently displayed directory changed.