GNU Octave  4.0.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
files-dock-widget.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2011-2015 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 the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 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 <http://www.gnu.org/licenses/>.
20 
21 */
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>
37 #include <QMouseEvent>
38 
39 #include <QComboBox>
40 #include "octave-dock-widget.h"
41 
42 /**
43  @class files_dock_widget
44  @brief Dock widget to display files in the current directory.
45 */
47 {
48  Q_OBJECT
49 
50 public:
51 
52  files_dock_widget (QWidget *parent = 0);
53 
55 
56 public slots:
57 
58  /** Slot for handling a change in directory via double click. */
59  void item_double_clicked (const QModelIndex & index);
60 
61  /** Slot for handling the up-directory button in the toolbar. */
62  void change_directory_up ();
63 
64  /** Slot for handling the sync octave directory button in the toolbar. */
66 
67  /** Slot for handling the sync browser directory button in the toolbar. */
69 
70  /** Sets the current directory being displayed. */
71  void set_current_directory (const QString& dir);
72 
73  /** Accepts user input a the line edit for the current directory. */
75 
76  /** set the internal variable that holds the actual octave variable **/
77  void update_octave_directory (const QString& dir);
78 
79  /** Tells the widget to react on changed settings. */
80  void notice_settings (const QSettings *settings);
81 
82 private slots:
83  /** context menu wanted */
84  void contextmenu_requested (const QPoint& pos);
85 
90 
91  void headercontextmenu_requested (const QPoint& pos);
92 
93  /* context menu actions */
94  void contextmenu_open (bool);
95  void contextmenu_open_in_app (bool);
96  void contextmenu_copy_selection (bool);
97  void contextmenu_run (bool);
98  void contextmenu_load (bool);
99  void contextmenu_rename (bool);
100  void contextmenu_delete (bool);
101  void contextmenu_newfile (bool);
102  void contextmenu_newdir (bool);
103  void contextmenu_setcurrentdir (bool);
104  void contextmenu_findfiles (bool);
105 
106  /* popdown menu options */
107  void popdownmenu_newfile (bool);
108  void popdownmenu_newdir (bool);
109  void popdownmenu_search_dir (bool);
110  void popdownmenu_findfiles (bool);
111  void popdownmenu_home (bool);
112 
113  /* from octave_doc_widget */
114  void copyClipboard ();
115  void pasteClipboard ();
116  void selectAll ();
117 
118 signals:
119 
120  /** Emitted, whenever the user requested to open a file. */
121  void open_file (const QString& fileName);
122 
123  /** Emitted, whenever the currently displayed directory changed. */
124  void displayed_directory_changed (const QString& dir);
125 
126  /** Emitted, whenever the user requested to load a file. */
127  void load_file_signal (const QString& fileName);
128 
129  /** Emitted, whenever the user requested to run a file. */
130  void run_file_signal (const QFileInfo& info);
131 
132  /** Emitted, whenever wants to search for a file . */
133  void find_files_signal (const QString &startdir);
134 
135 private:
136  void process_new_file (const QString &parent_name);
137  void process_new_dir (const QString &parent_name);
138  void process_set_current_dir (const QString &parent_name);
139  void process_find_files (const QString &dir_name);
140 
141  /** set a new directory or open a file **/
142  void display_directory (const QString& dir, bool set_octave_dir = true);
143 
144  void open_item_in_app (const QModelIndex& index);
145 
146  /** Variables for the actions **/
150 
151  /** The file system model. */
152  QFileSystemModel *_file_system_model;
153 
154  /** The file system view. */
156  QComboBox * _current_directory;
157 
158  /** Internal variables **/
159  bool _sync_octave_dir; // flag if syncing with octave
160  QString _octave_dir; // the actual octave dir
161 
162  enum { MaxMRUDirs = 10 };
163 };
164 
165 #endif // FILESDOCKWIDGET_H
void load_file_signal(const QString &fileName)
Emitted, whenever the user requested to load a file.
QComboBox * _current_directory
void process_new_file(const QString &parent_name)
void process_find_files(const QString &dir_name)
void do_sync_browser_directory()
Slot for handling the sync browser directory button in the toolbar.
void toggle_headercontextitem_filetype()
void process_set_current_dir(const QString &parent_name)
void popdownmenu_findfiles(bool)
void update_octave_directory(const QString &dir)
set the internal variable that holds the actual octave variable
void set_current_directory(const QString &dir)
Sets the current directory being displayed.
void toggle_headercontextitem_filesize()
void headercontextmenu_requested(const QPoint &pos)
void popdownmenu_search_dir(bool)
void contextmenu_rename(bool)
void run_file_signal(const QFileInfo &info)
Emitted, whenever the user requested to run a file.
files_dock_widget(QWidget *parent=0)
QTreeView * _file_tree_view
The file system view.
void notice_settings(const QSettings *settings)
Tells the widget to react on changed settings.
void popdownmenu_newdir(bool)
void contextmenu_open_in_app(bool)
void contextmenu_findfiles(bool)
void contextmenu_delete(bool)
void do_sync_octave_directory()
Slot for handling the sync octave directory button in the toolbar.
void open_file(const QString &fileName)
Emitted, whenever the user requested to open a file.
void change_directory_up()
Slot for handling the up-directory button in the toolbar.
void toggle_headercontextitem_showhidden()
void process_new_dir(const QString &parent_name)
void accept_directory_line_edit()
Accepts user input a the line edit for the current directory.
void displayed_directory_changed(const QString &dir)
Emitted, whenever the currently displayed directory changed.
void popdownmenu_newfile(bool)
QAction * _sync_octave_directory_action
void find_files_signal(const QString &startdir)
Emitted, whenever wants to search for a file .
QFileSystemModel * _file_system_model
The file system model.
void toggle_headercontextitem_datemodified()
Dock widget to display files in the current directory.
bool _sync_octave_dir
Internal variables.
void contextmenu_requested(const QPoint &pos)
context menu wanted
void contextmenu_setcurrentdir(bool)
void open_item_in_app(const QModelIndex &index)
void display_directory(const QString &dir, bool set_octave_dir=true)
set a new directory or open a file
QToolBar * _navigation_tool_bar
Variables for the actions.
void contextmenu_newfile(bool)
void contextmenu_newdir(bool)
QAction * _sync_browser_directory_action
void contextmenu_copy_selection(bool)
void item_double_clicked(const QModelIndex &index)
Slot for handling a change in directory via double click.