Ctrl-H shortcut to toggle hidden files' visibility
[case] / src / filelist.cpp
index ad822de..3d9c8c4 100644 (file)
@@ -75,11 +75,21 @@ bool FileList::goUp() {
 }
 
 
+void FileList::toggleShowHiddenFiles() {
+    clearSelection();
+    scrollToTop();
+    fileSystemModel->setFilter(fileSystemModel->filter() ^ QDir::Hidden);
+}
+
+
 void FileList::activateItem(QModelIndex index) {
     const QFileInfo &file = fileSystemModel->fileInfo(index);
 
     if(file.isDir()) {
         changePath(file.absoluteFilePath());
+        // hack: we reset it to MultiSelection again in the mousePressEvent
+        // without this, the item under the cursor gets selected right after changing the directory
+        setSelectionMode(QAbstractItemView::NoSelection);
     } else if(file.isExecutable()) {
         QProcess::startDetached(file.absoluteFilePath());
     } else {
@@ -98,4 +108,6 @@ void FileList::activateItem(QModelIndex index) {
 void FileList::mousePressEvent(QMouseEvent *event) {
     emit mousePressed();
     QListView::mousePressEvent(event);
+    // need to reset the selection mode in case it was set to NoSelection in activateItem(...)
+    setSelectionMode(QAbstractItemView::MultiSelection);
 }