summaryrefslogtreecommitdiff
path: root/qutebrowser/mainwindow
diff options
context:
space:
mode:
authorJason Rosenzweig <mail4jasonr@gmail.com>2021-06-03 08:09:00 +0800
committerJason Rosenzweig <mail4jasonr@gmail.com>2021-06-03 08:09:00 +0800
commitf713421b8887f72dd8116054f86575c7607b6a7d (patch)
tree2e46c2c8a42a3c8d4db8cee6b520af482171aefe /qutebrowser/mainwindow
parent17e79ac6679c5b1e8e6afc39e7759939e55464cc (diff)
downloadqutebrowser-f713421b8887f72dd8116054f86575c7607b6a7d.tar.gz
qutebrowser-f713421b8887f72dd8116054f86575c7607b6a7d.zip
Completely reworked the mechanism and it appears to just work
Diffstat (limited to 'qutebrowser/mainwindow')
-rw-r--r--qutebrowser/mainwindow/prompt.py28
1 files changed, 16 insertions, 12 deletions
diff --git a/qutebrowser/mainwindow/prompt.py b/qutebrowser/mainwindow/prompt.py
index cf9230c75..610b274c4 100644
--- a/qutebrowser/mainwindow/prompt.py
+++ b/qutebrowser/mainwindow/prompt.py
@@ -27,8 +27,7 @@ import dataclasses
from typing import Deque, MutableSequence, Optional, cast
from PyQt5.QtCore import (pyqtSlot, pyqtSignal, Qt, QTimer, QDir, QModelIndex,
- QItemSelectionModel, QObject, QEventLoop,
- QSortFilterProxyModel)
+ QItemSelectionModel, QObject, QEventLoop)
from PyQt5.QtWidgets import (QWidget, QGridLayout, QVBoxLayout, QLineEdit,
QLabel, QFileSystemModel, QTreeView, QSizePolicy,
QSpacerItem)
@@ -640,8 +639,6 @@ class FilenamePrompt(_BasePrompt):
dirname = os.path.dirname(path)
basename = os.path.basename(path)
-
- orig_path = path
if not tabbed:
self._to_complete = ''
@@ -664,12 +661,21 @@ class FilenamePrompt(_BasePrompt):
log.prompt.exception("Failed to get directory information")
return
- self._file_model.setRootPath(path)
- self._proxy_file_model.setSourceModel(self._file_model)
- self._file_view.setRootIndex(self._proxy_file_model.mapFromSource(self._file_model.index(path)))
- modpath = orig_path[orig_path.rindex('/')+1:]
+ root = self._file_model.setRootPath(path)
+ self._file_view.setRootIndex(root)
+
+ # Iterate over all directories in the current root path to see if the input is a substring
+ for currentDir in os.listdir(path):
+ currentDir = os.path.join(path, currentDir)
+
+ if basename not in os.path.basename(currentDir):
+ index = self._file_model.index(currentDir)
+ self._file_view.setRowHidden(index.row(), index.parent(), True)
+ else:
+ index = self._file_model.index(currentDir)
+ self._file_view.setRowHidden(index.row(), index.parent(), False)
- self._proxy_file_model.setFilterWildcard('*{}*'.format(modpath))
+ self._file_view.setModel(self._file_model)
@pyqtSlot(QModelIndex)
def _insert_path(self, index, *, clicked=True):
@@ -701,9 +707,7 @@ class FilenamePrompt(_BasePrompt):
def _init_fileview(self):
self._file_view = QTreeView(self)
self._file_model = QFileSystemModel(self)
- self._proxy_file_model = QSortFilterProxyModel()
- self._proxy_file_model.setSourceModel(self._file_model)
- self._file_view.setModel(self._proxy_file_model)
+ self._file_view.setModel(self._file_model)
self._file_view.clicked.connect(self._insert_path)
if config.val.prompt.filebrowser: