diff --git a/qutebrowser/models/basecompletion.py b/qutebrowser/models/basecompletion.py index 49e3f5b97..b6e6f95b7 100644 --- a/qutebrowser/models/basecompletion.py +++ b/qutebrowser/models/basecompletion.py @@ -18,13 +18,16 @@ """The base completion model for completion in the command line. Module attributes: - ROLE_MARKS: The role index used for marks. + Role: An enum of user defined model roles. """ from PyQt5.QtCore import Qt from PyQt5.QtGui import QStandardItemModel, QStandardItem -ROLE_MARKS = Qt.UserRole +from qutebrowser.utils.usertypes import enum + + +Role = enum('marks', 'sort', start=Qt.UserRole) class NoCompletionsError(Exception): @@ -77,7 +80,7 @@ class BaseCompletionModel(QStandardItemModel): """ haystack = self.data(index) marks = self._get_marks(needle, haystack) - self.setData(index, marks, ROLE_MARKS) + self.setData(index, marks, Role.marks) def new_category(self, name): """Add a new category to the model. diff --git a/qutebrowser/widgets/completion.py b/qutebrowser/widgets/completion.py index ba5e3f5fb..24788da4f 100644 --- a/qutebrowser/widgets/completion.py +++ b/qutebrowser/widgets/completion.py @@ -38,7 +38,7 @@ class CompletionView(QTreeView): Based on QTreeView but heavily customized so root elements show as category headers, and children show as flat list. - Highlights completions based on marks in the ROLE_MARKS data. + Highlights completions based on marks in the Role.marks data. Class attributes: STYLESHEET: The stylesheet template for the CompletionView. diff --git a/qutebrowser/widgets/completiondelegate.py b/qutebrowser/widgets/completiondelegate.py index 6760f5184..833fb87d5 100644 --- a/qutebrowser/widgets/completiondelegate.py +++ b/qutebrowser/widgets/completiondelegate.py @@ -27,7 +27,7 @@ from PyQt5.QtGui import (QIcon, QPalette, QTextDocument, QTextOption, QTextCursor, QColor, QAbstractTextDocumentLayout) import qutebrowser.config.config as config -from qutebrowser.models.basecompletion import ROLE_MARKS +from qutebrowser.models.basecompletion import Role from qutebrowser.config.style import get_stylesheet @@ -188,7 +188,7 @@ class CompletionItemDelegate(QStyledItemDelegate): self._doc.setDocumentMargin(2) if index.column() == 0: - marks = index.data(ROLE_MARKS) + marks = index.data(Role.marks) if marks is None: return for mark in marks: