GNU Octave  3.8.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-2013 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 
117 signals:
118 
119  /** Emitted, whenever the user requested to open a file. */
120  void open_file (const QString& fileName);
121 
122  /** Emitted, whenever the currently displayed directory changed. */
123  void displayed_directory_changed (const QString& dir);
124 
125  /** Emitted, whenever the user requested to load a file. */
126  void load_file_signal (const QString& fileName);
127 
128  /** Emitted, whenever the user requested to run a file. */
129  void run_file_signal (const QFileInfo& info);
130 
131  /** Emitted, whenever wants to search for a file . */
132  void find_files_signal (const QString &startdir);
133 
134 private:
135  void process_new_file (const QString &parent_name);
136  void process_new_dir (const QString &parent_name);
137  void process_set_current_dir (const QString &parent_name);
138  void process_find_files (const QString &dir_name);
139 
140  /** set a new directory or open a file **/
141  void display_directory (const QString& dir, bool set_octave_dir = true);
142 
143  void open_item_in_app (const QModelIndex& index);
144 
145  /** Variables for the actions **/
149 
150  /** The file system model. */
151  QFileSystemModel *_file_system_model;
152 
153  /** The file system view. */
155  QComboBox * _current_directory;
156 
157  /** Internal variables **/
158  bool _sync_octave_dir; // flag if syncing with octave
159  QString _octave_dir; // the actual octave dir
160 
161  enum { MaxMRUDirs = 10 };
162 };
163 
164 #endif // FILESDOCKWIDGET_H