Added the default column_widths as a class attribute instead of a config option.
This commit is contained in:
parent
5c2d3ec96a
commit
36372418ca
@ -28,6 +28,7 @@ from PyQt5.QtCore import pyqtSlot, pyqtSignal, Qt, QItemSelectionModel
|
||||
|
||||
from qutebrowser.config import config, style
|
||||
from qutebrowser.completion import completiondelegate, completer
|
||||
from qutebrowser.completion.models.base import BaseCompletionModel
|
||||
from qutebrowser.utils import qtutils, objreg, utils
|
||||
|
||||
|
||||
@ -100,8 +101,8 @@ class CompletionView(QTreeView):
|
||||
# FIXME handle new aliases.
|
||||
# objreg.get('config').changed.connect(self.init_command_completion)
|
||||
|
||||
self.column_widths = config.get('completion',
|
||||
'base-column-width-percentages')
|
||||
self.column_widths = BaseCompletionModel.COLUMN_WIDTHS
|
||||
|
||||
self._delegate = completiondelegate.CompletionItemDelegate(self)
|
||||
self.setItemDelegate(self._delegate)
|
||||
style.set_register_stylesheet(self)
|
||||
|
@ -27,7 +27,6 @@ from PyQt5.QtCore import Qt
|
||||
from PyQt5.QtGui import QStandardItemModel, QStandardItem
|
||||
|
||||
from qutebrowser.utils import usertypes, qtutils
|
||||
from qutebrowser.config import config
|
||||
|
||||
|
||||
Role = usertypes.enum('Role', ['sort', 'userdata'], start=Qt.UserRole,
|
||||
@ -40,13 +39,17 @@ class BaseCompletionModel(QStandardItemModel):
|
||||
|
||||
Used for showing completions later in the CompletionView. Supports setting
|
||||
marks and adding new categories/items easily.
|
||||
|
||||
Class Attributes:
|
||||
COLUMN_WIDTHS: The width percentages of the columns used in the
|
||||
completion view.
|
||||
"""
|
||||
|
||||
COLUMN_WIDTHS = (20, 70, 10)
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
self.setColumnCount(3)
|
||||
self.column_widths = config.get('completion',
|
||||
'base-column-width-percentages')
|
||||
self.columns_to_filter = [0]
|
||||
|
||||
def new_category(self, name, sort=None):
|
||||
|
@ -39,6 +39,8 @@ class CompletionFilterModel(QSortFilterProxyModel):
|
||||
Kept as attribute because calling `sourceModel` takes quite
|
||||
a long time for some reason.
|
||||
_sort_order: The order to use for sorting if using dumb_sort.
|
||||
column_widths: the width percentages of the columns in the
|
||||
completion view.
|
||||
"""
|
||||
|
||||
def __init__(self, source, parent=None, *, dumb_sort=None):
|
||||
@ -53,7 +55,7 @@ class CompletionFilterModel(QSortFilterProxyModel):
|
||||
else:
|
||||
self.setSortRole(completion.Role.sort)
|
||||
self._sort_order = dumb_sort
|
||||
self.column_widths = source.column_widths
|
||||
self.column_widths = source.COLUMN_WIDTHS
|
||||
|
||||
def set_pattern(self, val):
|
||||
"""Setter for pattern.
|
||||
|
@ -40,6 +40,8 @@ class UrlCompletionModel(base.BaseCompletionModel):
|
||||
TEXT_COLUMN = 1
|
||||
TIME_COLUMN = 2
|
||||
|
||||
COLUMN_WIDTHS = (40, 50, 10)
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
|
||||
@ -75,8 +77,6 @@ class UrlCompletionModel(base.BaseCompletionModel):
|
||||
|
||||
objreg.get('config').changed.connect(self.reformat_timestamps)
|
||||
|
||||
self.column_widths = (40, 50, 10)
|
||||
|
||||
def _fmt_atime(self, atime):
|
||||
"""Format an atime to a human-readable string."""
|
||||
fmt = config.get('completion', 'timestamp-format')
|
||||
|
@ -398,11 +398,6 @@ def data(readonly=False):
|
||||
"Whether to shrink the completion to be smaller than the "
|
||||
"configured size if there are no scrollbars."),
|
||||
|
||||
('base-column-width-percentages',
|
||||
SettingValue(typ.IntList(), '20,70,10'),
|
||||
"List of width percentages of the base completion columns."
|
||||
"These can be overridden by child classes."),
|
||||
|
||||
readonly=readonly
|
||||
)),
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user