Add a misc column to models.
This commit is contained in:
parent
fb24bcf016
commit
35006bd246
@ -44,7 +44,7 @@ class BaseCompletionModel(QStandardItemModel):
|
|||||||
|
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
self.setColumnCount(2)
|
self.setColumnCount(3)
|
||||||
|
|
||||||
def _get_marks(self, needle, haystack):
|
def _get_marks(self, needle, haystack):
|
||||||
"""Return the marks for needle in haystack.
|
"""Return the marks for needle in haystack.
|
||||||
@ -95,19 +95,29 @@ class BaseCompletionModel(QStandardItemModel):
|
|||||||
self.appendRow(cat)
|
self.appendRow(cat)
|
||||||
return cat
|
return cat
|
||||||
|
|
||||||
def new_item(self, cat, name, desc=''):
|
def new_item(self, cat, name, desc='', misc=None):
|
||||||
"""Add a new item to a category.
|
"""Add a new item to a category.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
cat: The parent category.
|
cat: The parent category.
|
||||||
name: The name of the item.
|
name: The name of the item.
|
||||||
desc: The description of the item.
|
desc: The description of the item.
|
||||||
|
misc: Misc text to display.
|
||||||
|
|
||||||
|
Return:
|
||||||
|
A (nameitem, descitem, miscitem) tuple.
|
||||||
"""
|
"""
|
||||||
nameitem = QStandardItem(name)
|
nameitem = QStandardItem(name)
|
||||||
descitem = QStandardItem(desc)
|
descitem = QStandardItem(desc)
|
||||||
|
if misc is None:
|
||||||
|
miscitem = QStandardItem()
|
||||||
|
else:
|
||||||
|
miscitem = QStandardItem(misc)
|
||||||
idx = cat.rowCount()
|
idx = cat.rowCount()
|
||||||
cat.setChild(idx, 0, nameitem)
|
cat.setChild(idx, 0, nameitem)
|
||||||
cat.setChild(idx, 1, descitem)
|
cat.setChild(idx, 1, descitem)
|
||||||
|
cat.setChild(idx, 2, miscitem)
|
||||||
|
return nameitem, descitem, miscitem
|
||||||
|
|
||||||
def flags(self, index):
|
def flags(self, index):
|
||||||
"""Return the item flags for index.
|
"""Return the item flags for index.
|
||||||
|
@ -40,12 +40,17 @@ class SettingSectionCompletionModel(BaseCompletionModel):
|
|||||||
|
|
||||||
class SettingOptionCompletionModel(BaseCompletionModel):
|
class SettingOptionCompletionModel(BaseCompletionModel):
|
||||||
|
|
||||||
"""A CompletionModel filled with settings and their descriptions."""
|
"""A CompletionModel filled with settings and their descriptions.
|
||||||
|
|
||||||
|
Attributes:
|
||||||
|
misc_items: A dict of the misc. column items which will be set later.
|
||||||
|
"""
|
||||||
|
|
||||||
# pylint: disable=abstract-method
|
# pylint: disable=abstract-method
|
||||||
|
|
||||||
def __init__(self, section, parent=None):
|
def __init__(self, section, parent=None):
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
|
self.misc_items = {}
|
||||||
cat = self.new_category("Config options for {}".format(section))
|
cat = self.new_category("Config options for {}".format(section))
|
||||||
sectdata = configdata.DATA[section]
|
sectdata = configdata.DATA[section]
|
||||||
for name, _ in sectdata.items():
|
for name, _ in sectdata.items():
|
||||||
@ -53,7 +58,11 @@ class SettingOptionCompletionModel(BaseCompletionModel):
|
|||||||
desc = sectdata.descriptions[name]
|
desc = sectdata.descriptions[name]
|
||||||
except (KeyError, AttributeError):
|
except (KeyError, AttributeError):
|
||||||
desc = ""
|
desc = ""
|
||||||
self.new_item(cat, name, desc)
|
value = config.get(section, name, raw=True)
|
||||||
|
_valitem, _descitem, miscitem = self.new_item(cat, name, desc,
|
||||||
|
value)
|
||||||
|
self.misc_items[section] = {}
|
||||||
|
self.misc_items[section][name] = miscitem
|
||||||
|
|
||||||
|
|
||||||
class SettingValueCompletionModel(BaseCompletionModel):
|
class SettingValueCompletionModel(BaseCompletionModel):
|
||||||
|
Loading…
Reference in New Issue
Block a user