diff -r 80e8c03548a4 gui/src/FilesDockWidget.cpp --- a/gui/src/FilesDockWidget.cpp Tue Mar 13 19:11:52 2012 -0400 +++ b/gui/src/FilesDockWidget.cpp Fri Mar 16 14:23:30 2012 +0530 @@ -24,7 +24,7 @@ #include #include #include - +#include "newfolderdialog.h" FilesDockWidget::FilesDockWidget (QWidget * parent):QDockWidget (parent) { setObjectName ("FilesDockWidget"); @@ -44,13 +44,22 @@ m_directoryUpAction = new QAction (m_directoryIcon, "", m_navigationToolBar); m_directoryUpAction->setStatusTip (tr ("Move up one directory.")); + m_newdirectoryIcon = style->standardIcon (QStyle::SP_FileDialogNewFolder); + m_newdirectoryUpAction = new QAction (m_newdirectoryIcon, "", m_navigationToolBar); + m_newdirectoryUpAction->setStatusTip (tr ("Create a new directory.")); + + m_currentDirectory = new QLineEdit (m_navigationToolBar); m_currentDirectory->setStatusTip (tr ("Enter the path or filename.")); m_navigationToolBar->addAction (m_directoryUpAction); + m_navigationToolBar->addAction (m_newdirectoryUpAction); m_navigationToolBar->addWidget (m_currentDirectory); connect (m_directoryUpAction, SIGNAL (triggered ()), this, - SLOT (onUpDirectory ())); + SLOT (onUpDirectory ())); + connect (m_newdirectoryUpAction, SIGNAL (triggered ()), this, + SLOT (onNewDirectory ())); // TODO: Add other buttons for creating directories @@ -61,8 +70,7 @@ m_fileSystemModel = new QFileSystemModel (this); m_fileSystemModel->setFilter (QDir::NoDotAndDotDot | QDir::AllEntries); - QModelIndex - rootPathIndex = m_fileSystemModel->setRootPath (homePath); + QModelIndex rootPathIndex = m_fileSystemModel->setRootPath (homePath); // Attach the model to the QTreeView and set the root index m_fileTreeView = new QTreeView (widget ()); @@ -81,6 +89,8 @@ connect (m_fileTreeView, SIGNAL (doubleClicked (const QModelIndex &)), this, SLOT (itemDoubleClicked (const QModelIndex &))); + connect (m_fileTreeView, SIGNAL (doubleClicked (const QModelIndex &)), this, + SLOT (itemDoubleClicked (const QModelIndex &))); // Layout the widgets vertically with the toolbar on top QVBoxLayout * @@ -153,6 +163,26 @@ } void +FilesDockWidget::onNewDirectory (void) +{ + QString name ; + NewFolderDialog fileNameDialog; + if(fileNameDialog.exec()==QDialog::Accepted) + { + name = fileNameDialog.getname(); + } + QDir dir = QDir (m_fileSystemModel->filePath (m_fileTreeView->rootIndex ())); + if(name!=NULL){ + dir.mkdir(name); + } + m_fileSystemModel->setRootPath (dir.absolutePath ()); + m_fileTreeView->setRootIndex (m_fileSystemModel-> + index (dir.absolutePath ())); + setCurrentDirectory (dir.absolutePath ()); +} + + +void FilesDockWidget::currentDirectoryEntered () { QFileInfo fileInfo (m_currentDirectory->text ()); @@ -196,3 +226,4 @@ emit activeChanged (false); QDockWidget::closeEvent (event); } + diff -r 80e8c03548a4 gui/src/FilesDockWidget.h --- a/gui/src/FilesDockWidget.h Tue Mar 13 19:11:52 2012 -0400 +++ b/gui/src/FilesDockWidget.h Fri Mar 16 14:23:30 2012 +0530 @@ -45,6 +45,7 @@ /** Slot for handling the up-directory button in the toolbar. */ void onUpDirectory (); + void onNewDirectory (); void setCurrentDirectory (QString currentDirectory); @@ -72,6 +73,10 @@ /** Variables for the up-directory action. */ QIcon m_directoryIcon; QAction *m_directoryUpAction; + + QIcon m_newdirectoryIcon; + QAction *m_newdirectoryUpAction; + QToolButton *upDirectoryButton; /** The file system model. */ @@ -83,3 +88,4 @@ }; #endif // FILESDOCKWIDGET_H + diff -r 80e8c03548a4 gui/src/src.pro --- a/gui/src/src.pro Tue Mar 13 19:11:52 2012 -0400 +++ b/gui/src/src.pro Fri Mar 16 14:23:30 2012 +0530 @@ -90,7 +90,8 @@ backend/OctaveLink.cpp \ backend/OctaveMainThread.cpp \ backend/ReadlineAdapter.cpp \ - WelcomeWizard.cpp + WelcomeWizard.cpp \ + newfolderdialog.cpp HEADERS += \ lexer/lexeroctavegui.h \ @@ -107,8 +108,10 @@ backend/OctaveLink.h \ backend/OctaveMainThread.h \ backend/ReadlineAdapter.h \ - WelcomeWizard.h + WelcomeWizard.h \ + newfolderdialog.h FORMS += \ SettingsDialog.ui \ - WelcomeWizard.ui + WelcomeWizard.ui \ + newfolderdialog.ui