From d12d44cd511b76181859736fb60598a3ad7e3d0f Mon Sep 17 00:00:00 2001 From: Arno Date: Sun, 7 Nov 2010 11:46:42 +0100 Subject: Added Toobar Implemented a toolbar with various actions. Also did some artwork :) --- filesystemwidget.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'filesystemwidget.cpp') diff --git a/filesystemwidget.cpp b/filesystemwidget.cpp index 52aede8..5d63aef 100644 --- a/filesystemwidget.cpp +++ b/filesystemwidget.cpp @@ -107,11 +107,15 @@ FilesystemWidget::FilesystemWidget(QWidget *parent) : QWidget(parent) { setLayout(mainLayout); } -void FilesystemWidget::directoryChanged(const QModelIndex &selected, const QModelIndex & /* deselected */){ +void FilesystemWidget::directoryChanged(const QModelIndex &selected, const QModelIndex &deselected){ QModelIndex real = mDirProxy->mapToSource(selected); if(!real.isValid()){ return; } + QModelIndex realPrev = mDirProxy->mapToSource(deselected); + if(realPrev.isValid()){ + mLastDir = realPrev.data(QFileSystemModel::FilePathRole).toString(); + } mModel->setRootPath(mModel->filePath(real)); mDirEdit->setText(mModel->filePath(real)); setWindowTitle(mModel->filePath(real)); @@ -170,6 +174,16 @@ void FilesystemWidget::parentDir(){ } } +void FilesystemWidget::goBack(){ + if(mLastDir.isEmpty()){ + return; + } + QModelIndex lastIdx = mModel->index(mLastDir); + if(lastIdx.isValid()){ + mDirView->selectionModel()->setCurrentIndex(mDirProxy->mapFromSource(lastIdx), QItemSelectionModel::ClearAndSelect); + } +} + void FilesystemWidget::deleteFiles(){ QSortFilterProxyModel *proxy = static_cast(mFileView->model()); QModelIndexList selected = mFileView->selectionModel()->selectedRows(); -- cgit v1.2.3-70-g09d2