Mercurial > hg > octave-lyh
annotate gui/src/FilesDockWidget.cpp @ 14602:c8453a013000 gui
Cleaned up code. Fixed bug that causes the GUI to freeze when launching another editor.
* FileEditor: Now the call of another process returns immediately. Adjusted text when closing a file.
* MainWindow: Moved creating a lexer into the constructor.
author | Jacob Dawid <jacob.dawid@googlemail.com> |
---|---|
date | Mon, 07 May 2012 02:36:49 +0200 |
parents | faece6b2ab90 |
children | 66ff321cb62e |
rev | line source |
---|---|
13504
13e3d60aff2d
Replaced Quint with OctaveGUI.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13501
diff
changeset
|
1 /* OctaveGUI - A graphical user interface for Octave |
13674
c0e66d6e3dc8
Updated license headers and moved to AGPLv3.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13671
diff
changeset
|
2 * Copyright (C) 2011 Jacob Dawid (jacob.dawid@googlemail.com) |
13501 | 3 * |
4 * This program is free software: you can redistribute it and/or modify | |
14290
faece6b2ab90
Corrected license headers in all files to GPL.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14289
diff
changeset
|
5 * it under the terms of the GNU General Public License as |
13674
c0e66d6e3dc8
Updated license headers and moved to AGPLv3.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13671
diff
changeset
|
6 * published by the Free Software Foundation, either version 3 of the |
c0e66d6e3dc8
Updated license headers and moved to AGPLv3.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13671
diff
changeset
|
7 * License, or (at your option) any later version. |
13501 | 8 * |
9 * This program is distributed in the hope that it will be useful, | |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14290
faece6b2ab90
Corrected license headers in all files to GPL.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14289
diff
changeset
|
12 * GNU General Public License for more details. |
13501 | 13 * |
14290
faece6b2ab90
Corrected license headers in all files to GPL.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14289
diff
changeset
|
14 * You should have received a copy of the GNU General Public License |
13674
c0e66d6e3dc8
Updated license headers and moved to AGPLv3.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13671
diff
changeset
|
15 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
13501 | 16 */ |
17 | |
13537
a43ecce77eec
Introduced a central ResourceManager class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13536
diff
changeset
|
18 #include "ResourceManager.h" |
13501 | 19 #include "FilesDockWidget.h" |
20 | |
21 #include <QApplication> | |
22 #include <QFileInfo> | |
23 #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
|
24 #include <QSettings> |
bb3676025b36
User can set a custom file editor instead of the built-in one.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13522
diff
changeset
|
25 #include <QProcess> |
13539
a4b5cad8f7c6
Added command line parser class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13537
diff
changeset
|
26 #include <QDebug> |
13501 | 27 |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
28 FilesDockWidget::FilesDockWidget (QWidget * parent):QDockWidget (parent) |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
29 { |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
30 setObjectName ("FilesDockWidget"); |
13589
ee49f1a15c06
Changed "Current Folder" to "Current Directory".
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13577
diff
changeset
|
31 setWindowTitle (tr ("Current Directory")); |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
32 setWidget (new QWidget (this)); |
13501 | 33 |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
34 // Create a toolbar |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
35 m_navigationToolBar = new QToolBar ("", widget ()); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
36 m_navigationToolBar->setAllowedAreas (Qt::TopToolBarArea); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
37 m_navigationToolBar->setMovable (false); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
38 m_navigationToolBar->setIconSize (QSize (20, 20)); |
13501 | 39 |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
40 // Add a button to the toolbar with the QT standard icon for up-directory |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
41 // TODO: Maybe change this to be an up-directory icon that is OS specific??? |
13522
09d9cb7c3014
Further simplified OctaveLink by removing the readline event hook.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13506
diff
changeset
|
42 QStyle *style = QApplication::style (); |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
43 m_directoryIcon = style->standardIcon (QStyle::SP_FileDialogToParent); |
13522
09d9cb7c3014
Further simplified OctaveLink by removing the readline event hook.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13506
diff
changeset
|
44 m_directoryUpAction = new QAction (m_directoryIcon, "", m_navigationToolBar); |
13549
807e5e9b7591
Added lots of status tips.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13539
diff
changeset
|
45 m_directoryUpAction->setStatusTip (tr ("Move up one directory.")); |
807e5e9b7591
Added lots of status tips.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13539
diff
changeset
|
46 |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
47 m_currentDirectory = new QLineEdit (m_navigationToolBar); |
13549
807e5e9b7591
Added lots of status tips.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13539
diff
changeset
|
48 m_currentDirectory->setStatusTip (tr ("Enter the path or filename.")); |
13501 | 49 |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
50 m_navigationToolBar->addAction (m_directoryUpAction); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
51 m_navigationToolBar->addWidget (m_currentDirectory); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
52 connect (m_directoryUpAction, SIGNAL (triggered ()), this, |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
53 SLOT (onUpDirectory ())); |
13501 | 54 |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
55 // TODO: Add other buttons for creating directories |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
56 |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
57 // Create the QFileSystemModel starting in the home directory |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
58 QString |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
59 homePath = QDir::homePath (); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
60 // TODO: This should occur after Octave has been initialized and the startup directory of Octave is established |
13501 | 61 |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
62 m_fileSystemModel = new QFileSystemModel (this); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
63 m_fileSystemModel->setFilter (QDir::NoDotAndDotDot | QDir::AllEntries); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
64 QModelIndex |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
65 rootPathIndex = m_fileSystemModel->setRootPath (homePath); |
13501 | 66 |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
67 // Attach the model to the QTreeView and set the root index |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
68 m_fileTreeView = new QTreeView (widget ()); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
69 m_fileTreeView->setModel (m_fileSystemModel); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
70 m_fileTreeView->setRootIndex (rootPathIndex); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
71 m_fileTreeView->setSortingEnabled (true); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
72 m_fileTreeView->setAlternatingRowColors (true); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
73 m_fileTreeView->setAnimated (true); |
13535
98bde3b5b7a0
File browser does not show all information.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13531
diff
changeset
|
74 m_fileTreeView->setColumnHidden (1, true); |
98bde3b5b7a0
File browser does not show all information.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13531
diff
changeset
|
75 m_fileTreeView->setColumnHidden (2, true); |
98bde3b5b7a0
File browser does not show all information.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13531
diff
changeset
|
76 m_fileTreeView->setColumnHidden (3, true); |
13549
807e5e9b7591
Added lots of status tips.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13539
diff
changeset
|
77 m_fileTreeView->setStatusTip (tr ("Doubleclick a file to open it.")); |
807e5e9b7591
Added lots of status tips.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13539
diff
changeset
|
78 |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
79 setCurrentDirectory (m_fileSystemModel->fileInfo (rootPathIndex). |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
80 absoluteFilePath ()); |
13501 | 81 |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
82 connect (m_fileTreeView, SIGNAL (doubleClicked (const QModelIndex &)), this, |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
83 SLOT (itemDoubleClicked (const QModelIndex &))); |
13501 | 84 |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
85 // Layout the widgets vertically with the toolbar on top |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
86 QVBoxLayout * |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
87 layout = new QVBoxLayout (); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
88 layout->setSpacing (0); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
89 layout->addWidget (m_navigationToolBar); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
90 layout->addWidget (m_fileTreeView); |
13671
c6dc85026aa6
Rworked margins in layouts.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13589
diff
changeset
|
91 layout->setMargin (1); |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
92 widget ()->setLayout (layout); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
93 // TODO: Add right-click contextual menus for copying, pasting, deleting files (and others) |
13501 | 94 |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
95 connect (m_currentDirectory, SIGNAL (returnPressed ()), this, |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
96 SLOT (currentDirectoryEntered ())); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
97 QCompleter * |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
98 completer = new QCompleter (m_fileSystemModel, this); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
99 m_currentDirectory->setCompleter (completer); |
13577
e440b3f32f02
Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13549
diff
changeset
|
100 |
e440b3f32f02
Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13549
diff
changeset
|
101 connect (this, SIGNAL (visibilityChanged(bool)), this, SLOT(handleVisibilityChanged(bool))); |
13501 | 102 } |
103 | |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
104 void |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
105 FilesDockWidget::itemDoubleClicked (const QModelIndex & index) |
13501 | 106 { |
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
|
107 // Retrieve the file info associated with the model index. |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
108 QFileInfo fileInfo = m_fileSystemModel->fileInfo (index); |
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
|
109 |
bb3676025b36
User can set a custom file editor instead of the built-in one.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13522
diff
changeset
|
110 // If it is a directory, cd into it. |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
111 if (fileInfo.isDir ()) |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
112 { |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
113 m_fileSystemModel->setRootPath (fileInfo.absolutePath ()); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
114 m_fileTreeView->setRootIndex (index); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
115 setCurrentDirectory (m_fileSystemModel->fileInfo (index). |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
116 absoluteFilePath ()); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
117 } |
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
|
118 // Otherwise attempt to open it. |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
119 else |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
120 { |
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
|
121 // Check if the user wants to use a custom file editor. |
13537
a43ecce77eec
Introduced a central ResourceManager class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13536
diff
changeset
|
122 QSettings *settings = ResourceManager::instance ()->settings (); |
a43ecce77eec
Introduced a central ResourceManager class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13536
diff
changeset
|
123 if (settings->value ("useCustomFileEditor").toBool ()) |
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
|
124 { |
13537
a43ecce77eec
Introduced a central ResourceManager class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13536
diff
changeset
|
125 QString editor = settings->value ("customFileEditor").toString (); |
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
|
126 QStringList arguments; |
bb3676025b36
User can set a custom file editor instead of the built-in one.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13522
diff
changeset
|
127 arguments << fileInfo.filePath (); |
14602
c8453a013000
Cleaned up code. Fixed bug that causes the GUI to freeze when launching another editor.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14290
diff
changeset
|
128 QProcess::startDetached (editor, arguments); |
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
|
129 } |
bb3676025b36
User can set a custom file editor instead of the built-in one.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13522
diff
changeset
|
130 else |
bb3676025b36
User can set a custom file editor instead of the built-in one.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13522
diff
changeset
|
131 { |
bb3676025b36
User can set a custom file editor instead of the built-in one.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13522
diff
changeset
|
132 emit openFile (fileInfo.filePath ()); |
bb3676025b36
User can set a custom file editor instead of the built-in one.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13522
diff
changeset
|
133 } |
13501 | 134 } |
135 } | |
136 | |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
137 void |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
138 FilesDockWidget::setCurrentDirectory (QString currentDirectory) |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
139 { |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
140 m_currentDirectory->setText (currentDirectory); |
13501 | 141 } |
142 | |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
143 void |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
144 FilesDockWidget::onUpDirectory (void) |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
145 { |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
146 QDir dir = |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
147 QDir (m_fileSystemModel->filePath (m_fileTreeView->rootIndex ())); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
148 dir.cdUp (); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
149 m_fileSystemModel->setRootPath (dir.absolutePath ()); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
150 m_fileTreeView->setRootIndex (m_fileSystemModel-> |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
151 index (dir.absolutePath ())); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
152 setCurrentDirectory (dir.absolutePath ()); |
13501 | 153 } |
154 | |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
155 void |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
156 FilesDockWidget::currentDirectoryEntered () |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
157 { |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
158 QFileInfo fileInfo (m_currentDirectory->text ()); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
159 if (fileInfo.isDir ()) |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
160 { |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
161 m_fileTreeView->setRootIndex (m_fileSystemModel-> |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
162 index (fileInfo.absolutePath ())); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
163 m_fileSystemModel->setRootPath (fileInfo.absolutePath ()); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
164 setCurrentDirectory (fileInfo.absoluteFilePath ()); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
165 } |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
166 else |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
167 { |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
168 if (QFile::exists (fileInfo.absoluteFilePath ())) |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
169 emit openFile (fileInfo.absoluteFilePath ()); |
13501 | 170 } |
171 } | |
13536
869c62c15e95
Few minor improvements, added advanced settings for file browser.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13535
diff
changeset
|
172 |
869c62c15e95
Few minor improvements, added advanced settings for file browser.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13535
diff
changeset
|
173 void |
869c62c15e95
Few minor improvements, added advanced settings for file browser.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13535
diff
changeset
|
174 FilesDockWidget::noticeSettings () |
869c62c15e95
Few minor improvements, added advanced settings for file browser.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13535
diff
changeset
|
175 { |
13537
a43ecce77eec
Introduced a central ResourceManager class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13536
diff
changeset
|
176 QSettings *settings = ResourceManager::instance ()->settings (); |
a43ecce77eec
Introduced a central ResourceManager class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13536
diff
changeset
|
177 m_fileTreeView->setColumnHidden (0, !settings->value ("showFilenames").toBool ()); |
a43ecce77eec
Introduced a central ResourceManager class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13536
diff
changeset
|
178 m_fileTreeView->setColumnHidden (1, !settings->value ("showFileSize").toBool ()); |
a43ecce77eec
Introduced a central ResourceManager class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13536
diff
changeset
|
179 m_fileTreeView->setColumnHidden (2, !settings->value ("showFileType").toBool ()); |
a43ecce77eec
Introduced a central ResourceManager class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13536
diff
changeset
|
180 m_fileTreeView->setColumnHidden (3, !settings->value ("showLastModified").toBool ()); |
a43ecce77eec
Introduced a central ResourceManager class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13536
diff
changeset
|
181 m_fileTreeView->setAlternatingRowColors (settings->value ("useAlternatingRowColors").toBool ()); |
a43ecce77eec
Introduced a central ResourceManager class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13536
diff
changeset
|
182 //if (settings.value ("showHiddenFiles").toBool ()) |
13539
a4b5cad8f7c6
Added command line parser class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13537
diff
changeset
|
183 // TODO: React on option for hidden files. |
13536
869c62c15e95
Few minor improvements, added advanced settings for file browser.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13535
diff
changeset
|
184 } |
13577
e440b3f32f02
Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13549
diff
changeset
|
185 |
e440b3f32f02
Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13549
diff
changeset
|
186 void |
e440b3f32f02
Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13549
diff
changeset
|
187 FilesDockWidget::handleVisibilityChanged (bool visible) |
e440b3f32f02
Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13549
diff
changeset
|
188 { |
e440b3f32f02
Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13549
diff
changeset
|
189 if (visible) |
e440b3f32f02
Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13549
diff
changeset
|
190 emit activeChanged (true); |
e440b3f32f02
Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13549
diff
changeset
|
191 } |
e440b3f32f02
Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13549
diff
changeset
|
192 |
e440b3f32f02
Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13549
diff
changeset
|
193 void |
e440b3f32f02
Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13549
diff
changeset
|
194 FilesDockWidget::closeEvent (QCloseEvent *event) |
e440b3f32f02
Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13549
diff
changeset
|
195 { |
e440b3f32f02
Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13549
diff
changeset
|
196 emit activeChanged (false); |
e440b3f32f02
Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13549
diff
changeset
|
197 QDockWidget::closeEvent (event); |
e440b3f32f02
Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13549
diff
changeset
|
198 } |