diff options
author | Andrew MacFie <amacfie@sent.com> | 2021-01-19 14:17:37 -0500 |
---|---|---|
committer | Andrew MacFie <amacfie@sent.com> | 2021-01-19 14:17:37 -0500 |
commit | 907b41e9ff8e7a3b09335c6a290d9124da66c0aa (patch) | |
tree | cab9e4185bcc01e9e2c06821857a2eef5876e0e8 /qutebrowser/completion/models/filepathcategory.py | |
parent | 51343a432bb39556aec68129e7ac1585ee50ac9b (diff) | |
download | qutebrowser-907b41e9ff8e7a3b09335c6a290d9124da66c0aa.tar.gz qutebrowser-907b41e9ff8e7a3b09335c6a290d9124da66c0aa.zip |
Fix method implementation
Diffstat (limited to 'qutebrowser/completion/models/filepathcategory.py')
-rw-r--r-- | qutebrowser/completion/models/filepathcategory.py | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/qutebrowser/completion/models/filepathcategory.py b/qutebrowser/completion/models/filepathcategory.py index d086e2d8b..8c25f3584 100644 --- a/qutebrowser/completion/models/filepathcategory.py +++ b/qutebrowser/completion/models/filepathcategory.py @@ -20,9 +20,9 @@ import glob import os from pathlib import Path -from typing import List +from typing import Any, List -from PyQt5.QtCore import QAbstractListModel, QModelIndex, QObject, QUrl +from PyQt5.QtCore import QAbstractListModel, QModelIndex, QObject, Qt, QUrl class FilePathCategory(QAbstractListModel): @@ -55,9 +55,8 @@ class FilePathCategory(QAbstractListModel): if os.path.isabs(expanded): glob_str = glob.escape(expanded) + '*' expanded_paths = sorted(glob.glob(glob_str)) - - head = Path(val).parts[0] # if ~ or ~user was expanded, contract it in `_paths` + head = Path(val).parts[0] if head.startswith('~'): self._paths = [_contractuser(expanded_path, head) for expanded_path in expanded_paths] @@ -66,12 +65,14 @@ class FilePathCategory(QAbstractListModel): else: self._paths = [] - def data(self, index: QModelIndex) -> str: + def data( + self, index: QModelIndex, role: int = Qt.ItemDataRole.DisplayRole + ) -> Any: """Implement abstract method in QAbstractListModel.""" - if index.column() == 0: + if role == Qt.DisplayRole and index.column() == 0: return self._paths[index.row()] else: - return '' + return None def rowCount(self, parent: QModelIndex = QModelIndex()) -> int: """Implement abstract method in QAbstractListModel.""" |