mirror of
https://github.com/SELinuxProject/setools
synced 2025-04-23 23:55:18 +00:00
The table model can handle lists as a single/first column. Signed-off-by: Chris PeBenito <pebenito@ieee.org>
37 lines
912 B
Python
37 lines
912 B
Python
# Copyright 2016, Tresys Technology, LLC
|
|
#
|
|
# SPDX-License-Identifier: LGPL-2.1-only
|
|
#
|
|
#
|
|
from PyQt5 import QtCore
|
|
import setools
|
|
|
|
from .table import SEToolsTableModel
|
|
|
|
__all__ = ("CommonTable",)
|
|
|
|
|
|
class CommonTable(SEToolsTableModel[setools.Common]):
|
|
|
|
"""Table-based model for common permission sets."""
|
|
|
|
headers = ["Name", "Permissions"]
|
|
|
|
def data(self, index: QtCore.QModelIndex, role: int = QtCore.Qt.ItemDataRole.DisplayRole):
|
|
if not self.item_list or not index.isValid():
|
|
return None
|
|
|
|
row = index.row()
|
|
col = index.column()
|
|
item = self.item_list[row]
|
|
|
|
match role:
|
|
case QtCore.Qt.ItemDataRole.DisplayRole:
|
|
match col:
|
|
case 0:
|
|
return item.name
|
|
case 1:
|
|
return ", ".join(sorted(item.perms))
|
|
|
|
return super().data(index, role)
|