annotate gui/src/FilesDockWidget.cpp @ 13535:98bde3b5b7a0

File browser does not show all information.
author Jacob Dawid <jacob.dawid@googlemail.com>
date Tue, 26 Jul 2011 17:33:59 +0200
parents bb3676025b36
children 869c62c15e95
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
2 * Copyright (C) 2011 Jacob Dawid
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
3 * jacob.dawid@googlemail.com
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
4 *
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
5 * This program is free software: you can redistribute it and/or modify
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
6 * it under the terms of the GNU General Public License as published by
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
7 * the Free Software Foundation, either version 3 of the License, or
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
8 * (at your option) any later version.
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
9 *
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
10 * This program is distributed in the hope that it will be useful,
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
13 * GNU General Public License for more details.
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
14 *
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
17 */
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
18
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
19 #include "FilesDockWidget.h"
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
20
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
21 #include <QApplication>
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
22 #include <QFileInfo>
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
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>
bb3676025b36 User can set a custom file editor instead of the built-in one.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13522
diff changeset
26 #include <QDesktopServices>
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
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");
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
31 setWindowTitle (tr ("Current Folder"));
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
32 setWidget (new QWidget (this));
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
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
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
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);
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
45 m_currentDirectory = new QLineEdit (m_navigationToolBar);
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
46
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
47 m_navigationToolBar->addAction (m_directoryUpAction);
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
48 m_navigationToolBar->addWidget (m_currentDirectory);
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
49 connect (m_directoryUpAction, SIGNAL (triggered ()), this,
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
50 SLOT (onUpDirectory ()));
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
51
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
52 // TODO: Add other buttons for creating directories
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
53
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
54 // Create the QFileSystemModel starting in the home directory
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
55 QString
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
56 homePath = QDir::homePath ();
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
57 // TODO: This should occur after Octave has been initialized and the startup directory of Octave is established
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
58
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
59 m_fileSystemModel = new QFileSystemModel (this);
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
60 m_fileSystemModel->setFilter (QDir::NoDotAndDotDot | QDir::AllEntries);
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
61 QModelIndex
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
62 rootPathIndex = m_fileSystemModel->setRootPath (homePath);
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
63
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
64 // 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
65 m_fileTreeView = new QTreeView (widget ());
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
66 m_fileTreeView->setModel (m_fileSystemModel);
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
67 m_fileTreeView->setRootIndex (rootPathIndex);
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
68 m_fileTreeView->setSortingEnabled (true);
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
69 m_fileTreeView->setAlternatingRowColors (true);
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
70 m_fileTreeView->setAnimated (true);
13535
98bde3b5b7a0 File browser does not show all information.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13531
diff changeset
71 m_fileTreeView->setColumnHidden (1, true);
98bde3b5b7a0 File browser does not show all information.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13531
diff changeset
72 m_fileTreeView->setColumnHidden (2, true);
98bde3b5b7a0 File browser does not show all information.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13531
diff changeset
73 m_fileTreeView->setColumnHidden (3, true);
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
74 setCurrentDirectory (m_fileSystemModel->fileInfo (rootPathIndex).
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
75 absoluteFilePath ());
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
76
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
77 connect (m_fileTreeView, SIGNAL (doubleClicked (const QModelIndex &)), this,
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
78 SLOT (itemDoubleClicked (const QModelIndex &)));
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
79
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
80 // Layout the widgets vertically with the toolbar on top
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
81 QVBoxLayout *
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
82 layout = new QVBoxLayout ();
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
83 layout->setSpacing (0);
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
84 layout->addWidget (m_navigationToolBar);
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
85 layout->addWidget (m_fileTreeView);
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
86 widget ()->setLayout (layout);
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
87 // TODO: Add right-click contextual menus for copying, pasting, deleting files (and others)
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
88
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
89 connect (m_currentDirectory, SIGNAL (returnPressed ()), this,
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
90 SLOT (currentDirectoryEntered ()));
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
91 QCompleter *
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
92 completer = new QCompleter (m_fileSystemModel, this);
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
93 m_currentDirectory->setCompleter (completer);
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
94 }
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
95
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
96 void
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
97 FilesDockWidget::itemDoubleClicked (const QModelIndex & index)
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
98 {
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
99 // 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
100 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
101
bb3676025b36 User can set a custom file editor instead of the built-in one.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13522
diff changeset
102 // If it is a directory, cd into it.
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
103 if (fileInfo.isDir ())
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
104 {
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
105 m_fileSystemModel->setRootPath (fileInfo.absolutePath ());
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
106 m_fileTreeView->setRootIndex (index);
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
107 setCurrentDirectory (m_fileSystemModel->fileInfo (index).
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
108 absoluteFilePath ());
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
109 }
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
110 // Otherwise attempt to open it.
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
111 else
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
112 {
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
113 // Check if the user wants to use a custom file editor.
bb3676025b36 User can set a custom file editor instead of the built-in one.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13522
diff changeset
114 QDesktopServices desktopServices;
bb3676025b36 User can set a custom file editor instead of the built-in one.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13522
diff changeset
115 QString settingsFile =
bb3676025b36 User can set a custom file editor instead of the built-in one.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13522
diff changeset
116 desktopServices.storageLocation (QDesktopServices::HomeLocation) +
bb3676025b36 User can set a custom file editor instead of the built-in one.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13522
diff changeset
117 "/.quint/settings.ini";
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 QSettings settings (settingsFile, QSettings::IniFormat);
bb3676025b36 User can set a custom file editor instead of the built-in one.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13522
diff changeset
119 if (settings.value ("useCustomFileEditor").toBool ())
bb3676025b36 User can set a custom file editor instead of the built-in one.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13522
diff changeset
120 {
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 QString editor = settings.value ("customFileEditor").toString ();
bb3676025b36 User can set a custom file editor instead of the built-in one.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13522
diff changeset
122 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
123 arguments << 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
124 QProcess::execute (editor, 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
125 }
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 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
127 {
bb3676025b36 User can set a custom file editor instead of the built-in one.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13522
diff changeset
128 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
129 }
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
130 }
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
131 }
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
132
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
133 void
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
134 FilesDockWidget::setCurrentDirectory (QString currentDirectory)
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
135 {
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
136 m_currentDirectory->setText (currentDirectory);
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
137 }
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
138
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
139 void
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
140 FilesDockWidget::onUpDirectory (void)
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
141 {
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
142 QDir dir =
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
143 QDir (m_fileSystemModel->filePath (m_fileTreeView->rootIndex ()));
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
144 dir.cdUp ();
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
145 m_fileSystemModel->setRootPath (dir.absolutePath ());
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
146 m_fileTreeView->setRootIndex (m_fileSystemModel->
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
147 index (dir.absolutePath ()));
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
148 setCurrentDirectory (dir.absolutePath ());
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
149 }
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
150
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
151 void
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
152 FilesDockWidget::currentDirectoryEntered ()
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
153 {
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
154 QFileInfo fileInfo (m_currentDirectory->text ());
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
155 if (fileInfo.isDir ())
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
156 {
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
157 m_fileTreeView->setRootIndex (m_fileSystemModel->
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
158 index (fileInfo.absolutePath ()));
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
159 m_fileSystemModel->setRootPath (fileInfo.absolutePath ());
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
160 setCurrentDirectory (fileInfo.absoluteFilePath ());
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
161 }
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
162 else
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
163 {
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
164 if (QFile::exists (fileInfo.absoluteFilePath ()))
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
165 emit openFile (fileInfo.absoluteFilePath ());
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
166 }
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
167 }