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