summaryrefslogtreecommitdiffstats
path: root/filesystemwidget.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'filesystemwidget.cpp')
-rw-r--r--filesystemwidget.cpp16
1 files changed, 15 insertions, 1 deletions
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<QSortFilterProxyModel*>(mFileView->model());
QModelIndexList selected = mFileView->selectionModel()->selectedRows();