# HG changeset patch # User Jacob Dawid # Date 1302820857 -7200 # Node ID e5156fd235f16cd5a0bf7d91b14ec2b577a4a23a # Parent 604c37e8f38884ddfb408d61050f558842a64732 Added current folder address bar. diff --git a/gui//src/FilesDockWidget.cpp b/gui//src/FilesDockWidget.cpp --- a/gui//src/FilesDockWidget.cpp +++ b/gui//src/FilesDockWidget.cpp @@ -1,6 +1,7 @@ #include "FilesDockWidget.h" #include +#include FilesDockWidget::FilesDockWidget(QWidget *parent) : QDockWidget(parent) { @@ -19,8 +20,10 @@ QStyle *style = QApplication::style(); m_directoryIcon = style->standardIcon(QStyle::SP_FileDialogToParent); m_directoryUpAction = new QAction(m_directoryIcon, "", m_navigationToolBar); + m_currentDirectory = new QLineEdit(m_navigationToolBar); m_navigationToolBar->addAction(m_directoryUpAction); + m_navigationToolBar->addWidget(m_currentDirectory); connect(m_directoryUpAction, SIGNAL(triggered()), this, SLOT(onUpDirectory())); // TODO: Add other buttons for creating directories @@ -40,6 +43,7 @@ m_fileTreeView->setSortingEnabled(true); m_fileTreeView->setAlternatingRowColors(true); m_fileTreeView->setAnimated(true); + setCurrentDirectory(m_fileSystemModel->fileInfo(rootPathIndex).absoluteFilePath()); connect(m_fileTreeView, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(itemDoubleClicked(const QModelIndex &))); @@ -50,6 +54,9 @@ layout->addWidget(m_fileTreeView); widget()->setLayout(layout); // TODO: Add right-click contextual menus for copying, pasting, deleting files (and others) + + connect(m_currentDirectory, SIGNAL(returnPressed()), this, SLOT(currentDirectoryEntered())); + //m_currentDirectory->setEnabled(false); } void FilesDockWidget::itemDoubleClicked(const QModelIndex &index) @@ -58,17 +65,34 @@ if (fileInfo.isDir()) { m_fileSystemModel->setRootPath(fileInfo.absolutePath()); m_fileTreeView->setRootIndex(index); + setCurrentDirectory(m_fileSystemModel->fileInfo(index).absoluteFilePath()); } else { QFileInfo fileInfo = m_fileSystemModel->fileInfo(index); emit openFile(fileInfo.filePath()); } } -void FilesDockWidget::onUpDirectory(void) -{ - // Move up an index node +void FilesDockWidget::setCurrentDirectory(QString currentDirectory) { + m_currentDirectory->setText(currentDirectory); +} + +void FilesDockWidget::onUpDirectory(void) { + // Move up an inm_fileTreeView->setRootIndex(m_fileSystemModel->index(dir.absolutePath()));dex node QDir dir = QDir(m_fileSystemModel->filePath(m_fileTreeView->rootIndex())); dir.cdUp(); + m_fileSystemModel->setRootPath(dir.absolutePath()); m_fileTreeView->setRootIndex(m_fileSystemModel->index(dir.absolutePath())); + setCurrentDirectory(dir.absolutePath()); } +void FilesDockWidget::currentDirectoryEntered() { + QFileInfo fileInfo(m_currentDirectory->text()); + if (fileInfo.isDir()) { + m_fileTreeView->setRootIndex(m_fileSystemModel->index(fileInfo.absolutePath())); + m_fileSystemModel->setRootPath(fileInfo.absolutePath()); + setCurrentDirectory(fileInfo.absoluteFilePath()); + } else { + if(QFile::exists(fileInfo.absoluteFilePath())) + emit openFile(fileInfo.absoluteFilePath()); + } +} diff --git a/gui//src/FilesDockWidget.h b/gui//src/FilesDockWidget.h --- a/gui//src/FilesDockWidget.h +++ b/gui//src/FilesDockWidget.h @@ -44,13 +44,12 @@ #include "octave/str-vec.h" #include "octave/cmd-hist.h" #include +#include class FilesDockWidget : public QDockWidget { Q_OBJECT public : FilesDockWidget(QWidget *parent = 0); - void setDirectory(QString dir); - public slots: /** Slot for handling a change in directory via double click. */ void itemDoubleClicked(const QModelIndex &index); @@ -58,6 +57,10 @@ /** Slot for handling the up-directory button in the toolbar. */ void onUpDirectory(); + void setCurrentDirectory(QString currentDirectory); + + void currentDirectoryEntered(); + signals: void openFile(QString fileName); @@ -77,6 +80,7 @@ /** The file system view. */ QTreeView *m_fileTreeView; + QLineEdit *m_currentDirectory; }; #endif // FILESDOCKWIDGET_H diff --git a/gui//src/MainWindow.h b/gui//src/MainWindow.h --- a/gui//src/MainWindow.h +++ b/gui//src/MainWindow.h @@ -157,7 +157,7 @@ while(m_mainWindow->isRunning()) { // Get a full variable list. - QList symbolTable = OctaveLink::instance()->variableInfoList(); + QList symbolTable = OctaveLink::instance()->workspace(); if(symbolTable.size()) { m_mainWindow->variablesDockWidget()->setVariablesList(symbolTable); } diff --git a/gui//src/OctaveLink.cpp b/gui//src/OctaveLink.cpp --- a/gui//src/OctaveLink.cpp +++ b/gui//src/OctaveLink.cpp @@ -73,7 +73,7 @@ *******************************************************************************/ //************************************************************************* -QList OctaveLink::variableInfoList() { +QList OctaveLink::workspace() { QMutexLocker mutexLocker(&m_internalAccessMutex); return m_variableSymbolTableList; } diff --git a/gui//src/OctaveLink.h b/gui//src/OctaveLink.h --- a/gui//src/OctaveLink.h +++ b/gui//src/OctaveLink.h @@ -175,7 +175,7 @@ int setBreakpointAction(BreakPointAction action); /** Variable related methods. */ - QList variableInfoList(void); + QList workspace(void); /** TODO: Describe. */ QList requestedVariables(void);