Mercurial > hg > octave-terminal
changeset 13450:e5156fd235f1
Added current folder address bar.
author | Jacob Dawid <jacob.dawid@googlemail.com> |
---|---|
date | Fri, 15 Apr 2011 00:40:57 +0200 |
parents | 604c37e8f388 |
children | b3b248cbe29f |
files | gui//src/FilesDockWidget.cpp gui//src/FilesDockWidget.h gui//src/MainWindow.h gui//src/OctaveLink.cpp gui//src/OctaveLink.h |
diffstat | 5 files changed, 36 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/gui//src/FilesDockWidget.cpp +++ b/gui//src/FilesDockWidget.cpp @@ -1,6 +1,7 @@ #include "FilesDockWidget.h" #include <QApplication> +#include <QFileInfo> 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()); + } +}
--- 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 <QDockWidget> +#include <QLineEdit> 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
--- a/gui//src/MainWindow.h +++ b/gui//src/MainWindow.h @@ -157,7 +157,7 @@ while(m_mainWindow->isRunning()) { // Get a full variable list. - QList<SymbolRecord> symbolTable = OctaveLink::instance()->variableInfoList(); + QList<SymbolRecord> symbolTable = OctaveLink::instance()->workspace(); if(symbolTable.size()) { m_mainWindow->variablesDockWidget()->setVariablesList(symbolTable); }
--- a/gui//src/OctaveLink.cpp +++ b/gui//src/OctaveLink.cpp @@ -73,7 +73,7 @@ *******************************************************************************/ //************************************************************************* -QList<SymbolRecord> OctaveLink::variableInfoList() { +QList<SymbolRecord> OctaveLink::workspace() { QMutexLocker mutexLocker(&m_internalAccessMutex); return m_variableSymbolTableList; }
--- a/gui//src/OctaveLink.h +++ b/gui//src/OctaveLink.h @@ -175,7 +175,7 @@ int setBreakpointAction(BreakPointAction action); /** Variable related methods. */ - QList<SymbolRecord> variableInfoList(void); + QList<SymbolRecord> workspace(void); /** TODO: Describe. */ QList<RequestedVariable> requestedVariables(void);