Mercurial > octave
annotate libgui/src/files-dock-widget.cc @ 16611:999400bebe5e
move more common code from dock widgets into octave-dock-widget.h
* terminal-dock-widget.cc, file-editor.cc, files-dock-widget.cc,
workspace-view.cc (constructor): remove connectiong changed_settings signal
* files-dock-widget.cc/.h, file-editor.h: do not include QSettings here
* octave-dock-widget.h(constructor): connect changed_settings signal
* octave-dock-widget.h: include QSettings, empty virtual slot notice-settings
author | Torsten <ttl@justmail.de> |
---|---|
date | Sat, 04 May 2013 23:37:27 +0200 |
parents | 3ce0c312a40b |
children | 99a57611d58a |
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 */ |
13501 | 22 |
15286
ae9079bbc627
Add '#include <config.h>' to C++ files in libgui/src
Rik <rik@octave.org>
parents:
15204
diff
changeset
|
23 #ifdef HAVE_CONFIG_H |
ae9079bbc627
Add '#include <config.h>' to C++ files in libgui/src
Rik <rik@octave.org>
parents:
15204
diff
changeset
|
24 #include <config.h> |
ae9079bbc627
Add '#include <config.h>' to C++ files in libgui/src
Rik <rik@octave.org>
parents:
15204
diff
changeset
|
25 #endif |
ae9079bbc627
Add '#include <config.h>' to C++ files in libgui/src
Rik <rik@octave.org>
parents:
15204
diff
changeset
|
26 |
14707
674740c44c09
Changed various files to matche file naming conventions.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14703
diff
changeset
|
27 #include "resource-manager.h" |
16460
4d4e7c6f839d
use consistent names for dock-widget files
John W. Eaton <jwe@octave.org>
parents:
16455
diff
changeset
|
28 #include "files-dock-widget.h" |
13501 | 29 |
30 #include <QApplication> | |
31 #include <QFileInfo> | |
32 #include <QCompleter> | |
13531
bb3676025b36
User can set a custom file editor instead of the built-in one.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13522
diff
changeset
|
33 #include <QProcess> |
13539
a4b5cad8f7c6
Added command line parser class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13537
diff
changeset
|
34 #include <QDebug> |
15461
1e64aff609c3
save/restore column state and sorting (column and order) in files-widget
Torsten <ttl@justmail.de>
parents:
15368
diff
changeset
|
35 #include <QHeaderView> |
16498
605d7f0ee0d8
Added Filesdockwidget recently viewed directory pulldownlist
John Donoghue <john.donoghue@ieee.org>
parents:
16487
diff
changeset
|
36 #include <QLineEdit> |
605d7f0ee0d8
Added Filesdockwidget recently viewed directory pulldownlist
John Donoghue <john.donoghue@ieee.org>
parents:
16487
diff
changeset
|
37 #include <QSizePolicy> |
16503
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
38 #include <QMenu> |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
39 #include <QInputDialog> |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
40 #include <QMessageBox> |
16542
016073c0cb94
Add popdown toolbutton to files-dock-window toolbar.
John Donoghue <john.donoghue@ieee.org>
parents:
16525
diff
changeset
|
41 #include <QToolButton> |
16594
3ce0c312a40b
contextmenu for opening files in default applications
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
42 #include <QUrl> |
3ce0c312a40b
contextmenu for opening files in default applications
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
43 #include <QDesktopServices> |
13501 | 44 |
16555
04fb96f4bea1
allow double-click in file browser to load data files
John W. Eaton <jwe@octave.org>
parents:
16542
diff
changeset
|
45 #include "load-save.h" |
04fb96f4bea1
allow double-click in file browser to load data files
John W. Eaton <jwe@octave.org>
parents:
16542
diff
changeset
|
46 |
15368
36ececf69385
avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents:
15367
diff
changeset
|
47 files_dock_widget::files_dock_widget (QWidget *p) |
16057
c3057d80cf91
Created common octave_dock_widget class
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
15552
diff
changeset
|
48 : octave_dock_widget (p) |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
49 { |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
50 setObjectName ("FilesDockWidget"); |
15552
bbbb89cc338f
make a floating widget behave like a normal window (bug #37190)
Torsten <ttl@justmail.de>
parents:
15461
diff
changeset
|
51 setWindowIcon (QIcon(":/actions/icons/logo.png")); |
16437
919796a440c6
use signal for changing directory
John W. Eaton <jwe@octave.org>
parents:
16413
diff
changeset
|
52 setWindowTitle (tr ("File Browser")); |
16499
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
53 setToolTip (tr ("Browse your files.")); |
16450
3207f1d62e74
improve encapsulation of file browser window object
John W. Eaton <jwe@octave.org>
parents:
16437
diff
changeset
|
54 |
3207f1d62e74
improve encapsulation of file browser window object
John W. Eaton <jwe@octave.org>
parents:
16437
diff
changeset
|
55 QWidget *container = new QWidget (this); |
3207f1d62e74
improve encapsulation of file browser window object
John W. Eaton <jwe@octave.org>
parents:
16437
diff
changeset
|
56 |
3207f1d62e74
improve encapsulation of file browser window object
John W. Eaton <jwe@octave.org>
parents:
16437
diff
changeset
|
57 setWidget (container); |
13501 | 58 |
16455
38ed6bdd1f7f
move signal/slot connections from main window to sub window where possible
John W. Eaton <jwe@octave.org>
parents:
16450
diff
changeset
|
59 connect (this, SIGNAL (open_file (const QString&)), |
38ed6bdd1f7f
move signal/slot connections from main window to sub window where possible
John W. Eaton <jwe@octave.org>
parents:
16450
diff
changeset
|
60 parent (), SLOT (open_file (const QString&))); |
38ed6bdd1f7f
move signal/slot connections from main window to sub window where possible
John W. Eaton <jwe@octave.org>
parents:
16450
diff
changeset
|
61 |
38ed6bdd1f7f
move signal/slot connections from main window to sub window where possible
John W. Eaton <jwe@octave.org>
parents:
16450
diff
changeset
|
62 connect (this, SIGNAL (displayed_directory_changed (const QString&)), |
38ed6bdd1f7f
move signal/slot connections from main window to sub window where possible
John W. Eaton <jwe@octave.org>
parents:
16450
diff
changeset
|
63 parent (), SLOT (set_current_working_directory (const QString&))); |
38ed6bdd1f7f
move signal/slot connections from main window to sub window where possible
John W. Eaton <jwe@octave.org>
parents:
16450
diff
changeset
|
64 |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
65 // Create a toolbar |
16525
e192525236ad
configurable size of toolbar icons
Torsten <ttl@justmail.de>
parents:
16515
diff
changeset
|
66 _navigation_tool_bar = new QToolBar ("", container); |
e192525236ad
configurable size of toolbar icons
Torsten <ttl@justmail.de>
parents:
16515
diff
changeset
|
67 _navigation_tool_bar->setAllowedAreas (Qt::TopToolBarArea); |
e192525236ad
configurable size of toolbar icons
Torsten <ttl@justmail.de>
parents:
16515
diff
changeset
|
68 _navigation_tool_bar->setMovable (false); |
13501 | 69 |
16525
e192525236ad
configurable size of toolbar icons
Torsten <ttl@justmail.de>
parents:
16515
diff
changeset
|
70 _current_directory = new QComboBox (_navigation_tool_bar); |
16499
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
71 _current_directory->setToolTip (tr ("Enter the path or filename")); |
16498
605d7f0ee0d8
Added Filesdockwidget recently viewed directory pulldownlist
John Donoghue <john.donoghue@ieee.org>
parents:
16487
diff
changeset
|
72 _current_directory->setEditable(true); |
605d7f0ee0d8
Added Filesdockwidget recently viewed directory pulldownlist
John Donoghue <john.donoghue@ieee.org>
parents:
16487
diff
changeset
|
73 _current_directory->setMaxCount(MaxMRUDirs); |
605d7f0ee0d8
Added Filesdockwidget recently viewed directory pulldownlist
John Donoghue <john.donoghue@ieee.org>
parents:
16487
diff
changeset
|
74 _current_directory->setInsertPolicy(QComboBox::NoInsert); |
16499
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
75 _current_directory->setSizeAdjustPolicy (QComboBox::AdjustToMinimumContentsLengthWithIcon); |
16498
605d7f0ee0d8
Added Filesdockwidget recently viewed directory pulldownlist
John Donoghue <john.donoghue@ieee.org>
parents:
16487
diff
changeset
|
76 QSizePolicy sizePol(QSizePolicy::Expanding, QSizePolicy::Preferred); |
605d7f0ee0d8
Added Filesdockwidget recently viewed directory pulldownlist
John Donoghue <john.donoghue@ieee.org>
parents:
16487
diff
changeset
|
77 _current_directory->setSizePolicy(sizePol); |
13501 | 78 |
16499
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
79 QAction *directory_up_action = new QAction (QIcon(":/actions/icons/up.png"), |
16525
e192525236ad
configurable size of toolbar icons
Torsten <ttl@justmail.de>
parents:
16515
diff
changeset
|
80 "", _navigation_tool_bar); |
16499
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
81 directory_up_action->setToolTip (tr ("Move up one directory")); |
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
82 |
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
83 _sync_browser_directory_action = new QAction (QIcon(":/actions/icons/reload.png"), |
16542
016073c0cb94
Add popdown toolbutton to files-dock-window toolbar.
John Donoghue <john.donoghue@ieee.org>
parents:
16525
diff
changeset
|
84 tr("Show octave directory"), _navigation_tool_bar); |
16499
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
85 _sync_browser_directory_action->setToolTip (tr ("Goto current octave directory")); |
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
86 _sync_browser_directory_action->setEnabled ("false"); |
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
87 |
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
88 _sync_octave_directory_action = new QAction (QIcon(":/actions/icons/ok.png"), |
16542
016073c0cb94
Add popdown toolbutton to files-dock-window toolbar.
John Donoghue <john.donoghue@ieee.org>
parents:
16525
diff
changeset
|
89 tr("Set octave directory"), _navigation_tool_bar); |
16499
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
90 _sync_octave_directory_action->setToolTip (tr ("Set octave directroy to current browser directory")); |
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
91 _sync_octave_directory_action->setEnabled ("false"); |
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
92 |
16542
016073c0cb94
Add popdown toolbutton to files-dock-window toolbar.
John Donoghue <john.donoghue@ieee.org>
parents:
16525
diff
changeset
|
93 QToolButton * popdown_button = new QToolButton(); |
016073c0cb94
Add popdown toolbutton to files-dock-window toolbar.
John Donoghue <john.donoghue@ieee.org>
parents:
16525
diff
changeset
|
94 popdown_button->setToolTip(tr ("Actions on current directory")); |
016073c0cb94
Add popdown toolbutton to files-dock-window toolbar.
John Donoghue <john.donoghue@ieee.org>
parents:
16525
diff
changeset
|
95 QMenu * popdown_menu = new QMenu(); |
016073c0cb94
Add popdown toolbutton to files-dock-window toolbar.
John Donoghue <john.donoghue@ieee.org>
parents:
16525
diff
changeset
|
96 popdown_menu->addAction(_sync_browser_directory_action); |
016073c0cb94
Add popdown toolbutton to files-dock-window toolbar.
John Donoghue <john.donoghue@ieee.org>
parents:
16525
diff
changeset
|
97 popdown_menu->addAction(_sync_octave_directory_action); |
016073c0cb94
Add popdown toolbutton to files-dock-window toolbar.
John Donoghue <john.donoghue@ieee.org>
parents:
16525
diff
changeset
|
98 popdown_button->setMenu(popdown_menu); |
016073c0cb94
Add popdown toolbutton to files-dock-window toolbar.
John Donoghue <john.donoghue@ieee.org>
parents:
16525
diff
changeset
|
99 popdown_button->setPopupMode(QToolButton::InstantPopup); |
016073c0cb94
Add popdown toolbutton to files-dock-window toolbar.
John Donoghue <john.donoghue@ieee.org>
parents:
16525
diff
changeset
|
100 popdown_button->setDefaultAction(new QAction(QIcon(":/actions/icons/gear.png"),"", _navigation_tool_bar)); |
016073c0cb94
Add popdown toolbutton to files-dock-window toolbar.
John Donoghue <john.donoghue@ieee.org>
parents:
16525
diff
changeset
|
101 |
016073c0cb94
Add popdown toolbutton to files-dock-window toolbar.
John Donoghue <john.donoghue@ieee.org>
parents:
16525
diff
changeset
|
102 popdown_menu->addSeparator(); |
016073c0cb94
Add popdown toolbutton to files-dock-window toolbar.
John Donoghue <john.donoghue@ieee.org>
parents:
16525
diff
changeset
|
103 popdown_menu->addAction(QIcon(":/actions/icons/filenew.png"), |
016073c0cb94
Add popdown toolbutton to files-dock-window toolbar.
John Donoghue <john.donoghue@ieee.org>
parents:
16525
diff
changeset
|
104 tr ("New File"), |
016073c0cb94
Add popdown toolbutton to files-dock-window toolbar.
John Donoghue <john.donoghue@ieee.org>
parents:
16525
diff
changeset
|
105 this, SLOT(popdownmenu_newfile(bool))); |
016073c0cb94
Add popdown toolbutton to files-dock-window toolbar.
John Donoghue <john.donoghue@ieee.org>
parents:
16525
diff
changeset
|
106 popdown_menu->addAction(QIcon(":/actions/icons/folder_new.png"), |
016073c0cb94
Add popdown toolbutton to files-dock-window toolbar.
John Donoghue <john.donoghue@ieee.org>
parents:
16525
diff
changeset
|
107 tr ("New Directory"), |
016073c0cb94
Add popdown toolbutton to files-dock-window toolbar.
John Donoghue <john.donoghue@ieee.org>
parents:
16525
diff
changeset
|
108 this, SLOT(popdownmenu_newdir(bool))); |
016073c0cb94
Add popdown toolbutton to files-dock-window toolbar.
John Donoghue <john.donoghue@ieee.org>
parents:
16525
diff
changeset
|
109 |
16525
e192525236ad
configurable size of toolbar icons
Torsten <ttl@justmail.de>
parents:
16515
diff
changeset
|
110 _navigation_tool_bar->addWidget (_current_directory); |
e192525236ad
configurable size of toolbar icons
Torsten <ttl@justmail.de>
parents:
16515
diff
changeset
|
111 _navigation_tool_bar->addAction (directory_up_action); |
16542
016073c0cb94
Add popdown toolbutton to files-dock-window toolbar.
John Donoghue <john.donoghue@ieee.org>
parents:
16525
diff
changeset
|
112 _navigation_tool_bar->addWidget (popdown_button); |
16499
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
113 |
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
114 connect (directory_up_action, SIGNAL (triggered ()), this, |
16437
919796a440c6
use signal for changing directory
John W. Eaton <jwe@octave.org>
parents:
16413
diff
changeset
|
115 SLOT (change_directory_up ())); |
16499
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
116 connect (_sync_octave_directory_action, SIGNAL (triggered ()), this, |
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
117 SLOT (do_sync_octave_directory ())); |
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
118 connect (_sync_browser_directory_action, SIGNAL (triggered ()), this, |
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
119 SLOT (do_sync_browser_directory ())); |
13501 | 120 |
16510
e22604d4bf85
* files-dock-widget.cc(constructor): initial dir is where octave was started
Torsten <ttl@justmail.de>
parents:
16509
diff
changeset
|
121 // Create the QFileSystemModel starting in the actual directory |
e22604d4bf85
* files-dock-widget.cc(constructor): initial dir is where octave was started
Torsten <ttl@justmail.de>
parents:
16509
diff
changeset
|
122 QDir curr_dir; |
14712
5cb54cca8a06
Completion of code reformatting.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14709
diff
changeset
|
123 _file_system_model = new QFileSystemModel (this); |
5cb54cca8a06
Completion of code reformatting.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14709
diff
changeset
|
124 _file_system_model->setFilter (QDir::NoDotAndDotDot | QDir::AllEntries); |
16510
e22604d4bf85
* files-dock-widget.cc(constructor): initial dir is where octave was started
Torsten <ttl@justmail.de>
parents:
16509
diff
changeset
|
125 QModelIndex rootPathIndex = _file_system_model->setRootPath ( |
e22604d4bf85
* files-dock-widget.cc(constructor): initial dir is where octave was started
Torsten <ttl@justmail.de>
parents:
16509
diff
changeset
|
126 curr_dir.absolutePath ()); |
13501 | 127 |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
128 // Attach the model to the QTreeView and set the root index |
16450
3207f1d62e74
improve encapsulation of file browser window object
John W. Eaton <jwe@octave.org>
parents:
16437
diff
changeset
|
129 _file_tree_view = new QTreeView (container); |
14712
5cb54cca8a06
Completion of code reformatting.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14709
diff
changeset
|
130 _file_tree_view->setModel (_file_system_model); |
5cb54cca8a06
Completion of code reformatting.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14709
diff
changeset
|
131 _file_tree_view->setRootIndex (rootPathIndex); |
5cb54cca8a06
Completion of code reformatting.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14709
diff
changeset
|
132 _file_tree_view->setSortingEnabled (true); |
5cb54cca8a06
Completion of code reformatting.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14709
diff
changeset
|
133 _file_tree_view->setAlternatingRowColors (true); |
5cb54cca8a06
Completion of code reformatting.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14709
diff
changeset
|
134 _file_tree_view->setAnimated (true); |
16499
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
135 _file_tree_view->setToolTip (tr ("Doubleclick a file to open it")); |
13549
807e5e9b7591
Added lots of status tips.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13539
diff
changeset
|
136 |
15461
1e64aff609c3
save/restore column state and sorting (column and order) in files-widget
Torsten <ttl@justmail.de>
parents:
15368
diff
changeset
|
137 // get sort column and order as well as cloumn state (order and width) |
1e64aff609c3
save/restore column state and sorting (column and order) in files-widget
Torsten <ttl@justmail.de>
parents:
15368
diff
changeset
|
138 QSettings *settings = resource_manager::get_settings (); |
1e64aff609c3
save/restore column state and sorting (column and order) in files-widget
Torsten <ttl@justmail.de>
parents:
15368
diff
changeset
|
139 // FIXME -- what should happen if settings is 0? |
1e64aff609c3
save/restore column state and sorting (column and order) in files-widget
Torsten <ttl@justmail.de>
parents:
15368
diff
changeset
|
140 _file_tree_view->sortByColumn ( |
1e64aff609c3
save/restore column state and sorting (column and order) in files-widget
Torsten <ttl@justmail.de>
parents:
15368
diff
changeset
|
141 settings->value ("filesdockwidget/sort_files_by_column",0).toInt (), |
1e64aff609c3
save/restore column state and sorting (column and order) in files-widget
Torsten <ttl@justmail.de>
parents:
15368
diff
changeset
|
142 static_cast<Qt::SortOrder>(settings->value ("filesdockwidget/sort_files_by_order",Qt::AscendingOrder).toUInt ()) |
1e64aff609c3
save/restore column state and sorting (column and order) in files-widget
Torsten <ttl@justmail.de>
parents:
15368
diff
changeset
|
143 ); |
1e64aff609c3
save/restore column state and sorting (column and order) in files-widget
Torsten <ttl@justmail.de>
parents:
15368
diff
changeset
|
144 _file_tree_view->header ()->restoreState (settings->value ("filesdockwidget/column_state").toByteArray ()); |
1e64aff609c3
save/restore column state and sorting (column and order) in files-widget
Torsten <ttl@justmail.de>
parents:
15368
diff
changeset
|
145 |
16498
605d7f0ee0d8
Added Filesdockwidget recently viewed directory pulldownlist
John Donoghue <john.donoghue@ieee.org>
parents:
16487
diff
changeset
|
146 QStringList mru_dirs = settings->value ("filesdockwidget/mru_dir_list").toStringList (); |
605d7f0ee0d8
Added Filesdockwidget recently viewed directory pulldownlist
John Donoghue <john.donoghue@ieee.org>
parents:
16487
diff
changeset
|
147 _current_directory->addItems(mru_dirs); |
605d7f0ee0d8
Added Filesdockwidget recently viewed directory pulldownlist
John Donoghue <john.donoghue@ieee.org>
parents:
16487
diff
changeset
|
148 |
605d7f0ee0d8
Added Filesdockwidget recently viewed directory pulldownlist
John Donoghue <john.donoghue@ieee.org>
parents:
16487
diff
changeset
|
149 _current_directory->setEditText(_file_system_model->fileInfo (rootPathIndex). |
15367
501a9cc2c68f
maint: whitespace cleanup in GUI code
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15300
diff
changeset
|
150 absoluteFilePath ()); |
13501 | 151 |
16450
3207f1d62e74
improve encapsulation of file browser window object
John W. Eaton <jwe@octave.org>
parents:
16437
diff
changeset
|
152 connect (_file_tree_view, SIGNAL (doubleClicked (const QModelIndex &)), |
3207f1d62e74
improve encapsulation of file browser window object
John W. Eaton <jwe@octave.org>
parents:
16437
diff
changeset
|
153 this, SLOT (item_double_clicked (const QModelIndex &))); |
13501 | 154 |
16503
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
155 // add context menu to tree_view |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
156 _file_tree_view->setContextMenuPolicy(Qt::CustomContextMenu); |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
157 connect(_file_tree_view, SIGNAL(customContextMenuRequested(const QPoint &)), |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
158 this, SLOT(contextmenu_requested(const QPoint &))); |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
159 |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
160 // Layout the widgets vertically with the toolbar on top |
15368
36ececf69385
avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents:
15367
diff
changeset
|
161 QVBoxLayout *vbox_layout = new QVBoxLayout (); |
36ececf69385
avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents:
15367
diff
changeset
|
162 vbox_layout->setSpacing (0); |
16525
e192525236ad
configurable size of toolbar icons
Torsten <ttl@justmail.de>
parents:
16515
diff
changeset
|
163 vbox_layout->addWidget (_navigation_tool_bar); |
15368
36ececf69385
avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents:
15367
diff
changeset
|
164 vbox_layout->addWidget (_file_tree_view); |
36ececf69385
avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents:
15367
diff
changeset
|
165 vbox_layout->setMargin (1); |
16450
3207f1d62e74
improve encapsulation of file browser window object
John W. Eaton <jwe@octave.org>
parents:
16437
diff
changeset
|
166 |
3207f1d62e74
improve encapsulation of file browser window object
John W. Eaton <jwe@octave.org>
parents:
16437
diff
changeset
|
167 container->setLayout (vbox_layout); |
3207f1d62e74
improve encapsulation of file browser window object
John W. Eaton <jwe@octave.org>
parents:
16437
diff
changeset
|
168 |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
169 // TODO: Add right-click contextual menus for copying, pasting, deleting files (and others) |
13501 | 170 |
16498
605d7f0ee0d8
Added Filesdockwidget recently viewed directory pulldownlist
John Donoghue <john.donoghue@ieee.org>
parents:
16487
diff
changeset
|
171 connect (_current_directory->lineEdit(), SIGNAL (returnPressed ()), |
605d7f0ee0d8
Added Filesdockwidget recently viewed directory pulldownlist
John Donoghue <john.donoghue@ieee.org>
parents:
16487
diff
changeset
|
172 this, SLOT (accept_directory_line_edit ())); |
605d7f0ee0d8
Added Filesdockwidget recently viewed directory pulldownlist
John Donoghue <john.donoghue@ieee.org>
parents:
16487
diff
changeset
|
173 |
605d7f0ee0d8
Added Filesdockwidget recently viewed directory pulldownlist
John Donoghue <john.donoghue@ieee.org>
parents:
16487
diff
changeset
|
174 connect (_current_directory, SIGNAL (activated (const QString &)), |
605d7f0ee0d8
Added Filesdockwidget recently viewed directory pulldownlist
John Donoghue <john.donoghue@ieee.org>
parents:
16487
diff
changeset
|
175 this, SLOT (set_current_directory (const QString &))); |
14803
625be3eb27c5
Current directories now synchronize on top, in the file browser and the cwd in octave.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14728
diff
changeset
|
176 |
16506
8a4960f2c7c3
gui: allow running files from the file browser
Torsten <ttl@justmail.de>
parents:
16504
diff
changeset
|
177 connect (this, SIGNAL (run_file_signal (const QString&)), |
16570
d5ae5aa80d42
preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents:
16562
diff
changeset
|
178 parent (), SLOT (execute_command_in_terminal (const QString&))); |
16506
8a4960f2c7c3
gui: allow running files from the file browser
Torsten <ttl@justmail.de>
parents:
16504
diff
changeset
|
179 |
16450
3207f1d62e74
improve encapsulation of file browser window object
John W. Eaton <jwe@octave.org>
parents:
16437
diff
changeset
|
180 QCompleter *completer = new QCompleter (_file_system_model, this); |
14712
5cb54cca8a06
Completion of code reformatting.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14709
diff
changeset
|
181 _current_directory->setCompleter (completer); |
13577
e440b3f32f02
Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13549
diff
changeset
|
182 |
14812
9d9eb9bac65e
Improved menu structure of file, edit and window menu. Removed ambiguous shortcuts, improved focus handling for operating the GUI with the keyboard. Added new shortcuts to focus subwindows directly.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14803
diff
changeset
|
183 setFocusProxy (_current_directory); |
16499
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
184 |
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
185 _sync_octave_dir = true; // default, overwirtten with notice_settings () |
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
186 _octave_dir = ""; |
13501 | 187 } |
188 | |
15461
1e64aff609c3
save/restore column state and sorting (column and order) in files-widget
Torsten <ttl@justmail.de>
parents:
15368
diff
changeset
|
189 files_dock_widget::~files_dock_widget () |
1e64aff609c3
save/restore column state and sorting (column and order) in files-widget
Torsten <ttl@justmail.de>
parents:
15368
diff
changeset
|
190 { |
1e64aff609c3
save/restore column state and sorting (column and order) in files-widget
Torsten <ttl@justmail.de>
parents:
15368
diff
changeset
|
191 QSettings *settings = resource_manager::get_settings (); |
1e64aff609c3
save/restore column state and sorting (column and order) in files-widget
Torsten <ttl@justmail.de>
parents:
15368
diff
changeset
|
192 int sort_column = _file_tree_view->header ()->sortIndicatorSection (); |
1e64aff609c3
save/restore column state and sorting (column and order) in files-widget
Torsten <ttl@justmail.de>
parents:
15368
diff
changeset
|
193 Qt::SortOrder sort_order = _file_tree_view->header ()->sortIndicatorOrder (); |
1e64aff609c3
save/restore column state and sorting (column and order) in files-widget
Torsten <ttl@justmail.de>
parents:
15368
diff
changeset
|
194 settings->setValue ("filesdockwidget/sort_files_by_column", sort_column); |
1e64aff609c3
save/restore column state and sorting (column and order) in files-widget
Torsten <ttl@justmail.de>
parents:
15368
diff
changeset
|
195 settings->setValue ("filesdockwidget/sort_files_by_order", sort_order); |
16175
6f83158c714c
gui: make sure settings are really written into the settings file
Torsten <ttl@justmail.de>
parents:
16057
diff
changeset
|
196 settings->setValue ("filesdockwidget/column_state", _file_tree_view->header ()->saveState ()); |
16498
605d7f0ee0d8
Added Filesdockwidget recently viewed directory pulldownlist
John Donoghue <john.donoghue@ieee.org>
parents:
16487
diff
changeset
|
197 |
605d7f0ee0d8
Added Filesdockwidget recently viewed directory pulldownlist
John Donoghue <john.donoghue@ieee.org>
parents:
16487
diff
changeset
|
198 QStringList dirs; |
605d7f0ee0d8
Added Filesdockwidget recently viewed directory pulldownlist
John Donoghue <john.donoghue@ieee.org>
parents:
16487
diff
changeset
|
199 for(int i=0; i< _current_directory->count(); i++) |
605d7f0ee0d8
Added Filesdockwidget recently viewed directory pulldownlist
John Donoghue <john.donoghue@ieee.org>
parents:
16487
diff
changeset
|
200 { |
605d7f0ee0d8
Added Filesdockwidget recently viewed directory pulldownlist
John Donoghue <john.donoghue@ieee.org>
parents:
16487
diff
changeset
|
201 dirs.append(_current_directory->itemText(i)); |
605d7f0ee0d8
Added Filesdockwidget recently viewed directory pulldownlist
John Donoghue <john.donoghue@ieee.org>
parents:
16487
diff
changeset
|
202 } |
605d7f0ee0d8
Added Filesdockwidget recently viewed directory pulldownlist
John Donoghue <john.donoghue@ieee.org>
parents:
16487
diff
changeset
|
203 settings->setValue ("filesdockwidget/mru_dir_list", dirs); |
605d7f0ee0d8
Added Filesdockwidget recently viewed directory pulldownlist
John Donoghue <john.donoghue@ieee.org>
parents:
16487
diff
changeset
|
204 |
16175
6f83158c714c
gui: make sure settings are really written into the settings file
Torsten <ttl@justmail.de>
parents:
16057
diff
changeset
|
205 settings->sync (); |
15461
1e64aff609c3
save/restore column state and sorting (column and order) in files-widget
Torsten <ttl@justmail.de>
parents:
15368
diff
changeset
|
206 } |
1e64aff609c3
save/restore column state and sorting (column and order) in files-widget
Torsten <ttl@justmail.de>
parents:
15368
diff
changeset
|
207 |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
208 void |
16437
919796a440c6
use signal for changing directory
John W. Eaton <jwe@octave.org>
parents:
16413
diff
changeset
|
209 files_dock_widget::item_double_clicked (const QModelIndex& index) |
13501 | 210 { |
13531
bb3676025b36
User can set a custom file editor instead of the built-in one.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13522
diff
changeset
|
211 // Retrieve the file info associated with the model index. |
14712
5cb54cca8a06
Completion of code reformatting.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14709
diff
changeset
|
212 QFileInfo fileInfo = _file_system_model->fileInfo (index); |
16437
919796a440c6
use signal for changing directory
John W. Eaton <jwe@octave.org>
parents:
16413
diff
changeset
|
213 set_current_directory (fileInfo.absoluteFilePath ()); |
13501 | 214 } |
215 | |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
216 void |
16437
919796a440c6
use signal for changing directory
John W. Eaton <jwe@octave.org>
parents:
16413
diff
changeset
|
217 files_dock_widget::set_current_directory (const QString& dir) |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
218 { |
16437
919796a440c6
use signal for changing directory
John W. Eaton <jwe@octave.org>
parents:
16413
diff
changeset
|
219 display_directory (dir); |
14803
625be3eb27c5
Current directories now synchronize on top, in the file browser and the cwd in octave.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14728
diff
changeset
|
220 } |
625be3eb27c5
Current directories now synchronize on top, in the file browser and the cwd in octave.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14728
diff
changeset
|
221 |
625be3eb27c5
Current directories now synchronize on top, in the file browser and the cwd in octave.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14728
diff
changeset
|
222 void |
16437
919796a440c6
use signal for changing directory
John W. Eaton <jwe@octave.org>
parents:
16413
diff
changeset
|
223 files_dock_widget::accept_directory_line_edit (void) |
14803
625be3eb27c5
Current directories now synchronize on top, in the file browser and the cwd in octave.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14728
diff
changeset
|
224 { |
16498
605d7f0ee0d8
Added Filesdockwidget recently viewed directory pulldownlist
John Donoghue <john.donoghue@ieee.org>
parents:
16487
diff
changeset
|
225 display_directory (_current_directory->currentText ()); |
14803
625be3eb27c5
Current directories now synchronize on top, in the file browser and the cwd in octave.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14728
diff
changeset
|
226 } |
625be3eb27c5
Current directories now synchronize on top, in the file browser and the cwd in octave.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14728
diff
changeset
|
227 |
625be3eb27c5
Current directories now synchronize on top, in the file browser and the cwd in octave.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14728
diff
changeset
|
228 void |
16437
919796a440c6
use signal for changing directory
John W. Eaton <jwe@octave.org>
parents:
16413
diff
changeset
|
229 files_dock_widget::change_directory_up (void) |
14803
625be3eb27c5
Current directories now synchronize on top, in the file browser and the cwd in octave.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14728
diff
changeset
|
230 { |
625be3eb27c5
Current directories now synchronize on top, in the file browser and the cwd in octave.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14728
diff
changeset
|
231 QDir dir = QDir (_file_system_model->filePath (_file_tree_view->rootIndex ())); |
625be3eb27c5
Current directories now synchronize on top, in the file browser and the cwd in octave.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14728
diff
changeset
|
232 dir.cdUp (); |
625be3eb27c5
Current directories now synchronize on top, in the file browser and the cwd in octave.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14728
diff
changeset
|
233 display_directory (dir.absolutePath ()); |
13501 | 234 } |
235 | |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
236 void |
16499
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
237 files_dock_widget::do_sync_octave_directory (void) |
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
238 { |
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
239 QDir dir = QDir (_file_system_model->filePath (_file_tree_view->rootIndex ())); |
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
240 emit displayed_directory_changed (dir.absolutePath ()); |
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
241 } |
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
242 |
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
243 void |
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
244 files_dock_widget::do_sync_browser_directory (void) |
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
245 { |
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
246 display_directory (_octave_dir,false); // false: no sync of octave dir |
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
247 } |
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
248 |
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
249 void |
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
250 files_dock_widget::update_octave_directory (const QString& dir) |
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
251 { |
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
252 _octave_dir = dir; |
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
253 if (_sync_octave_dir) |
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
254 display_directory (_octave_dir,false); // false: no sync of octave dir |
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
255 } |
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
256 |
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
257 void |
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
258 files_dock_widget::display_directory (const QString& dir, bool set_octave_dir) |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
259 { |
16437
919796a440c6
use signal for changing directory
John W. Eaton <jwe@octave.org>
parents:
16413
diff
changeset
|
260 QFileInfo fileInfo (dir); |
14803
625be3eb27c5
Current directories now synchronize on top, in the file browser and the cwd in octave.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14728
diff
changeset
|
261 if (fileInfo.exists ()) |
625be3eb27c5
Current directories now synchronize on top, in the file browser and the cwd in octave.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14728
diff
changeset
|
262 { |
625be3eb27c5
Current directories now synchronize on top, in the file browser and the cwd in octave.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14728
diff
changeset
|
263 if (fileInfo.isDir ()) |
625be3eb27c5
Current directories now synchronize on top, in the file browser and the cwd in octave.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14728
diff
changeset
|
264 { |
625be3eb27c5
Current directories now synchronize on top, in the file browser and the cwd in octave.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14728
diff
changeset
|
265 _file_tree_view->setRootIndex (_file_system_model-> |
15367
501a9cc2c68f
maint: whitespace cleanup in GUI code
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15300
diff
changeset
|
266 index (fileInfo.absoluteFilePath ())); |
14803
625be3eb27c5
Current directories now synchronize on top, in the file browser and the cwd in octave.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14728
diff
changeset
|
267 _file_system_model->setRootPath (fileInfo.absoluteFilePath ()); |
16437
919796a440c6
use signal for changing directory
John W. Eaton <jwe@octave.org>
parents:
16413
diff
changeset
|
268 _file_system_model->sort (0, Qt::AscendingOrder); |
16499
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
269 if (_sync_octave_dir && set_octave_dir) |
16542
016073c0cb94
Add popdown toolbutton to files-dock-window toolbar.
John Donoghue <john.donoghue@ieee.org>
parents:
16525
diff
changeset
|
270 process_set_current_dir(fileInfo.absoluteFilePath ()); |
16498
605d7f0ee0d8
Added Filesdockwidget recently viewed directory pulldownlist
John Donoghue <john.donoghue@ieee.org>
parents:
16487
diff
changeset
|
271 |
605d7f0ee0d8
Added Filesdockwidget recently viewed directory pulldownlist
John Donoghue <john.donoghue@ieee.org>
parents:
16487
diff
changeset
|
272 // see if its in the list, and if it is, remove it and then, put at top of the list |
605d7f0ee0d8
Added Filesdockwidget recently viewed directory pulldownlist
John Donoghue <john.donoghue@ieee.org>
parents:
16487
diff
changeset
|
273 int index = _current_directory->findText(fileInfo.absoluteFilePath ()); |
605d7f0ee0d8
Added Filesdockwidget recently viewed directory pulldownlist
John Donoghue <john.donoghue@ieee.org>
parents:
16487
diff
changeset
|
274 if(index != -1) |
605d7f0ee0d8
Added Filesdockwidget recently viewed directory pulldownlist
John Donoghue <john.donoghue@ieee.org>
parents:
16487
diff
changeset
|
275 { |
605d7f0ee0d8
Added Filesdockwidget recently viewed directory pulldownlist
John Donoghue <john.donoghue@ieee.org>
parents:
16487
diff
changeset
|
276 _current_directory->removeItem(index); |
605d7f0ee0d8
Added Filesdockwidget recently viewed directory pulldownlist
John Donoghue <john.donoghue@ieee.org>
parents:
16487
diff
changeset
|
277 } |
605d7f0ee0d8
Added Filesdockwidget recently viewed directory pulldownlist
John Donoghue <john.donoghue@ieee.org>
parents:
16487
diff
changeset
|
278 _current_directory->insertItem(0, fileInfo.absoluteFilePath ()); |
605d7f0ee0d8
Added Filesdockwidget recently viewed directory pulldownlist
John Donoghue <john.donoghue@ieee.org>
parents:
16487
diff
changeset
|
279 _current_directory->setCurrentIndex(0); |
14803
625be3eb27c5
Current directories now synchronize on top, in the file browser and the cwd in octave.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14728
diff
changeset
|
280 } |
625be3eb27c5
Current directories now synchronize on top, in the file browser and the cwd in octave.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14728
diff
changeset
|
281 else |
625be3eb27c5
Current directories now synchronize on top, in the file browser and the cwd in octave.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14728
diff
changeset
|
282 { |
16555
04fb96f4bea1
allow double-click in file browser to load data files
John W. Eaton <jwe@octave.org>
parents:
16542
diff
changeset
|
283 QString abs_fname = fileInfo.absoluteFilePath (); |
04fb96f4bea1
allow double-click in file browser to load data files
John W. Eaton <jwe@octave.org>
parents:
16542
diff
changeset
|
284 |
04fb96f4bea1
allow double-click in file browser to load data files
John W. Eaton <jwe@octave.org>
parents:
16542
diff
changeset
|
285 if (QFile::exists (abs_fname)) |
04fb96f4bea1
allow double-click in file browser to load data files
John W. Eaton <jwe@octave.org>
parents:
16542
diff
changeset
|
286 { |
04fb96f4bea1
allow double-click in file browser to load data files
John W. Eaton <jwe@octave.org>
parents:
16542
diff
changeset
|
287 if (is_octave_data_file (abs_fname.toStdString ())) |
04fb96f4bea1
allow double-click in file browser to load data files
John W. Eaton <jwe@octave.org>
parents:
16542
diff
changeset
|
288 emit load_file_signal (abs_fname); |
04fb96f4bea1
allow double-click in file browser to load data files
John W. Eaton <jwe@octave.org>
parents:
16542
diff
changeset
|
289 else |
16562
fb8fe0ed4bbb
* files-doc-widget.cc: Undo unintended changes from changeset 5fc1ce2947bd.
John W. Eaton <jwe@octave.org>
parents:
16558
diff
changeset
|
290 emit open_file (fileInfo.absoluteFilePath ()); |
16555
04fb96f4bea1
allow double-click in file browser to load data files
John W. Eaton <jwe@octave.org>
parents:
16542
diff
changeset
|
291 } |
14803
625be3eb27c5
Current directories now synchronize on top, in the file browser and the cwd in octave.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14728
diff
changeset
|
292 } |
13501 | 293 } |
294 } | |
13536
869c62c15e95
Few minor improvements, added advanced settings for file browser.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13535
diff
changeset
|
295 |
16594
3ce0c312a40b
contextmenu for opening files in default applications
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
296 void |
3ce0c312a40b
contextmenu for opening files in default applications
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
297 files_dock_widget::open_item_in_app (const QModelIndex& index) |
3ce0c312a40b
contextmenu for opening files in default applications
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
298 { |
3ce0c312a40b
contextmenu for opening files in default applications
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
299 // Retrieve the file info associated with the model index. |
3ce0c312a40b
contextmenu for opening files in default applications
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
300 QFileInfo fileInfo = _file_system_model->fileInfo (index); |
3ce0c312a40b
contextmenu for opening files in default applications
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
301 |
3ce0c312a40b
contextmenu for opening files in default applications
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
302 QString file = fileInfo.absoluteFilePath (); |
3ce0c312a40b
contextmenu for opening files in default applications
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
303 |
3ce0c312a40b
contextmenu for opening files in default applications
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
304 QDesktopServices::openUrl (QUrl::fromLocalFile (file)); |
3ce0c312a40b
contextmenu for opening files in default applications
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
305 } |
3ce0c312a40b
contextmenu for opening files in default applications
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
306 |
16503
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
307 void |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
308 files_dock_widget::contextmenu_requested (const QPoint& mpos) |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
309 { |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
310 |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
311 QMenu menu(this); |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
312 |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
313 QModelIndex index = _file_tree_view->indexAt (mpos); |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
314 //QAbstractItemModel *m = _file_tree_view->model (); |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
315 |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
316 if (index.isValid()) |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
317 { |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
318 QFileInfo info = _file_system_model->fileInfo(index); |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
319 |
16515
87b78e75a2b9
gui: undo disabling menu entries in context menu of file browser
Torsten <ttl@justmail.de>
parents:
16510
diff
changeset
|
320 menu.addAction (QIcon (":/actions/icons/fileopen.png"), tr("Open"), |
16507
8cb12cf9ca32
gui: add icons to the context menu of the the file browser
Torsten <ttl@justmail.de>
parents:
16506
diff
changeset
|
321 this, SLOT(contextmenu_open(bool))); |
16594
3ce0c312a40b
contextmenu for opening files in default applications
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
322 |
3ce0c312a40b
contextmenu for opening files in default applications
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
323 menu.addAction (tr("Open in Default Application"), |
3ce0c312a40b
contextmenu for opening files in default applications
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
324 this, SLOT (contextmenu_open_in_app (bool))); |
3ce0c312a40b
contextmenu for opening files in default applications
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
325 |
16515
87b78e75a2b9
gui: undo disabling menu entries in context menu of file browser
Torsten <ttl@justmail.de>
parents:
16510
diff
changeset
|
326 if (info.isFile () && info.suffix () == "m") |
87b78e75a2b9
gui: undo disabling menu entries in context menu of file browser
Torsten <ttl@justmail.de>
parents:
16510
diff
changeset
|
327 menu.addAction (QIcon (":/actions/icons/artsbuilderexecute.png"), |
87b78e75a2b9
gui: undo disabling menu entries in context menu of file browser
Torsten <ttl@justmail.de>
parents:
16510
diff
changeset
|
328 tr("Run"), this, SLOT(contextmenu_run(bool))); |
16594
3ce0c312a40b
contextmenu for opening files in default applications
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
329 |
16515
87b78e75a2b9
gui: undo disabling menu entries in context menu of file browser
Torsten <ttl@justmail.de>
parents:
16510
diff
changeset
|
330 if (info.isFile ()) |
87b78e75a2b9
gui: undo disabling menu entries in context menu of file browser
Torsten <ttl@justmail.de>
parents:
16510
diff
changeset
|
331 menu.addAction (tr("Load Data"), this, SLOT(contextmenu_load(bool))); |
16507
8cb12cf9ca32
gui: add icons to the context menu of the the file browser
Torsten <ttl@justmail.de>
parents:
16506
diff
changeset
|
332 |
16509
14045b872a3d
Add set current directory context menu to file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16507
diff
changeset
|
333 if (info.isDir ()) |
14045b872a3d
Add set current directory context menu to file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16507
diff
changeset
|
334 { |
14045b872a3d
Add set current directory context menu to file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16507
diff
changeset
|
335 menu.addSeparator (); |
16515
87b78e75a2b9
gui: undo disabling menu entries in context menu of file browser
Torsten <ttl@justmail.de>
parents:
16510
diff
changeset
|
336 menu.addAction (QIcon (":/actions/icons/ok.png"), |
87b78e75a2b9
gui: undo disabling menu entries in context menu of file browser
Torsten <ttl@justmail.de>
parents:
16510
diff
changeset
|
337 tr ("Set Current Directory"), |
16509
14045b872a3d
Add set current directory context menu to file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16507
diff
changeset
|
338 this, SLOT (contextmenu_setcurrentdir (bool))); |
14045b872a3d
Add set current directory context menu to file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16507
diff
changeset
|
339 } |
14045b872a3d
Add set current directory context menu to file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16507
diff
changeset
|
340 |
16503
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
341 menu.addSeparator(); |
16515
87b78e75a2b9
gui: undo disabling menu entries in context menu of file browser
Torsten <ttl@justmail.de>
parents:
16510
diff
changeset
|
342 menu.addAction (tr ("Rename"), this, SLOT(contextmenu_rename(bool))); |
87b78e75a2b9
gui: undo disabling menu entries in context menu of file browser
Torsten <ttl@justmail.de>
parents:
16510
diff
changeset
|
343 menu.addAction (QIcon(":/actions/icons/editdelete.png"), tr("Delete"), |
87b78e75a2b9
gui: undo disabling menu entries in context menu of file browser
Torsten <ttl@justmail.de>
parents:
16510
diff
changeset
|
344 this, SLOT(contextmenu_delete(bool))); |
16503
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
345 |
16515
87b78e75a2b9
gui: undo disabling menu entries in context menu of file browser
Torsten <ttl@justmail.de>
parents:
16510
diff
changeset
|
346 if (info.isDir()) |
87b78e75a2b9
gui: undo disabling menu entries in context menu of file browser
Torsten <ttl@justmail.de>
parents:
16510
diff
changeset
|
347 { |
87b78e75a2b9
gui: undo disabling menu entries in context menu of file browser
Torsten <ttl@justmail.de>
parents:
16510
diff
changeset
|
348 menu.addSeparator(); |
87b78e75a2b9
gui: undo disabling menu entries in context menu of file browser
Torsten <ttl@justmail.de>
parents:
16510
diff
changeset
|
349 menu.addAction (QIcon (":/actions/icons/filenew.png"), |
87b78e75a2b9
gui: undo disabling menu entries in context menu of file browser
Torsten <ttl@justmail.de>
parents:
16510
diff
changeset
|
350 tr ("New File"), |
87b78e75a2b9
gui: undo disabling menu entries in context menu of file browser
Torsten <ttl@justmail.de>
parents:
16510
diff
changeset
|
351 this, SLOT(contextmenu_newfile(bool))); |
87b78e75a2b9
gui: undo disabling menu entries in context menu of file browser
Torsten <ttl@justmail.de>
parents:
16510
diff
changeset
|
352 menu.addAction (QIcon (":/actions/icons/folder_new.png"), |
87b78e75a2b9
gui: undo disabling menu entries in context menu of file browser
Torsten <ttl@justmail.de>
parents:
16510
diff
changeset
|
353 tr("New Directory"), |
87b78e75a2b9
gui: undo disabling menu entries in context menu of file browser
Torsten <ttl@justmail.de>
parents:
16510
diff
changeset
|
354 this, SLOT(contextmenu_newdir(bool))); |
87b78e75a2b9
gui: undo disabling menu entries in context menu of file browser
Torsten <ttl@justmail.de>
parents:
16510
diff
changeset
|
355 } |
16503
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
356 |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
357 menu.exec(_file_tree_view->mapToGlobal(mpos)); |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
358 |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
359 } |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
360 } |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
361 |
16506
8a4960f2c7c3
gui: allow running files from the file browser
Torsten <ttl@justmail.de>
parents:
16504
diff
changeset
|
362 void |
16503
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
363 files_dock_widget::contextmenu_open (bool) |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
364 { |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
365 |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
366 QItemSelectionModel *m = _file_tree_view->selectionModel (); |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
367 QModelIndexList rows = m->selectedRows (); |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
368 |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
369 for( QModelIndexList::iterator it = rows.begin (); it != rows.end (); it++) |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
370 { |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
371 item_double_clicked(*it); |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
372 } |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
373 } |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
374 |
16506
8a4960f2c7c3
gui: allow running files from the file browser
Torsten <ttl@justmail.de>
parents:
16504
diff
changeset
|
375 void |
16594
3ce0c312a40b
contextmenu for opening files in default applications
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
376 files_dock_widget::contextmenu_open_in_app (bool) |
3ce0c312a40b
contextmenu for opening files in default applications
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
377 { |
3ce0c312a40b
contextmenu for opening files in default applications
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
378 QItemSelectionModel *m = _file_tree_view->selectionModel (); |
3ce0c312a40b
contextmenu for opening files in default applications
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
379 QModelIndexList rows = m->selectedRows (); |
3ce0c312a40b
contextmenu for opening files in default applications
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
380 |
3ce0c312a40b
contextmenu for opening files in default applications
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
381 for (QModelIndexList::iterator it = rows.begin (); it != rows.end (); it++) |
3ce0c312a40b
contextmenu for opening files in default applications
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
382 open_item_in_app (*it); |
3ce0c312a40b
contextmenu for opening files in default applications
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
383 } |
3ce0c312a40b
contextmenu for opening files in default applications
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
384 |
3ce0c312a40b
contextmenu for opening files in default applications
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
385 void |
16504
49b059bf27c7
allow loading files from file browser
John W. Eaton <jwe@octave.org>
parents:
16503
diff
changeset
|
386 files_dock_widget::contextmenu_load (bool) |
49b059bf27c7
allow loading files from file browser
John W. Eaton <jwe@octave.org>
parents:
16503
diff
changeset
|
387 { |
49b059bf27c7
allow loading files from file browser
John W. Eaton <jwe@octave.org>
parents:
16503
diff
changeset
|
388 QItemSelectionModel *m = _file_tree_view->selectionModel (); |
49b059bf27c7
allow loading files from file browser
John W. Eaton <jwe@octave.org>
parents:
16503
diff
changeset
|
389 QModelIndexList rows = m->selectedRows (); |
49b059bf27c7
allow loading files from file browser
John W. Eaton <jwe@octave.org>
parents:
16503
diff
changeset
|
390 |
49b059bf27c7
allow loading files from file browser
John W. Eaton <jwe@octave.org>
parents:
16503
diff
changeset
|
391 if (rows.size () > 0) |
49b059bf27c7
allow loading files from file browser
John W. Eaton <jwe@octave.org>
parents:
16503
diff
changeset
|
392 { |
49b059bf27c7
allow loading files from file browser
John W. Eaton <jwe@octave.org>
parents:
16503
diff
changeset
|
393 QModelIndex index = rows[0]; |
49b059bf27c7
allow loading files from file browser
John W. Eaton <jwe@octave.org>
parents:
16503
diff
changeset
|
394 |
49b059bf27c7
allow loading files from file browser
John W. Eaton <jwe@octave.org>
parents:
16503
diff
changeset
|
395 QFileInfo info = _file_system_model->fileInfo(index); |
49b059bf27c7
allow loading files from file browser
John W. Eaton <jwe@octave.org>
parents:
16503
diff
changeset
|
396 |
49b059bf27c7
allow loading files from file browser
John W. Eaton <jwe@octave.org>
parents:
16503
diff
changeset
|
397 emit load_file_signal (info.fileName ()); |
49b059bf27c7
allow loading files from file browser
John W. Eaton <jwe@octave.org>
parents:
16503
diff
changeset
|
398 } |
49b059bf27c7
allow loading files from file browser
John W. Eaton <jwe@octave.org>
parents:
16503
diff
changeset
|
399 } |
49b059bf27c7
allow loading files from file browser
John W. Eaton <jwe@octave.org>
parents:
16503
diff
changeset
|
400 |
16506
8a4960f2c7c3
gui: allow running files from the file browser
Torsten <ttl@justmail.de>
parents:
16504
diff
changeset
|
401 void |
8a4960f2c7c3
gui: allow running files from the file browser
Torsten <ttl@justmail.de>
parents:
16504
diff
changeset
|
402 files_dock_widget::contextmenu_run (bool) |
8a4960f2c7c3
gui: allow running files from the file browser
Torsten <ttl@justmail.de>
parents:
16504
diff
changeset
|
403 { |
8a4960f2c7c3
gui: allow running files from the file browser
Torsten <ttl@justmail.de>
parents:
16504
diff
changeset
|
404 QItemSelectionModel *m = _file_tree_view->selectionModel (); |
8a4960f2c7c3
gui: allow running files from the file browser
Torsten <ttl@justmail.de>
parents:
16504
diff
changeset
|
405 QModelIndexList rows = m->selectedRows (); |
8a4960f2c7c3
gui: allow running files from the file browser
Torsten <ttl@justmail.de>
parents:
16504
diff
changeset
|
406 |
8a4960f2c7c3
gui: allow running files from the file browser
Torsten <ttl@justmail.de>
parents:
16504
diff
changeset
|
407 if (rows.size () > 0) |
8a4960f2c7c3
gui: allow running files from the file browser
Torsten <ttl@justmail.de>
parents:
16504
diff
changeset
|
408 { |
8a4960f2c7c3
gui: allow running files from the file browser
Torsten <ttl@justmail.de>
parents:
16504
diff
changeset
|
409 QModelIndex index = rows[0]; |
8a4960f2c7c3
gui: allow running files from the file browser
Torsten <ttl@justmail.de>
parents:
16504
diff
changeset
|
410 |
8a4960f2c7c3
gui: allow running files from the file browser
Torsten <ttl@justmail.de>
parents:
16504
diff
changeset
|
411 QFileInfo info = _file_system_model->fileInfo(index); |
8a4960f2c7c3
gui: allow running files from the file browser
Torsten <ttl@justmail.de>
parents:
16504
diff
changeset
|
412 |
16507
8cb12cf9ca32
gui: add icons to the context menu of the the file browser
Torsten <ttl@justmail.de>
parents:
16506
diff
changeset
|
413 QString function_name = info.fileName (); |
8cb12cf9ca32
gui: add icons to the context menu of the the file browser
Torsten <ttl@justmail.de>
parents:
16506
diff
changeset
|
414 // We have to cut off the suffix, because octave appends it. |
8cb12cf9ca32
gui: add icons to the context menu of the the file browser
Torsten <ttl@justmail.de>
parents:
16506
diff
changeset
|
415 function_name.chop (info.suffix ().length () + 1); |
8cb12cf9ca32
gui: add icons to the context menu of the the file browser
Torsten <ttl@justmail.de>
parents:
16506
diff
changeset
|
416 emit run_file_signal (QString ("cd \'%1\'\n%2\n") |
16506
8a4960f2c7c3
gui: allow running files from the file browser
Torsten <ttl@justmail.de>
parents:
16504
diff
changeset
|
417 .arg(info.absolutePath ()).arg (function_name)); |
8a4960f2c7c3
gui: allow running files from the file browser
Torsten <ttl@justmail.de>
parents:
16504
diff
changeset
|
418 } |
8a4960f2c7c3
gui: allow running files from the file browser
Torsten <ttl@justmail.de>
parents:
16504
diff
changeset
|
419 } |
8a4960f2c7c3
gui: allow running files from the file browser
Torsten <ttl@justmail.de>
parents:
16504
diff
changeset
|
420 |
16504
49b059bf27c7
allow loading files from file browser
John W. Eaton <jwe@octave.org>
parents:
16503
diff
changeset
|
421 void |
16503
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
422 files_dock_widget::contextmenu_rename (bool) |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
423 { |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
424 QItemSelectionModel *m = _file_tree_view->selectionModel (); |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
425 QModelIndexList rows = m->selectedRows (); |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
426 if(rows.size() > 0) |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
427 { |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
428 QModelIndex index = rows[0]; |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
429 |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
430 QFileInfo info = _file_system_model->fileInfo(index); |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
431 QDir path = info.absoluteDir(); |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
432 QString old_name = info.fileName(); |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
433 bool ok; |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
434 |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
435 QString new_name = QInputDialog::getText (this, tr("Rename file/directory"), |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
436 tr("Rename file/directory:\n") + old_name + tr("\n to: "), |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
437 QLineEdit::Normal, old_name, &ok); |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
438 if(ok && new_name.length()>0) |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
439 { |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
440 new_name = path.absolutePath() + "/" + new_name; |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
441 old_name = path.absolutePath() + "/" + old_name; |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
442 path.rename(old_name, new_name); |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
443 _file_system_model->revert(); |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
444 } |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
445 } |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
446 |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
447 } |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
448 |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
449 void |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
450 files_dock_widget::contextmenu_delete (bool) |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
451 { |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
452 QItemSelectionModel *m = _file_tree_view->selectionModel (); |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
453 QModelIndexList rows = m->selectedRows (); |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
454 |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
455 for( QModelIndexList::iterator it = rows.begin (); it != rows.end (); it++) |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
456 { |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
457 QModelIndex index = *it; |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
458 |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
459 QFileInfo info = _file_system_model->fileInfo(index); |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
460 |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
461 if(QMessageBox::question(this, tr("Delete file/directory"), |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
462 tr("Are you sre you want to delete\n") + info.filePath(), |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
463 QMessageBox::Yes|QMessageBox::No) == QMessageBox::Yes) |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
464 { |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
465 if(info.isDir()) |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
466 { |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
467 // see if direcory is empty |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
468 QDir path(info.absoluteFilePath()); |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
469 QList<QFileInfo> fileLst = path.entryInfoList(QDir::AllEntries | QDir::NoDotAndDotDot); |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
470 |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
471 if(fileLst.count() != 0) |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
472 QMessageBox::warning(this, tr("Delete file/directory"), |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
473 tr("Can not delete a directory that is not empty")); |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
474 else |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
475 _file_system_model->rmdir(index); |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
476 } |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
477 else |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
478 { |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
479 _file_system_model->remove(index); |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
480 } |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
481 |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
482 _file_system_model->revert(); |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
483 |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
484 } |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
485 } |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
486 } |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
487 |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
488 void |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
489 files_dock_widget::contextmenu_newfile (bool) |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
490 { |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
491 QItemSelectionModel *m = _file_tree_view->selectionModel (); |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
492 QModelIndexList rows = m->selectedRows (); |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
493 |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
494 if(rows.size() > 0) |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
495 { |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
496 QModelIndex index = rows[0]; |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
497 |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
498 QFileInfo info = _file_system_model->fileInfo(index); |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
499 QString parent_dir = info.filePath(); |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
500 |
16542
016073c0cb94
Add popdown toolbutton to files-dock-window toolbar.
John Donoghue <john.donoghue@ieee.org>
parents:
16525
diff
changeset
|
501 process_new_file(parent_dir); |
16503
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
502 } |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
503 } |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
504 |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
505 void |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
506 files_dock_widget::contextmenu_newdir (bool) |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
507 { |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
508 QItemSelectionModel *m = _file_tree_view->selectionModel (); |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
509 QModelIndexList rows = m->selectedRows (); |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
510 |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
511 if(rows.size() > 0) |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
512 { |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
513 QModelIndex index = rows[0]; |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
514 |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
515 QFileInfo info = _file_system_model->fileInfo(index); |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
516 QString parent_dir = info.filePath(); |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
517 |
16542
016073c0cb94
Add popdown toolbutton to files-dock-window toolbar.
John Donoghue <john.donoghue@ieee.org>
parents:
16525
diff
changeset
|
518 process_new_dir(parent_dir); |
16503
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
519 } |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
520 } |
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
521 |
16509
14045b872a3d
Add set current directory context menu to file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16507
diff
changeset
|
522 void |
14045b872a3d
Add set current directory context menu to file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16507
diff
changeset
|
523 files_dock_widget::contextmenu_setcurrentdir (bool) |
14045b872a3d
Add set current directory context menu to file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16507
diff
changeset
|
524 { |
14045b872a3d
Add set current directory context menu to file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16507
diff
changeset
|
525 QItemSelectionModel *m = _file_tree_view->selectionModel (); |
14045b872a3d
Add set current directory context menu to file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16507
diff
changeset
|
526 QModelIndexList rows = m->selectedRows (); |
16503
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
527 |
16509
14045b872a3d
Add set current directory context menu to file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16507
diff
changeset
|
528 if(rows.size() > 0) |
14045b872a3d
Add set current directory context menu to file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16507
diff
changeset
|
529 { |
14045b872a3d
Add set current directory context menu to file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16507
diff
changeset
|
530 QModelIndex index = rows[0]; |
16503
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
531 |
16509
14045b872a3d
Add set current directory context menu to file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16507
diff
changeset
|
532 QFileInfo info = _file_system_model->fileInfo(index); |
14045b872a3d
Add set current directory context menu to file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16507
diff
changeset
|
533 |
14045b872a3d
Add set current directory context menu to file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16507
diff
changeset
|
534 if(info.isDir()) |
14045b872a3d
Add set current directory context menu to file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16507
diff
changeset
|
535 { |
16542
016073c0cb94
Add popdown toolbutton to files-dock-window toolbar.
John Donoghue <john.donoghue@ieee.org>
parents:
16525
diff
changeset
|
536 process_set_current_dir(info.absoluteFilePath ()); |
16509
14045b872a3d
Add set current directory context menu to file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16507
diff
changeset
|
537 } |
14045b872a3d
Add set current directory context menu to file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16507
diff
changeset
|
538 } |
14045b872a3d
Add set current directory context menu to file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16507
diff
changeset
|
539 } |
16503
c1ff738d606d
allow files to be renamed or deleted using the file browser
John Donoghue <john.donoghue@ieee.org>
parents:
16499
diff
changeset
|
540 |
13536
869c62c15e95
Few minor improvements, added advanced settings for file browser.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13535
diff
changeset
|
541 void |
16413
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16410
diff
changeset
|
542 files_dock_widget::notice_settings (const QSettings *settings) |
13536
869c62c15e95
Few minor improvements, added advanced settings for file browser.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13535
diff
changeset
|
543 { |
16413
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16410
diff
changeset
|
544 // Qsettings pointer is checked before emitting. |
15164
bc801a44bb1f
follow Octave pattern for resource_manager singleton
John W. Eaton <jwe@octave.org>
parents:
14812
diff
changeset
|
545 |
16525
e192525236ad
configurable size of toolbar icons
Torsten <ttl@justmail.de>
parents:
16515
diff
changeset
|
546 int icon_size = settings->value ("toolbar_icon_size",24).toInt (); |
e192525236ad
configurable size of toolbar icons
Torsten <ttl@justmail.de>
parents:
16515
diff
changeset
|
547 if (icon_size > 16) |
e192525236ad
configurable size of toolbar icons
Torsten <ttl@justmail.de>
parents:
16515
diff
changeset
|
548 icon_size = icon_size - 4; |
e192525236ad
configurable size of toolbar icons
Torsten <ttl@justmail.de>
parents:
16515
diff
changeset
|
549 _navigation_tool_bar->setIconSize (QSize (icon_size,icon_size)); |
e192525236ad
configurable size of toolbar icons
Torsten <ttl@justmail.de>
parents:
16515
diff
changeset
|
550 |
16410
f62163bed4dc
gui: always show file names in file dock widget
Torsten <ttl@justmail.de>
parents:
16379
diff
changeset
|
551 // file names are always shown, other columns can be hidden by settings |
f62163bed4dc
gui: always show file names in file dock widget
Torsten <ttl@justmail.de>
parents:
16379
diff
changeset
|
552 _file_tree_view->setColumnHidden (0, false); |
16499
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
553 _file_tree_view->setColumnHidden (1, !settings->value ("filesdockwidget/showFileSize",false).toBool ()); |
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
554 _file_tree_view->setColumnHidden (2, !settings->value ("filesdockwidget/showFileType",false).toBool ()); |
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
555 _file_tree_view->setColumnHidden (3, !settings->value ("filesdockwidget/showLastModified",false).toBool ()); |
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
556 _file_tree_view->setAlternatingRowColors (settings->value ("filesdockwidget/useAlternatingRowColors",true).toBool ()); |
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
557 if (settings->value ("filesdockwidget/showHiddenFiles",false).toBool ()) |
16379
4bb1b82076e5
gui: provide defaults for all values read from the settings file
Torsten <ttl@justmail.de>
parents:
16175
diff
changeset
|
558 { |
4bb1b82076e5
gui: provide defaults for all values read from the settings file
Torsten <ttl@justmail.de>
parents:
16175
diff
changeset
|
559 // TODO: React on option for hidden files. |
4bb1b82076e5
gui: provide defaults for all values read from the settings file
Torsten <ttl@justmail.de>
parents:
16175
diff
changeset
|
560 } |
16499
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
561 // enalbe the buttons to sync octave/browser dir only if this is not done by default |
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
562 _sync_octave_dir = settings->value ("filesdockwidget/sync_octave_directory",false).toBool (); |
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
563 _sync_octave_directory_action->setEnabled (!_sync_octave_dir); |
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
564 _sync_browser_directory_action->setEnabled (!_sync_octave_dir); |
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
565 |
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
566 if (_sync_octave_dir) |
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
567 display_directory (_octave_dir); // sync browser to octave dir |
facf00ce97d3
gui: configurable synchronization between file browser and octave directory
Torsten <ttl@justmail.de>
parents:
16498
diff
changeset
|
568 |
13536
869c62c15e95
Few minor improvements, added advanced settings for file browser.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13535
diff
changeset
|
569 } |
16542
016073c0cb94
Add popdown toolbutton to files-dock-window toolbar.
John Donoghue <john.donoghue@ieee.org>
parents:
16525
diff
changeset
|
570 |
016073c0cb94
Add popdown toolbutton to files-dock-window toolbar.
John Donoghue <john.donoghue@ieee.org>
parents:
16525
diff
changeset
|
571 void |
016073c0cb94
Add popdown toolbutton to files-dock-window toolbar.
John Donoghue <john.donoghue@ieee.org>
parents:
16525
diff
changeset
|
572 files_dock_widget::popdownmenu_newdir (bool) |
016073c0cb94
Add popdown toolbutton to files-dock-window toolbar.
John Donoghue <john.donoghue@ieee.org>
parents:
16525
diff
changeset
|
573 { |
016073c0cb94
Add popdown toolbutton to files-dock-window toolbar.
John Donoghue <john.donoghue@ieee.org>
parents:
16525
diff
changeset
|
574 process_new_dir(_file_system_model->rootPath()); |
016073c0cb94
Add popdown toolbutton to files-dock-window toolbar.
John Donoghue <john.donoghue@ieee.org>
parents:
16525
diff
changeset
|
575 } |
016073c0cb94
Add popdown toolbutton to files-dock-window toolbar.
John Donoghue <john.donoghue@ieee.org>
parents:
16525
diff
changeset
|
576 |
016073c0cb94
Add popdown toolbutton to files-dock-window toolbar.
John Donoghue <john.donoghue@ieee.org>
parents:
16525
diff
changeset
|
577 void |
016073c0cb94
Add popdown toolbutton to files-dock-window toolbar.
John Donoghue <john.donoghue@ieee.org>
parents:
16525
diff
changeset
|
578 files_dock_widget::popdownmenu_newfile (bool) |
016073c0cb94
Add popdown toolbutton to files-dock-window toolbar.
John Donoghue <john.donoghue@ieee.org>
parents:
16525
diff
changeset
|
579 { |
016073c0cb94
Add popdown toolbutton to files-dock-window toolbar.
John Donoghue <john.donoghue@ieee.org>
parents:
16525
diff
changeset
|
580 process_new_file(_file_system_model->rootPath()); |
016073c0cb94
Add popdown toolbutton to files-dock-window toolbar.
John Donoghue <john.donoghue@ieee.org>
parents:
16525
diff
changeset
|
581 } |
016073c0cb94
Add popdown toolbutton to files-dock-window toolbar.
John Donoghue <john.donoghue@ieee.org>
parents:
16525
diff
changeset
|
582 |
016073c0cb94
Add popdown toolbutton to files-dock-window toolbar.
John Donoghue <john.donoghue@ieee.org>
parents:
16525
diff
changeset
|
583 void |
016073c0cb94
Add popdown toolbutton to files-dock-window toolbar.
John Donoghue <john.donoghue@ieee.org>
parents:
16525
diff
changeset
|
584 files_dock_widget::process_new_file (const QString &parent_dir) |
016073c0cb94
Add popdown toolbutton to files-dock-window toolbar.
John Donoghue <john.donoghue@ieee.org>
parents:
16525
diff
changeset
|
585 { |
016073c0cb94
Add popdown toolbutton to files-dock-window toolbar.
John Donoghue <john.donoghue@ieee.org>
parents:
16525
diff
changeset
|
586 bool ok; |
016073c0cb94
Add popdown toolbutton to files-dock-window toolbar.
John Donoghue <john.donoghue@ieee.org>
parents:
16525
diff
changeset
|
587 |
016073c0cb94
Add popdown toolbutton to files-dock-window toolbar.
John Donoghue <john.donoghue@ieee.org>
parents:
16525
diff
changeset
|
588 QString name = QInputDialog::getText (this, tr("Create File"), tr("Create file in\n") + parent_dir, |
016073c0cb94
Add popdown toolbutton to files-dock-window toolbar.
John Donoghue <john.donoghue@ieee.org>
parents:
16525
diff
changeset
|
589 QLineEdit::Normal, "New File.txt", &ok); |
016073c0cb94
Add popdown toolbutton to files-dock-window toolbar.
John Donoghue <john.donoghue@ieee.org>
parents:
16525
diff
changeset
|
590 if(ok && name.length()>0) |
016073c0cb94
Add popdown toolbutton to files-dock-window toolbar.
John Donoghue <john.donoghue@ieee.org>
parents:
16525
diff
changeset
|
591 { |
016073c0cb94
Add popdown toolbutton to files-dock-window toolbar.
John Donoghue <john.donoghue@ieee.org>
parents:
16525
diff
changeset
|
592 name = parent_dir + "/" + name; |
016073c0cb94
Add popdown toolbutton to files-dock-window toolbar.
John Donoghue <john.donoghue@ieee.org>
parents:
16525
diff
changeset
|
593 |
016073c0cb94
Add popdown toolbutton to files-dock-window toolbar.
John Donoghue <john.donoghue@ieee.org>
parents:
16525
diff
changeset
|
594 QFile file(name); |
016073c0cb94
Add popdown toolbutton to files-dock-window toolbar.
John Donoghue <john.donoghue@ieee.org>
parents:
16525
diff
changeset
|
595 file.open(QIODevice::WriteOnly); |
016073c0cb94
Add popdown toolbutton to files-dock-window toolbar.
John Donoghue <john.donoghue@ieee.org>
parents:
16525
diff
changeset
|
596 _file_system_model->revert(); |
016073c0cb94
Add popdown toolbutton to files-dock-window toolbar.
John Donoghue <john.donoghue@ieee.org>
parents:
16525
diff
changeset
|
597 } |
016073c0cb94
Add popdown toolbutton to files-dock-window toolbar.
John Donoghue <john.donoghue@ieee.org>
parents:
16525
diff
changeset
|
598 } |
016073c0cb94
Add popdown toolbutton to files-dock-window toolbar.
John Donoghue <john.donoghue@ieee.org>
parents:
16525
diff
changeset
|
599 |
016073c0cb94
Add popdown toolbutton to files-dock-window toolbar.
John Donoghue <john.donoghue@ieee.org>
parents:
16525
diff
changeset
|
600 void |
016073c0cb94
Add popdown toolbutton to files-dock-window toolbar.
John Donoghue <john.donoghue@ieee.org>
parents:
16525
diff
changeset
|
601 files_dock_widget::process_new_dir (const QString &parent_dir) |
016073c0cb94
Add popdown toolbutton to files-dock-window toolbar.
John Donoghue <john.donoghue@ieee.org>
parents:
16525
diff
changeset
|
602 { |
016073c0cb94
Add popdown toolbutton to files-dock-window toolbar.
John Donoghue <john.donoghue@ieee.org>
parents:
16525
diff
changeset
|
603 bool ok; |
016073c0cb94
Add popdown toolbutton to files-dock-window toolbar.
John Donoghue <john.donoghue@ieee.org>
parents:
16525
diff
changeset
|
604 |
016073c0cb94
Add popdown toolbutton to files-dock-window toolbar.
John Donoghue <john.donoghue@ieee.org>
parents:
16525
diff
changeset
|
605 QString name = QInputDialog::getText (this, tr("Create Directory"), tr("Create folder in\n") + parent_dir, |
016073c0cb94
Add popdown toolbutton to files-dock-window toolbar.
John Donoghue <john.donoghue@ieee.org>
parents:
16525
diff
changeset
|
606 QLineEdit::Normal, "New Directory", &ok); |
016073c0cb94
Add popdown toolbutton to files-dock-window toolbar.
John Donoghue <john.donoghue@ieee.org>
parents:
16525
diff
changeset
|
607 if(ok && name.length()>0) |
016073c0cb94
Add popdown toolbutton to files-dock-window toolbar.
John Donoghue <john.donoghue@ieee.org>
parents:
16525
diff
changeset
|
608 { |
016073c0cb94
Add popdown toolbutton to files-dock-window toolbar.
John Donoghue <john.donoghue@ieee.org>
parents:
16525
diff
changeset
|
609 QDir dir(parent_dir); |
016073c0cb94
Add popdown toolbutton to files-dock-window toolbar.
John Donoghue <john.donoghue@ieee.org>
parents:
16525
diff
changeset
|
610 dir.mkdir(name); |
016073c0cb94
Add popdown toolbutton to files-dock-window toolbar.
John Donoghue <john.donoghue@ieee.org>
parents:
16525
diff
changeset
|
611 _file_system_model->revert(); |
016073c0cb94
Add popdown toolbutton to files-dock-window toolbar.
John Donoghue <john.donoghue@ieee.org>
parents:
16525
diff
changeset
|
612 } |
016073c0cb94
Add popdown toolbutton to files-dock-window toolbar.
John Donoghue <john.donoghue@ieee.org>
parents:
16525
diff
changeset
|
613 } |
016073c0cb94
Add popdown toolbutton to files-dock-window toolbar.
John Donoghue <john.donoghue@ieee.org>
parents:
16525
diff
changeset
|
614 |
016073c0cb94
Add popdown toolbutton to files-dock-window toolbar.
John Donoghue <john.donoghue@ieee.org>
parents:
16525
diff
changeset
|
615 void files_dock_widget::process_set_current_dir(const QString & dir) |
016073c0cb94
Add popdown toolbutton to files-dock-window toolbar.
John Donoghue <john.donoghue@ieee.org>
parents:
16525
diff
changeset
|
616 { |
016073c0cb94
Add popdown toolbutton to files-dock-window toolbar.
John Donoghue <john.donoghue@ieee.org>
parents:
16525
diff
changeset
|
617 emit displayed_directory_changed (dir); |
016073c0cb94
Add popdown toolbutton to files-dock-window toolbar.
John Donoghue <john.donoghue@ieee.org>
parents:
16525
diff
changeset
|
618 } |
016073c0cb94
Add popdown toolbutton to files-dock-window toolbar.
John Donoghue <john.donoghue@ieee.org>
parents:
16525
diff
changeset
|
619 |