# HG changeset patch # User Jacob Dawid # Date 1302525566 -7200 # Node ID 7e8c437b29cbae71ef985b222cd8a5104520aa12 # Parent 7a5998cebef3bd3a8b076080bbee9bed05f5873b Incorporated John Swenses code for a filesystem view dock. diff --git a/gui//Quint.pro b/gui//Quint.pro --- a/gui//Quint.pro +++ b/gui//Quint.pro @@ -41,7 +41,8 @@ src/ProcessInfo.cpp \ src/OctaveTerminal.cpp \ src/VariablesDockWidget.cpp \ - src/HistoryDockWidget.cpp + src/HistoryDockWidget.cpp \ + src/FilesDockWidget.cpp HEADERS += \ src/TerminalCharacterDecoder.h \ @@ -79,7 +80,8 @@ src/kdecore_export.h \ src/OctaveTerminal.h \ src/VariablesDockWidget.h \ - src/HistoryDockWidget.h + src/HistoryDockWidget.h \ + src/FilesDockWidget.h INCFLAGS = -g3 $$system(mkoctfile -p INCFLAGS) LFLAGS = $$system(mkoctfile -p LFLAGS) \ diff --git a/gui//src/FilesDockWidget.cpp b/gui//src/FilesDockWidget.cpp new file mode 100644 --- /dev/null +++ b/gui//src/FilesDockWidget.cpp @@ -0,0 +1,76 @@ +#include "FilesDockWidget.h" + +#include + +FilesDockWidget::FilesDockWidget(QWidget *parent) + : QDockWidget(parent) +{ + setWidget(new QWidget(this)); + + // Create a toolbar + toolbar = new QToolBar ("", widget()); + toolbar->setAllowedAreas (Qt::TopToolBarArea); + toolbar->setMovable (false); + toolbar->setIconSize (QSize (20,20)); + + // Add a button to the toolbar with the QT standard icon for up-directory + // TODO: Maybe change this to be an up-directory icon that is OS specific??? + QStyle *style = QApplication::style(); + dirIcon = style->standardIcon(QStyle::SP_FileDialogToParent); + dirAction = new QAction (dirIcon, "", toolbar); + + toolbar->addAction (dirAction); + connect(dirAction, SIGNAL(triggered()), this, SLOT(onUpDirectory())); + + // TODO: Add other buttons for creating directories + + // Create the QFileSystemModel starting in the home directory + QString homePath = QDir::homePath (); + // TODO: This should occur after Octave has been initialized and the startup directory of Octave is established + + fileSystemModel = new QFileSystemModel(this); + fileSystemModel->setFilter (QDir::NoDotAndDotDot | QDir::AllEntries); + QModelIndex rootPathIndex = fileSystemModel->setRootPath (homePath); + + // Attach the model to the QTreeView and set the root index + fileTreeView = new QTreeView(widget()); + fileTreeView->setModel (fileSystemModel); + fileTreeView->setRootIndex (rootPathIndex); + fileTreeView->setSortingEnabled (true); + + connect( fileTreeView, SIGNAL(doubleClicked(const QModelIndex &) ), this, SLOT( itemDoubleClicked(const QModelIndex &) ) ); + // TODO: Maybe also add a keyPress event handler so users can navigate manually + + + // Layout the widgets vertically with the toolbar on top + layout = new QVBoxLayout(); + layout->setSpacing(0); + layout->addWidget(toolbar); + layout->addWidget(fileTreeView); + widget()->setLayout(layout); + // TODO: Add right-click contextual menus for copying, pasting, deleting files (and others) +} + +void FilesDockWidget::itemDoubleClicked(const QModelIndex &index) +{ + QFileInfo fileInfo = fileSystemModel->fileInfo (index); + if (fileInfo.isDir ()) + { + fileSystemModel->setRootPath (fileInfo.absolutePath ()); + fileTreeView->setRootIndex (index); + } + else + { + // TODO: Open the file appropriately based on the mime type + } +} + +void FilesDockWidget::onUpDirectory(void) +{ + // Move up an index node + QDir dir = QDir(fileSystemModel->filePath(fileTreeView->rootIndex())); + dir.cdUp(); + fileTreeView->setRootIndex(fileSystemModel->index(dir.absolutePath())); + +} + diff --git a/gui//src/FilesDockWidget.h b/gui//src/FilesDockWidget.h new file mode 100644 --- /dev/null +++ b/gui//src/FilesDockWidget.h @@ -0,0 +1,78 @@ +#ifndef FILESDOCKWIDGET_H +#define FILESDOCKWIDGET_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION +#include "octave/config.h" +#include "octave/octave.h" +#include "octave/str-vec.h" +#include "octave/cmd-hist.h" +#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); + + /** + * Slot for handling the up-directory button in the toolbar + */ + void onUpDirectory(void); + +private: + // Layout widget for packing the toolbar and treeview widgets + QVBoxLayout *layout; + + // TODO: Add toolbar with buttons for navigating the path, creating dirs, etc + + /** + * Toolbar for file and directory manipulation + */ + QToolBar *toolbar; + + /** + * Variables for the up-directory action. + */ + QIcon dirIcon; + QAction *dirAction; + QToolButton *upDirectoryButton; + + /** + * The file system model. + */ + QFileSystemModel *fileSystemModel; + + /** + * The file system view. + */ + QTreeView *fileTreeView; +}; + +#endif // FILESDOCKWIDGET_H diff --git a/gui//src/MainWindow.cpp b/gui//src/MainWindow.cpp --- a/gui//src/MainWindow.cpp +++ b/gui//src/MainWindow.cpp @@ -38,11 +38,14 @@ m_octaveTerminal = new OctaveTerminal(this); m_variablesDockWidget = new VariablesDockWidget(this); m_historyDockWidget = new HistoryDockWidget(this); - setWindowTitle("Quint"); + m_filesDockWidget = new FilesDockWidget(this); + + setWindowTitle("Octave"); setCentralWidget(m_octaveTerminal); addDockWidget(Qt::LeftDockWidgetArea, m_variablesDockWidget); addDockWidget(Qt::LeftDockWidgetArea, m_historyDockWidget); + addDockWidget(Qt::RightDockWidgetArea, m_filesDockWidget); } void MainWindow::establishOctaveLink() { diff --git a/gui//src/MainWindow.h b/gui//src/MainWindow.h --- a/gui//src/MainWindow.h +++ b/gui//src/MainWindow.h @@ -25,6 +25,7 @@ #include "OctaveLink.h" #include "VariablesDockWidget.h" #include "HistoryDockWidget.h" +#include "FilesDockWidget.h" // Octave includes #undef PACKAGE_BUGREPORT @@ -88,6 +89,7 @@ OctaveTerminal *octaveTerminal() { return m_octaveTerminal; } VariablesDockWidget *variablesDockWidget() { return m_variablesDockWidget; } HistoryDockWidget *historyDockWidget() { return m_historyDockWidget; } + FilesDockWidget *filesDockWidget() { return m_filesDockWidget; } public slots: private: @@ -96,6 +98,7 @@ OctaveTerminal *m_octaveTerminal; VariablesDockWidget *m_variablesDockWidget; HistoryDockWidget *m_historyDockWidget; + FilesDockWidget *m_filesDockWidget; // Threads for running octave and managing the data interaction. OctaveMainThread *m_octaveMainThread; diff --git a/gui//src/OctaveLink.cpp b/gui//src/OctaveLink.cpp --- a/gui//src/OctaveLink.cpp +++ b/gui//src/OctaveLink.cpp @@ -115,8 +115,7 @@ //************************************************************************* OctaveLink::OctaveLink() - : m_previousHistoryLength(0), - m_isProcessingServerData(false) { + : m_previousHistoryLength(0) { } OctaveLink::~OctaveLink() { @@ -251,8 +250,6 @@ QMutexLocker mutexLocker(&m_internalAccessMutex); - m_isProcessingServerData = true; - process_breakpoint_action(); processBreakpointAndRemoveModify(); processRequestedVariables(); @@ -260,8 +257,6 @@ setHistoryList(); setBreakPointList(); - m_isProcessingServerData = false; - #ifndef __WIN32__ gettimeofday(&stop, NULL); double elapsed = stop.tv_sec - start.tv_sec + 1E-6 * (stop.tv_usec - start.tv_usec); diff --git a/gui//src/OctaveLink.h b/gui//src/OctaveLink.h --- a/gui//src/OctaveLink.h +++ b/gui//src/OctaveLink.h @@ -112,8 +112,6 @@ } } VariableMetaData; - bool isProcessing(void) { return m_isProcessingServerData; } - // Functions used to access data form the client side. /** Debugging related methods. */ @@ -228,8 +226,6 @@ /** History related member variables. */ string_vector m_historyList; int m_previousHistoryLength; - - bool m_isProcessingServerData; static OctaveLink m_singleton; }; #endif // OCTAVELINK_H diff --git a/gui//src/QTerminalWidget.h b/gui//src/QTerminalWidget.h --- a/gui//src/QTerminalWidget.h +++ b/gui//src/QTerminalWidget.h @@ -31,16 +31,6 @@ Q_OBJECT public: /** - * \enum ColorScheme - * Different color schemes for the terminal. - */ - enum ColorScheme { - WhiteOnBlack, - GreenOnBlack, - BlackOnLightYellow - }; - - /** * \enum ScrollBarPosition * Defines the scrollbar position of the terminal. */